+
+ static function groupsFromText($text, $profile)
+ {
+ $groups = array();
+
+ /* extract all !group */
+ $count = preg_match_all('/(?:^|\s)!(' . Nickname::DISPLAY_FMT . ')/',
+ strtolower($text),
+ $match);
+
+ if (!$count) {
+ return $groups;
+ }
+
+ foreach (array_unique($match[1]) as $nickname) {
+ $group = User_group::getForNickname($nickname, $profile);
+ if (!empty($group) && $profile->isMember($group)) {
+ $groups[] = $group->id;
+ }
+ }
+
+ return $groups;
+ }
+
+ protected $_original = -1;
+
+ function getOriginal()
+ {
+ if (is_int($this->_original) && $this->_original == -1) {
+ if (empty($this->reply_to)) {
+ $this->_original = null;
+ } else {
+ $this->_original = Notice::staticGet('id', $this->reply_to);
+ }
+ }
+ return $this->_original;
+ }
+
+ /**
+ * Magic function called at serialize() time.
+ *
+ * We use this to drop a couple process-specific references
+ * from DB_DataObject which can cause trouble in future
+ * processes.
+ *
+ * @return array of variable names to include in serialization.
+ */
+
+ function __sleep()
+ {
+ $vars = parent::__sleep();
+ $skip = array('_original', '_profile');
+ return array_diff($vars, $skip);
+ }
+
+ static function defaultScope()
+ {
+ $scope = common_config('notice', 'defaultscope');
+ if (is_null($scope)) {
+ if (common_config('site', 'private')) {
+ $scope = 1;
+ } else {
+ $scope = 0;
+ }
+ }
+ return $scope;
+ }
+