Archived
Fix: categories were uneditable (#135)
This commit is contained in:
@@ -16,10 +16,6 @@ $data = array();
|
||||
if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
|
||||
$name = $serendipity['POST']['cat']['name'];
|
||||
$data['post_save'] = true;
|
||||
$r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category WHERE category_name = '". serendipity_db_escape_string($name)."'");
|
||||
if (is_array($r) && is_array($r[0])) {
|
||||
$data['error_name'] = true;
|
||||
} else {
|
||||
$desc = $serendipity['POST']['cat']['description'];
|
||||
if (is_array($serendipity['POST']['cat']['write_authors']) && in_array(0, $serendipity['POST']['cat']['write_authors'])) {
|
||||
$authorid = 0;
|
||||
@@ -32,19 +28,17 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
|
||||
|
||||
|
||||
if ($serendipity['GET']['adminAction'] == 'new' || $serendipity['GET']['adminAction'] == 'newSub') {
|
||||
# only continue if category-name doesn't already exists, as user have no means to distinguish between them
|
||||
$r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category WHERE category_name = '". serendipity_db_escape_string($name)."'");
|
||||
if (is_array($r) && is_array($r[0])) {
|
||||
$data['error_name'] = true;
|
||||
$data['category_name'] = $name;
|
||||
} else {
|
||||
$data['new'] = true;
|
||||
if ($parentid != 0) {
|
||||
// TODO: This doesn't seem to work as expected, serendipity_rebuildCategoryTree(); is still needed! Only activate this optimization function when it's really working :)
|
||||
// TODO: This works if only one subcategory exists. Otherwise, the first query will return an array.
|
||||
/*
|
||||
$res = serendipity_db_query("SELECT category_right FROM {$serendipity['dbPrefix']}category WHERE parentid={$parentid}");
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET category_left=category_left+2, category_right=category_right+2 WHERE category_right>{$res}");
|
||||
*/
|
||||
}
|
||||
|
||||
$catid = serendipity_addCategory($name, $desc, $authorid, $icon, $parentid);
|
||||
serendipity_ACLGrant($catid, 'category', 'read', $serendipity['POST']['cat']['read_authors']);
|
||||
serendipity_ACLGrant($catid, 'category', 'write', $serendipity['POST']['cat']['write_authors']);
|
||||
}
|
||||
} elseif ($serendipity['GET']['adminAction'] == 'edit') {
|
||||
$data['edit'] = true;
|
||||
if (!serendipity_checkPermission('adminCategoriesMaintainOthers') && !serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write')) {
|
||||
@@ -65,7 +59,7 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
serendipity_rebuildCategoryTree();
|
||||
$serendipity['GET']['adminAction'] = 'view';
|
||||
@@ -207,10 +201,6 @@ if ( $serendipity['GET']['adminAction'] == 'view' ) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_object($serendipity['smarty'])) {
|
||||
serendipity_smarty_init();
|
||||
}
|
||||
|
||||
echo serendipity_smarty_show('admin/category.inc.tpl', $data);
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{/if}
|
||||
{/if}
|
||||
{if $error_name}
|
||||
<span class="msg_error"><span class="icon-attention-circled"></span> {$CONST.CATEGORY_ALREADY_EXIST|sprintf:$cat_data.category_name|escape}</span>
|
||||
<span class="msg_error"><span class="icon-attention-circled"></span> {$CONST.CATEGORY_ALREADY_EXIST|sprintf:$category_name|escape}</span>
|
||||
{/if}
|
||||
{/if}
|
||||
{if $doDelete}
|
||||
@@ -54,7 +54,7 @@
|
||||
<div id="category_basics" class="clearfix">
|
||||
<div class="form_field">
|
||||
<label for="category_name">{$CONST.NAME}</label>
|
||||
<input id="category_name" pattern="^(?!({foreach $categories as $cat}{$cat.category_name}|{/foreach})$).*" name="serendipity[cat][name]" type="text" value="{$this_cat.category_name|default:""|escape}" title="Categoryname already exists">
|
||||
<input id="category_name" pattern="{if $new}^(?!({foreach $categories as $cat}{$cat.category_name}|{/foreach})$).*{else}^(?!({foreach $categories as $cat}{if $this_cat.category_name != $cat.category_name}{$cat.category_name}{/if}|{/foreach})$).*{/if}" name="serendipity[cat][name]" type="text" value="{$this_cat.category_name|default:""|escape}" title="Categoryname already exists">
|
||||
</div>
|
||||
|
||||
<div class="form_field">
|
||||
|
||||
Reference in New Issue
Block a user