Ejemplo n.º 1
0
 /**
  * clean orphan items from database
  * 
  * @return 	bool	true on success
  */
 function cleanOrphan()
 {
     return parent::cleanOrphan($this->db->prefix("bb_posts"), "post_id");
 }
Ejemplo n.º 2
0
 /**
  * clean orphan items from database
  * 
  * @return 	bool	true on success
  */
 function cleanOrphan()
 {
     $this->deleteAll(new Criteria("post_time", 0), true, true);
     parent::cleanOrphan($this->db->prefix("bb_topics"), "topic_id");
     parent::cleanOrphan($this->db->prefix("bb_posts_text"), "post_id");
     /* for MySQL 4.1+ */
     if ($this->mysql_major_version() >= 4) {
         $sql = "DELETE FROM " . $this->db->prefix("bb_posts_text") . " WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM " . $this->table . ") )";
     } else {
         // for 4.0+
         /* */
         $sql = "DELETE " . $this->db->prefix("bb_posts_text") . " FROM " . $this->db->prefix("bb_posts_text") . " LEFT JOIN " . $this->table . " AS aa ON " . $this->db->prefix("bb_posts_text") . ".post_id = aa.post_id " . " WHERE (aa.post_id IS NULL)";
         /* */
         // Alternative for 4.1+
         /*
         $sql = 	"DELETE bb FROM ".$this->db->prefix("bb_posts_text")." AS bb".
         		" LEFT JOIN ".$this->table." AS aa ON bb.post_id = aa.post_id ".
         		" WHERE (aa.post_id IS NULL)";
         */
     }
     if (!($result = $this->db->queryF($sql))) {
         //xoops_error($this->db->error());
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * clean orphan links from database
  * 
  * @return 	bool	true on success
  */
 function cleanOrphan()
 {
     return parent::cleanOrphan($this->db->prefix("tag_tag"), "tag_id");
 }
Ejemplo n.º 4
0
    function delete(&$category)
    {
        global $xoopsModule;
		$forum_handler = &xoops_getmodulehandler('forum', 'xforum');
		$forum_handler->deleteAll(new Criteria("cat_id", $category->getVar('cat_id')), true, true);
        if ($result = parent::delete($category)) {
            // Delete group permissions
            return $this->deletePermission($category);
        } else {
	        $category->setErrors("delete category error: ".$sql);
            return false;
        }
    }
Ejemplo n.º 5
0
 /**
  * clean orphan items from database
  * 
  * @return 	bool	true on success
  */
 function cleanOrphan()
 {
     return parent::cleanOrphan($this->db->prefix("bb_topics"), "topic_id");
 }
Ejemplo n.º 6
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);
    }
Ejemplo n.º 7
0
    /**
     * clean orphan items from database
     * 
     * @return 	bool	true on success
     */
    function cleanOrphan()
    {
	    parent::cleanOrphan($this->db->prefix("xf_categories"), "cat_id");
	    
    	if($this->mysql_major_version() >= 4):
    	/*
        $sql = "DELETE FROM ".$this->table.
        		" WHERE (parent_forum >0 AND parent_forum NOT IN ( SELECT DISTINCT forum_id FROM ".$this->table.") )";
        */
        $sql = 	"DELETE ".$this->table." FROM ".$this->table.
        		" LEFT JOIN ".$this->table." AS aa ON ".$this->table.".parent_forum = aa.forum_id ".
        		" WHERE ".$this->table.".parent_forum>0 AND (aa.forum_id IS NULL)";
        if (!$result = $this->db->queryF($sql)):
	        xoops_error("cleanOrphan error:". $sql);
        endif;
        else:
        $this->identifierName = "parent_forum";
        $forum_list = $this->getList(new Criteria("parent_forum", 0, ">"));
        $this->identifierName = "forum_name";
        if($parent_forums = @array_values($forum_list)){
	        $parent_list = $this->getIds(new Criteria("forum_id", "(".implode(", ", $parent_forums).")", "IN"));
	        foreach($forum_list as $forum_id => $parent_forum){
		        if(in_array($parent_forum, $parent_list)) continue;
		        $forum_obj =& $this->get($forum_id);
		        $this->delete($forum_obj);
		        unset($forum_obj);
	        }
        }
		endif;
        
	    return true;
    }
