Example #1
0
    function insert(&$category)
    {
        parent::insert($category, true);
        if ($category->isNew()) {
	        $this->applyPermissionTemplate($category);
        }

        return $category->getVar('cat_id');
    }
Example #2
0
 function insert(&$post, $force = true)
 {
     global $xoopsUser;
     // Set the post time
     // The time should be "publish" time. To be adjusted later
     if (!$post->getVar("post_time")) {
         $post->setVar("post_time", time());
     }
     $topic_handler =& xoops_getmodulehandler("topic", "newbb");
     // Verify the topic ID
     if ($topic_id = $post->getVar("topic_id")) {
         $topic_obj =& $topic_handler->get($topic_id);
         // Invalid topic OR the topic is no approved and the post is not top post
         if (!$topic_obj) {
             return false;
         }
     }
     if (empty($topic_id)) {
         $post->setVar("topic_id", 0);
         $post->setVar("pid", 0);
         $post->setNew();
         $topic_obj =& $topic_handler->create();
     }
     $text_handler =& xoops_getmodulehandler("text", "newbb");
     $post_text_vars = array("post_text", "post_edit", "dohtml", "doxcode", "dosmiley", "doimage", "dobr");
     if ($post->isNew()) {
         if (!($topic_id = $post->getVar("topic_id"))) {
             $topic_obj->setVar("topic_title", $post->getVar("subject", "n"));
             $topic_obj->setVar("topic_poster", $post->getVar("uid"));
             $topic_obj->setVar("forum_id", $post->getVar("forum_id"));
             $topic_obj->setVar("topic_time", $post->getVar("post_time"));
             $topic_obj->setVar("poster_name", $post->getVar("poster_name"), true);
             $topic_obj->setVar("approved", $post->getVar("approved"), true);
             if (!($topic_id = $topic_handler->insert($topic_obj, $force))) {
                 $post->deleteAttachment();
                 $post->setErrors("insert topic error");
                 //xoops_error($topic_obj->getErrors());
                 return false;
             }
             $post->setVar('topic_id', $topic_id);
             $pid = 0;
             $post->setVar("pid", 0);
         } elseif (!$post->getVar("pid")) {
             $pid = $topic_handler->getTopPostId($topic_id);
             $post->setVar("pid", $pid);
         }
         $text_obj =& $text_handler->create();
         foreach ($post_text_vars as $key) {
             $text_obj->vars[$key] = $post->vars[$key];
         }
         $post->destoryVars($post_text_vars);
         if (!($post_id = parent::insert($post, $force))) {
             return false;
         }
         $text_obj->setVar("post_id", $post_id);
         if (!$text_handler->insert($text_obj, $force)) {
             $this->delete($post);
             $post->setErrors("post text insert error");
             //xoops_error($text_obj->getErrors());
             return false;
         }
         if ($post->getVar("approved") > 0) {
             $this->approve($post, true);
         }
         $post->setVar('post_id', $post_id);
     } else {
         if ($post->isTopic()) {
             if ($post->getVar("subject") != $topic_obj->getVar("topic_title")) {
                 $topic_obj->setVar("topic_title", $post->getVar("subject", "n"));
             }
             if ($post->getVar("approved") != $topic_obj->getVar("approved")) {
                 $topic_obj->setVar("approved", $post->getVar("approved"));
             }
             if (!($result = $topic_handler->insert($topic_obj, $force))) {
                 $post->setErrors("update topic error");
                 //xoops_error($topic_obj->getErrors());
                 return false;
             }
         }
         $text_obj =& $text_handler->get($post->getVar("post_id"));
         $text_obj->setDirty();
         foreach ($post_text_vars as $key) {
             $text_obj->vars[$key] = $post->vars[$key];
         }
         $post->destoryVars($post_text_vars);
         if (!($post_id = parent::insert($post, $force))) {
             //xoops_error($post->getErrors());
             return false;
         }
         if (!$text_handler->insert($text_obj, $force)) {
             $post->setErrors("update post text error");
             //xoops_error($text_obj->getErrors());
             return false;
         }
     }
     return $post->getVar('post_id');
 }
Example #3
0
    function insert(&$xforum)
    {
        if(!parent::insert($xforum, true)){
	        xoops_error($xforum->getErrors());
	        return false;
        }
        
        if ($xforum->isNew()) {
        	$this->applyPermissionTemplate($xforum);
    	}

        return $xforum->getVar('forum_id');
    }
Example #4
0
    function setRead_db($read_item, $post_id, $uid)
    {
	    if(empty($uid)){
		    if(is_object($GLOBALS["xoopsUser"])){
			    $uid = $GLOBALS["xoopsUser"]->getVar("uid");
		    }else{
			    return false;
		    }
	    }
	    
	    $sql = "UPDATE ".$this->table.
	    		" SET post_id = ".intval($post_id).",".
	    		" 	read_time =".time().
	    		" WHERE read_item = ".intval($read_item).
	    		" 	AND uid = ".intval($uid);
	    if($this->db->queryF($sql) && $this->db->getAffectedRows()){
		    return true;
	    }
	    $object =& $this->create();
	    $object->setVar("read_item", $read_item, true);
	    $object->setVar("post_id", $post_id, true);
	    $object->setVar("uid", $uid, true);
	    $object->setVar("read_time", time(), true);
	    return parent::insert($object);
    }
