/** * 回覧先ユーザ情報を取得 * * @param $replyType 回答種別 * @param $flg 自分を含むかどうかのフラグ * @param $limit * @param $offset * @return mixed (正常時:回覧先ユーザ情報/異常時;false) * @access public */ function getCircularUsers($replyType, $flg, $limit = 0, $offset = 0) { $sql = ""; $sql .= "SELECT "; $sql .= "u.receive_user_id, "; $sql .= "u.update_time, "; if ($replyType == CIRCULAR_REPLY_TYPE_CHECKBOX_VALUE || $replyType == CIRCULAR_REPLY_TYPE_RADIO_VALUE) { $sql .= "u.reply_choice AS reply, "; } else { $sql .= "u.reply_body AS reply, "; } $sql .= "u.reply_flag, "; $sql .= "users.handle "; $sql .= "FROM "; $sql .= "{circular_user} u "; $sql .= "INNER JOIN {users} users "; $sql .= "ON u.receive_user_id = users.user_id "; $whereParams = array('room_id' => $this->_request->getParameter('room_id'), 'circular_id' => $this->_request->getParameter('circular_id')); $sql .= $this->_db->getWhereSQL($params, $whereParams); $myself = false; $_user_auth_id = $this->_session->getParameter('_user_auth_id'); if ($flg && $offset === 0) { $sql1 = $sql . " AND u.receive_user_id = ? "; $params1 = $params + array('receive_user_id' => $this->_user_id); $myself = $this->_db->execute($sql1, $params1); if ($myself === false) { return false; } if ($_user_auth_id < CIRCULAR_ALL_VIEW_AUTH) { $limit--; } } else { if ($_user_auth_id < CIRCULAR_ALL_VIEW_AUTH) { $offset--; } } $sql .= " AND u.receive_user_id <> '" . $this->_user_id . "'"; $sql .= " ORDER BY users.login_id ASC "; $others = $this->_db->execute($sql, $params, $limit, $offset, true); if ($others === false) { $this->_db->addError(); return false; } if ($myself) { $result = array_merge($myself, $others); } else { $result = $others; } return $result; }
/** * 回覧状況を既読にする * * @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; }