Changeset 19732


Ignore:
Timestamp:
Jan 2, 2013, 11:48:21 PM (11 years ago)
Author:
julien1311
Message:

Compatible 2.4 mais pas encore top...

Location:
extensions/Piwecard
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • extensions/Piwecard/admin/template/consult.tpl

    r8771 r19732  
    22  <h2>{$ECARD_VERSION}</h2>
    33</div>
    4 <p>
    5 {'ecard_consult_detail'|@translate}
    6 </p>
    7 
    84<fieldset>
    95        <legend>{'ecard_list'|@translate}</legend>
  • extensions/Piwecard/admin/template/manage.tpl

    r10615 r19732  
    1 {html_head}
    2 {/html_head}
    3 
    41<div class="titrePage">
    52  <h2>{$ECARD_VERSION}</h2>
    63</div>
    7 <p>
    8 {'ecard_management'|@translate}
    9 </p>
    104<form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
    115<fieldset>
    126        <legend>{'ecard_manage'|@translate}</legend>
    137        <table>
    14 
    15                 <tr>
    16                         <td>{'ecard_authorized_group'|@translate} &nbsp;&nbsp;</b></td>
    17                         <td>{$group_perm.GROUPSELECTION}</td>
    18         </tr>
    19                 <tr><td colspan="2"><i>{'ecard_authorized_group_info'|@translate}</i></td></tr>
    208                <tr><td colspan="2"><br></td></tr>
    219                <TR>
     
    5745                                </tr>
    5846                                <tr>
    59                                         <td class="categoryList1"  colspan="2">
     47                                        <td class="categoryList1" colspan="2">
    6048                                        <div id="cat_select">
    6149                                                {$DOUBLE_SELECT}
  • extensions/Piwecard/admin/template/params.tpl

    r9342 r19732  
    22  <h2>{$ECARD_VERSION}</h2>
    33</div>
    4 <p>
    5 {'ecard_params'|@translate}
    6 </p>
    74<form method="post" action=""   ENCTYPE="multipart/form-data">
    85
  • extensions/Piwecard/include/config_param.inc.php

    r8771 r19732  
    1515                '%sujet'                => isset($_POST['sujet']) ? $_POST['sujet'] : ''  ,
    1616                '%message'              => isset($_POST['message']) ? $_POST['message'] : ''  ,
    17                 '%imgurl'               => get_image_url($image_element),
     17                '%imgurl'               => DerivativeImage::thumb_url($image_element) ,
    1818                '%imginfos'             => isset($image_element['imginfos']) ? $image_element['imginfos'] : ''  ,
    1919                );
  • extensions/Piwecard/include/ecard.class.php

    r9342 r19732  
    77global $user, $conf;
    88
    9 class ecard
    10 {
     9class ecard {
    1110        var $debug = false;
    1211        var $my_config  ;
    13         var $infos = array();   // conain all the info for the ecard : message; subject....
    14 
     12        var $infos = array();   // contains all the info of the ecard : message, subject....
    1513        var $user_groups = array();
    1614       
    1715        // Class constructor
    18         function ecard()
    19         {
     16        function ecard() {
    2017                $this->load_config();
    2118        }
     
    2320       
    2421        // Load general configuration from config_database
    25         function load_config()
    26         {
    27 
     22        function load_config() {
    2823                $query = '
    2924                  SELECT value
     
    3429                $result = pwg_query($query);
    3530
    36             if($result)
    37                 {
    38                      $row = mysql_fetch_row($result);
    39                      if(is_string($row[0]))
    40                          {
    41                         $this->my_config = unserialize(($row[0]));
    42                      }
     31            if(isset($result)) {
     32                        $row = mysql_fetch_row($result);
     33                        if(is_string($row[0])) {
     34                                $this->my_config = unserialize(($row[0]));
     35                        }
    4336            }
    4437                $this->load_default_config();
     
    4639       
    4740        // Initialize default values of params
    48         private function load_default_config()
    49         {
     41        private function load_default_config() {
    5042            include ECARD_INC_PATH.'default_values.inc.php';
    51             foreach ($ecard_default_values as $key => $value)
    52                 {
    53 //                      echo "value=".$key." \ ";
    54                     if (!isset($this->my_config[$key]))         $this->my_config[$key] = $value;
     43            foreach ($ecard_default_values as $key => $value) {
     44                    if (!isset($this->my_config[$key]))
     45                                $this->my_config[$key] = $value;
    5546                }
    5647        }
     
    7768
    7869        // Retrieve user groups
    79         function get_user_groups()
    80         {
     70        function get_user_groups() {
    8171                global $user;
    82                 if ($this->debug)
    83                         foreach ($user as $id=>$val)
    84                         {
    85                                 if (is_array($val))
    86                                         foreach ($val as $id2=>$val2)
    87                                                 echo "user[".$id."][".$id2."]=".$val2."\n";
    88                                 else
    89                                         echo "user[".$id."]=".$val."\n";
    90                         }
    91 
     72               
    9273                $query = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';';
    93                 if ($this->debug)               echo $query."\n";
     74
    9475                $result = pwg_query($query);
    95                 while ($row = mysql_fetch_assoc($result))
    96                 {
    97                   array_push($this->user_groups, $row['group_id']);
    98                 }
     76                while ($row = mysql_fetch_assoc($result)) {
     77                        array_push($this->user_groups, $row['group_id']);
     78                }
     79        }
     80
     81
     82        function section_init_ecard() {
     83                global $tokens, $page;
    9984               
    100                 if ($this->debug)
    101                 foreach ($this->user_groups as $gr)
    102                         echo "Group=".$gr."\n";
    103 
    104         }
    105 
    106 
    107         function section_init_ecard()
    108         {
    109                 global $tokens, $page;
    11085                if ($tokens[0] == 'ecard')
    111                   $page['section'] = 'ecard';
    112         }
    113        
    114         function index_ecard()
    115         {
     86                        $page['section'] = 'ecard';
     87        }
     88       
     89        function index_ecard() {
    11690                global $page;
    11791               
    118                 if (isset($page['section']) and $page['section'] == 'ecard')
    119                 {
    120                 /*
    121                         foreach ($page as $i=>$p)
    122                         echo "page[".$i."]=".$p." ;";
    123                 */
     92                if (isset($page['section']) and $page['section'] == 'ecard') {
    12493                        include(ECARD_PATH . 'publish.php');
    12594                }
     
    12796
    12897        //Générer une chaine de caractère unique et aléatoire
    129 
    13098        private function random($car) {
    131         $string = "";
    132         $chaine = "abcdefghijklmnpqrstuvwxy0123456789";
    133         srand((double)microtime()*1000000);
    134         for($i=0; $i<$car; $i++) {
    135         $string .= $chaine[rand()%strlen($chaine)];
    136         }
    137         return $string;
     99                $string = "";
     100                $chaine = "abcdefghijklmnpqrstuvwxy0123456789";
     101                srand((double)microtime()*1000000);
     102                for($i=0; $i<$car; $i++) {
     103                        $string .= $chaine[rand()%strlen($chaine)];
     104                }
     105                return $string;
    138106        }
    139107
    140108        // NB of days between 2 dates "AAAA-MM-JJ HH:hh:ss"
    141          function NbJours($debut, $fin) {
    142 
    143           $tDeb = explode("-", substr($debut,0,strpos($debut, ' ')));
    144           $tFin = explode("-", substr($fin,0,strpos($fin, ' ')));
    145 
    146           $diff = mktime(0, 0, 0, $tFin[1], $tFin[2], $tFin[0]) -
    147                           mktime(0, 0, 0, $tDeb[1], $tDeb[2], $tDeb[0]);
    148          
    149           return(($diff / 86400));
    150 
     109        function NbJours($debut, $fin) {
     110                $tDeb = explode("-", substr($debut,0,strpos($debut, ' ')));
     111                $tFin = explode("-", substr($fin,0,strpos($fin, ' ')));
     112
     113                $diff = mktime(0, 0, 0, $tFin[1], $tFin[2], $tFin[0]) - mktime(0, 0, 0, $tDeb[1], $tDeb[2], $tDeb[0]);
     114
     115                return(($diff / 86400));
    151116        }
    152117
    153118        function AjoutJours($debut, $jours, $soustrait = false) {
    154           $tDeb = explode("-", substr($debut,0,strpos($debut, ' ')));
    155           $tDebH = explode(":", substr($debut,strpos($debut, ' ')+1));
    156           $tFin = "";
     119                $tDeb = explode("-", substr($debut,0,strpos($debut, ' ')));
     120                $tDebH = explode(":", substr($debut,strpos($debut, ' ')+1));
     121                $tFin = "";
    157122
    158123                $nb_ans = (int)(($jours)/365);
     
    164129                else
    165130                        $tFin = date("Y-m-d H:m:s", mktime($tDebH[0], $tDebH[1], $tDebH[2], $tDeb[1] + $nb_mois, $tDeb[2] + $nb_jours, $tDeb[0] + $nb_ans));
    166          
    167           return($tFin);
    168 
    169         }
    170        
    171         function parse($data, $_POST = NULL, $image_element = NULL)
    172         {
     131
     132                return($tFin);
     133        }
     134       
     135        function parse($data, $_POST = NULL, $image_element = NULL) {
    173136                include (ECARD_PATH.'include/config_param.inc.php');
    174137
     
    185148       
    186149        // Get the number of ecard in the database
    187         function get_nb_ecard()
    188         {
    189 
     150        function get_nb_ecard() {
    190151                $query = 'SELECT COUNT(DISTINCT numero) as nb FROM '.ECARD_TABLE
    191152                                . ' ORDER BY date'
    192153                                .';';
    193154                $result = pwg_query($query);
    194                 if ($result)
    195                 {
     155                if ($result) {
    196156                        $nb=mysql_fetch_assoc($result);
    197157                        return $nb['nb'];
     
    202162
    203163        // Get the number of valid ecard in the database
    204         function get_nb_valid_ecard()
    205         {
    206 
     164        function get_nb_valid_ecard() {
    207165                $query = 'SELECT numero,date,duration  FROM '.ECARD_TABLE
    208166                                .';';
    209167                $result = pwg_query($query);
    210168                $count = 0;
    211                 while($ecard_info = mysql_fetch_assoc($result))
    212                 {
    213                         if ( $ecard_info['duration'] == 0
    214                                 OR $this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) <= $ecard_info['duration']) // activ  ecard
     169                while($ecard_info = mysql_fetch_assoc($result)) {
     170                        if ($ecard_info['duration'] == 0 OR $this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) <= $ecard_info['duration'])        // activ  ecard
    215171                                $count++;
    216172                }
     
    220176       
    221177        // Get ecard information into array
    222         function get_ecard($ecard_id = null)
    223         {
    224                 if ($ecard_id!== null)
    225                 {
     178        function get_ecard($ecard_id = null) {
     179                if ($ecard_id!== null) {
    226180                        $query = '
    227181                                SELECT *
     
    241195
    242196        // Get ecard information into array
    243         function is_valid($ecard_id = null, $param_date=false)
    244         {
    245                 if ($ecard_id!== null)
    246                 {
     197        function is_valid($ecard_id = null, $param_date=false) {
     198                if ($ecard_id!== null) {
    247199                        $ecard_info = $this->get_ecard($ecard_id);
    248200                        if ($ecard_info != false)
     
    261213                               
    262214                                if (isset ($ecard_info)
    263                                         and $duration != 0              // 0 means always activ
    264                                         and ($this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) > $duration)      // Inactiv ecard
     215                                        AND $duration != 0              // 0 means always activ
     216                                        AND ($this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) > $duration)      // Inactiv ecard
    265217                                        )
    266218                                {
    267                                         if ($this->debug)       echo "Invalid";
    268219                                        return false;
    269                                 }
    270                                 else
    271                                 {
    272                                         if ($this->debug)       echo "Valid";
     220                                } else {
    273221                                        return true;
    274222                                }
     
    276224                        else
    277225                                return false;
    278                 }
    279                 else
    280                 {
    281                         if ($this->debug)       echo "Invalid";
     226                } else {
    282227                        return true;
    283228                }
    284 
    285229        }
    286230
     
    288232        // delete one ecard
    289233        // force to delete valid ecard
    290         function delete_ecard($ecard_id = null, $force = false)
    291         {
    292        
    293                 if ($ecard_id!== null)
    294                 {
     234        function delete_ecard($ecard_id = null, $force = false) {
     235                if ($ecard_id!== null) {
    295236                        $ecard_info = $this->get_ecard($ecard_id);
    296237                        if ($this->debug)
     
    310251                                WHERE numero ="' . $ecard_id  . '"
    311252                                ';
    312 
    313 //      echo "DELETE";
    314253                        pwg_query($query);
    315254                }
    316255                else
    317                         return false;           
    318        
     256                        return false;
    319257        }
    320258       
    321259        // Delete all invalid ecard
    322         function delete_allinvalid_ecard()
    323         {
     260        function delete_allinvalid_ecard() {
    324261                $date = $this->AjoutJours(date("Y-m-d H:m:s"), $this->my_config['activ'], true);
    325 
    326262
    327263                $query = '
     
    330266                                WHERE date < "' . $date  . '"
    331267                                ';
    332 //              echo "QUERY=".$query;
    333 //      echo "DELETE";
     268
    334269                pwg_query($query);
    335270       
     
    337272       
    338273        // Add tpl to picture.php page to display ecard informations
    339         function display_ecard_to_picture()
    340         {
    341                 global $page, $user, $template, $conf;
    342 
    343                 // init user groups
     274        function display_ecard_to_picture() {
     275                global $page, $user, $template;
     276
     277                // Init user groups
    344278                $this->get_user_groups();
    345279
    346         // Load language files
    347         load_language('plugin.lang', ECARD_PATH);
    348        
    349280                // CSS and JS file for the template
    350                 $css_file = "lightbox-form.css";
    351                 $template->block_html_head('', '<link rel="stylesheet" type="text/css" href="'.ECARD_PATH . 'template/'.$css_file.'">', $smarty, $repeat);
    352                 $template->block_html_head('', '<script src="'.ECARD_PATH .'js/lightbox-form.js" type="text/javascript"></script>', $smarty, $repeat);         
    353 
    354                
    355 //              if (($page['section']) == 'categories' AND !empty($page['category']))           // only on category page!
    356         if (isset($page['section']))
    357                 {
    358                
    359        
     281                $file = "lightbox-form";
     282                $template->append('<link rel="stylesheet" type="text/css" href="'.ECARD_PATH . 'template/'.$file.'.css">');
     283                $template->append('<script src="'.ECARD_PATH .'js/'.$file.'.js" type="text/javascript"></script>');             
     284
     285                // Only on category page!
     286                if (isset($page['section'])) {
    360287                        $upper_names = null;
    361            
    362             if ( !empty($page['category']))
    363             {
    364                 // get all upper categories from the image category to test
    365                 //      - if the parameter for "recursiv" is OK
    366                 //      - if the upper category is activated for this function
    367                 $query = 'SELECT *
    368                             FROM '.CATEGORIES_TABLE.'
    369                             WHERE id = '.$page['category']['id'].'
    370                             ;';
    371                 $cat = mysql_fetch_assoc(pwg_query($query));
    372                 if (empty($cat))
    373                 {
    374                     $upper_ids = null;
    375                 }
    376                 else
    377                 {
    378                     foreach ($cat as $k => $v)
    379                     {
    380                         // If the field is true or false, the variable is transformed into a
    381                         // boolean value.
    382                         if ($cat[$k] == 'true' or $cat[$k] == 'false')
    383                         {
    384                           $cat[$k] = get_boolean( $cat[$k] );
    385                         }
    386                     }
    387                     $upper_ids = explode(',', $cat['uppercats']);
    388                 }
     288                       
     289                        if (!empty($page['category'])) {
     290                                // Gets all upper categories from the image category to test
     291                                //      - if the parameter for "recursive" is OK
     292                                //      - if the upper category is activated for this function
     293                                $query = 'SELECT *
     294                                                        FROM '.CATEGORIES_TABLE.'
     295                                                        WHERE id = '.pwg_db_real_escape_string($page['category']['id']).'
     296                                                        ;';
     297                                $cat = mysql_fetch_assoc(pwg_query($query));
     298                               
     299                                if (empty($cat)) {
     300                                        $upper_ids = null;
     301                                } else {
     302                                        foreach ($cat as $k => $v) {
     303                                                // If the field is true or false, the variable is transformed into a
     304                                                // boolean value.
     305                                                if ($cat[$k] == 'true' or $cat[$k] == 'false') {
     306                                                  $cat[$k] = get_boolean($cat[$k]);
     307                                                }
     308                                        }
     309                                        $upper_ids = explode(',', $cat['uppercats']);
     310                                }
    389311                        }
    390            
    391                         if ($this->my_config['user_cat'])       // !Function anly allowed on user image
    392                         {
     312                       
     313                        if ($this->my_config['user_cat']) {     // !Function only allowed on user image
    393314                                // Check the category name, user name et img author
    394315                                // Get all name for upper categories and current category
    395                 if (isset($cat) and !empty($cat))
    396                 {
    397                     $catname[0] = $cat['name'];
    398                     if (isset($upper_ids) and $upper_ids != null)
    399                     {
    400                         $nb=1;
    401                         foreach ($upper_ids as $upper_cat)
    402                         {
    403                             // Get upper cat info and store the name
    404                             $cat_info = get_cat_info($upper_cat);
    405                             $catname[$nb++] = $cat_info['name'];
    406                             if ($this->debug)
    407                                 echo "Catname[".($nb-1)."]=".$catname[$nb-1]." <br>";
    408                         }
    409                     }
     316                                if (isset($cat) and !empty($cat)) {
     317                                        $catname[0] = $cat['name'];
     318                                        if (isset($upper_ids) and $upper_ids != null) {
     319                                                $nb=1;
     320                                                foreach ($upper_ids as $upper_cat) {
     321                                                        // Get upper cat info and store the name
     322                                                        $cat_info = get_cat_info($upper_cat);
     323                                                        $catname[$nb++] = $cat_info['name'];
     324                                                }
     325                                        }
    410326                                }
    411327                                // Username or the current user
     
    421337                                                .';';
    422338                                $result = pwg_query($query);
    423                                 if (isset($result))
    424                                 {
     339                                if (isset($result)) {
    425340                                        $img_infos = mysql_fetch_array($result);
    426341                                        $authorname = $img_infos['author'];
    427342                                }
    428                                                                
    429 
    430                         }                       
    431                        
    432 /*
    433                         foreach ($page as $k => $v)
    434                         {
    435                                 if (is_array($v))
    436                                         foreach ($v as $kk => $vv)
    437                                                 echo "page[".$k."][".$kk."]=".$vv." <br>";
    438                                 else
    439                                         echo "page[".$k."]=".$v." <br>";
    440                         }
    441 */                     
     343                        }               
    442344               
    443                 // only on available cats
    444                         if ( $this->my_config['allcats']                // Available on all cats
    445                                 OR ( !empty($page['category']) AND in_array($page['category']['id'], $this->my_config['cats'])) // Available on specific cats
     345                        // Only on available cats
     346                        if ($this->my_config['allcats']         // Available on all cats
     347                                OR (!empty($page['category']) AND in_array($page['category']['id'], $this->my_config['cats']))  // Available on specific cats
    446348                                OR ($this->my_config['recursive'] AND isset($upper_ids) AND                             // Available on upper cats this recursiv mode
    447349                                                (array_intersect($upper_ids, $this->my_config['cats']) != array()))
     
    454356                                )
    455357                        {
    456                         // and only available groups
     358                        // And only available groups
    457359                                if (empty($this->my_config['groups'])
    458                                         or (!empty($this->my_config['groups'])
    459                                                 and (array_intersect($this->user_groups, $this->my_config['groups']) != array()))
     360                                        OR (!empty($this->my_config['groups'])
     361                                                AND (array_intersect($this->user_groups, $this->my_config['groups']) != array()))
    460362                                        )
    461363                                {
    462 
    463                
    464                 // Check if user is guest.
    465                 // In this case, force mail to default mail (in params)
    466                 if (is_a_guest())
    467                 {
    468 //                    $this->my_config['expmail_change'] = false; // Disable exp mail change
    469                     if (!empty($this->my_config['defaultmail']))
    470                         $user['email'] = $this->my_config['defaultmail'];
    471                 }
    472                                
    473                                
    474                                
     364                               
     365                                // Check if user is guest.
     366                                // In this case, force mail to default mail (in params)
     367                                if (is_a_guest()) {
     368                                        if (!empty($this->my_config['defaultmail']))
     369                                                $user['email'] = $this->my_config['defaultmail'];
     370                                }
    475371                       
    476                         // Template informations
    477                                         $template->assign( 'ecard', array(
    478                                                         'sujet' => l10n('ecard_send_title'),
    479                                                         'message' => l10n('ecard_send_message'),
    480                                                         'votrenom' => $user['username'],        //"votre nom",
    481                                                         'votremail' => $user['email'],          //"votre mail (test@test.com)",
    482                                                         'sonnom' => l10n('ecard_send_dest_name'),
    483                                                         'sonmail' => l10n('ecard_send_dest_mail'),
    484                                                         'copy'  => $this->my_config['send_copy'] ? 'checked="checked"' : '',
    485                                                         'changemail' => ($this->my_config['expmail_change'] ? '' : 'disabled="disabled"')
    486                                                         ));
    487 
    488                         // TEmplate add for the active parameter choice by the user
    489                                         if ($this->my_config['active_parameter'])       // Allowed for the user
    490                                         {
    491                                                 $template->append('ECARD_ACTIV',array('ID' => 0,'NAME' => l10n('ecard_nolimit'),'SELECTED' => ($this->my_config['activ'] == 0 ? 'checked' : '')));
    492                                                 for($jj=5; $jj < 30; $jj+=5)
    493                                                         $template->append('ECARD_ACTIV',array('ID' => $jj,'NAME' => $jj ,'SELECTED' => ($this->my_config['activ'] == $jj ? 'checked' : '')));
    494                                         }
     372                                // Template informations
     373                                $template->assign( 'ecard', array(
     374                                                'sujet' => l10n('ecard_send_title'),
     375                                                'message' => l10n('ecard_send_message'),
     376                                                'votrenom' => $user['username'],        //"votre nom",
     377                                                'votremail' => $user['email'],          //"votre mail (test@test.com)",
     378                                                'sonnom' => l10n('ecard_send_dest_name'),
     379                                                'sonmail' => l10n('ecard_send_dest_mail'),
     380                                                'copy'  => $this->my_config['send_copy'] ? 'checked="checked"' : '',
     381                                                'changemail' => ($this->my_config['expmail_change'] ? '' : 'disabled="disabled"')
     382                                                ));
     383
     384                                // Template add for the active parameter choice by the user
     385                                if ($this->my_config['active_parameter']) {     // Allowed for the user
     386                                        $template->append('ECARD_ACTIV',array('ID' => 0,'NAME' => l10n('ecard_nolimit'),'SELECTED' => ($this->my_config['activ'] == 0 ? 'checked' : '')));
     387                                        for($jj=5; $jj < 30; $jj+=5)
     388                                                $template->append('ECARD_ACTIV',array('ID' => $jj,'NAME' => $jj ,'SELECTED' => ($this->my_config['activ'] == $jj ? 'checked' : '')));
     389                                }
    495390                                                       
    496                         // TEmplate add for the send method to be chose, by the user
    497                                         // default : text
    498                                         $template->append('ECARD_SEND',array('ID' => 0,'NAME' => l10n('ecard_maillink'),'SELECTED' => ($this->my_config['send_HTML'] ?  '' : 'checked')));
    499                                         if ($this->my_config['send_HTML'])      // Allowed for the user
    500                                         {
    501                                                 $template->append('ECARD_SEND',array('ID' => 1,'NAME' => l10n('ecard_mailhtml') ,'SELECTED' => ($this->my_config['send_HTML'] ? 'checked' : '')));
     391                                // Template add for the send method to be chose, by the user
     392                                // default : text
     393                                $template->append('ECARD_SEND',array('ID' => 0,'NAME' => l10n('ecard_maillink'),'SELECTED' => ($this->my_config['send_HTML'] ?  '' : 'checked')));
     394                                if ($this->my_config['send_HTML']) {    // Allowed for the user
     395                                        $template->append('ECARD_SEND',array('ID' => 1,'NAME' => l10n('ecard_mailhtml') ,'SELECTED' => ($this->my_config['send_HTML'] ? 'checked' : '')));
     396                                }
     397
     398                                // Send the card
     399                                if (isset($_POST['ecard_submit'])) {
     400                                        $send_method = $_POST['ecard_send'];
     401                                        // If conf doesn't allow to modify the %votremail param, force it to user mail
     402                                        if (!isset($_POST['votremail']))
     403                                                $_POST['votremail'] = $user['email'];
     404                                       
     405                                        // Initialize the array for image element
     406                                        $image_element = array();
     407
     408                                        // Get all image informations - to be replaced by a Core PWG function
     409                                        $query = '
     410                                        SELECT *
     411                                          FROM '.IMAGES_TABLE.'
     412                                          WHERE id = '.$page['image_id']
     413                                          .' LIMIT 1'
     414                                          .';';
     415
     416                                        $result = pwg_query($query);
     417                                        if (isset($result))
     418                                                $image_element = mysql_fetch_array($result);
     419                                       
     420                                        // Generate random number
     421                                        $image_element['next_element_id']  = $this->random(15);
     422
     423                                        // Image infos
     424                                        if ($this->my_config['ecard_showinfos']) {
     425                                                if (isset($image_element['name'])) {
     426                                                        $image_element['imginfos'] = $image_element['name'];
     427                                                        if (isset($image_element['author']))
     428                                                                $image_element['imginfos'] .= ' ('.$image_element['author'].')';
     429                                                }
     430                                                       
    502431                                        }
    503432                                               
    504 
    505                                 // Send the card
    506                                         if (isset($_POST['ecard_submit']))
    507                                         {
     433                                        if ($this->debug)       echo "Next_element=".$image_element['next_element_id']."\n";
     434
     435                                        $query = '
     436                                        INSERT INTO ' . ECARD_TABLE .'
     437                                        VALUES ( "'.$image_element['next_element_id'].'","'
     438                                                         .$_POST['votrenom'].'","'
     439                                                         .$_POST['sonnom'].'","'
     440                                                         .$_POST['votremail'].'","'
     441                                                         .$_POST['sonmail'].'","'
     442                                                         .$_POST['sujet'].'","'
     443                                                         .$_POST['message'].'",'
     444                                                         .$image_element['id'].',
     445                                                         now(),'
     446                                                         .(isset($_POST['ecard_activ']) ? $_POST['ecard_activ'] : $this->my_config['activ'])
     447                                                         .');';
     448                                        // TO DO : add valid date (end date or duration) / add number (increment number) /
     449
     450                                        pwg_query($query);
     451
     452                                        // Complete the image_element array with Link for the ecard url to be added in the mail
     453                                        set_make_full_url();
     454                                        $chemin = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$image_element['next_element_id']);
     455                                        $image_element['chemin'] = $chemin;
     456                                        unset_make_full_url();
     457
     458                                        // Complete the image_element with the url to point to the image url
     459                                        set_make_full_url();
     460                                        $image_element['url_picture'] = duplicate_picture_url(
     461                                          array(
     462                                                'image_id' => $image_element['id'],
     463                                                'image_file' => $image_element['file']
     464                                          ),
     465                                          array('start')
     466                                        );
     467                                        unset_make_full_url();
     468
     469                                        $sujetdumail = htmlspecialchars_decode($this->parse( $this->my_config['subject_link'], $_POST));
    508470                                       
    509                                                 $send_method = $_POST['ecard_send'];
    510                                                 // If conf dont allow to modify the %votremail param, force it to user mail
    511                                                 if (!isset($_POST['votremail']))
    512                                                         $_POST['votremail'] = $user['email'];
    513                                                
    514                                                 // Initialize the array for image element
    515                                                 $image_element = array();
    516 
    517                                                 // Get all image informations - to be replaced by a Core PWG function
    518                                                 $query = '
    519                                                 SELECT *
    520                                                   FROM '.IMAGES_TABLE.'
    521                                                   WHERE id = '.$page['image_id']
    522                                                   .' LIMIT 1'
    523                                                   .';';
    524                         //                     echo $query;
    525                                                 $result = pwg_query($query);
    526                                                 if (isset($result))
    527                                                         $image_element = mysql_fetch_array($result);
    528                                                
    529                                                 // Generate random number
    530                                                 $image_element['next_element_id']  = $this->random(15);
    531 
    532                                                 // image infos
    533                                                 if ($this->my_config['ecard_showinfos'])
    534                                                 {
    535                                                         if (isset($image_element['name']))
    536                                                         {
    537                                                                 $image_element['imginfos'] = $image_element['name'];
    538                                                                 if (isset($image_element['author']))
    539                                                                         $image_element['imginfos'] .= ' ('.$image_element['author'].')';
    540                                                         }
    541                                                                
    542                                                 }
    543                                                
    544                         if ($this->debug)       echo "Next_element=".$image_element['next_element_id']."\n";
    545 
    546                                                 $query = '
    547                                                 INSERT INTO ' . ECARD_TABLE .'
    548                                                 VALUES ( "'.$image_element['next_element_id'].'","'
    549                                                                  .$_POST['votrenom'].'","'
    550                                                                  .$_POST['sonnom'].'","'
    551                                                                  .$_POST['votremail'].'","'
    552                                                                  .$_POST['sonmail'].'","'
    553                                                                  .$_POST['sujet'].'","'
    554                                                                  .$_POST['message'].'",'
    555                                                                  .$image_element['id'].',
    556                                                                  now(),'
    557                                                                  .(isset($_POST['ecard_activ']) ? $_POST['ecard_activ'] : $this->my_config['activ'])
    558                                                                  .');';
    559                                                 // TO DO : add valid date (end date or duration) / add number (increment number) /
    560 
    561                         if ($this->debug)                       echo $query."\n";
    562                                                 pwg_query($query);
    563 
    564                                                 // Complete the image_element array with Link for the ecard url to be added in the mail
    565                                                 set_make_full_url();
    566                                                 $chemin = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$image_element['next_element_id']);
    567                                                 $image_element['chemin'] = $chemin;
    568                                                 unset_make_full_url();
    569         //                                      echo "chemin = ".$chemin."\n" ;
    570 
    571                                                 // Complete the image_element with the url to point to the image url
    572                                                 set_make_full_url();
    573                                                 $image_element['url_picture'] = duplicate_picture_url(
    574                                                   array(
    575                                                         'image_id' => $image_element['id'],
    576                                                         'image_file' => $image_element['file']
    577                                                   ),
    578                                                   array('start')
    579                                                 );
    580                                                 unset_make_full_url();
    581                                                
    582 
    583                                                 $sujetdumail = htmlspecialchars_decode($this->parse( $this->my_config['subject_link'], $_POST));
    584                                                
    585                                                 switch($send_method)
    586                                                 {
    587                                                 case 0 : // text
    588                                                         // Get the standard message (in admin param) and parse it with the informations
    589                                                         $messagemail =  stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_link'], $_POST, $image_element)));
    590 
    591                                                         $mail_arg=array('from' => $_POST['votremail'],
    592                                                                                         'subject' => $sujetdumail,
    593                                                                                         'content' => $messagemail,
    594                                                                                         'content_format' => "text/plain",
    595                                                                                         'email_format' => "text/html"
    596                                                                                         );
    597                                                
    598                                                         break;
    599                                                 case 1 : // html
    600                                                         $messagemailHTML =  stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_HTML'], $_POST, $image_element)));
    601 
    602                                                         $mail_arg=array('from' => $_POST['votremail'],
    603                                                                                         'subject' => $sujetdumail,
    604                                                                                         'content' => $messagemailHTML,
    605                                                                                         'content_format' => "text/html",
    606                                                                                         'email_format' => "text/html"
    607                                                                                         );
    608                                                         if ($this->debug)               echo "messagemailHTML=".$messagemailHTML."\n";
    609                                                         break;
    610                                                 }
    611                                                
    612                                                 // Add the copy to expe if param.
    613                                                 if (isset($_POST['copy']))      // send copy to sender
    614                                                         $mail_arg['Bcc'] = array((isset($_POST['votremail']) ? $_POST['votremail'] : $user['email']));
    615                                                
    616                                                 // SEnd the mail
    617                                                 pwg_mail($_POST['sonmail'], $mail_arg);
    618                                                
     471                                        switch($send_method) {
     472                                        case 0 : // text
     473                                                // Get the standard message (in admin param) and parse it with the informations
     474                                                $messagemail =  stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_link'], $_POST, $image_element)));
     475                                                $mail_arg=array('from' => $_POST['votremail'],
     476                                                                                'subject' => $sujetdumail,
     477                                                                                'content' => $messagemail,
     478                                                                                'content_format' => "text/plain",
     479                                                                                'email_format' => "text/html"
     480                                                                                );
     481                                       
     482                                                break;
     483                                        case 1 : // html
     484                                                $messagemailHTML =  stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_HTML'], $_POST, $image_element)));
     485                                                $mail_arg=array('from' => $_POST['votremail'],
     486                                                                                'subject' => $sujetdumail,
     487                                                                                'content' => $messagemailHTML,
     488                                                                                'content_format' => "text/html",
     489                                                                                'email_format' => "text/html"
     490                                                                                );
     491                                                if ($this->debug)               echo "messagemailHTML=".$messagemailHTML."\n";
     492                                                break;
    619493                                        }
    620                                         $template->set_filenames(array('ecard' =>  ECARD_ROOT.'/template/ecard.tpl'));
    621                                         $template->concat('COMMENT_IMG', $template->parse('ecard', true));
     494                                       
     495                                        // Add the copy to expe if param.
     496                                        if (isset($_POST['copy']))      // send copy to sender
     497                                                $mail_arg['Bcc'] = array((isset($_POST['votremail']) ? $_POST['votremail'] : $user['email']));
     498                                       
     499                                        // Send the mail
     500                                        pwg_mail($_POST['sonmail'], $mail_arg);
     501                                }
     502                               
     503                                $template->set_filenames(array('ecard' =>  ECARD_ROOT.'/template/ecard.tpl'));
     504                                $template->concat('COMMENT_IMG', $template->parse('ecard', true));
    622505                                }
    623506                        }
  • extensions/Piwecard/language/en_UK/plugin.lang.php

    r9342 r19732  
    7676$lang['ecard_message_link']                             = 'Message sent (mail for link mode only)';
    7777$lang['ecard_message_html']                             = 'Message sent (mail HTML with photo)';
    78 $lang['ecard_parameters']                       =
     78$lang['ecard_parameters']                               =
    7979'<b><u>Paramètres </u></b>:<br>
    8080<b>%votrenom</b>    ==> Sender name<br>
  • extensions/Piwecard/main.inc.php

    r10629 r19732  
    22/*
    33 * Plugin Name: Piwecard
    4  * Version: 1.1.0
     4 * Version: auto
    55 * Description: envoi de Cartes Virtuelles
    66 * Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=487
     
    3636global $page, $template;
    3737
     38// Load language files
     39load_language('plugin.lang', ECARD_PATH);       
    3840
    3941$ecard = new ecard();
  • extensions/Piwecard/maintain.inc.php

    r8771 r19732  
    88
    99
    10 function plugin_install()
    11 {
     10function plugin_install() {
    1211        global $prefixeTable, $conf;
    1312
    1413        $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'ecard"';
    1514        $result = pwg_query($query);
    16         if (!mysql_fetch_row($result))
    17         {
     15        if (!mysql_fetch_row($result)) {
    1816
    1917        // ecard description
     
    4038
    4139    pwg_query($q);
    42    
    43 
    44        
    4540        }
    46 
    4741}
    4842
    49 function plugin_activate()
    50 {
     43function plugin_activate() {
    5144 
    5245}
    5346
    54 function plugin_uninstall()
    55 {
     47function plugin_uninstall() {
    5648    global $prefixeTable;
    5749
     
    6456    ;';
    6557    pwg_query($q);
    66 
    6758}
    68 
    69 
    7059?>
  • extensions/Piwecard/publish.php

    r8771 r19732  
    4949                                'url'   => $url,
    5050                                'name'  => $row['name'],
    51                                 'thumb' => get_thumbnail_url($row),
    52                                 'img'   => get_image_url($row),
     51                                'thumb' => DerivativeImage::thumb_url($row),
     52                                'img'   => DerivativeImage::url(IMG_LARGE, $row),
    5353                                'adrexp' => $tableau['adrexp'],
    5454                                'nomexp' => $tableau['nomexp'],
  • extensions/Piwecard/template/ecard.tpl

    r8771 r19732  
    1 
    2 
    31<div id="filter"></div>
    42<div id="box">
Note: See TracChangeset for help on using the changeset viewer.