Revert "smartified group.inc.php"

This reverts commit ff667b661772b106f52242fbee2e03e8d33ca737.
This commit is contained in:
Ian 2012-02-18 09:25:10 +01:00
parent eb55f1c04d
commit 1fc36abe56
2 changed files with 203 additions and 276 deletions

View File

@ -10,14 +10,11 @@ if (!serendipity_checkPermission('adminUsersGroups')) {
return;
}
$data = array();
/* Delete a group */
if (isset($_POST['DELETE_YES']) && serendipity_checkFormToken()) {
$group = serendipity_fetchGroup($serendipity['POST']['group']);
serendipity_deleteGroup($serendipity['POST']['group']);
$data['delete_yes'] = true;
$data['group_id'] = $serendipity['POST']['group'];
$data['group'] = $group;
printf('<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DELETED_GROUP . '</div>', htmlspecialchars($serendipity['POST']['group']), htmlspecialchars($group['name']));
}
/* Save new group */
@ -25,9 +22,7 @@ if (isset($_POST['SAVE_NEW']) && serendipity_checkFormToken()) {
$serendipity['POST']['group'] = serendipity_addGroup($serendipity['POST']['name']);
$perms = serendipity_getAllPermissionNames();
serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST'], false, $serendipity['POST']['forbidden_plugins'], $serendipity['POST']['forbidden_hooks']);
$data['save_new'] = true;
$data['group_id'] = $serendipity['POST']['group'];
$data['group'] = $group;
printf('<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . CREATED_GROUP . '</div>', '#' . htmlspecialchars($serendipity['POST']['group']) . ', ' . htmlspecialchars($serendipity['POST']['name']));
}
@ -35,109 +30,233 @@ if (isset($_POST['SAVE_NEW']) && serendipity_checkFormToken()) {
if (isset($_POST['SAVE_EDIT']) && serendipity_checkFormToken()) {
$perms = serendipity_getAllPermissionNames();
serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST'], false, $serendipity['POST']['forbidden_plugins'], $serendipity['POST']['forbidden_hooks']);
$data['save_edit'] = true;
$data['name'] = $serendipity['POST']['name'];
printf('<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . MODIFIED_GROUP . '</div>', htmlspecialchars($serendipity['POST']['name']));
}
if ( $serendipity['GET']['adminAction'] != 'delete' ) {
$data['delete'] = false;
?>
<table width="100%">
<tr>
<td><strong><?php echo GROUP; ?></strong></td>
<td width="200">&nbsp;</td>
</tr>
<tr>
<td colspan="3">
<?php
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
$groups = serendipity_getAllGroups();
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
$groups = serendipity_getAllGroups($serendipity['authorid']);
} else {
$groups = array();
}
$i = 0;
foreach($groups as $group) {
?>
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo ($i++ % 2) ? 'even' : 'uneven' ?>">
<table width="100%">
<tr>
<td><?php echo htmlspecialchars($group['name']); ?></td>
<td width="200" align="right"> <a href="?serendipity[adminModule]=groups&amp;serendipity[adminAction]=edit&amp;serendipity[group]=<?php echo $group['id'] ?>" title="<?php echo EDIT . " " . htmlspecialchars($group['name']); ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png'); ?>" alt="<?php echo EDIT . " " . htmlspecialchars($group['name']); ?>" /><?php echo EDIT ?></a>
<a href="?<?php echo serendipity_setFormToken('url'); ?>&amp;serendipity[adminModule]=groups&amp;serendipity[adminAction]=delete&amp;serendipity[group]=<?php echo $group['id'] ?>" title="<?php echo DELETE . " " . htmlspecialchars($group['name']); ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png'); ?>" alt="<?php echo DELETE . " " . htmlspecialchars($group['name']); ?>" /><?php echo DELETE ?></a></td>
</tr>
</table>
</div>
<?php
}
?>
</td>
</tr>
<?php if ( !isset($_POST['NEW']) ) { ?>
<tr>
<td colspan="3" align="right">
<form action="?serendipity[adminModule]=groups" method="post">
<input type="submit" name="NEW" value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton input_button" />
</form>
</td>
</tr>
<?php } ?>
</table>
if (serendipity_checkPermission('adminUsersMaintainOthers')) {
$groups = serendipity_getAllGroups();
} elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
$groups = serendipity_getAllGroups($serendipity['authorid']);
} else {
$groups = array();
}
$data['groups'] = $groups;
if ( !isset($_POST['NEW']) ) {
$data['new'] = $true;
}
$data['deleteFormToken'] = serendipity_setFormToken('url');
<?php
}
if ($serendipity['GET']['adminAction'] == 'edit' || isset($_POST['NEW'])) {
if (isset($_POST['NEW'])) {
$data['new'] = true;
} else {
$data['edit'] = true;
}
$data['formToken'] = serendipity_setFormToken();
if ($serendipity['GET']['adminAction'] == 'edit') {
$group = serendipity_fetchGroup($serendipity['GET']['group']);
$from = &$group;
} else {
$from = array();
}
$data['from'] = $from;
?>
<br />
<br />
<hr noshade="noshade">
<form action="?serendipity[adminModule]=groups" method="post">
<?php echo serendipity_setFormToken(); ?>
<div>
<h3>
<?php
if ($serendipity['GET']['adminAction'] == 'edit') {
$group = serendipity_fetchGroup($serendipity['GET']['group']);
echo EDIT;
$from = &$group;
echo '<input type="hidden" name="serendipity[group]" value="' . $from['id'] . '" />';
} else {
echo CREATE;
$from = array();
}
?>
</h3>
<table>
<tr>
<td><?php echo NAME; ?></td>
<td><input class="input_textbox" type="text" name="serendipity[name]" value="<?php echo htmlspecialchars($from['name']); ?>" /></td>
</tr>
<tr>
<td valign="top"><?php echo USERCONF_GROUPS; ?></td>
<td><select name="serendipity[members][]" multiple="multiple" size="5">
<?php
$allusers = serendipity_fetchUsers();
$users = serendipity_getGroupUsers($from['id']);
$allusers = serendipity_fetchUsers();
$users = serendipity_getGroupUsers($from['id']);
$selected = array();
foreach((array)$users AS $user) {
$selected[$user['id']] = true;
}
$data['selected'] = $selected;
$data['allusers'] = $allusers;
$selected = array();
foreach((array)$users AS $user) {
$selected[$user['id']] = true;
}
foreach($allusers AS $user) {
echo '<option value="' . (int)$user['authorid'] . '" ' . (isset($selected[$user['authorid']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<?php
$perms = serendipity_getAllPermissionNames();
ksort($perms);
$data['perms'] = $perms;
foreach($perms AS $perm => $userlevels) {
if (defined('PERMISSION_' . strtoupper($perm))) {
$data['perms'][$perm]['permission_name'] = constant('PERMISSION_' . strtoupper($perm));
} else {
$data['perms'][$perm]['permission_name'] = $perm;
if (substr($perm, 0, 2) == 'f_') {
continue;
}
if (!serendipity_checkPermission($perm) && $perm != 'hiddenGroup') {
$data['perms'][$perm]['permission'] = false;
if (isset($from[$perm]) && $from[$perm] === 'true') {
$selected = 'checked="checked"';
} else {
$data['perms'][$perm]['permission'] = true;
$selected = '';
}
if (!isset($section)) {
$section = $perm;
}
if ($section != $perm && substr($perm, 0, strlen($section)) == $section) {
$indent = '&nbsp;&nbsp;';
$indentB = '';
} elseif ($section != $perm) {
$indent = '<br />';
$indentB = '<br />';
$section = $perm;
}
if (defined('PERMISSION_' . strtoupper($perm))) {
$permname = constant('PERMISSION_' . strtoupper($perm));
} else {
$permname = $perm;
}
if (!serendipity_checkPermission($perm) && $perm != 'hiddenGroup') {
echo "<tr>\n";
echo "<td>$indent" . htmlspecialchars($permname) . "</td>\n";
echo '<td>' . $indentB . ' ' . (!empty($selected) ? YES : NO) . '</td>' . "\n";
echo "</tr>\n";
} else {
echo "<tr>\n";
echo "<td>$indent<label for=\"" . htmlspecialchars($perm) . "\">" . htmlspecialchars($permname) . "</label></td>\n";
echo '<td>' . $indentB . '<input class="input_checkbox" id="' . htmlspecialchars($perm) . '" type="checkbox" name="serendipity[' . htmlspecialchars($perm) . ']" value="true" ' . $selected . ' /></td>' . "\n";
echo "</tr>\n";
}
}
if ($serendipity['enablePluginACL']) {
$data['enablePluginACL'] = true;
$allplugins =& serendipity_plugin_api::get_event_plugins();
$allhooks = array();
$data['allplugins'] = $allplugins;
foreach($allplugins AS $plugid => $currentplugin) {
foreach($currentplugin['b']->properties['event_hooks'] AS $hook => $set) {
$allhooks[$hook] = true;
}
$data['allplugins'][$plugid]['has_permission'] = serendipity_hasPluginPermissions($plugid, $from['id']);
}
ksort($allhooks);
$data['allhooks'] = $allhooks;
foreach($allhooks AS $hook => $set) {
$data['allhooks'][$hook]['has_permission'] = serendipity_hasPluginPermissions($hook, $from['id']);
}
?>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td valign="top"><?php echo PERMISSION_FORBIDDEN_PLUGINS; ?></td>
<td>
<select name="serendipity[forbidden_plugins][]" multiple="multiple" size="5">
<?php
foreach($allplugins AS $plugid => $currentplugin) {
foreach($currentplugin['b']->properties['event_hooks'] AS $hook => $set) {
$allhooks[$hook] = true;
}
echo '<option value="' . urlencode($plugid) . '" ' . (serendipity_hasPluginPermissions($plugid, $from['id']) ? '' : 'selected="selected"') . '>' . htmlspecialchars($currentplugin['b']->properties['name']) . '</option>' . "\n";
}
ksort($allhooks);
?>
</select>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td valign="top"><?php echo PERMISSION_FORBIDDEN_HOOKS; ?></td>
<td>
<select name="serendipity[forbidden_hooks][]" multiple="multiple" size="5">
<?php
foreach($allhooks AS $hook => $set) {
echo '<option value="' . urlencode($hook) . '" ' . (serendipity_hasPluginPermissions($hook, $from['id']) ? '' : 'selected="selected"') . '>' . htmlspecialchars($hook) . '</option>' . "\n";
}
?>
</select>
</td>
</tr>
<?php
} else {
?>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><?php echo PERMISSION_FORBIDDEN_ENABLE_DESC; ?></td>
</tr>
<?php
}
?>
</table>
<?php
if ($serendipity['GET']['adminAction'] == 'edit') { ?>
<input type="submit" name="SAVE_EDIT" value="<?php echo SAVE; ?>" class="serendipityPrettyButton input_button" />
<?php echo ' - ' . WORD_OR . ' - ' ?>
<input type="submit" name="SAVE_NEW" value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton input_button" />
<?php } else { ?>
<input type="submit" name="SAVE_NEW" value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton input_button" />
<?php } ?>
</div>
</form>
<?php
} elseif ($serendipity['GET']['adminAction'] == 'delete') {
$data['delete'] = $true;
$group = serendipity_fetchGroup($serendipity['GET']['group']);
$data['group_id'] = $serendipity['GET']['group'];
$data['group'] = $group;
$data['formToken'] = serendipity_setFormToken();
?>
<form action="?serendipity[adminModule]=groups" method="post">
<div>
<?php printf(DELETE_GROUP, (int)$serendipity['GET']['group'], htmlspecialchars($group['name'])); ?>
<br /><br />
<?php echo serendipity_setFormToken(); ?>
<input type="hidden" name="serendipity[group]" value="<?php echo htmlspecialchars($serendipity['GET']['group']); ?>" />
<input type="submit" name="DELETE_YES" value="<?php echo DUMP_IT; ?>" class="serendipityPrettyButton input_button" />
<input type="submit" name="NO" value="<?php echo NOT_REALLY; ?>" class="serendipityPrettyButton input_button" />
</div>
</form>
<?php
}
$serendipity['smarty']->assign($data);
$tfile = dirname(__FILE__) . "/groups.inc.tpl";
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
$content = $serendipity['smarty']->fetch('file:'. $tfile);
$serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
echo $content;
/* vim: set sts=4 ts=4 expandtab : */
?>

View File

@ -1,192 +0,0 @@
{if $delete_yes}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{$CONST.DELETED_GROUP|sprintf:"{$group_id|escape:"html"}":"{$group.name|escape:"html"}"}
</div>
{/if}
{if $save_new}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{$CONST.CREATED_GROUP|sprintf:"{$group_id|escape:"html"}":"{$group.name|escape:"html"}"}
</div>
{/if}
{if $save_edit}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{$CONST.MODIFIED_GROUP|sprintf:"{$name|escape:"html"}"}
</div>
{/if}
{if $delete == false}
<table width="100%">
<tr>
<td><strong>{$CONST.GROUP}</strong></td>
<td width="200">&nbsp;</td>
</tr>
<tr>
<td colspan="3">
{foreach $groups as $group}
<div class="serendipity_admin_list_item serendipity_admin_list_item_{if $group@iteration is even} even {else} uneven {/if}">
<table width="100%">
<tr>
<td>{$group.name|escape:"html"}</td>
<td width="200" align="right">
<a href="?serendipity[adminModule]=groups&amp;serendipity[adminAction]=edit&amp;serendipity[group]={$group.id}" title="{$CONST.EDIT} {$group.name|escape:"html"}" class="serendipityIconLink">
<img src="{serendipity_getFile file="admin/img/edit.png"}" alt="{$CONST.EDIT} $group.name|escape:"html"}" />
{$CONST.EDIT}
</a>
<a href="?{$deleteFormToken}&amp;serendipity[adminModule]=groups&amp;serendipity[adminAction]=delete&amp;serendipity[group]={$group.id}" title="{$CONST.DELETE} {$group.name|escape:"html"}" class="serendipityIconLink">
<img src="{serendipity_getFile file="admin/img/delete.png"}" alt="{$CONST.DELETE} {$group.name|escape:"html"}" />
{$CONST.DELETE}
</a>
</td>
</tr>
</table>
</div>
{/foreach}
</td>
</tr>
{if ! $new}
<tr>
<td colspan="3" align="right">
<form action="?serendipity[adminModule]=groups" method="post">
<input type="submit" name="NEW" value="{$CONST.CREATE_NEW_GROUP}" class="serendipityPrettyButton input_button" />
</form>
</td>
</tr>
{/if}
</table>
{/if}
{if $edit || $new}
<br />
<br />
<hr noshade="noshade">
<form action="?serendipity[adminModule]=groups" method="post">
{$formToken}
<div>
<h3>
{if $edit}
{$CONST.EDIT}
<input type="hidden" name="serendipity[group]" value="{$from.id}" />
{else}
{$CONST.CREATE}
{/if}
</h3>
<table>
<tr>
<td>{$CONST.NAME}</td>
<td><input class="input_textbox" type="text" name="serendipity[name]" value="{$from.name|escape:"html"}" /></td>
</tr>
<tr>
<td valign="top">{$CONST.USERCONF_GROUPS}</td>
<td>
<select name="serendipity[members][]" multiple="multiple" size="5">
{foreach $allusers as $user}
<option value="{$user.authorid}" {if isset($selected.{$user.authorid})} selected="selected"{/if} >{$user.realname|escape:"html"}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
{foreach $perms as $perm}
{if {{$perm@key}|truncate:"2":""} == "f_"}
{continue}
{/if}
{if ! isset($section)}
{$section=$perm@key}
{/if}
{if $section != {$perm@key} && {{$perm@key}|truncate:"{$section|count_characters}":""} == $section}
{$indent="&nbsp;&nbsp;"}
{$indentB=""}
{else}
{if $section != {$perm@key}}
{$indent="<br />"}
{$indentB="<br />"}
{$section="{$perm@key}"}
{/if}
{/if}
{if $perm.permission == false}
<tr>
<td>{$indent} {$perm.permission_name|escape:"html"}</td>
<td>{$indentB} {if isset($from.{$perm@key}) && $from.{$perm@key} == "true"} YES {else} NO {/if} </td>
</tr>
{else}
<tr>
<td>{$indent} <label for="{{$perm@key}|escape:"html"}">{$perm.permission_name|escape:"html"}</label></td>
<td>{$indentB} <input class="input_checkbox" id="{{$perm@key}|escape:"html"}" type="checkbox" name="serendipity[{{$perm@key}|escape:"html"}]" value="true" {if isset({$from.{$perm@key}}) && {$from.{$perm@key}} == "true"} checked="checked" {/if} /></td>
</tr>
{/if}
{/foreach}
{if $enablePluginACL}
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td valign="top">{$CONST.PERMISSION_FORBIDDEN_PLUGINS}</td>
<td>
<select name="serendipity[forbidden_plugins][]" multiple="multiple" size="5">
{foreach $allplugins as $plugin}
<option value="{{$plugin@key}|escape:"url"} {if $plugin.has_permission == false} selected="selected" {/if} >{$plugin.b->properties.name|escape:"html"}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td valign="top">{$CONST.PERMISSION_FORBIDDEN_HOOKS}</td>
<td>
<select name="serendipity[forbidden_hooks][]" multiple="multiple" size="5">
{foreach $allhooks as $hook}
<option value="{{$hook@key}|escape:"url"}" {$hook.has_permission == false} 'selected="selected"}>{{$hook@key}|escape:"html"}</option>
{/foreach}
</select>
</td>
</tr>
{else}
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">{$CONST.PERMISSION_FORBIDDEN_ENABLE_DESC}</td>
</tr>
{/if}
</table>
{if $edit}
<input type="submit" name="SAVE_EDIT" value="{$CONST.SAVE}" class="serendipityPrettyButton input_button" />
{$CONST.WORD_OR} -
<input type="submit" name="SAVE_NEW" value="{$CONST.CREATE_NEW_GROUP}" class="serendipityPrettyButton input_button" />
{else}
<input type="submit" name="SAVE_NEW" value="{$CONST.CREATE_NEW_GROUP}" class="serendipityPrettyButton input_button" />
{/if}
</div>
</form>
{else}
{if $delete}
<form action="?serendipity[adminModule]=groups" method="post">
<div>
{$CONST.DELETE_GROUP|sprintf:"{$group_id}":"{$group.name|escape:"html"}"}
<br /><br />
{$formToken}
<input type="hidden" name="serendipity[group]" value="{$group_id|escape:"html"}" />
<input type="submit" name="DELETE_YES" value="{$CONST.DUMP_IT}" class="serendipityPrettyButton input_button" />
<input type="submit" name="NO" value="{$CONST.NOT_REALLY}" class="serendipityPrettyButton input_button" />
</div>
</form>
{/if}
{/if}