/** * 回覧板データ配列を生成 * * @param object $recordSet ADORecordSet * @return array データ配列 * @access private */ function &_fetchCircularList(&$recordSet, $params) { $format = "YmdHis"; list($today, $soonDate) = $this->_getSoonPeriod($format); $mobile = false; if ($this->_session->getParameter('_mobile_flag') == true) { $mobile = true; } $circulars = array(); while ($circular = $recordSet->fetchRow()) { if ($params['list_type'] === CIRCULAR_LIST_TYPE_CIRCULATING || $params['list_type'] === CIRCULAR_LIST_TYPE_ALL) { $whereParams = array('room_id' => $circular['room_id'], 'circular_id' => $circular['circular_id']); $circular['total_count'] = $this->_db->countExecute('circular_user', $whereParams); $whereParams['reply_flag'] = _ON; $circular['seen_count'] = $this->_db->countExecute('circular_user', $whereParams); } if ($mobile) { $result = $this->_db->countExecute('circular_user', array("receive_user_id" => $this->_user_id)); if (empty($result)) { $circular["has_reply_auth"] = false; } else { $circular["has_reply_auth"] = true; } $date = timezone_date($circular["insert_time"], false, "Ymd"); } if (empty($circular['period'])) { if ($mobile) { $circulars[$date][] = $circular; } else { $circulars[] = $circular; } continue; } list($circular['displayPeriodDate'], $ymdPeriodDate) = $this->getDisplayPeriodDate($circular['period']); if ($today > $ymdPeriodDate) { $circular['periodClassName'] = CIRCULAR_PERIOD_OVER; if ($mobile) { $circular["has_reply_auth"] = false; } } else { if ($soonDate >= $ymdPeriodDate) { $circular['periodClassName'] = CIRCULAR_PERIOD_SOON; } } if ($mobile) { $circulars[$date][] = $circular; } else { $circulars[] = $circular; } } return $circulars; }
/** * 回覧状況を既読にする * * @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; }