[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/ -> auth.php (source)

   1  <?php
   2  
   3  /**
   4   * Allows admin to edit all auth plugin settings.
   5   *
   6   * JH: copied and Hax0rd from admin/enrol.php and admin/filters.php
   7   *
   8   */
   9  
  10  require_once('../config.php');
  11  require_once($CFG->libdir.'/adminlib.php');
  12  require_once($CFG->libdir.'/tablelib.php');
  13  
  14  require_login();
  15  require_capability('moodle/site:config', context_system::instance());
  16  
  17  $returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
  18  
  19  $PAGE->set_url($returnurl);
  20  
  21  $action = optional_param('action', '', PARAM_ALPHANUMEXT);
  22  $auth   = optional_param('auth', '', PARAM_PLUGIN);
  23  
  24  get_enabled_auth_plugins(true); // fix the list of enabled auths
  25  if (empty($CFG->auth)) {
  26      $authsenabled = array();
  27  } else {
  28      $authsenabled = explode(',', $CFG->auth);
  29  }
  30  
  31  if (!empty($auth) and !exists_auth_plugin($auth)) {
  32      print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
  33  }
  34  
  35  ////////////////////////////////////////////////////////////////////////////////
  36  // process actions
  37  
  38  if (!confirm_sesskey()) {
  39      redirect($returnurl);
  40  }
  41  
  42  switch ($action) {
  43      case 'disable':
  44          // remove from enabled list
  45          $key = array_search($auth, $authsenabled);
  46          if ($key !== false) {
  47              unset($authsenabled[$key]);
  48              set_config('auth', implode(',', $authsenabled));
  49          }
  50  
  51          if ($auth == $CFG->registerauth) {
  52              set_config('registerauth', '');
  53          }
  54          \core\session\manager::gc(); // Remove stale sessions.
  55          core_plugin_manager::reset_caches();
  56          break;
  57  
  58      case 'enable':
  59          // add to enabled list
  60          if (!in_array($auth, $authsenabled)) {
  61              $authsenabled[] = $auth;
  62              $authsenabled = array_unique($authsenabled);
  63              set_config('auth', implode(',', $authsenabled));
  64          }
  65          \core\session\manager::gc(); // Remove stale sessions.
  66          core_plugin_manager::reset_caches();
  67          break;
  68  
  69      case 'down':
  70          $key = array_search($auth, $authsenabled);
  71          // check auth plugin is valid
  72          if ($key === false) {
  73              print_error('pluginnotenabled', 'auth', $returnurl, $auth);
  74          }
  75          // move down the list
  76          if ($key < (count($authsenabled) - 1)) {
  77              $fsave = $authsenabled[$key];
  78              $authsenabled[$key] = $authsenabled[$key + 1];
  79              $authsenabled[$key + 1] = $fsave;
  80              set_config('auth', implode(',', $authsenabled));
  81          }
  82          break;
  83  
  84      case 'up':
  85          $key = array_search($auth, $authsenabled);
  86          // check auth is valid
  87          if ($key === false) {
  88              print_error('pluginnotenabled', 'auth', $returnurl, $auth);
  89          }
  90          // move up the list
  91          if ($key >= 1) {
  92              $fsave = $authsenabled[$key];
  93              $authsenabled[$key] = $authsenabled[$key - 1];
  94              $authsenabled[$key - 1] = $fsave;
  95              set_config('auth', implode(',', $authsenabled));
  96          }
  97          break;
  98  
  99      default:
 100          break;
 101  }
 102  
 103  redirect($returnurl);
 104  
 105  


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1