예제 #1
0
 /**
  * __construct
  * 
  * @param   XoopsDatabase  &$db
  * @param   string  $dirname
  * 
  * @return  void
  **/
 public function __construct(&$db, $dirname)
 {
     $this->mTable = strtr($this->mTable, array('{dirname}' => $dirname));
     parent::XoopsObjectGenericHandler($db);
 }
예제 #2
0
 /**
  * __construct
  * 
  * @param   XoopsDatabase  &$db
  * @param   string  $dirname
  * 
  * @return  void
  **/
 public function __construct(&$db, $dirname)
 {
     $this->mTable = strtr($this->mTable, array('{dirname}' => $dirname));
     parent::XoopsObjectGenericHandler($db);
     $this->mUtils = new Xcforum_Utils();
     $this->mAsset = new Xcforum_AssetManager($this->mDirname);
     $this->_setupAccessController('forums');
     $this->mDirname = $dirname;
     $this->mForumAcc = $this->_get_forum_permissions();
     //adump($this->mForumAcc);
     //atrace();
 }
예제 #3
0
 /**
  * insert
  *
  * @param	XCforum_PostObject  $obj
  * @param	bool  $force
  *
  * @return	bool
  **/
 public function insert($obj, $force = false)
 {
     /*  order as:
     			1:insert post
     			2:update topic by post_id |or| insert topic by post_id and forum_id
     			3:update forum by post and topic
     			4:update post by topic_id
     		*/
     // 1:insert post
     if (parent::insert($obj, $force) === true) {
         $this->inserted_obj = $obj;
         // Only for a new post
         if ($obj->isNew()) {
             // 2:update topic |or| insert topic by post_id and forum_id
             $handler = Legacy_Utils::getModuleHandler('topics', $this->getDirname());
             $ins_arr = array('topic_last_post_id' => $obj->get('post_id'), 'topic_last_post_time' => $obj->get('post_time'));
             // Adding a New Topic in the forum
             //adump($this->got_forum_id);
             if ($this->got_forum_id > 0) {
                 $ins_arr = array_merge($ins_arr, array('forum_id' => $this->got_forum_id));
             }
             $tpObj =& $handler->updateTopicFromPost($obj, $ins_arr);
             //adump($tpObj);
             if (is_object($tpObj)) {
                 // 3:update forum by post and topic
                 $this->topic_obj = $tpObj;
                 //	$frHandler =& $this->mAsset->getObject('handler', 'Forums',false);
                 $frHandler = Legacy_Utils::getModuleHandler('forums', $this->getDirname());
                 $frObj = $frHandler->get($this->got_forum_id);
                 $ins_arr = array('forum_last_post_id' => (int) $tpObj->get('topic_last_post_id'), 'forum_last_post_time' => (int) $tpObj->get('topic_last_post_time'));
                 $pst_countup = $obj->isNEW() ? true : false;
                 $tpc_countup = $tpObj->isNEW() ? true : false;
                 $frHandler->updateForumFromTopic($tpObj, $ins_arr, array('post_countup' => $pst_countup, 'topic_countup' => $tpc_countup));
                 //$sql = "SELECT MAX(topic_last_post_id),MAX(topic_last_post_time),COUNT(topic_id),SUM(topic_posts_count) FROM ".$db->prefix($dirname."_topics")." WHERE forum_id=$forum_id" ;
                 // 4:update post by topic_id
                 $inserted_topic_id = $tpObj->get('topic_id');
                 if ($this->updatePost($obj, array('topic_id' => $inserted_topic_id)) == true) {
                     if ($this->post_updated !== true) {
                         // update the podie;st tree information
                         $this->updatePostTree();
                         $this->post_updated = true;
                     }
                     //die; //for debug
                     return true;
                 }
                 return false;
             }
             return false;
             // TODO: error handle and return
         }
         return false;
     }
 }
예제 #4
0
 /**
  * __construct
  * 
  * @param   XoopsDatabase  &$db
  * @param   string  $dirname
  * 
  * @return  void
  **/
 public function __construct(&$db, $dirname)
 {
     $this->mTable = strtr($this->mTable, array('{dirname}' => $dirname));
     parent::XoopsObjectGenericHandler($db);
     $this->mRoot =& XCube_Root::getSingleton();
     $this->mModule =& $this->mRoot->mContext->mModule;
     $this->mAsset =& $this->mModule->mAssetManager;
 }
예제 #5
0
 /**
  * __construct
  *
  * @param   XoopsDatabase  &$db
  * @param   string  $dirname
  *
  * @return  void
  **/
 public function __construct(&$db, $dirname)
 {
     parent::XoopsObjectGenericHandler($db);
     $this->mDirname = $dirname;
 }