Exemple #1
0
 function write_setting($data)
 {
     global $SESSION;
     unset($SESSION->cal_courses_shown);
     return parent::write_setting($data);
 }
Exemple #2
0
 /**
  * Save the selected setting
  *
  * @param string $data The selected site
  * @return string empty string or error message
  */
 public function write_setting($data)
 {
     global $DB, $CFG;
     //for install cli script, $CFG->defaultuserroleid is not set so do nothing
     if (empty($CFG->defaultuserroleid)) {
         return '';
     }
     $servicename = MOODLE_OFFICIAL_MOBILE_SERVICE;
     require_once $CFG->dirroot . '/webservice/lib.php';
     $webservicemanager = new webservice();
     if ((string) $data === $this->yes) {
         //code run when enable mobile web service
         //enable web service systeme if necessary
         set_config('enablewebservices', true);
         //enable mobile service
         $mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
         $mobileservice->enabled = 1;
         $webservicemanager->update_external_service($mobileservice);
         //enable xml-rpc server
         $activeprotocols = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
         if (!in_array('xmlrpc', $activeprotocols)) {
             $activeprotocols[] = 'xmlrpc';
             set_config('webserviceprotocols', implode(',', $activeprotocols));
         }
         //allow xml-rpc:use capability for authenticated user
         $this->set_xmlrpc_cap(true);
     } else {
         //disable web service system if no other services are enabled
         $otherenabledservices = $DB->get_records_select('external_services', 'enabled = :enabled AND (shortname != :shortname OR shortname IS NULL)', array('enabled' => 1, 'shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
         if (empty($otherenabledservices)) {
             set_config('enablewebservices', false);
             //also disable xml-rpc server
             $activeprotocols = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
             $protocolkey = array_search('xmlrpc', $activeprotocols);
             if ($protocolkey !== false) {
                 unset($activeprotocols[$protocolkey]);
                 set_config('webserviceprotocols', implode(',', $activeprotocols));
             }
             //disallow xml-rpc:use capability for authenticated user
             $this->set_xmlrpc_cap(false);
         }
         //disable the mobile service
         $mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
         $mobileservice->enabled = 0;
         $webservicemanager->update_external_service($mobileservice);
     }
     return parent::write_setting($data);
 }
Exemple #3
0
 /**
  * Saves the new settings passed in $data
  *
  * @param string $data
  * @return mixed string or Array
  */
 public function write_setting($data)
 {
     global $CFG, $DB;
     $oldvalue = $this->config_read($this->name);
     $return = parent::write_setting($data);
     $newvalue = $this->config_read($this->name);
     if ($oldvalue !== $newvalue) {
         // force full regrading
         $DB->set_field('grade_items', 'needsupdate', 1, array('needsupdate' => 0));
     }
     return $return;
 }