Permalink
Browse files

Added page revomal via a link. Closed #892.

  • Loading branch information...
1 parent 8632500 commit cecbcc6983b75d0c56d97189e0c6f351d4951409 @trustmaster trustmaster committed May 26, 2012
Showing with 27 additions and 13 deletions.
  1. +15 −6 modules/page/inc/page.edit.php
  2. +11 −7 modules/page/inc/page.functions.php
  3. +1 −0 modules/page/tpl/page.tpl
View
21 modules/page/inc/page.edit.php
@@ -51,7 +51,7 @@
include $pl;
}
/* ===== */
-
+
cot_block($usr['isadmin'] || $usr['auth_write'] && $usr['id'] == $row_page['page_ownerid']);
$rpage['page_keywords'] = cot_import('rpagekeywords', 'P', 'TXT');
@@ -74,7 +74,7 @@
$rpage['page_expire'] = (int)cot_import_date('rpageexpire');
$rpage['page_expire'] = ($rpage['page_expire'] <= $rpage['page_begin']) ? 0 : $rpage['page_expire'];
$rpage['page_updated'] = $sys['now'];
-
+
$rpublish = cot_import('rpublish', 'P', 'ALP'); // For backwards compatibility
$rpage['page_state'] = ($rpublish == 'OK') ? 0 : cot_import('rpagestate', 'P', 'INT');
@@ -90,7 +90,16 @@
$rpage['page_ownerid'] = cot_import('rpageownerid', 'P', 'INT');
$rpage['page_filecount'] = cot_import('rpagefilecount', 'P', 'INT');
}
- $rpagedelete = cot_import('rpagedelete', 'P', 'BOL');
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST')
+ {
+ $rpagedelete = cot_import('rpagedelete', 'P', 'BOL');
+ }
+ else
+ {
+ $rpagedelete = cot_import('delete', 'G', 'BOL');
+ cot_check_xg();
+ }
if ($rpagedelete)
{
@@ -126,7 +135,7 @@
}
cot_redirect(cot_url('page', "c=" . $row_page['page_cat'], '', true));
}
-
+
cot_check(empty($rpage['page_cat']), 'page_catmissing', 'rpagecat');
cot_check(mb_strlen($rpage['page_title']) < 2, 'page_titletooshort', 'rpagetitle');
cot_check(!empty($rpage['page_alias']) && preg_match('`[+/?%#&]`', $rpage['page_alias']), 'page_aliascharacters', 'rpagealias');
@@ -145,7 +154,7 @@
include $pl;
}
/* ===== */
-
+
if (!cot_error_found())
{
if (!empty($rpage['page_alias']))
@@ -303,7 +312,7 @@
$exfld_title = isset($L['page_'.$exfld['field_name'].'_title']) ? $L['page_'.$exfld['field_name'].'_title'] : $exfld['field_description'];
$t->assign(array(
- 'PAGEEDIT_FORM_'.$uname => $exfld_val,
+ 'PAGEEDIT_FORM_'.$uname => $exfld_val,
'PAGEEDIT_FORM_'.$uname.'_TITLE' => $exfld_title,
'PAGEEDIT_FORM_EXTRAFLD' => $exfld_val,
'PAGEEDIT_FORM_EXTRAFLD_TITLE' => $exfld_title
View
18 modules/page/inc/page.functions.php
@@ -23,7 +23,7 @@
$cot_extrafields[$db_pages] = (!empty($cot_extrafields[$db_pages])) ? $cot_extrafields[$db_pages] : array();
-$structure['page'] = (is_array($structure['page'])) ? $structure['page'] : array();
+$structure['page'] = (is_array($structure['page'])) ? $structure['page'] : array();
/**
* Cuts the page after 'more' tag or after the first page (if multipage)
@@ -81,7 +81,7 @@ function cot_selectbox_categories($check, $name, $subcat = '', $hideprivate = tr
global $db, $db_structure, $usr, $structure, $L, $R;
$structure['page'] = (is_array($structure['page'])) ? $structure['page'] : array();
-
+
$result_array = array();
foreach ($structure['page'] as $i => $x)
{
@@ -118,7 +118,7 @@ function cot_selectbox_categories($check, $name, $subcat = '', $hideprivate = tr
function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $admin_rights = null, $pagepath_home = false, $emptytitle = '')
{
global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_pages, $usr, $sys, $cot_yesno, $structure, $db_structure;
-
+
static $extp_first = null, $extp_main = null;
static $pag_auth = array();
@@ -182,10 +182,11 @@ function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $a
$validate_url = cot_url('admin', "m=page&a=validate&id={$page_data['page_id']}&x={$sys['xk']}");
$unvalidate_url = cot_url('admin', "m=page&a=unvalidate&id={$page_data['page_id']}&x={$sys['xk']}");
$edit_url = cot_url('page', "m=edit&id={$page_data['page_id']}");
+ $delete_url = cot_url('page', "m=edit&a=update&delete=1&id={$page_data['page_id']}&x={$sys['xk']}");
$page_data['page_status'] = cot_page_status(
- $page_data['page_state'],
- $page_data['page_begin'],
+ $page_data['page_state'],
+ $page_data['page_begin'],
$page_data['page_expire']
);
@@ -241,13 +242,16 @@ function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $a
{
$validate_confirm_url = cot_confirm_url($validate_url, 'page', 'page_confirm_validate');
$unvalidate_confirm_url = cot_confirm_url($unvalidate_url, 'page', 'page_confirm_unvalidate');
+ $delete_confirm_url = cot_confirm_url($delete_url, 'page', 'page_confirm_delete');
$temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
$temp_array['ADMIN_EDIT_URL'] = $edit_url;
$temp_array['ADMIN_UNVALIDATE'] = $page_data['page_state'] == 1 ?
cot_rc_link($validate_confirm_url, $L['Validate'], 'class="confirmLink"') :
cot_rc_link($unvalidate_confirm_url, $L['Putinvalidationqueue'], 'class="confirmLink"');
$temp_array['ADMIN_UNVALIDATE_URL'] = $page_data['page_state'] == 1 ?
$validate_confirm_url : $unvalidate_confirm_url;
+ $temp_array['ADMIN_DELETE'] = cot_rc_link($delete_confirm_url, $L['Delete'], 'class="confirmLink"');
+ $temp_array['ADMIN_DELETE_URL'] = $delete_confirm_url;
}
else if ($usr['id'] == $page_data['page_ownerid'])
{
@@ -292,7 +296,7 @@ function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $a
'SHORTTITLE' => (!empty($emptytitle)) ? $emptytitle : $L['Deleted'],
);
}
-
+
$return_array = array();
foreach ($temp_array as $key => $val)
{
@@ -347,7 +351,7 @@ function cot_page_config_order()
function cot_page_status($page_state, $page_begin, $page_expire)
{
global $sys;
-
+
if ($page_state == 0)
{
if ($page_expire > 0 && $page_expire <= $sys['now'])
View
1 modules/page/tpl/page.tpl
@@ -48,6 +48,7 @@
<li><a href="{PAGE_CAT|cot_url('page','m=add&c=$this')}">{PHP.L.page_addtitle}</a></li>
<li>{PAGE_ADMIN_UNVALIDATE}</li>
<li>{PAGE_ADMIN_EDIT}</li>
+ <li>{PAGE_ADMIN_DELETE}</li>
</ul>
</div>
<!-- END: PAGE_ADMIN -->

0 comments on commit cecbcc6

Please sign in to comment.