[ Index ] |
|
Code source de Claroline 188 |
1 <?php // $Id: module.php,v 1.45.2.1 2007/04/02 15:34:52 mathieu Exp $ 2 3 /** 4 * CLAROLINE 5 * @version 1.8 $Revision: 1.45.2.1 $ 6 * 7 * @copyright (c) 2001-2007 Universite catholique de Louvain (UCL) 8 * 9 * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE 10 * 11 * @package ADMIN 12 * 13 * @author claro team <cvs@claroline.net> 14 * @since 1.8 15 */ 16 17 require '../../inc/claro_init_global.inc.php'; 18 19 //SECURITY CHECK 20 21 if ( ! claro_is_user_authenticated() ) 22 { 23 claro_disp_auth_form(); 24 } 25 26 if ( ! claro_is_platform_admin() ) 27 { 28 claro_die(get_lang('Not allowed')); 29 } 30 31 //CONFIG and DEVMOD vars : 32 33 //SQL table name 34 35 $tbl_name = claro_sql_get_main_tbl(); 36 $tbl_module = $tbl_name['module']; 37 $tbl_module_info = $tbl_name['module_info']; 38 $tbl_dock = $tbl_name['dock']; 39 40 //NEEDED LIBRAIRIES 41 42 require_once get_path('incRepositorySys') . '/lib/module.manage.lib.php'; 43 require_once get_path('incRepositorySys') . '/lib/admin.lib.inc.php'; 44 45 $interbredcrump[]= array ('url' => get_path('rootAdminWeb'), 'name' => get_lang('Administration')); 46 47 $undeactivable_tool_array = array('CLDOC', 48 'CLGRP' 49 ); 50 51 $htmlHeadXtra[] = 52 "<script type=\"text/javascript\"> 53 function confirmMakeVisible () 54 { 55 if (confirm(\" ".clean_str_for_javascript(get_lang("Are you sure you want to make this module visible in all courses ?"))."\")) 56 {return true;} 57 else 58 {return false;} 59 } 60 function confirmMakeInVisible () 61 { 62 if (confirm(\" ".clean_str_for_javascript(get_lang("Are you sure you want to make this module invisible in all courses ?"))."\")) 63 {return true;} 64 else 65 {return false;} 66 } 67 </script>"; 68 69 //---------------------------------- 70 // GET REQUEST VARIABLES 71 //---------------------------------- 72 73 $cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : null); 74 $item = (isset($_REQUEST['item'])? $_REQUEST['item'] : 'GLOBAL'); 75 $section_selected = (isset($_REQUEST['section'])? $_REQUEST['section'] : null); 76 $moduleId = (isset($_REQUEST['module_id'])? $_REQUEST['module_id'] : null); 77 $module = get_module_info($moduleId); 78 $dockList = get_dock_list($module['type']); 79 $interbredcrump[]= array ('url' => 'module_list.php?typeReq=' . $module['type'], 'name' => get_lang('Module list')); 80 $interbredcrump[]= array ('url' =>'','name' => get_lang($module['module_name'])); 81 $nameTools = get_lang('Module settings'); 82 $noPHP_SELF=true; 83 84 //---------------------------------- 85 // EXECUTE COMMAND 86 //---------------------------------- 87 88 switch ( $cmd ) 89 { 90 case 'activ' : 91 { 92 if (activate_module($moduleId)) 93 { 94 $dialogBox = get_lang('Module activation succeeded'); 95 $module['activation'] = 'activated'; 96 } 97 else 98 { 99 $dialogBox = get_lang('Cannot activate module'); 100 } 101 break; 102 } 103 case 'deactiv' : 104 { 105 if (deactivate_module($moduleId)) 106 { 107 $dialogBox = get_lang('Module deactivation succeeded'); 108 $module['activation'] = 'deactivated'; 109 } 110 else 111 { 112 $dialogBox = get_lang('Cannot deactivate module'); 113 $module['activation'] = 'activated'; 114 } 115 break; 116 } 117 case 'movedock' : 118 { 119 if( is_array($dockList) ) 120 { 121 if ( isset($_REQUEST['displayDockList']) && is_array($_REQUEST['displayDockList']) ) 122 { 123 foreach ($dockList as $dockId => $dockName) 124 { 125 126 if ( in_array($dockId,$_REQUEST['displayDockList']) ) 127 { 128 add_module_in_dock($moduleId, $dockId); 129 } 130 else 131 { 132 remove_module_dock($moduleId, $dockId); 133 } 134 } 135 } 136 $dialogBox = get_lang('Changes in the display of the module have been applied'); 137 } 138 break; 139 } 140 case 'makeVisible': 141 case 'makeInvisible': 142 { 143 $visibility = ( 'makeVisible' == $cmd ) ? true : false; 144 145 list ( $log, $success ) = set_module_visibility( $moduleId, $visibility ); 146 147 if ( $success ) 148 { 149 $dialogBox = get_lang('Module visibility updated'); 150 } 151 else 152 { 153 $dialogBox = get_lang('Failed to update module visibility'); 154 } 155 156 break; 157 } 158 } 159 160 // create an array with only dock names 161 162 $sql = "SELECT `name` AS `dockname` 163 FROM `" . $tbl_dock . "` 164 WHERE `module_id` = " . (int) $moduleId; 165 166 $module_dock = claro_sql_query_fetch_all($sql); 167 168 $dock_checked = array(); 169 170 foreach($module_dock as $thedock) 171 { 172 $dock_checked[] = $thedock['dockname']; 173 } 174 175 //---------------------------------- 176 // DISPLAY 177 //---------------------------------- 178 179 include get_path('incRepositorySys') . '/claro_init_header.inc.php'; 180 181 // find module icon, if any 182 183 if (array_key_exists('icon',$module) && !empty($module['icon']) && file_exists(get_module_path($module['label']) . '/' .$module['icon'])) 184 { 185 $icon = '<img src="' . get_module_url($module['label']) . '/' . $module['icon'] . '" />'; 186 } 187 elseif (file_exists(get_module_path($module['label']) . '/icon.png')) 188 { 189 $icon = '<img src="' . get_module_url($module['label']) . '/icon.png" />'; 190 } 191 elseif (file_exists(get_module_path($module['label']) . '/icon.gif')) 192 { 193 $icon = '<img src="' . get_module_url($module['label']) . '/icon.gif" />'; 194 } 195 else 196 { 197 $icon = '<small>' . get_lang('No icon') . '</small>'; 198 } 199 200 //display title 201 202 echo claro_html_tool_title($nameTools . ' : ' . get_lang($module['module_name'])); 203 204 //Display Forms or dialog box(if needed) 205 206 if ( isset($dialogBox) ) 207 { 208 echo claro_html_message_box($dialogBox); 209 } 210 211 //display tabbed navbar 212 213 echo '<div>' 214 . '<ul id="navlist">' 215 . "\n" 216 ; 217 218 //display the module type tabbed naviguation bar 219 220 if ($item == 'GLOBAL') 221 { 222 echo '<li><a href="module.php?module_id='.$moduleId 223 . '&item=GLOBAL" class="current">' 224 . get_lang('Global settings').'</a></li>' 225 . "\n" 226 ; 227 } 228 else 229 { 230 echo '<li><a href="module.php?module_id='.$moduleId.'&item=GLOBAL">' 231 . get_lang('Global settings').'</a></li>' 232 . "\n" 233 ; 234 } 235 236 $config_code = $module['label']; 237 238 // new config object 239 require_once get_path('incRepositorySys') . '/lib/configHtml.class.php'; 240 241 $config = new ConfigHtml($config_code, $_SERVER['HTTP_REFERER']); 242 243 if ( $config->load() ) 244 { 245 if ($item == 'LOCAL') 246 { 247 echo '<li><a href="module.php?module_id='.$moduleId 248 . '&item=LOCAL" class="current">' 249 . get_lang('Local settings').'</a></li>' 250 . "\n" 251 ; 252 } 253 else 254 { 255 echo '<li><a href="module.php?module_id='.$moduleId.'&item=LOCAL">' 256 . get_lang('Local settings').'</a></li>' 257 . "\n" 258 ; 259 } 260 } 261 262 if ($item == 'About' || is_null($item)) 263 { 264 echo '<li><a href="module.php?module_id='.$moduleId 265 . '&item=About" class="current">' 266 . get_lang('About').'</a></li>' 267 . "\n" 268 ; 269 } 270 else 271 { 272 echo '<li><a href="module.php?module_id='.$moduleId.'&item=About">' 273 . get_lang('About').'</a></li>' 274 . "\n" 275 ; 276 } 277 278 echo '</ul>'. "\n" 279 . '</div>'. "\n" 280 ; 281 282 283 switch ($item) 284 { 285 case 'GLOBAL': 286 { 287 echo claro_html_tool_title(array('subTitle' => get_lang('Platform Settings'))); 288 289 echo '<form action="' . $_SERVER['PHP_SELF'] . '?module_id=' . $module['module_id'] . '&item='.$item.'" method="POST">'; 290 291 echo '<table>' . "\n"; 292 293 //Activation form 294 if (in_array($module['label'],$undeactivable_tool_array)) 295 { 296 $action_link = get_lang('This module cannot be deactivated'); 297 } 298 elseif ( 'activated' == $module['activation'] ) 299 { 300 $activ_form = 'deactiv'; 301 $action_link = '<a href="' . $_SERVER['PHP_SELF'] 302 . '?cmd='.$activ_form.'&module_id='.$module['module_id'] 303 . '&item=GLOBAL" title="' 304 . get_lang('Activated - Click to deactivate').'">' 305 . '<img src="' . get_path('imgRepositoryWeb') 306 . 'mark.gif" border="0" alt="'. get_lang('Activated') . '" /></a>' 307 ; 308 } 309 else 310 { 311 $activ_form = 'activ'; 312 $action_link = '<a href="' . $_SERVER['PHP_SELF'] 313 . '?cmd='.$activ_form.'&module_id=' 314 . $module['module_id'].'&item=GLOBAL" ' 315 . 'title="'.get_lang('Deactivated - Click to activate').'">' 316 . '<img src="' . get_path('imgRepositoryWeb') 317 . 'block.gif" border="0" alt="'. get_lang('Deactivated') . '"/></a>'; 318 } 319 320 echo '<td align="right" valign="top">' 321 . get_lang('Activation') 322 . ' : ' . "\n" 323 . '</td>' . "\n" 324 . '<td>' . "\n" 325 . $action_link . "\n" 326 . '</td>' . "\n" 327 . '</tr>' . "\n" 328 . '<tr>' . "\n" 329 . '<td colspan="2"> </td>' . "\n" 330 . '</tr>' . "\n" 331 ; 332 333 if ($module['type'] == 'tool') 334 { 335 echo '<tr><td>' 336 . get_lang( 'Visibility' ) 337 . ' : ' 338 . '</td>' . "\n" 339 . '<td>' . "\n" 340 . '<small><a href="' 341 . $_SERVER['PHP_SELF'] . '?module_id=' . $module['module_id'].'&cmd=makeVisible&item=GLOBAL"' 342 . 'title="'.get_lang( 'Make module visible in all courses' ).'"' 343 . ' onclick="return confirmMakeVisible();">' 344 . '<img src="' . get_path('imgRepositoryWeb') 345 . 'visible.gif" border="0" alt="'. get_lang('Visible') . '"/> ' 346 . get_lang( 'Make visible' ) 347 . '</a></small>' 348 . " | " 349 . '<small><a href="' 350 . $_SERVER['PHP_SELF'] . '?module_id=' . $module['module_id'].'&cmd=makeInvisible&item=GLOBAL"' 351 . 'title="'.get_lang( 'Make module invisible in all courses' ).'"' 352 . ' onclick="return confirmMakeInVisible();">' 353 . '<img src="' . get_path('imgRepositoryWeb') 354 . 'invisible.gif" border="0" alt="'. get_lang('Invisible') . '"/> ' 355 . get_lang( 'Make invisible' ) 356 . '</a></small>' 357 . '<td><tr>' . "\n" 358 ; 359 } 360 elseif ($module['type'] == 'applet') 361 { 362 //choose the dock radio button list display 363 if ( is_array($dockList) && $module['type']!='tool') 364 { 365 echo '<tr>' ."\n" 366 . '<td syle="align:right" colspan="2">' . get_lang('Display'). ' :</td>' ."\n" 367 . '</tr>' ."\n" 368 ; 369 370 $i = 1; 371 372 //display each option 373 foreach ($dockList as $dockId => $dockName) 374 { 375 if (in_array($dockId,$dock_checked)) $is_checked = 'checked="checked"'; else $is_checked = ""; 376 377 echo '<tr>' ."\n" 378 . '<td> </td>' ."\n" 379 . '<td>' ."\n" 380 . '<input type="checkbox" name="displayDockList[]" value="' . $dockId . '" id="displayDock_' . $i . '" ' . $is_checked . ' />' 381 . '<label for="displayDock_' . $i . '">' . $dockName . '</label>' 382 . '</td>' ."\n" 383 . '</tr>' ."\n" 384 ; 385 386 $i++; 387 } 388 } 389 390 // display submit button 391 echo '<tr><td colspan="2"> </td></tr>' . "\n" 392 . '<tr>' ."\n" 393 . '<td style="text-align:right">' . get_lang('Save') . ' :</td>' . "\n" 394 . '<td >' 395 . '<input type="hidden" name="cmd" value="movedock" />'. "\n" 396 . '<input type="submit" value="' . get_lang('Ok') . '" /> '. "\n" 397 . claro_html_button($_SERVER['HTTP_REFERER'], get_lang('Cancel')) . '</td>' . "\n" 398 . '</tr>' . "\n" 399 . '</form>' 400 ; 401 } 402 else // not a tool, not an applet 403 { 404 // nothing to do at the moment 405 } 406 407 echo '</table>' . "\n" 408 . '</td>' . "\n" 409 . '</tr>' . "\n" 410 . '</table>' . "\n" 411 ; 412 break; 413 } 414 case 'LOCAL': 415 { 416 $form = ''; 417 418 $url_params = '&module_id='. $moduleId .'&item='. htmlspecialchars($item); 419 420 $form = $config->display_section_menu($section_selected,$url_params); 421 422 // init config name 423 $config_name = $config->config_code; 424 425 if ( isset($_REQUEST['cmd']) && isset($_REQUEST['property']) ) 426 { 427 if ( 'save' == $_REQUEST['cmd'] ) 428 { 429 if ( ! empty($_REQUEST['property']) ) 430 { 431 list($message, $error) = generate_conf($config,$_REQUEST['property']); 432 } 433 } 434 // display form 435 $form .= $config->display_form($_REQUEST['property'],$section_selected,$url_params); 436 } 437 else 438 { 439 // display form 440 $form .= $config->display_form(null,$section_selected,$url_params); 441 } 442 443 echo '<div style=padding-left:1em;padding-right:1em;>'; 444 445 if ( ! empty($message) ) 446 { 447 echo claro_html_message_box($message); 448 } 449 450 echo $form.'</div>'; 451 452 break; 453 } 454 default: 455 { 456 $moduleDescription = trim( $module['description'] ); 457 458 $moduleDescription = (empty( $moduleDescription ) ) 459 ? get_lang('No description given') 460 : $moduleDescription 461 ; 462 463 echo claro_html_tool_title(array('subTitle' => get_lang('Description'))) 464 . '<p>' 465 . htmlspecialchars( $moduleDescription ) 466 . '</p>' . "\n" 467 ; 468 469 echo claro_html_tool_title(array('subTitle' => get_lang('General Informations'))) . "\n" 470 . '<table>' . "\n" 471 . '<tr>' . "\n" 472 . '<td colspan="2">' . "\n" 473 . '</td>' . "\n" 474 . '</tr>' . "\n" 475 . '<tr>' . "\n" 476 . '<td align="right">' 477 . get_lang('Icon') 478 . ' : </td>' . "\n" 479 . '<td>' . "\n" 480 . $icon . "\n" 481 . '</td>' . "\n" 482 . '</tr>' . "\n" 483 . '<tr>' . "\n" 484 . '<td align="right">' . get_lang('Module name') . ' : </td>' . "\n" 485 . '<td >' . $module['module_name'] . '</td>' . "\n" 486 . '</tr>' . "\n" 487 . '<tr>' . "\n" 488 . '<td align="right">' . get_lang('Type') . ' : </td>' . "\n" 489 . '<td>' . $module['type'] . '</td>' . "\n" 490 . '</tr>' . "\n" 491 . '<tr>' . "\n" 492 . '<td align="right">' . get_lang('Version') . ' : </td>' . "\n" 493 . '<td >' . $module['version'] . '</td>' . "\n" 494 . '</tr>' . "\n" 495 . '<tr>' . "\n" 496 . '<td align="right">' . get_lang('License') . ' : </td>' . "\n" 497 . '<td >General Public License</td>' . "\n" 498 . '</tr>' . "\n" 499 . '<tr>' . "\n" 500 . '<td align="right">' . get_lang('Author') . ' : </td>' . "\n" 501 . '<td >' . $module['author'] . '</td>' . "\n" 502 . '</tr>' . "\n" 503 . '<tr>' . "\n" 504 . '<td align="right">' . get_lang('Contact') . ' : </td>' . "\n" 505 . '<td >' . $module['author_email'] . '</td>' . "\n" 506 . '</tr>' . "\n" 507 . '<tr>' . "\n" 508 . '<td align="right">' . get_lang('Website') . ' : </td>' . "\n" 509 . '<td><a href="' . $module['website'] . '">' . $module['website'] . '</a></td>' . "\n" 510 . '</tr>' . "\n" 511 . '</table>' . "\n" 512 . '</td>' . "\n" 513 . '<td>' . "\n" 514 . '<table>' . "\n" 515 ; 516 } 517 } 518 519 echo '</table>' . "\n" 520 . '</td>' . "\n" 521 . '</tr>' . "\n" 522 . '</table>' . "\n" 523 ; 524 525 include get_path('incRepositorySys') . '/claro_init_footer.inc.php'; 526 527 ?>
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 |
![]() |