summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php38
1 files changed, 33 insertions, 5 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index e59712864..ed41acbae 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));
+ }
}