Changeset 29317


Ignore:
Timestamp:
08/29/14 14:19:11 (5 years ago)
Author:
mistic100
Message:

Add allow_send_admin parameter

Location:
extensions/UserCollections
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/admin/config.php

    r28854 r29317  
    55{ 
    66  $conf['user_collections'] = array( 
    7     'allow_public'    => isset($_POST['allow_public']), 
    8     'allow_mails'     => isset($_POST['allow_mails']) && isset($_POST['allow_public']), 
     7    'allow_public'      => isset($_POST['allow_public']), 
     8    'allow_mails'       => isset($_POST['allow_mails']) && isset($_POST['allow_public']), 
     9    'allow_send_admin'  => isset($_POST['allow_send_admin']), 
    910    ); 
    1011 
     
    1213} 
    1314 
    14 $template->assign(array( 
    15   'user_collections' => $conf['user_collections'], 
    16   )); 
    17  
     15$template->assign('user_collections', $conf['user_collections']); 
    1816 
    1917$template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/config.tpl')); 
  • extensions/UserCollections/admin/template/config.tpl

    r25678 r29317  
    2626      </label> 
    2727    </li> 
     28    <li> 
     29      <label> 
     30        <input type="checkbox" name="allow_send_admin" {if $user_collections.allow_send_admin}checked="checked"{/if}> 
     31        <b>{'Allow users to send their collections (public or not) to the admin'|translate}</b> 
     32      </label> 
     33    </li> 
    2834  </ul> 
    2935</fieldset> 
  • extensions/UserCollections/include/UserCollection.class.php

    r27604 r29317  
    448448 
    449449    $comment_action = 'validate'; 
     450    $for_admin = $comm['to'] == 'admin'; 
    450451 
    451452    // check author 
     
    455456      $comment_action = 'reject'; 
    456457    } 
    457     if (empty($comm['recipient_name'])) 
     458    if (!$for_admin && empty($comm['recipient_name'])) 
    458459    { 
    459460      $errors[] = l10n('Please enter the recipient name'); 
     
    472473      $comment_action = 'reject'; 
    473474    } 
    474     if (empty($comm['recipient_email'])) 
    475     { 
    476       $errors[] = l10n('Please enter the recipient e-mail'); 
    477       $comment_action = 'reject'; 
    478     } 
    479     else if (!empty($comm['recipient_email']) and !email_check_format($comm['recipient_email'])) 
    480     { 
    481       $errors[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 
    482       $comment_action = 'reject'; 
     475    if (!$for_admin) 
     476    { 
     477      if (empty($comm['recipient_email'])) 
     478      { 
     479        $errors[] = l10n('Please enter the recipient e-mail'); 
     480        $comment_action = 'reject'; 
     481      } 
     482      else if (!empty($comm['recipient_email']) and !email_check_format($comm['recipient_email'])) 
     483      { 
     484        $errors[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 
     485        $comment_action = 'reject'; 
     486      } 
    483487    } 
    484488 
     
    493497    if ($comment_action == 'validate') 
    494498    { 
    495       // switch to guest user for get_sql_condition_FandF 
    496       $user_save = $user; 
    497       $user = build_user($conf['guest_id'], true); 
     499      if (!$for_admin) 
     500      { 
     501        // switch to guest user for get_sql_condition_FandF 
     502        $user_save = $user; 
     503        $user = build_user($conf['guest_id'], true); 
     504      } 
    498505 
    499506      // get pictures 
     
    517524      $pictures = hash_from_query($query, 'id'); 
    518525 
    519       // switch back to current user 
    520       $user = $user_save; 
    521       unset($user_save); 
    522  
    523       $share_key = array('share_key'=>'mail-' . substr(sha1($this->data['id'].$conf['secret_key']), 0, 11)); 
    524  
    525       $tpl_vars = array( 
    526         'COL_URL' => $this->addShare($share_key, false), 
    527         'PARAMS' => $comm, 
    528         'derivative_params' => ImageStdParams::get_by_type(IMG_SQUARE), 
    529         ); 
     526      if (!$for_admin) 
     527      { 
     528        // switch back to current user 
     529        $user = $user_save; 
     530        unset($user_save); 
     531      } 
    530532 
    531533      // pictures infos 
    532534      set_make_full_url(); 
     535      $thumbnails = array(); 
    533536 
    534537      foreach ($pictures as $row) 
     
    536539        $name = render_element_name($row); 
    537540 
    538         $tpl_vars['THUMBNAILS'][] = array( 
     541        $thumbnails[] = array( 
    539542          'TN_ALT' => htmlspecialchars(strip_tags($name)), 
    540543          'NAME' =>   $name, 
     
    546549      unset_make_full_url(); 
    547550 
    548       $result = pwg_mail( 
    549         array( 
    550           'name' => $comm['recipient_name'], 
    551           'email' => $comm['recipient_email'], 
    552           ), 
    553         array( 
    554           'subject' => '['.$conf['gallery_title'].'] '.l10n('A photo collection by %s', $comm['sender_name']), 
    555           'mail_title' => $this->getParam('name'), 
    556           'mail_subtitle' => l10n('by %s', $comm['sender_name']), 
    557           'content_format' => 'text/html', 
    558           'from' => array( 
    559             'name' => $comm['sender_name'], 
    560             'email' => $comm['sender_email'], 
    561             ) 
    562           ), 
    563         array( 
    564           'filename' => 'mail', 
    565           'dirname' => realpath(USER_COLLEC_PATH . 'template'), 
    566           'assign' => $tpl_vars, 
     551      if ($for_admin) 
     552      { 
     553        $col_url = USER_COLLEC_PUBLIC.'edit/'.$this->data['id']; 
     554      } 
     555      else 
     556      { 
     557        $share_key = array('share_key'=>'mail-' . substr(sha1($this->data['id'].$conf['secret_key']), 0, 11)); 
     558        $col_url = $this->addShare($share_key, false); 
     559      } 
     560 
     561      $mail_config = array( 
     562        'subject' => '['.$conf['gallery_title'].'] '.l10n('A photo collection by %s', $comm['sender_name']), 
     563        'mail_title' => $this->getParam('name'), 
     564        'mail_subtitle' => l10n('by %s', $comm['sender_name']), 
     565        'content_format' => 'text/html', 
     566        'from' => array( 
     567          'name' => $comm['sender_name'], 
     568          'email' => $comm['sender_email'], 
    567569          ) 
    568570        ); 
     571      $mail_tpl = array( 
     572        'filename' => 'mail', 
     573        'dirname' => realpath(USER_COLLEC_PATH . 'template'), 
     574        'assign' => array( 
     575          'COL_URL' => $col_url, 
     576          'PARAMS' => $comm, 
     577          'derivative_params' => ImageStdParams::get_by_type(IMG_SQUARE), 
     578          'THUMBNAILS' => $thumbnails, 
     579          ) 
     580        ); 
     581       
     582      if ($for_admin) 
     583      { 
     584        $result = pwg_mail_admins($mail_config, $mail_tpl); 
     585      } 
     586      else 
     587      { 
     588        $result = pwg_mail( 
     589          array( 
     590            'name' => $comm['recipient_name'], 
     591            'email' => $comm['recipient_email'], 
     592            ), 
     593          $mail_config, 
     594          $mail_tpl 
     595          ); 
     596      } 
    569597 
    570598      if ($result == false) 
  • extensions/UserCollections/include/collections.inc.php

    r28626 r29317  
    173173 
    174174    // send mail 
    175     if ($conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public']) 
     175    if (($conf['user_collections']['allow_public'] && $conf['user_collections']['allow_mails']) 
     176        || $conf['user_collections']['allow_send_admin']) 
    176177    { 
    177178      if (isset($_POST['send_mail'])) 
     
    180181          'sender_email' =>     trim($_POST['sender_email']), 
    181182          'sender_name' =>      trim($_POST['sender_name']), 
     183          'to' =>               $_POST['to'], 
    182184          'recipient_email' =>  trim($_POST['recipient_email']), 
    183185          'recipient_name' =>   trim($_POST['recipient_name']), 
     
    249251          USER_COLLEC_PUBLIC . 'view/' . $page['col_id'] .'-' 
    250252          ); 
    251  
    252         if ($conf['user_collections']['allow_mails']) 
    253         { 
    254           user_collections_add_button('mail', 'U_MAIL', true); 
    255         } 
     253      } 
     254       
     255      if (($conf['user_collections']['allow_public'] && $conf['user_collections']['allow_mails']) 
     256        || $conf['user_collections']['allow_send_admin']) 
     257      { 
     258        user_collections_add_button('mail', 'U_MAIL', true); 
    256259      } 
    257260 
     
    265268      ); 
    266269 
    267     $template->assign('UC_TKEY', get_ephemeral_key(3)); 
     270    $template->assign(array( 
     271      'UC_TKEY' => get_ephemeral_key(3), 
     272      'UC_CONFIG' => $conf['user_collections'] 
     273      )); 
    268274 
    269275    // modify page title 
  • extensions/UserCollections/language/en_UK/plugin.lang.php

    r26058 r29317  
    3131$lang['Allow users to set their collections as public'] = 'Allow users to set their collections as public'; 
    3232$lang['Allow users to send their public collections by mail'] = 'Allow users to send their public collections by mail'; 
     33$lang['Allow users to send their collections (public or not) to the admin'] = 'Allow users to send their collections (public or not) to the admin'; 
    3334$lang['Fields'] = 'Fields'; 
    3435$lang['Active'] = 'Active'; 
     
    6970$lang['Name'] = 'Name'; 
    7071$lang['Send'] = 'Send'; 
     72$lang['To'] = 'To'; 
     73$lang['Administrator'] = 'Administrator'; 
     74$lang['Someone else'] = 'Someone else'; 
    7175 
    7276?> 
  • extensions/UserCollections/language/fr_FR/plugin.lang.php

    r26058 r29317  
    3131$lang['Allow users to set their collections as public'] = 'Les utilisateurs peuvent rendre leurs collections publiques'; 
    3232$lang['Allow users to send their public collections by mail'] = 'Les utilisateurs peuvent envoyer leurs collections publiques par mail'; 
     33$lang['Allow users to send their collections (public or not) to the admin'] = 'Les utilisateurs peuvent envoyer leurs collections (publiques ou non) à l\'administrateur'; 
    3334$lang['Fields'] = 'Champs'; 
    3435$lang['Active'] = 'Actifs'; 
     
    6970$lang['Name'] = 'Nom'; 
    7071$lang['Send'] = 'Envoyer'; 
     72$lang['To'] = 'Pour'; 
     73$lang['Administrator'] = 'Administrateur'; 
     74$lang['Someone else'] = 'Quelqu\'un d\'autre'; 
    7175 
    7276?> 
  • extensions/UserCollections/maintain.class.php

    r28854 r29317  
    99   
    1010  private $default_conf = array( 
     11    'allow_send_admin' => true, 
    1112    'allow_mails' => true, 
    1213    'allow_public' => true, 
     
    3031    { 
    3132      conf_update_param('user_collections', $this->default_conf, true); 
     33    } 
     34    else 
     35    { 
     36      $old_conf = safe_unserialize($conf['user_collections']); 
     37       
     38      if (!isset($old_conf['allow_send_admin'])) 
     39      { 
     40        $old_conf['allow_send_admin'] = true; 
     41        conf_update_param('user_collections', $old_conf, true); 
     42      } 
    3243    } 
    3344 
  • extensions/UserCollections/template/collection_edit.tpl

    r25678 r29317  
    130130  }); 
    131131 
     132  jQuery('#mail_form [name=to]').on('change', function() { 
     133    $('.recipient-input').toggle(jQuery(this).val() == 'email'); 
     134    jQuery.colorbox.resize(); 
     135  }); 
    132136 
    133137  jQuery('#mail_form').css('background-color', bg_color); 
     
    258262        </td> 
    259263      </tr> 
    260       <tr> 
     264      {if $UC_CONFIG.allow_send_admin && !$UC_CONFIG.allow_mails} 
     265      <tr> 
     266        <td class="title">{'To'|translate}</td> 
     267        <td>{'Administrator'|translate}</td> 
     268      </tr> 
     269      {/if} 
     270      <tr {if !$UC_CONFIG.allow_send_admin || !$UC_CONFIG.allow_mails}style="display:none"{/if}> 
     271        <td class="title">{'To'|translate}</td> 
     272        <td> 
     273          <label><input type="radio" name="to" value="admin" checked> {'Administrator'|translate}</label> 
     274          <label><input type="radio" name="to" value="email"> {'Someone else'|translate}</label> 
     275        </td> 
     276      </tr> 
     277      <tr style="display:none" class="recipient-input"> 
    261278        <td class="title"><label for="recipient_name">{'Recipient name'|translate}</label></td> 
    262279        <td> 
     
    264281        </td> 
    265282      </tr> 
    266       <tr> 
     283      <tr style="display:none" class="recipient-input"> 
    267284        <td class="title"><label for="recipient_email">{'Recipient e-mail'|translate}</label></td> 
    268285        <td> 
Note: See TracChangeset for help on using the changeset viewer.