Merge pull request #2720 from PayBas/ticket/12838

[ticket/12838] Add ACP events to acp_ranks

* PayBas/ticket/12838:
  [ticket/12838] Simplify normal special rank array creation
  [ticket/12838] Update RC2 to RC3
  [ticket/12838] Update events.md to RC3
  [ticket/12838] Allow for extra columns in cache obtain_ranks()
  [ticket/12838] Add raw row-data to acp_ranks core event
  [ticket/12838] Simplify special rank template conditional
  [ticket/12838] Add core events to acp_ranks.php
  [ticket/12838] Update events.md
  [ticket/12838] Add _before versions
  [ticket/12838] Add template events to acp_ranks.html
This commit is contained in:
Joas Schilling 2014-08-07 16:13:35 +02:00
commit 0194c261c3
4 changed files with 98 additions and 15 deletions

View file

@ -24,6 +24,9 @@
<fieldset> <fieldset>
<legend>{L_ACP_RANKS}</legend> <legend>{L_ACP_RANKS}</legend>
<!-- EVENT acp_ranks_edit_before -->
<dl> <dl>
<dt><label for="title">{L_RANK_TITLE}{L_COLON}</label></dt> <dt><label for="title">{L_RANK_TITLE}{L_COLON}</label></dt>
<dd><input name="title" type="text" id="title" value="{RANK_TITLE}" maxlength="255" /></dd> <dd><input name="title" type="text" id="title" value="{RANK_TITLE}" maxlength="255" /></dd>
@ -38,13 +41,15 @@
<dd><label><input onclick="phpbb.toggleDisplay('posts', -1)" type="radio" class="radio" name="special_rank" value="1" id="special_rank"<!-- IF S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> /> {L_YES}</label> <dd><label><input onclick="phpbb.toggleDisplay('posts', -1)" type="radio" class="radio" name="special_rank" value="1" id="special_rank"<!-- IF S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input onclick="phpbb.toggleDisplay('posts', 1)" type="radio" class="radio" name="special_rank" value="0"<!-- IF not S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> <label><input onclick="phpbb.toggleDisplay('posts', 1)" type="radio" class="radio" name="special_rank" value="0"<!-- IF not S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
</dl> </dl>
<!-- IF S_SPECIAL_RANK --><div id="posts" style="display: none;"><!-- ELSE --><div id="posts"><!-- ENDIF --> <div id="posts"<!-- IF S_SPECIAL_RANK --> style="display: none;"<!-- ENDIF -->>
<dl> <dl>
<dt><label for="min_posts">{L_RANK_MINIMUM}{L_COLON}</label></dt> <dt><label for="min_posts">{L_RANK_MINIMUM}{L_COLON}</label></dt>
<dd><input name="min_posts" type="number" id="min_posts" maxlength="10" value="{MIN_POSTS}" /></dd> <dd><input name="min_posts" type="number" id="min_posts" maxlength="10" value="{MIN_POSTS}" /></dd>
</dl> </dl>
</div> </div>
<!-- EVENT acp_ranks_edit_after -->
<p class="submit-buttons"> <p class="submit-buttons">
<input type="hidden" name="action" value="save" /> <input type="hidden" name="action" value="save" />
@ -68,18 +73,22 @@
<table class="table1 zebra-table"> <table class="table1 zebra-table">
<thead> <thead>
<tr> <tr>
<!-- EVENT acp_ranks_list_header_before -->
<th>{L_RANK_IMAGE}</th> <th>{L_RANK_IMAGE}</th>
<th>{L_RANK_TITLE}</th> <th>{L_RANK_TITLE}</th>
<th>{L_RANK_MINIMUM}</th> <th>{L_RANK_MINIMUM}</th>
<!-- EVENT acp_ranks_list_header_after -->
<th>{L_ACTION}</th> <th>{L_ACTION}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- BEGIN ranks --> <!-- BEGIN ranks -->
<tr> <tr>
<!-- EVENT acp_ranks_list_column_before -->
<td style="text-align: center;"><!-- IF ranks.S_RANK_IMAGE --><img src="{ranks.RANK_IMAGE}" alt="{ranks.RANK_TITLE}" title="{ranks.RANK_TITLE}" /><!-- ELSE -->&nbsp; - &nbsp;<!-- ENDIF --></td> <td style="text-align: center;"><!-- IF ranks.S_RANK_IMAGE --><img src="{ranks.RANK_IMAGE}" alt="{ranks.RANK_TITLE}" title="{ranks.RANK_TITLE}" /><!-- ELSE -->&nbsp; - &nbsp;<!-- ENDIF --></td>
<td style="text-align: center;">{ranks.RANK_TITLE}</td> <td style="text-align: center;">{ranks.RANK_TITLE}</td>
<td style="text-align: center;"><!-- IF ranks.S_SPECIAL_RANK -->&nbsp; - &nbsp;<!-- ELSE -->{ranks.MIN_POSTS}<!-- ENDIF --></td> <td style="text-align: center;"><!-- IF ranks.S_SPECIAL_RANK -->&nbsp; - &nbsp;<!-- ELSE -->{ranks.MIN_POSTS}<!-- ENDIF --></td>
<!-- EVENT acp_ranks_list_column_after -->
<td style="text-align: center;"><a href="{ranks.U_EDIT}">{ICON_EDIT}</a> <a href="{ranks.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a></td> <td style="text-align: center;"><a href="{ranks.U_EDIT}">{ICON_EDIT}</a> <a href="{ranks.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a></td>
</tr> </tr>
<!-- END ranks --> <!-- END ranks -->

View file

@ -85,6 +85,50 @@ acp_posting_buttons_before
* Since: 3.1.0-b4 * Since: 3.1.0-b4
* Purpose: Add content before BBCode posting buttons in the ACP * Purpose: Add content before BBCode posting buttons in the ACP
acp_ranks_edit_after
===
* Locations:
+ adm/style/acp_ranks.html
* Since: 3.1.0-RC3
* Purpose: Add content after the rank details when editing a rank in the ACP
acp_ranks_edit_before
===
* Locations:
+ adm/style/acp_ranks.html
* Since: 3.1.0-RC3
* Purpose: Add content before the rank details when editing a rank in the ACP
acp_ranks_list_column_after
===
* Locations:
+ adm/style/acp_ranks.html
* Since: 3.1.0-RC3
* Purpose: Add content before the first column in the ranks list in the ACP
acp_ranks_list_column_before
===
* Locations:
+ adm/style/acp_ranks.html
* Since: 3.1.0-RC3
* Purpose: Add content after the last column (but before the action column)
in the ranks list in the ACP
acp_ranks_list_header_after
===
* Locations:
+ adm/style/acp_ranks.html
* Since: 3.1.0-RC3
* Purpose: Add content before the first header-column in the ranks list in the ACP
acp_ranks_list_header_before
===
* Locations:
+ adm/style/acp_ranks.html
* Since: 3.1.0-RC3
* Purpose: Add content after the last header-column (but before the action column)
in the ranks list in the ACP
acp_simple_footer_after acp_simple_footer_after
=== ===
* Location: adm/style/simple_footer.html * Location: adm/style/simple_footer.html

View file

@ -25,7 +25,7 @@ class acp_ranks
function main($id, $mode) function main($id, $mode)
{ {
global $db, $user, $auth, $template, $cache, $request; global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/posting'); $user->add_lang('acp/posting');
@ -73,6 +73,17 @@ class acp_ranks
'rank_image' => htmlspecialchars_decode($rank_image) 'rank_image' => htmlspecialchars_decode($rank_image)
); );
/**
* Modify the SQL array when saving a rank
*
* @event core.acp_ranks_save_modify_sql_ary
* @var int rank_id The ID of the rank (if available)
* @var array sql_ary Array with the rank's data
* @since 3.1.0-RC3
*/
$vars = array('rank_id', 'sql_ary');
extract($phpbb_dispatcher->trigger_event('core.acp_ranks_save_modify_sql_ary', compact($vars)));
if ($rank_id) if ($rank_id)
{ {
$sql = 'UPDATE ' . RANKS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE rank_id = $rank_id"; $sql = 'UPDATE ' . RANKS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE rank_id = $rank_id";
@ -202,7 +213,7 @@ class acp_ranks
$filename_list = '<option value=""' . (($edit_img == '') ? ' selected="selected"' : '') . '>----------</option>' . $filename_list; $filename_list = '<option value=""' . (($edit_img == '') ? ' selected="selected"' : '') . '>----------</option>' . $filename_list;
unset($existing_imgs, $imglist); unset($existing_imgs, $imglist);
$template->assign_vars(array( $tpl_ary = array(
'S_EDIT' => true, 'S_EDIT' => true,
'U_BACK' => $this->u_action, 'U_BACK' => $this->u_action,
'RANKS_PATH' => $phpbb_root_path . $config['ranks_path'], 'RANKS_PATH' => $phpbb_root_path . $config['ranks_path'],
@ -212,9 +223,21 @@ class acp_ranks
'S_FILENAME_LIST' => $filename_list, 'S_FILENAME_LIST' => $filename_list,
'RANK_IMAGE' => ($edit_img) ? $phpbb_root_path . $config['ranks_path'] . '/' . $edit_img : htmlspecialchars($phpbb_admin_path) . 'images/spacer.gif', 'RANK_IMAGE' => ($edit_img) ? $phpbb_root_path . $config['ranks_path'] . '/' . $edit_img : htmlspecialchars($phpbb_admin_path) . 'images/spacer.gif',
'S_SPECIAL_RANK' => (isset($ranks['rank_special']) && $ranks['rank_special']) ? true : false, 'S_SPECIAL_RANK' => (isset($ranks['rank_special']) && $ranks['rank_special']) ? true : false,
'MIN_POSTS' => (isset($ranks['rank_min']) && !$ranks['rank_special']) ? $ranks['rank_min'] : 0) 'MIN_POSTS' => (isset($ranks['rank_min']) && !$ranks['rank_special']) ? $ranks['rank_min'] : 0,
); );
/**
* Modify the template output array for editing/adding ranks
*
* @event core.acp_ranks_edit_modify_tpl_ary
* @var array ranks Array with the rank's data
* @var array tpl_ary Array with the rank's template data
* @since 3.1.0-RC3
*/
$vars = array('ranks', 'tpl_ary');
extract($phpbb_dispatcher->trigger_event('core.acp_ranks_edit_modify_tpl_ary', compact($vars)));
$template->assign_vars($tpl_ary);
return; return;
break; break;
@ -231,7 +254,7 @@ class acp_ranks
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$template->assign_block_vars('ranks', array( $rank_row = array(
'S_RANK_IMAGE' => ($row['rank_image']) ? true : false, 'S_RANK_IMAGE' => ($row['rank_image']) ? true : false,
'S_SPECIAL_RANK' => ($row['rank_special']) ? true : false, 'S_SPECIAL_RANK' => ($row['rank_special']) ? true : false,
@ -240,8 +263,21 @@ class acp_ranks
'MIN_POSTS' => $row['rank_min'], 'MIN_POSTS' => $row['rank_min'],
'U_EDIT' => $this->u_action . '&amp;action=edit&amp;id=' . $row['rank_id'], 'U_EDIT' => $this->u_action . '&amp;action=edit&amp;id=' . $row['rank_id'],
'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row['rank_id']) 'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row['rank_id'],
); );
/**
* Modify the template output array for each listed rank
*
* @event core.acp_ranks_list_modify_rank_row
* @var array row Array with the rank's data
* @var array rank_row Array with the rank's template data
* @since 3.1.0-RC3
*/
$vars = array('row', 'rank_row');
extract($phpbb_dispatcher->trigger_event('core.acp_ranks_list_modify_rank_row', compact($vars)));
$template->assign_block_vars('ranks', $rank_row);
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);

View file

@ -168,18 +168,12 @@ class service
{ {
if ($row['rank_special']) if ($row['rank_special'])
{ {
$ranks['special'][$row['rank_id']] = array( unset($row['rank_min']);
'rank_title' => $row['rank_title'], $ranks['special'][$row['rank_id']] = $row;
'rank_image' => $row['rank_image']
);
} }
else else
{ {
$ranks['normal'][] = array( $ranks['normal'][$row['rank_id']] = $row;
'rank_title' => $row['rank_title'],
'rank_min' => $row['rank_min'],
'rank_image' => $row['rank_image']
);
} }
} }
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);