[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // Allows the admin to manage activity modules 3 4 require_once('../config.php'); 5 require_once ('../course/lib.php'); 6 require_once($CFG->libdir.'/adminlib.php'); 7 require_once($CFG->libdir.'/tablelib.php'); 8 9 // defines 10 define('MODULE_TABLE','module_administration_table'); 11 12 admin_externalpage_setup('managemodules'); 13 14 $show = optional_param('show', '', PARAM_PLUGIN); 15 $hide = optional_param('hide', '', PARAM_PLUGIN); 16 17 18 /// Print headings 19 20 $stractivities = get_string("activities"); 21 $struninstall = get_string('uninstallplugin', 'core_admin'); 22 $strversion = get_string("version"); 23 $strhide = get_string("hide"); 24 $strshow = get_string("show"); 25 $strsettings = get_string("settings"); 26 $stractivities = get_string("activities"); 27 $stractivitymodule = get_string("activitymodule"); 28 $strshowmodulecourse = get_string('showmodulecourse'); 29 30 /// If data submitted, then process and store. 31 32 if (!empty($hide) and confirm_sesskey()) { 33 if (!$module = $DB->get_record("modules", array("name"=>$hide))) { 34 print_error('moduledoesnotexist', 'error'); 35 } 36 $DB->set_field("modules", "visible", "0", array("id"=>$module->id)); // Hide main module 37 // Remember the visibility status in visibleold 38 // and hide... 39 $sql = "UPDATE {course_modules} 40 SET visibleold=visible, visible=0 41 WHERE module=?"; 42 $DB->execute($sql, array($module->id)); 43 // Increment course.cacherev for courses where we just made something invisible. 44 // This will force cache rebuilding on the next request. 45 increment_revision_number('course', 'cacherev', 46 "id IN (SELECT DISTINCT course 47 FROM {course_modules} 48 WHERE visibleold=1 AND module=?)", 49 array($module->id)); 50 core_plugin_manager::reset_caches(); 51 admin_get_root(true, false); // settings not required - only pages 52 } 53 54 if (!empty($show) and confirm_sesskey()) { 55 if (!$module = $DB->get_record("modules", array("name"=>$show))) { 56 print_error('moduledoesnotexist', 'error'); 57 } 58 $DB->set_field("modules", "visible", "1", array("id"=>$module->id)); // Show main module 59 $DB->set_field('course_modules', 'visible', '1', array('visibleold'=>1, 'module'=>$module->id)); // Get the previous saved visible state for the course module. 60 // Increment course.cacherev for courses where we just made something visible. 61 // This will force cache rebuilding on the next request. 62 increment_revision_number('course', 'cacherev', 63 "id IN (SELECT DISTINCT course 64 FROM {course_modules} 65 WHERE visible=1 AND module=?)", 66 array($module->id)); 67 core_plugin_manager::reset_caches(); 68 admin_get_root(true, false); // settings not required - only pages 69 } 70 71 echo $OUTPUT->header(); 72 echo $OUTPUT->heading($stractivities); 73 74 /// Get and sort the existing modules 75 76 if (!$modules = $DB->get_records('modules', array(), 'name ASC')) { 77 print_error('moduledoesnotexist', 'error'); 78 } 79 80 /// Print the table of all modules 81 // construct the flexible table ready to display 82 $table = new flexible_table(MODULE_TABLE); 83 $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'uninstall', 'settings')); 84 $table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strsettings, $struninstall)); 85 $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php'); 86 $table->set_attribute('id', 'modules'); 87 $table->set_attribute('class', 'admintable generaltable'); 88 $table->setup(); 89 90 foreach ($modules as $module) { 91 92 if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) { 93 $strmodulename = '<span class="notifyproblem">'.$module->name.' ('.get_string('missingfromdisk').')</span>'; 94 $missing = true; 95 } else { 96 // took out hspace="\10\", because it does not validate. don't know what to replace with. 97 $icon = "<img src=\"" . $OUTPUT->pix_url('icon', $module->name) . "\" class=\"icon\" alt=\"\" />"; 98 $strmodulename = $icon.' '.get_string('modulename', $module->name); 99 $missing = false; 100 } 101 102 $uninstall = ''; 103 if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('mod_'.$module->name, 'manage')) { 104 $uninstall = html_writer::link($uninstallurl, $struninstall); 105 } 106 107 if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") || 108 file_exists("$CFG->dirroot/mod/$module->name/settingstree.php")) { 109 $settings = "<a href=\"settings.php?section=modsetting$module->name\">$strsettings</a>"; 110 } else { 111 $settings = ""; 112 } 113 114 try { 115 $count = $DB->count_records_select($module->name, "course<>0"); 116 } catch (dml_exception $e) { 117 $count = -1; 118 } 119 if ($count>0) { 120 $countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" . 121 "&sesskey=".sesskey()."\" title=\"$strshowmodulecourse\">$count</a>"; 122 } else if ($count < 0) { 123 $countlink = get_string('error'); 124 } else { 125 $countlink = "$count"; 126 } 127 128 if ($missing) { 129 $visible = ''; 130 $class = ''; 131 } else if ($module->visible) { 132 $visible = "<a href=\"modules.php?hide=$module->name&sesskey=".sesskey()."\" title=\"$strhide\">". 133 "<img src=\"" . $OUTPUT->pix_url('t/hide') . "\" class=\"iconsmall\" alt=\"$strhide\" /></a>"; 134 $class = ''; 135 } else { 136 $visible = "<a href=\"modules.php?show=$module->name&sesskey=".sesskey()."\" title=\"$strshow\">". 137 "<img src=\"" . $OUTPUT->pix_url('t/show') . "\" class=\"iconsmall\" alt=\"$strshow\" /></a>"; 138 $class = 'dimmed_text'; 139 } 140 if ($module->name == "forum") { 141 $uninstall = ""; 142 $visible = ""; 143 $class = ""; 144 } 145 $version = get_config('mod_'.$module->name, 'version'); 146 147 $table->add_data(array( 148 $strmodulename, 149 $countlink, 150 $version, 151 $visible, 152 $settings, 153 $uninstall, 154 ), $class); 155 } 156 157 $table->print_html(); 158 159 echo $OUTPUT->footer(); 160 161
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |