Ignore:
Timestamp:
Feb 21, 2010, 4:44:14 PM (14 years ago)
Author:
Eric
Message:

[NBC_UserAdvManager] Pre-2.13.4 for testing only:

  • Bug 1303 and 1387 fixed : There is a bug in Piwigo 2.0.8 about switch_lang() function. This may be fixed in the next Piwigo release. These UAM fix are available only for Piwigo 2.0.8 and have to be recoded for the next Piwigo release. (Thx to Rub and cljosse for their usefull help).
  • Bug 1444 fixed
  • Bug 1445 pre-fixed : Begining of plugin's admin panel improvement. Add of new help language files (FR for the moment), deletion of ConfirmMail tab, mix all config in one tab, add of cuetips. This is for testing !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php

    r4458 r4927  
    11<?php
    2 include_once (NBC_UserAdvManager_PATH.'include/constants.php');
    3 load_language('plugin.lang', NBC_UserAdvManager_PATH);
     2include_once (NBC_UAM_PATH.'include/constants.php');
     3load_language('plugin.lang', NBC_UAM_PATH);
    44
    55/* Function called from main.inc.php to send validation email */
    66function SendMail2User($typemail, $id, $username, $password, $email, $confirm)
    77{
    8   global $conf;
    9   load_language('plugin.lang', NBC_UserAdvManager_PATH);
     8  /* Only available for next Piwigo release (bug in switch_lang function) */
     9  //global $conf;
     10 
     11  /* ****************************************************************** */
     12  /* Delete this after new Piwigo release (bug in switch_lang function) */
     13  global $conf, $user;
     14  $save_user = $user;
     15  /* ****************************************************************** */
     16
    1017  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
    1118 
     
    2229;';
    2330  $data = mysql_fetch_assoc(pwg_query($query));
    24   $language = $data['language'];
     31
     32/* Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language */
     33  if (empty($data))
     34  {
    2535/* And switch gallery to this language before using personalized and multilangual contents */
    26   switch_lang_to($data['language']);
     36    $language = pwg_get_session_var( 'lang_switch', $user['language'] );
     37    switch_lang_to($language);
     38  }
     39  else
     40  {
     41/* And switch gallery to this language before using personalized and multilangual contents */
     42    $language = $data['language']; /* Usefull for debugging */
     43    switch_lang_to($data['language']);
     44    load_language('plugin.lang', NBC_UAM_PATH);
     45  }
    2746
    2847  switch($typemail)
     
    92111  ));
    93112
    94 /* Switching back to default language */
    95 switch_lang_back();
    96 
    97113/* ********************** */
    98114/* Email sending debugger */
     
    100116/* the send of emails for */
    101117/* debugging              */
    102 /* ********************** */ 
    103 //  MailLog($email,$subject, $content);
    104118/* ********************** */
    105 }
    106 
    107 
    108 /* Email sending debugger function */
    109 //function MailLog  ($to, $subject, $content)
    110 //{
    111 //   $fo=fopen (NBC_UserAdvManager_PATH.'admin/maillog.txt','a') ;
    112 //   fwrite($fo,"======================\n") ;
    113 //   fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");
    114 //   fwrite($fo,$to . "\n" . $subject . "\r\n") ;
    115 //   fwrite($fo, "\n" . $content . "\r\n") ;
    116    //fwrite($fo, 'Langue : '."\n" . $language . "\r\n") ;
    117 //   fclose($fo) ;
    118    //return mail ($to,$subject) ;
    119 //}
     119//$content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url();   
     120//MailLog($email,$subject,$content,$language);
     121/* ********************** */
     122
     123/* Switching back to default language */
     124  /* ****************************************************************** */
     125  /* Delete this after new Piwigo release (bug in switch_lang function) */
     126$user=$save_user ;
     127  /* ****************************************************************** */
     128switch_lang_back();
     129}
    120130
    121131
     
    123133function ResendMail2User($typemail, $user_id, $username, $email, $confirm)
    124134{
    125   global $conf;
     135  /* Only available for next Piwigo release (bug in switch_lang function) */
     136  //global $conf;
     137 
     138  /* ****************************************************************** */
     139  /* Delete this after new Piwigo release (bug in switch_lang function) */
     140  global $conf, $user;
     141  $save_user = $user;
     142  /* ****************************************************************** */
     143 
    126144  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
    127145        $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
     
    140158  $data = mysql_fetch_assoc(pwg_query($query));
    141159  $language = $data['language'];
     160 
    142161/* And switch gallery to this language before using personalized and multilangual contents */
    143162  switch_lang_to($data['language']);
     163   
     164  load_language('plugin.lang', NBC_UAM_PATH);
    144165
    145166  switch($typemail)
     
    201222  ));
    202223
    203 /* Switching back to default language */
    204 switch_lang_back();
    205224/* ********************** */
    206225/* Email sending debugger */
     
    208227/* the send of emails for */
    209228/* debugging              */
    210 /* ********************** */ 
    211 //  MailLog($email,$subject);
    212229/* ********************** */
     230//$content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url();
     231//MailLog($email,$subject,$content,$language);
     232/* ********************** */
     233
     234/* Switching back to default language */
     235  /* ****************************************************************** */
     236  /* Delete this after new Piwigo release (bug in switch_lang function) */
     237$user=$save_user ;
     238  /* ****************************************************************** */
     239switch_lang_back();
    213240}
    214241
     
    217244function ghostreminder($user_id, $username, $email)
    218245{
    219   global $conf;
     246  /* Only available for next Piwigo release (bug in switch_lang function) */
     247  //global $conf;
     248 
     249  /* ****************************************************************** */
     250  /* Delete this after new Piwigo release (bug in switch_lang function) */
     251  global $conf, $user;
     252  $save_user = $user;
     253  /* ****************************************************************** */
     254 
    220255  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
    221256 
     
    232267  $data = mysql_fetch_assoc(pwg_query($query));
    233268  $language = $data['language'];
     269
    234270/* And switch gallery to this language before using personalized and multilangual contents */
    235271  switch_lang_to($data['language']);
    236 
    237   $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Ghost_remainder_of_%s', $username));
    238      
     272   
     273  load_language('plugin.lang', NBC_UAM_PATH);
     274 
     275  $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Ghost_reminder_of_%s', $username));     
     276
    239277  if (isset($conf_nbc_UserAdvManager[19]) and $conf_nbc_UserAdvManager[19] <> '' and isset($conf_nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17] == 'true')
    240278  {
     
    243281      $infos1 = get_user_language_desc($conf_nbc_UserAdvManager[19])."\n\n";
    244282    }
    245     else $infos1 = l10n($conf_nbc_UserAdvManager[19])."\n\n";
    246    
     283    else
     284    {
     285      $infos1 = l10n($conf_nbc_UserAdvManager[19])."\n\n";
     286    }
     287
    247288    resetlastvisit($user_id);
    248289  }
     
    253294  ));
    254295
    255 /* Switching back to default language */
    256 switch_lang_back();
    257296/* ********************** */
    258297/* Email sending debugger */
     
    260299/* the send of emails for */
    261300/* debugging              */
    262 /* ********************** */ 
    263 //  MailLog($email,$subject);
    264301/* ********************** */
     302//$content = get_user_language_desc($conf_nbc_UserAdvManager[19])."\n\n"; 
     303//MailLog($email,$subject,$content,$language);
     304/* ********************** */
     305
     306/* Switching back to default language */
     307  /* ****************************************************************** */
     308  /* Delete this after new Piwigo release (bug in switch_lang function) */
     309$user=$save_user ;
     310  /* ****************************************************************** */
     311switch_lang_back();
    265312}
    266313
     
    343390    }
    344391   
    345     return get_absolute_root_url().NBC_UserAdvManager_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID;
     392    return get_absolute_root_url().NBC_UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID;
    346393  }
    347394}
     
    373420                pwg_query($query);
    374421   
    375     return get_absolute_root_url().NBC_UserAdvManager_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID;
     422    return get_absolute_root_url().NBC_UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID;
    376423  }
    377424}
     
    10471094  return (bool)($res=mysql_query($query));
    10481095}
     1096
     1097/* Email sending debugger function */
     1098function MailLog  ($to, $subject, $content, $language)
     1099{
     1100   $fo=fopen (NBC_UAM_PATH.'admin/maillog.txt','a') ;
     1101   fwrite($fo,"======================\n") ;
     1102   fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");
     1103   fwrite($fo,$to . "\n" . $subject . "\r\n") ;
     1104   fwrite($fo, "\n" . $content . "\r\n") ;
     1105   fwrite($fo, 'Langue : '."\n" . $language . "\r\n") ;
     1106   fclose($fo) ;
     1107 //return mail ($to,$subject) ;
     1108}
     1109
     1110
     1111/* Function called from UserAdvManager_admin.php to get the plugin version */
     1112function PluginVer($dir)
     1113{
     1114  $path = $dir;
     1115
     1116  $plg_data = implode( '', file($path.'main.inc.php') );
     1117  if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) )
     1118  {
     1119    $plugin['name'] = trim( $val[1] );
     1120  }
     1121  if (preg_match("|Version: (.*)|", $plg_data, $val))
     1122  {
     1123    $plugin['version'] = trim($val[1]);
     1124  }
     1125  if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) )
     1126  {
     1127    $plugin['uri'] = trim($val[1]);
     1128  }
     1129  if ($desc = load_language('description.txt', $path.'/', array('return' => true)))
     1130  {
     1131    $plugin['description'] = trim($desc);
     1132  }
     1133  elseif ( preg_match("|Description: (.*)|", $plg_data, $val) )
     1134  {
     1135    $plugin['description'] = trim($val[1]);
     1136  }
     1137  if ( preg_match("|Author: (.*)|", $plg_data, $val) )
     1138  {
     1139    $plugin['author'] = trim($val[1]);
     1140  }
     1141  if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
     1142  {
     1143    $plugin['author uri'] = trim($val[1]);
     1144  }
     1145  if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid='))
     1146  {
     1147    list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']);
     1148    if (is_numeric($extension)) $plugin['extension'] = $extension;
     1149  }
     1150// IMPORTANT SECURITY !
     1151  $plugin = array_map('htmlspecialchars', $plugin);
     1152
     1153  return $plugin ;
     1154}
    10491155?>
Note: See TracChangeset for help on using the changeset viewer.