| [ Index ] |
|
Code source de Claroline 188 |
1 <?php // $Id: index.php,v 1.90 2007/01/25 06:16:39 moosh Exp $ 2 /** 3 * CLAROLINE 4 * 5 * Script for forum tool 6 * 7 * @version 1.8 $Revision: 1.90 $ 8 * 9 * @copyright 2001-2007 Universite catholique de Louvain (UCL) 10 * @copyright (C) 2001 The phpBB Group 11 * 12 * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE 13 * 14 * @author Claro Team <cvs@claroline.net> 15 * 16 * @package CLFRM 17 * 18 * @todo $last_post would be always a timestamp 19 * 20 */ 21 22 /*================================================================= 23 Init Section 24 =================================================================*/ 25 26 $tlabelReq = 'CLFRM'; 27 $gidReq=null; 28 $gidReset=true; 29 30 require '../inc/claro_init_global.inc.php'; 31 32 $nameTools = get_lang('Forums'); 33 34 if ( ! claro_is_in_a_course() || ! claro_is_course_allowed() ) claro_disp_auth_form(true); 35 36 claro_set_display_mode_available(true); // view mode 37 38 /*----------------------------------------------------------------- 39 Stats 40 -----------------------------------------------------------------*/ 41 42 event_access_tool(claro_get_current_tool_id(), claro_get_current_course_tool_data('label')); 43 44 /*----------------------------------------------------------------- 45 Library 46 -----------------------------------------------------------------*/ 47 48 include_once get_path('incRepositorySys') . '/lib/forum.lib.php'; 49 50 /*----------------------------------------------------------------- 51 Initialise variables 52 -----------------------------------------------------------------*/ 53 54 $last_visit = claro_get_current_user_data('lastLogin'); 55 $is_allowedToEdit = claro_is_course_manager() ; 56 $dialogBox = ''; 57 58 /*================================================================= 59 Main Section 60 =================================================================*/ 61 62 /*----------------------------------------------------------------- 63 Administration command 64 -----------------------------------------------------------------*/ 65 66 if ( $is_allowedToEdit ) include_once ('./admin.php'); 67 68 /*----------------------------------------------------------------- 69 Get forums categories 70 -----------------------------------------------------------------*/ 71 72 $categories = get_category_list(); 73 $total_categories = count($categories); 74 75 $forum_list = get_forum_list(); 76 77 if ( claro_is_user_authenticated() ) 78 { 79 $userGroupList = get_user_group_list(claro_get_current_user_id()); 80 $tutorGroupList = get_tutor_group_list(claro_get_current_user_id()); 81 } 82 else 83 { 84 $userGroupList = array(); 85 $tutorGroupList = array(); 86 } 87 88 89 /*================================================================= 90 Display Section 91 =================================================================*/ 92 93 // Claroline Header 94 95 include get_path('incRepositorySys') . '/claro_init_header.inc.php'; 96 97 $pagetype = 'index'; 98 99 $is_allowedToEdit = claro_is_allowed_to_edit() 100 || ( claro_is_group_tutor() && !claro_is_course_manager() ); 101 // ( claro_is_group_tutor() 102 // is added to give admin status to tutor 103 // && !claro_is_course_manager()) 104 // is added to let course admin, tutor of current group, use student mode 105 106 $is_forumAdmin = claro_is_allowed_to_edit(); 107 108 $is_groupPrivate = claro_get_current_group_properties_data('private'); 109 110 echo claro_html_tool_title(get_lang('Forums'), 111 $is_allowedToEdit ? 'help_forum.php' : false); 112 113 echo disp_search_box(); 114 115 if ( !empty($dialogBox) ) echo claro_html_message_box($dialogBox); 116 117 // Forum toolbar 118 119 echo claro_html_menu_horizontal(disp_forum_toolbar($pagetype, 0, 0, 0)); 120 121 /*----------------------------------------------------------------- 122 Display Forum Index Page 123 ------------------------------------------------------------------*/ 124 125 echo '<table width="100%" class="claroTable emphaseLine">' . "\n"; 126 127 $colspan = $is_allowedToEdit ? 9 : 4; 128 129 $categoryIterator = 0; 130 131 foreach ( $categories as $this_category ) 132 { 133 ++$categoryIterator; 134 135 // Pass category for sumple user if no forum inside 136 if ($this_category['forum_count'] == 0 && ! $is_allowedToEdit) continue; 137 138 if ($this_category['forum_count'] > 0) $thCssClass = ''; 139 else $thCssClass = ' class="invisible" '; 140 141 echo '<tr class="superHeader" align="left" valign="top">' . "\n" 142 143 . '<th colspan="'.$colspan.'" '.$thCssClass.'>' 144 ; 145 146 if($is_allowedToEdit) 147 { 148 echo '<div style="float:right">' 149 . '<a href="' . $_SERVER['PHP_SELF'] 150 . '?cmd=rqEdCat&catId=' . $this_category['cat_id'] . '">' 151 . '<img src="' . get_path('imgRepositoryWeb') . 'edit.gif" alt="' . get_lang('Edit') . '" />' 152 . '</a>' 153 . ' ' 154 ; 155 156 if ( $this_category['cat_id'] != GROUP_FORUMS_CATEGORY ) 157 echo '<a href="'.$_SERVER['PHP_SELF'].'?cmd=exDelCat&catId='.$this_category['cat_id'].'" ' 158 . 'onClick="return confirm_delete(\''. clean_str_for_javascript($this_category['cat_title']).'\');" >' 159 . '<img src="' . get_path('imgRepositoryWeb') . '/delete.gif" alt="'.get_lang('Delete').'" />' 160 . '</a>' 161 . ' ' 162 ; 163 164 if ( $categoryIterator > 1) 165 echo '<a href="'.$_SERVER['PHP_SELF'].'?cmd=exMvUpCat&catId='.$this_category['cat_id'].'">' 166 . '<img src="' . get_path('imgRepositoryWeb') . '/up.gif" alt="'.get_lang('Move up').'" />' 167 . '</a>' 168 ; 169 170 if ( $categoryIterator < $total_categories) 171 { 172 echo '<a href="' . $_SERVER['PHP_SELF'] 173 . '?cmd=exMvDownCat' 174 . '&catId=' . $this_category['cat_id'] . '">' 175 . '<img src="' . get_path('imgRepositoryWeb') . 'down.gif" alt="' . get_lang('Move down') . '" />' 176 . '</a>' 177 ; 178 } 179 180 echo '</div>' 181 ; 182 } 183 184 echo htmlspecialchars($this_category['cat_title']); 185 186 if ( $this_category['cat_id'] == GROUP_FORUMS_CATEGORY) 187 { 188 echo ' ' 189 . '<a href="' . get_module_url('CLGRP') . '/group.php">' 190 . '<img src="' . get_path('imgRepositoryWeb') . '/group.gif" alt="' . get_lang('Groups') . '">' 191 . '</a>' 192 ; 193 } 194 195 echo '</th>' . "\n" 196 . '</tr>' . "\n" 197 ; 198 199 if ($this_category['forum_count'] == 0) 200 { 201 echo '<tr>' . "\n" 202 . '<td colspan="' . $colspan . '" align="center">' . get_lang('No forum') . '</td>' . "\n" 203 . '</tr>' . "\n"; 204 } 205 else 206 { 207 echo ' <tr class="headerX" align="center">' . "\n" 208 . ' <th align="left">' . get_lang('Forum') . '</th>' . "\n" 209 . ' <th>' . get_lang('Topics') . '</th>' . "\n" 210 . ' <th>' . get_lang('Posts') . '</th>' . "\n" 211 . ' <th>' . get_lang('Last message') . '</th>' . "\n" 212 ; 213 214 if ($is_allowedToEdit) 215 { 216 echo '<th>'.get_lang('Edit').'</th>' 217 . '<th>'.get_lang('Empty').'</th>' 218 . '<th>'.get_lang('Delete').'</th>' 219 . '<th colspan="2">'.get_lang('Move').'</th>' 220 ; 221 } 222 echo '</tr>' . "\n"; 223 } 224 225 $forumIterator = 0; 226 227 if (claro_is_user_authenticated()) $date = $claro_notifier->get_notification_date(claro_get_current_user_id()); 228 229 foreach ( $forum_list as $this_forum ) 230 { 231 if ( $this_forum['cat_id'] == $this_category['cat_id'] ) 232 { 233 ++ $forumIterator; 234 235 $forum_name = htmlspecialchars($this_forum['forum_name']); 236 $forum_desc = htmlspecialchars($this_forum['forum_desc']); 237 $last_post = $this_forum['post_time']; 238 $total_topics = (int) $this_forum['forum_topics']; 239 $total_posts = (int) $this_forum['forum_posts' ]; 240 $forum_id = (int) $this_forum['forum_id' ]; 241 $group_id = is_null($this_forum['group_id']) ? 242 null : (int) $this_forum['group_id']; 243 244 $forum_post_allowed = ($this_forum['forum_access'] != 0) ? true : false; 245 246 echo '<tr align="left" valign="top">' . "\n"; 247 248 if (claro_is_user_authenticated() && $claro_notifier->is_a_notified_forum(claro_get_current_course_id(), $date, claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $this_forum['forum_id'])) 249 { 250 $forum_img = 'forum_hot.gif'; 251 } 252 else 253 { 254 $forum_img = 'forum.gif'; 255 } 256 257 if ( $forum_post_allowed) 258 { 259 $locked_string = ''; 260 } 261 else 262 { 263 $locked_string = ' <img src="' . get_path('imgRepositoryWeb') . '/locked.gif" alt="'.get_lang('Locked').'" title="'.get_lang('Locked').'" /> <small>('.get_lang('No new post allowed').')</small>'; 264 } 265 266 echo '<td>' . "\n" 267 . '<img src="' . get_path('imgRepositoryWeb') . $forum_img . '" alt="" />' . "\n" 268 . ' ' . "\n" 269 ; 270 271 // Visit only my group forum if not admin or tutor. 272 // If tutor, see all groups but indicate my groups. 273 // Group Category == 1 274 275 if ( ! is_null($group_id ) ) 276 { 277 if ( in_array($group_id, $userGroupList ) 278 || in_array($group_id, $tutorGroupList) 279 || ! $is_groupPrivate || $is_forumAdmin 280 ) 281 { 282 echo '<a href="viewforum.php?gidReq=' . $group_id 283 . '&forum=' . $forum_id . '">' 284 . $forum_name 285 . '</a>' . "\n" 286 287 . ' ' . "\n" 288 289 . '<a href="' . get_module_url('CLGRP') . '/group_space.php?gidReq=' . $group_id . '">' 290 . '<img src="' . get_path('imgRepositoryWeb') . '/group.gif" alt="' . get_lang('Group area') . '">' 291 . '</a>' . "\n" 292 ; 293 294 if ( is_array($tutorGroupList) && in_array($group_id, $tutorGroupList) ) 295 { 296 echo ' <small>(' . get_lang('my supervision') . ')</small>'; 297 } 298 299 if ( is_array($userGroupList) && in_array($group_id, $userGroupList) ) 300 { 301 echo ' <small>(' . get_lang('my group') . ')</small>'; 302 } 303 } 304 else 305 { 306 echo $forum_name; 307 } 308 } 309 else 310 { 311 echo '<a href="viewforum.php?forum=' . $forum_id . '">' 312 . $forum_name 313 . '</a> '; 314 } 315 316 echo $locked_string; 317 318 echo '<br /><div class="comment">' . $forum_desc . '</div>' . "\n" 319 . '</td>' . "\n" 320 321 . '<td align="center">' . "\n" 322 . '<small>' . $total_topics . '</small>' . "\n" 323 . '</td>' . "\n" 324 325 . '<td align="center">' . "\n" 326 . '<small>' . $total_posts . '</small>' . "\n" 327 . '</td>' . "\n" 328 . '<td align="center">' . "\n" 329 . '<small>' 330 . ( 331 ($last_post > 0) ? 332 claro_html_localised_date(get_locale('dateTimeFormatShort'), datetime_to_timestamp($last_post)) : 333 get_lang('No post') 334 ) 335 . '</small>' 336 . '</td>' . "\n" 337 ; 338 339 340 if( $is_allowedToEdit) 341 { 342 echo '<td align="center">'; 343 344 if ( is_null($group_id ) ) 345 { 346 echo '<a href="'.$_SERVER['PHP_SELF'].'?cmd=rqEdForum&forumId='.$forum_id.'">' 347 . '<img src="' . get_path('imgRepositoryWeb') . 'edit.gif" alt="'.get_lang('Edit').'" />' 348 . '</a>' 349 ; 350 } 351 else 352 { 353 echo ' '; 354 } 355 356 echo '</td>' 357 358 . '<td align="center">' 359 . '<a href="'.$_SERVER['PHP_SELF'].'?cmd=exEmptyForum&forumId='.$forum_id.'" ' 360 . 'onClick="return confirm_empty(\''. clean_str_for_javascript($forum_name).'\');" >' 361 . '<img src="' . get_path('imgRepositoryWeb') . 'sweep.gif" alt="'.get_lang('Empty').'" />' 362 . '</a>' 363 . '</td>' 364 365 .'<td align="center">'; 366 367 if ( is_null($group_id ) ) 368 { 369 echo '<a href="'.$_SERVER['PHP_SELF'].'?cmd=exDelForum&forumId='.$forum_id.'" ' 370 . 'onClick="return confirm_delete(\''. clean_str_for_javascript($forum_name).'\');" >' 371 . '<img src="' . get_path('imgRepositoryWeb') . 'delete.gif" alt="'.get_lang('Delete').'" />' 372 . '</a>'; 373 } 374 else echo ' '; 375 376 echo '</td>' 377 378 . '<td align="center">'; 379 380 if ($forumIterator > 1) 381 { 382 echo '<a href="'.$_SERVER['PHP_SELF'].'?cmd=exMvUpForum&forumId='.$forum_id.'">' 383 . '<img src="' . get_path('imgRepositoryWeb') . 'up.gif" alt="'.get_lang('Move up').'" />' 384 . '</a>'; 385 } 386 else echo ' '; 387 388 echo '</td>' 389 . '<td align="center">' 390 ; 391 392 if ( $forumIterator < $this_category['forum_count'] ) 393 { 394 echo '<a href="'.$_SERVER['PHP_SELF'].'?cmd=exMvDownForum&forumId='.$forum_id.'">' 395 . '<img src="' . get_path('imgRepositoryWeb') . 'down.gif" alt="'.get_lang('Move down').'" />' 396 . '</a>'; 397 } 398 else echo ' '; 399 400 echo '</td>'; 401 } 402 403 echo '</tr>' . "\n"; 404 } 405 } 406 } 407 408 echo '</table>' . "\n"; 409 410 // Display Forum Footer 411 412 include get_path('incRepositorySys') . '/claro_init_footer.inc.php'; 413 414 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Nov 29 14:38:42 2007 | par Balluche grâce à PHPXref 0.7 |
|