X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FMessage.php;h=718a9d922a525eccbb5218d9b412c11e4c24a76a;hb=69ac99ff949ab0118ff25a62471980ad0ec7a52b;hp=71362d9b75db25843f0e43d43830c114308d1314;hpb=4b443089884a30806aa5a3d00665fbd6296ccd43;p=quix0rs-gnu-social.git diff --git a/classes/Message.php b/classes/Message.php index 71362d9b75..718a9d922a 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -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,20 @@ 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)); + } }