summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controllers/controllers.php1
-rw-r--r--controllers/micropub.php2
-rw-r--r--lib/helpers.php5
-rw-r--r--schema/migrations/0007.sql2
-rw-r--r--schema/mysql.sql1
-rw-r--r--schema/sqlite.sql3
-rw-r--r--views/new-post.php30
7 files changed, 41 insertions, 3 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index 2cbe56e..bf1cb86 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -72,6 +72,7 @@ $app->get('/new', function() use($app) {
'micropub_access_token' => $user->micropub_access_token,
'response_date' => $user->last_micropub_response_date,
'syndication_targets' => json_decode($user->syndication_targets, true),
+ 'supported_visibility' => json_decode($user->supported_visibility, true),
'location_enabled' => $user->location_enabled,
'user' => $user,
'authorizing' => false
diff --git a/controllers/micropub.php b/controllers/micropub.php
index a6ec9d5..fa8e477 100644
--- a/controllers/micropub.php
+++ b/controllers/micropub.php
@@ -2,7 +2,7 @@
$app->get('/micropub/syndications', function() use($app) {
if($user=require_login($app)) {
- $data = get_micropub_config($user, ['q'=>'syndicate-to']);
+ $data = get_micropub_config($user);
$app->response()['Content-type'] = 'application/json';
$app->response()->body(json_encode(array(
'targets' => $data['targets'],
diff --git a/lib/helpers.php b/lib/helpers.php
index 7dca36d..57e3374 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -298,6 +298,7 @@ function get_micropub_config(&$user, $query=[]) {
// Reset the values so they can be overwritten
$user->syndication_targets = '';
$user->supported_post_types = '';
+ $user->supported_visibility = '';
$user->micropub_media_endpoint = '';
if(count($targets))
@@ -316,6 +317,10 @@ function get_micropub_config(&$user, $query=[]) {
}
}
+ if(isset($r['data']['visibility']) && is_array($r['data']['visibility'])) {
+ $user->supported_visibility = json_encode($r['data']['visibility']);
+ }
+
$user->save();
return [
diff --git a/schema/migrations/0007.sql b/schema/migrations/0007.sql
new file mode 100644
index 0000000..2d51a15
--- /dev/null
+++ b/schema/migrations/0007.sql
@@ -0,0 +1,2 @@
+ALTER TABLE users
+ADD COLUMN `supported_visibility` LONGTEXT;
diff --git a/schema/mysql.sql b/schema/mysql.sql
index bbe0dd4..1007256 100644
--- a/schema/mysql.sql
+++ b/schema/mysql.sql
@@ -25,5 +25,6 @@ CREATE TABLE `users` (
`email_username` varchar(255) DEFAULT NULL,
`default_timezone` varchar(255) DEFAULT NULL,
`supported_post_types` longtext,
+ `supported_visibility` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/schema/sqlite.sql b/schema/sqlite.sql
index 8eaa7b0..37365cd 100644
--- a/schema/sqlite.sql
+++ b/schema/sqlite.sql
@@ -24,5 +24,6 @@ CREATE TABLE users (
instagram_access_token TEXT,
email_username TEXT,
default_timezone TEXT,
- supported_post_types TEXT
+ supported_post_types TEXT,
+ supported_visibility TEXT
);
diff --git a/views/new-post.php b/views/new-post.php
index aba4129..dad9427 100644
--- a/views/new-post.php
+++ b/views/new-post.php
@@ -79,8 +79,23 @@
<?php endif ?>
+ <?php if($this->supported_visibility): ?>
+ <div class="form-group" style="margin-top: 1em;">
+ <label for="visibility">Visibility</label>
+ <select class="form-control" id="visibility">
+ <?php
+ foreach(['Public','Unlisted','Private'] as $v):
+ if(in_array(strtolower($v), $this->supported_visibility)):
+ echo '<option value="'.strtolower($v).'">'.$v.'</option>';
+ endif;
+ endforeach;
+ ?>
+ </select>
+ </div>
+ <?php endif ?>
+
<?php if($this->syndication_targets): ?>
- <div class="form-group" style="margin-top: 1em;">
+ <div id="syndication-targets" class="form-group" style="margin-top: 1em;">
<label for="note_syndicate-to">Syndicate <a href="javascript:reload_syndications()">(refresh list)</a></label>
<div id="syndication-container">
<?php
@@ -562,6 +577,14 @@ $(function(){
}
});
+ $("#visibility").on('change', function(e){
+ if($(this).val() == 'private') {
+ $("#syndication-targets").addClass('hidden');
+ } else {
+ $("#syndication-targets").removeClass('hidden');
+ }
+ });
+
$("#expand-reply").click(function(){
$('.reply-section').removeClass('hidden');
$(this).addClass('hidden');
@@ -740,6 +763,11 @@ $(function(){
entry["rsvp"] = $("#note_rsvp").val();
}
+ if($("#visibility").val()) {
+ formData.append("visibility", $("#visibility").val());
+ entry["visibility"] = $("#visibility").val();
+ }
+
function appendPhotoToFormData(photo, prop) {
if(photo.external) {
if(photo.alt) {