Ignore:
Timestamp:
Jan 26, 2011, 3:59:23 PM (13 years ago)
Author:
cljosse
Message:

[Mail_Supervisor] compatibility with piwigo 2.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Mail_supervisor/admin/mail_superv_admin.php

    r7050 r8917  
    2828
    2929if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
     30if (!defined('MAIL_SUPERV_PATH_ABS')) define('MAIL_SUPERV_PATH_ABS' ,  dirname(__FILE__).'/');
    3031
    3132global $user, $lang, $conf, $errors,$mails_donnees;
     
    7778
    7879$tabhelp=  '  <img src="'.PHPWG_ROOT_PATH. $icon_path .'"  width=10px   alt="(?)"> ';
    79 
    80  
    81 
    8280$tabsheet = new tabsheet();
    8381$tabsheet->add('mail_superv_admin',
     
    9896               $my_base_url.'&amp;tab=mail_superv_help');
    9997                           
    100                            
    10198$tabsheet->select($page['tab']);
    10299$tabsheet->assign();
     
    133130                if (!isset($mails_options[check_header_carbon])) $mails_options[check_header_carbon] = 'off' ;  //1
    134131                if (!isset($mails_options[check_mailto])) $mails_options[check_mailto] = 'off' ;  //0
    135 //================================================================================================             
     132//================================================================================================     
     133$mails_options[set_auto] = 'off' ;
     134$mails_options[no_connect] = 'off' ;
     135       
    136136$mails_donnees = Get_Datas();
    137137
     
    144144$aff_nb=true;
    145145
    146 
    147        
    148146// *************************************************************************
    149147// |                          Selection de l'onglet                        |
     
    151149
    152150                $modif=false ;
    153                 /*
    154                 $sql="SELECT *
    155 FROM `".$prefixeTable."plugins`
    156 WHERE `id` LIKE 'Mail_supervisor'
    157 ";
    158  $result = @pwg_query($sql);
    159         if ($result) {
    160             $versions = mysql_fetch_array($result,MYSQL_ASSOC);
    161         }
    162 $version = $versions['version'];
    163 */
    164 $plugin =  Get_Version_plugins( MAIL_SUPERV_PATH);
    165 $version = $plugin['version'] ;
     151
     152        $plugin =  Get_Version_plugins( MAIL_SUPERV_PATH);
     153        $version = $plugin['version'] ;
    166154 //=========================================================
    167155
     
    219207        }
    220208
    221  
     209  //===================================================================
    222210        if ( $_POST['submit'] == l10n('Sv_Valider') ) 
    223211                {
     
    287275         'version' =>    $version ,
    288276        'MAIL_SUPERV_PATH' =>  MAIL_SUPERV_PATH ,
    289         'path_js' => $path_js
     277        'path_js' => $path_js,
     278    'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS,
     279     
    290280                                                )
    291281                                );     
    292282
    293283        $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_admin.tpl')));
    294                 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     284 
     285
     286        $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    295287               
    296288 break;
     
    302294 
    303295   case 'mail_superv_test':
    304    
    305    $mails_donnees = Get_Datas() ;
    306         $group_id = isset($_POST['group']) ? $_POST['group'] :  '-1'  ;
    307         if ($group_id >= 0) {
    308       $query = '
    309                 SELECT
    310                 name
    311                 FROM '.GROUPS_TABLE.'
    312                 WHERE id = '.$group_id.'
    313                 ;';
    314                 list($group_name) = mysql_fetch_row(pwg_query($query));
     296                load_language('plugin.lang', MAIL_SUPERV_PATH);
     297                $mails_donnees = Get_Datas() ;
     298                $group_id = isset($_POST['group']) ? $_POST['group'] :  '-1'  ;
     299
     300                if ($group_id >= 0) {
     301                $query = 'SELECT
     302                                        name
     303                                                FROM '.GROUPS_TABLE.'
     304                                                WHERE id = '.$group_id.'
     305                                                ;';
     306                        list($group_name) = mysql_fetch_row(pwg_query($query));
    315307                }       else {
    316308                                $group_name="";         
    317309                }               
     310
    318311//================================================
    319312// info by email to an access granted group of category informations
    320 if (isset($_POST['submitEmail']) and !empty($_POST['group']))
     313
     314
     315if (isset($_POST['Submit']) and !empty($_POST['group']))
    321316{
    322317  set_make_full_url();
     318
    323319  /* TODO: if $category['representative_picture_id']
    324320    is empty find child representative_picture_id */
    325 /*
    326  * send en email to user's group
    327  *
    328  * @param:
    329  *   - group_id: mail are sent to group with this Id
    330  *   - email_format: mail format
    331  *   - keyargs_subject: mail subject on l10n_args format
    332  *   - dirname: short name of directory including template
    333  *   - tpl_shortname: short template name without extension
    334  *   - assign_vars: array used to assign_vars to mail template
    335  *   - language_selected: send mail only to user with this selected language
    336  *
    337  * @return boolean (Ok or not)
    338 */
    339 
    340 if (function_exists('get_user_language_desc') ) $titre = get_user_language_desc($conf['gallery_title']);
    341 else
    342 $titre=$conf['gallery_title'];
    343 
    344 $message = empty($_POST['MAIL_CONTENT']) ? $mails_donnees['message_test'] : stripslashes($_POST['MAIL_CONTENT']);
     321
     322
     323        if (function_exists('get_user_language_desc') ) $titre = get_user_language_desc($conf['gallery_title']);
     324        else $titre=$conf['gallery_title'];
     325
     326        $message = empty($_POST['MAIL_CONTENT']) ? $mails_donnees['message_test'] : stripslashes($_POST['MAIL_CONTENT']);
    345327
    346328 if (function_exists('get_user_language_desc') ) $message = get_user_language_desc($message);
    347   // TODO Mettre un array pour traduction subjet
    348 
    349  
    350   pwg_mail_group(
    351     $_POST['group'],
    352     get_str_email_format(true), 
    353     get_l10n_args('[%s] ---> %s', array($titre,'Information') ), //sujet
    354     'cat_group_info',  // template
    355     array
    356     (
    357       'CPL_CONTENT' => $message."\n\n".$user['username']
    358     ),
    359     '' );
    360        
    361 
    362 $mails_donnees['message_test']= str_replace('"',"'",$message) ;
    363  unset_make_full_url();
     329
     330 if ( $_POST['Submit']==l10n('Sv_Envoyer') ) {
     331         /*
     332         * send en email to user's group
     333         *
     334         * @param:
     335         *   - group_id: mail are sent to group with this Id
     336         *   - email_format: mail format
     337         *   - keyargs_subject: mail subject on l10n_args format
     338         *   - dirname: short name of directory including template
     339         *   - tpl_shortname: short template name without extension
     340         *   - assign_vars: array used to assign_vars to mail template
     341         *   - language_selected: send mail only to user with this selected language
     342         *
     343         * @return boolean (Ok or not)
     344        */   
     345        pwg_mail_group(
     346                $_POST['group'],
     347                get_str_email_format(true), 
     348                get_l10n_args('[%s] ---> %s', array($titre,'Information') ), //sujet
     349                'cat_group_info',  // template
     350                array    ('CPL_CONTENT' => $message."\n\n".$user['username'] ),
     351                '' );
     352       
     353        $mails_donnees['message_test']= str_replace('"',"'",$message) ;
     354
     355        unset_make_full_url();
    364356        sauve_donnees();
    365 $mails_donnees = Get_Datas() ;
    366        
    367   $query = '
    368 SELECT
    369     name
    370   FROM '.GROUPS_TABLE.'
    371   WHERE id = '.$_POST['group'].'
    372 ;';
    373   list($group_name) = mysql_fetch_row(pwg_query($query));
    374  
    375   array_push(
    376     $page['infos'],
    377     sprintf(
    378       l10n('An information email was sent to group "%s"'),
    379       $group_name
    380       )
    381     );
     357        $mails_donnees = Get_Datas() ;
     358    $query = 'SELECT
     359                name
     360                        FROM '.GROUPS_TABLE.'
     361                        WHERE id = '.$_POST['group'].'
     362                        ;';
     363                list($group_name) = mysql_fetch_row(pwg_query($query));
     364                 
     365                  array_push(
     366                                        $page['infos'],
     367                                        sprintf( l10n('An information email was sent to group "%s"'),
     368                                                        $group_name  )
     369                                        );
     370                                                                $group_id =-1 ;
     371  }
    382372
    383  load_language('plugin.lang', MAIL_SUPERV_PATH);
    384 //=====================================================================================
    385 if ( isset($_POST['test_envoie']) ) {
    386 $mails_donnees['message_test'] = empty($_POST['MAIL_CONTENT']) ? '' : stripslashes($_POST['MAIL_CONTENT']);
    387                 $message=$mails_donnees['message_test'];
    388 //test_envoie($message,$group_name,$group_id);
    389                 sauve_donnees();
    390  
    391                 $mails_donnees = Get_Datas() ;
    392                
    393   }
    394 
     373
     374//======================================================================================
    395375  $groups[-1] = '---------';
    396 
    397   $query = '
    398     SELECT id, name
    399                 FROM '.GROUPS_TABLE.'
    400                 ORDER BY name ASC
    401                 ;';
     376  $query = ' SELECT id, name
     377                        FROM '.GROUPS_TABLE.'
     378                        ORDER BY name ASC
     379                        ;';
    402380
    403381  $result = pwg_query($query);
    404382//----------------------------------------------------------------     
    405383  while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
    406   {
    407     $groups[$row['id']] = $row['name'];
    408   }
     384  {    $groups[$row['id']] = $row['name'];  }
    409385 //---------------------------------------------------------------
    410 
     386if ( isset($_POST['Submit'])) $group_id=-1;
    411387  $template->assign(
    412388        'Group',
    413                 array(
    414                         'group_options'=> $groups,
    415                         'selected' => $group_id
     389                array( 'group_options'=> $groups,
     390                                'selected' => $group_id
    416391                        )
    417392                );
    418393//=================================================================
    419394$destinataires= implode("<br />",get_liste($group_id));
     395if( $destinataires !="" )
     396$infos_message .= " List :<hr>" .  $destinataires . "<hr>" ;
     397 
    420398  $template->assign(
    421399                                        array(
    422                                 'Groupe'     => $groups,
    423                         'message_test' => $mails_donnees['message_test'] ,
    424                                 'liste' => $destinataires ,
    425  'version' =>    $version ,
    426                             'MAIL_CONTENT' => $mails_donnees['message_test'],
    427                     'path_js' => $path_js
     400                                                'Groupe'     => $groups,
     401                                        'message_test' => $mails_donnees['message_test'] ,
     402                                                'liste' => $destinataires ,
     403                                                'version' =>     $version ,
     404                                                'MAIL_CONTENT' => $mails_donnees['message_test'],
     405                                                'path_js' => $path_js,
     406                        'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS,
     407                        'MAIL_SUPERV_PATH' => MAIL_SUPERV_PATH ,
    428408                                                )
    429409                                );     
    430410                               
    431         $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_test.tpl')));
    432                 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    433                
    434                   $toolbar = 'Basic';
    435   $width = '750px';
    436   $height = '200px';
    437   $areas = array();
    438   $areas[]='MAIL_CONTENT';
    439  //  $areas[]= 'MAIL_CONTENT';
    440  if (!empty($areas))
    441   {
    442   if (function_exists('set_fckeditor_instance'))
    443     set_fckeditor_instance($areas, $toolbar, $width, $height);
    444   }
    445  
     411   $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_test.tpl')));
     412   $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     413//=========================================================================             
     414                $toolbar = 'Basic';
     415                $width = '750px';
     416                $height = '200px';
     417                $areas = array();
     418                $areas[]='MAIL_CONTENT';
     419                if (!empty($areas)){
     420                                if (function_exists('set_fckeditor_instance'))
     421                                set_fckeditor_instance($areas, $toolbar, $width, $height);
     422                        }
     423                       
    446424   break;
    447425// *************************************************************************
     
    453431 //------------------------------------------------------------------------------------
    454432        $mails_options[no_mail_list] = isset($_POST['no_mail_list']) ? $_POST['no_mail_list'] : $mails_options[no_mail_list] ;
    455         $mails_options[no_connect] = isset($_POST['no_connect']) ? $_POST['no_connect'] : $mails_options[no_connect] ;
    456             $mails_options[set_auto] = isset($_POST['set_auto']) ? $_POST['set_auto'] : $mails_options[set_auto] ;             
     433        $mails_options[no_connect] = 'off' ;//isset($_POST['no_connect']) ? $_POST['no_connect'] : $mails_options[no_connect] ;
     434            $mails_options[set_auto] = 'off' ;//isset($_POST['set_auto']) ? $_POST['set_auto'] : $mails_options[set_auto] ;             
    457435//=======================================================================================       
    458436    $info_ip = (isset($info_ip)) ? $info_ip : '' ;
     
    485463                {
    486464                                $mails_options[no_mail_list] = isset($_POST['no_mail_list']) ? $_POST['no_mail_list'] : "off" ;
    487                         $mails_options[no_connect] = isset($_POST['no_connect']) ? $_POST['no_connect'] : "off" ;
    488                         $mails_options[set_auto] = isset($_POST['set_auto']) ? $_POST['set_auto'] : "off" ;
     465                        $mails_options[no_connect] ='off' ;// isset($_POST['no_connect']) ? $_POST['no_connect'] : "off" ;
     466                        $mails_options[set_auto] = 'off' ;//isset($_POST['set_auto']) ? $_POST['set_auto'] : "off" ;
    489467                                $mails_options[set_id] = isset($_POST['set_id']) ? $_POST['set_id'] : "off" ;
    490468                                sauve_options();
     
    518496     $template->assign(
    519497                                        array(
    520                                         'start' => $params['start'],
    521                                         'per_page' => $params['per_page'] ,
    522                                 'maxipage'  =>  $maxipage ,
    523                                             'smile_bonjour' => $smile_bonjour ,
    524                                                 'img_logo' => $img_logo ,
    525                                 'champs_ip' => $champs_ip ,                                     
    526                                                 'liste_ip' => $liste_ip,
    527                                                 'champs_bl' =>  $champs_bl       ,     
    528                                                 'liste_bl' => $liste_bl ,
    529                                 //'conf_admin_layout' => $conf['admin_layout'] ,
    530                                                 'istype' => $istype ,
    531                                                 'ip_black' => $ip_black ,
    532                                                 'IS_SPAM' => test_spam(  $ip_black),
    533                                                 'ip_black_len' =>  strlen($ip_black)  ,
    534                                                 'MAIL_SUPERV_PATH' => MAIL_SUPERV_PATH ,
    535                             'path_js' => $path_js ,
    536                                                 'F_ACTION' => $f_action ,
     498                        'start' => $params['start'],
     499                        'per_page' => $params['per_page'] ,
     500                        'maxipage'  =>  $maxipage ,
     501                        'smile_bonjour' => $smile_bonjour ,
     502                        'img_logo' => $img_logo ,
     503                        'champs_ip' => $champs_ip ,                                     
     504                        'liste_ip' => $liste_ip,
     505                        'champs_bl' =>  $champs_bl       ,     
     506                        'liste_bl' => $liste_bl ,
     507                        //'conf_admin_layout' => $conf['admin_layout'] ,
     508                        'istype' => $istype ,
     509                        'ip_black' => $ip_black ,
     510                        'IS_SPAM' => test_spam(  $ip_black),
     511                        'ip_black_len' =>  strlen($ip_black)  ,
     512                        'MAIL_SUPERV_PATH' => MAIL_SUPERV_PATH ,
     513                        'path_js' => $path_js ,
     514                        'F_ACTION' => $f_action ,
    537515                                               
    538                                                 'no_mail_list' => ($mails_options[no_mail_list] == 'on') ? 'checked="checked"' : '' ,
     516                        'no_mail_list' => ($mails_options[no_mail_list] == 'on') ? 'checked="checked"' : '' ,
    539517                        'no_connect' => ($mails_options[no_connect] == 'on') ? 'checked="checked"' : '' ,
    540                                                 'set_auto' => ($mails_options[set_auto] == 'on') ? 'checked="checked"' : '' ,
    541                                                 'set_id' => ($mails_options[set_id] == 'on') ? 'checked="checked"' : '' ,
    542                                                 'IP' =>  $ip ,                                         
    543                                                 'PAYS' =>  $pays  ,
    544                                 'VILLE' =>  $ville ,
    545                                 'REGION' =>  $region , 
    546                                                  'version' =>    $version ,
     518                        'set_auto' => ($mails_options[set_auto] == 'on') ? 'checked="checked"' : '' ,
     519                        'set_id' => ($mails_options[set_id] == 'on') ? 'checked="checked"' : '' ,
     520                        'IP' =>  $ip ,                                         
     521                        'PAYS' =>  $pays  ,
     522                        'VILLE' =>  $ville ,
     523                        'REGION' =>  $region , 
     524                        'version' =>     $version ,
     525                        'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS,
    547526                                        )
    548527                                );                       
     
    567546                                         'version' =>    $version ,
    568547                                         'MAIL_SUPERV_PATH' =>  MAIL_SUPERV_PATH ,
    569                          'path_js' => $path_js
     548                         'path_js' => $path_js,
     549                        'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS
    570550                                        )
    571551                        );             
Note: See TracChangeset for help on using the changeset viewer.