Changeset 5328


Ignore:
Timestamp:
Mar 25, 2010, 12:24:01 AM (11 years ago)
Author:
patdenice
Message:

Feature 1533: admincan activate/deactivate user customization.

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r5304 r5328  
    5252    'rate_anonymous',
    5353    'email_admin_on_new_user',
     54    'allow_user_customization',
    5455   );
    5556
  • trunk/admin/themes/default/template/configuration.tpl

    r5304 r5328  
    6565        <span class="property">{'Allow user registration'|@translate}</span>
    6666        <input type="checkbox" name="allow_user_registration" {if ($main.allow_user_registration)}checked="checked"{/if}>
     67      </label>
     68    </li>
     69
     70    <li>
     71      <label>
     72        <span class="property">{'Allow user customization'|@translate}</span>
     73        <input type="checkbox" name="allow_user_customization" {if ($main.allow_user_customization)}checked="checked"{/if}>
    6774      </label>
    6875    </li>
  • trunk/install/config.sql

    r5304 r5328  
    1818INSERT INTO piwigo_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');
    1919INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?');
     20INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_customization','true','allow users to customize their gallery?');
    2021INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail');
    2122INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
  • trunk/language/en_UK/admin.lang.php

    r5304 r5328  
    750750$lang['Activate field "%s"'] = 'Activate field "%s"';
    751751$lang['Photo Properties'] = 'Photo Properties';
     752$lang['Allow user customization'] = 'Allow user customization';
    752753?>
  • trunk/language/fr_FR/common.lang.php

    r5316 r5328  
    388388$lang['validate this comment'] = 'valider ce commentaire';
    389389$lang['(!) This comment requires validation'] = '(!) Ce commentaire requiert une validation';
     390$lang['Allow user customization'] = "Permettre la personnalisation de l'affichage";
    390391?>
  • trunk/profile.php

    r5206 r5328  
    105105  }
    106106
    107   $int_pattern = '/^\d+$/';
    108   if (empty($_POST['nb_image_line'])
    109       or (!preg_match($int_pattern, $_POST['nb_image_line'])))
    110   {
    111     $errors[] = l10n('The number of images per row must be a not null scalar');
    112   }
    113 
    114   if (empty($_POST['nb_line_page'])
    115       or (!preg_match($int_pattern, $_POST['nb_line_page'])))
    116   {
    117     $errors[] = l10n('The number of rows per page must be a not null scalar');
    118   }
    119 
    120   if ($_POST['maxwidth'] != ''
    121       and (!preg_match($int_pattern, $_POST['maxwidth'])
    122            or $_POST['maxwidth'] < 50))
    123   {
    124     $errors[] = l10n('Maximum width must be a number superior to 50');
    125   }
    126   if ($_POST['maxheight']
    127        and (!preg_match($int_pattern, $_POST['maxheight'])
    128              or $_POST['maxheight'] < 50))
    129   {
    130     $errors[] = l10n('Maximum height must be a number superior to 50');
    131   }
    132   // periods must be integer values, they represents number of days
    133   if (!preg_match($int_pattern, $_POST['recent_period'])
    134       or $_POST['recent_period'] <= 0)
    135   {
    136     $errors[] = l10n('Recent period must be a positive integer value') ;
     107  if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
     108  {
     109    $int_pattern = '/^\d+$/';
     110    if (empty($_POST['nb_image_line'])
     111        or (!preg_match($int_pattern, $_POST['nb_image_line'])))
     112    {
     113      $errors[] = l10n('The number of images per row must be a not null scalar');
     114    }
     115
     116    if (empty($_POST['nb_line_page'])
     117        or (!preg_match($int_pattern, $_POST['nb_line_page'])))
     118    {
     119      $errors[] = l10n('The number of rows per page must be a not null scalar');
     120    }
     121
     122    if ($_POST['maxwidth'] != ''
     123        and (!preg_match($int_pattern, $_POST['maxwidth'])
     124             or $_POST['maxwidth'] < 50))
     125    {
     126      $errors[] = l10n('Maximum width must be a number superior to 50');
     127    }
     128    if ($_POST['maxheight']
     129         and (!preg_match($int_pattern, $_POST['maxheight'])
     130               or $_POST['maxheight'] < 50))
     131    {
     132      $errors[] = l10n('Maximum height must be a number superior to 50');
     133    }
     134    // periods must be integer values, they represents number of days
     135    if (!preg_match($int_pattern, $_POST['recent_period'])
     136        or $_POST['recent_period'] <= 0)
     137    {
     138      $errors[] = l10n('Recent period must be a positive integer value') ;
     139    }
    137140  }
    138141
     
    200203    }
    201204
    202     // update user "additional" informations (specific to Piwigo)
    203     $fields = array(
    204       'nb_image_line', 'nb_line_page', 'language', 'maxwidth', 'maxheight',
    205       'expand', 'show_nb_comments', 'show_nb_hits', 'recent_period', 'theme'
    206       );
    207 
    208     $data = array();
    209     $data['user_id'] = $userdata['id'];
    210 
    211     foreach ($fields as $field)
    212     {
    213       if (isset($_POST[$field]))
     205    if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
     206    {
     207      // update user "additional" informations (specific to Piwigo)
     208      $fields = array(
     209        'nb_image_line', 'nb_line_page', 'language', 'maxwidth', 'maxheight',
     210        'expand', 'show_nb_comments', 'show_nb_hits', 'recent_period', 'theme'
     211        );
     212
     213      $data = array();
     214      $data['user_id'] = $userdata['id'];
     215
     216      foreach ($fields as $field)
    214217      {
    215         $data[$field] = $_POST[$field];
     218        if (isset($_POST[$field]))
     219        {
     220          $data[$field] = $_POST[$field];
     221        }
    216222      }
    217     }
    218     mass_updates(USER_INFOS_TABLE,
    219                  array('primary' => array('user_id'), 'update' => $fields),
    220                  array($data));
    221 
     223      mass_updates(USER_INFOS_TABLE,
     224                   array('primary' => array('user_id'), 'update' => $fields),
     225                   array($data));
     226    }
    222227    trigger_action( 'save_profile_from_post', $userdata['id'] );
    223228
     
    246251      'USERNAME'=>stripslashes($userdata['username']),
    247252      'EMAIL'=>get_email_address_as_display_text(@$userdata['email']),
     253      'ALLOW_USER_CUSTOMIZATION'=>$conf['allow_user_customization'],
    248254      'NB_IMAGE_LINE'=>$userdata['nb_image_line'],
    249255      'NB_ROW_PAGE'=>$userdata['nb_line_page'],
  • trunk/themes/default/template/profile_content.tpl

    r5123 r5328  
    4040  </fieldset>
    4141
     42{if $ALLOW_USER_CUSTOMIZATION}
    4243  <fieldset>
    4344    <legend>{'Preferences'|@translate}</legend>
     
    100101    </ul>
    101102  </fieldset>
     103{/if}
    102104
    103105  <p class="bottomButtons">
Note: See TracChangeset for help on using the changeset viewer.