Changeset 12561 for extensions/Subscribe_to_comments/include
- Timestamp:
- Nov 6, 2011, 7:33:55 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Subscribe_to_comments/include/functions.inc.php
r12560 r12561 15 15 $exclude = null; 16 16 if (!empty($_POST['stc_mail'])) $exclude = pwg_db_real_escape_string($_POST['stc_mail']); 17 if (!is_a_guest()) $exclude = $user['email'];17 else if (!is_a_guest()) $exclude = $user['email']; 18 18 19 19 // get subscribers emails … … 30 30 31 31 set_make_full_url(); 32 switch ($type) 33 { 34 case 'image': 35 { 36 // get image infos 37 $query = ' 32 if ($type == 'image') 33 { 34 // get image infos 35 $query = ' 38 36 SELECT 39 37 id, … … 43 41 WHERE id = '.$comm['image_id'].' 44 42 ;'; 45 $element = pwg_db_fetch_assoc(pwg_query($query)); 46 47 if (empty($element['name'])) 48 { 49 $element['name'] = get_name_from_file($element['file']); 50 } 43 $element = pwg_db_fetch_assoc(pwg_query($query)); 51 44 52 $url_params = array('image_id' => $element['id']); 53 if (!empty($page['category'])) 54 { 55 $url_params['section'] = 'categories'; 56 $url_params['category'] = $page['category']; 57 } 58 59 $element['url'] = make_picture_url($url_params); 60 break; 45 if (empty($element['name'])) 46 { 47 $element['name'] = get_name_from_file($element['file']); 61 48 } 62 49 63 case 'category' : 50 $url_params = array('image_id' => $element['id']); 51 if (!empty($page['category'])) 64 52 { 65 // get category infos 66 $query = ' 53 $url_params['section'] = 'categories'; 54 $url_params['category'] = $page['category']; 55 } 56 57 $element['url'] = make_picture_url($url_params); 58 } 59 else if ($type == 'category') 60 { 61 // get category infos 62 $query = ' 67 63 SELECT 68 64 id, 69 name 65 name, 66 permalink 70 67 FROM '.CATEGORIES_TABLE.' 71 68 WHERE id = '.$comm['category_id'].' 72 69 ;'; 73 $element = pwg_db_fetch_assoc(pwg_query($query)); 74 75 $url_params['section'] = 'categories'; 76 $url_params['category'] = $element; 77 78 79 $element['url'] = make_index_url($url_params); 80 break; 81 } 70 $element = pwg_db_fetch_assoc(pwg_query($query)); 71 72 $url_params['section'] = 'categories'; 73 $url_params['category'] = $element; 74 75 $element['url'] = make_index_url($url_params); 82 76 } 83 77 … … 117 111 } 118 112 113 119 114 /* 120 115 * add an email to subscribers list … … 128 123 129 124 $infos = $errors = array(); 130 131 125 if ( is_a_guest() and empty($email) ) 132 126 { 133 127 array_push($errors, l10n('Invalid email adress, your are not subscribed to comments.')); 128 129 $orig = $template->get_template_vars('errors'); 130 if (empty($orig)) $orig = array(); 131 $template->assign('errors', array_merge($orig, $errors)); 132 133 if ($type == 'category') $template->set_prefilter('index', 'coa_messages'); // here we use a prefilter existing in COA 134 134 135 return; 135 136 } 136 else if ( !is_a_guest())137 else if (!is_a_guest()) 137 138 { 138 139 $email = $user['email']; 139 140 } 140 141 142 // don't care if already registered 141 143 $query = ' 142 144 INSERT IGNORE INTO '.SUBSCRIBE_TO_TABLE.'( … … 155 157 pwg_query($query); 156 158 159 // send validation mail 157 160 if (is_a_guest() and pwg_db_insert_id() != 0) 158 161 { 162 $element_name = ($type == 'image') ? $picture['current']['name'] : $page['category']['name']; 163 159 164 $mail_args = array( 160 165 'subject' => '['.strip_tags($conf['gallery_title']).'] Please confirm your subscribtion to comments', … … 163 168 164 169 $mail_args['content'] = ' 165 You requested to subscribe by email to comments on <b>'.$ picture['current']['name'].'</b>.<br>170 You requested to subscribe by email to comments on <b>'.$element_name.'</b>.<br> 166 171 <br> 167 172 We care about your inbox, so we want to confirm this request. Please click the confirm link to activate the subscription.<br> … … 175 180 array_push($infos, l10n('Please check your email inbox to confirm your subscription.')); 176 181 } 182 // just displat confirmation message 183 else if (pwg_db_insert_id() != 0) 184 { 185 array_push($infos, l10n('You have been added to the list of subscribers for this '.($type=='image' ? 'picture' : 'album').'.')); 186 } 187 177 188 178 189 if (!empty($infos)) 179 190 { 180 $template->assign('infos', array_merge($template->get_template_vars('infos'), $infos)); 181 } 182 if (!empty($errors)) 183 { 184 $template->assign('errors', array_merge($template->get_template_vars('errors'), $errors)); 185 } 186 } 191 $orig = $template->get_template_vars('infos'); 192 if (empty($orig)) $orig = array(); 193 $template->assign('infos', array_merge($orig, $infos)); 194 195 if ($type == 'category') $template->set_prefilter('index', 'coa_messages'); 196 } 197 } 198 187 199 188 200 /** … … 194 206 function make_stc_url($action, $email) 195 207 { 196 if ( empty($action) or empty($email) ) return null; 208 if ( empty($action) or empty($email) ) 209 { 210 trigger_error('make_stc_url missing action and/or mail', E_USER_WARNING); 211 return null; 212 } 197 213 198 214 global $conf; … … 219 235 } 220 236 237 221 238 /** 222 239 * crypt a string using mcrypt extension or a binary method … … 266 283 } 267 284 285 268 286 /** 269 287 * variant of base64 functions usable into url
Note: See TracChangeset
for help on using the changeset viewer.