예제 #1
0
 function getAllChildTopics()
 {
     $ret = array();
     $xt = new XoopsTree($this->table, "topic_id", "topic_pid");
     $topic_arr = $xt->getAllChild($this->topic_id, "topic_title");
     if (is_array($topic_arr) && count($topic_arr)) {
         foreach ($topic_arr as $topic) {
             $ret[] = new XoopsTopic($this->table, $topic);
         }
     }
     return $ret;
 }
 function delete()
 {
     $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("xhnewbb_posts"), $this->post_id);
     if (!($result = $this->db->query($sql))) {
         return false;
     }
     $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("xhnewbb_posts_text"), $this->post_id);
     if (!($result = $this->db->query($sql))) {
         echo "Could not remove posts text for Post ID:" . $this->post_id . ".<br />";
     }
     if (!empty($this->uid)) {
         $sql = sprintf("UPDATE %s SET posts=posts-1 WHERE uid = %u", $this->db->prefix("users"), $this->uid);
         if (!($result = $this->db->query($sql))) {
             //	echo "Could not update user posts.";
         }
     }
     if ($this->istopic()) {
         $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $this->db->prefix("xhnewbb_topics"), $this->topic_id);
         if (!($result = $this->db->query($sql))) {
             echo "Could not delete topic.";
         }
         // u2t table
         $this->db->query("DELETE FROM " . $this->db->prefix("xhnewbb_users2topics") . " WHERE topic_id = {$this->topic_id}");
         // end of u2t table
     }
     include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
     $mytree = new XoopsTree($this->db->prefix("xhnewbb_posts"), "post_id", "pid");
     $arr = $mytree->getAllChild($this->post_id);
     $size = count($arr);
     if ($size > 0) {
         for ($i = 0; $i < $size; $i++) {
             $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("xhnewbb_posts"), $arr[$i]['post_id']);
             if (!($result = $this->db->query($sql))) {
                 echo "Could not delete post " . $arr[$i]['post_id'] . "";
             }
             $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("xhnewbb_posts_text"), $arr[$i]['post_id']);
             if (!($result = $this->db->query($sql))) {
                 echo "Could not delete post text " . $arr[$i]['post_id'] . "";
             }
             if (!empty($arr[$i]['uid'])) {
                 $sql = "UPDATE " . $this->db->prefix("users") . " SET posts=posts-1 WHERE uid=" . $arr[$i]['uid'] . "";
                 if (!($result = $this->db->query($sql))) {
                     //	echo "Could not update user posts.";
                 }
             }
         }
     }
 }
예제 #3
0
 function delete(&$post, $isDeleteOne = true, $force = false)
 {
     if (!is_object($post) || $post->getVar('post_id') == 0) {
         return false;
     }
     if ($isDeleteOne) {
         if ($post->isTopic()) {
             $criteria = new CriteriaCompo(new Criteria("topic_id", $post->getVar('topic_id')));
             $criteria->add(new Criteria('approved', 1));
             $criteria->add(new Criteria('pid', 0, ">"));
             if ($this->getPostCount($criteria) > 0) {
                 return false;
             }
         }
         return $this->_delete($post, $force);
     } else {
         require_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
         $mytree = new XoopsTree($this->db->prefix("bb_posts"), "post_id", "pid");
         $arr = $mytree->getAllChild($post->getVar('post_id'));
         for ($i = 0; $i < count($arr); $i++) {
             $childpost =& $this->create(false);
             $childpost->assignVars($arr[$i]);
             $this->_delete($childpost, $force);
             unset($childpost);
         }
         $this->_delete($post, $force);
     }
     return true;
 }
예제 #4
0
 function delete(&$post, $isDeleteOne = true)
 {
     if ($isDeleteOne) {
         return $this->_delete($post);
     } else {
         include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
         $mytree = new XoopsTree($this->db->prefix("bb_posts"), "post_id", "pid");
         $arr = $mytree->getAllChild($post->getVar('post_id'));
         for ($i = 0; $i < count($arr); $i++) {
             $childpost =& $this->create(false);
             $childpost->assignVars($arr[$i]);
             $this->_delete($childpost);
             unset($childpost);
         }
         $this->_delete($post);
     }
     return true;
 }
