/**
  * Return hub information
  * @return hub
  */
 public static function get_info()
 {
     // Ensure the current user is allowed to run this function
     $context = context_system::instance();
     self::validate_context($context);
     //viewinfo: hub directory
     //viewsmallinfo: registered site
     if (!has_capability('local/hub:viewinfo', $context) and !has_capability('local/hub:viewsmallinfo', $context)) {
         throw new moodle_exception('nocapabalitytogetinfo', 'local_hub');
     }
     //not useful to validate no params, but following line just here to remind u ;)
     self::validate_parameters(self::get_info_parameters(), array());
     $hub = new local_hub();
     $hubinfo = $hub->get_info();
     $resultinfo = array();
     $resultinfo['name'] = $hubinfo['name'];
     $resultinfo['description'] = clean_param($hubinfo['description'], PARAM_TEXT);
     $resultinfo['hublogo'] = $hubinfo['hublogo'];
     $resultinfo['url'] = $hubinfo['url'];
     $resultinfo['language'] = $hubinfo['language'];
     $resultinfo['sites'] = $hubinfo['sites'];
     $resultinfo['courses'] = $hubinfo['courses'];
     $resultinfo['enrollablecourses'] = $hubinfo['enrollablecourses'];
     $resultinfo['downloadablecourses'] = $hubinfo['downloadablecourses'];
     if (has_capability('local/hub:viewinfo', $context)) {
         $resultinfo['contactname'] = $hubinfo['contactname'];
         $resultinfo['contactemail'] = $hubinfo['contactemail'];
         $resultinfo['privacy'] = $hubinfo['privacy'];
     }
     return $resultinfo;
 }
