| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: filters.php,v 1.38.4.2 2007/12/25 10:03:17 skodak Exp $ 2 3 require_once ('../config.php'); 4 5 $action = optional_param('action', '', PARAM_ACTION); 6 $filterpath = optional_param('filterpath', '', PARAM_PATH); 7 8 require_login(); 9 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); 10 11 $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters"; 12 13 if (!confirm_sesskey()) { 14 redirect($returnurl); 15 } 16 17 // get a list of installed filters 18 $installedfilters = array(); 19 $filterlocations = array('mod','filter'); 20 foreach ($filterlocations as $filterlocation) { 21 $plugins = get_list_of_plugins($filterlocation); 22 foreach ($plugins as $plugin) { 23 $pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php"; 24 if (is_readable($pluginpath)) { 25 $installedfilters["$filterlocation/$plugin"] = "$filterlocation/$plugin"; 26 } 27 } 28 } 29 30 // get all the currently selected filters 31 if (!empty($CFG->textfilters)) { 32 $activefilters = explode(',', $CFG->textfilters); 33 } else { 34 $activefilters = array(); 35 } 36 37 //====================== 38 // Process Actions 39 //====================== 40 41 switch ($action) { 42 43 case 'hide': 44 $key=array_search($filterpath, $activefilters); 45 // check filterpath is valid 46 if ($key===false) { 47 break; 48 } 49 // just delete it 50 unset($activefilters[$key]); 51 break; 52 53 case 'show': 54 // check filterpath is valid 55 if (!array_key_exists($filterpath, $installedfilters)) { 56 error("Filter $filterpath is not currently installed", $url); 57 } elseif (array_search($filterpath,$activefilters)) { 58 // filterpath is already active - doubleclick?? 59 } else { 60 // add it to installed filters 61 $activefilters[] = $filterpath; 62 $activefilters = array_unique($activefilters); 63 } 64 break; 65 66 case 'down': 67 $key=array_search($filterpath, $activefilters); 68 // check filterpath is valid 69 if ($key===false) { 70 error("Filter $filterpath is not currently active", $url); 71 } elseif ($key>=(count($activefilters)-1)) { 72 // cannot be moved any further down - doubleclick?? 73 } else { 74 // swap with $key+1 75 $fsave = $activefilters[$key]; 76 $activefilters[$key] = $activefilters[$key+1]; 77 $activefilters[$key+1] = $fsave; 78 } 79 break; 80 81 case 'up': 82 $key=array_search($filterpath, $activefilters); 83 // check filterpath is valid 84 if ($key===false) { 85 error("Filter $filterpath is not currently active", $url); 86 } elseif ($key<1) { 87 //cannot be moved any further up - doubleclick?? 88 } else { 89 // swap with $key-1 90 $fsave = $activefilters[$key]; 91 $activefilters[$key] = $activefilters[$key-1]; 92 $activefilters[$key-1] = $fsave; 93 } 94 break; 95 } 96 97 // save, reset cache and return 98 set_config('textfilters', implode(',', $activefilters)); 99 reset_text_filters_cache(); 100 redirect($returnurl); 101 102 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |