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

Add display option. Optimizations.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.