Changeset 19968
- Timestamp:
- Jan 8, 2013, 12:32:56 AM (11 years ago)
- Location:
- extensions/Piwecard
- Files:
-
- 1 added
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/Piwecard/admin/admin_consult.php
r19956 r19968 36 36 $result = pwg_query($query); 37 37 38 while($file = mysql_fetch_assoc($result)) {38 while($file = pwg_db_fetch_assoc($result)) { 39 39 $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['id']); 40 40 -
extensions/Piwecard/admin/admin_manage.php
r19956 r19968 4 4 global $template, $page; 5 5 6 $ me= get_plugin_data($plugin_id);6 $piwecard = get_plugin_data($plugin_id); 7 7 8 $template->set_filenames( 9 array('plugin_admin_content'=> ECARD_ROOT.'/admin/template/admin_manage.tpl',10 'double_select'=> 'double_select.tpl'11 ));8 $template->set_filenames(array( 9 'plugin_admin_content' => ECARD_ROOT.'/admin/template/admin_manage.tpl', 10 'double_select' => 'double_select.tpl' 11 )); 12 12 13 // Switch on right side (=>) 14 if (isset($_POST['falsify']) and isset($_POST['cat_true']) and count($_POST['cat_true']) > 0) { 15 foreach ($_POST['cat_true'] as $cat) 16 unset($piwecard->my_config['cats'][array_search($cat, $piwecard->my_config['cats'])]); 17 $piwecard->save_config(); 18 } 13 19 14 15 16 // Switch on right side (=> ) 17 if ( isset($_POST['falsify']) and !is_adviser() 18 and isset($_POST['cat_true']) and count($_POST['cat_true']) > 0) 19 { 20 foreach ($_POST['cat_true'] as $cat) 21 unset($me->my_config['cats'][array_search($cat,$me->my_config['cats'])]); 22 23 $me->save_config(); 24 25 } 26 // Switch on left side ( <=) 27 if ( isset($_POST['trueify']) and !is_adviser() 28 and isset($_POST['cat_false']) and count($_POST['cat_false']) > 0) 29 { 30 31 $query = ' 32 SELECT id, name, uppercats, global_rank 33 FROM '.CATEGORIES_TABLE. 34 ' WHERE id IN ("'.implode('","', $_POST['cat_false']).'");'; 35 20 // Switch on left side (<=) 21 if (isset($_POST['trueify']) and isset($_POST['cat_false']) and count($_POST['cat_false']) > 0) { 22 $query = 'SELECT id, name, uppercats, global_rank FROM '.CATEGORIES_TABLE.' WHERE id IN ("'.implode('","', $_POST['cat_false']).'");'; 36 23 $result = pwg_query($query); 37 24 $categories = array(); 38 if (!empty($result)) 39 {40 while ($row = mysql_fetch_assoc($result))25 26 if (!empty($result)) { 27 while ($row = pwg_db_fetch_assoc($result)) 41 28 array_push($categories, $row); 42 29 } 43 30 usort($categories, 'global_rank_compare'); 44 31 45 if (!empty($result)) 46 { 47 foreach ($categories as $cat) 48 { 49 array_push($me->my_config['cats'], $cat['id']); 32 if (!empty($result)) { 33 foreach ($categories as $cat) { 34 array_push($piwecard->my_config['cats'], $cat['id']); 50 35 } 51 36 } 52 53 $me->save_config(); 37 $piwecard->save_config(); 54 38 } 55 56 39 57 40 if (isset($_POST['submit'])) { 58 59 $me->my_config['allcats'] = isset($_POST['allcats']); 60 $me->my_config['user_cat'] = isset($_POST['user_cat']); 61 $me->my_config['recursive'] = isset($_POST['recursiv']); 62 $me->my_config['groups'] = isset($_POST['groups']) ? 63 array_map("mysql_escape_string", $_POST['groups']) : 64 array(); 65 66 $me->save_config(); 41 $piwecard->my_config['allcats'] = isset($_POST['allcats']); 42 $piwecard->my_config['user_cat'] = isset($_POST['user_cat']); 43 $piwecard->my_config['recursive'] = isset($_POST['recursiv']); 44 if ($piwecard->my_config['groups'] = isset($_POST['groups'])) 45 array_map("mysql_escape_string", $_POST['groups']); 46 else 47 array(); 48 $piwecard->save_config(); 67 49 array_push($page['infos'], l10n('ecard_admin_saveOK')); 68 69 50 } 70 71 72 51 73 52 // Groups selection 74 53 $groups = get_all_groups(); 75 if (!empty($groups)) 76 { 77 $template->assign('group_perm', array('GROUPSELECTION' => get_html_groups_selection($groups, 'groups', (isset($me->my_config['groups']) ? $me->my_config['groups'] : array())))); 78 54 if (!empty($groups)) { 55 $template->assign('group_perm', array('GROUPSELECTION' => get_html_groups_selection($groups, 'groups', (isset($piwecard->my_config['groups']) ? $piwecard->my_config['groups'] : array())))); 79 56 } 80 81 82 57 83 58 // Test double select wall categories 84 59 // Categories non prises en compte 85 $query = ' 86 SELECT id, name, uppercats, global_rank 87 FROM '.CATEGORIES_TABLE. 88 ' WHERE id not IN ("'.implode('","', $me->my_config['cats']).'");'; 89 90 $result = pwg_query($query); 91 $categories = array(); 92 if (!empty($result)) 93 { 94 while ($row = mysql_fetch_assoc($result)) 60 $query = 'SELECT id, name, uppercats, global_rank FROM '.CATEGORIES_TABLE.' WHERE id not IN ("'.implode('","', $piwecard->my_config['cats']).'");'; 61 $result = pwg_query($query); 62 $categories = array(); 63 if (!empty($result)) { 64 while ($row = pwg_db_fetch_assoc($result)) 95 65 array_push($categories, $row); 96 66 } … … 98 68 99 69 $tpl = array(); 100 if (!empty($result)) 101 { 102 foreach ($categories as $cat) 103 { 104 $tpl[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], 105 null, 106 false); 107 70 if (!empty($result)) { 71 foreach ($categories as $cat) { 72 $tpl[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false); 108 73 } 109 74 } … … 111 76 $template->assign( 'category_option_false_selected', array()); 112 77 113 114 115 116 78 // Categories prises en compte 117 118 $query = ' 119 SELECT id, name, uppercats, global_rank 120 FROM '.CATEGORIES_TABLE. 121 ' WHERE id IN ("'.implode('","', $me->my_config['cats']).'");'; 122 79 $query = 'SELECT id, name, uppercats, global_rank FROM '.CATEGORIES_TABLE.' WHERE id IN ("'.implode('","', $piwecard->my_config['cats']).'");'; 123 80 $result = pwg_query($query); 124 81 $categories = array(); 125 82 if (!empty($result)) 126 83 { 127 while ($row = mysql_fetch_assoc($result))84 while ($row = pwg_db_fetch_assoc($result)) 128 85 array_push($categories, $row); 129 86 } 130 87 usort($categories, 'global_rank_compare'); 131 88 $tpl2 = array(); 132 if (!empty($result)) 133 { 134 foreach ($categories as $cat) 135 { 136 $tpl2[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], 137 null, 138 false); 139 89 if (!empty($result)) { 90 foreach ($categories as $cat) { 91 $tpl2[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false); 140 92 } 141 93 } … … 143 95 $template->assign( 'category_option_true_selected', array()); 144 96 145 $template->assign('ECARD_ALLCATS', ($me->my_config['allcats'] ? 'checked="checked"' : '')); 146 $template->assign('ECARD_USERCAT', ($me->my_config['user_cat'] ? 'checked="checked"' : '')); 147 $template->assign('ECARD_RECURSIV', ($me->my_config['recursive'] ? 'checked="checked"' : '')); 148 97 $template->assign('ECARD_ALLCATS', ($piwecard->my_config['allcats'] ? 'checked="checked"' : '')); 98 $template->assign('ECARD_USERCAT', ($piwecard->my_config['user_cat'] ? 'checked="checked"' : '')); 99 $template->assign('ECARD_RECURSIV', ($piwecard->my_config['recursive'] ? 'checked="checked"' : '')); 149 100 150 101 $template->assign(Array( … … 154 105 )); 155 106 156 157 158 107 $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); 159 108 $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); 160 109 110 function get_html_groups_selection($groups, $fieldname, $selecteds = array()) { 111 global $conf; 112 113 if (count ($groups) == 0) { 114 return ''; 115 } 116 117 $output = '<div id="'.$fieldname.'">'; 118 $id = 1; 119 120 foreach ($groups as $group) { 121 $output.= '<input type="checkbox" name="'.$fieldname.'[]" id="group_'.$id++.'" value="'.$group['id'].'"'; 161 122 123 if (in_array($group['id'], $selecteds)) { 124 $output.= ' checked="checked"'; 125 } 162 126 163 function get_html_groups_selection( 164 $groups, 165 $fieldname, 166 $selecteds = array() 167 ) 168 { 169 global $conf; 170 if (count ($groups) == 0 ) 171 { 172 return ''; 173 } 174 $output = '<div id="'.$fieldname.'">'; 175 $id = 1; 176 foreach ($groups as $group) 177 { 178 $output.= 127 $output.= '><label> '. $group['name'].'</label>\n'; 128 } 129 $output.= '</div>'; 179 130 180 '<input type="checkbox" name="'.$fieldname.'[]"' 181 .' id="group_'.$id++.'"' 182 .' value="'.$group['id'].'"' 183 ; 184 185 if (in_array($group['id'], $selecteds)) 186 { 187 $output.= ' checked="checked"'; 188 } 189 190 $output.= 191 '><label>' 192 .' '. $group['name'] 193 .'</label>' 194 ."\n" 195 ; 196 } 197 $output.= '</div>'; 198 199 return $output; 131 return $output; 200 132 } 201 133 134 function get_all_groups() { 135 $query = 'SELECT id, name FROM '.GROUPS_TABLE.' ORDER BY name ASC;'; 136 $result = pwg_query($query); 202 137 138 $groups = array(); 139 while ($row = pwg_db_fetch_assoc($result)) { 140 array_push($groups, $row); 141 } 142 uasort($groups, 'name_compare'); 203 143 204 function get_all_groups() 205 { 206 $query = ' 207 SELECT id, name 208 FROM '.GROUPS_TABLE.' 209 ORDER BY name ASC 210 ;'; 211 $result = pwg_query($query); 212 213 $groups = array(); 214 while ($row = mysql_fetch_assoc($result)) 215 { 216 array_push($groups, $row); 217 } 218 219 uasort($groups, 'name_compare'); 220 return $groups; 144 return $groups; 221 145 } 222 223 224 146 ?> -
extensions/Piwecard/admin/template/admin_manage.tpl
r19926 r19968 1 {footer_script} 2 {literal} 3 $(document).ready(function(){ 4 if ($("#ecard_selected_cats").attr('checked') == "checked") { 5 $("#ecard_selected_cats_options").css("display","block"); 6 } else { 7 $("#ecard_selected_cats_options").css("display","none"); 8 } 9 10 $("#ECardAdminManage").click(function(){ 11 if ($("#ecard_selected_cats").attr('checked') == "checked") { 12 $("#ecard_selected_cats_options").show("fast"); 13 } else { 14 $("#ecard_selected_cats_options").hide("fast"); 15 } 16 }); 17 }); 18 {/literal} 19 {/footer_script} 20 1 21 <div class="titrePage"> 2 <h2>{$ECARD_VERSION}</h2>22 <h2>{'ecard'|@translate}</h2> 3 23 </div> 4 24 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data"> 5 <fieldset> 6 <legend>{'ecard_manage'|@translate}</legend> 7 <table> 8 <tr><td colspan="2"><br></td></tr> 9 <TR> 10 <TD colspan="2"> 11 <b><u>{'ecard_manage'|@translate} 1 :</u></b> <input type="checkbox" name="user_cat" {$ECARD_USERCAT}/> {'ecard_active_user_cat'|@translate} 12 <br/> 13 </TD> 14 </TR> 15 <TR> 16 <TD colspan="2"> 17 <b><u>{'ecard_manage'|@translate} 2 :</u></b> <input type="checkbox" name="allcats" {$ECARD_ALLCATS}/> {'ecard_active_all_cats'|@translate} 18 <br/> 19 </TD> 20 </TR> 21 <TD colspan="2"> 22 <b><u>{'ecard_manage'|@translate} 3 :</u></b> {'ecard_active_spec_cats'|@translate} 23 <br/> 24 </TD> 25 </TR> 26 <TR> 27 <TD colspan="2"> 28 <table> 29 <tr> 30 <td colspan ="2"> 31 {'option'|@translate} : <input type="checkbox" name="recursiv" {$ECARD_RECURSIV}/> {'ecard_recursiv'|@translate} 32 <br/> 33 </TD> 34 </TR> 35 <TR> 36 <TD colspan="2"><br> 37 <td> 38 </tr> 39 <TR > 40 <td align="left" colspan="2"> 41 <div id="cat_select0"> 42 {'option'|@translate} : <b>{'ecard_cat'|@translate} </b> 43 </div> 44 </td> 45 </tr> 46 <tr> 47 <td class="categoryList1" colspan="2"> 48 <div id="cat_select"> 25 <fieldset> 26 <legend>{'ecard_manage'|@translate}</legend> 27 <div id="ECardAdminManage"> 28 <div> 29 <input type="radio" name="ecard_manage" id="ecard_user_cats" value="ecard_user_cats" {$ecard.user_cats} /><label for="ecard_user_cats">{'ecard_active_user_cat'|@translate}</label><br /> 30 </div> 31 <div> 32 <input type="radio" name="ecard_manage" id="ecard_all_cats" value="ecard_all_cats" {$ecard.all_cats} /><label for="ecard_all_cats">{'ecard_active_all_cats'|@translate}</label><br /> 33 </div> 34 <div> 35 <input type="radio" name="ecard_manage" id="ecard_selected_cats" value="ecard_selected_cats" {$ecard.selected_cats}><label for="ecard_selected_cats">{'ecard_active_spec_cats'|@translate}</label><br /> 36 <div id="ecard_selected_cats_options"> 37 <input type="checkbox" name="ecard_selected_cats_recursive" id="ecard_selected_cats_recursive" {$ecard.selected_cats_recursive} /><label for="ecard_selected_cats_recursive">{'ecard_recursive'|@translate}</label><br /> 38 <div id="ecard_cat_select"> 49 39 {$DOUBLE_SELECT} 50 40 </div> 51 </td> 52 </tr> 53 </table> 54 </td> 55 </tr> 56 57 </table> 58 59 60 <br/> 61 </fieldset> 62 63 <p><input type="submit" name="submit" value="{'ecard_admin_submit'|@translate}" /></p> 64 41 </div> 42 </div> 43 <div> 44 <input type="submit" name="submit" value="{'Submit'|@translate}" /> 45 </div> 46 </div> 47 </fieldset> 65 48 </form> -
extensions/Piwecard/admin/template/admin_params.tpl
r19926 r19968 1 1 <div class="titrePage"> 2 <h2>{$ ECARD_VERSION}</h2>2 <h2>{$ecard}</h2> 3 3 </div> 4 4 <form method="post" action="" ENCTYPE="multipart/form-data"> 5 <div id="ECardAdminParams"> 6 <fieldset> 7 <legend>{'ecard_config'|@translate}</legend> 8 <div> 9 {'ecard_activ_nb'|@translate} 10 <select id="ecard_activ" name="ecard_activ"> 11 {foreach from=$ECARD_ACTIV item=ECARD_ACTIV} 12 <option value="{$ECARD_ACTIV.ID}" {$ECARD_ACTIV.SELECTED}>{$ECARD_ACTIV.NAME}</option> 13 {/foreach} 14 </select> 15 </div> 16 <div> 17 <input type="checkbox" name="ecard_sendcopy" {$ECARD_SENDCOPY}/> {'ecard_send_copy'|@translate} 18 </div> 19 <div> 20 <input type="checkbox" name="ecard_modifexpmail" {$ECARD_MODIFEXPMAIL}/> {'ecard_nomodif_expmail'|@translate} 21 </div> 22 <div> 23 <input type="checkbox" name="ecard_sendhtml" {$ECARD_SENDHTML}/> {'ecard_send_HTML'|@translate} 24 </div> 25 <div> 26 <input type="checkbox" name="ecard_showinfos" {$ECARD_SHOWINFOS}/> {'ecard_show_infos'|@translate} 27 </div> 28 <div> 29 {'ecard_admin_nb_page'|@translate} 30 <select id="ecard_nb_page" name="ecard_nb_page"> 31 {foreach from=$ECARD_NB_PAGE item=ECARD_NB_PAGE} 32 <option value="{$ECARD_NB_PAGE.ID}" {$ECARD_NB_PAGE.SELECTED}>{$ECARD_NB_PAGE.NAME}</option> 33 {/foreach} 34 </select> 35 </div> 36 <div> 37 {'ecard_default_mail'|@translate} 38 <input type="text" maxlength="50" size="50" name="defaultmail" id="defaultmail" value="{$ECARD_DEFAULT_MAIL}" /> 39 </div> 40 </fieldset> 5 41 6 <fieldset> 7 <legend>{'ecard_config'|@translate}</legend> 8 <ul> 9 <li> 10 {'ecard_activ_nb'|@translate} 11 <select id="ecard_activ" name="ecard_activ"> 12 {foreach from=$ECARD_ACTIV item=ECARD_ACTIV} 13 <option value="{$ECARD_ACTIV.ID}" {$ECARD_ACTIV.SELECTED}>{$ECARD_ACTIV.NAME}</option> 14 {/foreach} 15 </select> 16 </li> 17 <li> 18 <input type="checkbox" name="ecard_sendcopy" {$ECARD_SENDCOPY}/> {'ecard_send_copy'|@translate} 19 <br/> 20 </li> 21 <li> 22 <input type="checkbox" name="ecard_modifexpmail" {$ECARD_MODIFEXPMAIL}/> {'ecard_nomodif_expmail'|@translate} 23 <br/> 24 </li> 25 <li> 26 <input type="checkbox" name="ecard_sendhtml" {$ECARD_SENDHTML}/> {'ecard_send_HTML'|@translate} 27 <br/> 28 </li> 29 <li> 30 <input type="checkbox" name="ecard_showinfos" {$ECARD_SHOWINFOS}/> {'ecard_show_infos'|@translate} 31 <br/> 32 </li> 33 <li> 34 {'ecard_admin_nb_page'|@translate} 35 <select id="ecard_nb_page" name="ecard_nb_page"> 36 {foreach from=$ECARD_NB_PAGE item=ECARD_NB_PAGE} 37 <option value="{$ECARD_NB_PAGE.ID}" {$ECARD_NB_PAGE.SELECTED}>{$ECARD_NB_PAGE.NAME}</option> 38 {/foreach} 39 </select> 40 </li> 41 <li> 42 {'ecard_default_mail'|@translate} <input type="text" maxlength="50" size="50" name="defaultmail" id="defaultmail" value="{$ECARD_DEFAULT_MAIL}" /> 42 <fieldset> 43 <legend>{'ecard_mail_config'|@translate}</legend> 44 </br> 45 <ul> 46 <li> 47 <span class="property"> 48 <label for="ecard_subject_link">{'ecard_subject_link'|@translate}</label> 49 </span> 50 <input type="text" maxlength="255" size="50" name="ecard_subject_link" id="ecard_subject_link" value="{$ECARD_SUBJECT_LINK}" /> 51 </li> 52 <li> 43 53 44 </li> 45 </ul> 54 <span class="property"> 55 <label for="page_banner">{'ecard_message_link'|@translate}</label> 56 </span> 57 <textarea name="ecard_message_link" id="ecard_message_link" rows="10" cols="50" style="width:100%; height: 150px;">{$ECARD_MESSAGE_LINK}</textarea> 58 </li> 59 <li> 46 60 47 </fieldset> 48 49 <fieldset> 50 <legend>{'ecard_mail_config'|@translate}</legend> 51 </br> 52 <ul> 53 <li> 54 <span class="property"> 55 <label for="ecard_subject_link">{'ecard_subject_link'|@translate}</label> 56 </span> 57 <input type="text" maxlength="255" size="50" name="ecard_subject_link" id="ecard_subject_link" value="{$ECARD_SUBJECT_LINK}" /> 58 </li> 59 <li> 60 61 <span class="property"> 62 <label for="page_banner">{'ecard_message_link'|@translate}</label> 63 </span> 64 <textarea name="ecard_message_link" id="ecard_message_link" rows="10" cols="50" style="width:100%; height: 150px;">{$ECARD_MESSAGE_LINK}</textarea> 65 </li> 66 <li> 67 68 <span class="property"> 69 <label for="page_banner">{'ecard_message_html'|@translate}</label> 70 </span> 71 <textarea name="ecard_message_html" id="ecard_message_html" rows="10" cols="50" style="width:100%; height: 200px;">{$ECARD_MESSAGE_HTML}</textarea> 72 </li> 73 <p><div align="left"> 74 <small>{'ecard_parameters'|@translate}<small> 75 </div></p> 76 </ul> 77 78 </fieldset> 79 80 <p><input type="submit" name="submit" value="{'ecard_admin_submit'|@translate}" /></p> 81 61 <span class="property"> 62 <label for="page_banner">{'ecard_message_html'|@translate}</label> 63 </span> 64 <textarea name="ecard_message_html" id="ecard_message_html" rows="10" cols="50" style="width:100%; height: 200px;">{$ECARD_MESSAGE_HTML}</textarea> 65 </li> 66 <p><div align="left"> 67 <small>{'ecard_parameters'|@translate}<small> 68 </div></p> 69 </ul> 70 71 </fieldset> 72 <div> 73 <input type="submit" name="submit" value="{'Submit'|@translate}" /> 74 </div> 75 </div> 82 76 </form> -
extensions/Piwecard/include/piwecard.class.php
r19956 r19968 2 2 global $user, $conf; 3 3 4 class ecard {4 class Piwecard { 5 5 var $my_config; 6 6 var $user_groups = array(); … … 17 17 18 18 if(isset($result)) { 19 $row = mysql_fetch_row($result);19 $row = pwg_db_fetch_row($result); 20 20 if(is_string($row[0])) { 21 21 $this->my_config = unserialize(($row[0])); … … 27 27 // Initialize default values of params 28 28 private function load_default_config() { 29 include ECARD_INC_PATH.'default_values.inc.php';29 require_once(ECARD_INSTALL_PATH.'default_values.inc.php'); 30 30 foreach ($ecard_default_values as $key => $value) { 31 31 if (!isset($this->my_config[$key])) … … 36 36 // Save general configuration to config_database 37 37 function save_config() { 38 $query = 'UPDATE '.CONFIG_TABLE.' SET value="'. serialize($this->my_config).'" WHERE param="piwecard";';38 $query = 'UPDATE '.CONFIG_TABLE.' SET value="'.pwg_db_real_escape_string(serialize($this->my_config)).'" WHERE param="piwecard";'; 39 39 $result = pwg_query($query); 40 40 … … 53 53 54 54 $result = pwg_query($query); 55 while ($row = mysql_fetch_assoc($result)) {55 while ($row = pwg_db_fetch_assoc($result)) { 56 56 array_push($this->user_groups, $row['group_id']); 57 57 } … … 84 84 return $string; 85 85 } 86 87 // NB of days between 2 dates "AAAA-MM-JJ HH:hh:ss"88 /* function NbJours($debut, $fin) {89 $tDeb = explode("-", substr($debut,0,strpos($debut, ' ')));90 $tFin = explode("-", substr($fin,0,strpos($fin, ' ')));91 92 $diff = mktime(0, 0, 0, $tFin[1], $tFin[2], $tFin[0]) - mktime(0, 0, 0, $tDeb[1], $tDeb[2], $tDeb[0]);93 94 return(($diff / 86400));95 }96 97 function AjoutJours($debut, $jours, $soustrait = false) {98 $tDeb = explode("-", substr($debut,0,strpos($debut, ' ')));99 $tDebH = explode(":", substr($debut,strpos($debut, ' ')+1));100 $tFin = "";101 102 $nb_ans = (int)(($jours)/365);103 $nb_mois = (int)(( ($jours)%365) / 31);104 $nb_jours = (int)(( ($jours)%365) % 31);105 106 if ($soustrait)107 $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));108 else109 $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));110 111 return($tFin);112 } */113 86 114 87 function parse($data, $_POST = NULL, $image_element = NULL) { … … 131 104 132 105 if ($result) { 133 $nb= mysql_fetch_assoc($result);106 $nb=pwg_db_fetch_assoc($result); 134 107 return $nb['nb']; 135 108 } else … … 143 116 144 117 if ($result) { 145 $nb= mysql_fetch_assoc($result);118 $nb=pwg_db_fetch_assoc($result); 146 119 return $nb['nb']; 147 120 } else … … 157 130 $result = pwg_query($query); 158 131 if ($result) 159 return mysql_fetch_assoc($result);132 return pwg_db_fetch_assoc($result); 160 133 else 161 134 return false; … … 222 195 WHERE id = '.pwg_db_real_escape_string($page['category']['id']).' 223 196 ;'; 224 $cat = mysql_fetch_assoc(pwg_query($query));197 $cat = pwg_db_fetch_assoc(pwg_query($query)); 225 198 226 199 if (empty($cat)) { … … 284 257 { 285 258 286 // Check if user is guest. 287 // In this case, force mail to default mail (in params) 288 if (is_a_guest()) { 289 if (!empty($this->my_config['defaultmail'])) 290 $user['email'] = $this->my_config['defaultmail']; 291 } 292 293 // Template informations 294 $template->assign('ecard', array( 295 'subject' => l10n('ecard_send_title'), 296 'message' => l10n('ecard_send_message'), 297 'sender_name' => $user['username'], 298 'sender_email' => $user['email'], 299 'recipient_name' => l10n('ecard_send_dest_name'), 300 'recipient_email' => l10n('ecard_send_dest_mail'), 301 'copy' => $this->my_config['send_copy'] ? 'checked="checked"' : '', 302 'changemail' => ($this->my_config['expmail_change'] ? '' : 'disabled="disabled"') 303 )); 304 305 // Template add for the active parameter choice by the user 306 if ($this->my_config['active_parameter']) { // Allowed for the user 307 $template->append('ecard_validity',array('id' => 0, 'name' => l10n('ecard_nolimit'), 'selected' => ($this->my_config['activ'] == 0 ? 'checked' : ''))); 308 for($jj=5; $jj < 30; $jj+=5) 309 $template->append('ecard_validity',array('id' => $jj, 'name' => $jj , 'selected' => ($this->my_config['activ'] == $jj ? 'checked' : ''))); 310 } 311 312 // Template add for the send method to be chose, by the user 313 // default : text 314 $template->append('ecard_send_method',array('id' => 0, 'name' => l10n('ecard_maillink'), 'selected' => ($this->my_config['send_HTML'] ? '' : 'checked'))); 315 if ($this->my_config['send_HTML']) { // Allowed for the user 316 $template->append('ecard_send_method',array('id' => 1, 'name' => l10n('ecard_mailhtml'), 'selected' => ($this->my_config['send_HTML'] ? 'checked' : ''))); 317 } 318 319 // Send the card 320 if (isset($_POST['ecard_submit'])) { 321 $send_method = $_POST['ecard_send_method']; 259 // Check if user is guest. 260 // In this case, force mail to default mail (in params) 261 if (is_a_guest()) { 262 if (!empty($this->my_config['defaultmail'])) 263 $user['email'] = $this->my_config['defaultmail']; 264 } 265 266 // Template informations 267 $template->assign('ecard', array( 268 'subject' => l10n('ecard_send_title'), 269 'message' => l10n('ecard_send_message'), 270 'sender_name' => $user['username'], 271 'sender_email' => $user['email'], 272 'recipient_name' => l10n('ecard_send_dest_name'), 273 'recipient_email' => l10n('ecard_send_dest_mail'), 274 'copy' => $this->my_config['send_copy'] ? 'checked="checked"' : '', 275 'changemail' => ($this->my_config['expmail_change'] ? '' : 'disabled="disabled"') 276 )); 277 278 // Template add for the active parameter choice by the user 279 if ($this->my_config['active_parameter']) { // Allowed for the user 280 $template->append('ecard_validity',array('id' => 0, 'name' => l10n('ecard_nolimit'), 'selected' => ($this->my_config['activ'] == 0 ? 'checked' : ''))); 281 for($jj=5; $jj < 30; $jj+=5) 282 $template->append('ecard_validity',array('id' => $jj, 'name' => $jj , 'selected' => ($this->my_config['activ'] == $jj ? 'checked' : ''))); 283 } 284 285 // Template add for the send method to be chose, by the user 286 // default : text 287 $template->append('ecard_send_method',array('id' => 0, 'name' => l10n('ecard_maillink'), 'selected' => ($this->my_config['send_HTML'] ? '' : 'checked'))); 288 if ($this->my_config['send_HTML']) { // Allowed for the user 289 $template->append('ecard_send_method',array('id' => 1, 'name' => l10n('ecard_mailhtml'), 'selected' => ($this->my_config['send_HTML'] ? 'checked' : ''))); 290 } 291 292 // Send the card 293 if (isset($_POST['ecard_submit'])) { 294 $send_method = $_POST['ecard_send_method']; 295 296 // If conf doesn't allow to modify the %votremail param, force it to user mail 297 if (!isset($_POST['ecard_sender_email'])) 298 $_POST['ecard_sender_email'] = $user['email']; 299 300 // Initialize the array for image element 301 $image_element = array(); 302 303 // Get all image informations 304 $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id='.$page['image_id'].' LIMIT 1;'; 305 $result = pwg_query($query); 306 if (isset($result)) 307 $image_element = mysql_fetch_array($result); 308 309 // Generate random number 310 $image_element['next_element_id'] = $this->random(64); 311 312 // Image infos 313 if ($this->my_config['ecard_showinfos']) { 314 if (isset($image_element['name'])) { 315 $image_element['picture_infos'] = $image_element['name']; 316 if (isset($image_element['author'])) 317 $image_element['picture_infos'] .= ' ('.$image_element['author'].')'; 318 } 319 } 320 321 $insert = array( 322 'id' => $image_element['next_element_id'], 323 'sender_name' => $_POST['ecard_sender_name'], 324 'recipient_name' => $_POST['ecard_recipient_name'], 325 'sender_email' => $_POST['ecard_sender_email'], 326 'recipient_email' => $_POST['ecard_recipient_email'], 327 'subject' => $_POST['ecard_subject'], 328 'message' => $_POST['ecard_message'], 329 'image' => $image_element['id'], 330 'date_creation' => date("Y-m-d H:i:s"), 331 ); 332 if ($_POST['ecard_validity'] != '0') { 333 $date = new DateTime(); 334 $date->modify("+".$_POST['ecard_validity']." day"); 335 $insert['date_validity'] = $date->format('Y-m-d H:i:s'); 336 } 337 single_insert(ECARD_TABLE, $insert); 338 339 // Complete the image_element array with Link for the ecard url to be added in the mail 340 set_make_full_url(); 341 $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$image_element['next_element_id']); 342 $image_element['ecard_url'] = $ecard_url; 343 unset_make_full_url(); 344 345 // Complete the image_element with the url to point to the image url 346 set_make_full_url(); 347 $image_element['picture_url'] = duplicate_picture_url( 348 array( 349 'image_id' => $image_element['id'], 350 'image_file' => $image_element['file'] 351 ), 352 array('start') 353 ); 354 unset_make_full_url(); 355 356 $mail_subject = htmlspecialchars_decode($this->parse( $this->my_config['subject_link'], $_POST)); 357 358 switch($send_method) { 359 case 0 : // text 360 // Get the standard message (in admin param) and parse it with the informations 361 $mail_message = stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_link'], $_POST, $image_element))); 362 $mail_arg=array('from' => $_POST['ecard_sender_email'], 363 'subject' => $mail_subject, 364 'content' => $mail_message, 365 'content_format' => "text/plain", 366 'email_format' => "text/html" 367 ); 368 break; 369 case 1 : // html 370 $mail_message_HTML = stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_HTML'], $_POST, $image_element))); 371 $mail_arg=array('from' => $_POST['ecard_sender_email'], 372 'subject' => $mail_subject, 373 'content' => $mail_message_HTML, 374 'content_format' => "text/html", 375 'email_format' => "text/html" 376 ); 377 break; 378 default: 379 break; 380 } 381 382 // Add the copy to expe if param. 383 if (isset($_POST['ecard_copy'])) // send copy to sender 384 $mail_arg['Bcc'] = array((isset($_POST['ecard_sender_email']) ? $_POST['ecard_sender_email'] : $user['email'])); 385 386 // Send the mail 387 pwg_mail($_POST['ecard_recipient_email'], $mail_arg); 388 } 322 389 323 // If conf doesn't allow to modify the %votremail param, force it to user mail 324 if (!isset($_POST['ecard_sender_email'])) 325 $_POST['ecard_sender_email'] = $user['email']; 326 327 // Initialize the array for image element 328 $image_element = array(); 329 330 // Get all image informations 331 $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id='.$page['image_id'].' LIMIT 1;'; 332 $result = pwg_query($query); 333 if (isset($result)) 334 $image_element = mysql_fetch_array($result); 335 336 // Generate random number 337 $image_element['next_element_id'] = $this->random(64); 338 339 // Image infos 340 if ($this->my_config['ecard_showinfos']) { 341 if (isset($image_element['name'])) { 342 $image_element['picture_infos'] = $image_element['name']; 343 if (isset($image_element['author'])) 344 $image_element['picture_infos'] .= ' ('.$image_element['author'].')'; 345 } 346 } 347 348 $insert = array( 349 'id' => $image_element['next_element_id'], 350 'sender_name' => $_POST['ecard_sender_name'], 351 'recipient_name' => $_POST['ecard_recipient_name'], 352 'sender_email' => $_POST['ecard_sender_email'], 353 'recipient_email' => $_POST['ecard_recipient_email'], 354 'subject' => $_POST['ecard_subject'], 355 'message' => $_POST['ecard_message'], 356 'image' => $image_element['id'], 357 'date_creation' => date("Y-m-d H:i:s"), 358 ); 359 if ($_POST['ecard_validity'] != '0') { 360 $date = new DateTime(); 361 $date->modify("+".$_POST['ecard_validity']." day"); 362 $insert['date_validity'] = $date->format('Y-m-d H:i:s'); 363 } 364 single_insert(ECARD_TABLE, $insert); 365 366 // Complete the image_element array with Link for the ecard url to be added in the mail 367 set_make_full_url(); 368 $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$image_element['next_element_id']); 369 $image_element['ecard_url'] = $ecard_url; 370 unset_make_full_url(); 371 372 // Complete the image_element with the url to point to the image url 373 set_make_full_url(); 374 $image_element['picture_url'] = duplicate_picture_url( 375 array( 376 'image_id' => $image_element['id'], 377 'image_file' => $image_element['file'] 378 ), 379 array('start') 380 ); 381 unset_make_full_url(); 382 383 $mail_subject = htmlspecialchars_decode($this->parse( $this->my_config['subject_link'], $_POST)); 384 385 switch($send_method) { 386 case 0 : // text 387 // Get the standard message (in admin param) and parse it with the informations 388 $mail_message = stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_link'], $_POST, $image_element))); 389 $mail_arg=array('from' => $_POST['ecard_sender_email'], 390 'subject' => $mail_subject, 391 'content' => $mail_message, 392 'content_format' => "text/plain", 393 'email_format' => "text/html" 394 ); 395 396 break; 397 case 1 : // html 398 $mail_message_HTML = stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_HTML'], $_POST, $image_element))); 399 $mail_arg=array('from' => $_POST['ecard_sender_email'], 400 'subject' => $mail_subject, 401 'content' => $mail_message_HTML, 402 'content_format' => "text/html", 403 'email_format' => "text/html" 404 ); 405 break; 406 } 407 408 // Add the copy to expe if param. 409 if (isset($_POST['ecard_copy'])) // send copy to sender 410 $mail_arg['Bcc'] = array((isset($_POST['ecard_sender_email']) ? $_POST['ecard_sender_email'] : $user['email'])); 411 412 // Send the mail 413 pwg_mail($_POST['ecard_recipient_email'], $mail_arg); 414 } 415 416 $template->set_filenames(array('ecard_template' => ECARD_ROOT.'/template/ecard.tpl')); 417 $template->concat('COMMENT_IMG', $template->parse('ecard_template', true)); 390 $template->set_filenames(array('ecard_template' => ECARD_ROOT.'/template/ecard.tpl')); 391 $template->concat('COMMENT_IMG', $template->parse('ecard_template', true)); 418 392 } 419 393 } -
extensions/Piwecard/install/functions.inc.php
r19956 r19968 26 26 $result = pwg_query($query); 27 27 28 while($data = mysql_fetch_assoc($result)) {28 while($data = pwg_db_fetch_assoc($result)) { 29 29 $insert = array( 30 30 'id' => $data['numero'], -
extensions/Piwecard/main.inc.php
r19956 r19968 5 5 * Description: envoi de Cartes Virtuelles 6 6 * Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=487 7 * Author: Tiico 8 * Author URI: 7 * Author: Tiico & Julien1311 9 8 * */ 10 /********* Fichier main.inc.php *********/11 12 /* See CHANGELOG for release informations */13 9 14 10 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); … … 18 14 define('ECARD_VERSION', '1.1.0'); 19 15 20 define('ECARD_NAME', 'Piwecard');21 16 define('ECARD_ROOT', dirname(__FILE__)); 22 define('ECARD_DIR' , basename(dirname(__FILE__))); 23 define('ECARD_CFG_DB' , ECARD_DIR); 24 define('ECARD_PATH' , PHPWG_PLUGINS_PATH . ECARD_DIR . '/'); 25 define('ECARD_INC_PATH' , PHPWG_PLUGINS_PATH . ECARD_DIR . '/include/'); 26 define('ECARD_IMG_PATH' , PHPWG_PLUGINS_PATH . ECARD_DIR . '/img/'); 27 define('ECARD_ADMIN_PATH' , PHPWG_PLUGINS_PATH . ECARD_DIR . '/admin/'); 28 define('ECARD_TABLE' , $prefixeTable . 'piwecard'); 17 define('ECARD_DIR', basename(dirname(__FILE__))); 18 define('ECARD_PATH', PHPWG_PLUGINS_PATH.ECARD_DIR.'/'); 19 define('ECARD_INC_PATH', PHPWG_PLUGINS_PATH . ECARD_DIR . '/include/'); 20 define('ECARD_INSTALL_PATH', PHPWG_PLUGINS_PATH . ECARD_DIR . '/install/'); 21 define('ECARD_TABLE', $prefixeTable . 'piwecard'); 29 22 define('ECARD_ADMIN', get_root_url() . 'admin.php?page=plugin-'.ECARD_DIR); 30 23 31 24 load_language('plugin.lang', ECARD_PATH); 32 25 33 include_once ECARD_INC_PATH.'ecard.class.php';34 include_once( PHPWG_ROOT_PATH.'include/functions_mail.inc.php');35 include_once( PHPWG_ROOT_PATH.'include/functions_picture.inc.php');26 include_once(ECARD_INC_PATH.'piwecard.class.php'); 27 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 28 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 36 29 global $page, $template; 37 30 … … 39 32 load_language('plugin.lang', ECARD_PATH); 40 33 41 $ecard = new ecard();34 $ecard = new Piwecard(); 42 35 43 36 // Add ecard to picture page -
extensions/Piwecard/publish.php
r19925 r19968 4 4 global $template; 5 5 6 $ecard = new ecard();6 $ecard = new Piwecard(); 7 7 8 8 $ecard_id = explode('ecard/', $_SERVER['REQUEST_URI']); … … 12 12 $query = 'SELECT * FROM '.ECARD_TABLE.' WHERE numero = "'.$ecard_id.'";'; 13 13 $result = pwg_query($query); 14 $result_array = mysql_fetch_assoc($result);14 $result_array = pwg_db_fetch_assoc($result); 15 15 16 16 if (isset($result_array['numero'])) { … … 19 19 $result = pwg_query($query); 20 20 21 $row = mysql_fetch_assoc($result);21 $row = pwg_db_fetch_assoc($result); 22 22 set_make_full_url(); 23 23 $url = duplicate_picture_url(
Note: See TracChangeset
for help on using the changeset viewer.