예제 #5
0
 function delete()
 {
     $sql = sprintf("DELETE FROM %s WHERE comment_id = %u", $this->ctable, $this->getVar('comment_id'));
     if (!($result = $this->db->query($sql))) {
         return false;
     }
     $sql = sprintf("UPDATE %s SET posts = posts-1 WHERE uid = %u", $this->db->prefix("users"), $this->getVar("user_id"));
     if (!($result = $this->db->query($sql))) {
         echo "Could not update user posts.";
     }
     $mytree = new XoopsTree($this->ctable, "comment_id", "pid");
     $arr = $mytree->getAllChild($this->getVar("comment_id"), "comment_id");
     $size = count($arr);
     if ($size > 0) {
         for ($i = 0; $i < $size; $i++) {
             $sql = sprintf("DELETE FROM %s WHERE comment_bid = %u", $this->ctable, $arr[$i]['comment_id']);
             if (!($result = $this->db->query($sql))) {
                 echo "Could not delete comment.";
             }
             $sql = sprintf("UPDATE %s SET posts = posts-1 WHERE uid = %u", $this->db->prefix("users"), $arr[$i]['user_id']);
             if (!($result = $this->db->query($sql))) {
                 echo "Could not update user posts.";
             }
         }
     }
     return $size + 1;
 }
예제 #6
0
	function getAllChild(){
		$ret = array();
		$xt = new XoopsTree($this->table, "id", "pid");

// bug fix: constant parse error: orders -> "orders"
//		$category_arr = $xt->getAllChild($this->id, orders);
		$category_arr = $xt->getAllChild($this->id, "orders");

		if ( is_array($category_arr) && count($category_arr) ) {
			foreach($category_arr as $category){
				$ret[] = new WfsCategory($category);
			}
		}
		return $ret;
	}
예제 #7
0
 /**
  * Enter description here...
  *
  * @return int
  */
 public function delete()
 {
     $sql = sprintf('DELETE FROM %s WHERE comment_id = %u', $this->ctable, $this->getVar('comment_id'));
     if (!($result = $this->db->query($sql))) {
         return false;
     }
     $sql = sprintf('UPDATE %s SET posts = posts-1 WHERE uid = %u', $this->db->prefix('users'), $this->getVar('user_id'));
     if (!($result = $this->db->query($sql))) {
         echo 'Could not update user posts.';
     }
     $mytree = new XoopsTree($this->ctable, 'comment_id', 'pid');
     $arr = $mytree->getAllChild($this->getVar('comment_id'), 'comment_id');
     $size = count($arr);
     if ($size > 0) {
         for ($i = 0; $i < $size; ++$i) {
             $sql = sprintf('DELETE FROM %s WHERE comment_bid = %u', $this->ctable, $arr[$i]['comment_id']);
             if (!($result = $this->db->query($sql))) {
                 echo 'Could not delete comment.';
             }
             $sql = sprintf('UPDATE %s SET posts = posts-1 WHERE uid = %u', $this->db->prefix('users'), $arr[$i]['user_id']);
             if (!($result = $this->db->query($sql))) {
                 echo 'Could not update user posts.';
             }
         }
     }
     return $size + 1;
 }
