Changeset 9264


Ignore:
Timestamp:
02/17/11 17:50:04 (9 years ago)
Author:
patdenice
Message:

Remove useless file.

Location:
extensions/AdditionalPages/admin
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/AdditionalPages/admin/add_page.inc.php

    r9261 r9264  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 
    44 
    5 $edited_page = array(); 
    6 $edited_page['id'] = 0; 
    7 $edited_page['homepage'] = false; 
    8 $page_title = l10n('ap_create'); 
     5if (!isset($edited_page)) 
     6{ 
     7  $edited_page = array(); 
     8  $edited_page['id'] = 0; 
     9  $edited_page['homepage'] = false; 
     10  $page_title = l10n('ap_create'); 
     11} 
    912 
    10 include(AP_PATH.'admin/page_form.inc.php'); 
     13// Enregistrement 
     14if (isset($_POST['save'])) 
     15{ 
     16  if (empty($_POST['title'])) 
     17  { 
     18    array_push($page['errors'], l10n('ap_no_name')); 
     19  } 
     20  if (!empty($_POST['permalink'])) 
     21  { 
     22    $permalink = $_POST['permalink']; 
     23    $sanitized_permalink = preg_replace( '#[^a-zA-Z0-9_/-]#', '' ,$permalink); 
     24    $sanitized_permalink = trim($sanitized_permalink, '/'); 
     25    $sanitized_permalink = str_replace('//', '/', $sanitized_permalink); 
     26    if ( $sanitized_permalink != $permalink or preg_match( '#^(\d)+(-.*)?$#', $permalink) ) 
     27    { 
     28      array_push($page['errors'], l10n('The permalink name must be composed of a-z, A-Z, 0-9, "-", "_" or "/". It must not be numeric or start with number followed by "-"')); 
     29    } 
     30    $query =' 
     31SELECT id FROM '.ADD_PAGES_TABLE.' 
     32WHERE permalink = "'.$permalink.'" 
     33  AND id <> '.$edited_page['id'].' 
     34;'; 
     35    $ids = array_from_query($query, 'id'); 
     36    if (!empty($ids)) 
     37    { 
     38      array_push($page['errors'], sprintf(l10n('Permalink %s is already used by additional page %s'), $permalink, $ids[0])); 
     39    } 
     40    $permalink = '"'.$permalink.'"'; 
     41  } 
     42  else 
     43  { 
     44    $permalink = 'NULL'; 
     45  } 
     46 
     47  $language = $_POST['lang'] != 'ALL' ? '"'.$_POST['lang'].'"' : 'NULL'; 
     48  $group_access = !empty($_POST['groups']) ? '"'.implode(',', $_POST['groups']).'"' : 'NULL'; 
     49  $user_access = !empty($_POST['users']) ? '"'.implode(',', $_POST['users']).'"' : 'NULL'; 
     50 
     51  if (empty($page['errors'])) 
     52  { 
     53    if ($page['tab'] == 'edit_page') 
     54    { 
     55      $query = ' 
     56UPDATE '.ADD_PAGES_TABLE.' 
     57SET lang = '.$language.', 
     58  title = "'.$_POST['title'].'", 
     59  content = "'.$_POST['ap_content'].'", 
     60  users = '.$user_access.', 
     61  groups = '.$group_access.', 
     62  permalink = '.$permalink.' 
     63WHERE id = '.$edited_page['id'] .' 
     64;'; 
     65      pwg_query($query); 
     66    } 
     67    else 
     68    { 
     69      $query = 'SELECT MAX(ABS(pos)) AS pos FROM ' . ADD_PAGES_TABLE . ';'; 
     70      list($position) = array_from_query($query, 'pos'); 
     71       
     72      $query = ' 
     73INSERT INTO ' . ADD_PAGES_TABLE . ' ( pos , lang , title , content , users , groups , permalink) 
     74VALUES ('.($position+1).' , '.$language.' , "'.$_POST['title'].'" , "'.$_POST['ap_content'].'" , '.$user_access.' , '.$group_access.' , '.$permalink.');'; 
     75      pwg_query($query); 
     76      $edited_page['id'] = mysql_insert_id(); 
     77    } 
     78 
     79    // Homepage 
     80    if (isset($_POST['homepage']) xor $conf['additional_pages']['homepage'] == $edited_page['id']) 
     81    { 
     82      $conf['additional_pages']['homepage'] = isset($_POST['homepage']) ? $edited_page['id'] : null; 
     83      pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.addslashes(serialize($conf['additional_pages'])).'" WHERE param = "additional_pages";'); 
     84    } 
     85 
     86    // Enregistrement du fichier de sauvegarde 
     87    mkgetdir($conf['local_data_dir'], MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); 
     88    mkgetdir($conf['local_data_dir'].'/additional_pages_backup', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); 
     89    $sav_file = @fopen($conf['local_data_dir'].'/additional_pages_backup/' . $edited_page['id'] . '.txt', "w"); 
     90    @fwrite($sav_file, "Title: ".$_POST['title']." 
     91Permalink: ".$_POST['permalink']." 
     92Language: ".$_POST['lang']." 
     93 
     94" . $_POST['ap_content']); 
     95    @fclose($sav_file); 
     96 
     97    if (isset($_GET['redirect'])) 
     98    { 
     99      redirect(make_index_url() . '/page/' . $edited_page['id']); 
     100    } 
     101    redirect($my_base_url.'&page_saved='); 
     102  } 
     103 
     104  $edited_page['title'] = stripslashes($_POST['title']); 
     105  $edited_page['permalink'] = $_POST['permalink']; 
     106  $edited_page['content'] = stripslashes($_POST['ap_content']); 
     107  $edited_page['groups'] = !empty($_POST['groups']) ? trim($group_access, '"') : ''; 
     108  $edited_page['users'] = !empty($_POST['users']) ? trim($user_access, '"') :  ''; 
     109  $edited_page['homepage'] = isset($_POST['homepage']); 
     110} 
     111 
     112// Selection des langues 
     113$options['ALL'] = l10n('ap_all_lang'); 
     114$selected = 'ALL'; 
     115foreach (get_languages() as $language_code => $language_name) 
     116{ 
     117  $options[$language_code] = $language_name; 
     118  if (isset($edited_page['lang']) and $edited_page['lang'] == $language_code) 
     119  { 
     120    $selected = $language_code; 
     121  } 
     122} 
     123$template->assign('lang', array( 
     124  'OPTIONS' => $options, 
     125  'SELECTED' => $selected)); 
     126 
     127// Selection des groupes 
     128if ($conf['additional_pages']['group_perm']) 
     129{ 
     130        include_once(AP_PATH . 'admin/functions_groups.php'); 
     131  $groups = !empty($edited_page['groups']) ? explode(',', $edited_page['groups']) : array(); 
     132        $template->assign('GROUPSELECTION', get_html_groups_selection(get_all_groups(), 'groups', $groups)); 
     133} 
     134 
     135// Selection des utilisateurs 
     136if ($conf['additional_pages']['user_perm']) 
     137{ 
     138  if (isset($_GET['edit'])) 
     139          $selected_users = isset($edited_page['users']) ? explode(',', $edited_page['users']) : array(); 
     140  else 
     141    $selected_users = array('guest', 'generic', 'normal'); 
     142 
     143        $template->assign('user_perm', array( 
     144    'GUEST' => (in_array('guest', $selected_users) ? 'checked="checked"' : ''), 
     145                'GENERIC' => (in_array('generic', $selected_users) ? 'checked="checked"' : ''), 
     146                'NORMAL' => (in_array('normal', $selected_users) ? 'checked="checked"' : ''))); 
     147} 
     148 
     149// Chargement des données pour l'édition 
     150if ($page['tab'] == 'edit_page') 
     151{ 
     152  $template->assign(array( 
     153    'NAME' => $edited_page['title'], 
     154    'PERMALINK' => $edited_page['permalink'], 
     155    'HOMEPAGE' => $edited_page['homepage'], 
     156    'CONTENT' => $edited_page['content'])); 
     157} 
     158 
     159// Parametrage du template 
     160$template->assign('AP_TITLE', $page_title); 
     161 
     162$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/add_page.tpl'); 
     163$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 
    11164 
    12165?> 
  • extensions/AdditionalPages/admin/edit_page.inc.php

    r9261 r9264  
    3232$template->assign('delete', true); 
    3333 
    34 include(AP_PATH.'admin/page_form.inc.php'); 
     34include(AP_PATH.'admin/add_page.inc.php'); 
    3535 
    3636?> 
Note: See TracChangeset for help on using the changeset viewer.