Beispiel #2
0
            //delete the communication
            $hub->delete_communication($directorytohubcommunication);
        }
        if (!empty($hubtodirectorycommunication)) {
            $hub->delete_communication($hubtodirectorycommunication);
        }
    }
    redirect(new moodle_url('/local/hub/admin/register.php', array('sesskey' => sesskey(), 'error' => $error)));
}
/////// UPDATE ACTION ////////
// update the hub registration (in fact it is a new registration)
$update = optional_param('update', 0, PARAM_INT);
if ($update && confirm_sesskey()) {
    //update the registration
    $function = 'hubdirectory_update_hub_info';
    $hubinfo = $hub->get_info();
    $hubinfo['name'] = clean_param($hubinfo['name'], PARAM_TEXT);
    $hubinfo['description'] = clean_param($hubinfo['description'], PARAM_TEXT);
    $hubinfo['contactname'] = clean_param($hubinfo['contactname'], PARAM_TEXT);
    $params = array('hubinfo' => $hubinfo);
    $serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php";
    require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php";
    $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hubtodirectorycommunication->token);
    try {
        $result = $xmlrpcclient->call($function, $params);
    } catch (Exception $e) {
        $error = get_string('errorregistration', 'local_hub', $e->getMessage());
    }
}
/////// FORM REGISTRATION ACTION //////
// retrieve the privacy setting
Beispiel #3
0
 public function definition()
 {
     global $CFG, $DB, $SITE;
     $hub = new local_hub();
     $mform =& $this->_form;
     $mform->addElement('header', 'moodle', get_string('hubdetails', 'local_hub'));
     $hubname = get_config('local_hub', 'name');
     $hubdescription = get_config('local_hub', 'description');
     $contactname = get_config('local_hub', 'contactname');
     $contactemail = get_config('local_hub', 'contactemail');
     $hublogo = get_config('local_hub', 'hublogo');
     $privacy = get_config('local_hub', 'privacy');
     $hublanguage = get_config('local_hub', 'language');
     if (empty($hubname) or empty($privacy) or empty($hubdescription)) {
         $mform->addElement('static', 'missinghubsetup', '', get_string('settingsinvalid', 'local_hub'));
         return;
     }
     $mform->addElement('static', 'comment', '', get_string('hubregistrationcomment', 'local_hub'));
     $mform->addElement('hidden', 'url', $CFG->wwwroot);
     $mform->setType('url', PARAM_URL);
     $languages = get_string_manager()->get_list_of_languages();
     $mform->addElement('static', 'hubnamestring', get_string('name', 'local_hub'), $hubname);
     $mform->addElement('hidden', 'name', $hubname);
     $mform->setType('name', PARAM_TEXT);
     $mform->addElement('static', 'hubprivacystring', get_string('privacy', 'local_hub'), $hub->get_privacy_string($privacy));
     $mform->addElement('hidden', 'privacy', $privacy);
     $mform->setType('privacy', PARAM_ALPHA);
     // A string like 'public' or 'private'.
     $mform->addElement('static', 'languagestring', get_string('language'), $languages[$hublanguage]);
     $mform->addElement('hidden', 'language', $hublanguage);
     $mform->setType('language', PARAM_LANG);
     $mform->addElement('static', 'hubdescriptionstring', get_string('description', 'local_hub'), format_text($hubdescription));
     $mform->addElement('hidden', 'description', $hubdescription);
     $mform->setType('description', PARAM_TEXT);
     $mform->addElement('static', 'contactnamestring', get_string('contactname', 'local_hub'), $contactname);
     $mform->addElement('hidden', 'contactname', $contactname);
     $mform->setType('contactname', PARAM_TEXT);
     $mform->addElement('static', 'contactemailstring', get_string('contactemail', 'local_hub'), $contactemail);
     $mform->addElement('hidden', 'contactemail', $contactemail);
     $mform->setType('contactemail', PARAM_EMAIL);
     if (!empty($hublogo)) {
         $params = array('filetype' => HUB_HUBSCREENSHOT_FILE_TYPE, 'time' => time());
         $imageurl = new moodle_url($CFG->wwwroot . "/local/hub/webservice/download.php", $params);
         $imagetag = html_writer::empty_tag('img', array('src' => $imageurl, 'alt' => $hubname));
         $mform->addElement('static', 'logourlstring', get_string('image', 'local_hub'), $imagetag);
     } else {
         $hublogo = 0;
     }
     $mform->addElement('hidden', 'hublogo', $hublogo);
     $mform->setType('hublogo', PARAM_INT);
     $mform->addElement('static', 'urlstring', get_string('url', 'local_hub'), $CFG->wwwroot);
     $hubinfo = $hub->get_info();
     $mform->addElement('static', 'sitesstring', get_string('registeredsites', 'local_hub'), $hubinfo['sites']);
     $mform->addElement('hidden', 'sites', $hubinfo['sites']);
     $mform->setType('sites', PARAM_INT);
     $mform->addElement('static', 'coursesstring', get_string('registeredcourses', 'local_hub'), $hubinfo['courses']);
     $mform->addElement('hidden', 'courses', $hubinfo['courses']);
     $mform->setType('courses', PARAM_INT);
     $mform->addElement('static', 'enrollablecoursesstring', get_string('enrollablecourses', 'local_hub'), $hubinfo['enrollablecourses']);
     $mform->addElement('hidden', 'enrollablecourses', $hubinfo['enrollablecourses']);
     $mform->setType('enrollablecourses', PARAM_INT);
     $mform->addElement('static', 'downloadablecoursesstring', get_string('downloadablecourses', 'local_hub'), $hubinfo['downloadablecourses']);
     $mform->addElement('hidden', 'downloadablecourses', $hubinfo['downloadablecourses']);
     $mform->setType('downloadablecourses', PARAM_INT);
     //if the hub is private do not display the register button
     if ($privacy != HUBPRIVATE and empty($this->_customdata['alreadyregistered'])) {
         $buttonlabel = get_string('hubregister', 'local_hub');
         $this->add_action_buttons(false, $buttonlabel);
     }
 }