public function get_avatar(array $args) { $ar = array('login' => $args['username'], 'authtype' => midgardmvc_core::get_instance()->configuration->services_authentication_authtype); try { $user = new midgard_user($ar); } catch (Exception $e) { //User does not exist, send 404. throw new midgardmvc_exception_notfound("Avatar not found"); } if ($user) { $attachments = $user->get_person()->list_attachments(); //Check if attachement exists if (count($attachments) == 0) { //fetch avatar from meego.com $employeenumber = $user->get_person()->get_parameter('midgardmvc_core_services_authentication_ldap', 'employeenumber'); $file = 'http://meego.com/sites/all/files/imagecache/user_pics/user_pics/picture-' . $employeenumber . '.png'; $opts = array(); if ($this->proxy) { $opts = array('http' => array('proxy' => $this->proxy, 'request_fulluri' => true)); } $context = stream_context_create($opts); $src = fopen($file, 'rb', false, $context); if ($src) { $attachment = $user->get_person()->create_attachment('meego:avatar', 'meego:avatar', 'image/png'); //Does not work through proxy as is. $this->copy_file_to_attachment($src, $attachment, $context); $attachments[0] = $attachment; } } if (count($attachments) > 0) { //serve attachment $this->serve_attachment($attachments[0]); } } //redirect to default avatar midgardmvc_core::get_instance()->head->relocate('http://meego.com/sites/all/themes/meego/images/user_picture_blank.png'); }
private function check_existing($memberid) { $tokens = array('login' => $memberid, 'authtype' => 'OpenID', 'active' => true, 'password' => ''); try { $user = new midgard_user($tokens); if ($user) { $person = $user->get_person(); if ($person) { return new fi_openkeidas_registration_user($person->guid); } } } catch (midgard_error_exception $e) { } return new fi_openkeidas_registration_user(); }
private function _load_person($username) { if (!$this->user) { debug_add("Failed to authenticate the given user: " . midcom_connection::get_error_string(), MIDCOM_LOG_INFO); return false; } $this->person = $this->user->get_person(); $person_class = new $GLOBALS['midcom_config']['person_class'](); if (get_class($this->person) != $person_class) { // Cast the person object to correct person class $this->person = new $person_class($this->person->guid); $this->person->username = $username; } return true; }