From 418a5a95ab4831ec905dd849fa2632dec24b96da Mon Sep 17 00:00:00 2001 From: Marcel van der Boom Date: Wed, 19 Aug 2009 08:34:17 +0200 Subject: Change the notice type defines all into class constants and adapt all files. --- classes/Notice.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'classes/Notice.php') diff --git a/classes/Notice.php b/classes/Notice.php index ebd5e1efd..442eb00fd 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -29,10 +29,6 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; define('NOTICE_CACHE_WINDOW', 61); -define('NOTICE_LOCAL_PUBLIC', 1); -define('NOTICE_REMOTE_OMB', 0); -define('NOTICE_LOCAL_NONPUBLIC', -1); - define('MAX_BOXCARS', 128); class Notice extends Memcached_DataObject @@ -62,7 +58,11 @@ class Notice extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - const GATEWAY = -2; + /* Notice types */ + const LOCAL_PUBLIC = 1; + const REMOTE_OMB = 0; + const LOCAL_NONPUBLIC = -1; + const GATEWAY = -2; function getProfile() { @@ -134,7 +134,7 @@ class Notice extends Memcached_DataObject } static function saveNew($profile_id, $content, $source=null, - $is_local=1, $reply_to=null, $uri=null, $created=null) { + $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null) { $profile = Profile::staticGet($profile_id); @@ -177,7 +177,7 @@ class Notice extends Memcached_DataObject if (($blacklist && in_array($profile_id, $blacklist)) || ($source && $autosource && in_array($source, $autosource))) { - $notice->is_local = -1; + $notice->is_local = Notice::LOCAL_NONPUBLIC; } else { $notice->is_local = $is_local; } @@ -509,7 +509,7 @@ class Notice extends Memcached_DataObject function blowPublicCache($blowLast=false) { - if ($this->is_local == 1) { + if ($this->is_local == Notice::LOCAL_PUBLIC) { $cache = common_memcache(); if ($cache) { $cache->delete(common_cache_key('public')); @@ -775,10 +775,11 @@ class Notice extends Memcached_DataObject } if (common_config('public', 'localonly')) { - $notice->whereAdd('is_local = 1'); + $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC); } else { - # -1 == blacklisted - $notice->whereAdd('is_local != -1'); + # -1 == blacklisted, -2 == gateway (i.e. Twitter) + $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC); + $notice->whereAdd('is_local !='. Notice::GATEWAY); } if ($since_id != 0) { -- cgit v1.2.3-54-g00ecf From d213a8cf90d2c6273b32618ddd2bd1c4c252b332 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 20 Aug 2009 16:56:26 -0400 Subject: update data classes for TEXT content in notice --- classes/Notice.php | 6 ++---- classes/laconica.ini | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'classes/Notice.php') diff --git a/classes/Notice.php b/classes/Notice.php index 9578d87b2..ba74a98a8 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -44,7 +44,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 @@ -55,9 +55,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 diff --git a/classes/laconica.ini b/classes/laconica.ini index f8d4eebd3..4f57ba3da 100755 --- a/classes/laconica.ini +++ b/classes/laconica.ini @@ -266,7 +266,7 @@ ts = K id = 129 profile_id = 129 uri = 2 -content = 2 +content = 34 rendered = 34 url = 2 created = 142 -- cgit v1.2.3-54-g00ecf From 4d05afae302f1870af369a713ab7ed291c821165 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 21 Aug 2009 08:05:13 -0400 Subject: Notice class has methods to check content length --- classes/Notice.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'classes/Notice.php') diff --git a/classes/Notice.php b/classes/Notice.php index ba74a98a8..e27f09c2c 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1352,4 +1352,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)); + } } -- cgit v1.2.3-54-g00ecf From d5825893c8982a9856f0b7a1731c178160237cdf Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 21 Aug 2009 08:12:57 -0400 Subject: validation code in Notice correctly checks length of content --- classes/Notice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/Notice.php') diff --git a/classes/Notice.php b/classes/Notice.php index e27f09c2c..2133247b8 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -152,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.'); } -- cgit v1.2.3-54-g00ecf