Changeset 849


Ignore:
Timestamp:
Aug 25, 2005, 12:22:29 AM (19 years ago)
Author:
plg
Message:
  • deletion : no mail notification anymore. Feature replaced by RSS feed notification.
  • improvement : on waiting pictures management. Ability to validate all or reject all in one clic.
  • regrouped fields in admin/update
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r792 r849  
    165165    $history_yes = ($conf['log']=='true')?'checked="checked"':'';
    166166    $history_no  = ($conf['log']=='false')?'checked="checked"':'';
    167     $notif_yes = ($conf['mail_notification']=='true')?'checked="checked"':'';
    168     $notif_no = ($conf['mail_notification']=='false')?'checked="checked"':'';
    169167    $lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
    170168    $lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':'';
     
    180178        'L_CONF_HISTORY'=>$lang['history'],
    181179        'L_CONF_HISTORY_INFO'=>$lang['conf_log_info'],
    182         'L_CONF_NOTIFICATION'=>$lang['conf_notification'],
    183         'L_CONF_NOTIFICATION_INFO'=>$lang['conf_notification_info'],
    184180        'L_CONF_GALLERY_LOCKED'=>$lang['conf_gallery_locked'],
    185181        'L_CONF_GALLERY_LOCKED_INFO'=>$lang['conf_gallery_locked_info'],
     
    189185        'HISTORY_YES'=>$history_yes,
    190186        'HISTORY_NO'=>$history_no,
    191         'NOTIFICATION_YES'=>$notif_yes,
    192         'NOTIFICATION_NO'=>$notif_no,
    193187        'GALLERY_LOCKED_YES'=>$lock_yes,
    194188        'GALLERY_LOCKED_NO'=>$lock_no,
  • trunk/admin/waiting.php

    r792 r849  
    3131include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
    3232//--------------------------------------------------------------------- updates
    33 if ( isset( $_POST['submit'] ) )
     33
     34if (isset($_POST))
    3435{
    35   $query = 'SELECT * FROM '.WAITING_TABLE;
    36   $query.= " WHERE validated = 'false';";
    37   $result = pwg_query( $query );
    38   while ( $row = mysql_fetch_array( $result ) )
    39   {
    40     $key = 'validate-'.$row['id'];
    41     if ( isset( $_POST[$key] ) )
     36  $to_validate = array();
     37  $to_reject = array();
     38 
     39  if (isset($_POST['submit']))
     40  {   
     41    foreach (explode(',', $_POST['list']) as $waiting_id)
    4242    {
    43       if ( $_POST[$key] == 'true' )
     43      if (isset($_POST['action-'.$waiting_id]))
    4444      {
    45         // The uploaded element was validated, we have to set the
    46         // "validated" field to "true"
    47         $query = 'UPDATE '.WAITING_TABLE;
    48         $query.= " SET validated = 'true'";
    49         $query.= ' WHERE id = '.$row['id'];
    50         $query.= ';';
    51         pwg_query( $query );
    52       }
    53       else
    54       {
    55         // The uploaded element was refused, we have to delete its reference
    56         // in the database and to delete the element as well.
    57         $query = 'DELETE FROM '.WAITING_TABLE;
    58         $query.= ' WHERE id = '.$row['id'];
    59         $query.= ';';
    60         pwg_query( $query );
    61         // deletion of the associated files
    62         $dir = get_complete_dir( $row['storage_category_id'] );
    63         unlink( $dir.$row['file'] );
    64         if (isset($row['tn_ext']) and $row['tn_ext'] != '' )
     45        switch ($_POST['action-'.$waiting_id])
    6546        {
    66           $thumbnail = $conf['prefix_thumbnail'];
    67           $thumbnail.= get_filename_wo_extension( $row['file'] );
    68           $thumbnail.= '.'.$row['tn_ext'];
    69           $url = $dir.'thumbnail/'.$thumbnail;
    70           unlink( $url );
     47          case 'reject' :
     48          {
     49            array_push($to_reject, $waiting_id);
     50            break;
     51          }
     52          case 'validate' :
     53          {
     54            array_push($to_validate, $waiting_id);
     55            break;
     56          }
    7157        }
    7258      }
    7359    }
    7460  }
    75   array_push($infos, $lang['waiting_update']);
     61  else if (isset($_POST['validate-all']))
     62  {
     63    $to_validate = explode(',', $_POST['list']);
     64  }
     65  else if (isset($_POST['reject-all']))
     66  {
     67    $to_reject = explode(',', $_POST['list']);
     68  }
     69
     70  if (count($to_validate) > 0)
     71  {
     72    $query = '
     73UPDATE '.WAITING_TABLE.'
     74  SET validated = \'true\'
     75  WHERE id IN ('.implode(',', $to_validate).')
     76;';
     77    pwg_query($query);
     78
     79    array_push(
     80      $page['infos'],
     81      sprintf(
     82        l10n('%d waiting pictures validated'),
     83        count($to_validate)
     84        )
     85      );
     86  }
     87
     88  if (count($to_reject) > 0)
     89  {
     90    // The uploaded element was refused, we have to delete its reference in
     91    // the database and to delete the element as well.
     92    $query = '
     93SELECT id, storage_category_id, file, tn_ext
     94  FROM '.WAITING_TABLE.'
     95  WHERE id IN ('.implode(',', $to_reject).')
     96;';
     97    $result = pwg_query($query);
     98    while($row = mysql_fetch_array($result))
     99    {
     100      $dir = get_complete_dir($row['storage_category_id']);
     101      unlink($dir.$row['file']);
     102      if (isset($row['tn_ext']) and $row['tn_ext'] != '')
     103      {
     104        unlink(
     105          get_thumbnail_src(
     106            $dir.$row['file'],
     107            $row['tn_ext']
     108            )
     109          );
     110      }
     111      else if (@is_file(get_thumbnail_src($dir.$row['file'], 'jpg')))
     112      {
     113        unlink(
     114          get_thumbnail_src(
     115            $dir.$row['file'],
     116            'jpg'
     117            )
     118          );
     119      }
     120    }
     121   
     122    $query = '
     123DELETE
     124  FROM '.WAITING_TABLE.'
     125  WHERE id IN ('.implode(',', $to_reject).')
     126;';
     127    pwg_query($query);
     128
     129    array_push(
     130      $page['infos'],
     131      sprintf(
     132        l10n('%d waiting pictures rejected'),
     133        count($to_reject)
     134        )
     135      );
     136  }
    76137}
    77138
     
    93154//---------------------------------------------------------------- form display
    94155$cat_names = array();
     156$list = array();
     157
    95158$query = 'SELECT * FROM '.WAITING_TABLE;
    96159$query.= " WHERE validated = 'false'";
     
    114177  if ( $i++ % 2== 0 ) $class='row2';
    115178 
    116   $template->assign_block_vars('picture' ,array(
    117     'WAITING_CLASS'=>$class,
    118     'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'],
    119     'ID_IMG'=>$row['id'],
    120         'DATE_IMG'=>format_date( $row['date'], 'unix', true ),
    121         'FILE_IMG'=>$row['file'],
    122         'PREVIEW_URL_IMG'=>$preview_url,
    123         'UPLOAD_EMAIL'=>$row['mail_address'],
    124         'UPLOAD_USERNAME'=>$row['username']
    125         ));
     179  $template->assign_block_vars(
     180    'picture',
     181    array(
     182      'WAITING_CLASS'=>$class,
     183      'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'],
     184      'ID_IMG'=>$row['id'],
     185      'DATE_IMG' => date('Y-m-d H:i:s', $row['date']),
     186      'FILE_TITLE'=>$row['file'],
     187      'FILE_IMG' =>
     188        (strlen($row['file']) > 10) ?
     189          (substr($row['file'], 0, 10)).'...' : $row['file'],
     190      'PREVIEW_URL_IMG'=>$preview_url,
     191      'UPLOAD_EMAIL'=>$row['mail_address'],
     192      'UPLOAD_USERNAME'=>$row['username']
     193      )
     194    );
    126195
    127196  // is there an existing associated thumnail ?
     
    134203    $url.= 'thumbnail/'.$thumbnail;
    135204       
    136     $template->assign_block_vars('picture.thumbnail' ,array(
    137           'PREVIEW_URL_TN_IMG'=>$url,
    138           'FILE_TN_IMG'=>$thumbnail
    139           ));
    140   }
     205    $template->assign_block_vars(
     206      'picture.thumbnail',
     207      array(
     208        'PREVIEW_URL_TN_IMG' => $url,
     209        'FILE_TN_IMG' =>
     210          (strlen($thumbnail) > 10) ?
     211            (substr($thumbnail, 0, 10)).'...' : $thumbnail,
     212        'FILE_TN_TITLE' => $thumbnail
     213        )
     214      );
     215  }
     216
     217  array_push($list, $row['id']);
    141218}
     219
     220$template->assign_vars(
     221  array(
     222    'LIST' => implode(',', $list)
     223    )
     224  );
     225 
    142226//----------------------------------------------------------- sending html code
    143227$template->assign_var_from_handle('ADMIN_CONTENT', 'waiting');
  • trunk/doc/ChangeLog

    r848 r849  
     12005-08-25 Pierrick LE GALL
     2
     3        * deletion : no mail notification anymore. Feature replaced by RSS
     4        feed notification.
     5
     6        * improvement : on waiting pictures management. Ability to
     7        validate all or reject all in one clic.
     8
    192005-08-21 Pierrick LE GALL
    210
  • trunk/include/functions.inc.php

    r808 r849  
    434434}
    435435
    436 // notify sends a email to every admin of the gallery
    437 function notify( $type, $infos = '' )
    438 {
    439   global $conf;
    440 
    441   $headers = 'From: <'.$conf['mail_webmaster'].'>'."\n";
    442   $headers.= 'Reply-To: '.$conf['mail_webmaster']."\n";
    443   $headers.= 'X-Mailer: PhpWebGallery, PHP '.phpversion();
    444 
    445   $options = '-f '.$conf['mail_webmaster'];
    446   // retrieving all administrators
    447   $query = 'SELECT username,mail_address,language';
    448   $query.= ' FROM '.USERS_TABLE;
    449   $query.= " WHERE status = 'admin'";
    450   $query.= ' AND mail_address IS NOT NULL';
    451   $query.= ';';
    452   $result = pwg_query( $query );
    453   while ( $row = mysql_fetch_array( $result ) )
    454   {
    455     $to = $row['mail_address'];
    456     include( PHPWG_ROOT_PATH.'language/'.$row['language'].'/common.lang.php' );
    457     $content = $lang['mail_hello']."\n\n";
    458     switch ( $type )
    459     {
    460     case 'upload' :
    461       $subject = $lang['mail_new_upload_subject'];
    462       $content.= $lang['mail_new_upload_content'];
    463       break;
    464     case 'comment' :
    465       $subject = $lang['mail_new_comment_subject'];
    466       $content.= $lang['mail_new_comment_content'];
    467       break;
    468     }
    469     $infos = str_replace( '&nbsp;',  ' ', $infos );
    470     $infos = str_replace( '&minus;', '-', $infos );
    471     $content.= "\n\n".$infos;
    472     $content.= "\n\n-- \nPhpWebGallery ".PHPWG_VERSION;
    473     $content = wordwrap( $content, 72 );
    474     @mail( $to, $subject, $content, $headers, $options );
    475   }
    476 }
    477 
    478436function pwg_write_debug()
    479437{
  • trunk/install/config.sql

    r701 r849  
    1616INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('comments_validation','false','administrators validate users comments before becoming visible');
    1717INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('comments_forall','false','even guest not registered can post comments');
    18 INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('mail_notification','false','automated mail notification for adminsitrators');
    1918INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nb_image_line','5','Number of images displayed per row');
    2019INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nb_line_page','3','Number of rows displayed per page');
  • trunk/picture.php

    r847 r849  
    388388      $template->assign_block_vars('information',
    389389                                   array('INFORMATION'=>$message));
    390       // notification to the administrators
    391       if ( $conf['mail_notification'] )
    392       {
    393         // find any related category (can be unreachable to this admin)
    394         $category = $related_categories[0];
    395         // locally, we change the $conf['level_separator']
    396         $conf_separator = $conf['level_separator'];
    397         $conf['level_separator'] = ' > ';
    398         $cat_name = get_cat_display_name_cache($category['uppercats'],
    399                                                '',
    400                                                false);
    401         $conf['level_separator'] = $conf_separator;
    402        
    403         $cat_name = strip_tags( $cat_name );
    404         notify( 'comment', $cat_name.' > '.$picture['current']['name']);
    405       }
    406390    }
    407391    else
  • trunk/template/cclear/admin/configuration.tpl

    r841 r849  
    2323        <td class="row1"><input type="radio" class="radio" name="log" value="true" {general.HISTORY_YES} />{L_YES}&nbsp;&nbsp;
    2424        <input type="radio" class="radio" name="log" value="false" {general.HISTORY_NO} />{L_NO}</td>
    25   </tr>
    26   <tr>
    27     <td><strong>{general.L_CONF_NOTIFICATION}&nbsp;:</strong><br /><span class="small">{general.L_CONF_NOTIFICATION_INFO}</span></td>
    28         <td class="row1"><input type="radio" class="radio" name="mail_notification" value="true" {general.NOTIFICATION_YES} />{L_YES}&nbsp;&nbsp;
    29         <input type="radio" class="radio" name="mail_notification" value="false" {general.NOTIFICATION_NO} />{L_NO}</td>
    3025  </tr>
    3126  <tr>
  • trunk/template/cclear/admin/update.tpl

    r841 r849  
    1212  <li class="update_summary_err">{update.NB_ERRORS} {L_UPDATE_NB_ERRORS}</li>
    1313</ul>
    14 <!-- BEGIN errors -->
     14<!-- BEGIN update_errors -->
    1515<h3>{L_UPDATE_ERROR_LIST_TITLE}</h3>
    1616<ul>
    17   <!-- BEGIN error -->
    18   <li>[{update.errors.error.ELEMENT}] {update.errors.error.LABEL}</li>
    19   <!-- END error -->
     17  <!-- BEGIN update_error -->
     18  <li>[{update.update_errors.update_error.ELEMENT}] {update.update_errors.update_error.LABEL}</li>
     19  <!-- END update_error -->
    2020</ul>
    2121<h3>{L_UPDATE_ERRORS_CAPTION}</h3>
     
    2424  <li><strong>PWG-UPDATE-2</strong> : {L_UPDATE_MISSING_TN_INFO} {{PICTURE_EXT_LIST}}</li>
    2525</ul>
    26 <!-- END errors -->
    27 <!-- BEGIN infos -->
     26<!-- END update_errors -->
     27<!-- BEGIN update_infos -->
    2828<h3>{L_UPDATE_INFOS_TITLE}</h3>
    2929<ul>
    30   <!-- BEGIN info -->
    31   <li>[{update.infos.info.ELEMENT}] {update.infos.info.LABEL}</li>
    32   <!-- END info -->
     30  <!-- BEGIN update_info -->
     31  <li>[{update.update_infos.update_info.ELEMENT}] {update.update_infos.update_info.LABEL}</li>
     32  <!-- END update_info -->
    3333</ul>
    34 <!-- END infos -->
     34<!-- END update_infos -->
    3535<!-- END update -->
    3636
     
    4646<h3>{L_UPDATE_TITLE}</h3>
    4747<form action="{F_ACTION}" method="post" id="update">
    48   <ul>
    49     <li>
    50       {L_UPDATE_SYNC_FILES}
    51       <ul>
    52         <li><input type="radio" name="sync" value="dirs" {SYNC_DIRS_CHECKED} /> {L_UPDATE_SYNC_DIRS}</li>
    53         <li><input type="radio" name="sync" value="files" {SYNC_ALL_CHECKED} /> {L_UPDATE_SYNC_ALL}</li>
    54         <li><input type="checkbox" name="display_info" value="1" {DISPLAY_INFO_CHECKED} /> {L_UPDATE_DISPLAY_INFO}</li>
    55         <li><input type="checkbox" name="simulate" value="1" checked="checked" /> {L_UPDATE_SIMULATE}</li>
    56       </ul>
    57     </li>
    58     <li>
    59       {L_UPDATE_SYNC_METADATA}. {L_USED_METADATA} : {METADATA_LIST}.
    60       <ul>
    61         <li><input type="radio" name="sync" value="metadata_new" /> {L_UPDATE_SYNC_METADATA_NEW}</li>
    62         <li><input type="radio" name="sync" value="metadata_all" /> {L_UPDATE_SYNC_METADATA_ALL}</li>
    63       </ul>
    64     </li>
    65     <li>
    66       {L_UPDATE_CATS_SUBSET}<br />
    67       <select style="width:500px" name="cat" size="10">
    68         <!-- BEGIN category_option -->
    69         <option {introduction.category_option.SELECTED} value="{introduction.category_option.VALUE}">{introduction.category_option.OPTION}</option>
    70         <!-- END category_option -->
    71       </select>
    72       <input type="checkbox" name="subcats-included" value="1" {SUBCATS_INCLUDED_CHECKED} /> {L_SEARCH_SUBCATS_INCLUDED}
    73     </li>
    74   </ul>
    75   <p>
     48
     49  <fieldset>
     50    <legend>{L_UPDATE_SYNC_FILES}</legend>
     51
     52    <ul>
     53      <li><label><input type="radio" name="sync" value="dirs" {SYNC_DIRS_CHECKED} /> {L_UPDATE_SYNC_DIRS}</label></li>
     54      <li><label><input type="radio" name="sync" value="files" {SYNC_ALL_CHECKED} /> {L_UPDATE_SYNC_ALL}</label></li>
     55      <li><label><input type="checkbox" name="display_info" value="1" {DISPLAY_INFO_CHECKED} /> {L_UPDATE_DISPLAY_INFO}</label></li>
     56      <li><label><input type="checkbox" name="simulate" value="1" checked="checked" /> {L_UPDATE_SIMULATE}</label></li>
     57    </ul>
     58  </fieldset>
     59
     60  <fieldset>
     61    <legend>{L_UPDATE_SYNC_METADATA}</legend>
     62    <p> {L_USED_METADATA} : {METADATA_LIST}.</p>
     63    <ul>
     64      <li><label><input type="radio" name="sync" value="metadata_new" /> {L_UPDATE_SYNC_METADATA_NEW}</label></li>
     65      <li><label><input type="radio" name="sync" value="metadata_all" /> {L_UPDATE_SYNC_METADATA_ALL}</label></li>
     66    </ul>
     67  </fieldset>
     68 
     69  <fieldset>
     70    <legend>{L_UPDATE_CATS_SUBSET}</legend>
     71 
     72    <select style="width:500px" name="cat" size="10">
     73      <!-- BEGIN category_option -->
     74      <option {introduction.category_option.SELECTED} value="{introduction.category_option.VALUE}">{introduction.category_option.OPTION}</option>
     75      <!-- END category_option -->
     76    </select>
     77 
     78    <label><input type="checkbox" name="subcats-included" value="1" {SUBCATS_INCLUDED_CHECKED} /> {L_SEARCH_SUBCATS_INCLUDED}</label>
     79  </fieldset>
     80
     81  <p class="bottomButtons">
    7682    <input type="submit" value="{L_SUBMIT}" name="submit" class="bouton" />
    7783    <input type="reset"  value="{L_RESET}"  name="reset"  class="bouton" />
    7884  </p>
     85
    7986</form>
    8087<!-- END introduction -->
  • trunk/template/cclear/admin/waiting.tpl

    r841 r849  
    33
    44<form action="{F_ACTION}" method="post" id="waiting">
     5
     6  <input type="hidden" name="list" value="{LIST}" />
     7
    58  <table style="width:100%;" >
    69    <tr class="throw">
     
    1720      <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">{picture.DATE_IMG}</td>
    1821      <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">
    19         <a target="_blank" href="{picture.PREVIEW_URL_IMG}">{picture.FILE_IMG}</a>
     22        <a target="_blank" href="{picture.PREVIEW_URL_IMG}" title="{picture.FILE_TITLE}">{picture.FILE_IMG}</a>
    2023      </td>
    2124      <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">
    2225        <!-- BEGIN thumbnail -->
    23         <a target="_blank" href="{picture.thumbnail.PREVIEW_URL_TN_IMG}">{picture.thumbnail.FILE_TN_IMG}</a>
     26        <a target="_blank" href="{picture.thumbnail.PREVIEW_URL_TN_IMG}" title="{picture.thumbnail.FILE_TN_TITLE}">{picture.thumbnail.FILE_TN_IMG}</a>
    2427        <!-- END thumbnail -->
    2528      </td>
     
    2831      </td>
    2932      <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">
    30         <input type="radio" name="validate-{picture.ID_IMG}" value="true" />{L_SUBMIT}
    31         <input type="radio" name="validate-{picture.ID_IMG}" value="false" />{L_DELETE}
     33        <label><input type="radio" name="action-{picture.ID_IMG}" value="validate" /> {lang:Validate}</label>
     34        <label><input type="radio" name="action-{picture.ID_IMG}" value="reject" /> {lang:Reject}</label>
    3235      </td>
    3336    </tr>
    3437    <!-- END picture -->
    3538  </table>
    36   <p>
    37     <input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" />
    38     <input type="reset" name="reset" value="{L_RESET}" class="bouton" />
     39
     40  <p class="bottomButtons">
     41    <input type="submit" name="submit" value="{lang:Submit}" />
     42    <input type="submit" name="validate-all" value="{lang:Validate All}" />
     43    <input type="submit" name="reject-all" value="{lang:Reject All}" />
     44    <input type="reset" value="{lang:Reset}" />
    3945  </p>
     46
    4047</form>
  • trunk/upload.php

    r688 r849  
    213213    pwg_query( $query );
    214214    $page['waiting_id'] = mysql_insert_id();
    215     // mail notification for administrators
    216     if ( $conf['mail_notification'] )
    217     {
    218       notify( 'upload' );
    219     }
    220215  }
    221216}
     
    277272
    278273$username = !empty($_POST['username'])?$_POST['username']:$user['username'];
    279 $mail_address = !empty($_POST['mail_address'])?$_POST['mail_address']:$user['mail_address'];
     274$mail_address = !empty($_POST['mail_address'])?$_POST['mail_address']:@$user['mail_address'];
    280275$name = !empty($_POST['name'])?$_POST['name']:'';
    281276$author = !empty($_POST['author'])?$_POST['author']:'';
Note: See TracChangeset for help on using the changeset viewer.