Changeset 20180
- Timestamp:
- Jan 16, 2013, 12:38:26 AM (11 years ago)
- Location:
- extensions/Piwecard
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Piwecard/admin.php
r20089 r20180 2 2 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 check_status(ACCESS_ADMINISTRATOR); 4 5 5 6 global $template, $conf, $user; -
extensions/Piwecard/admin/admin_permissions.php
r20162 r20180 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 global $template, $page ;4 global $template, $page, $conf; 5 5 6 6 $piwecard = get_plugin_data($plugin_id); 7 7 8 $template->set_filenames(array( 9 'plugin_admin_content' => PIWECARD_ROOT.'/admin/template/admin_permissions.tpl', 10 'double_select' => 'double_select.tpl' 11 )); 12 8 // +-----------------------------------------------------------------------+ 9 // | form submission | 10 // +-----------------------------------------------------------------------+ 13 11 // Switch on right side (=>) 14 12 if (isset($_POST['falsify']) and isset($_POST['cat_true']) and count($_POST['cat_true']) > 0) { … … 40 38 if ($_POST['ecard_authorized_cats'] == 'user') 41 39 $piwecard->config['user_cats_case_sensitive'] = ((isset($_POST['ecard_user_cats_case_sensitive']) && $_POST['ecard_user_cats_case_sensitive'] == '1') ? true : false); 40 $piwecard->config['authorized_groups_users'] = $_POST['ecard_authorized_groups_users']; 41 if ($_POST['ecard_authorized_groups_users'] == 'granted' OR $_POST['ecard_authorized_groups_users'] == 'denied') { 42 $piwecard->config['selected_groups'] = (isset($_POST['groups']) ? $_POST['groups'] : array()); 43 $piwecard->config['selected_users'] = (isset($_POST['users']) ? $_POST['users'] : array()); 44 } 42 45 $piwecard->set_config(); 43 46 array_push($page['infos'], l10n('Information data registered in database')); 44 47 } 45 48 49 // +-----------------------------------------------------------------------+ 50 // | template initialization | 51 // +-----------------------------------------------------------------------+ 52 53 $template->set_filenames(array( 54 'plugin_admin_content' => PIWECARD_ROOT.'/admin/template/admin_permissions.tpl', 55 'double_select' => 'double_select.tpl' 56 )); 57 $template->assign('ecard', array( 58 'all_cats_checked' => (($piwecard->config['authorized_cats'] == 'all') ? 'checked="checked"' : ''), 59 'selected_cats_checked' => (($piwecard->config['authorized_cats'] == 'selected') ? 'checked="checked"' : ''), 60 'user_cats_checked' => (($piwecard->config['authorized_cats'] == 'user') ? 'checked="checked"' : ''), 61 'user_cats_case_sensitive' => (($piwecard->config['user_cats_case_sensitive']) ? 'checked="checked"' : ''), 62 'all_groups_users_checked' => (($piwecard->config['authorized_groups_users'] == 'all') ? 'checked="checked"' : ''), 63 'granted_groups_users_checked' => (($piwecard->config['authorized_groups_users'] == 'granted') ? 'checked="checked"' : ''), 64 'denied_groups_users_checked' => (($piwecard->config['authorized_groups_users'] == 'denied') ? 'checked="checked"' : ''), 65 ) 66 ); 67 $template->assign(array( 68 'F_ACTION' => '', 69 'L_CAT_OPTIONS_TRUE' => l10n('piwecard_selected_cats'), 70 'L_CAT_OPTIONS_FALSE' => l10n('piwecard_non_selected_cats'), 71 ) 72 ); 73 74 // +-----------------------------------------------------------------------+ 75 // | form construction | 76 // +-----------------------------------------------------------------------+ 46 77 //Populate double_select 47 78 $query = 'SELECT id, name, uppercats, global_rank FROM '.CATEGORIES_TABLE.' WHERE id not IN ("'.implode('","', $piwecard->config['selected_cats']).'");'; … … 57 88 if (!empty($result)) { 58 89 foreach ($categories as $cat) { 59 $tpl [$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false);90 $tpl_false[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false); 60 91 } 61 92 } 62 $template->assign('category_option_false', $tpl );93 $template->assign('category_option_false', $tpl_false); 63 94 $template->assign('category_option_false_selected', array()); 64 95 … … 72 103 usort($categories, 'global_rank_compare'); 73 104 74 $tpl 2= array();105 $tpl_true = array(); 75 106 if (!empty($result)) { 76 107 foreach ($categories as $cat) { 77 $tpl 2[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false);108 $tpl_true[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false); 78 109 } 79 110 } 80 $template->assign('category_option_true', $tpl 2);111 $template->assign('category_option_true', $tpl_true); 81 112 $template->assign('category_option_true_selected', array()); 82 113 83 $template->assign('ecard', array( 84 'all_cats_checked' => (($piwecard->config['authorized_cats'] == 'all') ? 'checked="checked"' : ''), 85 'selected_cats_checked' => (($piwecard->config['authorized_cats'] == 'selected') ? 'checked="checked"' : ''), 86 'user_cats_checked' => (($piwecard->config['authorized_cats'] == 'user') ? 'checked="checked"' : ''), 87 'user_cats_case_sensitive' => (($piwecard->config['user_cats_case_sensitive']) ? 'checked="checked"' : ''), 88 ) 89 ); 114 //Populate Groups and Users 115 //Groups 116 $groups = array(); 117 $query = 'SELECT id, name FROM '.GROUPS_TABLE.' ORDER BY name ASC;'; 118 $groups = simple_hash_from_query($query, 'id', 'name'); 119 $template->assign('groups', $groups); 90 120 91 $template->assign(array( 92 'F_ACTION' => '', 93 'L_CAT_OPTIONS_TRUE' => l10n('piwecard_selected_cats'), 94 'L_CAT_OPTIONS_FALSE' => l10n('piwecard_non_selected_cats'), 95 ) 96 ); 121 //Selected groups 122 $selected_groups = $piwecard->config['selected_groups']; 123 $template->assign('piwecard_selected_groups', $selected_groups); 124 125 //Users 126 $users = array(); 127 $query = 'SELECT '.$conf['user_fields']['id'].' AS id, '.$conf['user_fields']['username'].' AS username FROM '.USERS_TABLE.';'; 128 $users = simple_hash_from_query($query, 'id', 'username'); 129 $template->assign('users', $users); 130 131 //Selected users 132 $selected_users = $piwecard->config['selected_users']; 133 $template->assign('piwecard_selected_users', $selected_users); 134 135 if (count($selected_groups) > 0) { 136 $selected_groups_ids = array(); 137 $query = 'SELECT user_id, group_id FROM '.USER_GROUP_TABLE.' WHERE group_id IN ('.implode(',', $selected_groups).');'; 138 $result = pwg_query($query); 139 while ($row = pwg_db_fetch_assoc($result)) { 140 if (!isset($selected_groups_ids[$row['group_id']])) { 141 $selected_groups_ids[$row['group_id']] = array(); 142 } 143 array_push($selected_groups_ids[$row['group_id']], $row['user_id']); 144 } 145 $user_selected_by_group_ids = array(); 146 foreach ($selected_groups_ids as $group_users) { 147 $user_selected_by_group_ids = array_merge($user_selected_by_group_ids, $group_users); 148 } 149 $user_selected_by_group_ids = array_unique($user_selected_by_group_ids); 150 $user_selected_indirect_ids = array_diff($user_selected_by_group_ids, $selected_users); 151 152 $template->assign('nb_users_selected_indirect', count($user_selected_indirect_ids)); 153 $template->assign('nb_users_selected_indirect_style', array( 154 'granted' => (($piwecard->config['authorized_groups_users'] == 'granted') ? '' : 'style="display: none"'), 155 'denied' => (($piwecard->config['authorized_groups_users'] == 'denied') ? '' : 'style="display: none"'), 156 ) 157 ); 158 159 foreach ($selected_groups_ids as $group_id => $group_users) { 160 $group_usernames = array(); 161 foreach ($group_users as $user_id) { 162 if (in_array($user_id, $user_selected_indirect_ids)) { 163 array_push($group_usernames, $users[$user_id]); 164 } 165 } 166 167 $template->append('user_selected_indirect_groups', array( 168 'group_name' => $groups[$group_id], 169 'group_users' => implode(', ', $group_usernames), 170 ) 171 ); 172 } 173 } 174 175 // +-----------------------------------------------------------------------+ 176 // | sending html code | 177 // +-----------------------------------------------------------------------+ 97 178 98 179 $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); -
extensions/Piwecard/admin/template/admin_permissions.tpl
r20162 r20180 6 6 jQuery(".chzn-select").chosen(); 7 7 8 function checkStatusOptions( ) {9 if ($("#ecard_granted_group _user").prop('checked') == true || $("#ecard_denied_group_user").prop('checked') == true) {10 jQuery("#ecard_authorized_group _user_options").show("fast");8 function checkStatusOptions(speed) { 9 if ($("#ecard_granted_groups_users").prop('checked') == true || $("#ecard_denied_groups_users").prop('checked') == true) { 10 jQuery("#ecard_authorized_groups_users_options").show(speed); 11 11 } else { 12 jQuery("#ecard_authorized_group_user_options").hide("fast"); 12 jQuery("#ecard_authorized_groups_users_options").hide(speed); 13 } 14 } 15 16 function checkGrantedDenied() { 17 if ($("#ecard_granted_groups_users").prop('checked') == true) { 18 $("#nb_users_selected_indirect_granted").css("display", "inline"); 19 $("#nb_users_selected_indirect_denied").css("display", "none"); 20 } else if ($("#ecard_denied_groups_users").prop('checked') == true) { 21 $("#nb_users_selected_indirect_denied").css("display", "inline"); 22 $("#nb_users_selected_indirect_granted").css("display", "none"); 13 23 } 14 24 } 15 25 26 checkGrantedDenied(); 16 27 checkStatusOptions(); 17 jQuery("#ecard_authorized_group_user").change(function() { 18 checkStatusOptions(); 28 jQuery("#ecard_authorized_groups_users").change(function() { 29 checkGrantedDenied(); 30 checkStatusOptions("fast"); 19 31 }); 20 32 … … 68 80 <h2>{'piwecard_plugin'|@translate}</h2> 69 81 </div> 70 <form method="post" action="" class="properties">82 <form method="post" action=""> 71 83 <div id="ECardAdminPermissions"> 72 84 <fieldset> … … 90 102 </div> 91 103 </fieldset> 92 <fieldset id="ecard_authorized_group _user">93 <legend>{'piwecard_permissions_group _user'|@translate}</legend>104 <fieldset id="ecard_authorized_groups_users"> 105 <legend>{'piwecard_permissions_groups_users'|@translate}</legend> 94 106 <div class="ecard_radio"> 95 <input type="radio" name="ecard_authorized_group _user" id="ecard_all_group_user" value="all" {$ecard.all_group_user_checked} /><label for="ecard_all_group_user"> {'piwecard_permissions_all_group_user'|@translate}</label>107 <input type="radio" name="ecard_authorized_groups_users" id="ecard_all_groups_users" value="all" {$ecard.all_groups_users_checked} /><label for="ecard_all_groups_users"> {'piwecard_permissions_all_groups_users'|@translate}</label> 96 108 </div> 97 109 <div class="ecard_radio"> 98 <input type="radio" name="ecard_authorized_group _user" id="ecard_granted_group_user" value="granted" {$ecard.granted_group_user_checked} /><label for="ecard_granted_group_user"> {'piwecard_permissions_granted_group_user'|@translate}</label>110 <input type="radio" name="ecard_authorized_groups_users" id="ecard_granted_groups_users" value="granted" {$ecard.granted_groups_users_checked} /><label for="ecard_granted_groups_users"> {'piwecard_permissions_granted_groups_users'|@translate}</label> 99 111 </div> 100 112 <div class="ecard_radio"> 101 <input type="radio" name="ecard_authorized_group _user" id="ecard_denied_group_user" value="denied" {$ecard.denied_group_user_checked} /><label for="ecard_denied_group_user"> {'piwecard_permissions_denied_group_user'|@translate}</label>113 <input type="radio" name="ecard_authorized_groups_users" id="ecard_denied_groups_users" value="denied" {$ecard.denied_groups_users_checked} /><label for="ecard_denied_groups_users"> {'piwecard_permissions_denied_groups_users'|@translate}</label> 102 114 </div> 103 115 </fieldset> 104 <fieldset id="ecard_authorized_group _user_options">116 <fieldset id="ecard_authorized_groups_users_options"> 105 117 <legend>{'Groups and users'|@translate}</legend> 106 118 <div> … … 109 121 <div> 110 122 <select data-placeholder="{'Select groups...'|@translate}" class="chzn-select" multiple style="width:700px;" name="groups[]"> 111 {html_options options=$groups selected=$ groups_selected}123 {html_options options=$groups selected=$piwecard_selected_groups} 112 124 </select> 113 125 </div> … … 120 132 <div> 121 133 <select data-placeholder="{'Select users...'|@translate}" class="chzn-select" multiple style="width:700px;" name="users[]"> 122 {html_options options=$users selected=$ users_selected}134 {html_options options=$users selected=$piwecard_selected_users} 123 135 </select> 124 136 </div> 125 137 </div> 126 {if isset($nb_users_ granted_indirect)}138 {if isset($nb_users_selected_indirect)} 127 139 <div> 128 {'%u users have automatic permission because they belong to a granted group.'|@translate|@sprintf:$nb_users_granted_indirect} 140 <span id="nb_users_selected_indirect_granted" {$nb_users_selected_indirect_style.granted}>{'%u users have automatic permission because they belong to a granted group.'|@translate|@sprintf:$nb_users_selected_indirect}</span> 141 <span id="nb_users_selected_indirect_denied" {$nb_users_selected_indirect_style.denied}>{'piwecard_authorized_groups_users_denied'|@translate|@sprintf:$nb_users_selected_indirect}</span> 129 142 <a href="#" id="indirectPermissionsDetailsHide" style="display:none">{'hide details'|@translate}</a> 130 143 <a href="#" id="indirectPermissionsDetailsShow">{'show details'|@translate}</a> 131 144 <ul id="indirectPermissionsDetails" style="display:none"> 132 {foreach from=$user_ granted_indirect_groups item=group_details}145 {foreach from=$user_selected_indirect_groups item=group_details} 133 146 <li><span>{$group_details.group_name}</span> : {$group_details.group_users}</li> 134 147 {/foreach} -
extensions/Piwecard/css/piwecard.css
r20162 r20180 15 15 * +-----------------------------------------------------------------------+ */ 16 16 17 .clear {17 #addECardForm .clear { 18 18 clear: both; 19 19 } 20 20 21 #addECardForm .ecard_defaultTextActive { 22 font-style: italic; 23 } 24 21 25 #addECardForm { 22 26 line-height: 1.5em; … … 43 47 #addECardForm .ecard_input_right textarea { 44 48 width: 100%; 49 resize: vertical; 45 50 } 46 51 -
extensions/Piwecard/include/config_param.inc.php
r20105 r20180 5 5 // Fichier contenant les parametres du plugin (pour le parser) 6 6 $ecard_parse = array( 7 '%yourname%' => isset($ post['ecard_sender_name']) ? $post['ecard_sender_name'] : '' ,8 '%youremail%' => isset($ post['ecard_sender_email']) ? $post['ecard_sender_email'] : '' ,9 '%recipientname%' => isset($ post['ecard_recipient_name']) ? $post['ecard_recipient_name'] : '' ,10 '%recipientemail%' => isset($ post['ecard_recipient_email']) ? $post['ecard_recipient_email'] : '' ,7 '%yourname%' => isset($values['ecard_sender_name']) ? $values['ecard_sender_name'] : '' , 8 '%youremail%' => isset($values['ecard_sender_email']) ? $values['ecard_sender_email'] : '' , 9 '%recipientname%' => isset($values['ecard_recipient_name']) ? $values['ecard_recipient_name'] : '' , 10 '%recipientemail%' => isset($values['ecard_recipient_email']) ? $values['ecard_recipient_email'] : '' , 11 11 '%website%' => isset($conf['gallery_title']) ? $conf['gallery_title'] : '' , 12 12 '%websiteurl%' => get_absolute_root_url() , 13 13 '%ecardurl%' => isset($image_element['ecard_url']) ? $image_element['ecard_url'] : '' , 14 '%ecardtitle%' => isset($ post['ecard_title']) ? $post['ecard_title'] : '' ,15 '%ecardmessage%' => isset($ post['ecard_message']) ? $post['ecard_message'] : '' ,14 '%ecardtitle%' => isset($values['ecard_title']) ? $values['ecard_title'] : '' , 15 '%ecardmessage%' => isset($values['ecard_message']) ? $values['ecard_message'] : '' , 16 16 '%pictureurl%' => DerivativeImage::thumb_url($image_element) , 17 17 '%pictureinfos%' => isset($image_element['picture_infos']) ? $image_element['picture_infos'] : '' , -
extensions/Piwecard/include/piwecard.class.php
r20162 r20180 65 65 } 66 66 67 function parse($data, $ post, $image_element) {67 function parse($data, $values, $image_element) { 68 68 include (PIWECARD_PATH.'include/config_param.inc.php'); 69 69 … … 211 211 } 212 212 213 if ($this->config['authorized_groups_users'] == 'granted' OR $this->config['authorized_groups_users'] == 'denied') { 214 $user_groups = array(); 215 $query = 'SELECT group_id FROM '.USER_GROUP_TABLE.' WHERE user_id='.$user['id'].';'; 216 $result = pwg_query($query); 217 while ($row = pwg_db_fetch_assoc($result)) { 218 array_push($user_groups, $row['group_id']); 219 } 220 } 221 213 222 // Only on available cats 214 223 if (($this->config['authorized_cats'] == 'all') //Parameter : all … … 217 226 OR ($this->config['authorized_cats'] == 'user' AND !$this->config['user_cats_case_sensitive'] AND (in_array(strtolower($username), $catname) OR $username == $authorname)) //Parameter : user AND not case sensitive 218 227 ) { 219 // Check if user is guest. 220 // In this case, force mail to default mail (in configuration) 221 if (is_a_guest()) { 222 if (!empty($this->config['default_guest_email'])) 223 $user['email'] = $this->config['default_guest_email']; 224 } 225 226 // Template informations 227 $template->assign('ecard', array( 228 'title' => l10n('Title'), 229 'message' => l10n('piwecard_message'), 230 'sender_name' => $user['username'], 231 'sender_email' => $user['email'], 232 'recipient_name' => l10n('piwecard_recipient_name'), 233 'recipient_email' => l10n('piwecard_recipient_email'), 234 'copy' => $this->config['sender_copy'] ? 'checked="checked"' : '', 235 'changemail' => (!isset($user['email']) OR $this->config['sender_email_change']) ? '' : 'disabled="disabled"' 236 ) 237 ); 238 239 // Template add for the active parameter choice by the user 240 if ($this->config['validity_choice']) { 241 foreach($this->config['validity'] as $validity) { 242 $template->append('ecard_validity', array( 243 'id' => $validity, 244 'name' => ($validity == 0) ? l10n('piwecard_nolimit') : $validity.' '.l10n('piwecard_days'), 245 'selected' => ($this->config['validity_default'] == $validity ? 'checked' : '') 228 if (($this->config['authorized_groups_users'] == 'all') //Parameter : all 229 OR ($this->config['authorized_groups_users'] == 'granted' AND ((array_intersect($user_groups, $this->config['selected_groups']) != array()) OR in_array($user['id'], $this->config['selected_users']))) //Parameter : granted 230 OR ($this->config['authorized_groups_users'] == 'denied' AND ((array_intersect($user_groups, $this->config['selected_groups']) == array()) AND !in_array($user['id'], $this->config['selected_users']))) //Parameter : denied 231 ) { 232 // Check if user is guest. 233 // In this case, force mail to default mail (in configuration) 234 if (is_a_guest()) { 235 if (!empty($this->config['default_guest_email'])) 236 $user['email'] = $this->config['default_guest_email']; 237 } 238 239 // Template informations 240 $template->assign('ecard', array( 241 'title' => l10n('Title'), 242 'message' => l10n('piwecard_message'), 243 'sender_name' => $user['username'], 244 'sender_email' => $user['email'], 245 'recipient_name' => l10n('piwecard_recipient_name'), 246 'recipient_email' => l10n('piwecard_recipient_email'), 247 'copy' => $this->config['sender_copy'] ? 'checked="checked"' : '', 248 'changemail' => (!isset($user['email']) OR $this->config['sender_email_change']) ? '' : 'disabled="disabled"' 249 ) 250 ); 251 252 // Template add for the active parameter choice by the user 253 if ($this->config['validity_choice']) { 254 foreach($this->config['validity'] as $validity) { 255 $template->append('ecard_validity', array( 256 'id' => $validity, 257 'name' => ($validity == 0) ? l10n('piwecard_nolimit') : $validity.' '.l10n('piwecard_days'), 258 'selected' => ($this->config['validity_default'] == $validity ? 'checked' : '') 259 ) 260 ); 261 } 262 } else { 263 $template->assign('ecard_validity_hidden', $this->config['validity_default']); 264 } 265 266 foreach ($this->config['email_format_authorized'] as $email_format) { 267 $template->append('ecard_email_format', array( 268 'id' => $email_format, 269 'name' => l10n('piwecard_email_format_'.$email_format), 270 'selected' => (($this->config['email_format_default'] == $email_format) ? 'checked' : ''), 246 271 ) 247 272 ); 248 273 } 249 } else {250 $template->assign('ecard_validity_hidden', $this->config['validity_default']);251 }252 253 foreach ($this->config['email_format_authorized'] as $email_format) {254 $template->append('ecard_email_format', array(255 'id' => $email_format,256 'name' => l10n('piwecard_email_format_'.$email_format),257 'selected' => (($this->config['email_format_default'] == $email_format) ? 'checked' : ''),258 )259 );260 }261 262 $template->set_filenames(array('ecard_template' => PIWECARD_ROOT.'/template/ecard.tpl'));263 $template->concat('COMMENT_IMG', $template->parse('ecard_template', true));264 265 // Send the card266 if (isset($_POST['ecard_submit'])) {267 $email_format = $_POST['ecard_email_format'];268 274 269 //Check fields 270 if ($_POST['ecard_sender_name'] == '' 271 OR $_POST['ecard_recipient_name'] == '' 272 OR $_POST['ecard_sender_email'] == '' 273 OR $_POST['ecard_recipient_email'] == '' 274 OR $_POST['ecard_title'] == '' 275 OR $_POST['ecard_message'] == '') { 276 return; 275 $template->set_filenames(array('ecard_template' => PIWECARD_ROOT.'/template/ecard.tpl')); 276 $template->concat('COMMENT_IMG', $template->parse('ecard_template', true)); 277 278 // Send the card 279 if (isset($_POST['ecard_submit'])) { 280 // If conf doesn't allow to modify the %yourmail% param, force it to user mail 281 if (!$this->config['sender_email_change']) 282 $_POST['ecard_sender_email'] = $user['email']; 283 284 $email_format = $_POST['ecard_email_format']; 285 286 //Check fields 287 if ($_POST['ecard_sender_name'] == '' 288 OR $_POST['ecard_title'] == '' 289 OR $_POST['ecard_message'] == '') { 290 return; 291 } 292 293 if ($_POST['ecard_sender_email'] == '' OR !$this->is_valid_email($_POST['ecard_sender_email'])) 294 return; 295 296 foreach ($_POST['ecard_recipient_name'] as $recipient) 297 if ($recipient == '') 298 return; 299 300 foreach ($_POST['ecard_recipient_email'] as $recipient) 301 if ($recipient == '' OR !$this->is_valid_email($recipient)) { 302 return; 303 } 304 305 // Initialize the array for image element 306 $image_element = array(); 307 308 // Get all image informations 309 $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id='.$page['image_id'].' LIMIT 1;'; 310 $result = pwg_query($query); 311 if (isset($result)) 312 $image_element = mysql_fetch_array($result); 313 314 // Generate random number 315 $next_element_id_random = $this->random(64); 316 while (pwg_db_num_rows(pwg_query('SELECT id FROM '.PIWECARD_TABLE.' WHERE id="'.$next_element_id_random.'";')) != 0) { 317 $next_element_id_random = $this->random(64); 318 } 319 $image_element['next_element_id'] = $next_element_id_random; 320 321 // Image infos 322 if ($this->config['show_image_infos']) { 323 if (isset($image_element['name'])) { 324 $image_element['picture_infos'] = $image_element['name']; 325 if (isset($image_element['author'])) 326 $image_element['picture_infos'] .= ' ('.$image_element['author'].')'; 327 } 328 } 329 330 // Complete the image_element array with Link for the ecard url to be added in the mail 331 set_make_full_url(); 332 $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$image_element['next_element_id']); 333 $image_element['ecard_url'] = $ecard_url; 334 unset_make_full_url(); 335 336 // Complete the image_element with the url to point to the image url 337 set_make_full_url(); 338 $image_element['picture_url'] = duplicate_picture_url( 339 array( 340 'image_id' => $image_element['id'], 341 'image_file' => $image_element['file'] 342 ), 343 array('start') 344 ); 345 unset_make_full_url(); 346 347 // Send the mail 348 $recipient_infos = array_combine($_POST['ecard_recipient_name'], $_POST['ecard_recipient_email']); 349 foreach ($recipient_infos as $recipient_name => $recipient_email) { 350 $parse_list = array( 351 'ecard_sender_name' => $_POST['ecard_sender_name'], 352 'ecard_sender_email' => $_POST['ecard_sender_email'], 353 'ecard_recipient_name' => $recipient_name, 354 'ecard_recipient_email' => $recipient_email, 355 'ecard_title' => $_POST['ecard_title'], 356 'ecard_message' => $_POST['ecard_message'], 357 ); 358 359 $email_subject = htmlspecialchars_decode($this->parse($this->config['email_subject'], $parse_list, $image_element)); 360 $email_message = htmlspecialchars_decode($this->parse($this->config['email_message'][$email_format], $parse_list, $image_element)); 361 $email_arg=array( 'from' => $_POST['ecard_sender_email'], 362 'subject' => $email_subject, 363 ); 364 365 switch($email_format) { 366 case 'text': // text 367 $email_arg = array_merge($email_arg, array( 368 'content' => $email_message, 369 'content_format' => "text/html", 370 'email_format' => "text/plain" 371 ) 372 ); 373 break; 374 case 'html': // html 375 $email_arg = array_merge($email_arg, array( 376 'content' => '<html><head><title>'.$email_subject.'</title></head><body>'.$email_message.'</body></html>', 377 'content_format' => "text/html", 378 'email_format' => array("text/plain", "text/html"), 379 ) 380 ); 381 default: 382 break; 383 } 384 385 // Add the copy to expe if param. 386 if (isset($_POST['ecard_copy'])) // send copy to sender 387 $email_arg['Bcc'] = array((isset($_POST['ecard_sender_email']) ? $_POST['ecard_sender_email'] : $user['email'])); 388 389 pwg_mail($recipient_email, $email_arg); 390 391 $insert = array( 392 'id' => $image_element['next_element_id'], 393 'sender_name' => $_POST['ecard_sender_name'], 394 'recipient_name' => $recipient_name, 395 'sender_email' => $_POST['ecard_sender_email'], 396 'recipient_email' => $recipient_email, 397 'title' => $_POST['ecard_title'], 398 'message' => $_POST['ecard_message'], 399 'image' => $image_element['id'], 400 'date_creation' => date("Y-m-d H:i:s"), 401 ); 402 if ($_POST['ecard_validity'] != '0') { 403 $date = new DateTime(); 404 $date->modify("+".$_POST['ecard_validity']." day"); 405 $insert['date_validity'] = $date->format('Y-m-d H:i:s'); 406 } 407 single_insert(PIWECARD_TABLE, $insert); 408 } 277 409 } 278 279 if (($_POST['ecard_sender_email'] != '' AND !$piwecard->is_valid_email($_POST['ecard_sender_email']))280 OR ($_POST['ecard_recipient_email'] != '' AND !$piwecard->is_valid_email($_POST['ecard_recipient_email']))) {281 return;282 }283 284 // If conf doesn't allow to modify the %yourmail% param, force it to user mail285 if (!$this->config['sender_email_change'])286 $_POST['ecard_sender_email'] = $user['email'];287 288 // Initialize the array for image element289 $image_element = array();290 291 // Get all image informations292 $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id='.$page['image_id'].' LIMIT 1;';293 $result = pwg_query($query);294 if (isset($result))295 $image_element = mysql_fetch_array($result);296 297 // Generate random number298 $next_element_id_random = $this->random(64);299 while (pwg_db_num_rows(pwg_query('SELECT id FROM '.PIWECARD_TABLE.' WHERE id="'.$next_element_id_random.'";')) != 0) {300 $next_element_id_random = $this->random(64);301 }302 $image_element['next_element_id'] = $next_element_id_random;303 304 // Image infos305 if ($this->config['show_image_infos']) {306 if (isset($image_element['name'])) {307 $image_element['picture_infos'] = $image_element['name'];308 if (isset($image_element['author']))309 $image_element['picture_infos'] .= ' ('.$image_element['author'].')';310 }311 }312 313 $insert = array(314 'id' => $image_element['next_element_id'],315 'sender_name' => $_POST['ecard_sender_name'],316 'recipient_name' => $_POST['ecard_recipient_name'],317 'sender_email' => $_POST['ecard_sender_email'],318 'recipient_email' => $_POST['ecard_recipient_email'],319 'title' => $_POST['ecard_title'],320 'message' => $_POST['ecard_message'],321 'image' => $image_element['id'],322 'date_creation' => date("Y-m-d H:i:s"),323 );324 if ($_POST['ecard_validity'] != '0') {325 $date = new DateTime();326 $date->modify("+".$_POST['ecard_validity']." day");327 $insert['date_validity'] = $date->format('Y-m-d H:i:s');328 }329 single_insert(PIWECARD_TABLE, $insert);330 331 // Complete the image_element array with Link for the ecard url to be added in the mail332 set_make_full_url();333 $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$image_element['next_element_id']);334 $image_element['ecard_url'] = $ecard_url;335 unset_make_full_url();336 337 // Complete the image_element with the url to point to the image url338 set_make_full_url();339 $image_element['picture_url'] = duplicate_picture_url(340 array(341 'image_id' => $image_element['id'],342 'image_file' => $image_element['file']343 ),344 array('start')345 );346 unset_make_full_url();347 348 $email_subject = htmlspecialchars_decode($this->parse($this->config['email_subject'], $_POST, $image_element));349 $email_message = htmlspecialchars_decode($this->parse($this->config['email_message'][$email_format], $_POST, $image_element));350 $email_arg=array( 'from' => $_POST['ecard_sender_email'],351 'subject' => $email_subject,352 'content' => $email_message,353 );354 355 switch($email_format) {356 case 'text': // text357 $email_arg = array_merge($email_arg, array(358 'content_format' => "text/plain",359 'email_format' => "text/plain"360 )361 );362 break;363 case 'html': // html364 $email_arg = array_merge($email_arg, array(365 'content_format' => "text/html",366 'email_format' => "text/html"367 )368 );369 default:370 break;371 }372 373 // Add the copy to expe if param.374 if (isset($_POST['ecard_copy'])) // send copy to sender375 $email_arg['Bcc'] = array((isset($_POST['ecard_sender_email']) ? $_POST['ecard_sender_email'] : $user['email']));376 377 // Send the mail378 pwg_mail($_POST['ecard_recipient_email'], $email_arg);379 410 } 380 411 } -
extensions/Piwecard/install/default_values.inc.php
r20162 r20180 1 1 <?php 2 2 //Permissions parameters 3 $ecard_default_values['authorized_cats'] = 'selected'; //Determine the pagefrom which the user can send ecard : 'all' (all categories the user can access), 'selected' (only the categories defined in the parameter 'selected_cats') or 'user' (only the categories which are named like the user)3 $ecard_default_values['authorized_cats'] = 'selected'; //Determine the albums from which the user can send ecard : 'all' (all categories the user can access), 'selected' (only the categories defined in the parameter 'selected_cats') or 'user' (only the categories which are named like the user) 4 4 $ecard_default_values['selected_cats'] = array(); //List of categories where the plugin is active 5 $ecard_default_values['user_cats_case_sensitive'] = true; //List of categories where the plugin is active 5 $ecard_default_values['user_cats_case_sensitive'] = true; //case-sensitive if authorized_cat = user 6 $ecard_default_values['authorized_groups_users'] = 'all'; //Determine the groups/users who can send ecard : 'all' (everybody), 'granted' (only the groups/users defined in the parameters 'selected_groups' and 'selected_users') or 'denied' (all the groups/users but those defined in the parameters 'selected_groups' and 'selected_users') 7 $ecard_default_values['selected_groups'] = array(); //List of groups 8 $ecard_default_values['selected_users'] = array(); //List of users 6 9 7 10 //Configuration parameters -
extensions/Piwecard/js/piwecard.js
r20162 r20180 11 11 switch (elementType) { 12 12 case TEXT: 13 if (element.value == '' ) {13 if (element.value == '' || (element.value == element.title || element.className == "DefaultText")) { 14 14 document.getElementById(element.id+'_error').style.display = 'block'; 15 15 element.className += " ecard_error_input"; -
extensions/Piwecard/language/en_UK/plugin.lang.php
r20173 r20180 10 10 $lang['piwecard_selected_cats'] = 'Selected categories'; 11 11 $lang['piwecard_non_selected_cats'] = 'Non-selected categories'; 12 $lang['piwecard_authorized_groups_users_denied']= '%u users have automatic denial because they belong to a denied group.'; 12 13 13 14 //admin_permissions.tpl … … 17 18 $lang['piwecard_permissions_user_cat'] = 'Sending of e-cards is authorized only if the category or one of its parents is named after the user or if the user is the author of the image'; 18 19 $lang['piwecard_user_cats_case_sensitive'] = 'Case sensitive (the category or one of its parents is named after the user)'; 20 $lang['piwecard_permissions_groups_users'] = 'Permissions depending on the group or user'; 21 $lang['piwecard_permissions_all_groups_users'] = 'All the users can send e-cards'; 22 $lang['piwecard_permissions_granted_groups_users']= 'Give permissions to selected groups and users'; 23 $lang['piwecard_permissions_denied_groups_users']= 'Deny selected groups and users'; 19 24 20 25 //admin_configuration.php … … 79 84 $lang['piwecard_sender'] = 'Sender'; 80 85 $lang['piwecard_recipient'] = 'Recipient'; 86 $lang['piwecard_add_recipient'] = 'Add a recipient'; 81 87 $lang['piwecard_validity_label'] = 'Period of validity'; 82 88 $lang['piwecard_send_mandatory_fields'] = 'Mandatory fields'; … … 94 100 //default_values.inc.php 95 101 $lang['piwecard_default_email_subject'] = '%yourname% has sent you an e-card'; 96 $lang['piwecard_default_email_message_text'] = 'Hello %recipientname%!102 $lang['piwecard_default_email_message_text'] = 'Hello %recipientname%! 97 103 %yourname% has sent you an e-card from the website %website%. 98 104 You can view this e-card at the following address: %ecardurl%. 99 105 See you on %website% (%websiteurl%)! 100 106 The Webmaster'; 101 $lang['piwecard_default_email_message_html'] = '<p>Hello %recipientname%!</p>107 $lang['piwecard_default_email_message_html'] = '<p>Hello %recipientname%!</p> 102 108 <p><b>%yourname%</b> has sent you an e-card from the website <a href="%websiteurl%">%website%</a>:</p> 103 109 <p><b>%ecardtitle%</b></p> -
extensions/Piwecard/language/fr_FR/plugin.lang.php
r20162 r20180 10 10 $lang['piwecard_selected_cats'] = 'Albums sélectionnées'; 11 11 $lang['piwecard_non_selected_cats'] = 'Albums non sélectionnés'; 12 $lang['piwecard_authorized_groups_users_denied'] = '%u utilisateurs ont automatiquement les permissions rejetées car ils appartiennent à un groupe rejeté.'; 12 13 13 14 //admin_permissions.tpl … … 17 18 $lang['piwecard_permissions_user_cat'] = 'L\'envoi de carte virtuelle est autorisé uniquement si l\'album ou un de ses parents porte le même nom que l\'utilisateur ou si l\'utilisateur est l\'auteur de la photo'; 18 19 $lang['piwecard_user_cats_case_sensitive'] = 'Sensible à la casse (l\'album ou un de ses parents porte le même nom que l\'utilisateur)'; 20 $lang['piwecard_permissions_groups_users'] = 'Permissions en fonction des groupes et des utilisateurs'; 21 $lang['piwecard_permissions_all_groups_users'] = 'Tous les utilisateurs peuvent envoyer des cartes virtuelles'; 22 $lang['piwecard_permissions_granted_groups_users'] = 'Donner les permissions à une sélection de groupes et utilisateurs'; 23 $lang['piwecard_permissions_denied_groups_users'] = 'Refuser les permissions à une sélection de groupes et utilisateurs'; 19 24 20 25 //admin_configuration.php … … 79 84 $lang['piwecard_sender'] = 'Expéditeur'; 80 85 $lang['piwecard_recipient'] = 'Destinataire'; 86 $lang['piwecard_add_recipient'] = 'Ajouter un destinataire'; 81 87 $lang['piwecard_validity_label'] = 'Durée de validité'; 82 88 $lang['piwecard_send_mandatory_fields'] = 'Champs obligatoires'; -
extensions/Piwecard/template/ecard.tpl
r20162 r20180 11 11 height:"90%", 12 12 onComplete:function(){ 13 13 $(".ecard_defaultText").blur(); 14 14 } 15 15 }); 16 17 jQuery("#addECardForm form").submit(function(){ 18 //jQuery(".createECardOpen").colorbox.close(); 16 17 jQuery(document).on("focusin", ".ecard_defaultText", function() { 18 defaultTextFocusIn($(this)); 19 }); 20 21 jQuery(document).on("focusout", ".ecard_defaultText", function() { 22 defaultTextFocusOut($(this)); 23 }); 24 25 function defaultTextFocusIn(element) { 26 if (element.val() == element[0].title) { 27 element.removeClass("ecard_defaultTextActive"); 28 element.val(""); 29 } 30 } 31 32 function defaultTextFocusOut(element) { 33 if (element.val() == "") { 34 element.addClass("ecard_defaultTextActive"); 35 element.val(element[0].title); 36 } 37 } 38 39 $('#ecard_add_recipient').click(function() { 40 var num = $('.ecard_name_recipient').length-1; 41 var newNum = new Number(num + 1); 42 43 if (newNum < 5) { 44 var newRecipient = $('#ecard_field_recipient_' + num).clone().attr('id', 'ecard_field_recipient_' + newNum); 45 46 newRecipient.find('.ecard_mandatory_fields').remove(); 47 newRecipient.find('.ecard_error').css("display", "none"); 48 newRecipient.find('#ecard_recipient_name_' + num + '_error').attr('id', 'ecard_recipient_name_' + newNum + '_error'); 49 newRecipient.find('#ecard_recipient_email_' + num + '_error').attr('id', 'ecard_recipient_email_' + newNum + '_error'); 50 newRecipient.find('#ecard_recipient_name_' + num).attr({ 51 id: 'ecard_recipient_name_' + newNum, 52 name: 'ecard_recipient_name[' + newNum+']', 53 value: '' 54 }); 55 newRecipient.find('#ecard_recipient_email_' + num).attr({ 56 id: 'ecard_recipient_email_' + newNum, 57 name: 'ecard_recipient_email[' + newNum+']', 58 value: '' 59 }); 60 newRecipient.find('#ecard_recipient_name_' + newNum).removeClass("ecard_error_input"); 61 newRecipient.find('#ecard_recipient_email_' + newNum).removeClass("ecard_error_input"); 62 defaultTextFocusOut(newRecipient.find('#ecard_recipient_name_' + newNum)); 63 defaultTextFocusOut(newRecipient.find('#ecard_recipient_email_' + newNum)); 64 65 $('#ecard_field_recipient_' + num).after(newRecipient); 66 } 19 67 }); 20 68 }); … … 25 73 var senderNameOK = piwecard_checkField(form.ecard_sender_name, 0); 26 74 var senderEMailOK = piwecard_checkField(form.ecard_sender_email, 1); 27 var recipientNameOK = piwecard_checkField(form.ecard_recipient_name, 0); 28 var recipientEMailOK = piwecard_checkField(form.ecard_recipient_email, 1); 75 var recipientNameOK = new Array(); 76 var recipientEMailOK = new Array(); 77 var nbAdditionalRecipients = 0; 78 var allRecipientNamesOK = false; 79 var allRecipientEmailsOK = false; 29 80 30 if(titleOK && messageOK && senderNameOK && senderEMailOK && recipientNameOK && recipientEMailOK) 81 recipientNameOK[0] = piwecard_checkField(form.ecard_recipient_name_0, 0); 82 recipientEMailOK[0] = piwecard_checkField(form.ecard_recipient_email_0, 1); 83 84 while(document.getElementById("ecard_recipient_email_" + (nbAdditionalRecipients++))) { 85 var id_name = "ecard_recipient_name_"+nbAdditionalRecipients; 86 var id_email = "ecard_recipient_email_"+nbAdditionalRecipients; 87 recipientEMailOK[nbAdditionalRecipients] = piwecard_checkField(document.getElementById(id_email), 1, true); 88 if (recipientEMailOK[nbAdditionalRecipients] && document.getElementById(id_email).value != '') 89 recipientNameOK[nbAdditionalRecipients] = piwecard_checkField(document.getElementById(id_name), 0, true); 90 } 91 92 for (var i=0; i<=nbAdditionalRecipients; i++) { 93 if (recipientNameOK[i] && recipientEMailOK[i]) { 94 allRecipientNamesOK = true; 95 allRecipientEmailsOK = true; 96 } else { 97 allRecipientNamesOK = false; 98 allRecipientEmailsOK = false; 99 break; 100 } 101 } 102 103 if (titleOK && messageOK && senderNameOK && senderEMailOK && allRecipientNamesOK && allRecipientEmailsOK) 31 104 return true; 32 105 else … … 44 117 <div class="ecard_error" id="ecard_title_error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div> 45 118 <span class="ecard_label">{'Title'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 46 <span class="ecard_input_right"><input name="ecard_title" type="text" id="ecard_title" value="{$ecard.title}" title="{$ecard.title}"></span>119 <span class="ecard_input_right"><input name="ecard_title" type="text" id="ecard_title" class="ecard_defaultText" title="{$ecard.title}"></span> 47 120 </div> 48 121 <div class="ecard_field"> 49 122 <div class="ecard_error" id="ecard_message_error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div> 50 123 <span class="ecard_label">{'piwecard_message'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 51 <span class="ecard_input_right"><textarea name="ecard_message" id="ecard_message" value="{$ecard.message}" title="{$ecard.message}">{$ecard.message}</textarea></span>124 <span class="ecard_input_right"><textarea name="ecard_message" id="ecard_message" class="ecard_defaultText" title="{$ecard.message}"></textarea></span> 52 125 </div> 53 126 </fieldset> … … 59 132 <span class="ecard_label">{'piwecard_sender'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 60 133 <span class="ecard_name"><input name="ecard_sender_name" type="text" id="ecard_sender_name" maxlength="100" value="{$ecard.sender_name}"></span> 61 <span class="ecard_email"><input name="ecard_sender_email" type="text" id="ecard_sender_email" maxlength="100" {$ecard.changemail} value="{$ecard.sender_email}" onblur="piwecard_checkField(this, 1);"></span>134 <span class="ecard_email"><input name="ecard_sender_email" type="text" id="ecard_sender_email" maxlength="100" {$ecard.changemail} value="{$ecard.sender_email}"></span> 62 135 </div> 63 <div class="ecard_field" >64 <div class="ecard_error" id="ecard_recipient_name_ error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div>65 <div class="ecard_error" id="ecard_recipient_email_ error">{'piwecard_error'|@translate} {'piwecard_error_email'|@translate}</div>136 <div class="ecard_field" id="ecard_field_recipient_0"> 137 <div class="ecard_error" id="ecard_recipient_name_0_error">{'piwecard_error'|@translate} {'piwecard_error_text'|@translate}</div> 138 <div class="ecard_error" id="ecard_recipient_email_0_error">{'piwecard_error'|@translate} {'piwecard_error_email'|@translate}</div> 66 139 <span class="ecard_label">{'piwecard_recipient'|@translate}<span class="ecard_mandatory_fields">*</span> :</span> 67 <span class="ecard_name "><input name="ecard_recipient_name" type="text" id="ecard_recipient_name" maxlength="100" value="{$ecard.recipient_name}"></span>68 <span class="ecard_email"><input name="ecard_recipient_email " type="text" id="ecard_recipient_email" maxlength="100" value="{$ecard.recipient_email}" onblur="piwecard_checkField(this, 1);"></span>140 <span class="ecard_name ecard_name_recipient"><input name="ecard_recipient_name[0]" type="text" id="ecard_recipient_name_0" class="ecard_defaultText" maxlength="100" title="{$ecard.recipient_name}"></span> 141 <span class="ecard_email"><input name="ecard_recipient_email[0]" type="text" id="ecard_recipient_email_0" class="ecard_defaultText" maxlength="100" title="{$ecard.recipient_email}"></span> 69 142 </div> 143 <a href="javascript:void(0)" id="ecard_add_recipient">{'piwecard_add_recipient'|@translate}</a> 70 144 </fieldset> 71 145 <fieldset>
Note: See TracChangeset
for help on using the changeset viewer.