Esempio n. 1
0
 /**
  *  Loop posts and add to wiki search table(s)
  * 
  * Loop from 'awc_f_posts' table<br />
  * Save posts text to wo Wiki tables<br />
  * Flag post 't_wiki_pageid' columne
  * @parameter string $limit (how many entries to work with)
  * @uses awcs_forum_wikisearch_cls
  * @since Version 2.5.8
  */
 function threads_to_wiki($limit)
 {
     global $wgOut;
     require_once awc_dir . 'includes/to_wiki_dbase.php';
     $dbr = wfGetDB(DB_SLAVE);
     $awc_f_threads = $dbr->tableName('awc_f_threads');
     $awc_f_posts = $dbr->tableName('awc_f_posts');
     $sql = "SELECT t.t_id, t.t_name, p.p_post \r\r\n                    FROM {$awc_f_threads} t\r\r\n                    JOIN {$awc_f_posts} p\r\r\n                        ON p.p_threadid=t.t_id\r\r\n                    WHERE t.t_wiki_pageid=0 AND t.t_date = p.p_date\r\r\n                    ORDER BY t.t_date DESC\r\r\n                    LIMIT 0, {$limit}";
     $res = $dbr->query($sql);
     while ($r = $dbr->fetchObject($res)) {
         $tmp[] = array('p_post' => $r->p_post, 't_id' => $r->t_id, 't_name' => $r->t_name);
     }
     $dbr->freeResult($res);
     foreach ($tmp as $r) {
         // die($r['p_post']);
         $ws = new awcs_forum_wikisearch_cls();
         $ws->post = $r['p_post'];
         $ws->tID = $r['t_id'];
         $ws->title = $r['t_name'];
         $ws->p_wiki_hidden = $dbr->timestamp();
         $ws->add_thread();
         $wgOut->addHTML("pageID({$ws->pageID})  insert_textID({$ws->insert_textID}) insert_revID({$ws->insert_revID}) = {$r['t_name']} <br />");
         unset($ws);
     }
     /*
             
             $dbr = wfGetDB( DB_SLAVE );       
             $awc_f_threads = $dbr->tableName( 'awc_f_threads' ); 
             $awc_f_posts = $dbr->tableName( 'awc_f_posts' );          
             $sql = "SELECT t.t_wiki_pageid
                         FROM $awc_f_threads t
                         JOIN $awc_f_posts p
                             ON p.thread_id=t.t_id
                         WHERE t.t_date = p.p_date and t.t_wiki_pageid != 0
                         ORDER BY t.t_date DESC
                         LIMIT 0, $limit";
                         
             $res = $dbr->query($sql);
             while ($r = $dbr->fetchObject( $res )) {
                 //$tmp[] = array('p_post' => $r->p_post, 't_id' => $r->t_id , 't_name' => $r->t_name );
                 $tmp[] = $r->t_wiki_pageid;
             }
             $dbr->freeResult( $res );
             
             $pIDs = implode(',', $tmp);
             
             $dbw = wfGetDB( DB_MASTER );
             $wiki_page = $dbw->tableName( 'page' );          
             $sql = "UPDATE $wiki_page SET page_namespace = ".NS_AWC_FORUM." WHERE page_id IN ($pIDs) ";
             $res = $dbw->query($sql);   
     */
 }
