Changeset 21347
- Timestamp:
- Mar 8, 2013, 1:41:19 AM (11 years ago)
- Location:
- extensions/Comments_on_Albums/trunk
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Comments_on_Albums/trunk/main.inc.php
r19991 r21347 10 10 11 11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 12 13 if (mobile_theme()) 14 { 15 return; 16 } 12 17 13 18 global $prefixeTable; -
extensions/Comments_on_Albums/trunk/stuffs_module/config.inc.php
r12381 r21347 13 13 else 14 14 { 15 if (!isset($_POST['show_admin_buttons'])) 16 { 17 $_POST['show_admin_buttons'] = 'off'; 18 } 15 19 $datas = array( 16 20 $_POST['nb_comments'], 17 isset($_POST['show_admin_buttons']),21 $_POST['show_admin_buttons'], 18 22 $_POST['nb_cadres'], 19 23 $_POST['width'], … … 33 37 'HEIGHT' => $datas[4] 34 38 )); 35 if ($datas[1] )39 if ($datas[1] == 'on') 36 40 { 37 41 $template->assign(array('SHOW_ADMIN_BUTTONS' => 'checked="checked"')); -
extensions/Comments_on_Albums/trunk/stuffs_module/config.tpl
r18927 r21347 1 1 <table> 2 <tr> 3 <td align="right"><br>{'lastcoms_nb_comments'|@translate} </td> 4 <td><br> 5 <input type="text" size="3" maxlength="2" value="{$NB_COMMENTS}" name="nb_comments"/></td> 6 </tr> 7 <tr> 8 <td align="right"><br>{'lastcoms_show_buttons'|@translate} </td> 9 <td><br> 10 <input type="checkbox" name="show_admin_buttons" value="on" {$SHOW_ADMIN_BUTTONS}/></td> 11 </tr> 2 12 <tr> 3 <td align="right"><br>{'lastcoms_nb_comments'|@translate} </td> 4 <td><br> 5 <input type="text" size="3" maxlength="2" value="{$NB_COMMENTS}" name="nb_comments"/></td> 6 </tr> 7 <tr> 8 <td align="right"><br>{'lastcoms_show_buttons'|@translate} </td> 9 <td><br> 10 <input type="checkbox" name="show_admin_buttons" value="on" {$SHOW_ADMIN_BUTTONS}/></td> 11 </tr> 12 <tr> 13 <td align="right"><br>{'lastcoms_nb_cadres'|@translate} </td> 14 <td><br> 13 <td align="right"><br>{'lastcoms_nb_cadres'|@translate} </td> 14 <td><br> 15 15 {html_options name=nb_cadres options=$nb_cadres.OPTIONS selected=$nb_cadres.SELECTED} 16 16 </td> 17 17 </tr> 18 18 <tr> 19 20 21 22 23 24 25 26 27 19 <td align="right"><br>{'lastcoms_dim'|@translate} : {'lastcoms_width'|@translate} </td> 20 <td><br> 21 <input type="text" size="3" maxlength="3" value="{$WIDTH}" name="width"/> px</td> 22 </tr> 23 <tr> 24 <td align="right">{'lastcoms_height'|@translate} </td> 25 <td> 26 <input type="text" size="3" maxlength="3" value="{$HEIGHT}" name="height"/> px</td> 27 </tr> 28 28 </table> 29 29 <br> -
extensions/Comments_on_Albums/trunk/stuffs_module/main.inc.php
r12562 r21347 2 2 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 include_once(COA_PATH.'include/functions_comment.inc.php'); 5 4 6 global $user, $conf; 5 7 … … 7 9 // | comments management | 8 10 // +-----------------------------------------------------------------------+ 9 // comments deletion 10 if (isset($_GET['delete_album']) and is_numeric($_GET['delete_album']) and is_admin()) 11 { 12 check_status(ACCESS_ADMINISTRATOR); 13 check_pwg_token(); 14 $query = ' 15 DELETE FROM ' . COA_TABLE . ' 16 WHERE id=' . $_GET['delete_album'] . ' 17 ;'; 18 pwg_query($query); 19 } 20 21 // comments validation 22 if (isset($_GET['validate_album']) and is_numeric($_GET['validate_album']) and is_admin()) 23 { 24 check_status(ACCESS_ADMINISTRATOR); 25 check_pwg_token(); 26 $query = ' 27 UPDATE ' . COA_TABLE . ' 28 SET validated = \'true\' 29 , validation_date = NOW() 30 WHERE id=' . $_GET['validate_album'] . ' 31 ;'; 32 pwg_query($query); 11 12 $comment_id = null; 13 $action = null; 14 15 $actions = array('delete_comment_album', 'validate_comment_album', 'edit_comment_album'); 16 foreach ($actions as $loop_action) 17 { 18 if (isset($_GET[$loop_action])) 19 { 20 $action = $loop_action; 21 check_input_parameter($action, $_GET, false, PATTERN_ID); 22 $comment_id = $_GET[$action]; 23 break; 24 } 25 } 26 27 if (isset($action)) 28 { 29 check_pwg_token(); 30 31 $comment_author_id = get_comment_author_id_albums($comment_id); 32 $action = str_replace('_comment_album', '', $action); 33 34 if (can_manage_comment($action, $comment_author_id)) 35 { 36 $perform_redirect = false; 37 38 if ('delete' == $action) 39 { 40 delete_user_comment_albums($comment_id); 41 $perform_redirect = true; 42 } 43 44 if ('validate' == $action) 45 { 46 validate_user_comment_albums($comment_id); 47 $perform_redirect = true; 48 } 49 50 if ('edit' == $action) 51 { 52 if (!empty($_POST['content'])) 53 { 54 update_user_comment_albums( 55 array( 56 'comment_id' => $_GET['edit_comment_album'], 57 'category_id' => $_POST['image_id'], 58 'content' => $_POST['content'] 59 ), 60 $_POST['key'] 61 ); 62 63 $perform_redirect = true; 64 } 65 else 66 { 67 $edit_comment = $_GET['edit_comment_album']; 68 } 69 } 70 71 if ($perform_redirect) 72 { 73 $redirect_url = 74 PHPWG_ROOT_PATH 75 .'index.php' 76 .get_query_string_diff(array('delete_comment_album','validate_comment_album','edit_comment_album','pwg_token')); 77 78 redirect(rtrim($redirect_url, '=')); 79 } 80 } 33 81 } 34 82 … … 36 84 // | last comments display | 37 85 // +-----------------------------------------------------------------------+ 86 if ( !is_admin() ) 87 { 88 $page['where_clauses'][] = 'validated=\'true\''; 89 } 90 91 $page['where_clauses'][] = get_sql_condition_FandF 92 ( 93 array 94 ( 95 'forbidden_categories' => 'category_id', 96 'visible_categories' => 'category_id', 97 ), 98 '', true 99 ); 100 38 101 $comments = array(); 39 102 $element_ids = array(); 40 103 $category_ids = array(); 41 $max_width = 0;42 if (!is_admin())43 {44 $clauses[] = 'validated="true"';45 }46 $clauses[] = get_sql_condition_FandF (47 array ('forbidden_categories' => 'category_id',48 'visible_categories' => 'category_id'), '', true);49 104 50 105 $query = ' 51 SELECT 52 com.id AS comment_id, 53 com.category_id, 54 com.author, 55 com.author_id, 56 '.$conf['user_fields']['username'].' AS username, 57 com.date, 58 com.content, 59 com.validated 106 SELECT com.id AS comment_id, 107 com.category_id, 108 com.author, 109 com.author_id, 110 com.date, 111 com.content, 112 com.validated 60 113 FROM '.COA_TABLE.' AS com 61 LEFT JOIN '.USERS_TABLE.' A su62 114 LEFT JOIN '.USERS_TABLE.' AS u 115 ON u.'.$conf['user_fields']['id'].' = com.author_id 63 116 WHERE '.implode(' 64 AND ', $clauses).' 65 GROUP BY 66 comment_id 117 AND ', $page['where_clauses']).' 118 GROUP BY comment_id, 119 com.category_id, 120 com.author, 121 com.author_id, 122 com.date, 123 com.content, 124 com.validated 67 125 ORDER BY date DESC 68 LIMIT 0, ' . $datas[0] . ' 126 LIMIT 0, ' . $datas[0] . ';'; 127 128 $query.= ' 69 129 ;'; 70 71 130 $result = pwg_query($query); 72 while ($row = mysql_fetch_assoc($result))131 while ($row = pwg_db_fetch_assoc($result)) 73 132 { 74 133 array_push($comments, $row); … … 78 137 if (count($comments) > 0) 79 138 { 139 $block['TEMPLATE'] = 'stuffs_lastcoms.tpl'; 80 140 $block['TITLE_URL'] = 'comments.php?display_mode=albums'; 81 141 $block['comments'] = array(); 82 142 $block['MAX_WIDTH'] = $datas[3]; 143 $block['MAX_HEIGHT'] = $datas[4]; 144 switch ($datas[2]) 145 { 146 case 1 : 147 $block['NB_COMMENTS_LINE'] = '99%'; 148 break; 149 case 2 : 150 $block['NB_COMMENTS_LINE'] = '49%'; 151 break; 152 case 3 : 153 $block['NB_COMMENTS_LINE'] = '32.4%'; 154 break; 155 } 156 83 157 // retrieving category informations 84 158 $query = ' … … 90 164 com.id as comment_id, 91 165 img.id AS image_id, 92 img.path, 93 img.tn_ext 166 img.path 94 167 FROM '.CATEGORIES_TABLE.' AS cat 95 168 LEFT JOIN '.COA_TABLE.' AS com … … 115 188 $comment['cat_url'] = duplicate_index_url( 116 189 array( 117 'category' => array( 118 'id' => $categories[$comment['comment_id']]['id'], 119 'name' => $categories[$comment['comment_id']]['name'], 120 'permalink' => $categories[$comment['comment_id']]['permalink'], 121 ), 190 'category' => $categories[$comment['comment_id']], 122 191 array('start') 123 192 ) 124 193 ); 125 126 // category thumbnail 127 $comment['thumb'] = get_thumbnail_url( 128 array( 129 'id' => $categories[$comment['comment_id']]['image_id'], 130 'path' => $categories[$comment['comment_id']]['path'], 131 'tn_ext' => @$categories[$comment['comment_id']]['tn_ext'], 132 ) 133 ); 194 195 // source of the thumbnail picture 196 $src_image = new SrcImage(array( 197 'id' => $categories[$comment['comment_id']]['image_id'], 198 'path' => $categories[$comment['comment_id']]['path'], 199 )); 134 200 135 201 // author 136 $author = $comment['author'];137 202 if (empty($comment['author'])) 138 203 { 139 $author = l10n('guest'); 140 } 141 142 // comment content 204 $comment['author'] = l10n('guest'); 205 } 206 143 207 $tpl_comment = array( 144 208 'ID' => $comment['comment_id'], 145 209 'U_PICTURE' => $comment['cat_url'], 210 'src_image' => $src_image, 146 211 'ALT' => trigger_event('render_category_name', $categories[$comment['comment_id']]['name']), 147 'TN_SRC' => $comment['thumb'], 148 'AUTHOR' => trigger_event('render_comment_author', $author), 149 'DATE' => format_date($comment['date'], true), 150 'CONTENT' => trigger_event('render_comment_content', $comment['content'], 'album'), 212 'AUTHOR' => trigger_event('render_comment_author', $comment['author']), 213 'DATE'=>format_date($comment['date'], true), 214 'CONTENT'=>trigger_event('render_comment_content',$comment['content']), 151 215 'WIDTH' => $datas[3], 152 216 'HEIGHT' => $datas[4], 153 217 ); 154 155 switch ($datas[2]) 156 { 157 case 1 : 158 $tpl_comment['CLASS'] = 'one_comment'; 159 break; 160 case 2 : 161 $tpl_comment['CLASS'] = 'two_comment'; 162 break; 163 case 3 : 164 $tpl_comment['CLASS'] = 'three_comment'; 165 break; 166 } 167 168 // actions 169 if ( is_admin() and $datas[1]) 170 { 171 $url = get_root_url().'index.php'.get_query_string_diff(array('delete_album','validate_album')); 172 $tpl_comment['U_DELETE'] = add_url_params($url, array( 173 'delete_album' => $comment['comment_id'], 174 'pwg_token' => get_pwg_token())); 175 176 if ($comment['validated'] != 'true') 177 { 178 $tpl_comment['U_VALIDATE'] = add_url_params($url, array( 179 'validate_album' => $comment['comment_id'], 180 'pwg_token' => get_pwg_token())); 218 219 if ($datas[1] == 'on') 220 { 221 $url = 222 get_root_url() 223 .'index.php' 224 .get_query_string_diff(array('edit_comment_album', 'delete_comment_album','validate_comment_album', 'pwg_token')); 225 226 if (can_manage_comment('delete', $comment['author_id'])) 227 { 228 $tpl_comment['U_DELETE'] = add_url_params( 229 $url, 230 array( 231 'delete_comment_album' => $comment['comment_id'], 232 'pwg_token' => get_pwg_token(), 233 ) 234 ); 235 } 236 237 if (can_manage_comment('edit', $comment['author_id'])) 238 { 239 $tpl_comment['U_EDIT'] = add_url_params( 240 $url, 241 array( 242 'edit_comment_album' => $comment['comment_id'], 243 'pwg_token' => get_pwg_token(), 244 ) 245 ); 246 247 if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment)) 248 { 249 $tpl_comment['IN_EDIT'] = true; 250 $key = get_ephemeral_key(2, $comment['category_id']); 251 $tpl_comment['KEY'] = $key; 252 $tpl_comment['IMAGE_ID'] = $comment['category_id']; 253 $tpl_comment['CONTENT'] = $comment['content']; 254 $tpl_comment['PWG_TOKEN'] = get_pwg_token(); 255 } 256 } 257 258 if (can_manage_comment('validate', $comment['author_id'])) 259 { 260 if ('true' != $comment['validated']) 261 { 262 $tpl_comment['U_VALIDATE'] = add_url_params( 263 $url, 264 array( 265 'validate_comment_album'=> $comment['comment_id'], 266 'pwg_token' => get_pwg_token(), 267 ) 268 ); 269 } 181 270 } 182 271 } … … 184 273 array_push($block['comments'], $tpl_comment); 185 274 } 186 $block[' TEMPLATE'] = dirname(__FILE__).'/stuffs_lastcoms.tpl';275 $block['derivative_params'] = ImageStdParams::get_by_type(IMG_THUMB); 187 276 } 188 277
Note: See TracChangeset
for help on using the changeset viewer.