예제 #8
0
 function saveEntry()
 {
     global $xoopsModuleConfig;
     $myts =& MyTextSanitizer::getInstance();
     $this->setItemCriteria();
     if (isset($_POST['cancel'])) {
         $baseUrl = XMOBILE_URL . '/?act=' . $this->controller->getActionState() . '&plg=' . $this->controller->getPluginState();
         if ($this->sessionHandler->getSessionID() != '') {
             $baseUrl .= '&sess=' . $this->sessionHandler->getSessionID();
         }
         if ($this->topic_id != 0) {
             $baseUrl .= '&view=detail';
             $baseUrl .= '&start=' . $this->start;
             $baseUrl .= '&topic_id=' . $this->topic_id;
         } elseif ($this->forum_id != 0) {
             $baseUrl .= '&view=list&level=topic';
             $baseUrl .= '&forum_id=' . $this->forum_id;
         }
         header('Location: ' . $baseUrl);
         exit;
     }
     $this->checkForumAccess();
     $entry_type = htmlspecialchars($this->utils->getGetPost('entry_type', ''), ENT_QUOTES);
     $this->ticket =& new XoopsGTicket();
     // debug
     $this->utils->setDebugMessage(__CLASS__, 'getConfirmView entry_type', $entry_type);
     //チケットの確認
     //		if(!$ticket_check = $this->ticket->check())
     if (!($ticket_check = $this->ticket->check(true, '', false))) {
         //			return $this->ticket->getErrors();
         return _MD_XMOBILE_TICKET_ERROR;
     }
     $allow_html = 0;
     $new_id = 0;
     $sql = 'SELECT allow_html FROM ' . $this->db->prefix('xhnewbb_forums') . ' WHERE forum_id = ' . $this->forum_id;
     $ret = $this->db->query($sql);
     if (!$ret) {
         $this->utils->setDebugMessage(__CLASS__, 'getConfirmView db error', $this->db->error());
         return false;
     } else {
         $row = $this->db->fetchRow($ret);
         $allow_html = intval($row[0]);
         if ($allow_html == 0) {
             $nohtml = 1;
         } else {
             $nohtml = 0;
         }
     }
     $pid = intval($this->utils->getPost('pid', 0));
     $post_time = time();
     $uid = $this->sessionHandler->getUid();
     $poster_ip = $myts->makeTboxData4Save($_SERVER['REMOTE_ADDR']);
     $subject = $myts->makeTboxData4Save($this->utils->getPost('subject', ''));
     $nosmiley = intval($this->utils->getPost('nosmiley', 0));
     $icon = $myts->makeTboxData4Save($this->utils->getPost('icon', ''));
     $attachsig = intval($this->utils->getPost('attachsig', 0));
     $post_text = $myts->makeTareaData4Save($this->utils->getPost('post_text', ''));
     $poster_name = $myts->makeTareaData4Save($this->utils->getPost('poster_name', ''));
     if ($poster_name != '') {
         $post_text = sprintf(_MD_XHNEWBB_FMT_GUESTSPOSTHEADER, $poster_name) . $post_text;
     }
     // debug
     $this->utils->setDebugMessage(__CLASS__, 'getConfirmView sql', $sql);
     $this->utils->setDebugMessage(__CLASS__, 'getConfirmView allow_html', $allow_html);
     $this->utils->setDebugMessage(__CLASS__, 'getConfirmView nohtml', $nohtml);
     if ($entry_type != 'delete_entry' && $subject == '') {
         $body = _MD_XMOBILE_NEED_DATA;
         $body .= $this->getEditView();
         return $body;
     }
     switch ($entry_type) {
         case 'new_entry':
             if ($this->forum_access < 2) {
                 return _MD_XMOBILE_NO_PERM_MESSAGE;
             }
             $sql_insert_topics = "INSERT INTO " . $this->db->prefix('xhnewbb_topics') . " (topic_title,topic_poster,topic_time,topic_views,topic_replies,topic_last_post_id,forum_id) VALUES ('{$subject}',{$uid},{$post_time},0,0,0," . $this->forum_id . ")";
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_topics', $sql_insert_topics);
             if (!($ret_insert_topics = $this->db->query($sql_insert_topics))) {
                 // debug
                 $this->utils->setDebugMessage(__CLASS__, 'sql_insert_topics error', $this->db->error());
                 return _MD_XMOBILE_INSERT_FAILED;
             }
             $new_topic_id = $this->db->getInsertId();
             $sql_insert_posts = "INSERT INTO " . $this->db->prefix('xhnewbb_posts') . " (pid,topic_id,forum_id,post_time,uid,poster_ip,subject,nohtml,nosmiley,icon,attachsig) VALUES({$pid},{$new_topic_id},{$this->forum_id},{$post_time},{$uid},'{$poster_ip}','{$subject}',{$nohtml},{$nosmiley},'{$icon}',{$attachsig})";
             // debug
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts', $sql_insert_posts);
             if (!($ret_insert_posts = $this->db->query($sql_insert_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts error', $this->db->error());
                 return _MD_XMOBILE_INSERT_FAILED;
             }
             $new_id = $this->db->getInsertId();
             $sql_insert_posts_text = "INSERT INTO " . $this->db->prefix('xhnewbb_posts_text') . " (post_id,post_text) VALUES({$new_id},'{$post_text}')";
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts_text', $sql_insert_posts_text);
             if (!($ret_insert_posts_text = $this->db->query($sql_insert_posts_text))) {
                 $sql_delete_topics = "DELETE FROM " . $this->db->prefix('xhnewbb_topics') . " WHERE topic_id = {$new_topic_id}";
                 $this->db->query($sql_delete_topics);
                 $sql_delete_posts = "DELETE FROM " . $this->db->prefix('xhnewbb_posts') . " WHERE post_id = {$new_id}";
                 $this->db->query($sql_delete_posts);
                 $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts error', $this->db->error());
                 return _MD_XMOBILE_INSERT_FAILED;
             }
             $sql_update_forums = "UPDATE " . $this->db->prefix('xhnewbb_forums') . " SET forum_topics = forum_topics+1, forum_posts = forum_posts+1, forum_last_post_id = {$new_id} WHERE forum_id = {$this->forum_id}";
             $this->utils->setDebugMessage(__CLASS__, 'update_forums', $sql_update_forums);
             if (!($ret_update_forums = $this->db->query($sql_update_forums))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_update_forums error', $this->db->error());
                 return _MD_XMOBILE_INSERT_FAILED;
             }
             $sql_update_topics = "UPDATE " . $this->db->prefix('xhnewbb_topics') . " SET topic_last_post_id = {$new_id} WHERE topic_id = {$new_topic_id}";
             $this->utils->setDebugMessage(__CLASS__, 'sql_update_topics', $sql_update_topics);
             if (!($ret_update_topics = $this->db->query($sql_update_topics))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_update_topics error', $this->db->error());
                 return _MD_XMOBILE_INSERT_FAILED;
             }
             $sql_incremant_posts = sprintf("UPDATE %s SET posts=posts+1 WHERE uid = %u", $this->db->prefix("users"), $uid);
             $this->utils->setDebugMessage(__CLASS__, 'sql_incremant_posts', $sql_incremant_posts);
             if (!($ret_incremant_posts = $this->db->query($sql_incremant_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_incremant_posts error', $this->db->error());
                 return _MD_XMOBILE_INSERT_FAILED;
             }
             $this->utils->setDebugMessage(__CLASS__, 'insert new_entry', 'Success ');
             return _MD_XMOBILE_INSERT_SUCCESS;
             break;
         case 'reply_entry':
             if ($this->forum_access < 2) {
                 return _MD_XMOBILE_NO_PERM_MESSAGE;
             }
             $sql_insert_posts = "INSERT INTO " . $this->db->prefix('xhnewbb_posts') . " (pid,topic_id,forum_id,post_time,uid,poster_ip,subject,nohtml,nosmiley,icon,attachsig) VALUES({$pid},{$this->topic_id},{$this->forum_id},{$post_time},{$uid},'{$poster_ip}','{$subject}',{$nohtml},{$nosmiley},'{$icon}',{$attachsig})";
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts', $sql_insert_posts);
             if (!($ret_insert_posts = $this->db->query($sql_insert_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts error', $this->db->error());
                 return false;
             }
             $new_id = $this->db->getInsertId();
             $sql_insert_posts_text = "INSERT INTO " . $this->db->prefix('xhnewbb_posts_text') . " (post_id,post_text) VALUES({$new_id},'{$post_text}')";
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts_text', $sql_insert_posts_text);
             if (!($ret_insert_posts_text = $this->db->query($sql_insert_posts_text))) {
                 $sql_delete_posts = "DELETE FROM " . $this->db->prefix('xhnewbb_posts') . " WHERE post_id = {$this->post_id}";
                 $this->db->query($sql_delete_posts);
                 $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts_text error', $this->db->error());
                 return false;
             }
             $sql_update_topics = "UPDATE " . $this->db->prefix('xhnewbb_topics') . " SET topic_poster=" . $uid . ", topic_time=" . $post_time . ", topic_replies=topic_replies+1, topic_last_post_id=" . $new_id . " WHERE topic_id=" . $this->topic_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_update_topics', $sql_update_topics);
             if (!($ret_update_topics = $this->db->query($sql_update_topics))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_update_topics error', $this->db->error());
                 return false;
             }
             $sql_update_forums = "UPDATE " . $this->db->prefix('xhnewbb_forums') . " SET forum_posts = forum_posts+1, forum_last_post_id = {$new_id} WHERE forum_id = {$this->forum_id}";
             $this->utils->setDebugMessage(__CLASS__, 'sql_update_forums', $sql_update_forums);
             if (!($ret_update_forums = $this->db->query($sql_update_forums))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_update_forums error', $this->db->error());
                 return false;
             }
             $sql_incremant_posts = sprintf("UPDATE %s SET posts=posts+1 WHERE uid = %u", $this->db->prefix("users"), $uid);
             $this->utils->setDebugMessage(__CLASS__, 'sql_incremant_posts', $sql_incremant_posts);
             if (!($ret_incremant_posts = $this->db->query($sql_incremant_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_incremant_posts error', $this->db->error());
                 return false;
             }
             $this->utils->setDebugMessage(__CLASS__, 'reply_entry', 'Success');
             return _MD_XMOBILE_INSERT_SUCCESS;
             break;
         case 'edit_entry':
             if ($this->forum_access < 3) {
                 return _MD_XMOBILE_NO_PERM_MESSAGE;
             }
             $sql_insert_posts = "UPDATE " . $this->db->prefix('xhnewbb_posts') . " SET pid={$pid}, topic_id=" . $this->topic_id . ", forum_id=" . $this->forum_id . ",post_time={$post_time},poster_ip='{$poster_ip}',subject='{$subject}',nohtml={$nohtml},nosmiley={$nosmiley},icon='{$icon}',attachsig={$attachsig} WHERE post_id=" . $this->post_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts', $sql_insert_posts);
             if (!($ret_insert_posts = $this->db->query($sql_insert_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts error', $this->db->error());
                 return _MD_XMOBILE_UPDATE_FAILED;
             }
             $sql_insert_posts_text = "UPDATE " . $this->db->prefix('xhnewbb_posts_text') . " SET post_id=" . $this->post_id . ",post_text='{$post_text}' WHERE post_id=" . $this->post_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts_text', $sql_insert_posts_text);
             if (!($ret_insert_posts_text = $this->db->query($sql_insert_posts_text))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_insert_posts_text error', $this->db->error());
                 return _MD_XMOBILE_UPDATE_FAILED;
             }
             $sql_insert_topics = "UPDATE " . $this->db->prefix('xhnewbb_topics') . " SET topic_time={$post_time} WHERE topic_id=" . $this->topic_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_insert_topics', $sql_insert_topics);
             if (!($ret_insert_topics = $this->db->query($sql_insert_topics))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_insert_topics error', $this->db->error());
                 return _MD_XMOBILE_UPDATE_FAILED;
             }
             $this->utils->setDebugMessage(__CLASS__, 'edit_entry', 'Success');
             return _MD_XMOBILE_UPDATE_SUCCESS;
             break;
         case 'delete_entry':
             if ($this->forum_access < 3) {
                 return _MD_XMOBILE_NO_PERM_MESSAGE;
             }
             $poster_uid = 0;
             $sql_posts = "SELECT uid FROM " . $this->db->prefix('xhnewbb_posts') . " WHERE post_id = " . $this->post_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_posts', $sql_posts);
             if (!($ret_posts = $this->db->query($sql_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_posts error', $this->db->error());
                 return _MD_XMOBILE_DELETE_FAILED;
             }
             while ($row = $this->db->fetchArray($ret_posts)) {
                 $poster_uid = intval($row['uid']);
             }
             $istopic = 0;
             $pid = 0;
             $sql_istopic = 'SELECT pid FROM ' . $this->db->prefix('xhnewbb_posts') . ' WHERE post_id = ' . $this->post_id;
             if (!($ret_istopic = $this->db->query($sql_istopic))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_istopic error', $this->db->error());
                 return _MD_XMOBILE_DELETE_FAILED;
             }
             while ($row = $this->db->fetchArray($ret_istopic)) {
                 $pid = intval($row['pid']);
             }
             if ($pid == 0) {
                 $istopic = true;
             }
             $sql_delete_posts = "DELETE FROM " . $this->db->prefix('xhnewbb_posts') . " WHERE post_id = " . $this->post_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts', $sql_delete_posts);
             if (!($ret_delete_posts = $this->db->query($sql_delete_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts error', $this->db->error());
                 return _MD_XMOBILE_DELETE_FAILED;
             }
             $sql_delete_posts_text = "DELETE FROM " . $this->db->prefix('xhnewbb_posts_text') . " WHERE post_id = " . $this->post_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts_text', $sql_delete_posts_text);
             if (!($ret_delete_posts_text = $this->db->query($sql_delete_posts_text))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts_text error', $this->db->error());
                 return _MD_XMOBILE_DELETE_FAILED;
             }
             $sql_decrement_posts = sprintf("UPDATE %s SET posts=posts-1 WHERE uid = %u", $this->db->prefix('users'), $poster_uid);
             $this->utils->setDebugMessage(__CLASS__, 'sql_decrement_posts', $sql_decrement_posts);
             if (!($ret_decrement_posts = $this->db->query($sql_decrement_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_decrement_posts error', $this->db->error());
                 return _MD_XMOBILE_DELETE_FAILED;
             }
             include_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
             $child_count = 0;
             $mytree = new XoopsTree($this->db->prefix('xhnewbb_posts'), 'post_id', 'pid');
             $child_arr = $mytree->getAllChild($this->post_id);
             $child_count = count($child_arr);
             $post_count = $child_count + 1;
             if ($child_count > 0) {
                 foreach ($child_arr as $child) {
                     $sql_delete_posts_child = "DELETE FROM " . $this->db->prefix('xhnewbb_posts') . " WHERE pid=" . $child['post_id'];
                     $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts_child', $sql_delete_posts_child);
                     if (!($ret_delete_posts_child = $this->db->query($sql_delete_posts_child))) {
                         $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts_child error', $this->db->error());
                         return _MD_XMOBILE_DELETE_FAILED;
                     }
                     $sql_delete_posts_text_child = "DELETE FROM " . $this->db->prefix('xhnewbb_posts_text') . " WHERE post_id=" . $child['post_id'];
                     $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts_text_child', $sql_delete_posts_text_child);
                     if (!($ret_delete_posts_text_child = $this->db->query($sql_delete_posts_text_child))) {
                         $this->utils->setDebugMessage(__CLASS__, 'sql_delete_posts_text_child error', $this->db->error());
                         return _MD_XMOBILE_DELETE_FAILED;
                     }
                     $sql_decrement_posts_child = sprintf("UPDATE %s SET posts=posts-1 WHERE uid = %u", $this->db->prefix('users'), $child['uid']);
                     $this->utils->setDebugMessage(__CLASS__, 'sql_decrement_posts_child', $sql_decrement_posts_child);
                     if (!($ret_decrement_posts_child = $this->db->query($sql_decrement_posts_child))) {
                         $this->utils->setDebugMessage(__CLASS__, 'sql_decrement_posts_child error', $this->db->error());
                         return _MD_XMOBILE_DELETE_FAILED;
                     }
                 }
             }
             if ($istopic) {
                 $sql_delete_topics = "DELETE FROM " . $this->db->prefix('xhnewbb_topics') . " WHERE topic_id=" . $this->topic_id;
                 $this->utils->setDebugMessage(__CLASS__, 'sql_delete_topics', $sql_delete_topics);
                 if (!($ret_delete_topics = $this->db->query($sql_delete_topics))) {
                     $this->utils->setDebugMessage(__CLASS__, 'sql_delete_topics error', $this->db->error());
                     return _MD_XMOBILE_DELETE_FAILED;
                 }
                 $sql_delete_users2topics = "DELETE FROM " . $this->db->prefix('xhnewbb_users2topics') . " WHERE topic_id=" . $this->topic_id;
                 $this->utils->setDebugMessage(__CLASS__, 'sql_delete_users2topics', $sql_delete_users2topics);
                 if (!($ret_delete_users2topics = $this->db->query($sql_delete_users2topics))) {
                     $this->utils->setDebugMessage(__CLASS__, 'sql_delete_users2topics error', $this->db->error());
                     return _MD_XMOBILE_DELETE_FAILED;
                 }
                 $sql_update_forum_topics = "UPDATE " . $this->db->prefix('xhnewbb_forums') . " SET forum_topics=forum_topics-1 WHERE forum_id=" . $this->forum_id;
                 $this->utils->setDebugMessage(__CLASS__, 'sql_update_forum_topics', $sql_update_forum_topics);
                 if (!($ret_update_forum_topics = $this->db->query($sql_update_forum_topics))) {
                     $this->utils->setDebugMessage(__CLASS__, 'sql_update_forum_topics error', $this->db->error());
                     return _MD_XMOBILE_DELETE_FAILED;
                 }
             } else {
                 $topic_last_post_id = 0;
                 $topic_time = 0;
                 $sql_topic_last_post_id = "SELECT post_id,post_time FROM " . $this->db->prefix('xhnewbb_posts') . " WHERE topic_id=" . $this->topic_id . " ORDER BY post_time " . $this->item_order_sort;
                 if (!($ret_topic_last_post_id = $this->db->query($sql_topic_last_post_id, 1, 0))) {
                     $this->utils->setDebugMessage(__CLASS__, 'sql_topic_last_post_id error', $this->db->error());
                     return _MD_XMOBILE_DELETE_FAILED;
                 }
                 while ($row = $this->db->fetchArray($ret_topic_last_post_id)) {
                     $topic_last_post_id = intval($row['post_id']);
                     $topic_time = intval($row['post_time']);
                 }
                 $sql_update_topics = "UPDATE " . $this->db->prefix('xhnewbb_topics') . " SET topic_time=" . $topic_time . ", topic_replies=topic_replies-" . $post_count . ", topic_last_post_id=" . $topic_last_post_id . " WHERE topic_id=" . $this->topic_id;
                 $this->utils->setDebugMessage(__CLASS__, 'sql_update_topics', $sql_update_topics);
                 if (!($ret_update_topics = $this->db->query($sql_update_topics))) {
                     $this->utils->setDebugMessage(__CLASS__, 'sql_update_topics error', $this->db->error());
                     return _MD_XMOBILE_DELETE_FAILED;
                 }
             }
             $forum_last_post_id = 0;
             $sql_forum_last_post_id = "SELECT post_id FROM " . $this->db->prefix('xhnewbb_posts') . " WHERE forum_id=" . $this->forum_id . " ORDER BY post_time " . $this->item_order_sort;
             if (!($ret_forum_last_post_id = $this->db->query($sql_forum_last_post_id, 1, 0))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_forum_last_post_id error', $this->db->error());
                 return _MD_XMOBILE_DELETE_FAILED;
             }
             while ($row = $this->db->fetchArray($ret_forum_last_post_id)) {
                 $forum_last_post_id = intval($row['post_id']);
             }
             $sql_update_forum_posts = "UPDATE " . $this->db->prefix('xhnewbb_forums') . " SET forum_posts=forum_posts-" . $post_count . ", forum_last_post_id=" . $forum_last_post_id . " WHERE forum_id=" . $this->forum_id;
             $this->utils->setDebugMessage(__CLASS__, 'sql_update_forum_posts', $sql_update_forum_posts);
             if (!($ret_update_forum_posts = $this->db->query($sql_update_forum_posts))) {
                 $this->utils->setDebugMessage(__CLASS__, 'sql_update_forum_posts error', $this->db->error());
                 return _MD_XMOBILE_DELETE_FAILED;
             }
             $this->utils->setDebugMessage(__CLASS__, 'delete_entry', 'Success');
             return _MD_XMOBILE_DELETE_SUCCESS;
             break;
     }
 }
예제 #9
0
 function getAllChild()
 {
     $ret = array();
     $xt = new XoopsTree($this->table, "id", "pid");
     $category_arr = $xt->getAllChild($this->id, orders);
     if (is_array($category_arr) && count($category_arr)) {
         foreach ($category_arr as $category) {
             $ret[] = new WfsCategory($category);
         }
     }
     return $ret;
 }