Changeset 7540 for extensions/PWG_Stuffs


Ignore:
Timestamp:
Nov 1, 2010, 3:16:26 PM (14 years ago)
Author:
patdenice
Message:

Main block can be hidden according to user status or user group.

Location:
extensions/PWG_Stuffs
Files:
5 edited

Legend:

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

    r6230 r7540  
    99load_language('plugin.lang', STUFFS_PATH);
    1010
    11 if (!isset($_GET['type']) or !is_dir(STUFFS_PATH . 'modules/' . $_GET['type']))
     11if (!isset($_GET['type']) or ($_GET['type'] != 'MainBlock' and !is_dir(STUFFS_PATH . 'modules/' . $_GET['type'])))
    1212{
    1313  die('Wrong parameters...');
     
    2424if (isset($_POST['submit']) and !is_adviser())
    2525{
    26   include(STUFFS_PATH . 'modules/' . $type . '/config.inc.php');
     26  @include(STUFFS_PATH . 'modules/' . $type . '/config.inc.php');
    2727  if (empty($page['errors']))
    2828  {
     29    if ($type == 'MainBlock')
     30    {
     31      $_POST['module_name'] = 'MainBlock';
     32      $_POST['show_title'] = true;
     33      $_POST['on_home'] = true;
     34      $_POST['on_cats'] = true;
     35      $_POST['on_picture'] = true;
     36    }
    2937    if (empty($_POST['module_name']))
    3038    {
     
    105113  $template->assign(array(
    106114    'STUFFS_TITLE' => l10n('stuffs_edit_mod') . ' <i>' . trigger_event('render_stuffs_name', $module['name']) . '</i>',
     115    'MODULE_ID' => $_GET['edit'],
    107116    'MODULE_NAME' => $module['name'],
    108117    'DESC_VALUE' => (isset($module['descr']) ? $module['descr'] : ''),
     
    139148
    140149// Configuration du module
    141 include_once(STUFFS_PATH . 'modules/' . $type . '/config.inc.php');
     150@include_once(STUFFS_PATH . 'modules/' . $type . '/config.inc.php');
    142151
    143152$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/add_module.tpl'));
  • extensions/PWG_Stuffs/admin/manage.php

    r7340 r7540  
    1919  }
    2020
    21     pwg_query('
    22 UPDATE ' . STUFFS_TABLE . '
    23 SET datas = "'.addslashes(serialize(array('hide' => isset($_POST['hidemb'])))).'"
    24 WHERE id=0;');
    25 
    2621  array_push($page['infos'], l10n('stuffs_order_saved'));
    2722}
    2823
    2924// Affichage des modules et de leur position
    30 $q = 'SELECT id, name, descr, type, id_line, width, datas
     25$q = 'SELECT id, name, descr, type, id_line, width
    3126FROM ' . STUFFS_TABLE . '
    3227ORDER BY pos ASC;';
     
    6459                'ID' => $module['id'],
    6560    'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . STUFFS_DIR . '%2Fadmin%2Fadd_module.php&amp;type=' . $module['type'] . '&amp;edit=' . $module['id'],
    66     'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php&amp;del=' . $module['id'] : '',
     61    'U_DELETE' => !is_adviser() and $module['id'] != 0 ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php&amp;del=' . $module['id'] : '',
    6762  ));
    68 
    69   if ($module['type'] == 'MainBlock' and !empty($module['datas']))
    70   {
    71     $datas = unserialize($module['datas']);
    72     $template->assign('HIDEMB', $datas['hide']);
    73   }
    7463}
    7564
  • extensions/PWG_Stuffs/admin/template/add_module.tpl

    r3609 r7540  
    1111<fieldset>
    1212        <legend>{'stuffs_module_config'|@translate}</legend>
     13  {if $MODULE_ID == 0}<p>{'This module can be hidden only on homepage'|@translate}</p>{/if}
    1314        <table>
    1415
    1516                <tr><td colspan="3"><br></td></tr>
    1617
     18    {if $MODULE_ID != 0}
    1719                <tr>
    1820                        <td><b>{'stuffs_module_title'|@translate}&nbsp;&nbsp;</b></td>
     
    3032                        <td colspan="2">{'stuffs_only_for_admin'|@translate}</td>
    3133                </tr>
     34    {/if}
    3235
    3336                <tr><td colspan="3"><br></td></tr>
     
    6164</fieldset>
    6265
     66{if $MODULE_ID != 0}
    6367<fieldset>
    6468        <legend>{'stuffs_visual_config'|@translate}</legend>
     
    8185                <tr><td colspan="2"><br></td></tr>
    8286        </table>
    83 
    84 
    8587</fieldset>
    8688
     
    8991        {$MODULE_OPTIONS}
    9092</fieldset>
     93{/if}
    9194<p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$TAG_INPUT_ENABLED}/></p>
    9295</form>
  • extensions/PWG_Stuffs/admin/template/manage.tpl

    r7340 r7540  
    5151
    5252    <li class="categoryLi virtual_cat" id="module_{$module.ID}">
    53       {if $module.TYPE != 'MainBlock'}
    5453      <ul class="categoryActions">
     54        {if $module.TYPE != 'MainBlock'}
    5555        <li class="stuffs_line">
    5656          {'stuffs_id_ligne'|@translate}&nbsp;
     
    6363          <input type="text" size="2" maxlength="2" value="{$module.WIDTH}" name="width[{$module.ID}]" > %
    6464        </li>
     65        {/if}
    6566        <li><a href="{$module.U_EDIT}" title="{'stuffs_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'stuffs_edit'|@translate}"/></a></li>
    6667        {if !empty($module.U_DELETE) }
     
    6869        {/if}
    6970      </ul>
    70       {/if}
    7171
    7272      <p>
     
    7878      {if !empty($module.DESC)}
    7979        <p style="margin-left: 30px;"><i>{$module.DESC}</i></p>
    80       {elseif $module.TYPE == 'MainBlock'}
    81         <p style="margin-left: 30px;"><input name="hidemb" type="checkbox" {if $HIDEMB}checked="checked"{/if}> &nbsp;{'Hide on home page'|@translate}</p>
    8280      {/if}
    8381
  • extensions/PWG_Stuffs/include/class.inc.php

    r7402 r7540  
    5454    else return;
    5555
     56    if (!$page['is_homepage'])
     57    {
     58      $query .= ' OR id = 0';
     59    }
     60
    5661    $query .= '
    5762ORDER BY pos ASC;';
     
    7378      {
    7479                $this->pos = 'end';
    75         if (!empty($module['datas'])
    76           and $datas = unserialize($module['datas'])
    77           and $datas['hide'])
    78         {
    79           add_event_handler('loc_end_index', 'hide_main_block');
    80         }
    8180                continue;
    8281        }
     
    103102      $block['TEMPLATE'] = 'stuffs_'.strtolower($module['type']).'.tpl';
    104103        $this->set_tpl_block($block, $module);
     104    }
     105    if ($this->pos == 'begin')
     106    {
     107      add_event_handler('loc_end_index', 'hide_main_block');
    105108    }
    106109  }
Note: See TracChangeset for help on using the changeset viewer.