Beispiel #1
0
 public function getPhotoList($uid, $albumid, $start, $num, &$total)
 {
     $total = 0;
     if (!$uid) {
         return array();
     }
     $albumkey = compact('uid', 'albumid');
     $album = $this->albumDao->aGet($albumkey);
     if (empty($album)) {
         return array();
     }
     $option = new Ko_Tool_SQL();
     $offset = $start > 0 ? $start - 1 : $start;
     $addnum = $start > 0 ? 2 : 1;
     $limit = $num + $addnum;
     $option->oAnd('albumid = ?', $albumid)->oOffset($offset)->oLimit($limit)->oCalcFoundRows(true)->oOrderBy('sort desc, photoid desc');
     $photolist = $this->photoDao->aGetList($option);
     if ($count = count($photolist)) {
         if ($start > 0) {
             $prev = array_shift($photolist);
             $count--;
             $prev = $prev['photoid'];
         } else {
             $prev = 0;
         }
         if ($count > $num) {
             $next = array_pop($photolist);
             $count--;
             $next = $next['photoid'];
         } else {
             $next = 0;
         }
     }
     $total = $option->iGetFoundRows();
     if ($total != $album['pcount']) {
         $this->albumDao->iUpdate($albumkey, array('pcount' => $total));
     }
     foreach ($photolist as $k => &$v) {
         $update = array();
         if ($start + $k + 1 != $v['pos']) {
             $update['pos'] = $v['pos'] = $start + $k + 1;
         }
         if ($k != 0) {
             if ($photolist[$k - 1]['photoid'] != $v['prev']) {
                 $update['prev'] = $v['prev'] = $photolist[$k - 1]['photoid'];
             }
         } else {
             if ($prev != $v['prev']) {
                 $update['prev'] = $v['prev'] = $prev;
             }
         }
         if ($k != $count - 1) {
             if ($photolist[$k + 1]['photoid'] != $v['next']) {
                 $update['next'] = $v['next'] = $photolist[$k + 1]['photoid'];
             }
         } else {
             if ($next != $v['next']) {
                 $update['next'] = $v['next'] = $next;
             }
         }
         if (!empty($update)) {
             $this->photoDao->iUpdate($v, $update);
         }
     }
     unset($v);
     return $photolist;
 }
Beispiel #2
0
 /**
  * 用户查看会话消息列表详情,根据最小id查询
  *
  * @return array
  */
 public function aGetMessageListByMinmid($iUid, $iThread, $iMinmid, $iNum, $bAutoRead = true)
 {
     if (isset($this->_aConf['userthread'])) {
         $userthreadDao = $this->_aConf['userthread'] . 'Dao';
         $info = $this->{$userthreadDao}->aGet(array('uid' => $iUid, 'mid' => $iThread));
         if (empty($info)) {
             return array();
         }
         if ($bAutoRead && $info['unread']) {
             $this->{$userthreadDao}->iUpdate(array('uid' => $iUid, 'mid' => $iThread), array('unread' => 0));
         }
     }
     $oOption = new Ko_Tool_SQL();
     if (isset($this->_aConf['userthread'])) {
         $oOption->oWhere('ctime >= ?', $info['jointime']);
     }
     $oOption->oAnd('mid > ?', $iMinmid)->oOrderBy('mid desc')->oLimit($iNum);
     return $this->_aGetMessageList($iUid, $iThread, $oOption);
 }
Beispiel #3
0
 public function aGetListSeq($uid, $kind, $boundary, $num, &$next, &$next_boundary)
 {
     $msgtypes = $this->_aKind2MsgTypes($kind);
     $userDao = $this->_aConf['user'] . 'Dao';
     $option = new Ko_Tool_SQL();
     $option->oWhere('msgtype in (?)', $msgtypes)->oOrderBy('stime desc, msgid desc')->oLimit($num + 1);
     list($boundary_stime, $boundary_msgid) = explode('_', $boundary);
     if ($boundary_msgid) {
         $option->oAnd('stime < ? or (stime = ? and msgid < ?)', $boundary_stime, $boundary_stime, $boundary_msgid);
     }
     $splitField = $this->{$userDao}->sGetSplitField();
     if (strlen($splitField)) {
         $list = $this->{$userDao}->aGetList($uid, $option);
     } else {
         $option->oAnd('uid = ?', $uid);
         $list = $this->{$userDao}->aGetList($option);
     }
     $next = 0;
     if ($count = count($list)) {
         if (count($list) > $num) {
             $next = array_pop($list);
             $count--;
             $next = $next['msgid'];
         }
     }
     $contentDao = $this->_aConf['content'] . 'Dao';
     $msginfos = $this->{$contentDao}->aGetListByKeys($list);
     foreach ($list as $k => &$v) {
         $v = array_merge($msginfos[$v['msgid']], $v);
         $v['content'] = Ko_Tool_Enc::ADecode($v['content']);
         if ($k == $count - 1) {
             $next_boundary = $v['stime'] . '_' . $v['msgid'];
         }
     }
     unset($v);
     return $list;
 }