]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Message.php
Update to biz theme's input styles
[quix0rs-gnu-social.git] / classes / Message.php
index 71362d9b75db25843f0e43d43830c114308d1314..16d0c60b304704bf69dd63e002f1162d11657786 100644 (file)
@@ -39,6 +39,12 @@ class Message extends Memcached_DataObject
 
     static function saveNew($from, $to, $content, $source) {
 
+        $sender = Profile::staticGet('id', $from);
+
+        if (!$sender->hasRight(Right::NEWMESSAGE)) {
+            throw new ClientException(_('You are banned from sending direct messages.'));
+        }
+
         $msg = new Message();
 
         $msg->from_profile = $from;
@@ -67,4 +73,28 @@ class Message extends Memcached_DataObject
 
         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));
+    }
+
+    function notify()
+    {
+        $from = User::staticGet('id', $this->from_profile);
+        $to   = User::staticGet('id', $this->to_profile);
+
+        mail_notify_message($this, $from, $to);
+    }
 }