Second Opinion
Folosind serviciul second opinion ne puteți trimite RMN-uri, CT -uri, angiografii, fișiere .pdf, documente medicale. Astfel vă vom putea da o opinie neurochirurgicală, fără ca aceasta să poată înlocui un consult de specialitate. Răspunsurile vor fi date prin e-mail în cel mai scurt timp posibil (de obicei în mai putin de 24 de ore, dar nu mai mult de 48 de ore). Second opinion – Neurohope este un serviciu gratuit. www.neurohope.ro |
Problemã phpbb versiunea 3.0.14
Last Updated: Mar 25 2020 21:21, Started by
Rainq
, Mar 25 2020 10:50
·
0
#1
Posted 25 March 2020 - 10:50
Cum fac și eu coloane așa? Ce trebuie modificat și ce linie mai exact sau ce fișier?
Am așa: https://i.imgur.com/MWeTuZy.png Vreau așa: https://i.imgur.com/VNgkbTP.png |
#2
Posted 25 March 2020 - 15:18
Se face din css, din design. Poate modificare de poziționare a divurilor din php.
|
#3
Posted 25 March 2020 - 15:27
Asa are tema respectivul template, ori pui tema ori adaptezi codul acelei sectiuni.
|
#4
Posted 25 March 2020 - 21:21
Am rezolvat,intrați în cache ,ștergeți tot ce e acolo după care modificați acp_forums.html , functions_display.php și acp_forums.php
Vă las eu modificările mele: acp_forums.html <!-- INCLUDE overall_header.html --> <a name="maincontent"></a> <!-- IF S_EDIT_FORUM --> <script type="text/javascript"> // <![CDATA[ /** * Handle displaying/hiding several options based on the forum type */ function display_options(value) { <!-- IF not S_ADD_ACTION and S_FORUM_ORIG_POST --> if (value == {FORUM_POST}) { dE('type_actions', -1); } else { dE('type_actions', 1); } <!-- ENDIF --> <!-- IF not S_ADD_ACTION and S_FORUM_ORIG_CAT and S_HAS_SUBFORUMS --> if (value == {FORUM_LINK}) { dE('cat_to_link_actions', 1); } else { dE('cat_to_link_actions', -1); } <!-- ENDIF --> if (value == {FORUM_POST}) { dE('forum_post_options', 1); dE('forum_link_options', -1); dE('forum_rules_options', 1); dE('forum_cat_options', -1); } else if (value == {FORUM_LINK}) { dE('forum_post_options', -1); dE('forum_link_options', 1); dE('forum_rules_options', -1); dE('forum_cat_options', -1); } else if (value == {FORUM_CAT}) { dE('forum_post_options', -1); dE('forum_link_options', -1); dE('forum_rules_options', 1); dE('forum_cat_options', 1); } } /** * Init the wanted display functionality if javascript is enabled. * If javascript is not available, the user is still able to properly administer. */ onload = function() { <!-- IF not S_ADD_ACTION and S_FORUM_ORIG_POST --> <!-- IF S_FORUM_POST --> dE('type_actions', -1); <!-- ENDIF --> <!-- ENDIF --> <!-- IF not S_ADD_ACTION and S_FORUM_ORIG_CAT and S_HAS_SUBFORUMS --> <!-- IF S_FORUM_CAT --> dE('cat_to_link_actions', -1); <!-- ENDIF --> <!-- ENDIF --> <!-- IF not S_FORUM_POST --> dE('forum_post_options', -1); <!-- ENDIF --> <!-- IF not S_FORUM_CAT --> dE('forum_cat_options', -1); <!-- ENDIF --> <!-- IF not S_FORUM_LINK --> dE('forum_link_options', -1); <!-- ENDIF --> <!-- IF S_FORUM_LINK --> dE('forum_rules_options', -1); <!-- ENDIF --> } // ]]> </script> <a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">« {L_BACK}</a> <h1>{L_TITLE} <!-- IF FORUM_NAME -->:: {FORUM_NAME}<!-- ENDIF --></h1> <p>{L_FORUM_EDIT_EXPLAIN}</p> <!-- IF S_ERROR --> <div class="errorbox"> <h3>{L_WARNING}</h3> <p>{ERROR_MSG}</p> </div> <!-- ENDIF --> <form id="forumedit" method="post" action="{U_EDIT_ACTION}"> <fieldset> <legend>{L_FORUM_SETTINGS}</legend> <dl> <dt><label for="forum_type">{L_FORUM_TYPE}:</label></dt> <dd><select id="forum_type" name="forum_type" onchange="display_options(this.options[this.selectedIndex].value);">{S_FORUM_TYPE_OPTIONS}</select></dd> </dl> <!-- IF not S_ADD_ACTION and S_FORUM_ORIG_POST --> <div id="type_actions"> <dl> <dt><label for="type_action">{L_DECIDE_MOVE_DELETE_CONTENT}:</label></dt> <dd><label><input type="radio" class="radio" name="type_action" value="delete"<!-- IF not S_MOVE_FORUM_OPTIONS --> checked="checked" id="type_action"<!-- ENDIF --> /> {L_DELETE_ALL_POSTS}</label></dd> <!-- IF S_MOVE_FORUM_OPTIONS --><dd><label><input type="radio" class="radio" name="type_action" id="type_action" value="move" checked="checked" /> {L_MOVE_POSTS_TO}</label> <select name="to_forum_id">{S_MOVE_FORUM_OPTIONS}</select></dd><!-- ENDIF --> </dl> </div> <!-- ENDIF --> <!-- IF not S_ADD_ACTION and S_FORUM_ORIG_CAT and S_HAS_SUBFORUMS --> <div id="cat_to_link_actions"> <dl> <dt><label for="action_subforums">{L_DECIDE_MOVE_DELETE_SUBFORUMS}:</label></dt> <!-- IF S_FORUMS_LIST --> <dd><label><input type="radio" class="radio" id="action_subforums" name="action_subforums" value="move" checked="checked" /> {L_MOVE_SUBFORUMS_TO}</label> <select name="subforums_to_id">{S_FORUMS_LIST}</select></dd> <!-- ELSE --> <dd><label><input type="radio" class="radio" id="action_subforums" name="action_subforums" value="delete" checked="checked" /> {L_DELETE_SUBFORUMS}</label></dd> <!-- ENDIF --> </dl> </div> <!-- ENDIF --> <dl> <dt><label for="parent">{L_FORUM_PARENT}:</label></dt> <dd><select id="parent" name="forum_parent_id"><option value="0"<!-- IF not S_FORUM_PARENT_ID --> selected="selected"<!-- ENDIF -->>{L_NO_PARENT}</option>{S_PARENT_OPTIONS}</select></dd> </dl> <!-- IF S_CAN_COPY_PERMISSIONS --> <dl> <dt><label for="forum_perm_from">{L_COPY_PERMISSIONS}:</label><br /><span>{L_COPY_PERMISSIONS_EXPLAIN}</span></dt> <dd><select id="forum_perm_from" name="forum_perm_from"><option value="0">{L_NO_PERMISSIONS}</option>{S_FORUM_OPTIONS}</select></dd> <dt><label for="subforumslist_type">{L_SUBFORUMSLIST_TYPE}:</label><br /><span>{L_SUBFORUMSLIST_TYPE_EXPLAIN}</span></dt> <dd><input type="text" id="subforumslist_type" name="subforumslist_type" value="{SUBFORUMSLIST_TYPE}" size="4" maxlength="4" /></dd> </dl> <!-- ENDIF --> <dl> <dt><label for="forum_name">{L_FORUM_NAME}:</label></dt> <dd><input class="text medium" type="text" id="forum_name" name="forum_name" value="{FORUM_NAME}" maxlength="255" /></dd> </dl> <dl> <dt><label for="forum_desc">{L_FORUM_DESC}:</label><br /><span>{L_FORUM_DESC_EXPLAIN}</span></dt> <dd><textarea id="forum_desc" name="forum_desc" rows="5" cols="45">{FORUM_DESC}</textarea></dd> <dd><label><input type="checkbox" class="radio" name="desc_parse_bbcode"<!-- IF S_DESC_BBCODE_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_BBCODE}</label> <label><input type="checkbox" class="radio" name="desc_parse_smilies"<!-- IF S_DESC_SMILIES_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_SMILIES}</label> <label><input type="checkbox" class="radio" name="desc_parse_urls"<!-- IF S_DESC_URLS_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_URLS}</label></dd> </dl> <dl> <dt><label for="forum_image">{L_FORUM_IMAGE}:</label><br /><span>{L_FORUM_IMAGE_EXPLAIN}</span></dt> <dd><input class="text medium" type="text" id="forum_image" name="forum_image" value="{FORUM_IMAGE}" maxlength="255" /></dd> <!-- IF FORUM_IMAGE_SRC --> <dd><img src="{FORUM_IMAGE_SRC}" alt="{L_FORUM_IMAGE}" /></dd> <!-- ENDIF --> </dl> <dl> <dt><label for="forum_password">{L_FORUM_PASSWORD}:</label><br /><span>{L_FORUM_PASSWORD_EXPLAIN}</span></dt> <dd><input type="password" id="forum_password" name="forum_password" value="<!-- IF S_FORUM_PASSWORD_SET -->      <!-- ENDIF -->" autocomplete="off" /></dd> </dl> <dl> <dt><label for="forum_password_confirm">{L_FORUM_PASSWORD_CONFIRM}:</label><br /><span>{L_FORUM_PASSWORD_CONFIRM_EXPLAIN}</span></dt> <dd><input type="password" id="forum_password_confirm" name="forum_password_confirm" value="<!-- IF S_FORUM_PASSWORD_SET -->      <!-- ENDIF -->" autocomplete="off" /></dd> </dl> <!-- IF S_FORUM_PASSWORD_SET --> <dl> <dt><label for="forum_password_unset">{L_FORUM_PASSWORD_UNSET}:</label><br /><span>{L_FORUM_PASSWORD_UNSET_EXPLAIN}</span></dt> <dd><input id="forum_password_unset" name="forum_password_unset" type="checkbox" /></dd> </dl> <!-- ENDIF --> <dl> <dt><label for="forum_style">{L_FORUM_STYLE}:</label></dt> <dd><select id="forum_style" name="forum_style"><option value="0">{L_DEFAULT_STYLE}</option>{S_STYLES_OPTIONS}</select></dd> </dl> </fieldset> <div id="forum_cat_options"> <fieldset> <legend>{L_GENERAL_FORUM_SETTINGS}</legend> <dl> <dt><label for="display_active">{L_DISPLAY_ACTIVE_TOPICS}:</label><br /><span>{L_DISPLAY_ACTIVE_TOPICS_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="display_active" value="1"<!-- IF S_ENABLE_ACTIVE_TOPICS --> id="display_active" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="display_active" value="0"<!-- IF not S_ENABLE_ACTIVE_TOPICS --> id="display_active" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> </fieldset> </div> <div id="forum_post_options"> <fieldset> <legend>{L_GENERAL_FORUM_SETTINGS}</legend> <dl> <dt><label for="forum_status">{L_FORUM_STATUS}:</label></dt> <dd><select id="forum_status" name="forum_status">{S_STATUS_OPTIONS}</select></dd> </dl> <dl> <dt><label for="display_subforum_list">{L_LIST_SUBFORUMS}:</label><br /><span>{L_LIST_SUBFORUMS_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="display_subforum_list" value="1"<!-- IF S_DISPLAY_SUBFORUM_LIST --> id="display_subforum_list" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="display_subforum_list" value="0"<!-- IF not S_DISPLAY_SUBFORUM_LIST --> id="display_subforum_list" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="display_on_index">{L_LIST_INDEX}:</label><br /><span>{L_LIST_INDEX_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="display_on_index" value="1"<!-- IF S_DISPLAY_ON_INDEX --> id="display_on_index" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="display_on_index" value="0"<!-- IF not S_DISPLAY_ON_INDEX --> id="display_on_index" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="enable_post_review">{L_ENABLE_POST_REVIEW}:</label><br /><span>{L_ENABLE_POST_REVIEW_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="enable_post_review" value="1"<!-- IF S_ENABLE_POST_REVIEW --> id="enable_post_review" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="enable_post_review" value="0"<!-- IF not S_ENABLE_POST_REVIEW --> id="enable_post_review" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="enable_quick_reply">{L_ENABLE_QUICK_REPLY}:</label><br /><span>{L_ENABLE_QUICK_REPLY_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="enable_quick_reply" value="1"<!-- IF S_ENABLE_QUICK_REPLY --> id="enable_quick_reply" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="enable_quick_reply" value="0"<!-- IF not S_ENABLE_QUICK_REPLY --> id="enable_quick_reply" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="enable_indexing">{L_ENABLE_INDEXING}:</label><br /><span>{L_ENABLE_INDEXING_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="enable_indexing" value="1"<!-- IF S_ENABLE_INDEXING --> id="enable_indexing" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="enable_indexing" value="0"<!-- IF not S_ENABLE_INDEXING --> id="enable_indexing" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="enable_icons">{L_ENABLE_TOPIC_ICONS}:</label></dt> <dd><label><input type="radio" class="radio" name="enable_icons" value="1"<!-- IF S_TOPIC_ICONS --> id="enable_icons" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="enable_icons" value="0"<!-- IF not S_TOPIC_ICONS --> id="enable_icons" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="display_recent">{L_ENABLE_RECENT}:</label><br /><span>{L_ENABLE_RECENT_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="display_recent" value="1"<!-- IF S_DISPLAY_ACTIVE_TOPICS --> id="display_recent" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="display_recent" value="0"<!-- IF not S_DISPLAY_ACTIVE_TOPICS --> id="display_recent" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="topics_per_page">{L_FORUM_TOPICS_PAGE}:</label><br /><span>{L_FORUM_TOPICS_PAGE_EXPLAIN}</span></dt> <dd><input type="text" id="topics_per_page" name="topics_per_page" value="{TOPICS_PER_PAGE}" size="4" maxlength="4" /></dd> </dl> </fieldset> <fieldset> <legend>{L_FORUM_PRUNE_SETTINGS}</legend> <dl> <dt><label for="enable_prune">{L_FORUM_AUTO_PRUNE}:</label><br /><span>{L_FORUM_AUTO_PRUNE_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="enable_prune" value="1"<!-- IF S_PRUNE_ENABLE --> id="enable_prune" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="enable_prune" value="0"<!-- IF not S_PRUNE_ENABLE --> id="enable_prune" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="prune_freq">{L_AUTO_PRUNE_FREQ}:</label><br /><span>{L_AUTO_PRUNE_FREQ_EXPLAIN}</span></dt> <dd><input type="text" id="prune_freq" name="prune_freq" value="{PRUNE_FREQ}" maxlength="4" size="4" /> {L_DAYS}</dd> </dl> <dl> <dt><label for="prune_days">{L_AUTO_PRUNE_DAYS}:</label><br /><span>{L_AUTO_PRUNE_DAYS_EXPLAIN}</span></dt> <dd><input type="text" id="prune_days" name="prune_days" value="{PRUNE_DAYS}" maxlength="4" size="4" /> {L_DAYS}</dd> </dl> <dl> <dt><label for="prune_viewed">{L_AUTO_PRUNE_VIEWED}:</label><br /><span>{L_AUTO_PRUNE_VIEWED_EXPLAIN}</span></dt> <dd><input type="text" id="prune_viewed" name="prune_viewed" value="{PRUNE_VIEWED}" maxlength="4" size="4" /> {L_DAYS}</dd> </dl> <dl> <dt><label for="prune_old_polls">{L_PRUNE_OLD_POLLS}:</label><br /><span>{L_PRUNE_OLD_POLLS_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="prune_old_polls" value="1"<!-- IF S_PRUNE_OLD_POLLS --> id="prune_old_polls" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="prune_old_polls" value="0"<!-- IF not S_PRUNE_OLD_POLLS --> id="prune_old_polls" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="prune_announce">{L_PRUNE_ANNOUNCEMENTS}:</label></dt> <dd><label><input type="radio" class="radio" name="prune_announce" value="1"<!-- IF S_PRUNE_ANNOUNCE --> id="prune_announce" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="prune_announce" value="0"<!-- IF not S_PRUNE_ANNOUNCE --> id="prune_announce" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="prune_sticky">{L_PRUNE_STICKY}:</label></dt> <dd><label><input type="radio" class="radio" name="prune_sticky" value="1"<!-- IF S_PRUNE_STICKY --> id="prune_sticky" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="prune_sticky" value="0"<!-- IF not S_PRUNE_STICKY --> id="prune_sticky" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> </fieldset> </div> <div id="forum_link_options"> <fieldset> <legend>{L_GENERAL_FORUM_SETTINGS}</legend> <dl> <dt><label for="link_display_on_index">{L_LIST_INDEX}:</label><br /><span>{L_LIST_INDEX_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="link_display_on_index" value="1"<!-- IF S_DISPLAY_ON_INDEX --> id="link_display_on_index" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="link_display_on_index" value="0"<!-- IF not S_DISPLAY_ON_INDEX --> id="link_display_on_index" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> <dl> <dt><label for="forum_link">{L_FORUM_LINK}:</label><br /><span>{L_FORUM_LINK_EXPLAIN}</span></dt> <dd><input class="text medium" type="text" id="forum_link" name="forum_link" value="{FORUM_DATA_LINK}" maxlength="255" /></dd> </dl> <dl> <dt><label for="forum_link_track">{L_FORUM_LINK_TRACK}:</label><br /><span>{L_FORUM_LINK_TRACK_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="forum_link_track" value="1"<!-- IF S_FORUM_LINK_TRACK --> id="forum_link_track" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="forum_link_track" value="0"<!-- IF not S_FORUM_LINK_TRACK --> id="forum_link_track" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> </fieldset> </div> <div id="forum_rules_options"> <fieldset> <legend>{L_FORUM_RULES}</legend> <dl> <dt><label for="forum_rules_link">{L_FORUM_RULES_LINK}:</label><br /><span>{L_FORUM_RULES_LINK_EXPLAIN}</span></dt> <dd><input class="text medium" type="text" id="forum_rules_link" name="forum_rules_link" value="{FORUM_RULES_LINK}" maxlength="255" /></dd> </dl> <!-- IF FORUM_RULES_PREVIEW --> <dl> <dt><label>{L_FORUM_RULES_PREVIEW}:</label></dt> <dd>{FORUM_RULES_PREVIEW}</dd> </dl> <!-- ENDIF --> <dl> <dt><label for="forum_rules">{L_FORUM_RULES}:</label><br /><span>{L_FORUM_RULES_EXPLAIN}</span></dt> <dd><textarea id="forum_rules" name="forum_rules" rows="4" cols="70">{FORUM_RULES_PLAIN}</textarea></dd> <dd><label><input type="checkbox" class="radio" name="rules_parse_bbcode"<!-- IF S_BBCODE_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_BBCODE}</label> <label><input type="checkbox" class="radio" name="rules_parse_smilies"<!-- IF S_SMILIES_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_SMILIES}</label> <label><input type="checkbox" class="radio" name="rules_parse_urls"<!-- IF S_URLS_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_URLS}</label></dd> </dl> </fieldset> </div> <fieldset class="submit-buttons"> <legend>{L_SUBMIT}</legend> <input class="button1" type="submit" id="submit" name="update" value="{L_SUBMIT}" /> <input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" /> {S_FORM_TOKEN} </fieldset> </form> <!-- ELSEIF S_DELETE_FORUM --> <a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">« {L_BACK}</a> <h1>{L_FORUM_DELETE}</h1> <p>{L_FORUM_DELETE_EXPLAIN}</p> <!-- IF S_ERROR --> <div class="errorbox"> <h3>{L_WARNING}</h3> <p>{ERROR_MSG}</p> </div> <!-- ENDIF --> <form id="acp_forum" method="post" action="{U_ACTION}"> <fieldset> <legend>{L_FORUM_DELETE}</legend> <dl> <dt><label>{L_FORUM_NAME}:</label></dt> <dd><strong>{FORUM_NAME}</strong></dd> </dl> <!-- IF S_FORUM_POST --> <dl> <dt><label for="delete_action">{L_ACTION}:</label></dt> <dd><label><input type="radio" class="radio" id="delete_action" name="action_posts" value="delete" checked="checked" /> {L_DELETE_ALL_POSTS}</label></dd> <!-- IF S_MOVE_FORUM_OPTIONS --> <dd><label><input type="radio" class="radio" name="action_posts" value="move" /> {L_MOVE_POSTS_TO}</label> <select name="posts_to_id">{S_MOVE_FORUM_OPTIONS}</select></dd> <!-- ENDIF --> </dl> <!-- ENDIF --> <!-- IF S_HAS_SUBFORUMS --> <dl> <dt><label for="sub_delete_action">{L_ACTION}:</label></dt> <dd><label><input type="radio" class="radio" id="sub_delete_action" name="action_subforums" value="delete" checked="checked" /> {L_DELETE_SUBFORUMS}</label></dd> <!-- IF S_FORUMS_LIST --> <dd><label><input type="radio" class="radio" name="action_subforums" value="move" /> {L_MOVE_SUBFORUMS_TO}</label> <select name="subforums_to_id">{S_FORUMS_LIST}</select></dd> <!-- ENDIF --> </dl> <!-- ENDIF --> <p class="quick"> <input class="button1" type="submit" name="update" value="{L_SUBMIT}" /> </p> {S_FORM_TOKEN} </fieldset> </form> <!-- ELSEIF S_CONTINUE_SYNC --> <script type="text/javascript"> // <![CDATA[ var close_waitscreen = 0; // no scrollbars... popup('{UA_PROGRESS_BAR}', 400, 240, '_sync'); // ]]> </script> <h1>{L_FORUM_ADMIN}</h1> <p>{L_FORUM_ADMIN_EXPLAIN}</p> <p>{L_PROGRESS_EXPLAIN}</p> <!-- ELSE --> <script type="text/javascript"> // <![CDATA[ /** * Popup search progress bar */ function popup_progress_bar() { var close_waitscreen = 0; // no scrollbars... popup('{UA_PROGRESS_BAR}', 400, 240, '_sync'); } // ]]> </script> <h1>{L_FORUM_ADMIN}</h1> <p>{L_FORUM_ADMIN_EXPLAIN}</p> <!-- IF ERROR_MSG --> <div class="errorbox"> <h3>{L_WARNING}</h3> <p>{ERROR_MSG}</p> </div> <!-- ENDIF --> <!-- IF S_RESYNCED --> <script type="text/javascript"> // <![CDATA[ var close_waitscreen = 1; // ]]> </script> <div class="successbox"> <h3>{L_NOTIFY}</h3> <p>{L_FORUM_RESYNCED}</p> </div> <!-- ENDIF --> <p><strong>{NAVIGATION}<!-- IF S_NO_FORUMS --> [<a href="{U_EDIT}">{L_EDIT}</a> | <a href="{U_DELETE}">{L_DELETE}</a><!-- IF not S_LINK --> | <a href="{U_SYNC}">{L_RESYNC}</a><!-- ENDIF --->]<!-- ENDIF --></strong></p> <!-- IF .forums --> <table cellspacing="1"> <col class="row1" /><col class="row1" /><col class="row2" /> <tbody> <!-- BEGIN forums --> <tr> <td style="width: 5%; text-align: center;">{forums.FOLDER_IMAGE}</td> <td> <!-- IF forums.FORUM_IMAGE --><div style="float: {S_CONTENT_FLOW_BEGIN}; margin-right: 5px;">{forums.FORUM_IMAGE}</div><!-- ENDIF --> <strong><!-- IF forums.S_FORUM_LINK -->{forums.FORUM_NAME}<!-- ELSE --><a href="{forums.U_FORUM}">{forums.FORUM_NAME}</a><!-- ENDIF --></strong> <!-- IF forums.FORUM_DESCRIPTION --><br /><span>{forums.FORUM_DESCRIPTION}</span><!-- ENDIF --> <!-- IF forums.S_FORUM_POST --><br /><br /><span>{L_TOPICS}: <strong>{forums.FORUM_TOPICS}</strong> / {L_POSTS}: <strong>{forums.FORUM_POSTS}</strong></span><!-- ENDIF --> </td> <td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;"> <!-- IF forums.S_FIRST_ROW && not forums.S_LAST_ROW --> {ICON_MOVE_UP_DISABLED} <a href="{forums.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <!-- ELSEIF not forums.S_FIRST_ROW && not forums.S_LAST_ROW --> <a href="{forums.U_MOVE_UP}">{ICON_MOVE_UP}</a> <a href="{forums.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <!-- ELSEIF forums.S_LAST_ROW && not forums.S_FIRST_ROW --> <a href="{forums.U_MOVE_UP}">{ICON_MOVE_UP}</a> {ICON_MOVE_DOWN_DISABLED} <!-- ELSE --> {ICON_MOVE_UP_DISABLED} {ICON_MOVE_DOWN_DISABLED} <!-- ENDIF --> <a href="{forums.U_EDIT}">{ICON_EDIT}</a> <!-- IF not forums.S_FORUM_LINK --> <a href="{forums.U_SYNC}" onclick="popup_progress_bar();">{ICON_SYNC}</a> <!-- ELSE --> {ICON_SYNC_DISABLED} <!-- ENDIF --> <a href="{forums.U_DELETE}">{ICON_DELETE}</a> </td> </tr> <!-- END forums --> </tbody> </table> <!-- ENDIF --> <form id="fselect" method="post" action="{U_SEL_ACTION}"> <fieldset class="quick"> {L_SELECT_FORUM}: <select name="parent_id" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.submit(); }">{FORUM_BOX}</select> <input class="button2" type="submit" value="{L_GO}" /> {S_FORM_TOKEN} </fieldset> </form> <form id="forums" method="post" action="{U_ACTION}"> <fieldset class="quick"> <input type="hidden" name="action" value="add" /> <input type="text" name="forum_name" value="" maxlength="255" /> <input class="button2" name="addforum" type="submit" value="{L_CREATE_FORUM}" /> {S_FORM_TOKEN} </fieldset> </form> <!-- ENDIF --> <!-- INCLUDE overall_footer.html -->functions_display.php <?php /** * * @package phpBB3 * @version $Id$ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ /** * @ignore */ if (!defined('IN_PHPBB')) { exit; } /** * Display Forums */ function display_forums($root_data = '', $display_moderators = true, $return_moderators = false) { global $db, $auth, $user, $template; global $phpbb_root_path, $phpEx, $config; $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array(); $parent_id = $visible_forums = 0; $sql_from = ''; // Mark forums read? $mark_read = request_var('mark', ''); if ($mark_read == 'all') { $mark_read = ''; } if (!$root_data) { if ($mark_read == 'forums') { $mark_read = 'all'; } $root_data = array('forum_id' => 0); $sql_where = ''; } else { $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id']; } // Handle marking everything read if ($mark_read == 'all') { $redirect = build_url(array('mark', 'hash')); meta_refresh(3, $redirect); if (check_link_hash(request_var('hash', ''), 'global')) { markread('all'); trigger_error( $user->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>') ); } else { trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>')); } } // Display list of active topics for this category? $show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; $sql_array = array( 'SELECT' => 'f.*', 'FROM' => array( FORUMS_TABLE => 'f' ), 'LEFT_JOIN' => array(), ); if ($config['load_db_lastread'] && $user->data['is_registered']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'); $sql_array['SELECT'] .= ', ft.mark_time'; } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); if (!$user->data['is_registered']) { $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; } } if ($show_active) { $sql_array['LEFT_JOIN'][] = array( 'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'" ); $sql_array['SELECT'] .= ', fa.user_id'; } $sql = $db->sql_build_query('SELECT', array( 'SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => 'f.left_id', )); $result = $db->sql_query($sql); $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; // Check for unread global announcements (index page only) $ga_unread = false; if ($root_data['forum_id'] == 0) { $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1); if (!empty($unread_ga_list)) { $ga_unread = true; } } while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; // Mark forums read? if ($mark_read == 'forums') { if ($auth->acl_get('f_list', $forum_id)) { $forum_ids[] = $forum_id; } continue; } // Category with no members if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) { continue; } // Skip branch if (isset($right_id)) { if ($row['left_id'] < $right_id) { continue; } unset($right_id); } if (!$auth->acl_get('f_list', $forum_id)) { // if the user does not have permissions to list this forum, skip everything until next branch $right_id = $row['right_id']; continue; } if ($config['load_db_lastread'] && $user->data['is_registered']) { $forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark']; } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { if (!$user->data['is_registered']) { $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; } $forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; } // Count the difference of real to public topics, so we can display an information to moderators $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0; $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics']; // Display active topics from this forum? if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) { if (!isset($active_forum_ary['forum_topics'])) { $active_forum_ary['forum_topics'] = 0; } if (!isset($active_forum_ary['forum_posts'])) { $active_forum_ary['forum_posts'] = 0; } $active_forum_ary['forum_id'][] = $forum_id; $active_forum_ary['enable_icons'][] = $row['enable_icons']; $active_forum_ary['forum_topics'] += $row['forum_topics']; $active_forum_ary['forum_posts'] += $row['forum_posts']; // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it... if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) { $active_forum_ary['exclude_forum_id'][] = $forum_id; } } // if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) { if ($row['forum_type'] != FORUM_CAT) { $forum_ids_moderator[] = (int) $forum_id; } // Direct child of current branch $parent_id = $forum_id; $forum_rows[$forum_id] = $row; if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) { $branch_root_id = $forum_id; } $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; } else if ($row['forum_type'] != FORUM_CAT) { $subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false; $subforums[$parent_id][$forum_id]['name'] = $row['forum_name']; $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; $subforums[$parent_id][$forum_id]['children'] = array(); if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) { $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id; } if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) { $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; } $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; // Do not list redirects in LINK Forums as Posts. if ($row['forum_type'] != FORUM_LINK) { $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts']; } if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) { $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id']; $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject']; $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time']; $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id']; $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name']; $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour']; $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id; } } } $db->sql_freeresult($result); // Handle marking posts if ($mark_read == 'forums') { $redirect = build_url(array('mark', 'hash')); $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { // Add 0 to forums array to mark global announcements correctly $forum_ids[] = 0; markread('topics', $forum_ids); $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>'); meta_refresh(3, $redirect); trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message); } else { $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'); meta_refresh(3, $redirect); trigger_error($message); } } // Grab moderators ... if necessary if ($display_moderators) { if ($return_moderators) { $forum_ids_moderator[] = $root_data['forum_id']; } get_moderators($forum_moderators, $forum_ids_moderator); } // Used to tell whatever we have to create a dummy category or not. $last_catless = true; foreach ($forum_rows as $row) { // Empty category if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) { $template->assign_block_vars('forumrow', array( 'S_IS_CAT' => true, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'FORUM_FOLDER_IMG' => '', 'FORUM_FOLDER_IMG_SRC' => '', 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '', 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id'])) ); continue; } $visible_forums++; $forum_id = $row['forum_id']; $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; // Mark the first visible forum on index as unread if there's any unread global announcement if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0]) { $forum_unread = true; } $folder_image = $folder_alt = $l_subforums = ''; $subforums_list = array(); // Generate list of subforums if we need to if (isset($subforums[$forum_id])) { foreach ($subforums[$forum_id] as $subforum_id => $subforum_row) { $subforum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false; if (!$subforum_unread && !empty($subforum_row['children'])) { foreach ($subforum_row['children'] as $child_id) { if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id]) { // Once we found an unread child forum, we can drop out of this loop $subforum_unread = true; break; } } } if ($subforum_row['display'] && $subforum_row['name']) { $subforums_list[] = array( 'link' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id), 'name' => $subforum_row['name'], 'unread' => $subforum_unread, ); } else { unset($subforums[$forum_id][$subforum_id]); } // If one subforum is unread the forum gets unread too... if ($subforum_unread) { $forum_unread = true; } } $l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': '; $folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum'; } else { switch ($row['forum_type']) { case FORUM_POST: $folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read'; break; case FORUM_LINK: $folder_image = 'forum_link'; break; } } // Which folder should we display? if ($row['forum_status'] == ITEM_LOCKED) { $folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked'; $folder_alt = 'FORUM_LOCKED'; } else { $folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS'; } // Create last post link information, if appropriate if ($row['forum_last_post_id']) { $last_post_subject = $row['forum_last_post_subject']; $last_post_time = $user->format_date($row['forum_last_post_time']); $last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id']; } else { $last_post_subject = $last_post_time = $last_post_url = ''; } // Output moderator listing ... if applicable $l_moderator = $moderators_list = ''; if ($display_moderators && !empty($forum_moderators[$forum_id])) { $l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS']; $moderators_list = implode(', ', $forum_moderators[$forum_id]); } $l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS'; $post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : ''; $s_subforums_list = array(); foreach ($subforums_list as $subforum) { $s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '" title="' . (($subforum['unread']) ? $user->lang['UNREAD_POSTS'] : $user->lang['NO_UNREAD_POSTS']) . '">' . $subforum['name'] . '</a>'; } if ($row['forum_subforumslist_type']) { $s_subforums_list_m = array(); $s_subforums_list_str =''; $s_subforums_list_m = $s_subforums_list; $sf_list = count($s_subforums_list); if ($sf_list) { $rows = ceil ($sf_list / $row['forum_subforumslist_type']); $s_subforums_list_m = array_chunk($s_subforums_list_m, $rows); $s_subforums_list_str = '<br /> <span style="float: left;">'; $s_subforums_list_str .= (string) implode(',<br />', $s_subforums_list_m[0]); $s_subforums_list_str .= '</span> '; for ($i=1; $i*$rows < $sf_list; $i++) { $s_subforums_list_str .= '<span style="float: left;"> '; $s_subforums_list_str .= (string) implode(',<br /> ', $s_subforums_list_m[$i]); $s_subforums_list_str .= '</span>'; } $s_subforums_list = $s_subforums_list_str; } } else { $s_subforums_list = (string) implode(', ', $s_subforums_list); } $catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false; if ($row['forum_type'] != FORUM_LINK) { $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); } else { // If the forum is a link and we count redirects we need to visit it // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id)) { $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); } else { $u_viewforum = $row['forum_link']; } } $template->assign_block_vars('forumrow', array( 'S_IS_CAT' => false, 'S_NO_CAT' => $catless && !$last_catless, 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false, 'S_UNREAD_FORUM' => $forum_unread, 'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']), 'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false, 'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false, 'S_SUBFORUMS' => (sizeof($subforums_list)) ? true : false, 'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'TOPICS' => $row['forum_topics'], $l_post_click_count => $post_click_count, 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '', 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', 'LAST_POST_SUBJECT' => censor_text($last_post_subject), 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'MODERATORS' => $moderators_list, 'SUBFORUMS' => $s_subforums_list, 'L_SUBFORUM_STR' => $l_subforums, 'L_MODERATOR_STR' => $l_moderator, 'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '', 'U_VIEWFORUM' => $u_viewforum, 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url) ); // Assign subforums loop for style authors foreach ($subforums_list as $subforum) { $template->assign_block_vars('forumrow.subforum', array( 'U_SUBFORUM' => $subforum['link'], 'SUBFORUM_NAME' => $subforum['name'], 'S_UNREAD' => $subforum['unread']) ); } $last_catless = $catless; } $template->assign_vars(array( 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums') : '', 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), )); if ($return_moderators) { return array($active_forum_ary, $forum_moderators); } return array($active_forum_ary, array()); } /** * Create forum rules for given forum */ function generate_forum_rules(&$forum_data) { if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link']) { return; } global $template, $phpbb_root_path, $phpEx; if ($forum_data['forum_rules']) { $forum_data['forum_rules'] = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']); } $template->assign_vars(array( 'S_FORUM_RULES' => true, 'U_FORUM_RULES' => $forum_data['forum_rules_link'], 'FORUM_RULES' => $forum_data['forum_rules']) ); } /** * Create forum navigation links for given forum, create parent * list if currently null, assign basic forum info to template */ function generate_forum_nav(&$forum_data) { global $db, $user, $template, $auth, $config; global $phpEx, $phpbb_root_path; if (!$auth->acl_get('f_list', $forum_data['forum_id'])) { return; } // Get forum parents $forum_parents = get_forum_parents($forum_data); // Build navigation links if (!empty($forum_parents)) { foreach ($forum_parents as $parent_forum_id => $parent_data) { list($parent_name, $parent_type) = array_values($parent_data); // Skip this parent if the user does not have the permission to view it if (!$auth->acl_get('f_list', $parent_forum_id)) { continue; } $template->assign_block_vars('navlinks', array( 'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false, 'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false, 'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false, 'FORUM_NAME' => $parent_name, 'FORUM_ID' => $parent_forum_id, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id)) ); } } $template->assign_block_vars('navlinks', array( 'S_IS_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false, 'S_IS_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, 'S_IS_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_ID' => $forum_data['forum_id'], 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data['forum_id'])) ); $template->assign_vars(array( 'FORUM_ID' => $forum_data['forum_id'], 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']), 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_data['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options'])) ? true : false, )); return; } /** * Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise */ function get_forum_parents(&$forum_data) { global $db; $forum_parents = array(); if ($forum_data['parent_id'] > 0) { if ($forum_data['forum_parents'] == '') { $sql = 'SELECT forum_id, forum_name, forum_type FROM ' . FORUMS_TABLE . ' WHERE left_id < ' . $forum_data['left_id'] . ' AND right_id > ' . $forum_data['right_id'] . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']); } $db->sql_freeresult($result); $forum_data['forum_parents'] = serialize($forum_parents); $sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "' WHERE parent_id = " . $forum_data['parent_id']; $db->sql_query($sql); } else { $forum_parents = unserialize($forum_data['forum_parents']); } } return $forum_parents; } /** * Generate topic pagination */ function topic_generate_pagination($replies, $url) { global $config, $user; // Make sure $per_page is a valid value $per_page = ($config['posts_per_page'] <= 0) ? 1 : $config['posts_per_page']; if (($replies + 1) > $per_page) { $total_pages = ceil(($replies + 1) / $per_page); $pagination = ''; $times = 1; for ($j = 0; $j < $replies + 1; $j += $per_page) { $pagination .= '<a href="' . $url . ($j == 0 ? '' : '&start=' . $j) . '">' . $times . '</a>'; if ($times == 1 && $total_pages > 5) { $pagination .= '<span class="page-dots"> ... </span>'; // Display the last three pages $times = $total_pages - 3; $j += ($total_pages - 4) * $per_page; } else if ($times < $total_pages) { $pagination .= '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>'; } $times++; } } else { $pagination = ''; } return $pagination; } /** * Obtain list of moderators of each forum */ function get_moderators(&$forum_moderators, $forum_id = false) { global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth; $forum_id_ary = array(); if ($forum_id !== false) { if (!is_array($forum_id)) { $forum_id = array($forum_id); } // Exchange key/value pair to be able to faster check for the forum id existence $forum_id_ary = array_flip($forum_id); } $sql_array = array( 'SELECT' => 'm.*, u.user_colour, g.group_colour, g.group_type', 'FROM' => array( MODERATOR_CACHE_TABLE => 'm', ), 'LEFT_JOIN' => array( array( 'FROM' => array(USERS_TABLE => 'u'), 'ON' => 'm.user_id = u.user_id', ), array( 'FROM' => array(GROUPS_TABLE => 'g'), 'ON' => 'm.group_id = g.group_id', ), ), 'WHERE' => 'm.display_on_index = 1', ); // We query every forum here because for caching we should not have any parameter. $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql, 3600); while ($row = $db->sql_fetchrow($result)) { $f_id = (int) $row['forum_id']; if (!isset($forum_id_ary[$f_id])) { continue; } if (!empty($row['user_id'])) { $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); } else { $group_name = (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']); if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) { $forum_moderators[$f_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>'; } else { $forum_moderators[$f_id][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>'; } } } $db->sql_freeresult($result); return; } /** * User authorisation levels output * * @param string $mode Can be forum or topic. Not in use at the moment. * @param int $forum_id The current forum the user is in. * @param int $forum_status The forums status bit. */ function gen_forum_auth_level($mode, $forum_id, $forum_status) { global $template, $auth, $user, $config; $locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false; $rules = array( ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'], ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'], ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'], ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'], ); if ($config['allow_attachments']) { $rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT']; } foreach ($rules as $rule) { $template->assign_block_vars('rules', array('RULE' => $rule)); } return; } /** * Generate topic status */ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type) { global $user, $config; $folder = $folder_new = ''; if ($topic_row['topic_status'] == ITEM_MOVED) { $topic_type = $user->lang['VIEW_TOPIC_MOVED']; $folder_img = 'topic_moved'; $folder_alt = 'TOPIC_MOVED'; } else { switch ($topic_row['topic_type']) { case POST_GLOBAL: $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; $folder = 'global_read'; $folder_new = 'global_unread'; break; case POST_ANNOUNCE: $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT']; $folder = 'announce_read'; $folder_new = 'announce_unread'; break; case POST_STICKY: $topic_type = $user->lang['VIEW_TOPIC_STICKY']; $folder = 'sticky_read'; $folder_new = 'sticky_unread'; break; default: $topic_type = ''; $folder = 'topic_read'; $folder_new = 'topic_unread'; // Hot topic threshold is for posts in a topic, which is replies + the first post. ;) if ($config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED) { $folder .= '_hot'; $folder_new .= '_hot'; } break; } if ($topic_row['topic_status'] == ITEM_LOCKED) { $topic_type = $user->lang['VIEW_TOPIC_LOCKED']; $folder .= '_locked'; $folder_new .= '_locked'; } $folder_img = ($unread_topic) ? $folder_new : $folder; $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS'); // Posted image? if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted']) { $folder_img .= '_mine'; } } if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED) { $topic_type = $user->lang['VIEW_TOPIC_POLL']; } } /** * Assign/Build custom bbcodes for display in screens supporting using of bbcodes * The custom bbcodes buttons will be placed within the template block 'custom_codes' */ function display_custom_bbcodes() { global $db, $template, $user; // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing) $num_predefined_bbcodes = 22; $sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline FROM ' . BBCODES_TABLE . ' WHERE display_on_posting = 1 ORDER BY bbcode_tag'; $result = $db->sql_query($sql); $i = 0; while ($row = $db->sql_fetchrow($result)) { // If the helpline is defined within the language file, we will use the localised version, else just use the database entry... if (isset($user->lang[strtoupper($row['bbcode_helpline'])])) { $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])]; } $template->assign_block_vars('custom_tags', array( 'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'", 'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2), 'BBCODE_TAG' => $row['bbcode_tag'], 'BBCODE_HELPLINE' => $row['bbcode_helpline'], 'A_BBCODE_HELPLINE' => str_replace(array('&', '"', "'", '<', '>'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']), )); $i++; } $db->sql_freeresult($result); } /** * Display reasons */ function display_reasons($reason_id = 0) { global $db, $user, $template; $sql = 'SELECT * FROM ' . REPORTS_REASONS_TABLE . ' ORDER BY reason_order ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { // If the reason is defined within the language file, we will use the localized version, else just use the database entry... if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) { $row['reason_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]; $row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]; } $template->assign_block_vars('reason', array( 'ID' => $row['reason_id'], 'TITLE' => $row['reason_title'], 'DESCRIPTION' => $row['reason_description'], 'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false) ); } $db->sql_freeresult($result); } /** * Display user activity (action forum/topic) */ function display_user_activity(&$userdata) { global $auth, $template, $db, $user; global $phpbb_root_path, $phpEx; // Do not display user activity for users having more than 5000 posts... if ($userdata['user_posts'] > 5000) { return; } $forum_ary = array(); // Do not include those forums the user is not having read access to... $forum_read_ary = $auth->acl_getf('!f_read'); foreach ($forum_read_ary as $forum_id => $not_allowed) { if ($not_allowed['f_read']) { $forum_ary[] = (int) $forum_id; } } $forum_ary = array_unique($forum_ary); $forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : ''; $fid_m_approve = $auth->acl_getf('m_approve', true); $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', array_keys($fid_m_approve)) : ''; // Obtain active forum $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . " AND post_postcount = 1 AND (post_approved = 1 $sql_m_approve) $forum_sql GROUP BY forum_id ORDER BY num_posts DESC"; $result = $db->sql_query_limit($sql, 1); $active_f_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!empty($active_f_row)) { $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $active_f_row['forum_id']; $result = $db->sql_query($sql, 3600); $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); $db->sql_freeresult($result); } // Obtain active topic // We need to exclude passworded forums here so we do not leak the topic title $forum_ary_topic = array_unique(array_merge($forum_ary, $user->get_passworded_forums())); $forum_sql_topic = (!empty($forum_ary_topic)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary_topic, true) : ''; $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . " AND post_postcount = 1 AND (post_approved = 1 $sql_m_approve) $forum_sql_topic GROUP BY topic_id ORDER BY num_posts DESC"; $result = $db->sql_query_limit($sql, 1); $active_t_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!empty($active_t_row)) { $sql = 'SELECT topic_title FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $active_t_row['topic_id']; $result = $db->sql_query($sql); $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); $db->sql_freeresult($result); } $userdata['active_t_row'] = $active_t_row; $userdata['active_f_row'] = $active_f_row; $active_f_name = $active_f_id = $active_f_count = $active_f_pct = ''; if (!empty($active_f_row['num_posts'])) { $active_f_name = $active_f_row['forum_name']; $active_f_id = $active_f_row['forum_id']; $active_f_count = $active_f_row['num_posts']; $active_f_pct = ($userdata['user_posts']) ? ($active_f_count / $userdata['user_posts']) * 100 : 0; } $active_t_name = $active_t_id = $active_t_count = $active_t_pct = ''; if (!empty($active_t_row['num_posts'])) { $active_t_name = $active_t_row['topic_title']; $active_t_id = $active_t_row['topic_id']; $active_t_count = $active_t_row['num_posts']; $active_t_pct = ($userdata['user_posts']) ? ($active_t_count / $userdata['user_posts']) * 100 : 0; } $l_active_pct = ($userdata['user_id'] != ANONYMOUS && $userdata['user_id'] == $user->data['user_id']) ? $user->lang['POST_PCT_ACTIVE_OWN'] : $user->lang['POST_PCT_ACTIVE']; $template->assign_vars(array( 'ACTIVE_FORUM' => $active_f_name, 'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count), 'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct), 'ACTIVE_TOPIC' => censor_text($active_t_name), 'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count), 'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct), 'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id), 'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id), 'S_SHOW_ACTIVITY' => true) ); } /** * Topic and forum watching common code */ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '') { global $template, $db, $user, $phpEx, $start, $phpbb_root_path; $table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE; $where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id'; $match_id = ($mode == 'forum') ? $forum_id : $topic_id; $u_url = "uid={$user->data['user_id']}"; $u_url .= ($mode == 'forum') ? '&f' : '&f=' . $forum_id . '&t'; $is_watching = 0; // Is user watching this thread? if ($user_id != ANONYMOUS) { $can_watch = true; if ($notify_status == 'unset') { $sql = "SELECT notify_status FROM $table_sql WHERE $where_sql = $match_id AND user_id = $user_id"; $result = $db->sql_query($sql); $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL; $db->sql_freeresult($result); } if (!is_null($notify_status) && $notify_status !== '') { if (isset($_GET['unwatch'])) { $uid = request_var('uid', 0); $token = request_var('hash', ''); if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) { if ($uid != $user_id || $_GET['unwatch'] != $mode) { $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); $message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); trigger_error($message); } $sql = 'DELETE FROM ' . $table_sql . " WHERE $where_sql = $match_id AND user_id = $user_id"; $db->sql_query($sql); $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />'; $message .= sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); meta_refresh(3, $redirect_url); trigger_error($message); } else { $s_hidden_fields = array( 'uid' => $user->data['user_id'], 'unwatch' => $mode, 'start' => $start, 'f' => $forum_id, ); if ($mode != 'forum') { $s_hidden_fields['t'] = $topic_id; } if ($item_title == '') { $confirm_box_message = 'UNWATCH_' . strtoupper($mode); } else { $confirm_box_message = $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title); } confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); } } else { $is_watching = true; if ($notify_status != NOTIFY_YES) { $sql = 'UPDATE ' . $table_sql . " SET notify_status = " . NOTIFY_YES . " WHERE $where_sql = $match_id AND user_id = $user_id"; $db->sql_query($sql); } } } else { if (isset($_GET['watch'])) { $uid = request_var('uid', 0); $token = request_var('hash', ''); if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) { if ($uid != $user_id || $_GET['watch'] != $mode) { $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); $message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); trigger_error($message); } $is_watching = true; $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status) VALUES ($user_id, $match_id, " . NOTIFY_YES . ')'; $db->sql_query($sql); $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); meta_refresh(3, $redirect_url); trigger_error($message); } else { $s_hidden_fields = array( 'uid' => $user->data['user_id'], 'watch' => $mode, 'start' => $start, 'f' => $forum_id, ); if ($mode != 'forum') { $s_hidden_fields['t'] = $topic_id; } $confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title)); confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); } } else { $is_watching = 0; } } } else { if ((isset($_GET['unwatch']) && $_GET['unwatch'] == $mode) || (isset($_GET['watch']) && $_GET['watch'] == $mode)) { login_box(); } else { $can_watch = 0; $is_watching = 0; } } if ($can_watch) { $s_watching['link'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&hash=" . generate_link_hash("{$mode}_$match_id")); $s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; $s_watching['is_watching'] = $is_watching; } return; } /** * Get user rank title and image * * @param int $user_rank the current stored users rank id * @param int $user_posts the users number of posts * @param string &$rank_title the rank title will be stored here after execution * @param string &$rank_img the rank image as full img tag is stored here after execution * @param string &$rank_img_src the rank image source is stored here after execution * * Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false */ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src) { global $ranks, $config, $phpbb_root_path; if (empty($ranks)) { global $cache; $ranks = $cache->obtain_ranks(); } if (!empty($user_rank)) { $rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : ''; $rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : ''; $rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : ''; } else if ($user_posts !== false) { if (!empty($ranks['normal'])) { foreach ($ranks['normal'] as $rank) { if ($user_posts >= $rank['rank_min']) { $rank_title = $rank['rank_title']; $rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : ''; $rank_img_src = (!empty($rank['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] : ''; break; } } } } } /** * Get user avatar * * @param string $avatar Users assigned avatar name * @param int $avatar_type Type of avatar * @param string $avatar_width Width of users avatar * @param string $avatar_height Height of users avatar * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP * * @return string Avatar image */ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) { global $user, $config, $phpbb_root_path, $phpEx; if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) { return ''; } $avatar_img = ''; switch ($avatar_type) { case AVATAR_UPLOAD: if (!$config['allow_avatar_upload'] && !$ignore_config) { return ''; } $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar="; break; case AVATAR_GALLERY: if (!$config['allow_avatar_local'] && !$ignore_config) { return ''; } $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; break; case AVATAR_REMOTE: if (!$config['allow_avatar_remote'] && !$ignore_config) { return ''; } break; } $avatar_img .= $avatar; return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />'; } ?>acp_forums.php <?php /** * * @package acp * @version $Id$ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ /** * @ignore */ if (!defined('IN_PHPBB')) { exit; } /** * @package acp */ class acp_forums { var $u_action; var $parent_id = 0; function main($id, $mode) { global $db, $user, $auth, $template, $cache; global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; $user->add_lang('acp/forums'); $this->tpl_name = 'acp_forums'; $this->page_title = 'ACP_MANAGE_FORUMS'; $form_key = 'acp_forums'; add_form_key($form_key); $action = request_var('action', ''); $update = (isset($_POST['update'])) ? true : false; $forum_id = request_var('f', 0); $this->parent_id = request_var('parent_id', 0); $forum_data = $errors = array(); if ($update && !check_form_key($form_key)) { $update = false; $errors[] = $user->lang['FORM_INVALID']; } // Check additional permissions switch ($action) { case 'progress_bar': $start = request_var('start', 0); $total = request_var('total', 0); $this->display_progress_bar($start, $total); break; case 'delete': if (!$auth->acl_get('a_forumdel')) { trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } break; case 'add': if (!$auth->acl_get('a_forumadd')) { trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } break; } // Major routines if ($update) { switch ($action) { case 'delete': $action_subforums = request_var('action_subforums', ''); $subforums_to_id = request_var('subforums_to_id', 0); $action_posts = request_var('action_posts', ''); $posts_to_id = request_var('posts_to_id', 0); $errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); if (sizeof($errors)) { break; } $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); break; case 'edit': $forum_data = array( 'forum_id' => $forum_id ); // No break here case 'add': $forum_data += array( 'parent_id' => request_var('forum_parent_id', $this->parent_id), 'forum_type' => request_var('forum_type', FORUM_POST), 'type_action' => request_var('type_action', ''), 'forum_status' => request_var('forum_status', ITEM_UNLOCKED), 'forum_parents' => '', 'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)), 'forum_link' => request_var('forum_link', ''), 'forum_link_track' => request_var('forum_link_track', false), 'forum_desc' => utf8_normalize_nfc(request_var('forum_desc', '', true)), 'forum_desc_uid' => '', 'forum_desc_options' => 7, 'forum_desc_bitfield' => '', 'forum_rules' => utf8_normalize_nfc(request_var('forum_rules', '', true)), 'forum_rules_uid' => '', 'forum_rules_options' => 7, 'forum_rules_bitfield' => '', 'forum_rules_link' => request_var('forum_rules_link', ''), 'forum_image' => request_var('forum_image', ''), 'forum_style' => request_var('forum_style', 0), 'display_subforum_list' => request_var('display_subforum_list', false), 'forum_subforumslist_type' => request_var('subforumslist_type', 0), 'display_on_index' => request_var('display_on_index', false), 'forum_topics_per_page' => request_var('topics_per_page', 0), 'enable_indexing' => request_var('enable_indexing', true), 'enable_icons' => request_var('enable_icons', false), 'enable_prune' => request_var('enable_prune', false), 'enable_post_review' => request_var('enable_post_review', true), 'enable_quick_reply' => request_var('enable_quick_reply', false), 'prune_days' => request_var('prune_days', 7), 'prune_viewed' => request_var('prune_viewed', 7), 'prune_freq' => request_var('prune_freq', 1), 'prune_old_polls' => request_var('prune_old_polls', false), 'prune_announce' => request_var('prune_announce', false), 'prune_sticky' => request_var('prune_sticky', false), 'forum_password' => request_var('forum_password', '', true), 'forum_password_confirm'=> request_var('forum_password_confirm', '', true), 'forum_password_unset' => request_var('forum_password_unset', false), ); // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') { $forum_data['forum_options'] = 0; } // Use link_display_on_index setting if forum type is link if ($forum_data['forum_type'] == FORUM_LINK) { $forum_data['display_on_index'] = request_var('link_display_on_index', false); } // Linked forums and categories are not able to be locked... if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT) { $forum_data['forum_status'] = ITEM_UNLOCKED; } $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', false); // Get data for forum rules if specified... if ($forum_data['forum_rules']) { generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_parse_bbcode', false), request_var('rules_parse_urls', false), request_var('rules_parse_smilies', false)); } // Get data for forum description if specified if ($forum_data['forum_desc']) { generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_parse_bbcode', false), request_var('desc_parse_urls', false), request_var('desc_parse_smilies', false)); } $errors = $this->update_forum_data($forum_data); if (!sizeof($errors)) { $forum_perm_from = request_var('forum_perm_from', 0); $cache->destroy('sql', FORUMS_TABLE); $copied_permissions = false; // Copy permissions? if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] && ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) { copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); cache_moderators(); $copied_permissions = true; } /* Commented out because of questionable UI workflow - re-visit for 3.0.7 else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) { $this->copy_permission_page($forum_data); return; } */ $auth->acl_clear_prefetch(); $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; $message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED']; // redirect directly to permission settings screen if authed if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth')) { $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>'); meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url)); } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); } break; } } switch ($action) { case 'move_up': case 'move_down': if (!$forum_id) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $sql = 'SELECT * FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $move_forum_name = $this->move_forum_by($row, $action, 1); if ($move_forum_name !== false) { add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); $cache->destroy('sql', FORUMS_TABLE); } break; case 'sync': if (!$forum_id) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } @set_time_limit(0); $sql = 'SELECT forum_name, forum_topics_real FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } if ($row['forum_topics_real']) { $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $forum_id; $result = $db->sql_query($sql); $row2 = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Typecast to int if there is no data available $row2['min_topic_id'] = (int) $row2['min_topic_id']; $row2['max_topic_id'] = (int) $row2['max_topic_id']; $start = request_var('start', $row2['min_topic_id']); $batch_size = 2000; $end = $start + $batch_size; // Sync all topics in batch mode... sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); if ($end < $row2['max_topic_id']) { // We really need to find a way of showing statistics... no progress here $sql = 'SELECT COUNT(topic_id) as num_topics FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $forum_id . ' AND topic_id BETWEEN ' . $start . ' AND ' . $end; $result = $db->sql_query($sql); $topics_done = request_var('topics_done', 0) + (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); $start += $batch_size; $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['forum_topics_real']}"; meta_refresh(0, $url); $template->assign_vars(array( 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}", 'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}"), 'S_CONTINUE_SYNC' => true, 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['forum_topics_real'])) ); return; } } $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_forum"; meta_refresh(0, $url); $template->assign_vars(array( 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), 'S_CONTINUE_SYNC' => true, 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['forum_topics_real'])) ); return; break; case 'sync_forum': $sql = 'SELECT forum_name, forum_type FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } sync('forum', 'forum_id', $forum_id, false, true); add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); $cache->destroy('sql', FORUMS_TABLE); $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name'])); break; case 'add': case 'edit': if ($update) { $forum_data['forum_flags'] = 0; $forum_data['forum_flags'] += (request_var('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0; $forum_data['forum_flags'] += (request_var('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0; $forum_data['forum_flags'] += (request_var('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0; $forum_data['forum_flags'] += (request_var('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0; $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; $forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0; $forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0; } // Show form to create/modify a forum if ($action == 'edit') { $this->page_title = 'EDIT_FORUM'; $row = $this->get_forum_info($forum_id); $old_forum_type = $row['forum_type']; if (!$update) { $forum_data = $row; } else { $forum_data['left_id'] = $row['left_id']; $forum_data['right_id'] = $row['right_id']; } // Make sure no direct child forums are able to be selected as parents. $exclude_forums = array(); foreach (get_forum_branch($forum_id, 'children') as $row) { $exclude_forums[] = $row['forum_id']; } $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); $forum_data['forum_password_confirm'] = $forum_data['forum_password']; } else { $this->page_title = 'CREATE_FORUM'; $forum_id = $this->parent_id; $parents_list = make_forum_select($this->parent_id, false, false, false, false); // Fill forum data with default values if (!$update) { $forum_data = array( 'parent_id' => $this->parent_id, 'forum_type' => FORUM_POST, 'forum_status' => ITEM_UNLOCKED, 'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)), 'forum_link' => '', 'forum_link_track' => false, 'forum_desc' => '', 'forum_rules' => '', 'forum_rules_link' => '', 'forum_image' => '', 'forum_style' => 0, 'display_subforum_list' => true, 'forum_subforumslist_type' => 0, 'display_on_index' => false, 'forum_topics_per_page' => 0, 'enable_indexing' => true, 'enable_icons' => false, 'enable_prune' => false, 'prune_days' => 7, 'prune_viewed' => 7, 'prune_freq' => 1, 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, 'forum_options' => 0, 'forum_password' => '', 'forum_password_confirm'=> '', ); } } $forum_rules_data = array( 'text' => $forum_data['forum_rules'], 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true ); $forum_desc_data = array( 'text' => $forum_data['forum_desc'], 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true ); $forum_rules_preview = ''; // Parse rules if specified if ($forum_data['forum_rules']) { if (!isset($forum_data['forum_rules_uid'])) { // Before we are able to display the preview and plane text, we need to parse our request_var()'d value... $forum_data['forum_rules_uid'] = ''; $forum_data['forum_rules_bitfield'] = ''; $forum_data['forum_rules_options'] = 0; generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_allow_bbcode', false), request_var('rules_allow_urls', false), request_var('rules_allow_smilies', false)); } // Generate preview content $forum_rules_preview = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']); // decode... $forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']); } // Parse desciption if specified if ($forum_data['forum_desc']) { if (!isset($forum_data['forum_desc_uid'])) { // Before we are able to display the preview and plane text, we need to parse our request_var()'d value... $forum_data['forum_desc_uid'] = ''; $forum_data['forum_desc_bitfield'] = ''; $forum_data['forum_desc_options'] = 0; generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_allow_bbcode', false), request_var('desc_allow_urls', false), request_var('desc_allow_smilies', false)); } // decode... $forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']); } $forum_type_options = ''; $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK'); foreach ($forum_type_ary as $value => $lang) { $forum_type_options .= '<option value="' . $value . '"' . (($value == $forum_data['forum_type']) ? ' selected="selected"' : '') . '>' . $user->lang['TYPE_' . $lang] . '</option>'; } $styles_list = style_select($forum_data['forum_style'], true); $statuslist = '<option value="' . ITEM_UNLOCKED . '"' . (($forum_data['forum_status'] == ITEM_UNLOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['UNLOCKED'] . '</option><option value="' . ITEM_LOCKED . '"' . (($forum_data['forum_status'] == ITEM_LOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['LOCKED'] . '</option>'; $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . " AND forum_id <> $forum_id"; $result = $db->sql_query_limit($sql, 1); $postable_forum_exists = false; if ($db->sql_fetchrow($result)) { $postable_forum_exists = true; } $db->sql_freeresult($result); // Subforum move options if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT) { $subforums_id = array(); $subforums = get_forum_branch($forum_id, 'children'); foreach ($subforums as $row) { $subforums_id[] = $row['forum_id']; } $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); if ($postable_forum_exists) { $template->assign_vars(array( 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false??? ); } $template->assign_vars(array( 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, 'S_FORUMS_LIST' => $forums_list) ); } else if ($postable_forum_exists) { $template->assign_vars(array( 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) ); } $s_show_display_on_index = false; if ($forum_data['parent_id'] > 0) { // if this forum is a subforum put the "display on index" checkbox if ($parent_info = $this->get_forum_info($forum_data['parent_id'])) { if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT) { $s_show_display_on_index = true; } } } if (strlen($forum_data['forum_password']) == 32) { $errors[] = $user->lang['FORUM_PASSWORD_OLD']; } $template->assign_vars(array( 'S_EDIT_FORUM' => true, 'S_ERROR' => (sizeof($errors)) ? true : false, 'S_PARENT_ID' => $this->parent_id, 'S_FORUM_PARENT_ID' => $forum_data['parent_id'], 'S_ADD_ACTION' => ($action == 'add') ? true : false, 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, 'U_EDIT_ACTION' => $this->u_action . "&parent_id={$this->parent_id}&action=$action&f=$forum_id", 'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'], 'L_TITLE' => $user->lang[$this->page_title], 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '', 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_DATA_LINK' => $forum_data['forum_link'], 'FORUM_IMAGE' => $forum_data['forum_image'], 'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? $phpbb_root_path . $forum_data['forum_image'] : '', 'FORUM_POST' => FORUM_POST, 'FORUM_LINK' => FORUM_LINK, 'FORUM_CAT' => FORUM_CAT, 'PRUNE_FREQ' => $forum_data['prune_freq'], 'PRUNE_DAYS' => $forum_data['prune_days'], 'PRUNE_VIEWED' => $forum_data['prune_viewed'], 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], 'FORUM_RULES' => $forum_data['forum_rules'], 'FORUM_RULES_PREVIEW' => $forum_rules_preview, 'FORUM_RULES_PLAIN' => $forum_rules_data['text'], 'S_BBCODE_CHECKED' => ($forum_rules_data['allow_bbcode']) ? true : false, 'S_SMILIES_CHECKED' => ($forum_rules_data['allow_smilies']) ? true : false, 'S_URLS_CHECKED' => ($forum_rules_data['allow_urls']) ? true : false, 'S_FORUM_PASSWORD_SET' => (empty($forum_data['forum_password'])) ? false : true, 'FORUM_DESC' => $forum_desc_data['text'], 'S_DESC_BBCODE_CHECKED' => ($forum_desc_data['allow_bbcode']) ? true : false, 'S_DESC_SMILIES_CHECKED' => ($forum_desc_data['allow_smilies']) ? true : false, 'S_DESC_URLS_CHECKED' => ($forum_desc_data['allow_urls']) ? true : false, 'S_FORUM_TYPE_OPTIONS' => $forum_type_options, 'S_STATUS_OPTIONS' => $statuslist, 'S_PARENT_OPTIONS' => $parents_list, 'S_STYLES_OPTIONS' => $styles_list, 'S_FORUM_OPTIONS' => make_forum_select(($action == 'add') ? $forum_data['parent_id'] : false, ($action == 'edit') ? $forum_data['forum_id'] : false, false, false, false), 'S_SHOW_DISPLAY_ON_INDEX' => $s_show_display_on_index, 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, 'S_FORUM_ORIG_POST' => (isset($old_forum_type) && $old_forum_type == FORUM_POST) ? true : false, 'S_FORUM_ORIG_CAT' => (isset($old_forum_type) && $old_forum_type == FORUM_CAT) ? true : false, 'S_FORUM_ORIG_LINK' => (isset($old_forum_type) && $old_forum_type == FORUM_LINK) ? true : false, 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, 'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false, 'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false, 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, 'SUBFORUMSLIST_TYPE' => $forum_data['forum_subforumslist_type'], 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? true : false, 'S_PRUNE_OLD_POLLS' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false, 'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false, 'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false, 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true, 'S_ENABLE_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false, 'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false, 'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false, 'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false, )); return; break; case 'delete': if (!$forum_id) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $forum_data = $this->get_forum_info($forum_id); $subforums_id = array(); $subforums = get_forum_branch($forum_id, 'children'); foreach ($subforums as $row) { $subforums_id[] = $row['forum_id']; } $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . " AND forum_id <> $forum_id"; $result = $db->sql_query_limit($sql, 1); if ($db->sql_fetchrow($result)) { $template->assign_vars(array( 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false??? ); } $db->sql_freeresult($result); $parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id; $template->assign_vars(array( 'S_DELETE_FORUM' => true, 'U_ACTION' => $this->u_action . "&parent_id={$parent_id}&action=delete&f=$forum_id", 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, 'FORUM_NAME' => $forum_data['forum_name'], 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, 'S_FORUMS_LIST' => $forums_list, 'S_ERROR' => (sizeof($errors)) ? true : false, 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '') ); return; break; case 'copy_perm': $forum_perm_from = request_var('forum_perm_from', 0); // Copy permissions? if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) { copy_forum_permissions($forum_perm_from, $forum_id, true); cache_moderators(); $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_id; $message = $user->lang['FORUM_UPDATED']; // Redirect to permissions if ($auth->acl_get('a_fauth')) { $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>'); } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); } break; } // Default management page if (!$this->parent_id) { $navigation = $user->lang['FORUM_INDEX']; } else { $navigation = '<a href="' . $this->u_action . '">' . $user->lang['FORUM_INDEX'] . '</a>'; $forums_nav = get_forum_branch($this->parent_id, 'parents', 'descending'); foreach ($forums_nav as $row) { if ($row['forum_id'] == $this->parent_id) { $navigation .= ' -> ' . $row['forum_name']; } else { $navigation .= ' -> <a href="' . $this->u_action . '&parent_id=' . $row['forum_id'] . '">' . $row['forum_name'] . '</a>'; } } } // Jumpbox $forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id); if ($action == 'sync' || $action == 'sync_forum') { $template->assign_var('S_RESYNCED', true); } $sql = 'SELECT * FROM ' . FORUMS_TABLE . " WHERE parent_id = $this->parent_id ORDER BY left_id"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { do { $forum_type = $row['forum_type']; if ($row['forum_status'] == ITEM_LOCKED) { $folder_image = '<img src="images/icon_folder_lock.gif" alt="' . $user->lang['LOCKED'] . '" />'; } else { switch ($forum_type) { case FORUM_LINK: $folder_image = '<img src="images/icon_folder_link.gif" alt="' . $user->lang['LINK'] . '" />'; break; default: $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="' . $user->lang['SUBFORUM'] . '" />' : '<img src="images/icon_folder.gif" alt="' . $user->lang['FOLDER'] . '" />'; break; } } $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; $template->assign_block_vars('forums', array( 'FOLDER_IMAGE' => $folder_image, 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="" />' : '', 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'FORUM_TOPICS' => $row['forum_topics'], 'FORUM_POSTS' => $row['forum_posts'], 'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false, 'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false, 'U_FORUM' => $this->u_action . '&parent_id=' . $row['forum_id'], 'U_MOVE_UP' => $url . '&action=move_up', 'U_MOVE_DOWN' => $url . '&action=move_down', 'U_EDIT' => $url . '&action=edit', 'U_DELETE' => $url . '&action=delete', 'U_SYNC' => $url . '&action=sync') ); } while ($row = $db->sql_fetchrow($result)); } else if ($this->parent_id) { $row = $this->get_forum_info($this->parent_id); $url = $this->u_action . '&parent_id=' . $this->parent_id . '&f=' . $row['forum_id']; $template->assign_vars(array( 'S_NO_FORUMS' => true, 'U_EDIT' => $url . '&action=edit', 'U_DELETE' => $url . '&action=delete', 'U_SYNC' => $url . '&action=sync') ); } $db->sql_freeresult($result); $template->assign_vars(array( 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '', 'NAVIGATION' => $navigation, 'FORUM_BOX' => $forum_box, 'U_SEL_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id, 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), )); } /** * Get forum details */ function get_forum_info($forum_id) { global $db; $sql = 'SELECT * FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); } return $row; } /** * Update forum data */ function update_forum_data(&$forum_data) { global $db, $user, $cache, $phpbb_root_path; $errors = array(); if ($forum_data['forum_name'] == '') { $errors[] = $user->lang['FORUM_NAME_EMPTY']; } if (utf8_strlen($forum_data['forum_desc']) > 4000) { $errors[] = $user->lang['FORUM_DESC_TOO_LONG']; } if (utf8_strlen($forum_data['forum_rules']) > 4000) { $errors[] = $user->lang['FORUM_RULES_TOO_LONG']; } if ($forum_data['forum_password'] || $forum_data['forum_password_confirm']) { if ($forum_data['forum_password'] != $forum_data['forum_password_confirm']) { $forum_data['forum_password'] = $forum_data['forum_password_confirm'] = ''; $errors[] = $user->lang['FORUM_PASSWORD_MISMATCH']; } } if ($forum_data['prune_days'] < 0 || $forum_data['prune_viewed'] < 0 || $forum_data['prune_freq'] < 0) { $forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0; $errors[] = $user->lang['FORUM_DATA_NEGATIVE']; } $range_test_ary = array( array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'), ); if (!empty($forum_data['forum_image']) && !file_exists($phpbb_root_path . $forum_data['forum_image'])) { $errors[] = $user->lang['FORUM_IMAGE_NO_EXIST']; } validate_range($range_test_ary, $errors); // Set forum flags // 1 = link tracking // 2 = prune old polls // 4 = prune announcements // 8 = prune stickies // 16 = show active topics // 32 = enable post review $forum_data['forum_flags'] = 0; $forum_data['forum_flags'] += ($forum_data['forum_link_track']) ? FORUM_FLAG_LINK_TRACK : 0; $forum_data['forum_flags'] += ($forum_data['prune_old_polls']) ? FORUM_FLAG_PRUNE_POLL : 0; $forum_data['forum_flags'] += ($forum_data['prune_announce']) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0; $forum_data['forum_flags'] += ($forum_data['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0; $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; $forum_data['forum_flags'] += ($forum_data['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0; $forum_data['forum_flags'] += ($forum_data['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0; // Unset data that are not database fields $forum_data_sql = $forum_data; unset($forum_data_sql['forum_link_track']); unset($forum_data_sql['prune_old_polls']); unset($forum_data_sql['prune_announce']); unset($forum_data_sql['prune_sticky']); unset($forum_data_sql['show_active']); unset($forum_data_sql['enable_post_review']); unset($forum_data_sql['enable_quick_reply']); unset($forum_data_sql['forum_password_confirm']); // What are we going to do tonight Brain? The same thing we do everynight, // try to take over the world ... or decide whether to continue update // and if so, whether it's a new forum/cat/link or an existing one if (sizeof($errors)) { return $errors; } // As we don't know the old password, it's kinda tricky to detect changes if ($forum_data_sql['forum_password_unset']) { $forum_data_sql['forum_password'] = ''; } else if (empty($forum_data_sql['forum_password'])) { unset($forum_data_sql['forum_password']); } else { $forum_data_sql['forum_password'] = phpbb_hash($forum_data_sql['forum_password']); } unset($forum_data_sql['forum_password_unset']); if (!isset($forum_data_sql['forum_id'])) { // no forum_id means we're creating a new forum unset($forum_data_sql['type_action']); if ($forum_data_sql['parent_id']) { $sql = 'SELECT left_id, right_id, forum_type FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $forum_data_sql['parent_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } if ($row['forum_type'] == FORUM_LINK) { $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; return $errors; } $sql = 'UPDATE ' . FORUMS_TABLE . ' SET left_id = left_id + 2, right_id = right_id + 2 WHERE left_id > ' . $row['right_id']; $db->sql_query($sql); $sql = 'UPDATE ' . FORUMS_TABLE . ' SET right_id = right_id + 2 WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id'; $db->sql_query($sql); $forum_data_sql['left_id'] = $row['right_id']; $forum_data_sql['right_id'] = $row['right_id'] + 1; } else { $sql = 'SELECT MAX(right_id) AS right_id FROM ' . FORUMS_TABLE; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $forum_data_sql['left_id'] = $row['right_id'] + 1; $forum_data_sql['right_id'] = $row['right_id'] + 2; } $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql); $db->sql_query($sql); $forum_data['forum_id'] = $db->sql_nextid(); add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']); } else { $row = $this->get_forum_info($forum_data_sql['forum_id']); if ($row['forum_type'] == FORUM_POST && $row['forum_type'] != $forum_data_sql['forum_type']) { // Has subforums and want to change into a link? if ($row['right_id'] - $row['left_id'] > 1 && $forum_data_sql['forum_type'] == FORUM_LINK) { $errors[] = $user->lang['FORUM_WITH_SUBFORUMS_NOT_TO_LINK']; return $errors; } // we're turning a postable forum into a non-postable forum if ($forum_data_sql['type_action'] == 'move') { $to_forum_id = request_var('to_forum_id', 0); if ($to_forum_id) { $errors = $this->move_forum_content($forum_data_sql['forum_id'], $to_forum_id); } else { return array($user->lang['NO_DESTINATION_FORUM']); } } else if ($forum_data_sql['type_action'] == 'delete') { $errors = $this->delete_forum_content($forum_data_sql['forum_id']); } else { return array($user->lang['NO_FORUM_ACTION']); } $forum_data_sql['forum_posts'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_real'] = $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = ''; } else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK) { // Has subforums? if ($row['right_id'] - $row['left_id'] > 1) { // We are turning a category into a link - but need to decide what to do with the subforums. $action_subforums = request_var('action_subforums', ''); $subforums_to_id = request_var('subforums_to_id', 0); if ($action_subforums == 'delete') { $rows = get_forum_branch($row['forum_id'], 'children', 'descending', false); foreach ($rows as $_row) { // Do not remove the forum id we are about to change. ;) if ($_row['forum_id'] == $row['forum_id']) { continue; } $forum_ids[] = $_row['forum_id']; $errors = array_merge($errors, $this->delete_forum_content($_row['forum_id'])); } if (sizeof($errors)) { return $errors; } if (sizeof($forum_ids)) { $sql = 'DELETE FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids); $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids); $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids); $db->sql_query($sql); // Delete forum ids from extension groups table $sql = 'SELECT group_id, allowed_forums FROM ' . EXTENSION_GROUPS_TABLE; $result = $db->sql_query($sql); while ($_row = $db->sql_fetchrow($result)) { if (!$_row['allowed_forums']) { continue; } $allowed_forums = unserialize(trim($_row['allowed_forums'])); $allowed_forums = array_diff($allowed_forums, $forum_ids); $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' WHERE group_id = {$_row['group_id']}"; $db->sql_query($sql); } $db->sql_freeresult($result); $cache->destroy('_extensions'); } } else if ($action_subforums == 'move') { if (!$subforums_to_id) { return array($user->lang['NO_DESTINATION_FORUM']); } $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $subforums_to_id; $result = $db->sql_query($sql); $_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$_row) { return array($user->lang['NO_FORUM']); } $subforums_to_name = $_row['forum_name']; $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . " WHERE parent_id = {$row['forum_id']}"; $result = $db->sql_query($sql); while ($_row = $db->sql_fetchrow($result)) { $this->move_forum($_row['forum_id'], $subforums_to_id); } $db->sql_freeresult($result); $sql = 'UPDATE ' . FORUMS_TABLE . " SET parent_id = $subforums_to_id WHERE parent_id = {$row['forum_id']}"; $db->sql_query($sql); } // Adjust the left/right id $sql = 'UPDATE ' . FORUMS_TABLE . ' SET right_id = left_id + 1 WHERE forum_id = ' . $row['forum_id']; $db->sql_query($sql); } } else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST) { // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum) $forum_data_sql['forum_posts'] = 0; $forum_data_sql['forum_topics'] = 0; $forum_data_sql['forum_topics_real'] = 0; $forum_data_sql['forum_last_post_id'] = 0; $forum_data_sql['forum_last_post_subject'] = ''; $forum_data_sql['forum_last_post_time'] = 0; $forum_data_sql['forum_last_poster_id'] = 0; $forum_data_sql['forum_last_poster_name'] = ''; $forum_data_sql['forum_last_poster_colour'] = ''; } if (sizeof($errors)) { return $errors; } if ($row['parent_id'] != $forum_data_sql['parent_id']) { if ($row['forum_id'] != $forum_data_sql['parent_id']) { $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']); } else { $forum_data_sql['parent_id'] = $row['parent_id']; } } if (sizeof($errors)) { return $errors; } unset($forum_data_sql['type_action']); if ($row['forum_name'] != $forum_data_sql['forum_name']) { // the forum name has changed, clear the parents list of all forums (for safety) $sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_parents = ''"; $db->sql_query($sql); } // Setting the forum id to the forum id is not really received well by some dbs. ;) $forum_id = $forum_data_sql['forum_id']; unset($forum_data_sql['forum_id']); $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . ' WHERE forum_id = ' . $forum_id; $db->sql_query($sql); // Add it back $forum_data['forum_id'] = $forum_id; add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']); } return $errors; } /** * Move forum */ function move_forum($from_id, $to_id) { global $db, $user; $to_data = $moved_ids = $errors = array(); // Check if we want to move to a parent with link type if ($to_id > 0) { $to_data = $this->get_forum_info($to_id); if ($to_data['forum_type'] == FORUM_LINK) { $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; return $errors; } } $moved_forums = get_forum_branch($from_id, 'children', 'descending'); $from_data = $moved_forums[0]; $diff = sizeof($moved_forums) * 2; $moved_ids = array(); for ($i = 0; $i < sizeof($moved_forums); ++$i) { $moved_ids[] = $moved_forums[$i]['forum_id']; } // Resync parents $sql = 'UPDATE ' . FORUMS_TABLE . " SET right_id = right_id - $diff, forum_parents = '' WHERE left_id < " . $from_data['right_id'] . " AND right_id > " . $from_data['right_id']; $db->sql_query($sql); // Resync righthand side of tree $sql = 'UPDATE ' . FORUMS_TABLE . " SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = '' WHERE left_id > " . $from_data['right_id']; $db->sql_query($sql); if ($to_id > 0) { // Retrieve $to_data again, it may have been changed... $to_data = $this->get_forum_info($to_id); // Resync new parents $sql = 'UPDATE ' . FORUMS_TABLE . " SET right_id = right_id + $diff, forum_parents = '' WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id AND ' . $db->sql_in_set('forum_id', $moved_ids, true); $db->sql_query($sql); // Resync the righthand side of the tree $sql = 'UPDATE ' . FORUMS_TABLE . " SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = '' WHERE left_id > " . $to_data['right_id'] . ' AND ' . $db->sql_in_set('forum_id', $moved_ids, true); $db->sql_query($sql); // Resync moved branch $to_data['right_id'] += $diff; if ($to_data['right_id'] > $from_data['right_id']) { $diff = '+ ' . ($to_data['right_id'] - $from_data['right_id'] - 1); } else { $diff = '- ' . abs($to_data['right_id'] - $from_data['right_id'] - 1); } } else { $sql = 'SELECT MAX(right_id) AS right_id FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1); } $sql = 'UPDATE ' . FORUMS_TABLE . " SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' WHERE " . $db->sql_in_set('forum_id', $moved_ids); $db->sql_query($sql); return $errors; } /** * Move forum content from one to another forum */ function move_forum_content($from_id, $to_id, $sync = true) { global $db; $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); foreach ($table_ary as $table) { $sql = "UPDATE $table SET forum_id = $to_id WHERE forum_id = $from_id"; $db->sql_query($sql); } unset($table_ary); $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE); foreach ($table_ary as $table) { $sql = "DELETE FROM $table WHERE forum_id = $from_id"; $db->sql_query($sql); } if ($sync) { // Delete ghost topics that link back to the same forum then resync counters sync('topic_moved'); sync('forum', 'forum_id', $to_id, false, true); } return array(); } /** * Remove complete forum */ function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0) { global $db, $user, $cache; $forum_data = $this->get_forum_info($forum_id); $errors = array(); $log_action_posts = $log_action_forums = $posts_to_name = $subforums_to_name = ''; $forum_ids = array($forum_id); if ($action_posts == 'delete') { $log_action_posts = 'POSTS'; $errors = array_merge($errors, $this->delete_forum_content($forum_id)); } else if ($action_posts == 'move') { if (!$posts_to_id) { $errors[] = $user->lang['NO_DESTINATION_FORUM']; } else { $log_action_posts = 'MOVE_POSTS'; $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $posts_to_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $errors[] = $user->lang['NO_FORUM']; } else { $posts_to_name = $row['forum_name']; $errors = array_merge($errors, $this->move_forum_content($forum_id, $posts_to_id)); } } } if (sizeof($errors)) { return $errors; } if ($action_subforums == 'delete') { $log_action_forums = 'FORUMS'; $rows = get_forum_branch($forum_id, 'children', 'descending', false); foreach ($rows as $row) { $forum_ids[] = $row['forum_id']; $errors = array_merge($errors, $this->delete_forum_content($row['forum_id'])); } if (sizeof($errors)) { return $errors; } $diff = sizeof($forum_ids) * 2; $sql = 'DELETE FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids); $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids); $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids); $db->sql_query($sql); } else if ($action_subforums == 'move') { if (!$subforums_to_id) { $errors[] = $user->lang['NO_DESTINATION_FORUM']; } else { $log_action_forums = 'MOVE_FORUMS'; $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $subforums_to_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $errors[] = $user->lang['NO_FORUM']; } else { $subforums_to_name = $row['forum_name']; $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . " WHERE parent_id = $forum_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $this->move_forum($row['forum_id'], $subforums_to_id); } $db->sql_freeresult($result); // Grab new forum data for correct tree updating later $forum_data = $this->get_forum_info($forum_id); $sql = 'UPDATE ' . FORUMS_TABLE . " SET parent_id = $subforums_to_id WHERE parent_id = $forum_id"; $db->sql_query($sql); $diff = 2; $sql = 'DELETE FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " WHERE forum_id = $forum_id"; $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " WHERE forum_id = $forum_id"; $db->sql_query($sql); } } if (sizeof($errors)) { return $errors; } } else { $diff = 2; $sql = 'DELETE FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " WHERE forum_id = $forum_id"; $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " WHERE forum_id = $forum_id"; $db->sql_query($sql); } // Resync tree $sql = 'UPDATE ' . FORUMS_TABLE . " SET right_id = right_id - $diff WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}"; $db->sql_query($sql); $sql = 'UPDATE ' . FORUMS_TABLE . " SET left_id = left_id - $diff, right_id = right_id - $diff WHERE left_id > {$forum_data['right_id']}"; $db->sql_query($sql); // Delete forum ids from extension groups table $sql = 'SELECT group_id, allowed_forums FROM ' . EXTENSION_GROUPS_TABLE; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!$row['allowed_forums']) { continue; } $allowed_forums = unserialize(trim($row['allowed_forums'])); $allowed_forums = array_diff($allowed_forums, $forum_ids); $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' WHERE group_id = {$row['group_id']}"; $db->sql_query($sql); } $db->sql_freeresult($result); $cache->destroy('_extensions'); $log_action = implode('_', array($log_action_posts, $log_action_forums)); switch ($log_action) { case 'MOVE_POSTS_MOVE_FORUMS': add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS', $posts_to_name, $subforums_to_name, $forum_data['forum_name']); break; case 'MOVE_POSTS_FORUMS': add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', $posts_to_name, $forum_data['forum_name']); break; case 'POSTS_MOVE_FORUMS': add_log('admin', 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']); break; case '_MOVE_FORUMS': add_log('admin', 'LOG_FORUM_DEL_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']); break; case 'MOVE_POSTS_': add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS', $posts_to_name, $forum_data['forum_name']); break; case 'POSTS_FORUMS': add_log('admin', 'LOG_FORUM_DEL_POSTS_FORUMS', $forum_data['forum_name']); break; case '_FORUMS': add_log('admin', 'LOG_FORUM_DEL_FORUMS', $forum_data['forum_name']); break; case 'POSTS_': add_log('admin', 'LOG_FORUM_DEL_POSTS', $forum_data['forum_name']); break; default: add_log('admin', 'LOG_FORUM_DEL_FORUM', $forum_data['forum_name']); break; } return $errors; } /** * Delete forum content */ function delete_forum_content($forum_id) { global $db, $config, $phpbb_root_path, $phpEx; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); $db->sql_transaction('begin'); // Select then delete all attachments $sql = 'SELECT a.topic_id FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a WHERE p.forum_id = $forum_id AND a.in_message = 0 AND a.topic_id = p.topic_id"; $result = $db->sql_query($sql); $topic_ids = array(); while ($row = $db->sql_fetchrow($result)) { $topic_ids[] = $row['topic_id']; } $db->sql_freeresult($result); delete_attachments('topic', $topic_ids, false); // Delete shadow topics pointing to topics in this forum delete_topic_shadows($forum_id); // Before we remove anything we make sure we are able to adjust the post counts later. ;) $sql = 'SELECT poster_id FROM ' . POSTS_TABLE . ' WHERE forum_id = ' . $forum_id . ' AND post_postcount = 1 AND post_approved = 1'; $result = $db->sql_query($sql); $post_counts = array(); while ($row = $db->sql_fetchrow($result)) { $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; } $db->sql_freeresult($result); switch ($db->sql_layer) { case 'mysql4': case 'mysqli': // Delete everything else and thank MySQL for offering multi-table deletion $tables_ary = array( SEARCH_WORDMATCH_TABLE => 'post_id', REPORTS_TABLE => 'post_id', WARNINGS_TABLE => 'post_id', BOOKMARKS_TABLE => 'topic_id', TOPICS_WATCH_TABLE => 'topic_id', TOPICS_POSTED_TABLE => 'topic_id', POLL_OPTIONS_TABLE => 'topic_id', POLL_VOTES_TABLE => 'topic_id', ); $sql = 'DELETE ' . POSTS_TABLE; $sql_using = "\nFROM " . POSTS_TABLE; $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = $forum_id\n"; foreach ($tables_ary as $table => $field) { $sql .= ", $table "; $sql_using .= ", $table "; $sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field"; } $db->sql_query($sql . $sql_using . $sql_where); break; default: // Delete everything else and curse your DB for not offering multi-table deletion $tables_ary = array( 'post_id' => array( SEARCH_WORDMATCH_TABLE, REPORTS_TABLE, WARNINGS_TABLE, ), 'topic_id' => array( BOOKMARKS_TABLE, TOPICS_WATCH_TABLE, TOPICS_POSTED_TABLE, POLL_OPTIONS_TABLE, POLL_VOTES_TABLE, ) ); // Amount of rows we select and delete in one iteration. $batch_size = 500; foreach ($tables_ary as $field => $tables) { $start = 0; do { $sql = "SELECT $field FROM " . POSTS_TABLE . ' WHERE forum_id = ' . $forum_id; $result = $db->sql_query_limit($sql, $batch_size, $start); $ids = array(); while ($row = $db->sql_fetchrow($result)) { $ids[] = $row[$field]; } $db->sql_freeresult($result); if (sizeof($ids)) { $start += sizeof($ids); foreach ($tables as $table) { $db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids)); } } } while (sizeof($ids) == $batch_size); } unset($ids); break; } $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE); foreach ($table_ary as $table) { $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); } // Set forum ids to 0 $table_ary = array(DRAFTS_TABLE); foreach ($table_ary as $table) { $db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id"); } // Adjust users post counts if (sizeof($post_counts)) { foreach ($post_counts as $poster_id => $substract) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0 WHERE user_id = ' . $poster_id . ' AND user_posts < ' . $substract; $db->sql_query($sql); $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts - ' . $substract . ' WHERE user_id = ' . $poster_id . ' AND user_posts >= ' . $substract; $db->sql_query($sql); } } $db->sql_transaction('commit'); // Make sure the overall post/topic count is correct... $sql = 'SELECT COUNT(post_id) AS stat FROM ' . POSTS_TABLE . ' WHERE post_approved = 1'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); set_config('num_posts', (int) $row['stat'], true); $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' WHERE topic_approved = 1'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); set_config('num_topics', (int) $row['stat'], true); $sql = 'SELECT COUNT(attach_id) as stat FROM ' . ATTACHMENTS_TABLE; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); set_config('num_files', (int) $row['stat'], true); $sql = 'SELECT SUM(filesize) as stat FROM ' . ATTACHMENTS_TABLE; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); set_config('upload_dir_size', (float) $row['stat'], true); return array(); } /** * Move forum position by $steps up/down */ function move_forum_by($forum_row, $action = 'move_up', $steps = 1) { global $db; /** * Fetch all the siblings between the module's current spot * and where we want to move it to. If there are less than $steps * siblings between the current spot and the target then the * module will move as far as possible */ $sql = 'SELECT forum_id, forum_name, left_id, right_id FROM ' . FORUMS_TABLE . " WHERE parent_id = {$forum_row['parent_id']} AND " . (($action == 'move_up') ? "right_id < {$forum_row['right_id']} ORDER BY right_id DESC" : "left_id > {$forum_row['left_id']} ORDER BY left_id ASC"); $result = $db->sql_query_limit($sql, $steps); $target = array(); while ($row = $db->sql_fetchrow($result)) { $target = $row; } $db->sql_freeresult($result); if (!sizeof($target)) { // The forum is already on top or bottom return false; } /** * $left_id and $right_id define the scope of the nodes that are affected by the move. * $diff_up and $diff_down are the values to substract or add to each node's left_id * and right_id in order to move them up or down. * $move_up_left and $move_up_right define the scope of the nodes that are moving * up. Other nodes in the scope of ($left_id, $right_id) are considered to move down. */ if ($action == 'move_up') { $left_id = $target['left_id']; $right_id = $forum_row['right_id']; $diff_up = $forum_row['left_id'] - $target['left_id']; $diff_down = $forum_row['right_id'] + 1 - $forum_row['left_id']; $move_up_left = $forum_row['left_id']; $move_up_right = $forum_row['right_id']; } else { $left_id = $forum_row['left_id']; $right_id = $target['right_id']; $diff_up = $forum_row['right_id'] + 1 - $forum_row['left_id']; $diff_down = $target['right_id'] - $forum_row['right_id']; $move_up_left = $forum_row['right_id'] + 1; $move_up_right = $target['right_id']; } // Now do the dirty job $sql = 'UPDATE ' . FORUMS_TABLE . " SET left_id = left_id + CASE WHEN left_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} ELSE {$diff_down} END, right_id = right_id + CASE WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} ELSE {$diff_down} END, forum_parents = '' WHERE left_id BETWEEN {$left_id} AND {$right_id} AND right_id BETWEEN {$left_id} AND {$right_id}"; $db->sql_query($sql); return $target['forum_name']; } /** * Display progress bar for syncinc forums */ function display_progress_bar($start, $total) { global $template, $user; adm_page_header($user->lang['SYNC_IN_PROGRESS']); $template->set_filenames(array( 'body' => 'progress_bar.html') ); $template->assign_vars(array( 'L_PROGRESS' => $user->lang['SYNC_IN_PROGRESS'], 'L_PROGRESS_EXPLAIN' => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS']) ); adm_page_footer(); } /** * Display copy permission page * Not used at the moment - we will have a look at it for 3.0.7 */ function copy_permission_page($forum_data) { global $phpEx, $phpbb_admin_path, $template, $user; $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); $l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>'); $this->tpl_name = 'acp_forums_copy_perm'; $template->assign_vars(array( 'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url), 'L_ACL_LINK' => $l_acl, 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), 'S_COPY_ACTION' => $action, 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false), )); } } ?>Imagine: [ https://i.imgur.com/wwXl8It.png - Pentru incarcare in pagina (embed) Click aici ] |
Anunturi
▶ 0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users