- Совместимость
- не проверялся на совместимость
- Изменения в БД
- не требуются
- Автор
- krumax
- Общественное достояние
- да
Описание: добавляет возможность менять автора сообщения / id темы. Используется AJAX.
- Инструкция по установке
-
PHP:
*** Открыть ajax.php и найти **************************************** // // Ajax // class ajax_common { var $request = array(); var $response = array(); var $valid_actions = array( // ACTION NAME AJAX_AUTH 'edit_user_profile' => array('admin'), 'change_user_rank' => array('admin'), 'change_user_opt' => array('admin'), 'manage_user' => array('admin'), *** Добавить ниже ****************************************************** 'admin_change_poster' => array('admin'), 'admin_change_topic' => array('admin'), *** Перед последней скобкой вставить ************************************** function admin_change_topic() { global $userdata, $lang; $mode = (string) $this->request['mode']; switch($mode) { case 'change_topic_id': $topic_id = (int) $this->request['topic_id']; $new_id = (int) $this->request['new_id']; if(!$new_id || !$topic_id) bb_die('false id'); if(DB()->fetch_rowset("SELECT topic_id FROM ". BB_TOPICS ." WHERE topic_id = $new_id", 'topic_id')) bb_die('Такой топик уже имеется в базе'); DB()->query("UPDATE ". BB_TOPICS ." SET topic_id = $new_id WHERE topic_id = $topic_id"); DB()->query("UPDATE ". BB_TOPICS_WATCH ." SET topic_id = $new_id WHERE topic_id = $topic_id"); DB()->query("UPDATE ". BB_POSTS ." SET topic_id = $new_id WHERE topic_id = $topic_id"); DB()->query("UPDATE ". BB_BT_TORRENTS ." SET topic_id = $new_id WHERE topic_id = $topic_id"); DB()->query("UPDATE ". BB_BT_TRACKER ." SET topic_id = $new_id WHERE topic_id = $topic_id"); DB()->query("UPDATE ". BB_BT_TRACKER_SNAP ." SET topic_id = $new_id WHERE topic_id = $topic_id"); DB()->query("UPDATE ". BB_TOPICS_WATCH ." SET topic_id = $new_id WHERE topic_id = $topic_id"); DB()->query("UPDATE ". BB_BT_TORSTAT ." SET topic_id = $new_id WHERE topic_id = $topic_id"); bb_die('Готово!'); break; } } function admin_change_poster() { global $userdata, $lang; $mode = (string) $this->request['mode']; switch($mode) { case 'change_poster_id': require(INC_DIR .'functions_admin.php'); $new_user = (string) $this->request['user']; $post_id = (int) $this->request['post_id']; if(!$post_id || !$new_user) bb_die('false id'); if(!$new = get_userdata($new_user)) bb_die($lang['NO_USER_ID_SPECIFIED']); $old_user = DB()->fetch_rowset("SELECT poster_id FROM ". BB_POSTS ." WHERE post_id = $post_id", 'poster_id'); DB()->query("UPDATE ". BB_TOPICS ." SET topic_poster = {$new['user_id']} WHERE topic_first_post_id = $post_id"); DB()->query("UPDATE ". BB_POSTS ." SET poster_id = {$new['user_id']} WHERE post_id = $post_id"); DB()->query("UPDATE ". BB_BT_TORRENTS ." SET poster_id = {$new['user_id']} WHERE post_id = $post_id"); sync('user_posts', $old_user); sync('user_posts', $new['user_id']); bb_die('Готово!'); break; } } *** Открыть viewtopic.tpl и найти *********************************** <a class="small bold" href="{PIN_HREF}">{PIN_TITLE}</a> </td> <!-- IF SELECT_PPP --> *** Заменить ********************************* <a class="small bold" href="{PIN_HREF}">{PIN_TITLE}</a> <!-- IS_SUPER_ADMIN --> <script type="text/javascript"> ajax.admin_change_topic = function(mode) { url = prompt("Введите будущий ID-темы", ""); if(url) { ajax.exec({ action : 'admin_change_topic', mode : mode, topic_id : {TOPIC_ID}, new_id : url, }); } } </script> <span style="color:#CDCDCD;">|</span> <a class="small bold" onclick="ajax.admin_change_topic('change_topic_id'); return false;" href="#">Сменить ID-темы</a> <!-- ENDIF --> <!-- IF IS_ADMIN --> <span style="color:#CDCDCD;">|</span> <a class="small bold" onclick="ajax.admin_change_poster('change_poster_id'); return false;" href="#">Сменить автора</a> <!-- ENDIF --> </td> <!-- IF SELECT_PPP --> *** Найти *********************************** <!-- BEGIN postrow --> <tbody id="post_{postrow.POST_ID}" class="{postrow.ROW_CLASS}"> *** Заменить ********************************* <!-- BEGIN postrow --> <script type="text/javascript"> ajax.admin_change_poster = function(mode) { user = prompt("Введите user_id или username", "Tracker"); if(user) { ajax.exec({ action : 'admin_change_poster', mode : mode, post_id : {postrow.POST_ID}, user : user, }); } } </script> <tbody id="post_{postrow.POST_ID}" class="{postrow.ROW_CLASS}"> *** Сохранить *************************************