diff options
author | friendica <info@friendica.com> | 2013-09-30 21:49:26 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-09-30 21:49:26 -0700 |
commit | dffce63662c54db7ebb61786d39db6a900d1381f (patch) | |
tree | 88004c4a8362f4ee77bf670207076f76d876eb84 | |
parent | 2353e6d23f54902d3b2b9e3fd46f1baa6e803450 (diff) | |
download | volse-hubzilla-dffce63662c54db7ebb61786d39db6a900d1381f.tar.gz volse-hubzilla-dffce63662c54db7ebb61786d39db6a900d1381f.tar.bz2 volse-hubzilla-dffce63662c54db7ebb61786d39db6a900d1381f.zip |
implement republish permission for use in sourced channels
-rwxr-xr-x | boot.php | 36 | ||||
-rw-r--r-- | include/Contact.php | 3 | ||||
-rwxr-xr-x | include/items.php | 11 | ||||
-rw-r--r-- | include/permissions.php | 1 | ||||
-rw-r--r-- | install/database.sql | 2 | ||||
-rw-r--r-- | install/update.php | 10 | ||||
-rw-r--r-- | mod/settings.php | 40 | ||||
-rw-r--r-- | view/js/mod_connections.js | 3 |
8 files changed, 68 insertions, 38 deletions
@@ -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', '<br />' . "\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 @@ <?php -define( 'UPDATE_VERSION' , 1075 ); +define( 'UPDATE_VERSION' , 1076 ); /** * @@ -851,3 +851,11 @@ ADD INDEX ( `ud_last` ) "); } +function update_r1075() { + $r = q("ALTER TABLE `channel` ADD `channel_a_republish` INT UNSIGNED NOT NULL DEFAULT '128', +ADD INDEX ( `channel_a_republish` )"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} diff --git a/mod/settings.php b/mod/settings.php index cc8fd2564..ba2323873 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -377,23 +377,24 @@ function settings_post(&$a) { $pageflags = ($pageflags ^ PAGE_ADULT); $arr = array(); - $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0); - $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0); - $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0); - $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0); - $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0); - $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0); - $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0); - $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0); - $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0); - $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0); - $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0); - $arr['channel_a_delegate'] = (($_POST['delegate']) ? $_POST['delegate'] : 0); - $arr['channel_r_storage'] = (($_POST['view_storage']) ? $_POST['view_storage'] : 0); - $arr['channel_w_storage'] = (($_POST['write_storage']) ? $_POST['write_storage'] : 0); - $arr['channel_r_pages'] = (($_POST['view_pages']) ? $_POST['view_pages'] : 0); - $arr['channel_w_pages'] = (($_POST['write_pages']) ? $_POST['write_pages'] : 0); - + $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0); + $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0); + $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0); + $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0); + $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0); + $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0); + $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0); + $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0); + $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0); + $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0); + $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0); + $arr['channel_a_delegate'] = (($_POST['delegate']) ? $_POST['delegate'] : 0); + $arr['channel_r_storage'] = (($_POST['view_storage']) ? $_POST['view_storage'] : 0); + $arr['channel_w_storage'] = (($_POST['write_storage']) ? $_POST['write_storage'] : 0); + $arr['channel_r_pages'] = (($_POST['view_pages']) ? $_POST['view_pages'] : 0); + $arr['channel_w_pages'] = (($_POST['write_pages']) ? $_POST['write_pages'] : 0); + $arr['channel_a_republish'] = (($_POST['republish']) ? $_POST['republish'] : 0); + $defperms = 0; if(x($_POST['def_view_stream'])) $defperms += $_POST['def_view_stream']; @@ -427,6 +428,8 @@ function settings_post(&$a) { $defperms += $_POST['def_view_pages']; if(x($_POST['def_write_pages'])) $defperms += $_POST['def_write_pages']; + if(x($_POST['def_republish'])) + $defperms += $_POST['def_republish']; $notify = 0; @@ -531,7 +534,7 @@ function settings_post(&$a) { ); */ - $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d, channel_r_stream = %d, channel_r_profile = %d, channel_r_photos = %d, channel_r_abook = %d, channel_w_stream = %d, channel_w_wall = %d, channel_w_tagwall = %d, channel_w_comment = %d, channel_w_mail = %d, channel_w_photos = %d, channel_w_chat = %d, channel_a_delegate = %d, channel_r_storage = %d, channel_w_storage = %d, channel_r_pages = %d, channel_w_pages = %d where channel_id = %d limit 1", + $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d, channel_r_stream = %d, channel_r_profile = %d, channel_r_photos = %d, channel_r_abook = %d, channel_w_stream = %d, channel_w_wall = %d, channel_w_tagwall = %d, channel_w_comment = %d, channel_w_mail = %d, channel_w_photos = %d, channel_w_chat = %d, channel_a_delegate = %d, channel_r_storage = %d, channel_w_storage = %d, channel_r_pages = %d, channel_w_pages = %d, channel_a_republish = %d where channel_id = %d limit 1", dbesc($username), intval($pageflags), dbesc($timezone), @@ -556,6 +559,7 @@ function settings_post(&$a) { intval($arr['channel_w_storage']), intval($arr['channel_r_pages']), intval($arr['channel_w_pages']), + intval($arr['channel_a_republish']), intval(local_user()) ); diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js index 6bfa039a8..ed1577792 100644 --- a/view/js/mod_connections.js +++ b/view/js/mod_connections.js @@ -38,6 +38,7 @@ function connectFullShare() { $('#me_id_perms_post_mail').attr('checked','checked'); $('#me_id_perms_chat').attr('checked','checked'); $('#me_id_perms_view_storage').attr('checked','checked'); + $('#me_id_perms_republish').attr('checked','checked'); } function connectCautiousShare() { @@ -73,6 +74,8 @@ function connectForum() { $('#me_id_perms_post_comments').attr('checked','checked'); $('#me_id_perms_post_mail').attr('checked','checked'); $('#me_id_perms_tag_deliver').attr('checked','checked'); + $('#me_id_perms_republish').attr('checked','checked'); + } function connectSoapBox() { |