[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

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', get_context_instance(CONTEXT_SYSTEM));
  16  
  17  $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
  18  
  19  $action = optional_param('action', '', PARAM_ACTION);
  20  $auth   = optional_param('auth', '', PARAM_SAFEDIR);
  21  
  22  // get currently installed and enabled auth plugins
  23  $authsavailable = get_list_of_plugins('auth');
  24  
  25  get_enabled_auth_plugins(true); // fix the list of enabled auths
  26  if (empty($CFG->auth)) {
  27      $authsenabled = array();
  28  } else {
  29      $authsenabled = explode(',', $CFG->auth);
  30  }
  31  
  32  if (!empty($auth) and !exists_auth_plugin($auth)) {
  33      print_error('pluginnotinstalled', 'auth', $url, $auth);
  34  }
  35  
  36  ////////////////////////////////////////////////////////////////////////////////
  37  // process actions
  38  
  39  if (!confirm_sesskey()) {
  40      redirect($returnurl);
  41  }
  42  
  43  switch ($action) {
  44      case 'disable':
  45          // remove from enabled list
  46          $key = array_search($auth, $authsenabled);
  47          if ($key !== false) {
  48              unset($authsenabled[$key]);
  49              set_config('auth', implode(',', $authsenabled));
  50          }
  51  
  52          if ($auth == $CFG->registerauth) {
  53              set_config('registerauth', '');
  54          }
  55          break;
  56  
  57      case 'enable':
  58          // add to enabled list
  59          if (!in_array($auth, $authsenabled)) {
  60              $authsenabled[] = $auth;
  61              $authsenabled = array_unique($authsenabled);
  62              set_config('auth', implode(',', $authsenabled));
  63          }
  64          break;
  65  
  66      case 'down':
  67          $key = array_search($auth, $authsenabled);
  68          // check auth plugin is valid
  69          if ($key === false) {
  70              print_error('pluginnotenabled', 'auth', $url, $auth);
  71          }
  72          // move down the list
  73          if ($key < (count($authsenabled) - 1)) {
  74              $fsave = $authsenabled[$key];
  75              $authsenabled[$key] = $authsenabled[$key + 1];
  76              $authsenabled[$key + 1] = $fsave;
  77              set_config('auth', implode(',', $authsenabled));
  78          }
  79          break;
  80  
  81      case 'up':
  82          $key = array_search($auth, $authsenabled);
  83          // check auth is valid
  84          if ($key === false) {
  85              print_error('pluginnotenabled', 'auth', $url, $auth);
  86          }
  87          // move up the list
  88          if ($key >= 1) {
  89              $fsave = $authsenabled[$key];
  90              $authsenabled[$key] = $authsenabled[$key - 1];
  91              $authsenabled[$key - 1] = $fsave;
  92              set_config('auth', implode(',', $authsenabled));
  93          }
  94          break;
  95  
  96      default:
  97          break;
  98  }
  99  
 100  redirect ($returnurl);
 101  
 102  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7