Exemplo n.º 1
0
 public function generate_data()
 {
     if (is_null($this->get('username')) || $this->get('username') == '') {
         echo "You must enter a valid username for a moodle administrator account on this site.{$this->eolchar}";
         die;
     } elseif (is_null($this->get('password')) || $this->get('password') == '') {
         echo "You must enter a valid password for a moodle administrator account on this site.{$this->eolchar}";
         die;
     } else {
         if (!($user = authenticate_user_login($this->get('username'), $this->get('password')))) {
             echo "Invalid username or password!{$this->eolchar}";
             die;
         }
         complete_user_login($user);
         $systemcontext = get_context_instance(CONTEXT_SYSTEM);
         if (!is_siteadmin($user->id)) {
             //TODO: add some proper access control check here!!
             echo "You do not have administration privileges on this Moodle site. " . "These are required for running the generation script.{$this->eolchar}";
             die;
         }
     }
     parent::generate_data();
 }