Changeset 5328 for trunk/profile.php


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

Feature 1533: admincan activate/deactivate user customization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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'],
Note: See TracChangeset for help on using the changeset viewer.