Changeset 85


Ignore:
Timestamp:
Sep 11, 2003, 12:24:03 AM (21 years ago)
Author:
z0rglub
Message:

Mail notification for admins

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r61 r85  
    4444       'upload_maxfilesize', 'upload_maxwidth','upload_maxheight',
    4545       'upload_maxwidth_thumbnail','upload_maxheight_thumbnail','log',
    46        'comments_validation','comments_forall','authorize_cookies' );
     46       'comments_validation','comments_forall','authorize_cookies',
     47       'mail_notification' );
    4748$default_user_infos =
    4849array( 'nb_image_line','nb_line_page','language','maxwidth',
     
    404405$vtp->closeSession( $sub, 'param_line' );
    405406$vtp->closeSession( $sub, 'line' );
     407// mail notification for admins
     408$vtp->addSession( $sub, 'line' );
     409$vtp->addSession( $sub, 'param_line' );
     410$vtp->setVar( $sub, 'param_line.name',
     411              $lang['conf_general_mail_notification'] );
     412$vtp->addSession( $sub, 'group' );
     413$vtp->addSession( $sub, 'radio' );
     414$vtp->setVar( $sub, 'radio.name', 'mail_notification' );
     415$vtp->setVar( $sub, 'radio.value', 'true' );
     416$vtp->setVar( $sub, 'radio.option', $lang['yes'] );
     417$checked = '';
     418if ( $mail_notification == 'true' )
     419{
     420  $checked = ' checked="checked"';
     421}
     422$vtp->setVar( $sub, 'radio.checked', $checked );
     423$vtp->closeSession( $sub, 'radio' );
     424$vtp->addSession( $sub, 'radio' );
     425$vtp->setVar( $sub, 'radio.name', 'mail_notification' );
     426$vtp->setVar( $sub, 'radio.value', 'false' );
     427$vtp->setVar( $sub, 'radio.option', $lang['no'] );
     428$checked = '';
     429if ( $mail_notification == 'false' )
     430{
     431  $checked = ' checked="checked"';
     432}
     433$vtp->setVar( $sub, 'radio.checked', $checked );
     434$vtp->closeSession( $sub, 'radio' );
     435$vtp->closeSession( $sub, 'group' );
     436$vtp->setVar( $sub, 'param_line.def',
     437              $lang['conf_general_mail_notification_info'] );
     438$vtp->closeSession( $sub, 'param_line' );
     439$vtp->closeSession( $sub, 'line' );
    406440
    407441$vtp->addSession( $sub, 'line' );
  • trunk/include/config.inc.php

    r57 r85  
    5050$conf['picture_ext']        = array('jpg','JPG','gif','GIF','png','PNG');
    5151$conf['document_ext']       = array('doc','pdf','zip');
    52 $conf['top_number']         = 20;
     52$conf['top_number']         = 5;
    5353$conf['anti-flood_time']    = 60; // seconds between 2 comments : 0 to disable
    5454
     
    6565                'upload_maxheight', 'upload_maxwidth_thumbnail',
    6666                'upload_maxheight_thumbnail','log','comments_validation',
    67                 'comments_forall','authorize_cookies' );
     67                'comments_forall','authorize_cookies','mail_notification' );
    6868
    6969$query  = 'SELECT ';
  • trunk/include/functions.inc.php

    r61 r85  
    351351}
    352352
     353// format_date returns a formatted date for display. The date given in
     354// argument can be a unixdate (number of seconds since the 01.01.1970) or an
     355// american format (2003-09-15). By option, you can show the time. The
     356// output is internationalized.
     357//
     358// format_date( "2003-09-15", 'us', true ) -> "Monday 15 September 2003 21:52"
    353359function format_date( $date, $type = 'us', $show_time = false )
    354360{
     
    376382  return $formated_date;
    377383}
     384
     385// notify sends a email to every admin of the gallery
     386function notify( $type, $infos = '' )
     387{
     388  global $conf;
     389
     390  $headers = 'From: '.$conf['webmaster'].' <'.$conf['mail_webmaster'].'>'."\n";
     391  $headers.= 'Reply-To: '.$conf['mail_webmaster']."\n";
     392  $headers.= 'X-Mailer: PhpWebGallery, PHP '.phpversion();
     393
     394  $options = '-f '.$conf['mail_webmaster'];
     395  // retrieving all administrators
     396  $query = 'SELECT username,mail_address,language';
     397  $query.= ' FROM '.PREFIX_TABLE.'users';
     398  $query.= " WHERE status = 'admin'";
     399  $query.= ' AND mail_address IS NOT NULL';
     400  $query.= ';';
     401  $result = mysql_query( $query );
     402  while ( $row = mysql_fetch_array( $result ) )
     403  {
     404    $to = $row['mail_address'];
     405    include( PREFIX_INCLUDE.'./language/'.$row['language'].'.php' );
     406    $content = $lang['mail_hello']."\n\n";
     407    switch ( $type )
     408    {
     409    case 'upload' :
     410      $subject = $lang['mail_new_upload_subject'];
     411      $content.= $lang['mail_new_upload_content'];
     412      break;
     413    case 'comment' :
     414      $subject = $lang['mail_new_comment_subject'];
     415      $content.= $lang['mail_new_comment_content'];
     416      break;
     417    }
     418    $infos = str_replace( '&nbsp;',  ' ', $infos );
     419    $infos = str_replace( '&minus;', '-', $infos );
     420    $content.= "\n\n".$infos;
     421    $content.= "\n\n-- \nPhpWebGallery ".$conf['version'];
     422    $content = wordwrap( $content, 72 );
     423    @mail( $to, $subject, $content, $headers, $options );
     424  }
     425}
    378426?>
  • trunk/language/francais.php

    r77 r85  
    242242// end version 1.3
    243243
     244// start version 1.3
     245// mails
     246$lang['mail_hello'] = 'Bonjour,';
     247$lang['mail_new_upload_subject'] = 'Nouvelle image sur le site';
     248$lang['mail_new_upload_content'] = 'Une nouvelle image a été placée sur la galerie. Elle est en attente de validation. RDV dans la section d\'administration pour valider ou supprimer cette image.';
     249$lang['mail_new_comment_subject'] = 'Nouveau commentaire sur le site';
     250$lang['mail_new_comment_content'] = 'Un nouveau commentaire a été posté sur la galerie. Si vous avez activé la validation des commentaires, il faut d\'abord valider le commentaire dans la zone d\'administration pour le voir apparaître.'."\n\n".'Vous avez accès aux derniers commentaires dans la zone d\'administration.';
     251// end version 1.3
     252
    244253//----------------------------------administration
    245254if ( $isadmin )
     
    344353  $lang['conf_general_log'] = 'historique';
    345354  $lang['conf_general_log_info'] = 'historiser les visites sur le site ? Les visites seront visibles dans l\'historique de l\'administration';
     355  $lang['conf_general_mail_notification'] = 'Notification par mail';
     356  $lang['conf_general_mail_notification_info'] = 'Notification automatique par mail des administrateurs (seuls les administrateurs) lors de l\'ajout d\'un commentaire, ou lors de l\'ajout d\'une image.';
    346357  // end version 1.3
    347358  $lang['conf_comments'] = 'commentaires utilisateurs';
  • trunk/picture.php

    r84 r85  
    606606        $vtp->setVar( $handle, 'information.content', $message );
    607607        $vtp->closeSession( $handle, 'information' );
     608        // notification to the administrators
     609        if ( $conf['mail_notification'] )
     610        {
     611          $cat_name = get_cat_display_name( $page['cat_name'], ' > ', '' );
     612          $cat_name = strip_tags( $cat_name );
     613          if ( $page['name'] == '' ) $picture = $page['file'];
     614          else                       $picture = $page['name'];
     615          notify( 'comment', $cat_name.' > '.$picture );
     616        }
    608617      }
    609618      else
  • trunk/upload.php

    r82 r85  
    214214    mysql_query( $query );
    215215    $page['waiting_id'] = mysql_insert_id();
     216    // mail notification for administrators
     217    if ( $conf['mail_notification'] )
     218    {
     219      notify( 'comment' );
     220    }
    216221  }
    217222}
Note: See TracChangeset for help on using the changeset viewer.