Changeset 19732 for extensions/Piwecard
- Timestamp:
- Jan 2, 2013, 11:48:21 PM (12 years ago)
- Location:
- extensions/Piwecard
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Piwecard/admin/template/consult.tpl
r8771 r19732 2 2 <h2>{$ECARD_VERSION}</h2> 3 3 </div> 4 <p>5 {'ecard_consult_detail'|@translate}6 </p>7 8 4 <fieldset> 9 5 <legend>{'ecard_list'|@translate}</legend> -
extensions/Piwecard/admin/template/manage.tpl
r10615 r19732 1 {html_head}2 {/html_head}3 4 1 <div class="titrePage"> 5 2 <h2>{$ECARD_VERSION}</h2> 6 3 </div> 7 <p>8 {'ecard_management'|@translate}9 </p>10 4 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data"> 11 5 <fieldset> 12 6 <legend>{'ecard_manage'|@translate}</legend> 13 7 <table> 14 15 <tr>16 <td>{'ecard_authorized_group'|@translate} </b></td>17 <td>{$group_perm.GROUPSELECTION}</td>18 </tr>19 <tr><td colspan="2"><i>{'ecard_authorized_group_info'|@translate}</i></td></tr>20 8 <tr><td colspan="2"><br></td></tr> 21 9 <TR> … … 57 45 </tr> 58 46 <tr> 59 <td class="categoryList1" 47 <td class="categoryList1" colspan="2"> 60 48 <div id="cat_select"> 61 49 {$DOUBLE_SELECT} -
extensions/Piwecard/admin/template/params.tpl
r9342 r19732 2 2 <h2>{$ECARD_VERSION}</h2> 3 3 </div> 4 <p>5 {'ecard_params'|@translate}6 </p>7 4 <form method="post" action="" ENCTYPE="multipart/form-data"> 8 5 -
extensions/Piwecard/include/config_param.inc.php
r8771 r19732 15 15 '%sujet' => isset($_POST['sujet']) ? $_POST['sujet'] : '' , 16 16 '%message' => isset($_POST['message']) ? $_POST['message'] : '' , 17 '%imgurl' => get_image_url($image_element),17 '%imgurl' => DerivativeImage::thumb_url($image_element) , 18 18 '%imginfos' => isset($image_element['imginfos']) ? $image_element['imginfos'] : '' , 19 19 ); -
extensions/Piwecard/include/ecard.class.php
r9342 r19732 7 7 global $user, $conf; 8 8 9 class ecard 10 { 9 class ecard { 11 10 var $debug = false; 12 11 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.... 15 13 var $user_groups = array(); 16 14 17 15 // Class constructor 18 function ecard() 19 { 16 function ecard() { 20 17 $this->load_config(); 21 18 } … … 23 20 24 21 // Load general configuration from config_database 25 function load_config() 26 { 27 22 function load_config() { 28 23 $query = ' 29 24 SELECT value … … 34 29 $result = pwg_query($query); 35 30 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 } 43 36 } 44 37 $this->load_default_config(); … … 46 39 47 40 // Initialize default values of params 48 private function load_default_config() 49 { 41 private function load_default_config() { 50 42 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; 55 46 } 56 47 } … … 77 68 78 69 // Retrieve user groups 79 function get_user_groups() 80 { 70 function get_user_groups() { 81 71 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 92 73 $query = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';'; 93 if ($this->debug) echo $query."\n"; 74 94 75 $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; 99 84 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;110 85 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() { 116 90 global $page; 117 91 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') { 124 93 include(ECARD_PATH . 'publish.php'); 125 94 } … … 127 96 128 97 //Générer une chaine de caractère unique et aléatoire 129 130 98 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; 138 106 } 139 107 140 108 // 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)); 151 116 } 152 117 153 118 function AjoutJours($debut, $jours, $soustrait = false) { 154 155 156 119 $tDeb = explode("-", substr($debut,0,strpos($debut, ' '))); 120 $tDebH = explode(":", substr($debut,strpos($debut, ' ')+1)); 121 $tFin = ""; 157 122 158 123 $nb_ans = (int)(($jours)/365); … … 164 129 else 165 130 $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) { 173 136 include (ECARD_PATH.'include/config_param.inc.php'); 174 137 … … 185 148 186 149 // Get the number of ecard in the database 187 function get_nb_ecard() 188 { 189 150 function get_nb_ecard() { 190 151 $query = 'SELECT COUNT(DISTINCT numero) as nb FROM '.ECARD_TABLE 191 152 . ' ORDER BY date' 192 153 .';'; 193 154 $result = pwg_query($query); 194 if ($result) 195 { 155 if ($result) { 196 156 $nb=mysql_fetch_assoc($result); 197 157 return $nb['nb']; … … 202 162 203 163 // Get the number of valid ecard in the database 204 function get_nb_valid_ecard() 205 { 206 164 function get_nb_valid_ecard() { 207 165 $query = 'SELECT numero,date,duration FROM '.ECARD_TABLE 208 166 .';'; 209 167 $result = pwg_query($query); 210 168 $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 215 171 $count++; 216 172 } … … 220 176 221 177 // 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) { 226 180 $query = ' 227 181 SELECT * … … 241 195 242 196 // 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) { 247 199 $ecard_info = $this->get_ecard($ecard_id); 248 200 if ($ecard_info != false) … … 261 213 262 214 if (isset ($ecard_info) 263 and$duration != 0 // 0 means always activ264 and($this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) > $duration) // Inactiv ecard215 AND $duration != 0 // 0 means always activ 216 AND ($this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) > $duration) // Inactiv ecard 265 217 ) 266 218 { 267 if ($this->debug) echo "Invalid";268 219 return false; 269 } 270 else 271 { 272 if ($this->debug) echo "Valid"; 220 } else { 273 221 return true; 274 222 } … … 276 224 else 277 225 return false; 278 } 279 else 280 { 281 if ($this->debug) echo "Invalid"; 226 } else { 282 227 return true; 283 228 } 284 285 229 } 286 230 … … 288 232 // delete one ecard 289 233 // 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) { 295 236 $ecard_info = $this->get_ecard($ecard_id); 296 237 if ($this->debug) … … 310 251 WHERE numero ="' . $ecard_id . '" 311 252 '; 312 313 // echo "DELETE";314 253 pwg_query($query); 315 254 } 316 255 else 317 return false; 318 256 return false; 319 257 } 320 258 321 259 // Delete all invalid ecard 322 function delete_allinvalid_ecard() 323 { 260 function delete_allinvalid_ecard() { 324 261 $date = $this->AjoutJours(date("Y-m-d H:m:s"), $this->my_config['activ'], true); 325 326 262 327 263 $query = ' … … 330 266 WHERE date < "' . $date . '" 331 267 '; 332 // echo "QUERY=".$query; 333 // echo "DELETE"; 268 334 269 pwg_query($query); 335 270 … … 337 272 338 273 // 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 344 278 $this->get_user_groups(); 345 279 346 // Load language files347 load_language('plugin.lang', ECARD_PATH);348 349 280 // 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'])) { 360 287 $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 } 389 311 } 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 393 314 // Check the category name, user name et img author 394 315 // 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 } 410 326 } 411 327 // Username or the current user … … 421 337 .';'; 422 338 $result = pwg_query($query); 423 if (isset($result)) 424 { 339 if (isset($result)) { 425 340 $img_infos = mysql_fetch_array($result); 426 341 $authorname = $img_infos['author']; 427 342 } 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 } 442 344 443 // only on available cats444 if ( 445 OR ( 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 446 348 OR ($this->my_config['recursive'] AND isset($upper_ids) AND // Available on upper cats this recursiv mode 447 349 (array_intersect($upper_ids, $this->my_config['cats']) != array())) … … 454 356 ) 455 357 { 456 // and only available groups358 // And only available groups 457 359 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())) 460 362 ) 461 363 { 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 } 475 371 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 } 495 390 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 502 431 } 503 432 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)); 508 470 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; 619 493 } 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)); 622 505 } 623 506 } -
extensions/Piwecard/language/en_UK/plugin.lang.php
r9342 r19732 76 76 $lang['ecard_message_link'] = 'Message sent (mail for link mode only)'; 77 77 $lang['ecard_message_html'] = 'Message sent (mail HTML with photo)'; 78 $lang['ecard_parameters'] =78 $lang['ecard_parameters'] = 79 79 '<b><u>Paramètres </u></b>:<br> 80 80 <b>%votrenom</b> ==> Sender name<br> -
extensions/Piwecard/main.inc.php
r10629 r19732 2 2 /* 3 3 * Plugin Name: Piwecard 4 * Version: 1.1.04 * Version: auto 5 5 * Description: envoi de Cartes Virtuelles 6 6 * Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=487 … … 36 36 global $page, $template; 37 37 38 // Load language files 39 load_language('plugin.lang', ECARD_PATH); 38 40 39 41 $ecard = new ecard(); -
extensions/Piwecard/maintain.inc.php
r8771 r19732 8 8 9 9 10 function plugin_install() 11 { 10 function plugin_install() { 12 11 global $prefixeTable, $conf; 13 12 14 13 $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'ecard"'; 15 14 $result = pwg_query($query); 16 if (!mysql_fetch_row($result)) 17 { 15 if (!mysql_fetch_row($result)) { 18 16 19 17 // ecard description … … 40 38 41 39 pwg_query($q); 42 43 44 45 40 } 46 47 41 } 48 42 49 function plugin_activate() 50 { 43 function plugin_activate() { 51 44 52 45 } 53 46 54 function plugin_uninstall() 55 { 47 function plugin_uninstall() { 56 48 global $prefixeTable; 57 49 … … 64 56 ;'; 65 57 pwg_query($q); 66 67 58 } 68 69 70 59 ?> -
extensions/Piwecard/publish.php
r8771 r19732 49 49 'url' => $url, 50 50 '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), 53 53 'adrexp' => $tableau['adrexp'], 54 54 'nomexp' => $tableau['nomexp'], -
extensions/Piwecard/template/ecard.tpl
r8771 r19732 1 2 3 1 <div id="filter"></div> 4 2 <div id="box">
Note: See TracChangeset
for help on using the changeset viewer.