Changeset 1617


Ignore:
Timestamp:
Nov 22, 2006, 5:41:25 AM (17 years ago)
Author:
rvelices
Message:

feature 440: send mail to admin when comment is entered

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r1571 r1617  
    4747  $page['section'] = $_GET['section'];
    4848}
     49
     50$general_checkboxes = array(
     51    'log',
     52    'history_admin',
     53    'history_guest',
     54    'login_history',
     55    'email_admin_on_new_user'
     56   );
     57
     58$comments_checkboxes = array(
     59    'comments_forall',
     60    'comments_validation',
     61    'email_admin_on_comment',
     62    'email_admin_on_comment_validation',
     63  );
     64
    4965//------------------------------ verification and registration of modifications
    5066if (isset($_POST['submit']) and !is_adviser())
     
    5975        array_push($page['errors'], $lang['conf_gallery_url_error']);
    6076      }
    61       $_POST['log'] = empty($_POST['log'])?'false':'true';
    62       $_POST['history_admin'] = empty($_POST['history_admin'])?'false':'true';
    63       $_POST['history_guest'] = empty($_POST['history_guest'])?'false':'true';
    64       $_POST['login_history'] = empty($_POST['login_history'])?'false':'true';
     77      foreach( $general_checkboxes as $checkbox)
     78      {
     79        $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
     80      }
    6581      break;
    6682    }
     
    7490      {
    7591        array_push($page['errors'], $lang['conf_nb_comment_page_error']);
     92      }
     93      foreach( $comments_checkboxes as $checkbox)
     94      {
     95        $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
    7696      }
    7797      break;
     
    161181    ));
    162182
     183$html_check='checked="checked"';
     184
    163185switch ($page['section'])
    164186{
    165187  case 'general' :
    166188  {
    167     $html_check='checked="checked"';
    168 
    169189    $lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
    170190    $lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':'';
    171     $history_users = ($conf['log']=='true')?$html_check:'';
    172     $history_admin = ($conf['history_admin']=='true')?$html_check:'';
    173     $history_guest = ($conf['history_guest']=='true')?$html_check:'';
    174     $login_history = ($conf['login_history']=='true')?$html_check:'';
    175191
    176192    $template->assign_block_vars(
    177193      'general',
    178194      array(
    179         'HISTORY_USERS'=>$history_users,
    180         'HISTORY_ADMIN'=>$history_admin,
    181         'HISTORY_GUEST'=>$history_guest,
    182         'LOGIN_HISTORY'=>$login_history,
    183195        'GALLERY_LOCKED_YES'=>$lock_yes,
    184196        'GALLERY_LOCKED_NO'=>$lock_no,
     
    190202        'CONF_GALLERY_URL' => $conf['gallery_url'],
    191203        ));
     204
     205    foreach( $general_checkboxes as $checkbox)
     206    {
     207      $template->merge_block_vars(
     208          'general',
     209          array(
     210            strtoupper($checkbox) => ($conf[$checkbox]=='true')?$html_check:''
     211            )
     212        );
     213    }
    192214    break;
    193215  }
    194216  case 'comments' :
    195217  {
    196     $all_yes = ($conf['comments_forall']=='true')?'checked="checked"':'';
    197     $all_no  = ($conf['comments_forall']=='false')?'checked="checked"':'';
    198     $validate_yes = ($conf['comments_validation']=='true')?'checked="checked"':'';
    199     $validate_no = ($conf['comments_validation']=='false')?'checked="checked"':'';
    200 
    201218    $template->assign_block_vars(
    202219      'comments',
    203220      array(
    204221        'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
    205         'COMMENTS_ALL_YES'=>$all_yes,
    206         'COMMENTS_ALL_NO'=>$all_no,
    207         'VALIDATE_YES'=>$validate_yes,
    208         'VALIDATE_NO'=>$validate_no
    209222        ));
     223
     224    foreach( $comments_checkboxes as $checkbox)
     225    {
     226      $template->merge_block_vars(
     227          'comments',
     228          array(
     229            strtoupper($checkbox) => ($conf[$checkbox]=='true')?$html_check:''
     230            )
     231        );
     232    }
    210233    break;
    211234  }
  • trunk/comments.php

    r1598 r1617  
    156156// |                         comments management                           |
    157157// +-----------------------------------------------------------------------+
    158 if (is_admin() and !is_adviser() )
    159 {
    160   if (isset($_GET['delete']) and is_numeric($_GET['delete']) )
    161   {// comments deletion
    162     $query = '
     158if (isset($_GET['delete']) and is_numeric($_GET['delete'])
     159      and !is_adviser() )
     160{// comments deletion
     161  check_status(ACCESS_ADMINISTRATOR);
     162  $query = '
    163163DELETE FROM '.COMMENTS_TABLE.'
    164164  WHERE id='.$_GET['delete'].'
    165165;';
    166     pwg_query($query);
    167   }
    168 
    169   if (isset($_GET['validate']) and is_numeric($_GET['validate']) )
    170   {  // comments validation
    171     $query = '
     166  pwg_query($query);
     167}
     168
     169if (isset($_GET['validate']) and is_numeric($_GET['validate'])
     170      and !is_adviser() )
     171{  // comments validation
     172  check_status(ACCESS_ADMINISTRATOR);
     173  $query = '
    172174UPDATE '.COMMENTS_TABLE.'
    173175  SET validated = \'true\'
    174     , validation_date = NOW()
     176  , validation_date = NOW()
    175177  WHERE id='.$_GET['validate'].'
    176178;';
    177     pwg_query($query);
    178   }
    179 }
     179  pwg_query($query);
     180}
     181
    180182// +-----------------------------------------------------------------------+
    181183// |                       page header and options                         |
  • trunk/include/config_default.inc.php

    r1616 r1617  
    516516$conf['nbm_treatment_timeout_default'] = 20;
    517517
    518 // Send an email to the webmaster when a new user registers
    519 $conf['email_admin_on_new_user']=false;
    520 
    521518// +-----------------------------------------------------------------------+
    522519// | Set default admin layout                                              |
  • trunk/include/picture_comment.inc.php

    r1610 r1617  
    194194    $template->assign_block_vars('information',
    195195                                 array('INFORMATION'=>$message));
     196    if ( ($comment_action=='validate' and $conf['email_admin_on_comment'])
     197      or $conf['email_admin_on_comment_validation'] )
     198    {
     199      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     200
     201      $del_url = get_host_url().cookie_path()
     202        .'comments.php?delete='.$comm['id'];
     203
     204      $content =
     205        'Author: '.$comm['author']."\n"
     206        .'Comment: '.$comm['content']."\n"
     207        .'IP: '.$comm['ip']."\n"
     208        .'Browser: '.$comm['agent']."\n\n"
     209        .'Delete: '.$del_url."\n";
     210      if ($comment_action!='validate')
     211      {
     212        $content .=
     213          'Validate: '.get_host_url().cookie_path()
     214          .'comments.php?validate='.$comm['id'];
     215      }
     216      pwg_mail( get_webmaster_mail_address(), '',
     217          'PWG comment by '.$comm['author'],
     218          $content
     219          );
     220    }
    196221  }
    197222  else
  • trunk/install/config.sql

    r1584 r1617  
    2727INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
    2828INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_complementary_mail_content','','Complementary mail content for notification by mail');
     29INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_new_user','false','Send an email to the admin when a user registers');
     30INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_comment','false','Send an email to the admin when a valid comment is entered');
     31INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_comment_validation','false','Send an email to the admin when a comment requires validation');
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r1584 r1617  
    8282$lang['Edit tags'] = 'Edit tags';
    8383$lang['Elements'] = 'Elements';
     84$lang['Email admin when a new user registers'] = 'Email admin when a new user registers';
     85$lang['Email admin when a valid comment is entered'] = 'Email admin when a valid comment is entered';
     86$lang['Email admin when a comment requires validation'] = 'Email admin when a comment requires validation';
    8487$lang['Empty caddie'] = 'Empty caddie';
    8588$lang['Environment'] = 'Environment';
  • trunk/language/fr_FR.iso-8859-1/admin.lang.php

    r1584 r1617  
    8282$lang['Edit tags'] = 'Editer les tags';
    8383$lang['Elements'] = 'Éléments';
     84$lang['Email admin when a new user registers'] = 'Notifier le webmestre lors de l\'inscription d\'un utilisateur';
     85$lang['Email admin when a valid comment is entered'] = 'Notifier le webmestre quand un commentaire est enregistré';
     86$lang['Email admin when a comment requires validation'] = 'Notifier le webmestre quand un commentaire requiert sa validation';
    8487$lang['Empty caddie'] = 'Vider le panier';
    8588$lang['Environment'] = 'Environnement';
  • trunk/template/yoga/admin/configuration.tpl

    r1565 r1617  
    5454
    5555    <li>
     56      <label>
     57        <span class="property">{lang:Email admin when a new user registers}</span>
     58        <input type="checkbox" name="email_admin_on_new_user" {general.EMAIL_ADMIN_ON_NEW_USER} />
     59      </label>
     60    </li>
     61
     62    <br/>
     63    <li>
    5664      <fieldset>
    5765        <legend>{lang:History}</legend>
    5866        <ul>
    5967          <li>
    60             <label><span class="property">{lang:Users}</span><input type="checkbox" name="log" {general.HISTORY_USERS} /></label>
     68            <label><span class="property">{lang:Users}</span><input type="checkbox" name="log" {general.LOG} /></label>
    6169          </li>
    6270
     
    8593  <ul>
    8694    <li>
    87       <span class="property">{lang:Comments for all}</span>
    88       <label><input type="radio" class="radio" name="comments_forall" value="true" {comments.COMMENTS_ALL_YES} />{lang:Yes}</label>
    89       <label><input type="radio" class="radio" name="comments_forall" value="false" {comments.COMMENTS_ALL_NO} />{lang:No}</label>
     95      <label>
     96        <span class="property">{lang:Comments for all}</span>
     97        <input type="checkbox" name="comments_forall" {comments.COMMENTS_FORALL} />
     98      </label>
    9099    </li>
    91100
     
    98107
    99108    <li>
    100       <span class="property">{lang:Validation}</span>
    101       <label><input type="radio" class="radio" name="comments_validation" value="true" {comments.VALIDATE_YES} />{lang:Yes}</label>
    102       <label><input type="radio" class="radio" name="comments_validation" value="false" {comments.VALIDATE_NO} />{lang:No}</label>
    103     </li>
     109      <label>
     110        <span class="property">{lang:Validation}</span>
     111        <input type="checkbox" name="comments_validation" {comments.COMMENTS_VALIDATION} />
     112      </label>
     113    </li>
     114
     115
     116    <li>
     117      <label>
     118        <span class="property">{lang:Email admin when a valid comment is entered}</span>
     119        <input type="checkbox" name="email_admin_on_comment" {comments.EMAIL_ADMIN_ON_COMMENT} />
     120      </label>
     121    </li>
     122
     123    <li>
     124      <label>
     125        <span class="property">{lang:Email admin when a comment requires validation}</span>
     126        <input type="checkbox" name="email_admin_on_comment_validation" {comments.EMAIL_ADMIN_ON_COMMENT_VALIDATION} />
     127      </label>
     128    </li>
     129
    104130  </ul>
    105131</fieldset>
Note: See TracChangeset for help on using the changeset viewer.