From 8aae1582af5f894fecd64489b71ff92355714877 Mon Sep 17 00:00:00 2001 From: nanosimbiot Date: Fri, 2 Sep 2011 04:27:02 +0000 Subject: [PATCH] r276 git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@276 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293 --- upload/admin/admin_topic_templates.php | 225 +++++++++++++----- upload/includes/init_bb.php | 13 +- upload/includes/ucp/usercp_viewprofile.php | 63 +++-- .../templates/admin/admin_topic_templates.tpl | 74 ++++++ 4 files changed, 272 insertions(+), 103 deletions(-) diff --git a/upload/admin/admin_topic_templates.php b/upload/admin/admin_topic_templates.php index e9758757f..b234350b7 100644 --- a/upload/admin/admin_topic_templates.php +++ b/upload/admin/admin_topic_templates.php @@ -11,77 +11,176 @@ require('./pagestart.php'); require(LANG_DIR .'lang_admin_bt.php'); -$forums = DB()->fetch_rowset(" - SELECT f.forum_id, f.forum_parent, f.topic_tpl_id, f.forum_name - FROM ". BB_CATEGORIES ." c, ". BB_FORUMS ." f - WHERE f.cat_id = c.cat_id - ORDER BY c.cat_order, f.forum_order -"); +$mode = (string) request_var('mode', ''); -$tpl_ary = array(); -$available_tpl_id = array(0); -$tpl_select = array($lang['TPL_NONE'] => 0); - -$sql = "SELECT * FROM ". BB_TOPIC_TPL ." ORDER BY tpl_name"; - -foreach (DB()->fetch_rowset($sql) as $row) +if ($mode == 'templates') { - $tpl_ary[$row['tpl_id']] = $row; - $available_tpl_id[] = $row['tpl_id']; + $sql = "SELECT * FROM ". BB_TOPIC_TPL ." ORDER BY tpl_name"; - $name = isset($lang[strtoupper('TPL_'. $row['tpl_name'])]) ? $lang[strtoupper('TPL_'. $row['tpl_name'])] : $row['tpl_desc']; - $tpl_select[$name] = $row['tpl_id']; -} - -if (isset($_POST['submit']) && @is_array($_POST['forum_tpl'])) -{ - $cur_val = $new_val = array(); - - foreach ($forums as $forum) + foreach (DB()->fetch_rowset($sql) as $i => $row) { - $cur_val["{$forum['forum_id']}"] = (int) $forum['topic_tpl_id']; - } - foreach ($_POST['forum_tpl'] as $forum_id => $tpl_id) - { - if (isset($cur_val["$forum_id"]) && in_array($tpl_id, $available_tpl_id)) - { - $new_val["$forum_id"] = (int) $tpl_id; - } - } - if ($new_settings = array_diff_assoc($new_val, $cur_val)) - { - foreach ($new_settings as $forum_id => $tpl_id) - { - DB()->query(" - UPDATE ". BB_FORUMS ." SET - topic_tpl_id = ". (int) $tpl_id ." - WHERE forum_id = ". (int) $forum_id ." - "); - } + $template->assign_block_vars('tpl', array( + 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', + 'ID' => $row['tpl_id'], + 'NAME' => $row['tpl_name'], + )); } - $message = $lang['CONFIG_UPD'] .'

'; - $message .= sprintf($lang['RETURN_CONFIG'], '', '') .'

'; - $message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ''); - - message_die(GENERAL_MESSAGE, $message); -} - -foreach ($forums as $i => $forum) -{ - $template->assign_block_vars('forum', array( - 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', - 'SF_PAD' => ($forum['forum_parent']) ? 'padding-left: 20px;' : '', - 'TPL_SELECT' => build_select("forum_tpl[{$forum['forum_id']}]", $tpl_select, $forum['topic_tpl_id']), - 'FORUM_CLASS' => ($forum['forum_parent']) ? 'gen' : 'gen', - 'FORUM_STYLE' => ($forum['topic_tpl_id']) ? 'font-weight: bold;' : '', - 'FORUM_ID' => $forum['forum_id'], - 'FORUM_NAME' => htmlCHR($forum['forum_name']), + $template->assign_vars(array( + 'TPL_LIST' => true, + 'S_ACTION' => append_sid("admin_topic_templates.php?mode=delete"), )); } +else if ($mode == 'add' || $mode == 'edit') +{ $template->assign_vars(array( + 'TPL' => true, + )); -$template->assign_vars(array( - 'S_ACTION' => append_sid("admin_topic_templates.php"), -)); + if($mode == 'edit') + { $tpl_id = (int) request_var('tpl', ''); + if(!$tpl_id) bb_die(''); + $row = DB()->fetch_row("SELECT * FROM ". BB_TOPIC_TPL ." WHERE tpl_id = $tpl_id"); + if(!$row) bb_die(''); + + $template->assign_vars(array( + 'S_ACTION' => append_sid("admin_topic_templates.php?mode=edit&tpl=$tpl_id"), + )); + } + else + { $template->assign_vars(array( + 'S_ACTION' => append_sid("admin_topic_templates.php?mode=add"), + )); } + + $tpl_name = isset($_POST['tpl_name']) ? $_POST['tpl_name'] : @$row['tpl_name']; + $tpl_script = isset($_POST['tpl_script']) ? $_POST['tpl_script'] : @$row['tpl_script']; + $tpl_template = isset($_POST['tpl_template']) ? $_POST['tpl_template'] : @$row['tpl_template']; + $tpl_desc = isset($_POST['tpl_desc']) ? $_POST['tpl_desc'] : @$row['tpl_desc']; + + $template->assign_vars(array( + 'NAME' => $tpl_name, + 'SCRIPT' => $tpl_script, + 'TEMP' => $tpl_template, + 'DESC' => $tpl_desc, + )); + + if(isset($_POST['submit'])) + { + if($mode == 'edit') + { DB()->query("UPDATE ". BB_TOPIC_TPL ." SET + tpl_name = '". DB()->escape($tpl_name) ."', + tpl_script = '". DB()->escape($tpl_script) ."', + tpl_template = '". DB()->escape($tpl_template) ."', + tpl_desc = '". DB()->escape($tpl_desc) ."' + WHERE tpl_id = $tpl_id + "); + $message = 'изменено'; } + else + { DB()->query("INSERT INTO ". BB_TOPIC_TPL ." (tpl_name, tpl_script, tpl_template, tpl_desc) + VALUES ('". DB()->escape($tpl_name) ."', '". DB()->escape($tpl_script) ."', '". DB()->escape($tpl_template) ."', '". DB()->escape($tpl_desc) ."')"); + $message = 'добавлено'; } + + bb_die($message); + } +} +else if ($mode == 'delete') +{ $tpl_ids = isset($_POST['tpl_id']) ? $_POST['tpl_id'] : bb_die('вы ничего не выбрали'); + + foreach ($tpl_ids as $tpl_id) + { + $hidden_fields['tpl_id'][] = $tpl_id; + } + + if (isset($_POST['confirm'])) + { + DB()->query("DELETE ". BB_TOPIC_TPL ." WHERE tpl_id IN(". join(',', $tpl_ids) .")"); + bb_die('Удалено'); + } + else + { + $names = DB()->fetch_rowset("SELECT tpl_name FROM ". BB_TOPIC_TPL ." WHERE tpl_id IN(". join(',', $tpl_ids) .") ORDER BY tpl_name", 'tpl_name'); + + print_confirmation(array( + 'QUESTION' => 'Вы уверены, что хотите удалить?', + 'ITEMS_LIST' => join("\n\n
  • \n", $names), + 'FORM_ACTION' => "admin_topic_templates.php?mode=delete", + 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields), + )); + } } +else +{ + $forums = DB()->fetch_rowset(" + SELECT f.forum_id, f.forum_parent, f.topic_tpl_id, f.forum_name + FROM ". BB_CATEGORIES ." c, ". BB_FORUMS ." f + WHERE f.cat_id = c.cat_id + ORDER BY c.cat_order, f.forum_order + "); + + $tpl_ary = array(); + $available_tpl_id = array(0); + $tpl_select = array($lang['TPL_NONE'] => 0); + + $sql = "SELECT * FROM ". BB_TOPIC_TPL ." ORDER BY tpl_name"; + + foreach (DB()->fetch_rowset($sql) as $row) + { + $tpl_ary[$row['tpl_id']] = $row; + $available_tpl_id[] = $row['tpl_id']; + + $name = isset($lang[strtoupper('TPL_'. $row['tpl_name'])]) ? $lang[strtoupper('TPL_'. $row['tpl_name'])] : $row['tpl_desc']; + $tpl_select[$name] = $row['tpl_id']; + } + + if (isset($_POST['submit']) && @is_array($_POST['forum_tpl'])) + { + $cur_val = $new_val = array(); + + foreach ($forums as $forum) + { + $cur_val["{$forum['forum_id']}"] = (int) $forum['topic_tpl_id']; + } + foreach ($_POST['forum_tpl'] as $forum_id => $tpl_id) + { + if (isset($cur_val["$forum_id"]) && in_array($tpl_id, $available_tpl_id)) + { + $new_val["$forum_id"] = (int) $tpl_id; + } + } + if ($new_settings = array_diff_assoc($new_val, $cur_val)) + { + foreach ($new_settings as $forum_id => $tpl_id) + { + DB()->query(" + UPDATE ". BB_FORUMS ." SET + topic_tpl_id = ". (int) $tpl_id ." + WHERE forum_id = ". (int) $forum_id ." + "); + } + } + + $message = $lang['CONFIG_UPD'] .'

    '; + $message .= sprintf($lang['RETURN_CONFIG'], '', '') .'

    '; + $message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ''); + + message_die(GENERAL_MESSAGE, $message); + } + + foreach ($forums as $i => $forum) + { + $template->assign_block_vars('forum', array( + 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', + 'SF_PAD' => ($forum['forum_parent']) ? 'padding-left: 20px;' : '', + 'TPL_SELECT' => build_select("forum_tpl[{$forum['forum_id']}]", $tpl_select, $forum['topic_tpl_id']), + 'FORUM_CLASS' => ($forum['forum_parent']) ? 'gen' : 'gen', + 'FORUM_STYLE' => ($forum['topic_tpl_id']) ? 'font-weight: bold;' : '', + 'FORUM_ID' => $forum['forum_id'], + 'FORUM_NAME' => htmlCHR($forum['forum_name']), + )); + } + + $template->assign_vars(array( + 'FORUM_LIST' => true, + 'S_ACTION' => append_sid("admin_topic_templates.php"), + )); +} print_page('admin_topic_templates.tpl', 'admin'); diff --git a/upload/includes/init_bb.php b/upload/includes/init_bb.php index c13b12814..c0a830f36 100644 --- a/upload/includes/init_bb.php +++ b/upload/includes/init_bb.php @@ -343,7 +343,6 @@ define('BB_CATEGORIES', 'bb_categories'); define('BB_CAPTCHA', 'bb_captcha'); define('BB_CONFIG', 'bb_config'); define('BB_CRON', 'bb_cron'); -define('BB_DATASTORE', 'bb_datastore'); define('BB_DISALLOW', 'bb_disallow'); define('BB_EXTENSION_GROUPS', 'bb_extension_groups'); define('BB_EXTENSIONS', 'bb_extensions'); @@ -359,7 +358,7 @@ define('BB_PRIVMSGS_TEXT', 'bb_privmsgs_text'); define('BB_QUOTA_LIMITS', 'bb_quota_limits'); define('BB_QUOTA', 'bb_attach_quota'); define('BB_RANKS', 'bb_ranks'); -define('BB_REPORTS', 'bb_reports'); // Report +define('BB_REPORTS', 'bb_reports'); // Report define('BB_REPORTS_CHANGES', 'bb_reports_changes'); // Report Change's define('BB_REPORTS_MODULES', 'bb_reports_modules'); // Report Module Table define('BB_REPORTS_REASONS', 'bb_reports_reasons'); // Report Reasons @@ -543,15 +542,13 @@ $ads = new ads_common(); $datastore->enqueue(array( 'cat_forums', )); - + // Дата старта вашего проекта -if(!$bb_cfg['board_startdate']) +if(!$bb_cfg['board_startdate']) { bb_update_config(array('board_startdate' => TIMENOW)); - DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id = -1"); - DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id = 2"); - DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id = -746"); -} + DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id IN(2, ". EXCLUDED_USERS_CSV); +} // Cron if ((empty($_POST) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_SERVICE') && !file_exists(CRON_RUNNING) && ($bb_cfg['cron_enabled'] || defined('START_CRON'))) || defined('FORCE_CRON')) diff --git a/upload/includes/ucp/usercp_viewprofile.php b/upload/includes/ucp/usercp_viewprofile.php index 7377bc57d..44c0e24b7 100644 --- a/upload/includes/ucp/usercp_viewprofile.php +++ b/upload/includes/ucp/usercp_viewprofile.php @@ -21,13 +21,12 @@ if(bf($profiledata['user_opt'], 'user_opt', 'view_profile') && IS_GUEST) { meta_refresh(append_sid("login.php?redirect={$_SERVER['REQUEST_URI']}", true)); bb_die("{$profiledata['username']} " . $lang['FORBADE_VIEWING']); } -$avatar_img = get_avatar($profiledata['user_avatar'], $profiledata['user_avatar_type'], !bf($profiledata['user_opt'], 'user_opt', 'allow_avatar')); - if (!$ranks = $datastore->get('ranks')) { $datastore->update('ranks'); $ranks = $datastore->get('ranks'); } + $poster_rank = $rank_image = $rank_select = ''; if ($user_rank = $profiledata['user_rank'] AND isset($ranks[$user_rank])) { @@ -91,42 +90,42 @@ else if ($signature) } $template->assign_vars(array( - 'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), - 'USERNAME' => $profiledata['username'], - 'PROFILE_USER_ID' => $profiledata['user_id'], - 'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i'), - 'POSTER_RANK' => $poster_rank, - 'RANK_IMAGE' => $rank_image, - 'RANK_SELECT' => $rank_select, - 'POSTS' => $profiledata['user_posts'], - 'PM' => ''. $lang['SEND_PRIVATE_MESSAGE'] .'', - 'EMAIL' => $email, - 'WWW' => $profiledata['user_website'], - 'ICQ' => $profiledata['user_icq'], - 'LAST_VISIT_TIME' => ($profiledata['user_lastvisit']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_lastvisit'], 'Y-m-d H:i') : $lang['NEVER'], - 'LAST_ACTIVITY_TIME' => ($profiledata['user_session_time']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_session_time'], 'Y-m-d H:i') : $lang['NEVER'], - 'LOCATION' => ($profiledata['user_from']) ? $profiledata['user_from'] : '', + 'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), + 'USERNAME' => $profiledata['username'], + 'PROFILE_USER_ID' => $profiledata['user_id'], + 'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i', 'false'), + 'POSTER_RANK' => $poster_rank, + 'RANK_IMAGE' => $rank_image, + 'RANK_SELECT' => $rank_select, + 'POSTS' => $profiledata['user_posts'], + 'PM' => ''. $lang['SEND_PRIVATE_MESSAGE'] .'', + 'EMAIL' => $email, + 'WWW' => $profiledata['user_website'], + 'ICQ' => $profiledata['user_icq'], + 'LAST_VISIT_TIME' => ($profiledata['user_lastvisit']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_lastvisit'], 'Y-m-d H:i', 'false') : $lang['NEVER'], + 'LAST_ACTIVITY_TIME' => ($profiledata['user_session_time']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_session_time'], 'Y-m-d H:i', 'false') : $lang['NEVER'], + 'LOCATION' => $profiledata['user_from'], - 'USER_ACTIVE' => $profiledata['user_active'], + 'USER_ACTIVE' => $profiledata['user_active'], - 'OCCUPATION' => $profiledata['user_occ'], - 'INTERESTS' => $profiledata['user_interests'], - 'SKYPE' => $profiledata['user_skype'], - 'GENDER' => ($bb_cfg['gender'] && $profiledata['user_gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', - 'BIRTHDAY' => ($bb_cfg['birthday']['enabled'] && $profiledata['user_birthday']) ? realdate($profiledata['user_birthday'], 'Y-m-d') : '', - 'AGE' => ($bb_cfg['birthday']['enabled'] && $profiledata['user_birthday']) ? birthday_age($profiledata['user_birthday']) : '', - 'AVATAR_IMG' => $avatar_img, + 'OCCUPATION' => $profiledata['user_occ'], + 'INTERESTS' => $profiledata['user_interests'], + 'SKYPE' => $profiledata['user_skype'], + 'GENDER' => ($bb_cfg['gender'] && $profiledata['user_gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', + 'BIRTHDAY' => ($bb_cfg['birthday']['enabled'] && $profiledata['user_birthday']) ? realdate($profiledata['user_birthday'], 'Y-m-d') : '', + 'AGE' => ($bb_cfg['birthday']['enabled'] && $profiledata['user_birthday']) ? birthday_age($profiledata['user_birthday']) : '', + 'AVATAR_IMG' => get_avatar($profiledata['user_avatar'], $profiledata['user_avatar_type'], !bf($profiledata['user_opt'], 'user_opt', 'allow_avatar')), - 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), - 'L_ABOUT_USER_PROFILE' => sprintf($lang['ABOUT_USER'], $profiledata['username']), + 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), + 'L_ABOUT_USER_PROFILE' => sprintf($lang['ABOUT_USER'], $profiledata['username']), - 'U_SEARCH_USER' => "search.php?search_author=1&uid={$profiledata['user_id']}", - 'U_SEARCH_TOPICS' => "search.php?uid={$profiledata['user_id']}&myt=1", - 'U_SEARCH_RELEASES' => "tracker.php?rid={$profiledata['user_id']}#results", + 'U_SEARCH_USER' => "search.php?search_author=1&uid={$profiledata['user_id']}", + 'U_SEARCH_TOPICS' => "search.php?uid={$profiledata['user_id']}&myt=1", + 'U_SEARCH_RELEASES' => "tracker.php?rid={$profiledata['user_id']}#results", - 'S_PROFILE_ACTION' => "profile.php", + 'S_PROFILE_ACTION' => "profile.php", - 'SIGNATURE' => $signature, + 'SIGNATURE' => $signature, )); //bt diff --git a/upload/templates/admin/admin_topic_templates.tpl b/upload/templates/admin/admin_topic_templates.tpl index 6c817ed7a..dfe03d6fb 100644 --- a/upload/templates/admin/admin_topic_templates.tpl +++ b/upload/templates/admin/admin_topic_templates.tpl @@ -1,5 +1,11 @@

    {L_RELEASE_TEMPLATES}

    +Список форумов · +Список шаблонов · +Добавить шаблон +

    + +

    {L_RELEASE_EXP}


    @@ -26,3 +32,71 @@ + + + +

    На этой странице отображаются шаблоны

    +
    + +
    + + + + + + + + + + + + + + + + +
    {L_TEMPLATE}{L_DELETE}
    {tpl.NAME}
    +    + + + + +
    + +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    ОписаниеЗначение
    Имя
    Скрипт
    {L_TEMPLATE}
    {L_DESC}
    + +
    + +
    + +