summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rwxr-xr-xclasses/Deleted_notice.php44
-rw-r--r--classes/Message.php51
-rw-r--r--classes/Notice.php38
-rw-r--r--classes/Profile.php21
-rw-r--r--classes/User_group.php18
-rwxr-xr-x[-rw-r--r--]classes/laconica.ini19
6 files changed, 160 insertions, 31 deletions
diff --git a/classes/Deleted_notice.php b/classes/Deleted_notice.php
new file mode 100755
index 000000000..474d0b6f4
--- /dev/null
+++ b/classes/Deleted_notice.php
@@ -0,0 +1,44 @@
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('LACONICA')) { exit(1); }
+
+/**
+ * Table Definition for notice
+ */
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class Deleted_notice extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'deleted_notice'; // table name
+ public $id; // int(4) primary_key not_null
+ public $profile_id; // int(4) not_null
+ public $uri; // varchar(255) unique_key
+ public $created; // datetime() not_null
+ public $deleted; // datetime() not_null
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Deleted_notice',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+}
diff --git a/classes/Message.php b/classes/Message.php
index 4806057b4..979e6e87c 100644
--- a/classes/Message.php
+++ b/classes/Message.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Message extends Memcached_DataObject
+class Message extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -14,58 +14,73 @@ class Message extends Memcached_DataObject
public $uri; // varchar(255) unique_key
public $from_profile; // int(4) not_null
public $to_profile; // int(4) not_null
- public $content; // varchar(140)
- public $rendered; // text()
- public $url; // varchar(255)
+ public $content; // text()
+ public $rendered; // text()
+ public $url; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- public $source; // varchar(32)
+ public $source; // varchar(32)
/* Static get */
- function staticGet($k,$v=null)
- { return Memcached_DataObject::staticGet('Message',$k,$v); }
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Message',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
-
+
function getFrom()
{
return Profile::staticGet('id', $this->from_profile);
}
-
+
function getTo()
{
return Profile::staticGet('id', $this->to_profile);
}
-
+
static function saveNew($from, $to, $content, $source) {
-
+
$msg = new Message();
-
+
$msg->from_profile = $from;
$msg->to_profile = $to;
$msg->content = common_shorten_links($content);
$msg->rendered = common_render_text($content);
$msg->created = common_sql_now();
$msg->source = $source;
-
+
$result = $msg->insert();
-
+
if (!$result) {
common_log_db_error($msg, 'INSERT', __FILE__);
return _('Could not insert message.');
}
-
+
$orig = clone($msg);
$msg->uri = common_local_url('showmessage', array('message' => $msg->id));
-
+
$result = $msg->update($orig);
-
+
if (!$result) {
common_log_db_error($msg, 'UPDATE', __FILE__);
return _('Could not update message with new URI.');
}
-
+
return $msg;
}
+
+ static function maxContent()
+ {
+ $desclimit = common_config('message', 'contentlimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($desclimit)) {
+ $desclimit = common_config('site', 'textlimit');
+ }
+ return $desclimit;
+ }
+
+ static function contentTooLong($content)
+ {
+ $contentlimit = self::maxContent();
+ return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit));
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 442eb00fd..48d4a0940 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));
+ }
}
diff --git a/classes/Profile.php b/classes/Profile.php
index f926b2cef..8f92b386e 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -35,14 +35,13 @@ class Profile extends Memcached_DataObject
public $fullname; // varchar(255) multiple_key
public $profileurl; // varchar(255)
public $homepage; // varchar(255) multiple_key
- public $bio; // varchar(140) multiple_key
+ public $bio; // text() multiple_key
public $location; // varchar(255) multiple_key
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */
- function staticGet($k,$v=null)
- { return Memcached_DataObject::staticGet('Profile',$k,$v); }
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Profile',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@@ -461,4 +460,20 @@ class Profile extends Memcached_DataObject
$c->delete(common_cache_key('profile:notice_count:'.$this->id));
}
}
+
+ static function maxBio()
+ {
+ $biolimit = common_config('profile', 'biolimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($biolimit)) {
+ $biolimit = common_config('site', 'textlimit');
+ }
+ return $biolimit;
+ }
+
+ static function bioTooLong($bio)
+ {
+ $biolimit = self::maxBio();
+ return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
+ }
}
diff --git a/classes/User_group.php b/classes/User_group.php
index ea19cbb97..310ecff1e 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -13,7 +13,7 @@ class User_group extends Memcached_DataObject
public $nickname; // varchar(64) unique_key
public $fullname; // varchar(255)
public $homepage; // varchar(255)
- public $description; // varchar(140)
+ public $description; // text()
public $location; // varchar(255)
public $original_logo; // varchar(255)
public $homepage_logo; // varchar(255)
@@ -298,6 +298,22 @@ class User_group extends Memcached_DataObject
return $ids;
}
+ static function maxDescription()
+ {
+ $desclimit = common_config('group', 'desclimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($desclimit)) {
+ $desclimit = common_config('site', 'textlimit');
+ }
+ return $desclimit;
+ }
+
+ static function descriptionTooLong($desc)
+ {
+ $desclimit = self::maxDescription();
+ return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit));
+ }
+
function asAtomEntry($namespace=false, $source=false)
{
$xs = new XMLStringer(true);
diff --git a/classes/laconica.ini b/classes/laconica.ini
index 766bed75d..c02996b3f 100644..100755
--- a/classes/laconica.ini
+++ b/classes/laconica.ini
@@ -38,6 +38,17 @@ modified = 384
[consumer__keys]
consumer_key = K
+[deleted_notice]
+id = 129
+profile_id = 129
+uri = 2
+created = 142
+deleted = 142
+
+[deleted_notice__keys]
+id = K
+uri = U
+
[design]
id = 129
backgroundcolor = 1
@@ -228,7 +239,7 @@ id = 129
uri = 2
from_profile = 129
to_profile = 129
-content = 2
+content = 34
rendered = 34
url = 2
created = 142
@@ -255,7 +266,7 @@ ts = K
id = 129
profile_id = 129
uri = 2
-content = 2
+content = 34
rendered = 34
url = 2
created = 142
@@ -303,7 +314,7 @@ nickname = 130
fullname = 2
profileurl = 2
homepage = 2
-bio = 2
+bio = 34
location = 2
created = 142
modified = 384
@@ -475,7 +486,7 @@ id = 129
nickname = 2
fullname = 2
homepage = 2
-description = 2
+description = 34
location = 2
original_logo = 2
homepage_logo = 2