/**
  * fetch時コールバックメソッド(pages)
  *
  * @param $thread_num
  * @param $parent_id
  * @param $parent_room
  *
  * @access	private
  */
 function _makeRoomArray(&$result_params, $thread_num, $parent_id, &$parent_room)
 {
     if (!isset($result_params["room_arr"][$thread_num]) || !isset($result_params["room_arr"][$thread_num][$parent_id])) {
         return true;
     }
     $sess_enroll_room = $this->_session->getParameter(array("calendar", "enroll_room", $result_params["calendar_block"]["block_id"]));
     $next_thread_num = $thread_num + 1;
     foreach ($result_params["room_arr"][$thread_num][$parent_id] as $disp => $room) {
         if ($room["space_type"] == _SPACE_TYPE_GROUP && $room["private_flag"] == _ON) {
             if ($result_params["calendar_block"]["myroom_flag"] == _ON) {
                 $result_params["calendar_block"]["select_room_list"][] = $room["page_id"];
             }
             if ($result_params["calendar_block"]["myroom_flag"] == _ON && strpos(strtolower($result_params["action_name"]), "calendar_view_main") !== false) {
                 $result_params["enroll_room_arr"][] = $room;
             }
             continue;
         }
         if ($room["space_type"] != _SPACE_TYPE_GROUP || $room["space_type"] == _SPACE_TYPE_GROUP && $room["private_flag"] != _ON && $room["thread_num"] > 1) {
             $room["parent_page_name"] = $parent_room["page_name"];
         }
         if (!isset($sess_enroll_room) && in_array($room["page_id"], $result_params["calendar_block"]["select_room_list"]) || !empty($sess_enroll_room) && in_array($room["page_id"], $sess_enroll_room)) {
             $result_params["enroll_room_arr"][] = $room;
         } else {
             $result_params["not_enroll_room_arr"][] = $room;
         }
         $this->_makeRoomArray($result_params, $next_thread_num, $room["page_id"], $room);
     }
     return true;
 }
 function getFromInfo($public_flag)
 {
     if ($public_flag) {
         $usersView =& $this->_container->getComponent('usersView');
         $user =& $usersView->getUserById($this->_session->getParameter('_user_id'));
         $ret = array('from_name' => $user['handle']);
     } else {
         $configView =& $this->_container->getComponent('configView');
         $mailConfigs = $configView->getConfigByCatid(_SYS_CONF_MODID, _MAIL_CONF_CATID);
         $ret = array('from_name' => $mailConfigs['fromname']['conf_value'], 'from_email' => $mailConfigs['from']['conf_value']);
     }
     return $ret;
 }
 /**
  * フイルタデータを削除する
  *
  * @return boolean	true or false
  * @access	public
  */
 function deleteFilter()
 {
     $user_id = $this->_session->getParameter("_user_id");
     $filter_id = $this->_request->getParameter("filter_id");
     $params = array("filter_id" => $filter_id, "insert_user_id" => $user_id);
     if (!$this->_db->deleteExecute("pm_filter_action_link", $params)) {
         return false;
     }
     if (!$this->_db->deleteExecute("pm_filter", $params)) {
         return false;
     }
     return true;
 }
 /**
  * ルーム指定
  *
  * @access	public
  */
 function setSelectRoom()
 {
     $block_id = $this->_request->getParameter("block_id");
     $select_room = intval($this->_request->getParameter("select_room"));
     if ($select_room == _ON) {
         $not_enroll_room = $this->_session->getParameter(array("calendar", "not_enroll_room", $block_id));
         $enroll_room = $this->_session->getParameter(array("calendar", "enroll_room", $block_id));
         if (!isset($not_enroll_room) && !isset($enroll_room)) {
             $enroll_room = array($this->_session->getParameter("_main_room_id"));
         }
         $calendar_block = $this->_calendarView->getBlock();
         if (!$calendar_block) {
             return false;
         }
         if (!empty($calendar_block["select_room_list"]) && !empty($not_enroll_room)) {
             foreach ($not_enroll_room as $i => $room_id) {
                 if (in_array($room_id, $calendar_block["select_room_list"])) {
                     $params = array("block_id" => $block_id, "room_id" => $room_id);
                     $result = $this->_db->deleteExecute("calendar_select_room", $params);
                     if (!$result) {
                         return false;
                     }
                 }
             }
         }
         if (!empty($enroll_room)) {
             foreach ($enroll_room as $i => $room_id) {
                 if (empty($calendar_block["select_room_list"]) || !in_array($room_id, $calendar_block["select_room_list"])) {
                     $params = array("block_id" => $block_id, "room_id" => $room_id);
                     $result = $this->_db->insertExecute("calendar_select_room", $params);
                     if (!$result) {
                         return false;
                     }
                 }
             }
         }
     } else {
         $params = array("block_id" => $block_id);
         $result = $this->_db->deleteExecute("calendar_select_room", $params);
         if (!$result) {
             return false;
         }
     }
     return true;
 }
 /**
  * 予定の変更
  *
  * @access	public
  */
 function updatePlan($calendar_id, &$plan_params, $edit_rrule = 0)
 {
     if (isset($plan_params["start_date"]) && !isset($plan_params["start_time_full"])) {
         $plan_params["start_time_full"] = $plan_params["start_date"] . $plan_params["start_time"];
     } elseif (!isset($plan_params["start_date"]) && isset($plan_params["start_time_full"])) {
         $plan_params["start_date"] = substr($plan_params["start_time_full"], 0, 8);
         $plan_params["start_time"] = substr($plan_params["start_time_full"], 8);
     }
     if (isset($plan_params["end_date"]) && !isset($plan_params["end_time_full"])) {
         $plan_params["end_time_full"] = $plan_params["end_date"] . $plan_params["end_time"];
     } elseif (!isset($plan_params["end_date"]) && isset($plan_params["end_time_full"])) {
         $plan_params["end_date"] = substr($plan_params["end_time_full"], 0, 8);
         $plan_params["end_time"] = substr($plan_params["end_time_full"], 8);
     }
     $result =& $this->_db->selectExecute("calendar_plan", array("calendar_id" => $calendar_id));
     if (empty($result)) {
         return true;
     }
     $plan_id = $result[0]["plan_id"];
     if (!isset($plan_params["timezone_offset"])) {
         $plan_params["timezone_offset"] = $result[0]["timezone_offset"];
     }
     $plan_params["insert_time"] = $result[0]["insert_time"];
     $plan_params["insert_site_id"] = $result[0]["insert_site_id"];
     $plan_params["insert_user_id"] = $result[0]["insert_user_id"];
     $plan_params["insert_user_name"] = $result[0]["insert_user_name"];
     $params = array("location" => isset($plan_params["location"]) ? $plan_params["location"] : "", "contact" => isset($plan_params["contact"]) ? $plan_params["contact"] : "", "description" => isset($plan_params["description"]) ? $plan_params["description"] : "", "rrule" => isset($plan_params["rrule"]) ? $plan_params["rrule"] : "", "room_id" => isset($plan_params["room_id"]) ? $plan_params["room_id"] : 0);
     $plan_params = array_merge($plan_params, $params);
     if (defined("CALENDAR_PLAN_EDIT_ALL") && $edit_rrule == CALENDAR_PLAN_EDIT_ALL) {
         $result = $this->_db->updateExecute("calendar_plan_details", $params, array("plan_id" => $plan_id));
         if ($result === false) {
             return false;
         }
     } elseif (defined("CALENDAR_PLAN_EDIT_AFTER") && $edit_rrule == CALENDAR_PLAN_EDIT_AFTER) {
         $plan_id = $this->updatePlanByAfter($calendar_id, $plan_id, $plan_params);
         if ($plan_id === false) {
             return false;
         }
     } else {
         $plan_id = $this->_db->insertExecute("calendar_plan_details", $params, false, "plan_id");
         if ($plan_id === false) {
             return false;
         }
     }
     $params = array("plan_id" => $plan_id, "room_id" => isset($plan_params["room_id"]) ? $plan_params["room_id"] : 0, "title" => isset($plan_params["title"]) ? $plan_params["title"] : "", "title_icon" => isset($plan_params["title_icon"]) ? $plan_params["title_icon"] : "", "allday_flag" => isset($plan_params["allday_flag"]) ? $plan_params["allday_flag"] : _OFF, "start_date" => $plan_params["start_date"], "start_time" => $plan_params["start_time"], "start_time_full" => $plan_params["start_time_full"], "end_date" => $plan_params["end_date"], "end_time" => $plan_params["end_time"], "end_time_full" => $plan_params["end_time_full"], "timezone_offset" => isset($plan_params["timezone_offset"]) ? $plan_params["timezone_offset"] : $this->_session->getParameter("_timezone_offset"), "link_module" => isset($plan_params["link_module"]) ? $plan_params["link_module"] : "", "link_id" => isset($plan_params["link_id"]) ? $plan_params["link_id"] : _OFF, "link_action_name" => isset($plan_params["link_action_name"]) ? $plan_params["link_action_name"] : "");
     $plan_params = array_merge($plan_params, $params);
     if (isset($plan_params["insert_time"])) {
         $params["insert_time"] = $plan_params["insert_time"];
     }
     if (isset($plan_params["insert_site_id"])) {
         $params["insert_site_id"] = $plan_params["insert_site_id"];
     }
     if (isset($plan_params["insert_user_id"])) {
         $params["insert_user_id"] = $plan_params["insert_user_id"];
     }
     if (isset($plan_params["insert_user_name"])) {
         $params["insert_user_name"] = $plan_params["insert_user_name"];
     }
     $where_params = array("calendar_id" => $calendar_id);
     $result = $this->_db->updateExecute("calendar_plan", $params, $where_params, true);
     if ($result === false) {
         return false;
     }
     if ($edit_rrule != 0) {
         $result = $this->insertRRule($calendar_id, $plan_params["rrule"]);
         if ($result === false) {
             return false;
         }
     }
     return true;
 }