Пример #1
0
 public static function newFromDatabaseRow(\stdClass $row)
 {
     $id = UUID::fromBin($row->flowthread_id);
     // This is either NULL or a binary UUID
     $parentid = $row->flowthread_parentid;
     if ($parentid !== null) {
         $parentid = UUID::fromBin($parentid);
     }
     $data = array('id' => $id, 'pageid' => intval($row->flowthread_pageid), 'userid' => intval($row->flowthread_userid), 'username' => $row->flowthread_username, 'text' => $row->flowthread_text, 'parentid' => $parentid, 'status' => intval($row->flowthread_status), 'like' => intval($row->flowthread_like), 'report' => intval($row->flowthread_report));
     return new self($data);
 }
Пример #2
0
 public static function batchGetUserAttitude(\User $user, array $posts)
 {
     if (!count($posts)) {
         return array();
     }
     $dbr = wfGetDB(DB_SLAVE);
     $inExpr = self::buildPostInExpr($dbr, $posts);
     $res = $dbr->select('FlowThreadAttitude', array('flowthread_att_id', 'flowthread_att_type'), array('flowthread_att_id' . $inExpr, 'flowthread_att_userid' => $user->getId()));
     $ret = array();
     foreach ($res as $row) {
         $ret[UUID::fromBin($row->flowthread_att_id)->getHex()] = intval($row->flowthread_att_type);
     }
     foreach ($posts as $post) {
         if (!isset($ret[$post->id->getHex()])) {
             $ret[$post->id->getHex()] = Post::ATTITUDE_NORMAL;
         }
     }
     return $ret;
 }
Пример #3
0
 protected function formatPayload($payload, $event, $user)
 {
     switch ($payload) {
         case 'text':
             try {
                 return Post::newFromId(UUID::fromBin($event->getExtraParam('postid')))->text;
             } catch (\Exception $e) {
                 return wfMessage('notification-flowthread-payload-error');
             }
         default:
             return parent::formatPayload($payload, $event, $user);
             break;
     }
 }