Changeset 9310


Ignore:
Timestamp:
02/19/11 23:13:22 (9 years ago)
Author:
patdenice
Message:

Lot of optimization.
Add privacy level management.

Location:
extensions/AdditionalPages
Files:
2 deleted
24 edited
2 moved

Legend:

Unmodified
Added
Removed
  • extensions/AdditionalPages/additional_page.php

    r9272 r9310  
    88$identifier = $page['ap_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1]; 
    99 
    10 load_language('plugin.lang.php', AP_PATH); 
    11  
    1210if (function_exists('get_extended_desc')) 
    1311  add_event_handler('AP_render_content', 'get_extended_desc'); 
    1412 
    15 // Récupération des données de la page 
    16 $query = 'SELECT id, title , content, users, groups, permalink, standalone 
     13// Retrieve page data 
     14$query = 'SELECT id, title , content, users, groups, level, permalink, standalone 
    1715FROM ' . ADD_PAGES_TABLE . ' 
    1816'; 
     
    2119  'WHERE permalink = "'.$identifier.'";'; 
    2220 
    23 $row = mysql_fetch_assoc(pwg_query($query)); 
     21$row = pwg_db_fetch_assoc(pwg_query($query)); 
    2422 
    2523if (empty($row)) 
     
    4745); 
    4846 
    49 // Utilisateurs autorisés 
    50 if (!empty($row['users'])) 
     47if (!is_admin() and !$page['ap_homepage']) 
    5148{ 
    52   $authorized_users = explode(',', $row['users']); 
    53   if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users)) 
     49  // authorized users 
     50  if (!empty($row['users'])) 
    5451  { 
    55     if ($page['ap_homepage']) return; 
    56         page_forbidden(l10n('You are not authorized to access the requested page')); 
     52    $authorized_users = explode(',', $row['users']); 
     53    if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users)) 
     54    { 
     55      if ($page['ap_homepage']) return; 
     56      page_forbidden(l10n('You are not authorized to access the requested page')); 
     57    } 
     58  } 
     59 
     60  // authorized groups 
     61  if (!empty($row['groups'])) 
     62  { 
     63    $q = 'SELECT * 
     64  FROM ' . USER_GROUP_TABLE . ' 
     65  WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $row['groups'] . ');'; 
     66    $array = mysql_fetch_array(pwg_query($q)); 
     67    if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array)) 
     68    { 
     69      if ($page['ap_homepage']) return; 
     70      page_forbidden(l10n('You are not authorized to access the requested page')); 
     71    } 
     72  } 
     73 
     74  // authorized level 
     75  if ($user['level'] < $row['level']) 
     76  { 
     77    page_forbidden(l10n('You are not authorized to access the requested page')); 
    5778  } 
    5879} 
    5980 
    60 // Groupe autorisé 
    61 if (!empty($row['groups'])) 
    62 { 
    63   $q = 'SELECT * 
    64 FROM ' . USER_GROUP_TABLE . ' 
    65 WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $row['groups'] . ');'; 
    66   $array = mysql_fetch_array(pwg_query($q)); 
    67   if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array)) 
    68   { 
    69     if ($page['ap_homepage']) return; 
    70         page_forbidden(l10n('You are not authorized to access the requested page')); 
    71   } 
    72 } 
    73  
     81// Display standalone page 
    7482if ($page['additional_page']['standalone']) 
    7583{ 
  • extensions/AdditionalPages/admin/add_page.inc.php

    r9275 r9310  
    55if (!isset($edited_page)) 
    66{ 
    7   $edited_page = array(); 
    8   $edited_page['id'] = 0; 
    9   $edited_page['homepage'] = false; 
    107  $page_title = l10n('ap_create'); 
     8  $default_user = get_default_user_info(true); 
     9  $edited_page = array( 
     10    'id'         => 0, 
     11    'title'      => '', 
     12    'permalink'  => '', 
     13    'homepage'   => false, 
     14    'standalone' => false, 
     15    'level'      => $default_user['level'], 
     16    'users'      => array('guest', 'generic', 'normal', 'admin', 'webmaster'), 
     17    'groups'     => array(), 
     18    'content'    => '', 
     19  ); 
    1120} 
    1221 
     
    4756  if ($conf['additional_pages']['user_perm']) 
    4857  { 
    49     $user_access = !empty($_POST['users']) ? '"'.implode(',', $_POST['users']).'"' : '"admin"'; 
     58    $user_access = !empty($_POST['users']) ? '"'.implode(',', $_POST['users']).'"' : '""'; 
    5059  } 
    5160 
     
    6170  users = '.$user_access.', 
    6271  groups = '.$group_access.', 
     72  level = '.$_POST['level'].', 
    6373  permalink = '.$permalink.', 
    6474  standalone = '.$standalone.' 
     
    7181      $query = 'SELECT MAX(ABS(pos)) AS pos FROM ' . ADD_PAGES_TABLE . ';'; 
    7282      list($position) = array_from_query($query, 'pos'); 
    73        
     83 
    7484      $query = ' 
    75 INSERT INTO ' . ADD_PAGES_TABLE . ' ( pos , lang , title , content , users , groups , permalink, standalone) 
    76 VALUES ('.($position+1).' , '.$language.' , "'.$_POST['title'].'" , "'.$_POST['ap_content'].'" , '.$user_access.' , '.$group_access.' , '.$permalink.' , '.$standalone.');'; 
     85INSERT INTO '.ADD_PAGES_TABLE.' ( pos , lang , title , content , users , groups , level , permalink, standalone) 
     86VALUES ( 
     87  '.($position+1).', 
     88  '.$language.', 
     89  "'.$_POST['title'].'", 
     90  "'.$_POST['ap_content'].'", 
     91  '.$user_access.', 
     92  '.$group_access.', 
     93  '.$_POST['level'].', 
     94  '.$permalink.', 
     95  '.$standalone.' 
     96);'; 
    7797      pwg_query($query); 
    7898      $edited_page['id'] = mysql_insert_id(); 
     
    90110    mkgetdir($conf['local_data_dir'].'/additional_pages_backup', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); 
    91111    $sav_file = @fopen($conf['local_data_dir'].'/additional_pages_backup/' . $edited_page['id'] . '.txt', "w"); 
    92     @fwrite($sav_file, "Title: ".$_POST['title']." 
    93 Permalink: ".$_POST['permalink']." 
    94 Language: ".$_POST['lang']." 
    95  
    96 " . $_POST['ap_content']); 
     112    @fwrite($sav_file, "Title: ".$_POST['title']."\nPermalink: ".$_POST['permalink']."\nLanguage: ".$_POST['lang']."\n\n" . $_POST['ap_content']); 
    97113    @fclose($sav_file); 
    98114 
     
    105121 
    106122  $edited_page['title'] = stripslashes($_POST['title']); 
    107   $edited_page['permalink'] = $_POST['permalink']; 
     123  $edited_page['permalink'] = stripslashes($_POST['permalink']); 
    108124  $edited_page['lang'] = $_POST['lang']; 
    109125  $edited_page['content'] = stripslashes($_POST['ap_content']); 
    110   $edited_page['groups'] = !empty($_POST['groups']) ? trim($group_access, '"') : ''; 
    111   $edited_page['users'] = !empty($_POST['users']) ? trim($user_access, '"') :  ''; 
     126  $edited_page['groups'] = !empty($_POST['groups']) ? $_POST['groups'] : array(); 
     127  $edited_page['users'] = !empty($_POST['users']) ? $_POST['users'] :  array(); 
     128  $edited_page['level'] = $_POST['level']; 
    112129  $edited_page['homepage'] = isset($_POST['homepage']); 
    113130  $edited_page['standalone'] = isset($_POST['standalone']); 
     
    129146  'SELECTED' => $selected)); 
    130147 
    131 // Selection des groupes 
     148// Groups options 
    132149if ($conf['additional_pages']['group_perm']) 
    133150{ 
    134         include_once(AP_PATH . 'admin/functions_groups.php'); 
    135   $groups = !empty($edited_page['groups']) ? explode(',', $edited_page['groups']) : array(); 
    136         $template->assign('GROUPSELECTION', get_html_groups_selection(get_all_groups(), 'groups', $groups)); 
    137 } 
    138  
    139 // Selection des utilisateurs 
     151        $query = 'SELECT id, name FROM '.GROUPS_TABLE.' ORDER BY name ASC;'; 
     152  $result = pwg_query($query); 
     153  $groups = array(); 
     154  while ($row = pwg_db_fetch_assoc($result)) 
     155  { 
     156    $groups[$row['id']] = $row['name']; 
     157  } 
     158  $template->assign(array( 
     159    'groups' => $groups, 
     160    'selected_groups' => $edited_page['groups'], 
     161    ) 
     162  ); 
     163} 
     164 
     165// Users options 
    140166if ($conf['additional_pages']['user_perm']) 
    141167{ 
    142   $selected_users = array('guest', 'generic', 'normal'); 
    143   if (isset($_GET['edit']) and isset($edited_page['users'])) 
    144   { 
    145     $selected_users = explode(',', $edited_page['users']); 
    146   } 
    147  
    148         $template->assign('user_perm', array( 
    149       'GUEST' => in_array('guest', $selected_users) ? 'checked="checked"' : '', 
    150       'GENERIC' => in_array('generic', $selected_users) ? 'checked="checked"' : '', 
    151       'NORMAL' => in_array('normal', $selected_users) ? 'checked="checked"' : '' 
     168  $users_id = array('guest', 'generic', 'normal', 'admin', 'webmaster'); 
     169  $users = array(); 
     170  foreach ($users_id as $id) 
     171  { 
     172    $users[$id] = l10n('user_status_'.$id); 
     173  } 
     174  $template->assign(array( 
     175    'users' => $users, 
     176    'selected_users' => $edited_page['users'], 
    152177    ) 
    153178  ); 
    154179} 
    155180 
    156 // Chargement des données pour l'édition 
    157 if ($page['tab'] == 'edit_page') 
    158 { 
     181// User level options 
     182if ($conf['additional_pages']['level_perm']) 
     183{ 
     184  foreach ($conf['available_permission_levels'] as $level) 
     185  { 
     186    $level_options[$level] = l10n(sprintf('Level %d', $level)); 
     187  } 
    159188  $template->assign(array( 
    160     'NAME' => $edited_page['title'], 
    161     'PERMALINK' => $edited_page['permalink'], 
    162     'HOMEPAGE' => $edited_page['homepage'], 
    163     'STANDALONE' => $edited_page['standalone'], 
    164     'CONTENT' => $edited_page['content'])); 
    165 } 
    166  
    167 // Parametrage du template 
    168 $template->assign('AP_TITLE', $page_title); 
     189    'level_perm' => $level_options, 
     190    'level_selected' => $edited_page['level'] 
     191    ) 
     192  ); 
     193} 
     194 
     195// template output 
     196$template->assign(array( 
     197  'AP_TITLE' => $page_title, 
     198  'NAME' => $edited_page['title'], 
     199  'PERMALINK' => $edited_page['permalink'], 
     200  'HOMEPAGE' => $edited_page['homepage'], 
     201  'STANDALONE' => $edited_page['standalone'], 
     202  'CONTENT' => $edited_page['content'])); 
    169203 
    170204$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/add_page.tpl'); 
  • extensions/AdditionalPages/admin/config.inc.php

    r9275 r9310  
    1616    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET users = NULL;'); 
    1717  } 
     18  if ($conf['additional_pages']['level_perm'] and !isset($_POST['level_perm'])) 
     19  { 
     20    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET level = 0;'); 
     21  } 
    1822  if ($conf['additional_pages']['group_perm'] and !isset($_POST['group_perm'])) 
    1923  { 
     
    2125  } 
    2226 
    23   $params = array('show_home', 'group_perm', 'user_perm'); 
     27  $params = array('show_home', 'group_perm', 'user_perm', 'level_perm'); 
    2428 
    2529  foreach ($params as $param) 
     
    3741  conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages']))); 
    3842 
    39   if (isset($_POST['show_menu']) xor (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] == abs($mb_conf['mbAdditionalPages']))) 
     43  if (isset($_POST['show_menu']) xor (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] > 0)) 
    4044  { 
    4145    if (!isset($mb_conf['mbAdditionalPages'])) 
  • extensions/AdditionalPages/admin/edit_page.inc.php

    r9272 r9310  
    2121} 
    2222 
    23 $q = 'SELECT id , lang , title , content , users , groups , permalink, standalone 
     23$q = 'SELECT id , lang , title , content , users , groups , level , permalink, standalone 
    2424FROM ' . ADD_PAGES_TABLE . ' 
    2525WHERE id = '.$_GET['edit'].';'; 
    2626 
    27 $edited_page = mysql_fetch_assoc(pwg_query($q)); 
     27$edited_page = pwg_db_fetch_assoc(pwg_query($q)); 
    2828$page_title = l10n('ap_modify'); 
     29$edited_page['users'] = !empty($edited_page['users']) ? explode(',', $edited_page['users']) : array(); 
     30$edited_page['groups'] = !empty($edited_page['groups']) ? explode(',', $edited_page['groups']) : array(); 
    2931$edited_page['homepage'] = $conf['additional_pages']['homepage'] == $edited_page['id']; 
    3032$edited_page['standalone'] = ($edited_page['standalone'] == 'true'); 
  • extensions/AdditionalPages/admin/template/add_page.tpl

    r9275 r9310  
    22{html_head}{literal} 
    33<script type="text/javascript"> 
    4 function GereChkbox(conteneur, a_faire) { 
    5 var blnEtat=null; 
    6 var Chckbox = document.getElementById(conteneur).firstChild; 
    7         while (Chckbox!=null) { 
    8                 if (Chckbox.nodeName=="INPUT") 
    9                         if (Chckbox.getAttribute("type")=="checkbox") { 
    10                                 blnEtat = (a_faire=='0') ? false : (a_faire=='1') ? true : (document.getElementById(Chckbox.getAttribute("id")).checked) ? false : true; 
    11                                 document.getElementById(Chckbox.getAttribute("id")).checked=blnEtat; 
    12                         } 
    13                 Chckbox = Chckbox.nextSibling; 
    14         } 
    15 } 
    16  
    174jQuery().ready( function () { 
    185  jQuery('#title').focusout(function () { 
     
    2411  }); 
    2512}); 
    26  
    2713var auto_permalink = true; 
    2814</script> 
     15<style type="text/css"> 
     16#mainConf { margin:0; } 
     17.groups { margin-top:15px; } 
     18.groups input { margin-right:5px; } 
     19.groups label { margin-right:10px; display: inline-block; overflow: hidden; white-space: nowrap; line-height:1.3em;} 
     20.groups div { float:right; width:74%; line-height:1.3em;} 
     21</style> 
    2922{/literal}{/html_head} 
    3023 
     
    3225        <h2>{$AP_TITLE}</h2> 
    3326</div> 
    34 <form method="post" action="" class="properties"  ENCTYPE="multipart/form-data"> 
    35         <table> 
    36                 <tr> 
    37                         <td align="right"><label for="title">{'ap_page_name'|@translate}</label> &nbsp;&nbsp;</td> 
    38                         <td><input type="text" size="60" maxlength="255" value="{if isset($NAME)}{$NAME}{/if}" name="title" id="title"/></td> 
    39                 </tr> 
    40                 <tr> 
    41                         <td align="right"><label for="permalink">{'Permalink'|@translate}</label> &nbsp;&nbsp;</td> 
    42                         <td><input type="text" size="60" value="{if isset($PERMALINK)}{$PERMALINK}{/if}" name="permalink" id="permalink"/></td> 
    43                 </tr> 
    44                 <tr> 
    45                         <td align="right"><label for="lang">{'ap_page_lang'|@translate}</label> &nbsp;&nbsp;</td> 
    46                         <td> 
    47         {html_options name=lang id=lang options=$lang.OPTIONS selected=$lang.SELECTED} 
    48                         </td> 
    49                 </tr> 
    50     <tr><td>&nbsp;</td></tr> 
    51                 <tr> 
    52                         <td align="right"><label for="homepage">{'ap_set_as_homepage'|@translate}</label> &nbsp;&nbsp;</td> 
    53                         <td><input type="checkbox" name="homepage" id="homepage" {if isset($HOMEPAGE) and $HOMEPAGE}checked="checked"{/if}"/> 
    54       &nbsp; <i>{'ap_homepage_tip'|@translate}</i></td> 
    55                 </tr> 
    56                 <tr> 
    57                         <td align="right"><label for="standalone">{'ap_standalone_page'|@translate}</label> &nbsp;&nbsp;</td> 
    58                         <td><input type="checkbox" name="standalone" id="standalone" {if isset($STANDALONE) and $STANDALONE}checked="checked"{/if}"/> 
    59       &nbsp; <i>{'ap_standalone_tip'|@translate}</i></td> 
    60                 </tr> 
     27<form method="post" action="" class="properties" id="configContent" ENCTYPE="multipart/form-data"> 
     28<fieldset id="mainConf"> 
     29  <legend></legend> 
     30        <ul> 
     31    <li> 
     32      <span class="property"> 
     33        <label for="title">{'ap_page_name'|@translate}</label> 
     34      </span> 
     35      <input type="text" size="60" maxlength="255" value="{if isset($NAME)}{$NAME}{/if}" name="title" id="title"/> 
     36    </li> 
    6137 
    62                 {if isset($user_perm)} 
    63                 <tr> 
    64                         <td colspan="2"><hr></td> 
    65                 </tr> 
    66                 <tr> 
    67                         <td align="right">{'ap_authorized_users'|@translate} &nbsp;&nbsp;</td> 
    68                         <td> 
    69                                 <div id="users"> 
    70                                 <input type="checkbox" name="users[]" id="guest" value="guest" {$user_perm.GUEST}><label>&nbsp;{'user_status_guest'|@translate}</label> 
    71                                 <input type="checkbox" name="users[]" id="generic" value="generic" {$user_perm.GENERIC}><label>&nbsp;{'user_status_generic'|@translate}</label> 
    72                                 <input type="checkbox" name="users[]" id="normal" value="normal" {$user_perm.NORMAL}><label>&nbsp;{'user_status_normal'|@translate}</label> 
    73                                 <input type="checkbox" name="users[]" id="admin" value="admin" checked="checked" disabled onclick="return false;"><label>&nbsp;{'user_status_admin'|@translate}</label> 
    74                                 </div> 
    75                         </td> 
    76         </tr> 
     38    <li> 
     39      <span class="property"> 
     40        <label for="permalink">{'Permalink'|@translate}</label> 
     41      </span> 
     42      <input type="text" size="60" value="{if isset($PERMALINK)}{$PERMALINK}{/if}" name="permalink" id="permalink"/> 
     43    </li> 
     44 
     45    <li> 
     46      <span class="property"> 
     47        <label for="lang">{'ap_page_lang'|@translate}</label> 
     48      </span> 
     49      {html_options name=lang id=lang options=$lang.OPTIONS selected=$lang.SELECTED} 
     50    </li> 
     51 
     52    <li style="margin-top:15px;"> 
     53      <span class="property"> 
     54        <label for="homepage">{'ap_set_as_homepage'|@translate}</label> 
     55      </span> 
     56      <input type="checkbox" name="homepage" id="homepage" {if isset($HOMEPAGE) and $HOMEPAGE}checked="checked"{/if}/> 
     57      <i>{'ap_homepage_tip'|@translate}</i> 
     58    </li> 
     59 
     60    <li> 
     61      <span class="property"> 
     62        <label for="standalone">{'ap_standalone_page'|@translate}</label> 
     63      </span> 
     64      <input type="checkbox" name="standalone" id="standalone" {if isset($STANDALONE) and $STANDALONE}checked="checked"{/if}/> 
     65      <i>{'ap_standalone_tip'|@translate}</i> 
     66    </li> 
     67 
     68    {if isset($level_perm)} 
     69    <li style="margin-top:15px;"> 
     70      <span class="property"> 
     71        <label for="privacy">{'Privacy level'|@translate}</label> 
     72      </span> 
     73      <select name="level" size="1">{html_options options=$level_perm selected=$level_selected id=privacy}</select> 
     74    </li> 
    7775    {/if} 
    7876 
    79                 {if !empty($GROUPSELECTION)} 
    80                 <tr> 
    81                         <td colspan="2"><hr></td> 
    82                 </tr> 
    83                 <tr> 
    84                         <td align="right">{'ap_authorized_group'|@translate} &nbsp;&nbsp;</td> 
    85                         <td>{$GROUPSELECTION}</td> 
    86         </tr> 
    87         <tr> 
    88                 <td></td> 
    89                         <td><a href="javascript:GereChkbox('groups','1');">{'ap_select_all'|@translate}</a> / <a href="javascript:GereChkbox('groups','0');">{'ap_unselect_all'|@translate}</a> 
    90                         <i>&nbsp;&nbsp; {'ap_guest'|@translate}</i></td> 
    91         </tr> 
     77    {if isset($users)} 
     78    <li class="groups" style="margin-top:15px;"> 
     79      <span class="property"> 
     80        <label for="users">{'ap_authorized_users'|@translate}</label> 
     81      </span> 
     82      {html_checkboxes options=$users selected=$selected_users name=users} 
     83    </li> 
    9284    {/if} 
    93 </table> 
     85 
     86    {if isset($groups)} 
     87    <li class="groups" style="margin-top:15px;"> 
     88      <span class="property"> 
     89        <label for="groups">{'ap_authorized_group'|@translate}</label> 
     90      </span> 
     91      <div>{html_checkboxes options=$groups selected=$selected_groups name=groups}</div> 
     92    </li> 
     93    <li class="groups"> 
     94      <div> 
     95        <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', 'checked');return false;">{'ap_select_all'|@translate}</a> / 
     96        <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', '');return false;">{'ap_unselect_all'|@translate}</a> 
     97      </div> 
     98    </li> 
     99    {/if} 
     100</ul> 
     101</fieldset> 
    94102<table style="width:95%;"> 
    95103                <tr> 
  • extensions/AdditionalPages/admin/template/config.tpl

    r9275 r9310  
    3636  <legend>{'ap_perm'|@translate}</legend> 
    3737  <ul> 
     38      <li> 
     39      <label> 
     40        <span class="property">{'ap_level_perm'|@translate}</span> 
     41        <input type="checkbox" name="level_perm" id="level_perm" value="on" {if $ap_conf.level_perm}checked="checked"{/if}/> 
     42      </label> 
     43    </li> 
     44 
    3845    <li> 
    3946      <label> 
  • extensions/AdditionalPages/admin/upgrade.inc.php

    r9275 r9310  
    55global $prefixeTable, $conf; 
    66 
    7 load_conf_from_db('param = "additional_pages"'); 
    8 $old_conf = explode ("," , $conf['additional_pages']); 
     7$query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'additionalpages;'; 
     8$result = array_from_query($query, 'Collation'); 
     9if (strpos($result[4], 'utf8') === false) 
     10{ 
     11  $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages 
     12MODIFY COLUMN lang varchar(255) CHARACTER SET utf8 NOT NULL, 
     13MODIFY COLUMN title varchar(255) CHARACTER SET utf8 NOT NULL, 
     14MODIFY COLUMN text longtext CHARACTER SET utf8 NOT NULL, 
     15DEFAULT CHARACTER SET utf8;'; 
    916 
    10 $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages 
     17  pwg_query($query); 
     18} 
     19 
     20if ($conf['additional_pages'] === false) 
     21{ 
     22  load_conf_from_db('param = "additional_pages"'); 
     23  $old_conf = explode ("," , $conf['additional_pages']); 
     24 
     25  $query = ' 
     26ALTER TABLE ' . $prefixeTable . 'additionalpages 
    1127CHANGE `id` `id` SMALLINT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT , 
    1228CHANGE `pos` `pos` SMALLINT( 5 ) NULL DEFAULT NULL , 
     
    1733ADD `permalink` VARCHAR( 64 ) NULL DEFAULT NULL , 
    1834ADD `standalone` ENUM( "true", "false" ) NOT NULL DEFAULT "false";'; 
    19 pwg_query($query); 
     35  pwg_query($query); 
    2036 
    21 $query = ' 
     37  $query = ' 
    2238SELECT id, pos, title, lang 
    2339FROM '.$prefixeTable.'additionalpages 
    2440ORDER BY pos ASC 
    2541;'; 
    26 $result = pwg_query($query); 
    27 while ($row = mysql_fetch_assoc($result)) 
    28 { 
    29   $title = $row['title']; 
    30   $authorized_users = 'NULL'; 
    31   $authorized_groups = 'NULL'; 
     42  $result = pwg_query($query); 
     43  while ($row = pwg_db_fetch_assoc($result)) 
     44  { 
     45    $title = $row['title']; 
     46    $authorized_users = 'NULL'; 
     47    $authorized_groups = 'NULL'; 
    3248 
    33   if ($old_conf[7] == 'on' and strpos($title , '/user_id=')) 
    34   { 
    35     $array = explode('/user_id=' , $title); 
    36     $title = $array[0]; 
    37     $authorized_users = !empty($array[1]) ? '"'.$array[1].'"' : '"admin"'; 
    38   } 
    39   if ($old_conf[6] == 'on' and strpos($title , '/group_id=')) 
    40   { 
    41     $array = explode('/group_id=' , $title); 
    42     $title = $array[0]; 
    43     $authorized_groups = !empty($array[1]) ? '"'.$array[1].'"' : 'NULL'; 
    44   } 
     49    if ($old_conf[7] == 'on' and strpos($title , '/user_id=')) 
     50    { 
     51      $array = explode('/user_id=' , $title); 
     52      $title = $array[0]; 
     53      $authorized_users = !empty($array[1]) ? '"'.$array[1].'"' : '"admin"'; 
     54    } 
     55    if ($old_conf[6] == 'on' and strpos($title , '/group_id=')) 
     56    { 
     57      $array = explode('/group_id=' , $title); 
     58      $title = $array[0]; 
     59      $authorized_groups = !empty($array[1]) ? '"'.$array[1].'"' : 'NULL'; 
     60    } 
    4561 
    46   $position = $row['pos']; 
    47   if ($row['pos'] === '0') 
    48     $position = '-100'; 
    49   elseif (empty($row['pos'])) 
    50     $position = '0'; 
     62    $position = $row['pos']; 
     63    if ($row['pos'] === '0') 
     64      $position = '-100'; 
     65    elseif (empty($row['pos'])) 
     66      $position = '0'; 
    5167 
    52   $language = $row['lang'] != 'ALL' ? '"'.$row['lang'].'"' : 'NULL'; 
     68    $language = $row['lang'] != 'ALL' ? '"'.$row['lang'].'"' : 'NULL'; 
    5369 
    54   $query = ' 
     70    $query = ' 
    5571UPDATE '.$prefixeTable.'additionalpages 
    5672SET title = "'.addslashes($title).'", 
     
    6177WHERE id = '.$row['id'].' 
    6278;'; 
    63   pwg_query($query); 
     79    pwg_query($query); 
     80  } 
     81 
     82  if ($old_conf[1] == 'off') 
     83  { 
     84    $mb_conf = @unserialize($conf['blk_menubar']); 
     85    if (!isset($mb_conf['mbAdditionalPages'])) 
     86    { 
     87      $last = @abs(end($mb_conf)); 
     88      $mb_conf['mbAdditionalPages'] = $last + 50; 
     89    } 
     90    $mb_conf['mbAdditionalPages'] = -1 * abs($mb_conf['mbAdditionalPages']); 
     91    conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf))); 
     92  } 
     93 
     94  $new_conf = array( 
     95    'show_home' => @($old_conf[2] == 'on'), 
     96    'group_perm' => @($old_conf[6] == 'on'), 
     97    'user_perm' => @($old_conf[7] == 'on'), 
     98    'homepage' => null, 
     99    ); 
     100 
     101  $languages = explode('/', $old_conf[0]); 
     102  $new_conf['languages'] = array(); 
     103  foreach($languages as $language) 
     104  { 
     105    $array = explode(':', $language); 
     106    if (!isset($array[1])) $new_conf['languages']['default'] = $array[0]; 
     107    else $new_conf['languages'][$array[0]] = $array[1]; 
     108  } 
     109 
     110  $conf['additional_pages'] = $new_conf; 
     111 
     112  conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($new_conf))); 
    64113} 
    65114 
    66 if ($old_conf[1] == 'off') 
     115if (!isset($conf['additional_pages']['level_perm'])) 
    67116{ 
    68   $mb_conf = @unserialize($conf['blk_menubar']); 
    69   if (!isset($mb_conf['mbAdditionalPages'])) 
    70   { 
    71     $last = @abs(end($mb_conf)); 
    72     $mb_conf['mbAdditionalPages'] = $last + 50; 
    73   } 
    74   $mb_conf['mbAdditionalPages'] = -1 * abs($mb_conf['mbAdditionalPages']); 
    75   conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf))); 
     117  $query = ' 
     118ALTER TABLE ' . $prefixeTable . 'additionalpages 
     119ADD `level` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT "0" AFTER `groups` 
     120;'; 
     121  pwg_query($query); 
     122 
     123  $query = ' 
     124UPDATE ' . $prefixeTable . 'additionalpages 
     125SET users = CONCAT( users, ",admin,webmaster" ) 
     126WHERE users IS NOT NULL 
     127;'; 
     128  pwg_query($query); 
     129 
     130  $conf['additional_pages']['level_perm'] = false; 
     131 
     132  conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages']))); 
    76133} 
    77134 
    78 $new_conf = array( 
    79   'show_home' => @($old_conf[2] == 'on'), 
    80   'group_perm' => @($old_conf[6] == 'on'), 
    81   'user_perm' => @($old_conf[7] == 'on'), 
    82   'homepage' => null, 
    83   ); 
    84  
    85 $languages = explode('/', $old_conf[0]); 
    86 $new_conf['languages'] = array(); 
    87 foreach($languages as $language) 
    88 { 
    89   $array = explode(':', $language); 
    90   if (!isset($array[1])) $new_conf['languages']['default'] = $array[0]; 
    91   else $new_conf['languages'][$array[0]] = $array[1]; 
    92 } 
    93  
    94 $conf['additional_pages'] = $new_conf; 
    95  
    96 conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($new_conf))); 
    97  
    98135?> 
  • extensions/AdditionalPages/language/ar_SA/plugin.lang.php

    r8684 r9310  
    3838$lang['ap_parse_bbcode'] = 'حول الصفحات المكتوبة ب BBcode'; 
    3939$lang['ap_convert_bbcode_ok'] = 'التحويل تم.'; 
     40 
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page'; 
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage'; 
     43/*TODO*/$lang['ap_standalone_page'] = 'Standalone Page'; 
     44/*TODO*/$lang['ap_homepage_tip'] = 'Replace your gallery\'s homepage'; 
     45/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
     46/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
     48 
    4049?> 
  • extensions/AdditionalPages/language/cs_CZ/plugin.lang.php

    r9273 r9310  
    4545/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/de_DE/plugin.lang.php

    r9273 r9310  
    4545/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/en_UK/plugin.lang.php

    r9305 r9310  
    4545$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/es_ES/plugin.lang.php

    r9273 r9310  
    4545/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/fr_FR/plugin.lang.php

    r9294 r9310  
    4545$lang['ap_standalone_tip'] = 'La page requiert une structure HTML complète'; 
    4646$lang['ap_permalink_already_used'] = 'Le lien permanent %s est déja utilisé par la page %s'; 
     47$lang['ap_level_perm'] = 'par niveau de confidentialité'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/hu_HU/plugin.lang.php

    r9273 r9310  
    4545/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/it_IT/plugin.lang.php

    r9302 r9310  
    4545$lang['ap_standalone_tip'] = 'La pagina richiede la completa struttura HTML'; 
    4646$lang['ap_permalink_already_used'] = 'Permalink %s è già utilizzato da pagina %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849 
  • extensions/AdditionalPages/language/lv_LV/plugin.lang.php

    r9273 r9310  
    4545/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/nl_NL/plugin.lang.php

    r9297 r9310  
    4545$lang['ap_standalone_tip'] = 'Deze pagina dient een volledige HTML-structuur te hebben'; 
    4646$lang['ap_permalink_already_used'] = 'De permalink %s wordt al gebruikt door pagina %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/no_NO/plugin.lang.php

    r8856 r9310  
    3939$lang['ap_convert_bbcode_ok'] = 'Konverteriing effektuert.'; 
    4040 
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page'; 
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage'; 
     43/*TODO*/$lang['ap_standalone_page'] = 'Standalone Page'; 
     44/*TODO*/$lang['ap_homepage_tip'] = 'Replace your gallery\'s homepage'; 
     45/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
     46/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
     48 
    4149?> 
  • extensions/AdditionalPages/language/pl_PL/plugin.lang.php

    r9309 r9310  
    4545$lang['ap_standalone_tip'] = 'Strona wymaga pełnej struktury HTML'; 
    4646$lang['ap_permalink_already_used'] = 'Link permanentny %s jest już używane przez stronę %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/ru_RU/plugin.lang.php

    r9273 r9310  
    4545/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/sk_SK/plugin.lang.php

    r9273 r9310  
    4545/*TODO*/$lang['ap_standalone_tip'] = 'Page require full HTML structure'; 
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/sv_SE/plugin.lang.php

    r9303 r9310  
    4545$lang['ap_standalone_tip'] = 'Sidan kräver full HTML struktur'; 
    4646$lang['ap_permalink_already_used'] = 'Permalänk %s används redan av sidan %s'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/language/tr_TR/plugin.lang.php

    r9304 r9310  
    4545$lang['ap_standalone_tip'] = 'Sayfa tam HTML yapısı gerektirir'; 
    4646$lang['ap_permalink_already_used'] = 'Kalıcı bağlantı %s zaten sayfa %s tarafından kullanılıyor'; 
     47/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    4748 
    4849?> 
  • extensions/AdditionalPages/main.inc.php

    r9272 r9310  
    1919$conf['additional_pages'] = @unserialize($conf['additional_pages']); 
    2020 
    21 if ($conf['additional_pages'] === false) 
    22   include(AP_PATH.'admin/upgrade_from_21.php'); 
     21if (!isset($conf['additional_pages']['level_perm'])) 
     22  include(AP_PATH.'admin/upgrade.inc.php'); 
    2323 
    2424function additional_pages_admin_menu($menu) 
     
    4343} 
    4444 
    45 include(AP_PATH . 'index_menu.php'); 
     45function register_ap_menubar_blocks($menu_ref_arr) 
     46{ 
     47  $menu = & $menu_ref_arr[0]; 
     48  if ($menu->get_id() != 'menubar') return; 
     49  $menu->register_block( new RegisteredBlock( 'mbAdditionalPages', 'Additional Pages', 'P@t')); 
     50} 
     51 
     52function ap_apply($menu_ref_arr) 
     53{ 
     54  global $template, $conf, $user; 
     55 
     56  $menu = & $menu_ref_arr[0]; 
     57   
     58  if ( ($block = $menu->get_block( 'mbAdditionalPages' ) ) != null ) 
     59  { 
     60    $query = 'SELECT DISTINCT id, title, permalink, GROUP_CONCAT(groups) 
     61FROM ' . ADD_PAGES_TABLE . ' 
     62LEFT JOIN ' . USER_GROUP_TABLE . ' 
     63  ON user_id = '.$user['id'].' 
     64WHERE (lang = "' . $user['language'] . '" OR lang IS NULL) 
     65  AND (users IS NULL OR users LIKE "%'.$user['status'].'%") 
     66  AND (groups IS NULL OR groups REGEXP CONCAT("(^|,)",group_id,"(,|$)")) 
     67  AND level <= '.$user['level'].' 
     68  AND pos >= 0 
     69ORDER BY pos ASC 
     70;'; 
     71    $result = pwg_query($query); 
     72    $data = array(); 
     73    while ($row = pwg_db_fetch_assoc($result)) 
     74    { 
     75      $url = make_index_url().'/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']); 
     76      array_push($data, array('URL' => $url, 'LABEL' => $row['title'])); 
     77    } 
     78 
     79    if (!empty($data)) 
     80    { 
     81      $title = isset($conf['additional_pages']['languages'][$user['language']]) ? 
     82        $conf['additional_pages']['languages'][$user['language']] : 
     83        @$conf['additional_pages']['languages']['default']; 
     84 
     85      $template->set_template_dir(AP_PATH.'template/'); 
     86      $block->set_title($title); 
     87      $block->template = 'menubar_additional_pages.tpl'; 
     88      $block->data = $data; 
     89    } 
     90  } 
     91} 
    4692 
    4793add_event_handler('get_admin_plugin_menu_links', 'additional_pages_admin_menu'); 
    4894add_event_handler('loc_end_section_init', 'section_init_additional_page'); 
     95add_event_handler('blockmanager_register_blocks', 'register_ap_menubar_blocks'); 
     96add_event_handler('blockmanager_apply', 'ap_apply'); 
    4997 
    5098?> 
  • extensions/AdditionalPages/maintain.inc.php

    r9272 r9310  
    1717users VARCHAR( 255 ) NULL DEFAULT NULL , 
    1818groups VARCHAR( 255 ) NULL DEFAULT NULL , 
     19level TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT "0" , 
    1920permalink VARCHAR( 64 ) NULL DEFAULT NULL , 
    2021standalone ENUM( "true", "false" ) NOT NULL DEFAULT "false" , 
     
    3132      'languages' => array('default' => 'Additional Pages'), 
    3233      'show_home' => true, 
     34      'level_perm' => false, 
    3335      'group_perm' => false, 
    3436      'user_perm' => false, 
     
    5658    pwg_query('ALTER TABLE ' . HISTORY_TABLE . ' CHANGE section section ' . $type . ' DEFAULT NULL'); 
    5759  } 
    58    
    59   // Check if upgrade is needed 
    60   $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'additionalpages;'; 
    61   $result = array_from_query($query, 'Collation'); 
    62   if (strpos($result[4], 'utf8') === false) 
    63   { 
    64     upgrade_ap_from_17(); 
    65   } 
    6660} 
    6761 
     
    7771} 
    7872 
    79 function upgrade_ap_from_17() 
    80 { 
    81   global $prefixeTable; 
    82  
    83   $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages 
    84 MODIFY COLUMN lang varchar(255) CHARACTER SET utf8 NOT NULL, 
    85 MODIFY COLUMN title varchar(255) CHARACTER SET utf8 NOT NULL, 
    86 MODIFY COLUMN text longtext CHARACTER SET utf8 NOT NULL, 
    87 DEFAULT CHARACTER SET utf8;'; 
    88  
    89   pwg_query($query); 
    90 } 
    91  
    9273?> 
Note: See TracChangeset for help on using the changeset viewer.