Ejemplo n.º 1
0
 /**
  * ページInsert
  * @param array()
  * @param boolean room_flag:ルームとして作成する場合、true
  * @param boolean $footer_flag
  * @return int new page_id
  * @access	public
  */
 function insPage($ins_params = array(), $room_flag = false, $footer_flag = true)
 {
     $page_id = $this->_db->nextSeq('pages');
     if ($room_flag) {
         $params = array('page_id' => $page_id, 'room_id' => $page_id);
     } else {
         $params = array('page_id' => $page_id);
     }
     $params = array_merge($params, $ins_params);
     if (!isset($params['url'])) {
         $params['url'] = '';
     }
     if (!isset($params['permalink'])) {
         $params['permalink'] = '';
     }
     $result = $this->_db->insertExecute("pages", $params, $footer_flag);
     if ($result === false) {
         return false;
     }
     return $page_id;
 }
Ejemplo n.º 2
0
 /**
  * 会員テーブルInsert
  * 
  * @param   array   $params     パラメータ引数
  * @return boolean true or false
  * @access	public
  */
 function insUser($params = array())
 {
     $sitesView =& $this->_container->getComponent("sitesView");
     $sites = $sitesView->getSelfSite();
     while (1) {
         $id = $this->_db->nextSeq("users");
         $user_id = sha1(uniqid($sites['site_id'] . $id, true));
         // Hash値で同じものがないか念のためチェック
         $result = $this->_db->selectExecute("users", array("user_id" => $user_id));
         if ($result === false) {
             return false;
         }
         if (!isset($result[0]['user_id'])) {
             break;
         }
     }
     $params = array_merge(array("user_id" => $user_id), $params);
     $result = $this->_db->insertExecute("users", $params, true);
     if ($result === false) {
         return false;
     }
     return $user_id;
 }
Ejemplo n.º 3
0
 /**
  * Uploads Insert
  * @param array(page_id, module_id, file_name, file_path, action_name, file_size, mimetype, extension, garbage_flag)
  * @return int upload_id
  * @access	public
  */
 function insUploads($params)
 {
     $upload_id = $this->_db->nextSeq("uploads");
     $params['upload_id'] = $upload_id;
     if ($params['physical_file_name'] == "") {
         $params['physical_file_name'] = $params['upload_id'] . "." . $params['extension'];
     }
     if (!isset($params['sess_id']) || $params['sess_id'] == "") {
         $session =& $this->_container->getComponent("Session");
         $params['sess_id'] = $session->getID();
     }
     $footer_flag = false;
     if (!isset($params['insert_time'])) {
         $footer_flag = true;
     }
     $result = $this->_db->insertExecute("uploads", $params, $footer_flag);
     if ($result === false) {
         return false;
     }
     return $upload_id;
 }
