X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FNotice.php;h=48d4a094029f942346551e77265b191d181935b1;hb=b2664e1ae2e2cf66585cdd8696d88efdd053eb3b;hp=442eb00fdb2333de84025cee7f1c5e2241e30108;hpb=9f07921b45190b462e1a798622068e24ef31e124;p=quix0rs-gnu-social.git diff --git a/classes/Notice.php b/classes/Notice.php index 442eb00fdb..48d4a09402 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -40,7 +40,7 @@ class Notice extends Memcached_DataObject public $id; // int(4) primary_key not_null public $profile_id; // int(4) not_null public $uri; // varchar(255) unique_key - public $content; // varchar(140) + public $content; // text() public $rendered; // text() public $url; // varchar(255) public $created; // datetime() not_null @@ -51,9 +51,7 @@ class Notice extends Memcached_DataObject public $conversation; // int(4) /* Static get */ - function staticGet($k,$v=NULL) { - return Memcached_DataObject::staticGet('Notice',$k,$v); - } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE @@ -75,7 +73,21 @@ class Notice extends Memcached_DataObject $this->blowFavesCache(true); $this->blowSubsCache(true); + // For auditing purposes, save a record that the notice + // was deleted. + + $deleted = new Deleted_notice(); + + $deleted->id = $this->id; + $deleted->profile_id = $this->profile_id; + $deleted->uri = $this->uri; + $deleted->created = $this->created; + $deleted->deleted = common_sql_now(); + $this->query('BEGIN'); + + $deleted->insert(); + //Null any notices that are replies to this notice $this->query(sprintf("UPDATE notice set reply_to = null WHERE reply_to = %d", $this->id)); $related = array('Reply', @@ -140,7 +152,7 @@ class Notice extends Memcached_DataObject $final = common_shorten_links($content); - if (mb_strlen($final) > 140) { + if (Notice::contentTooLong($final)) { common_log(LOG_INFO, 'Rejecting notice that is too long.'); return _('Problem saving notice. Too long.'); } @@ -1341,4 +1353,20 @@ class Notice extends Memcached_DataObject return $last->id; } } + + static function maxContent() + { + $contentlimit = common_config('notice', 'contentlimit'); + // null => use global limit (distinct from 0!) + if (is_null($contentlimit)) { + $contentlimit = common_config('site', 'textlimit'); + } + return $contentlimit; + } + + static function contentTooLong($content) + { + $contentlimit = self::maxContent(); + return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit)); + } }