/** * Create a client and set the user. * @param $user array The calling user (optional / current platform user by default). */ public function __construct($user = null) { global $CFG, $USER, $DB; // Calling parent constructor parent::__construct(); // Checking user if (is_null($user)) { // Creating current user if (!($user_mnet_host = $DB->get_record('mnet_host', array('id' => $USER->mnethostid)))) { throw new \local_vmoodle\commands\Command_Exception('unknownuserhost'); } $user = array('username' => $USER->username, 'remoteuserhostroot' => $user_mnet_host->wwwroot, 'remotehostroot' => $CFG->wwwroot); $this->add_param($user, 'array'); } elseif (array_key_exists('username', $user) && array_key_exists('remoteuserhostroot', $user) && array_key_exists('remotehostroot', $user)) { $this->add_param($user, 'array'); } else { throw new \local_vmoodle\commands\Command_Exception('badclientuser'); } }