Ejemplo n.º 4
0
 /**
  * 記事データを登録する
  *
  * @return boolean	true or false
  * @access	public
  */
 function setPost()
 {
     // --- 記事テーブルに登録 ---
     $params = array("bbs_id" => $this->_request->getParameter("bbs_id"), "subject" => $this->_request->getParameter("subject"));
     $container =& DIContainerFactory::getContainer();
     $session =& $container->getComponent("Session");
     $mobile_flag = $session->getParameter('_mobile_flag');
     if ($mobile_flag == _OFF) {
         $params['icon_name'] = $this->_request->getParameter('icon_name');
     }
     $container =& DIContainerFactory::getContainer();
     $bbsView =& $container->getComponent("bbsView");
     $postID = $this->_request->getParameter("post_id");
     $bbs = $this->_request->getParameter("bbs");
     $insertFlag = false;
     if (empty($postID)) {
         $postID = $this->_db->nextSeq("bbs_post");
         $parentID = $this->_request->getParameter("parent_id");
         if (empty($parentID)) {
             $params["topic_id"] = $postID;
             $params["parent_id"] = 0;
         } else {
             $params["parent_id"] = $parentID;
             $params["topic_id"] = $bbsView->getTopicID($parentID);
             if ($params["topic_id"] === false) {
                 return false;
             }
         }
         $insertFlag = true;
         $this->_request->setParameter("post_id", $postID);
     } else {
         $params["topic_id"] = $bbsView->getTopicID($postID);
     }
     $params["post_id"] = $postID;
     $temporary = intval($this->_request->getParameter("temporary"));
     if (!$insertFlag) {
         $post = $this->_request->getParameter("post");
         if (empty($post)) {
             return false;
         }
         if ($temporary == _ON && $post["status"] != BBS_STATUS_BEFORE_RELEASED_VALUE) {
             $params["status"] = BBS_STATUS_TEMPORARY_VALUE;
         }
     }
     if (!isset($params["status"])) {
         if ($temporary == _ON) {
             $params["status"] = BBS_STATUS_BEFORE_RELEASED_VALUE;
         } else {
             $params["status"] = BBS_STATUS_RELEASED_VALUE;
         }
     }
     $body = $this->_request->getParameter("body");
     if ($mobile_flag == _ON) {
         $mobile_images = $this->_request->getParameter('bbs_mobile_images');
         $current_mobile_image = $session->getParameter('bbs_current_mobile_image');
         $br = '';
         if (substr(rtrim($body), -6) != '<br />') {
             $br = '<br />';
         }
         if (!empty($mobile_images)) {
             foreach ($mobile_images as $image) {
                 $body .= $br . $image;
             }
         } elseif (!empty($current_mobile_image)) {
             $body .= $br . $current_mobile_image;
         }
     }
     $params["contained_sign"] = $this->getContainedSignString($body);
     if ($insertFlag) {
         $result = $this->_db->insertExecute("bbs_post", $params, true);
     } else {
         if ($params["status"] == BBS_STATUS_RELEASED_VALUE && $post["status"] == BBS_STATUS_BEFORE_RELEASED_VALUE) {
             $params["insert_time"] = timezone_date();
             $post["insert_time"] = $params["insert_time"];
         }
         $result = $this->_db->updateExecute("bbs_post", $params, "post_id", true);
     }
     if ($result === false) {
         return false;
     }
     // --- 本文テーブルに登録 ---
     $status = $params["status"];
     $topicID = $params["topic_id"];
     $subject = $params["subject"];
     $room_id = $this->_request->getParameter("room_id");
     $params = array("post_id" => $postID, "body" => $body, "room_id" => $room_id);
     if ($insertFlag) {
         $result = $this->_db->insertExecute("bbs_post_body", $params);
     } else {
         $result = $this->_db->updateExecute("bbs_post_body", $params, "post_id");
     }
     if ($result === false) {
         return false;
     }
     // --- 根記事テーブルに登録 ---
     $child_flag = $topicID == $postID ? _OFF : _ON;
     if ($topicID == $postID && $insertFlag) {
         $params = array("topic_id" => $postID, "newest_time" => timezone_date(), "child_num" => "0", "room_id" => $room_id);
         $result = $this->_db->insertExecute("bbs_topic", $params);
     } else {
         $countSQL = "";
         if ($topicID != $postID) {
             $count = 0;
             if ($status == BBS_STATUS_TEMPORARY_VALUE && $post["status"] == BBS_STATUS_RELEASED_VALUE) {
                 $count = -1;
             } elseif ($status == BBS_STATUS_RELEASED_VALUE && (!isset($post) || $post["status"] != BBS_STATUS_RELEASED_VALUE)) {
                 $count = 1;
             }
             $countSQL = ", child_num = child_num + (" . $count . ") ";
         }
         $params = array(timezone_date(), $topicID);
         $sql = "UPDATE {bbs_topic} " . "SET newest_time = ? " . $countSQL . "WHERE topic_id = ?";
         $result = $this->_db->execute($sql, $params);
     }
     if ($result === false) {
         return false;
     }
     // --- メール送信データ登録 ---
     if ($bbs["mail_send"] == _ON && $status == BBS_STATUS_RELEASED_VALUE && ($insertFlag || $post["status"] == BBS_STATUS_BEFORE_RELEASED_VALUE)) {
         $session->setParameter("bbs_mail_post_id", $postID);
     }
     //--URL短縮形関連 Start--
     if ($insertFlag) {
         $container =& DIContainerFactory::getContainer();
         $abbreviateurlAction =& $container->getComponent("abbreviateurlAction");
         $result = $abbreviateurlAction->setAbbreviateUrl($this->_request->getParameter("bbs_id"), $postID);
         if ($result === false) {
             return false;
         }
     }
     //--URL短縮形関連 End--
     //--新着情報関連 Start--
     $whatsnewAction =& $container->getComponent("whatsnewAction");
     if ($temporary != _ON) {
         $whatsnew = array("unique_id" => $postID, "title" => $subject, "description" => $body, "action_name" => "bbs_view_main_post", "parameters" => "post_id=" . $postID, "child_flag" => $child_flag);
         if (!empty($post)) {
             $whatsnew["insert_time"] = $post["insert_time"];
             $whatsnew["insert_user_id"] = $post["insert_user_id"];
             $whatsnew["insert_user_name"] = $post["insert_user_name"];
         }
         $result = $whatsnewAction->auto($whatsnew);
     } else {
         $result = $whatsnewAction->delete($postID);
     }
     if ($result === false) {
         return false;
     }
     //--新着情報関連 End--
     // --- 投稿回数更新 ---
     if ($status == BBS_STATUS_RELEASED_VALUE && ($insertFlag || $post["status"] == BBS_STATUS_BEFORE_RELEASED_VALUE)) {
         $monthlynumberAction =& $container->getComponent("monthlynumberAction");
         if ($insertFlag) {
             $params = array("user_id" => $session->getParameter("_user_id"));
         } else {
             $params = array("user_id" => $post["insert_user_id"]);
         }
         if (!$monthlynumberAction->incrementMonthlynumber($params)) {
             return false;
         }
     }
     $session->removeParameter('bbs_current_mobile_image');
     if (!$insertFlag) {
         return true;
     }
     // --- 既読、投票テーブルに登録 ---
     if (!$this->read($postID)) {
         return false;
     }
     return true;
 }