We will need a per item comment policy to be able to determine in advance if we have permission to comment on something , and we'll need to send it out with all communications. The current check is not only flawed but also a huge performance hit. Also provide the ability for an item to disable commenting completely - such as for a webpage or wherever you want to prevent comments on one item, without requiring a change to your entire permission scheme. All of this is only partially implemented at the moment but we need the structures in place on several sites in order to finish it without breaking everything.

This commit is contained in:
friendica 2013-06-16 19:14:01 -07:00
parent 99252d65bf
commit 764ee785f5
4 changed files with 24 additions and 5 deletions

View File

@ -41,7 +41,7 @@ require_once('include/features.php');
define ( 'RED_PLATFORM', 'Red Matrix' ); define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 ); define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1043 ); define ( 'DB_UPDATE_VERSION', 1044 );
define ( 'EOL', '<br />' . "\r\n" ); define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
@ -436,6 +436,7 @@ define ( 'ITEM_NOTSHOWN', 0x0080); // technically visible but not normal
define ( 'ITEM_NSFW', 0x0100); define ( 'ITEM_NSFW', 0x0100);
define ( 'ITEM_RELAY', 0x0200); // used only in the communication layers, not stored define ( 'ITEM_RELAY', 0x0200); // used only in the communication layers, not stored
define ( 'ITEM_MENTIONSME', 0x0400); define ( 'ITEM_MENTIONSME', 0x0400);
define ( 'ITEM_NOCOMMENT', 0x0800); // commenting/followups are disabled
/** /**

View File

@ -549,13 +549,17 @@ function encode_item($item) {
intval($item['uid']) intval($item['uid'])
); );
if($r) if($r) {
$public_scope = $r[0]['channel_r_stream']; $public_scope = $r[0]['channel_r_stream'];
else $comment_scope = $r[0]['channel_w_comment'];
}
else {
$public_scope = 0; $public_scope = 0;
$comment_scope = 0;
}
$scope = map_scope($public_scope); $scope = map_scope($public_scope);
$c_scope = map_scope($comment_scope);
if($item['item_restrict'] & ITEM_DELETED) { if($item['item_restrict'] & ITEM_DELETED) {
$x['message_id'] = $item['mid']; $x['message_id'] = $item['mid'];
@ -597,6 +601,11 @@ function encode_item($item) {
if(! in_array('private',$y)) if(! in_array('private',$y))
$x['public_scope'] = $scope; $x['public_scope'] = $scope;
if($item['item_flags'] & ITEM_NOCOMMENT)
$x['comment_scope'] = 'none';
else
$x['comment_scope'] = $c_scope;
if($item['term']) if($item['term'])
$x['tags'] = encode_item_terms($item['term']); $x['tags'] = encode_item_terms($item['term']);

View File

@ -462,6 +462,7 @@ CREATE TABLE IF NOT EXISTS `item` (
`inform` mediumtext NOT NULL, `inform` mediumtext NOT NULL,
`location` char(255) NOT NULL DEFAULT '', `location` char(255) NOT NULL DEFAULT '',
`coord` char(255) NOT NULL DEFAULT '', `coord` char(255) NOT NULL DEFAULT '',
`comment_policy` char(255) NOT NULL DEFAULT '',
`allow_cid` mediumtext NOT NULL, `allow_cid` mediumtext NOT NULL,
`allow_gid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL,
`deny_cid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL,
@ -494,6 +495,7 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `mid` (`mid`), KEY `mid` (`mid`),
KEY `parent_mid` (`parent_mid`), KEY `parent_mid` (`parent_mid`),
KEY `uid_mid` (`mid`,`uid`), KEY `uid_mid` (`mid`,`uid`),
KEY `comment_policy` (`comment_policy`),
FULLTEXT KEY `title` (`title`), FULLTEXT KEY `title` (`title`),
FULLTEXT KEY `body` (`body`), FULLTEXT KEY `body` (`body`),
FULLTEXT KEY `allow_cid` (`allow_cid`), FULLTEXT KEY `allow_cid` (`allow_cid`),

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1043 ); define( 'UPDATE_VERSION' , 1044 );
/** /**
* *
@ -541,3 +541,10 @@ ADD `hubloc_connected` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', ADD IND
} }
function update_r1043() {
$r = q("ALTER TABLE `item` ADD `comment_policy` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `coord` ,
ADD INDEX ( `comment_policy` ) ");
if($r)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}