bos =& $Dippler->backoffice; if ($identifier) { $this->id = $identifier; } } public function setUserId($user_id) { $this->user_id = $user_id; } public function save() { return $this->bos->saveProfile($this->dataXML()); } public function load() { $loader = $this->bos->loadProfile($this->idXML()); if ($loader) { $this->type = "profile"; $this->id = $loader->id[0][0]; $this->firstname = $loader->firstname[0][0]; $this->lastname = $loader->lastname[0][0]; $this->email = $loader->email[0][0]; $this->user_id = $loader->user_id[0][0]; if (isset($loader->description[0][0])) { $this->description = $loader->description[0][0]; } if (isset($loader->homepage[0][0])) { $this->homepage = $loader->homepage[0][0]; } if (isset($loader->twitter[0][0])) { $this->twitter = $loader->twitter[0][0]; } if (isset($loader->delicious[0][0])) { $this->delicious = $loader->delicious[0][0]; } if (isset($loader->mendeley[0][0])) { $this->mendeley = $loader->mendeley[0][0]; } if (isset($loader->skype[0][0])) { $this->skype = $loader->skype[0][0]; } if (isset($loader->msn[0][0])) { $this->msn = $loader->msn[0][0]; } if (isset($loader->blogurl[0][0])) { $this->blogurl = $loader->blogurl[0][0]; } if (isset($loader->department[0][0])) { $this->department = $loader->department[0][0]; } if (isset($loader->curriculum[0][0]) && ($loader->curriculum[0][0] != 'null')) { $this->curriculum = $loader->curriculum[0][0]; } if (isset($loader->university[0][0]) && ($loader->university[0][0] != 'null')) { $this->university = $loader->university[0][0]; } if (isset($loader->institute[0][0]) && ($loader->institute[0][0] != 'null')) { $this->institute = $loader->institute[0][0]; } if (isset($loader->approved[0][0])) { $this->approved = $loader->approved[0][0]; } } } public function getURL() { $user = $this->getOwnerEntity(); return WWW_ROOT."profile/view/{$user->id}"; } public function getAvatarURL($size=54) { $default = WWW_ROOT."views/graphics/user.png"; return "http://www.gravatar.com/avatar/".md5(strtolower(trim($this->email)))."?d=".urlencode($default)."&s={$size}"; } public function getType() { return $this->type; } public function getOwner() { return $this->user_id; } public function getOwnerEntity() { if (!isset($this->owner_entity)) { $user = new User($this->user_id); $user->load(); $this->owner_entity = $user; return $user; } return $this->owner_entity; } public function canEdit() { global $Dippler; if (is_logged_in()) { if ($Dippler->is_admin()) { return 1; } if (get_logged_in_user_id() == $this->getOwner()) { if ($Dippler->is_learner()) { return 1; } } } return 0; } /** * Checks if profile can be viewed. * Only administrator can see profiles for unapproved users. * * @return bool */ public function canView() { global $Dippler; if ($Dippler->is_admin()) { return true; } if ($this->isApproved()) { return true; } return false; } /** * Checks if user is approved. * * @return bool */ public function isApproved() { if ($this->approved == 'true') { return true; } return false; } /** * Checks if unapprove button should be shown. * * @return bool */ public function isUnapproveShown() { global $Dippler; if ($Dippler->is_logged_in() && $Dippler->is_admin()) { return true; } return false; } /** * Checks if delete button is shown. * * @return bool */ public function isDeleteShown() { global $Dippler; if ($Dippler->is_logged_in() && $Dippler->is_admin()) { return true; } return false; } public function getFirstname() { return $this->firstname; } public function getLastname() { return $this->lastname; } public function getFullname() { return $this->firstname." ".$this->lastname; } public function getEmail() { return $this->email; } private function _isURL(&$url) { if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { return true; } return false; } public function getTwitterURL() { if (!empty($this->twitter)) { if ($this->_isURL($this->twitter)) { return $this->twitter; } return "http://twitter.com/{$this->twitter}"; } return ""; } public function getDeliciousURL() { if (!empty($this->delicious)) { if ($this->_isURL($this->delicious)) { return $this->delicious; } return "http://www.delicious.com/{$this->delicious}"; } return ""; } public function getMendeleyURL() { if (!empty($this->mendeley)) { if ($this->_isURL($this->mendeley)) { return $this->mendeley; } return "http://www.mendeley.com/profiles/{$this->mendeley}"; } return ""; } function idXML() { $data = ""; $data .= ""; if ($this->id) { $data .= "{$this->id}"; } else { $data .= "{$this->user_id}"; } $data .= ""; return $data; } function dataXML() { $data = ""; $data .= ""; $data .= "{$this->id}"; $data .= "{$this->user_id}"; $data .= "firstname}]]>"; $data .= "lastname}]]>"; $data .= "description}]]>"; $data .= "homepage}]]>"; $data .= "twitter}]]>"; $data .= "delicious}]]>"; $data .= "mendeley}]]>"; $data .= "skype}]]>"; $data .= "msn}]]>"; $data .= "curriculum}]]>"; $data .= "university}]]>"; $data .= "institute}]]>"; $data .= "blogurl}]]>"; $data .= "department}]]>"; $data .= ""; return $data; } function getProviders() { global $Dippler; return $Dippler->getProviders(); } } ?>