Example #5
0
    function insert(&$post, $force = true)
    {
        global $xoopsUser, $xoopsConfig;

        $topic_handler =& xoops_getmodulehandler("topic", "xforum");
	    // Verify the topic ID
        if($topic_id = $post->getVar("topic_id")){
	        $topic_obj =& $topic_handler->get($topic_id);
	        // Invalid topic OR the topic is no approved and the post is not top post
	        if( !$topic_obj 
	        //	|| (!$post->isTopic() && $topic_obj->getVar("approved") < 1) 
	        ){
		        return false;
	        }
        }
        if(empty($topic_id)){
	        $post->setVar("topic_id", 0);
	        $post->setVar("pid", 0);
	        $post->setNew();
	        $topic_obj =& $topic_handler->create();
        }
        $text_handler =& xoops_getmodulehandler("text", "xforum");
        $post_text_vars = array("post_text", "post_edit");
        if ($post->isNew()) {
            if (!$topic_id = $post->getVar("topic_id")) {
	            $topic_obj->setVar("topic_title", $post->getVar("subject", "n"));
	            $topic_obj->setVar("topic_poster", $post->getVar("uid"));
	            $topic_obj->setVar("forum_id", $post->getVar("forum_id"));
	            $topic_obj->setVar("topic_time", $post->getVar("post_time"));
	            $topic_obj->setVar("poster_name", $post->getVar("poster_name"), true);
	            $topic_obj->setVar("approved", $post->getVar("approved"), true);
                if (!$topic_id = $topic_handler->insert($topic_obj, $force)) {
                    $post->deleteAttachment();
                    $post->setErrors("insert topic error");
                	xoops_error($topic_obj->getErrors());
                    return false;
                }
                $post->setVar('topic_id', $topic_id);
                
                $pid = 0;
	            $post->setVar("pid", 0);
            }elseif(!$post->getVar("pid")){
	            $pid = $topic_handler->getTopPostId($topic_id);
	            $post->setVar("pid", $pid);
            }

	        $text_obj =& $text_handler->create();
            foreach($post_text_vars as $key){
	            $text_obj->vars[$key] = $post->vars[$key];
            }
            $post->destoryVars($post_text_vars);
            if (!$post_id = parent::insert($post, $force)) {
                return false;
            }
            $text_obj->setVar("post_id", $post_id);
            if (!$text_handler->insert($text_obj, $force)) {
	            $this->delete($post);
                $post->setErrors("post text insert error");
                xoops_error($text_obj->getErrors());
                return false;
            }
            if ($post->getVar("approved")>0) {
	            $this->approve($post, true);
            }
            $post->setVar('post_id', $post_id);
        } else {
            if ($post->isTopic()) {
	            if($post->getVar("subject") != $topic_obj->getVar("topic_title")){
		            $topic_obj->setVar("topic_title", $post->getVar("subject", "n"));
	            }
	            if($post->getVar("approved") != $topic_obj->getVar("approved")){
		            $topic_obj->setVar("approved", $post->getVar("approved"));
	            }
                if (!$result = $topic_handler->insert($topic_obj, $force)) {
                    $post->setErrors("update topic error");
                	xoops_error($topic_obj->getErrors());
                    return false;
                }
            }
	        $text_obj =& $text_handler->get($post->getVar("post_id"));
	        $text_obj->setDirty();
            foreach($post_text_vars as $key){
	            $text_obj->vars[$key] = $post->vars[$key];
            }
            $post->destoryVars($post_text_vars);
            if (!$post_id = parent::insert($post, $force)) {
                xoops_error($post->getErrors());
                return false;
            }
            if (!$text_handler->insert($text_obj, $force)) {
                $post->setErrors("update post text error");
                xoops_error($text_obj->getErrors());
                return false;
            }
        }
        return $post->getVar('post_id');
    }
Example #6
0
 function insert(&$object, $force = true)
 {
     if (!$object->getVar("topic_time")) {
         $object->setVar("topic_time", time());
     }
     if (!parent::insert($object, $force) || !$object->getVar("approved")) {
         return $object->getVar("topic_id");
     }
     $newbbConfig = newbb_load_config();
     if (!empty($newbbConfig['do_tag']) && @(include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php")) {
         if ($tag_handler = tag_getTagHandler()) {
             $tag_handler->updateByItem($object->getVar('topic_tags', 'n'), $object->getVar('topic_id'), "newbb");
         }
     }
     return $object->getVar("topic_id");
 }