Пример #1
0
 /**
  * 施設に紐付く予約できる権限のルーム取得
  *
  * @param	&$location	施設情報
  * @access	public
  */
 function getAddLocationRoom(&$location)
 {
     $pagesView =& $this->_container->getComponent("pagesView");
     $_user_auth_id = $this->_session->getparameter('_user_auth_id');
     $room_id_arr = $pagesView->getRoomIdByUserId(null, $location["add_authority"]);
     if ($room_id_arr === false) {
         return false;
     }
     if ($location['add_authority'] == _AUTH_GENERAL) {
         $search_result = array_search(_SELF_TOPGROUP_ID, $room_id_arr);
         if ($search_result) {
             unset($room_id_arr[$search_result]);
         }
     }
     $private_space = $pagesView->getPrivateSpaceByUserId($this->_session->getParameter("_user_id"));
     if ($private_space === false) {
         return false;
     }
     if (!empty($private_space)) {
         $private_room_id = $private_space[0]["page_id"];
     } else {
         $private_room_id = 0;
     }
     $actionChain =& $this->_container->getComponent('ActionChain');
     $actionName = $actionChain->getCurActionName();
     $location['hasPrivateReserveAuthority'] = false;
     if ($location['use_private_flag'] == _ON && !empty($room_id_arr) && $actionName != 'reservation_view_main_reserve_switch_location' && $actionName != 'reservation_view_edit_import_init') {
         if ($location['use_auth_flag'] == RESERVATION_USE_AUTH_USER && ($_user_auth_id == _AUTH_ADMIN || $location['add_authority'] <= $_user_auth_id)) {
             $location['hasPrivateReserveAuthority'] = true;
         } elseif ($location['use_auth_flag'] == RESERVATION_USE_AUTH_ROOM && count($room_id_arr) > 1) {
             $location['hasPrivateReserveAuthority'] = true;
         }
     }
     if (!$location['hasPrivateReserveAuthority']) {
         $search_result = array_search($private_room_id, $room_id_arr);
         if ($search_result != 0 || $search_result === 0) {
             unset($room_id_arr[$search_result]);
         }
     }
     if (count($room_id_arr) == 0) {
         return false;
     }
     if ($location["allroom_flag"] == _ON) {
         return $room_id_arr;
     }
     $params = array("location_id" => $location["location_id"]);
     $sql = "SELECT location.location_id, l_rooms.room_id, page.thread_num, page.private_flag, page.space_type, page.page_name";
     $sql .= " FROM {reservation_location} location" . " INNER JOIN {reservation_location_rooms} l_rooms" . " ON (location.location_id = l_rooms.location_id)" . " INNER JOIN {pages} page" . " ON (l_rooms.room_id = page.page_id)";
     $sql .= " WHERE location.location_id = ?" . " AND l_rooms.room_id IN (" . implode(",", $room_id_arr) . ")";
     $allow_add_rooms = $this->_db->execute($sql, $params, null, null, true, array($this, "_getLocationRoom"));
     if ($allow_add_rooms === false) {
         $this->_db->addError();
         return false;
     }
     if ($location['hasPrivateReserveAuthority']) {
         $allow_add_rooms[] = $private_room_id;
     }
     if ($location['use_auth_flag'] == RESERVATION_USE_AUTH_ROOM && count($allow_add_rooms) == 0) {
         $location['hasPrivateReserveAuthority'] = false;
     }
     return $allow_add_rooms;
 }