コード例 #1
0
ファイル: Notice.php プロジェクト: himmelex/NTW
 function addToGroupInbox($group)
 {
     $gi = Group_inbox::pkeyGet(array('group_id' => $group->id, 'notice_id' => $this->id));
     if (empty($gi)) {
         $gi = new Group_inbox();
         $gi->group_id = $group->id;
         $gi->notice_id = $this->id;
         $gi->created = $this->created;
         $result = $gi->insert();
         if (!$result) {
             common_log_db_error($gi, 'INSERT', __FILE__);
             throw new ServerException(_('Problem saving group inbox.'));
         }
         self::blow('user_group:notice_ids:%d', $gi->group_id);
     }
     return true;
 }
コード例 #2
0
ファイル: Notice.php プロジェクト: a780201/gnu-social
 function addToGroupInbox(User_group $group)
 {
     $gi = Group_inbox::pkeyGet(array('group_id' => $group->id, 'notice_id' => $this->id));
     if (!$gi instanceof Group_inbox) {
         $gi = new Group_inbox();
         $gi->group_id = $group->id;
         $gi->notice_id = $this->id;
         $gi->created = $this->created;
         $result = $gi->insert();
         if (!$result) {
             common_log_db_error($gi, 'INSERT', __FILE__);
             // TRANS: Server exception thrown when an update for a group inbox fails.
             throw new ServerException(_('Problem saving group inbox.'));
         }
         self::blow('user_group:notice_ids:%d', $gi->group_id);
     }
     return true;
 }
コード例 #3
0
ファイル: Notice.php プロジェクト: Br3nda/laconica
 function saveGroups()
 {
     $enabled = common_config('inboxes', 'enabled');
     if ($enabled !== true && $enabled !== 'transitional') {
         return;
     }
     /* extract all !group */
     $count = preg_match_all('/(?:^|\\s)!([A-Za-z0-9]{1,64})/', strtolower($this->content), $match);
     if (!$count) {
         return true;
     }
     $profile = $this->getProfile();
     /* Add them to the database */
     foreach (array_unique($match[1]) as $nickname) {
         /* XXX: remote groups. */
         $group = User_group::staticGet('nickname', $nickname);
         if (!$group) {
             continue;
         }
         // we automatically add a tag for every group name, too
         $tag = Notice_tag::pkeyGet(array('tag' => common_canonical_tag($nickname), 'notice_id' => $this->id));
         if (is_null($tag)) {
             $this->saveTag($nickname);
         }
         if ($profile->isMember($group)) {
             $gi = new Group_inbox();
             $gi->group_id = $group->id;
             $gi->notice_id = $this->id;
             $gi->created = common_sql_now();
             $result = $gi->insert();
             if (!$result) {
                 common_log_db_error($gi, 'INSERT', __FILE__);
             }
             // FIXME: do this in an offline daemon
             $inbox = new Notice_inbox();
             $UT = common_config('db', 'type') == 'pgsql' ? '"user"' : 'user';
             $qry = 'INSERT INTO notice_inbox (user_id, notice_id, created, source) ' . "SELECT {$UT}.id, " . $this->id . ", '" . $this->created . "', 2 " . "FROM {$UT} JOIN group_member ON {$UT}.id = group_member.profile_id " . 'WHERE group_member.group_id = ' . $group->id . ' ' . 'AND NOT EXISTS (SELECT user_id, notice_id ' . 'FROM notice_inbox ' . "WHERE user_id = {$UT}.id " . 'AND notice_id = ' . $this->id . ' )';
             if ($enabled === 'transitional') {
                 $qry .= " AND {$UT}.inboxed = 1";
             }
             $result = $inbox->query($qry);
         }
     }
 }