Esempio n. 2
0
 function add_thread($no_redirect = false)
 {
     global $awc_tables, $ForumStat, $awcUser;
     $wDB = wfGetDB(DB_MASTER);
     $this->t_lastdate = $wDB->timestamp();
     wfRunHooks('awcsforum_add_newthread', array(&$this));
     // 2.5.5
     #$bs = $dbw->nextSequenceValue( 'awc_f_threads_t_id_seq' );
     $wDB->insert('awc_f_threads', array('t_forumid' => $this->fID, 't_name' => $this->title, 't_starter' => $this->cur_memName, 't_starterid' => $this->cur_memID, 't_date' => $this->t_lastdate, 't_lastdate' => $this->t_lastdate, 't_ann' => $this->ann, 't_pin' => $this->sticky, 't_status' => $this->lock, 't_lastuser' => $this->cur_memName, 't_lastuserid' => $this->cur_memID));
     $NewTid = awcsforum_funcs::lastID($wDB, 'awc_f_threads', 't_id');
     $_SESSION['awc_rActive'][$NewTid] = $NewTid;
     unset($_SESSION['awc_nActive'][$NewTid]);
     if ($this->ann) {
         $wDB->insert('awc_f_anns', array('ann_id' => $NewTid));
     }
     # $bs = $dbw->nextSequenceValue( 'awc_f_posts_p_id_seq' );
     $p_wiki_hidden = $wDB->timestamp();
     $wDB->insert('awc_f_posts', array('p_threadid' => $NewTid, 'p_post' => $this->post, 'p_title' => $this->title, 'p_user' => $this->cur_memName, 'p_userid' => $this->cur_memID, 'p_date' => $this->t_lastdate, 'p_editdate' => $this->t_lastdate, 'p_forumid' => $this->fID, 'p_wiki_hidden' => $p_wiki_hidden, 'p_thread_start' => 1));
     $newid = awcsforum_funcs::lastID($wDB, 'awc_f_posts', 'p_id');
     $_SESSION['awc_rActive'][$NewTid] = $this->t_lastdate;
     //$_SESSION['awc_rActive'][$newid] = $newid;
     //unset($_SESSION['awc_nActive'][$newid]);
     $time_now = $wDB->timestamp();
     /* 
        $wDB->query(str_replace('  ', '', "UPDATE {$awc_tables['awc_f_threads']} t
                    JOIN {$awc_tables['awc_f_forums']} f
                        ON t.forum_id=f.f_id
                            SET f.f_threads = f.f_threads + 1,
                                f.f_lastdate = ".$this->t_lastdate.",
                                f.f_lastuser = '******',
                                f.f_lastuserid = ". $this->cur_memID .",
                                f.f_lasttitle = '". $this->title ."',
                                f.f_threadid = '". $NewTid ."',
                                    t.t_postid = '". $newid ."'
                    WHERE t_id = $NewTid"));
     */
     $wDB->query("UPDATE {$awc_tables['awc_f_forums']} \r\r\n                            SET f_threads = f_threads + 1,\r\r\n                            f_lastdate = '" . $time_now . "',\r\r\n                            f_lastuser = '******',\r\r\n                            f_lastuserid = " . $this->cur_memID . ",\r\r\n                            f_lasttitle = '" . $this->title . "',\r\r\n                            f_threadid = '" . $NewTid . "'\r\r\n                            WHERE f_id =" . $this->fID);
     $wDB->update('awc_f_threads', array('t_postid' => $newid), array('t_id' => $NewTid), '');
     $m_topics = $this->cur_m_topics;
     $m_posts = $this->cur_m_posts;
     $name = $this->cur_memName;
     if ($this->cur_memID != '0') {
         $wDB->update('awc_f_mems', array('m_posts' => $m_posts + 1, 'm_topics' => $m_topics + 1), array('m_id' => $this->cur_memID), '');
     }
     if ($this->cf_add_post_text_to_wiki) {
         require_once awc_dir . 'includes/to_wiki_dbase.php';
         $ws = new awcs_forum_wikisearch_cls();
         $ws->post = $this->post;
         $ws->tID = $NewTid;
         $ws->pID = $newid;
         $ws->title = $this->title;
         $ws->p_wiki_hidden = $p_wiki_hidden;
         $ws->add_thread();
     }
     if (isset($ForumStat)) {
         $ForumStat->stat_threads(1);
     }
     //$ForumStat->stat_posts(1);
     // $this->tID = $NewTid ;
     $wDB->commit();
     require_once awc_dir . 'includes/subscribe.php';
     $t_subscribe = new awcs_forum_subscribe();
     $t_subscribe->fID = $this->fID;
     $t_subscribe->tID = $NewTid;
     $t_subscribe->cur_memID = $this->cur_memID;
     $t_subscribe->subscribe = $this->subscribe;
     $t_subscribe->title = $this->title;
     $t_subscribe->post = $this->post;
     $t_subscribe->m_thread_subsrib = $this->m_thread_subsrib;
     $t_subscribe->m_forum_subsrib = $this->m_forum_subsrib;
     $t_subscribe->forum_or_thread = 'forum';
     wfRunHooks('awcsforum_add_newthread_forum_subscribe', array(&$t_subscribe, &$this));
     // 2.5.5
     $t_subscribe->check_user_forum_subscribe();
     if ($no_redirect) {
         return;
     }
     $info['msg'] = 'thread_has_been_add';
     $info['url'] = awc_url . "st/id" . $NewTid;
     return awcf_redirect($info);
 }