Ignore:
Timestamp:
Feb 26, 2011, 4:28:24 PM (13 years ago)
Author:
patdenice
Message:

Add display option. Optimizations.

Location:
extensions/PWG_Stuffs/admin
Files:
2 added
1 deleted
3 edited
4 moved

Legend:

Unmodified
Added
Removed
  • extensions/PWG_Stuffs/admin/add_module.inc.php

    r9369 r9383  
    3030      $desc = !empty($_POST['module_desc']) ? '"' . $_POST['module_desc'] . '"' : 'NULL';
    3131      $groups = !empty($_POST['groups']) ? '"' . implode(',', $_POST['groups']) . '"' : 'NULL';
    32       $users = !empty($_POST['users']) ? '"' . implode(',', $_POST['users']) . '"' : 'NULL';
     32      $users = 'NULL';
     33      if ($conf['Stuffs']['user_perm'])
     34      {
     35        $users = !empty($_POST['users']) ? '"' . implode(',', $_POST['users']) . '"' : '""';
     36      }
    3337      $show_title = isset($_POST['show_title']) ? '"true"' : '"false"';
    3438      $on_home = isset($_POST['on_home'])  ? '"true"' : '"false"';
     39      $on_root = isset($_POST['on_root'])  ? '"true"' : '"false"';
    3540      $on_cats = isset($_POST['on_cats'])  ? '"true"' : '"false"';
    3641      $on_picture = isset($_POST['on_picture'])  ? '"true"' : '"false"';
     
    4954    show_title=' . $show_title .',
    5055    on_home=' . $on_home .',
     56    on_root=' . $on_root .',
    5157    on_cats=' . $on_cats . ',
    5258    on_picture='. $on_picture . '
     
    6672
    6773        $query = '
    68 INSERT INTO ' . STUFFS_TABLE . ' ( id, pos, name, descr, path, parent, datas, users, groups, show_title, on_home, on_cats, on_picture, id_line, width )
     74INSERT INTO ' . STUFFS_TABLE . ' ( id, pos, name, descr, path, parent, datas, users, groups, show_title, on_home, on_root, on_cats, on_picture, id_line, width )
    6975VALUES (' . $next_element_id . ' ,
    7076  ' . $pos . ',
     
    7884  ' . $show_title . ',
    7985  ' . $on_home . ',
     86  ' . $on_root . ',
    8087  ' . $on_cats . ',
    8188  ' . $on_picture . ',
     
    94101  $module['users'] = array('guest', 'generic', 'normal', 'admin', 'webmaster');
    95102  $module['groups'] = array();
     103
    96104  $template->assign(array(
    97105    'STUFFS_TITLE' => l10n('stuffs_add_mod'),
    98106    'MODULE_NAME' => $modules[$module_path]['name'],
    99     'show_title_CHECKED' => 'checked="checked"',
    100     'on_home_CHECKED' => 'checked="checked"'));
     107    'show_title_CHECKED' => true,
     108    )
     109  );
     110
     111  $template->assign('selected_options', array(
     112    'on_home' => true,
     113    'on_root' => true,
     114    'on_cats' => false,
     115    'on_picture' => false,
     116    )
     117  );
    101118}
    102119
    103120// Users perm
    104 $template->assign('user_perm', array(
    105   'GUEST' => (in_array('guest', $module['users']) ? 'checked="checked"' : ''),
    106   'GENERIC' => (in_array('generic', $module['users']) ? 'checked="checked"' : ''),
    107   'NORMAL' => (in_array('normal', $module['users']) ? 'checked="checked"' : ''),
    108   'ADMIN' => (in_array('admin', $module['users']) ? 'checked="checked"' : ''),
    109   'WEBMASTER' => (in_array('webmaster', $module['users']) ? 'checked="checked"' : '')));
     121if ($conf['Stuffs']['user_perm'])
     122{
     123  $users_id = array('guest', 'generic', 'normal', 'admin', 'webmaster');
     124  $users = array();
     125  foreach ($users_id as $id)
     126  {
     127    $users[$id] = l10n('user_status_'.$id);
     128  }
     129  $template->assign(array(
     130    'users' => $users,
     131    'selected_users' => isset($module['users']) ? $module['users'] : $users_id,
     132    )
     133  );
     134}
    110135
    111136// Groups perm
    112 $groups = get_all_groups();
    113 if (!empty($groups))
     137if ($conf['Stuffs']['group_perm'])
    114138{
    115   $template->assign('group_perm', array('GROUPSELECTION' => get_html_groups_selection($groups, 'groups', $module['groups'])));
     139        $query = 'SELECT id, name FROM '.GROUPS_TABLE.' ORDER BY name ASC;';
     140  $result = pwg_query($query);
     141  $groups = array();
     142  while ($row = pwg_db_fetch_assoc($result))
     143  {
     144    $groups[$row['id']] = $row['name'];
     145  }
     146  $template->assign(array(
     147    'groups' => $groups,
     148    'selected_groups' => isset($module['groups']) ? $module['groups'] : array(),
     149    )
     150  );
    116151}
     152
     153// Level perm
     154if ($conf['Stuffs']['level_perm'])
     155{
     156  foreach ($conf['available_permission_levels'] as $level)
     157  {
     158    $level_options[$level] = l10n(sprintf('Level %d', $level));
     159  }
     160  $template->assign(array(
     161    'level_perm' => $level_options,
     162    'level_selected' => isset($module['level']) ? $module['level'] : 0,
     163    )
     164  );
     165}
     166
     167// Display options
     168$template->assign('display_options', array(
     169  'on_home' => true,
     170  'on_root' => true,
     171  'on_cats' => true,
     172  'on_picture' => true,
     173  )
     174);
    117175
    118176// Module configuration
  • extensions/PWG_Stuffs/admin/admin.php

    r9369 r9383  
    88include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    99include_once(STUFFS_PATH . 'include/functions.inc.php');
    10 include_once(STUFFS_PATH . 'admin/functions.inc.php');
    1110$my_base_url = get_admin_plugin_menu_link(__FILE__);
    1211
     
    2827if ($page['tab'] == 'edit_module')
    2928{
    30   $tabsheet->add('edit_module', l10n('stuffs_edit_mod'), $my_base_url.'&tab=edit_module');
     29  $tabsheet->add('edit_module', l10n('stuffs_edit_mod'), $my_base_url.'&tab=edit_module&edit='.$_GET['edit']);
    3130}
     31$tabsheet->add('config', l10n('Configuration'), $my_base_url.'&tab=config');
    3232$tabsheet->select($page['tab']);
    3333$tabsheet->assign();
     
    5151
    5252// Include file
    53 include(STUFFS_PATH.'admin/'.$page['tab'].'.php');
     53include(STUFFS_PATH.'admin/'.$page['tab'].'.inc.php');
    5454
    5555?>
  • extensions/PWG_Stuffs/admin/edit_module.inc.php

    r9369 r9383  
    1616  'MODULE_NAME' => $module['name'],
    1717  'DESC_VALUE' => (isset($module['descr']) ? $module['descr'] : ''),
    18   'show_title_CHECKED' => ($module['show_title'] == 'true' ? 'checked="checked"' : ''),
    19   'on_home_CHECKED' => ($module['on_home'] == 'true' ? 'checked="checked"' : ''),
    20   'on_cats_CHECKED' => ($module['on_cats'] == 'true' ? 'checked="checked"' : ''),
    21   'on_picture_CHECKED' => ($module['on_picture'] == 'true' ? 'checked="checked"' : ''),
     18  'show_title_CHECKED' => ($module['show_title'] == 'true'),
     19  )
     20);
     21
     22$template->assign('selected_options', array(
     23  'on_home' => ($module['on_home'] == 'true'),
     24  'on_root' => ($module['on_root'] == 'true'),
     25  'on_cats' => ($module['on_cats'] == 'true'),
     26  'on_picture' => ($module['on_picture'] == 'true'),
    2227  )
    2328);
     
    2530$module_path = $module['path'];
    2631
    27 include('add_module.php');
     32include('add_module.inc.php');
    2833
    2934?>
  • extensions/PWG_Stuffs/admin/template/add_module.tpl

    r7855 r9383  
     1{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
    12{include file='include/autosize.inc.tpl'}
    2 
    3 {$TINYMCE_SCRIPT}
     3{html_head}{literal}
     4<style type="text/css">
     5.groups { margin-top:15px; }
     6.groups input { margin-right:5px; }
     7.groups label { margin-right:10px; display: inline-block; overflow: hidden; white-space: nowrap; line-height:1.3em;}
     8.groups div { float:right; width:74%; line-height:1.3em;}
     9</style>
     10{/literal}{/html_head}
    411
    512<div class="titrePage">
     
    714</div>
    815
    9 <form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
     16<form method="post" action="" class="properties" ENCTYPE="multipart/form-data">
     17<fieldset id="mainConf" >
     18  <legend>{'stuffs_module_config'|@translate}</legend>
     19        <ul>
     20    <li>
     21      <span class="property">
     22        <label for="module_name">{'stuffs_module_title'|@translate}</label>
     23      </span>
     24      <textarea rows="2" name="module_name" id="module_name" class="description" style="height:2em; width:500px;">{$MODULE_NAME}</textarea>
     25    </li>
     26    <li>
     27      <span class="property">
     28        <label for="module_desc">{'stuffs_desc'|@translate}<br>&nbsp;</label>
     29      </span>
     30      <input type="text" maxlength="255" value="{$DESC_VALUE}" name="module_desc" id="module_desc" style="width:500px;"/><br><i>{'stuffs_only_for_admin'|@translate}</i>
     31    </li>
     32    <li>
     33      <span class="property">
     34        <label for="show_title">{'stuffs_show_title'|@translate}</label>
     35      </span>
     36      <input type="checkbox" name="show_title" id="show_title" value="1" {if $show_title_CHECKED}checked="checked"{/if}>
     37    </li>
    1038
    11 <fieldset>
    12         <legend>{'stuffs_module_config'|@translate}</legend>
    13         <table>
    14 
    15                 <tr><td colspan="3"><br></td></tr>
    16 
    17                 <tr>
    18                         <td><b>{'stuffs_module_title'|@translate}&nbsp;&nbsp;</b></td>
    19                         <td colspan="2"><textarea cols="50" rows="2" name="module_name" id="module_name" class="description" style="height: 2em">{$MODULE_NAME}</textarea></td>
    20                 </tr>
    21 
    22                 <tr><td colspan="3"><br></td></tr>
    23 
    24                 <tr>
    25                         <td><b>{'stuffs_desc'|@translate}&nbsp;&nbsp;</b></td>
    26                         <td colspan="2"><input type="text" size="65" maxlength="255" value="{$DESC_VALUE}" name="module_desc"/></td>
    27                 </tr>
    28                 <tr>
    29                         <td></td>
    30                         <td colspan="2">{'stuffs_only_for_admin'|@translate}</td>
    31                 </tr>
    32 
    33                 <tr><td colspan="3"><br></td></tr>
    34                 <tr>
    35                         <td><b>{'stuffs_authorized_users'|@translate} &nbsp;&nbsp;</b></td>
    36                         <td colspan="2">
    37                                 <div id="users">
    38                                 <input type="checkbox" name="users[]" id="guest" value="guest" {$user_perm.GUEST}><label>&nbsp;{'user_status_guest'|@translate}</label>
    39                                 <input type="checkbox" name="users[]" id="generic" value="generic" {$user_perm.GENERIC}><label>&nbsp;{'user_status_generic'|@translate}</label>
    40                                 <input type="checkbox" name="users[]" id="normal" value="normal" {$user_perm.NORMAL}><label>&nbsp;{'user_status_normal'|@translate}</label>
    41                                 <input type="checkbox" name="users[]" id="admin" value="admin" {$user_perm.ADMIN}><label>&nbsp;{'user_status_admin'|@translate}</label>
    42                                 <input type="checkbox" name="users[]" id="webmaster" value="webmaster" {$user_perm.WEBMASTER}><label>&nbsp;{'user_status_webmaster'|@translate}</label>
    43                                 </div>
    44                         </td>
    45         </tr>
    46 
    47                 {if isset($group_perm)}
    48                 <tr><td colspan="3"><br></td></tr>
    49                 <tr>
    50                         <td><b>{'stuffs_authorized_group'|@translate} &nbsp;&nbsp;</b></td>
    51                         <td colspan="2">{$group_perm.GROUPSELECTION}</td>
    52         </tr>
    53         <tr>
    54                 <td></td>
    55                         <td colspan="2"><i>{'stuffs_public_module'|@translate}</i></td>
    56         </tr>
     39    {if isset($level_perm)}
     40    <li style="margin-top:15px;">
     41      <span class="property">
     42        <label for="level">{'Privacy level'|@translate}</label>
     43      </span>
     44      <select name="level" id="level" size="1">{html_options options=$level_perm selected=$level_selected id=privacy}</select>
     45    </li>
    5746    {/if}
    5847
    59         <tr><td colspan="3"><br></td></tr>
    60         </table>
     48   
     49    {if isset($users)}
     50    <li class="groups" style="margin-top:15px;">
     51      <span class="property">
     52        <label for="users">{'stuffs_authorized_users'|@translate}</label>
     53      </span>
     54      {html_checkboxes options=$users selected=$selected_users name=users}
     55    </li>
     56    {/if}
     57
     58    {if isset($groups)}
     59    <li class="groups" style="margin-top:15px;">
     60      <span class="property">
     61        <label for="groups">{'stuffs_authorized_group'|@translate}</label>
     62      </span>
     63      <div>{html_checkboxes options=$groups selected=$selected_groups name=groups}</div>
     64    </li>
     65    <li class="groups">
     66      <div>
     67        <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', 'checked');return false;">{'stuffs_select_all'|@translate}</a> /
     68        <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', '');return false;">{'stuffs_unselect_all'|@translate}</a> &nbsp;
     69        <i>{'stuffs_guest'|@translate}</i>
     70      </div>
     71    </li>
     72    {/if}
     73  </ul>
    6174</fieldset>
    6275
    63 <fieldset>
    64         <legend>{'stuffs_visual_config'|@translate}</legend>
    65         <table>
    66                 <tr><td colspan="2"><br></td></tr>
    67                 <tr>
    68                         <td colspan="2"><input type="checkbox" name="show_title" value="1" {$show_title_CHECKED}>&nbsp;&nbsp;{'stuffs_show_title'|@translate}</td>
    69                 </tr>
    70                 <tr><td><br></td></tr>
    71                 <tr>
    72                         <td>{'stuffs_show_module_on'|@translate}</td>
    73                         <td>&nbsp;&nbsp;<input type="checkbox" name="on_home" value="1" {$on_home_CHECKED}>&nbsp;&nbsp;<i>{'stuffs_show_on_home'|@translate}</i></td>
    74                 </tr>
    75                 <tr><td></td>
    76                         <td>&nbsp;&nbsp;<input type="checkbox" name="on_cats" value="1" {$on_cats_CHECKED}>&nbsp;&nbsp;<i>{'stuffs_show_on_cats'|@translate}</i></td>
    77                 </tr>
    78                 <tr><td></td>
    79                         <td>&nbsp;&nbsp;<input type="checkbox" name="on_picture" value="1" {$on_picture_CHECKED}>&nbsp;&nbsp;<i>{'stuffs_show_on_pictures'|@translate}</i></td>
    80                 </tr>
    81                 <tr><td colspan="2"><br></td></tr>
    82         </table>
    83 
    84 
     76<fieldset id="indexDisplayConf">
     77        <legend>{'stuffs_show_module_on'|@translate}</legend>
     78  <ul>
     79    {foreach from=$display_options key=option item=value}
     80    {if $value}
     81    <li>
     82      <label>
     83        <span class="property">{'stuffs_show_'|@cat:$option|@translate}</span>
     84        <input type="checkbox" name="{$option}" value="1" {if $selected_options[$option]}checked="checked"{/if}>
     85      </label>
     86    </li>
     87    {/if}
     88    {/foreach}
     89  </ul>
    8590</fieldset>
    8691
  • extensions/PWG_Stuffs/admin/upgrade.inc.php

    r9369 r9383  
    9292  $query = 'ALTER TABLE ' . $prefixeTable . 'stuffs
    9393CHANGE `type` `path` VARCHAR( 255 ) NULL DEFAULT NULL,
    94 ADD `parent` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `path`
     94ADD `parent` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `path`,
     95ADD `level` TINYINT( 3 ) NOT NULL default "0" AFTER `groups`,
     96ADD `on_root` enum(\'true\',\'false\') NOT NULL AFTER `on_home`
     97;';
     98  pwg_query($query);
     99
     100  $query = 'UPDATE ' . $prefixeTable . 'stuffs
     101SET on_root = "false"
     102WHERE on_cats = "false"
    95103;';
    96104  pwg_query($query);
     
    107115;';
    108116  pwg_query($query);
     117
     118  $conf['Stuffs'] = array('level_perm' => false);
     119
     120  $query = 'SELECT id
     121FROM '.$prefixeTable.'stuffs
     122WHERE users <> "guest,generic,normal,admin,webmaster"
     123;';
     124  $ids = array_from_query($query, 'id');
     125  $conf['Stuffs']['user_perm'] = !empty($ids);
     126
     127  $query = 'SELECT id
     128FROM '.$prefixeTable.'stuffs
     129WHERE groups IS NOT NULL
     130;';
     131  $ids = array_from_query($query, 'id');
     132  $conf['Stuffs']['group_perm'] = !empty($ids);
     133
     134  $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
     135VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($conf['Stuffs'])).'" , "PWG Stuffs configuration");';
     136  pwg_query($query); 
    109137}
    110138
    111 $query = '
    112 UPDATE ' . PLUGINS_TABLE . '
    113 SET version=\''.STUFFS_VERSION.'\'
    114 WHERE id=\'PWG_Stuffs\'';
    115 pwg_query($query);
    116 
    117139?>
Note: See TracChangeset for help on using the changeset viewer.