コード例 #1
0
 /**
  * ポータル(自分が作成者 または 回覧者の回覧を一覧表示する)画面用のデータを取得
  *
  * @access public
  */
 function getPortalCircular()
 {
     $moduleId = $this->_request->getParameter('module_id');
     $fromStatement = "FROM {circular} C " . "LEFT JOIN {circular_user} U " . "ON C.circular_id = U.circular_id " . "AND U.receive_user_id = ? " . "AND U.reply_flag = ? " . "INNER JOIN {pages} P " . "ON C.room_id = P.room_id " . "INNER JOIN {blocks} B " . "ON P.page_id = B.page_id " . "AND B.module_id = ? " . "WHERE (C.post_user_id = ? " . "OR U.receive_user_id = ?) " . "AND (C.period = '' " . "OR C.period >= ? ) ";
     $sql = "SELECT MIN(B.block_id) AS block_id " . $fromStatement . "GROUP BY C.room_id";
     $params = array($this->_user_id, CIRCULAR_LIST_TYPE_UNSEEN, $moduleId, $this->_user_id, $this->_user_id, timezone_date());
     $blockIdString = $this->_db->execute($sql, $params, null, null, false, array($this, '_makeImplodeString'));
     if ($blockIdString === false) {
         $this->_db->addError();
         return false;
     }
     if (empty($blockIdString)) {
         return array();
     }
     $sql = "SELECT C.circular_id, " . "C.circular_subject, " . "C.icon_name, " . "C.period, " . "C.insert_user_name, " . "C.update_time, " . "B.block_id " . $fromStatement . "AND B.block_id IN (" . $blockIdString . ") " . "ORDER BY C.update_time DESC ";
     $result = $this->_db->execute($sql, $params, CIRCULAR_PORTAL_LIST_COUNT, null, true, array($this, "_callbackGetPortalCircular"));
     if ($result === false) {
         $this->_db->addError();
         return false;
     }
     return $result;
 }
コード例 #2
0
 /**
  * 回覧状況を既読にする
  *
  * @param   string  $type	既読設定タイプ
  * @return  boolean (true:正常/false:異常)
  * @access  public
  */
 function updateUserSeen($type)
 {
     $roomId = $this->_request->getParameter('room_id');
     $circularId = $this->_request->getParameter('circular_id');
     $whereParams = array('room_id' => $roomId, 'circular_id' => $circularId);
     $sql = "SELECT seen_option FROM {circular} ";
     $sql .= $this->_db->getWhereSQL($params, $whereParams);
     $result = $this->_db->execute($sql, $params);
     if ($result === false) {
         $this->_db->addError();
         return false;
     }
     if (!isset($result[0])) {
         return true;
     }
     $option = $result[0]['seen_option'];
     switch ($type) {
         case 'reply':
             if ($option == CIRCULAR_SEEN_OPTION_VISIT) {
                 return true;
             }
             break;
         case 'visit':
             if ($option == CIRCULAR_SEEN_OPTION_REPLY) {
                 return true;
             }
             $params = array();
             $whereParams += array('receive_user_id' => $this->_user_id);
             $sql = "SELECT reply_flag FROM {circular_user} ";
             $sql .= $this->_db->getWhereSQL($params, $whereParams);
             $result = $this->_db->execute($sql, $params);
             if ($result === false) {
                 return false;
             }
             if (!isset($result[0])) {
                 return true;
             }
             $replyFlg = $result[0]['reply_flag'];
             if ($replyFlg == CIRCULAR_LIST_TYPE_SEEN) {
                 return true;
             }
             break;
         default:
             return false;
     }
     $whereParams = array('room_id' => $roomId, 'circular_id' => $circularId, 'receive_user_id' => $this->_user_id);
     $result = $this->_db->updateExecute('circular_user', array('reply_flag' => CIRCULAR_REPLY_FLAG_SEEN), $whereParams, true);
     if ($result === false) {
         $this->_db->addError();
         return false;
     }
     $whereParams = array('room_id' => $roomId, 'circular_id' => $circularId, 'reply_flag' => CIRCULAR_REPLY_FLAG_UNSEEN);
     $count = $this->_db->countExecute('circular_user', $whereParams);
     if ($count === false) {
         $this->_db->addError();
         return false;
     }
     if (intval($count) === 0) {
         $whereParams = array('room_id' => $roomId, 'circular_id' => $circularId, 'status' => CIRCULAR_STATUS_CIRCULATING);
         $result = $this->_db->updateExecute('circular', array('status' => CIRCULAR_STATUS_CIRCULATED), $whereParams, true);
         if ($result === false) {
             $this->_db->addError();
             return false;
         }
     }
     return true;
 }