/**
  * execute実行
  *
  * @access  public
  */
 function execute()
 {
     $metadatas = $this->mdbView->getMetadatas(array("multidatabase_id" => intval($this->multidatabase_id)));
     if ($metadatas === false) {
         return 'error';
     }
     $order_params = array("display_sequence" => "ASC");
     $data = array();
     $line = 0;
     $data_contents = array();
     foreach ($metadatas as $metadata) {
         $data[] = $metadata['name'];
         $contents = $this->mdbView->getMDBTitleList(intval($this->multidatabase_id), $metadata['metadata_id'], $order_params);
         if ($contents === false) {
             return 'error';
         }
         $i = 0;
         foreach ($contents as $content) {
             if ($content['title'] != "" && ($metadata['type'] == MULTIDATABASE_META_TYPE_FILE || $metadata['type'] == MULTIDATABASE_META_TYPE_IMAGE)) {
                 if ($content['file_name'] != "") {
                     $content['title'] = $content['file_name'];
                 } else {
                     $content['title'] = "";
                 }
             } elseif ($content['title'] != "" && $metadata['type'] == MULTIDATABASE_META_TYPE_DATE) {
                 $content['title'] = timezone_date_format($content['title'], _DATE_FORMAT);
             } elseif ($content['insert_time'] != "" && $metadata['type'] == MULTIDATABASE_META_TYPE_INSERT_TIME) {
                 $content['title'] = timezone_date_format($content['insert_time'], _FULL_DATE_FORMAT);
             } elseif ($content['update_time'] != "" && $metadata['type'] == MULTIDATABASE_META_TYPE_UPDATE_TIME) {
                 $content['title'] = timezone_date_format($content['update_time'], _FULL_DATE_FORMAT);
             } elseif ($content['title'] != "" && $metadata['type'] == MULTIDATABASE_META_TYPE_AUTONUM) {
                 $content['title'] = intval($content['title']);
             }
             $data_contents[$i][$line] = $content['title'];
             $i++;
         }
         $line++;
     }
     $this->csvMain->add($data);
     foreach ($data_contents as $data_content) {
         $this->csvMain->add($data_content);
     }
     $this->csvMain->download($this->mdb_obj['multidatabase_name']);
     exit;
 }
 /**
  * execute処理
  *
  * @access  public
  */
 function execute()
 {
     $this->help_start_time = "090000";
     $this->help_end_time = "180000";
     $this->help_reserve_time = timezone_date_format(null, "Ymd");
     $this->category_list = $this->reservationView->getCategories();
     $this->location_count_list = $this->reservationView->getCountLocationByCategory();
     $this->location_list = $this->reservationView->getLocations();
     $this->location_count = count($this->location_list);
     foreach ($this->location_list as $location) {
         $this->location = $location;
         $this->location_id = $this->location["location_id"];
         $this->request->setParameter("location", $location);
         break;
     }
     $this->allow_add_rooms = $this->reservationView->getAddLocationRoom($location);
     return 'success';
 }
 /**
  * メール送信アクション
  *
  * @access  public
  */
 function execute()
 {
     $content_mail = $this->session->getParameter("multidatabase_mail_content_id");
     $content_id = intval($content_mail['content_id']);
     if (empty($content_id)) {
         return 'success';
     }
     $params = array("content_id" => $content_id);
     $contents = $this->db->selectExecute("multidatabase_content", $params);
     if ($contents === false || !isset($contents[0])) {
         return 'error';
     }
     $multidatabase_id = $contents[0]['multidatabase_id'];
     $metadatas = $this->mdbView->getMetadatas(array("multidatabase_id" => $multidatabase_id));
     if ($metadatas === false) {
         return 'error';
     }
     $mail = $this->mdbView->getMail($content_id, $metadatas);
     if ($mail === false) {
         return 'error';
     }
     $data = "";
     foreach (array_keys($metadatas) as $i) {
         $data .= htmlspecialchars($metadatas[$i]['name']) . ':';
         if ($metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_IMAGE || $metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_FILE) {
             $data .= $this->mdbView->getFileLink($mail['content' . $metadatas[$i]['metadata_id']], $mail['file_name' . $metadatas[$i]['metadata_id']], $mail['physical_file_name' . $metadatas[$i]['metadata_id']], $metadatas[$i], BASE_URL . INDEX_FILE_NAME);
         } elseif ($metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_WYSIWYG) {
             $data .= $mail['content' . $metadatas[$i]['metadata_id']];
         } elseif ($metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_DATE && !empty($mail['content' . $metadatas[$i]['metadata_id']])) {
             $data .= timezone_date_format($mail['content' . $metadatas[$i]['metadata_id']], _DATE_FORMAT);
         } elseif ($metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_INSERT_TIME) {
             $data .= timezone_date_format($mail['insert_time'], _FULL_DATE_FORMAT);
         } elseif ($metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_UPDATE_TIME) {
             $data .= timezone_date_format($mail['update_time'], _FULL_DATE_FORMAT);
         } elseif ($metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_AUTONUM) {
             $data .= intval($mail['content' . $metadatas[$i]['metadata_id']]);
         } elseif ($metadatas[$i]['type'] == MULTIDATABASE_META_TYPE_TEXTAREA) {
             $data .= str_replace("\n", '<br />', htmlspecialchars($mail['content' . $metadatas[$i]['metadata_id']]));
         } else {
             $data .= htmlspecialchars($mail['content' . $metadatas[$i]['metadata_id']]);
         }
         $data .= '<br />';
     }
     $this->mailMain->setSubject($mail['mail_subject']);
     $this->mailMain->setBody($mail['mail_body']);
     $tags['X-MDB_NAME'] = htmlspecialchars($mail['multidatabase_name']);
     $tags['X-DATA'] = $data;
     $tags['X-USER'] = htmlspecialchars($mail['insert_user_name']);
     $tags['X-TO_DATE'] = $mail['insert_time'];
     $tags['X-URL'] = BASE_URL . INDEX_FILE_NAME . "?action=" . DEFAULT_ACTION . "&active_action=multidatabase_view_main_detail" . "&content_id=" . $content_id . "&multidatabase_id=" . $multidatabase_id . "&block_id=" . $this->block_id . "#" . $this->session->getParameter("_id");
     $this->mailMain->assign($tags);
     if ($content_mail['agree_flag'] == MULTIDATABASE_STATUS_WAIT_AGREE_VALUE) {
         $users = $this->usersView->getSendMailUsers($this->room_id, _AUTH_CHIEF);
     } else {
         if ($content_mail['agree_flag'] == MULTIDATABASE_STATUS_AGREE_VALUE) {
             $users = $this->usersView->getSendMailUsers($this->room_id, $mail['mail_authority']);
         }
     }
     $this->mailMain->setToUsers($users);
     $this->mailMain->send();
     $this->session->removeParameter("multidatabase_mail_content_id");
     return 'success';
 }
 /**
  * 施設取得
  *
  * @access	public
  */
 function getDefaultLocation()
 {
     $module_id = $this->_request->getParameter("module_id");
     $configView =& $this->_container->getComponent("configView");
     $config = $configView->getConfig($module_id, false);
     if ($config === false) {
         return false;
     }
     $commonMain =& $this->_container->getComponent("commonMain");
     $timezoneMain =& $commonMain->registerClass(WEBAPP_DIR . '/components/timezone/Main.class.php', "Timezone_Main", "timezoneMain");
     $timezone_offset = $this->_session->getParameter("_timezone_offset");
     $location = array("location_id" => 0, "category_id" => 0, "location_name" => "", "active_flag" => _ON, "add_authority" => _AUTH_CHIEF, "time_table" => RESERVATION_DEF_WEEKYDAY, "time_table_arr" => explode(",", RESERVATION_DEF_WEEKYDAY), "start_time" => timezone_date_format(null, "Ymd090000"), "end_time" => timezone_date_format(null, "Ymd180000"), "timezone_offset" => $timezone_offset, "timezone_string" => $timezoneMain->getLangTimeZone($timezone_offset, false), "allday_flag" => _OFF, "contact" => "", "description" => "", "duplication_flag" => _OFF, "use_private_flag" => defined($config['use_private_flag']["conf_value"]) ? constant($config['use_private_flag']["conf_value"]) : intval($config['use_private_flag']["conf_value"]), "allroom_flag" => defined($config['allroom_flag']["conf_value"]) ? constant($config['allroom_flag']["conf_value"]) : intval($config['allroom_flag']["conf_value"]), "display_sequence" => 0);
     return $location;
 }
 /**
  * タスクデータ配列を生成する
  *
  * @param	array	$recordSet	タスクADORecordSet
  * @param	string	$format		日付フォーマット文字列
  * @return array	タスクデータ配列
  * @access	private
  */
 function &_makeTaskArray(&$recordSet, $funcParams = array())
 {
     $todo = $this->_request->getParameter("todo");
     if (!empty($funcParams["format"])) {
         $format = $funcParams["format"];
     } else {
         $format = _DATE_FORMAT;
     }
     if (!empty($funcParams["array_key"])) {
         $array_key = $funcParams["array_key"];
     } else {
         $array_key = "";
     }
     $tasks = array();
     while ($row = $recordSet->fetchRow()) {
         $row["category_id"] = isset($row["category_id"]) ? intval($row["category_id"]) : 0;
         $row["edit_authority"] = false;
         if ($todo["task_authority"] && $this->_hasEditAuthority($row["insert_user_id"])) {
             $row["edit_authority"] = true;
         }
         if (!empty($row["period"])) {
             $period = timezone_date_format($row["period"], null);
             if (substr($period, 8) == "000000") {
                 $previousDay = -1;
                 $format = str_replace("H", "24", $format);
                 $timeFormat = str_replace("H", "24", _SHORT_TIME_FORMAT);
             } else {
                 $previousDay = 0;
                 $timeFormat = _SHORT_TIME_FORMAT;
             }
             $date = mktime(intval(substr($period, 8, 2)), intval(substr($period, 10, 2)), intval(substr($period, 12, 2)), intval(substr($period, 4, 2)), intval(substr($period, 6, 2)) + $previousDay, intval(substr($period, 0, 4)));
             $row["display_period_date"] = date($format, $date);
             $row["display_period_time"] = date($timeFormat, $date);
             if ($this->_mobile_flag == _ON) {
                 $row["year"] = date("Y", $date);
                 $row["month"] = date("m", $date);
                 $row["day"] = date("d", $date);
             }
             if (!isset($thisDate)) {
                 $thisDate = timezone_date_format(null, null);
                 $soonDate = mktime(0, 0, 0, intval(substr($thisDate, 4, 2)), intval(substr($thisDate, 6, 2)) + $todo["soon_period"], intval(substr($thisDate, 0, 4)));
                 $thisDate = timezone_date_format(null, $format);
                 $soonDate = date($format, $soonDate);
             }
             if ($thisDate > $row["display_period_date"]) {
                 $row["period_class_name"] = TODO_PERIOD_CLASS_NAME_OVER;
             } elseif ($soonDate >= $row["display_period_date"]) {
                 $row["period_class_name"] = TODO_PERIOD_CLASS_NAME_SOON;
             }
         }
         if ($array_key == "category") {
             if (!isset($tasks[$row["category_id"]])) {
                 $tasks[$row["category_id"]] = array();
             }
             $tasks[$row["category_id"]][] = $row;
         } else {
             $tasks[] = $row;
         }
     }
     return $tasks;
 }
 /**
  * CSVデータを設定する
  *
  * @param	array	$recordSet	ADORecordSet
  * @param	array	$params[0]	質問データ配列
  * @param	array	$params[1]	集計データ配列
  * @return boolean	true:正常、false:異常
  * @access	private
  */
 function _makeCSV(&$recordSet, &$params)
 {
     $container =& DIContainerFactory::getContainer();
     $filterChain =& $container->getComponent("FilterChain");
     $smartyAssign =& $filterChain->getFilterByName("SmartyAssign");
     $csvMain =& $container->getComponent("csvMain");
     $data = array($smartyAssign->getLang("questionnaire_answerer"), $smartyAssign->getLang("questionnaire_answer_date"), $smartyAssign->getLang("questionnaire_answer_number"), $smartyAssign->getLang("questionnaire_question_number"), $smartyAssign->getLang("questionnaire_question_title"), $smartyAssign->getLang("questionnaire_answer_title"));
     $csvMain->add($data);
     $questions = $params[0];
     $summaries = $params[1];
     $questionnaire = $this->_request->getParameter("questionnaire");
     $anonymity = $questionnaire["anonymity_flag"];
     while ($row = $recordSet->fetchRow()) {
         $questionID = $row["question_id"];
         $question = $questions[$questionID];
         $summaryID = $row["summary_id"];
         $summary = $summaries[$summaryID];
         if ($question["question_type"] != QUESTIONNAIRE_QUESTION_TYPE_TEXTAREA_VALUE) {
             $choiceValues = array();
             $answerValues = $this->getAnswerValues($row["answer_value"], $question["choices"]);
             foreach (array_keys($answerValues) as $choiceID) {
                 if ($answerValues[$choiceID] == _ON) {
                     $choiceValues[] = $question["choices"][$choiceID]["choice_value"];
                 }
             }
             $row["answer_value"] = implode(",", $choiceValues);
         }
         if ($anonymity == _ON) {
             $summary["insert_user_name"] = $smartyAssign->getLang("questionnaire_anonymity_name");
             $summary["answer_number"] = "";
         }
         $data = array($summary["insert_user_name"], timezone_date_format($summary["answer_time"], _FULL_DATE_FORMAT), $summary["answer_number"], $question["question_sequence"], $question["question_value"], $row["answer_value"]);
         $csvMain->add($data);
     }
     return true;
 }
 /**
  * 日付を取得する
  *
  * @return array	日付データ
  * @access	public
  */
 function &_getDate($dateTime, $format = _SHORT_DATE_FORMAT)
 {
     $tempDate = timezone_date_format($dateTime, null);
     if (substr($tempDate, 8) == "000000") {
         $previousDay = -1;
         $format = str_replace("H", "24", $format);
     } else {
         $previousDay = 0;
     }
     $date = mktime(intval(substr($tempDate, 8, 2)), intval(substr($tempDate, 10, 2)), intval(substr($tempDate, 12, 2)), intval(substr($tempDate, 4, 2)), intval(substr($tempDate, 6, 2)) + $previousDay, intval(substr($tempDate, 0, 4)));
     $formatDate = date($format, $date);
     return $formatDate;
 }
 /**
  * CSVデータを設定する
  *
  * @param	array	$recordSet	ADORecordSet
  * @return boolean	true:正常、false:異常
  * @access	private
  */
 function _makeCSV(&$recordSet)
 {
     $container =& DIContainerFactory::getContainer();
     $filterChain =& $container->getComponent("FilterChain");
     $smartyAssign =& $filterChain->getFilterByName("SmartyAssign");
     $csvMain =& $container->getComponent("csvMain");
     $items = $this->_request->getParameter("items");
     $data = array();
     $data[] = $smartyAssign->getLang('registration_data_id');
     foreach ($items as $item) {
         $data[] = $item["item_name"];
     }
     $data[] = $smartyAssign->getLang("registration_entry_date");
     $csvMain->add($data);
     $datas = array();
     $fileDataFormat = $smartyAssign->getLang("registration_file_data_format");
     while ($row = $recordSet->fetchRow()) {
         $data = array();
         $data[] = $row['data_id'];
         foreach ($items as $item) {
             $key = "item_data_value" . $item["item_id"];
             $value = $row[$key];
             if (!empty($value) && $item["item_type"] == REGISTRATION_TYPE_FILE) {
                 $key = "file_name" . $item["item_id"];
                 $value = $row[$key] . sprintf($fileDataFormat, $value);
             }
             $data[] = $value;
         }
         $data[] = timezone_date_format($row["insert_time"], _FULL_DATE_FORMAT);
         $csvMain->add($data);
     }
     return $datas;
 }
 /**
  * fetch時コールバックメソッド
  * @param result adodb object
  * @return array
  * @access	private
  */
 function &_getChildFetchcallback($result, $direction_flag)
 {
     $ret = array();
     while ($row = $result->fetchRow()) {
         if (!empty($row['journal_date'])) {
             $row['journal_date'] = timezone_date_format($row['journal_date'], "YmdHis");
         }
         if ($direction_flag == JOURNAL_TRACKBACK_RECEIVE) {
             if (!empty($row['tb_url'])) {
                 $pos = strpos($row['tb_url'], "?action=journal_view_main_detail");
                 if ($pos != false) {
                     $row['tb_url'] = str_replace("?action=journal_view_main_detail", "?action=pages_view_main&active_action=journal_view_main_detail", $row['tb_url']);
                 }
             }
             $row["title"] = mb_convert_encoding($row["title"], _CHARSET, "auto");
             $row["content"] = mb_convert_encoding($row["content"], _CHARSET, "auto");
         }
         $row['has_edit_auth'] = $this->_hasEditAuthority($row['insert_user_id']);
         $row['has_confirm_auth'] = $this->_hasConfirmAuthority();
         $ret[] = $row;
     }
     return $ret;
 }
 /**
  * 課題データ配列を生成する
  *
  * @param	array	$recordSet	タスクADORecordSet
  * @param	string	$format		日付フォーマット文字列
  * @return array	タスクデータ配列
  * @access	private
  */
 function _makePeriod(&$assignment)
 {
     static $soon_period = null;
     static $thisDate = null;
     static $soonDate = null;
     if (!isset($soon_period)) {
         $soon_period = $this->_getSoonPeriod();
         $thisDate = timezone_date_format(null, null);
         $soonDate = date("YmdHis", mktime(0, 0, 0, intval(substr($thisDate, 4, 2)), intval(substr($thisDate, 6, 2)) + $soon_period, intval(substr($thisDate, 0, 4))));
     }
     if (!empty($assignment["period"])) {
         $period = timezone_date_format($assignment["period"], null);
         if (substr($period, 8) == "000000") {
             $previousDay = -1;
             $timeFormat = "";
         } else {
             $previousDay = 0;
             $timeFormat = _SHORT_TIME_FORMAT;
         }
         $date = mktime(intval(substr($period, 8, 2)), intval(substr($period, 10, 2)), intval(substr($period, 12, 2)), intval(substr($period, 4, 2)), intval(substr($period, 6, 2)) + $previousDay, intval(substr($period, 0, 4)));
         $assignment["display_period_date"] = date(_DATE_FORMAT, $date);
         $assignment["display_period_time"] = date($timeFormat, $date);
         $assignment["input_period"] = date(_INPUT_DATE_FORMAT, $date);
         if ($assignment["activity"] == _ON) {
             if ($thisDate > $period) {
                 $assignment["period_class_name"] = ASSIGNMENT_PERIOD_CLASS_NAME_OVER;
             } elseif ($soonDate >= $period) {
                 $assignment["period_class_name"] = ASSIGNMENT_PERIOD_CLASS_NAME_SOON;
             } else {
                 $assignment["period_class_name"] = "";
             }
         }
     }
     return true;
 }
 /**
  * 新着情報のコールバック関数
  *
  * @access	private
  */
 function _callbackWhatsnewTitle(&$recordSet, $title_metadata_id)
 {
     $result = array("title" => null, "description" => null);
     while ($row = $recordSet->fetchRow()) {
         if ($row['metadata_id'] == $title_metadata_id && !isset($result["title"])) {
             switch ($row["type"]) {
                 case MULTIDATABASE_META_TYPE_FILE:
                 case MULTIDATABASE_META_TYPE_IMAGE:
                     if (empty($row["file_name"])) {
                         $title = MULTIDATABASE_NOTITLE;
                     } else {
                         $title = $row["file_name"];
                     }
                     $result["title"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_WYSIWYG:
                     $container =& DIContainerFactory::getContainer();
                     $convertHtml =& $container->getComponent("convertHtml");
                     $title = $convertHtml->convertHtmlToText($row["content"]);
                     $title = preg_replace("/\\\n/", " ", $title);
                     $title = mb_substr($title, 0, _SEARCH_CONTENTS_LEN + 1, INTERNAL_CODE);
                     $result["title"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_AUTONUM:
                     $title = intval($row["content"]);
                     $result["title"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_DATE:
                     if (empty($row["content"])) {
                         $title = MULTIDATABASE_NOTITLE;
                     } else {
                         $title = timezone_date_format($row["content"], _DATE_FORMAT);
                     }
                     $result["title"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_INSERT_TIME:
                     $title = timezone_date_format($row["insert_time"], _FULL_DATE_FORMAT);
                     $result["title"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_UPDATE_TIME:
                     $title = timezone_date_format($row["update_time"], _FULL_DATE_FORMAT);
                     $result["title"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_MULTIPLE:
                     if (empty($row["content"])) {
                         $title = MULTIDATABASE_NOTITLE;
                     } else {
                         $multipleArr = explode("|", $row["content"]);
                         $title = $multipleArr[0];
                     }
                     $result["title"] = $title;
                     break;
                 default:
                     $result["title"] = $row["content"];
                     break;
             }
             continue;
         }
         if ($row['metadata_id'] != $title_metadata_id && !isset($result["description"])) {
             $result["description"] = $row["content"];
             continue;
         }
         if (isset($result["title"]) && isset($result["description"])) {
             break;
         }
     }
     return $result;
 }
 /**
  * 回覧板データ配列を生成
  *
  * @param object $recordSet ADORecordSet
  * @return array データ配列
  * @access private
  */
 function &_fetchCircularInfo(&$recordSet)
 {
     $circular = $recordSet->fetchRow();
     if (empty($circular['period'])) {
         return $circular;
     }
     list($circular['period'], $ymdPeriodDate) = $this->getDisplayPeriodDate($circular['period']);
     $today = timezone_date_format(null, 'YmdHis');
     if ($today > $ymdPeriodDate) {
         $circular['periodClassName'] = CIRCULAR_PERIOD_OVER;
     }
     return $circular;
 }
 /**
  * execute処理
  *
  * @access  public
  */
 function execute()
 {
     if ($this->block_id_arr) {
         $sqlwhere = " WHERE block.block_id IN (" . implode(",", $this->block_id_arr) . ")";
     } else {
         return 'success';
     }
     $sqlwhere .= " AND contents.temporary_flag = " . MULTIDATABASE_STATUS_RELEASED_VALUE;
     $sqlwhere .= $this->sqlwhere;
     $sqlwhere .= " GROUP BY contents.content_id ";
     $sql = "SELECT COUNT(*)" . " FROM {multidatabase} mdb" . " INNER JOIN {multidatabase_block} block ON (mdb.multidatabase_id=block.multidatabase_id)" . " INNER JOIN {multidatabase_content} contents ON (mdb.multidatabase_id=contents.multidatabase_id)" . " INNER JOIN {multidatabase_metadata_content} datas ON (contents.content_id=datas.content_id)" . $sqlwhere;
     $result = $this->db->execute($sql, $this->params, null, null, false);
     if ($result !== false) {
         $this->count = count($result);
     } else {
         $this->count = 0;
     }
     if ($this->only_count == _ON) {
         return 'count';
     }
     if ($this->count > 0) {
         $sql = "SELECT block.block_id, mdb.multidatabase_id, mdb.title_metadata_id, title.content as title, datas.content as content, contents.*, file.file_name" . " FROM {multidatabase} mdb" . " INNER JOIN {multidatabase_block} block ON (mdb.multidatabase_id=block.multidatabase_id)" . " INNER JOIN {multidatabase_content} contents ON (mdb.multidatabase_id=contents.multidatabase_id)" . " INNER JOIN {multidatabase_metadata_content} datas ON (contents.content_id=datas.content_id)" . " LEFT JOIN {multidatabase_metadata_content} title ON (mdb.title_metadata_id=title.metadata_id AND datas.content_id=title.content_id)" . " LEFT JOIN {multidatabase_file} file ON (title.metadata_content_id=file.metadata_content_id)" . $sqlwhere . " ORDER BY contents.insert_time DESC";
         $this->results =& $this->db->execute($sql, $this->params, $this->limit, $this->offset, true, array($this, '_fetchcallback'));
         $metadata_id_arr = array();
         foreach ($this->results as $result) {
             $metadata_id_arr[] = $result["metadata_id"];
         }
         $where_params = array("metadata_id IN (" . implode(',', $metadata_id_arr) . ") " => null);
         $metadatas = $this->db->selectExecute("multidatabase_metadata", $where_params, null, null, null, array($this, '_fetchMetadataCallback'));
         foreach ($this->results as $key => $result) {
             $metadata = $metadatas[$result["metadata_id"]];
             switch ($metadata["type"]) {
                 case MULTIDATABASE_META_TYPE_FILE:
                 case MULTIDATABASE_META_TYPE_IMAGE:
                     if (empty($result["file_name"])) {
                         $title = MULTIDATABASE_NOTITLE;
                     } else {
                         $title = $result["file_name"];
                     }
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_WYSIWYG:
                     $container =& DIContainerFactory::getContainer();
                     $convertHtml =& $container->getComponent("convertHtml");
                     $title = $convertHtml->convertHtmlToText($result["title"]);
                     $title = preg_replace("/\\\n/", " ", $title);
                     $title = mb_substr($title, 0, _SEARCH_CONTENTS_LEN + 1, INTERNAL_CODE);
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_AUTONUM:
                     $title = intval($result["title"]);
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_DATE:
                     if (empty($result["title"])) {
                         $title = MULTIDATABASE_NOTITLE;
                     } else {
                         $title = timezone_date_format($result["title"], _DATE_FORMAT);
                     }
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_INSERT_TIME:
                     $title = timezone_date_format($result["pubDate"], _FULL_DATE_FORMAT);
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_UPDATE_TIME:
                     $title = timezone_date_format($result["update_time"], _FULL_DATE_FORMAT);
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
                     break;
                 case MULTIDATABASE_META_TYPE_MULTIPLE:
                     if (empty($result["title"])) {
                         $title = MULTIDATABASE_NOTITLE;
                     } else {
                         $multipleArr = explode("|", $result["title"]);
                         $title = $multipleArr[0];
                     }
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
                     break;
                 default:
                     if (empty($result["title"])) {
                         $title = MULTIDATABASE_NOTITLE;
                     } else {
                         $title = $result["title"];
                     }
                     $this->results[$key]["title"] = $title;
                     $this->results[$key]["description"] = $title;
             }
             unset($this->results[$key]["title_metadata_id"]);
             unset($this->results[$key]["file_name"]);
             unset($this->results[$key]["update_time"]);
         }
     }
     return 'success';
 }
 /**
  * メールを送信する
  *
  * @access	public
  */
 function send()
 {
     if ($this->setting_config == false) {
         $this->_log->error("システム管理の設定が正しくありません", "Mailer#send");
         return false;
     }
     if ($this->body == "") {
         $this->_log->error("メッセージ本文がありません", "Mailer#send");
         return false;
     }
     if (!empty($this->priority)) {
         $this->headers[] = "X-Priority: " . $this->priority;
     }
     $this->headers[] = "X-Mailer: PHP/" . phpversion();
     $this->headers[] = "Return-Path: " . $this->fromEmail;
     $container =& DIContainerFactory::getContainer();
     $configView =& $container->getComponent("configView");
     $this->assign("X-FROM_EMAIL", $this->fromEmail);
     $this->assign("X-FROM_NAME", htmlspecialchars($this->fromName));
     $confs = $configView->getConfigByConfname(_SYS_CONF_MODID, "sitename");
     $this->assign("X-SITE_NAME", htmlspecialchars($confs["conf_value"]));
     $this->assign("X-SITE_URL", BASE_URL . INDEX_FILE_NAME);
     $session =& $container->getComponent("Session");
     if (!isset($this->_assignedTags['X-ROOM'])) {
         $request =& $container->getComponent("Request");
         $pageView =& $container->getComponent("pagesView");
         $roomId = $request->getParameter("room_id");
         $pages = $pageView->getPageById($roomId);
         $this->assign("X-ROOM", htmlspecialchars($pages["page_name"]));
     }
     if (!isset($this->_assignedTags["X-USER"])) {
         $this->assign("X-USER", htmlspecialchars($session->getParameter("_handle")));
     }
     $commonMain =& $container->getComponent("commonMain");
     $convertHtml =& $commonMain->registerClass(WEBAPP_DIR . '/components/convert/Html.class.php', "Convert_Html", "convertHtml");
     foreach ($this->_assignedTags as $k => $v) {
         if (substr($k, 0, 4) == "X-TO" || $k == "X-URL") {
             continue;
         }
         $this->body = str_replace("{" . $k . "}", $v, $this->body);
         $this->subject = str_replace("{" . $k . "}", $convertHtml->convertHtmlToText($v), $this->subject);
     }
     $this->body = str_replace("\r\n", "\n", $this->body);
     $this->body = str_replace("\r", "\n", $this->body);
     $this->body = str_replace("\n", $this->_LE, $this->body);
     $this->body = $this->_insertNewLine($this->body);
     if (isset($this->_assignedTags["X-URL"])) {
         $this->body = str_replace("{X-URL}", "<a href=\"" . $this->_assignedTags["X-URL"] . "\">" . $this->_assignedTags["X-URL"] . "</a>", $this->body);
         $mobile_body = str_replace("{X-URL}", $this->_assignedTags["X-URL"], $this->body);
         unset($this->_assignedTags["X-URL"]);
     } else {
         $mobile_body = $this->body;
     }
     $mobile_body = $convertHtml->convertHtmlToText($mobile_body);
     $mobile_body = $this->_insertNewLine($mobile_body);
     if (count($this->toUsers) > 0) {
         foreach ($this->toUsers as $user) {
             $email = $user["email"];
             if (empty($email)) {
                 continue;
             }
             if (isset($this->_assignedTags["X-TO_DATE"])) {
                 $date = timezone_date_format($this->_assignedTags["X-TO_DATE"], _FULL_DATE_FORMAT);
             } else {
                 $date = "";
             }
             if (!isset($user["handle"])) {
                 $user["handle"] = "";
             }
             // type (html(email) or text(mobile_email))
             if (!isset($user["type"])) {
                 $user["type"] = "html";
             }
             if (empty($user["lang_dirname"])) {
                 $user["lang_dirname"] = $session->getParameter("_lang");
                 if (!isset($user["lang_dirname"]) || $user["lang_dirname"] == "") {
                     $user["lang_dirname"] = "japanese";
                 }
             }
             $subject = $this->subject;
             if ($this->isHTML == true && ($user["type"] == "html" || $user["type"] == "email")) {
                 // htmlメール
                 $this->_mailer->IsHTML(true);
                 $body = $this->body;
                 $body = str_replace("{X-TO_HANDLE}", htmlspecialchars($user["handle"]), $body);
             } else {
                 // テキストメール
                 $this->_mailer->IsHTML(false);
                 $body = $mobile_body;
                 $body = str_replace("{X-TO_HANDLE}", $user["handle"], $body);
             }
             $subject = str_replace("{X-TO_HANDLE}", $user["handle"], $subject);
             $subject = str_replace("{X-TO_EMAIL}", $email, $subject);
             $subject = str_replace("{X-TO_DATE}", $date, $subject);
             $body = str_replace("{X-TO_EMAIL}", $email, $body);
             $body = str_replace("{X-TO_DATE}", $date, $body);
             $localFilePath = WEBAPP_DIR . "/language/" . strtolower($user["lang_dirname"]) . "/Mailer_Local.php";
             if (file_exists($localFilePath)) {
                 require_once $localFilePath;
                 $className = "Mailer_Local_" . ucfirst(strtolower($user["lang_dirname"]));
                 $local =& new $className();
                 $this->_mailer->CharSet = $local->charSet;
                 $this->_mailer->Encoding = $local->encoding;
                 if (!empty($this->fromName)) {
                     $this->_mailer->FromName = $local->encodeFromName($this->fromName);
                 }
                 $this->_mailer->Subject = $local->encodeSubject($subject);
                 $this->_mailer->Body = $local->encodeBody($body);
             } else {
                 $this->_mailer->CharSet = $this->charSet;
                 $this->_mailer->Encoding = $this->encoding;
                 if (!empty($this->fromName)) {
                     $this->_mailer->FromName = $this->fromName;
                 }
                 $this->_mailer->Subject = $subject;
                 $this->_mailer->Body = $body;
             }
             $this->_mailer->ClearAllRecipients();
             $this->_mailer->AddAddress($email);
             if (!empty($this->fromEmail)) {
                 $this->_mailer->From = $this->fromEmail;
             }
             $this->_mailer->ClearCustomHeaders();
             foreach ($this->headers as $header) {
                 $this->_mailer->AddCustomHeader($header);
             }
             if (!$this->_mailer->Send()) {
                 $this->_log->warn($email . "宛にメールを送信できませんでした/" . $this->_mailer->ErrorInfo, "Mailer#send");
             } else {
                 $this->_log->trace($email . "宛にメールを送信しました", "Mailer#send");
             }
             //flush();	// ob_contentが送られてしまうためコメント
         }
     }
     return true;
 }