Ejemplo n.º 8
0
    /**
     * clean orphan items from database
     * 
     * @return 	bool	true on success
     */
    function cleanOrphan()
    {
	    parent::cleanOrphan($this->db->prefix("xf_forums"), "forum_id");
	    parent::cleanOrphan($this->db->prefix("xf_posts"), "topic_id");
	    
	    return true;
    }
Ejemplo n.º 9
0
    /**
     * clean orphan items from database
     * 
     * @return 	bool	true on success
     */
    function cleanOrphan()
    {
	    parent::cleanOrphan($this->db->prefix("xf_topics"), "topic_id");
	    parent::cleanOrphan($this->db->prefix("xf_posts_text"), "post_id");
	    
    	/* for MySQL 4.1+ */
    	if($this->mysql_major_version() >= 4):
        $sql = "DELETE FROM ".$this->db->prefix("xf_posts_text").
        		" WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM ".$this->table.") )";
        else:
        // for 4.0+
        /* */
        $sql = 	"DELETE ".$this->db->prefix("xf_posts_text")." FROM ".$this->db->prefix("xf_posts_text").
        		" LEFT JOIN ".$this->table." AS aa ON ".$this->db->prefix("xf_posts_text").".post_id = aa.post_id ".
        		" WHERE (aa.post_id IS NULL)";
        /* */
        // Alternative for 4.1+
        /*
        $sql = 	"DELETE bb FROM ".$this->db->prefix("xf_posts_text")." AS bb".
        		" LEFT JOIN ".$this->table." AS aa ON bb.post_id = aa.post_id ".
        		" WHERE (aa.post_id IS NULL)";
        */
		endif;
        if (!$result = $this->db->queryF($sql)) {
	        forum_message("cleanOrphan:". $sql);
            return false;
        }
        return true;
    }
Ejemplo n.º 10
0
 /**
  * delete an object as well as links relying on it
  * 
  * @param	object	$object		{@link NewbbType}
  * @param 	bool 	$force 		flag to force the query execution despite security settings
  * @return 	bool
  */
 function delete(&$object, $force = true)
 {
     if (!is_object($object) || !$object->getVar($this->keyName)) {
         return false;
     }
     $queryFunc = empty($force) ? "query" : "queryF";
     /*
      * Remove forum-type links
      */
     $sql = "DELETE" . " FROM " . $this->db->prefix("bb_type_forum") . " WHERE  " . $this->keyName . " = " . $object->getVar($this->keyName);
     if (($result = $this->db->{$queryFunc}($sql)) == false) {
         // xoops_error($this->db->error());
     }
     /*
      * Reset topic type linked to this type
      */
     $sql = "UPATE" . " " . $this->db->prefix("bb_topics") . " SET " . $this->keyName . "=0" . " WHERE  " . $this->keyName . " = " . $object->getVar($this->keyName);
     if (($result = $this->db->{$queryFunc}($sql)) == false) {
         //xoops_error($this->db->error());
     }
     return parent::delete($object, $force);
 }
Ejemplo n.º 11
0
 /**
  * delete an object as well as links relying on it
  * 
  * @param	object	$object		{@link NewbbTag}
  * @param 	bool 	$force 		flag to force the query execution despite security settings
  * @return 	bool
  */
 function delete(&$object, $force = true)
 {
     if (!is_object($object) || !$object->getVar($this->keyName)) {
         return false;
     }
     $queryFunc = empty($force) ? "query" : "queryF";
     /*
      * Remove item-tag links
      */
     $sql = "DELETE" . " FROM {$this->table_link}" . " WHERE  {$this->keyName} = " . $object->getVar($this->keyName);
     if (($result = $this->db->{$queryFunc}($sql)) == false) {
         // xoops_error($this->db->error());
     }
     /*
      * Remove stats-tag links
      */
     $sql = "DELETE" . " FROM {$this->table_stats}" . " WHERE  {$this->keyName} = " . $object->getVar($this->keyName);
     if (($result = $this->db->{$queryFunc}($sql)) == false) {
         // xoops_error($this->db->error());
     }
     return parent::delete($object, $force);
 }
Ejemplo n.º 12
0
 /**
  * clean orphan items from database
  * 
  * @return 	bool	true on success
  */
 function cleanOrphan()
 {
     $this->deleteAll(new Criteria("topic_time", 0), true, true);
     parent::cleanOrphan($this->db->prefix("bb_forums"), "forum_id");
     parent::cleanOrphan($this->db->prefix("bb_posts"), "topic_id");
     return true;
 }