From dffce63662c54db7ebb61786d39db6a900d1381f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 21:49:26 -0700 Subject: implement republish permission for use in sourced channels --- boot.php | 36 ++++++++++++++++++------------------ include/Contact.php | 3 ++- include/items.php | 11 +++++++++++ include/permissions.php | 1 + install/database.sql | 2 ++ install/update.php | 10 +++++++++- mod/settings.php | 40 ++++++++++++++++++++++------------------ view/js/mod_connections.js | 3 +++ 8 files changed, 68 insertions(+), 38 deletions(-) diff --git a/boot.php b/boot.php index 3bdd33aeb..8e3a98454 100755 --- a/boot.php +++ b/boot.php @@ -45,7 +45,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1075 ); +define ( 'DB_UPDATE_VERSION', 1076 ); define ( 'EOL', '
' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -228,26 +228,26 @@ define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder */ -define ( 'PERMS_R_STREAM', 0x0001); -define ( 'PERMS_R_PROFILE', 0x0002); -define ( 'PERMS_R_PHOTOS', 0x0004); -define ( 'PERMS_R_ABOOK', 0x0008); +define ( 'PERMS_R_STREAM', 0x00001); +define ( 'PERMS_R_PROFILE', 0x00002); +define ( 'PERMS_R_PHOTOS', 0x00004); +define ( 'PERMS_R_ABOOK', 0x00008); -define ( 'PERMS_W_STREAM', 0x0010); -define ( 'PERMS_W_WALL', 0x0020); -define ( 'PERMS_W_TAGWALL', 0x0040); -define ( 'PERMS_W_COMMENT', 0x0080); -define ( 'PERMS_W_MAIL', 0x0100); -define ( 'PERMS_W_PHOTOS', 0x0200); -define ( 'PERMS_W_CHAT', 0x0400); -define ( 'PERMS_A_DELEGATE', 0x0800); - -define ( 'PERMS_R_STORAGE', 0x1000); -define ( 'PERMS_W_STORAGE', 0x2000); -define ( 'PERMS_R_PAGES', 0x4000); -define ( 'PERMS_W_PAGES', 0x8000); +define ( 'PERMS_W_STREAM', 0x00010); +define ( 'PERMS_W_WALL', 0x00020); +define ( 'PERMS_W_TAGWALL', 0x00040); +define ( 'PERMS_W_COMMENT', 0x00080); +define ( 'PERMS_W_MAIL', 0x00100); +define ( 'PERMS_W_PHOTOS', 0x00200); +define ( 'PERMS_W_CHAT', 0x00400); +define ( 'PERMS_A_DELEGATE', 0x00800); +define ( 'PERMS_R_STORAGE', 0x01000); +define ( 'PERMS_W_STORAGE', 0x02000); +define ( 'PERMS_R_PAGES', 0x04000); +define ( 'PERMS_W_PAGES', 0x08000); +define ( 'PERMS_A_REPUBLISH', 0x10000); // General channel permissions diff --git a/include/Contact.php b/include/Contact.php index b9e879bcf..46c84aab6 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -219,7 +219,8 @@ function channel_remove($channel_id, $local = true) { $r = q("update channel set channel_pageflags = (channel_pageflags | %d), channel_r_stream = 0, channel_r_profile = 0, channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0, channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0, - channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0 where channel_id = %d limit 1", + channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0, channel_a_republish = 0 + where channel_id = %d limit 1", intval(PAGE_REMOVED), intval($channel_id) ); diff --git a/include/items.php b/include/items.php index dcd9eb6fc..18736f974 100755 --- a/include/items.php +++ b/include/items.php @@ -2308,6 +2308,17 @@ function check_item_source($uid,$item) { if(! $r) return false; + $x = q("select abook_their_perms from abook where abook_channel = %d and abook_xchan = '%s' limit 1", + intval($uid), + dbesc($item['owner_xchan']) + ); + + if(! $x) + return false; + + if(! ($x[0]['abook_their_perms'] & PERMS_A_REPUBLISH)) + return false; + if($r[0]['src_channel_xchan'] === $item['owner_xchan']) return false; diff --git a/include/permissions.php b/include/permissions.php index bf50ebdd1..45ea7c3eb 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -28,6 +28,7 @@ function get_perms() { 'write_storage' => array('channel_w_storage', intval(PERMS_W_STORAGE), false, t('Can write to my "public" file storage'), ''), 'write_pages' => array('channel_w_pages', intval(PERMS_W_PAGES), false, t('Can edit my "public" pages'), ''), + 'republish' => array('channel_a_republish', intval(PERMS_A_REPUBLISH), false, t('Can source my "public" posts in derived channels'), t('Somewhat advanced - very useful in open communities')), 'delegate' => array('channel_a_delegate', intval(PERMS_A_DELEGATE), false, t('Can administer my channel resources'), t('Extremely advanced. Leave this alone unless you know what you are doing')), ); $ret = array('global_permissions' => $global_perms); diff --git a/install/database.sql b/install/database.sql index 77070027c..eb573fb4d 100644 --- a/install/database.sql +++ b/install/database.sql @@ -181,6 +181,7 @@ CREATE TABLE IF NOT EXISTS `channel` ( `channel_w_storage` int(10) unsigned NOT NULL DEFAULT '128', `channel_r_pages` int(10) unsigned NOT NULL DEFAULT '128', `channel_w_pages` int(10) unsigned NOT NULL DEFAULT '128', + `channel_a_republish` int(1) unsigned NOT NULL DEFAULT '128', PRIMARY KEY (`channel_id`), UNIQUE KEY `channel_address_unique` (`channel_address`), KEY `channel_account_id` (`channel_account_id`), @@ -213,6 +214,7 @@ CREATE TABLE IF NOT EXISTS `channel` ( KEY `channel_w_storage` (`channel_w_storage`), KEY `channel_r_pages` (`channel_r_pages`), KEY `channel_w_pages` (`channel_w_pages`), + KEY `channel_a_republish` (`channel_a_republish`), KEY `channel_deleted` (`channel_deleted`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/install/update.php b/install/update.php index 5c46538cf..8a583a947 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@