ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPublicUserProfileGUI Class Reference

GUI class for public user profile presentation. More...

+ Collaboration diagram for ilPublicUserProfileGUI:

Public Member Functions

 __construct ($a_user_id=0)
 Constructor.
 setUserId ($a_userid)
 Set User ID.
 getUserId ()
 Get User ID.
 setAsRows ($a_asrows)
 Set Output as Table Rows.
 getAsRows ()
 Get Output as Table Rows.
 setAdditional ($a_additional)
 Set Additonal Information.
 getAdditional ()
 Get Additonal Information.
 setBackUrl ($a_backurl)
 Set Back Link URL.
 getBackUrl ()
 Get Back Link URL.
 executeCommand ()
 Execute Command.
 getHTML ($a_preview=false)
 get public profile html code
 deliverVCard ()
 Deliver vcard information.
 view ()
 View.
 showUserPage ()
 Show user page.
 setTabs ($a_active)
 Set tabs.

Detailed Description

GUI class for public user profile presentation.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

ilPublicUserProfileGUI: ilExtPublicProfilePageGUI

Definition at line 14 of file class.ilPublicUserProfileGUI.php.

Constructor & Destructor Documentation

ilPublicUserProfileGUI::__construct (   $a_user_id = 0)

Constructor.

Parameters
intUser ID.

Definition at line 21 of file class.ilPublicUserProfileGUI.php.

References $_GET, $ilCtrl, $lng, setBackUrl(), and setUserId().

{
global $ilCtrl, $lng, $ilTabs;
$lng->loadLanguageModule("user");
$this->setUserId($a_user_id);
$ilCtrl->saveParameter($this, array("user_id","back_url", "user"));
if ($_GET["back_url"] != "")
{
$this->setBackUrl($_GET["back_url"]);
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilPublicUserProfileGUI::deliverVCard ( )

Deliver vcard information.

Definition at line 452 of file class.ilPublicUserProfileGUI.php.

References $type, ilObject\_exists(), ilUtil\deliverData(), ilObjMediaObject\getMimeType(), getUserId(), ilUtil\getWebspaceDir(), TEL_TYPE_CELL, TEL_TYPE_FAX, TEL_TYPE_HOME, and TEL_TYPE_WORK.

{
// get user object
if (!ilObject::_exists($this->getUserId()))
{
return "";
}
$user = new ilObjUser($this->getUserId());
require_once "./Services/User/classes/class.ilvCard.php";
$vcard = new ilvCard();
if ($user->getPref("public_profile") != "y" &&
$user->getPref("public_profile") != "g")
{
return;
}
$vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
$vcard->setNickname($user->getLogin());
$webspace_dir = ilUtil::getWebspaceDir("output");
$imagefile = $webspace_dir."/usr_images/".$user->getPref("profile_image");
if ($user->getPref("public_upload")=="y" && @is_file($imagefile))
{
$fh = fopen($imagefile, "r");
if ($fh)
{
$image = fread($fh, filesize($imagefile));
fclose($fh);
require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mimetype = ilObjMediaObject::getMimeType($imagefile);
if (preg_match("/^image/", $mimetype))
{
$type = $mimetype;
}
$vcard->setPhoto($image, $type);
}
}
$val_arr = array("getInstitution" => "institution", "getDepartment" => "department",
"getStreet" => "street",
"getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country",
"getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
"getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
"getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
$org = array();
$adr = array();
foreach ($val_arr as $key => $value)
{
// if value "y" show information
if ($user->getPref("public_".$value) == "y")
{
switch ($value)
{
case "institution":
$org[0] = $user->$key();
break;
case "department":
$org[1] = $user->$key();
break;
case "street":
$adr[2] = $user->$key();
break;
case "zipcode":
$adr[5] = $user->$key();
break;
case "city":
$adr[3] = $user->$key();
break;
case "country":
$adr[6] = $user->$key();
break;
case "phone_office":
$vcard->setPhone($user->$key(), TEL_TYPE_WORK);
break;
case "phone_home":
$vcard->setPhone($user->$key(), TEL_TYPE_HOME);
break;
case "phone_mobile":
$vcard->setPhone($user->$key(), TEL_TYPE_CELL);
break;
case "fax":
$vcard->setPhone($user->$key(), TEL_TYPE_FAX);
break;
case "email":
$vcard->setEmail($user->$key());
break;
case "hobby":
$vcard->setNote($user->$key());
break;
}
}
}
if (count($org))
{
$vcard->setOrganization(join(";", $org));
}
if (count($adr))
{
$vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
}
ilUtil::deliverData(utf8_decode($vcard->buildVCard()), $vcard->getFilename(), $vcard->getMimetype());
}

+ Here is the call graph for this function:

ilPublicUserProfileGUI::executeCommand ( )

Execute Command.

Definition at line 119 of file class.ilPublicUserProfileGUI.php.

References $_GET, $cmd, $ilCtrl, $ret, $tpl, ilObject\_lookupType(), and setUserId().

{
global $ilCtrl, $tpl, $ilUser;
if ($_GET["baseClass"] != "ilPublicUserProfileGUI")
{
$cmd = $ilCtrl->getCmd();
$ret = $this->$cmd();
return $ret;
}
else
{
$user_id = (int) $_GET["user_id"];
$this->setUserId($user_id);
if (ilObject::_lookupType($user_id) != "usr")
{
return;
}
$user = new ilObjUser($user_id);
if ($ilUser->getId() == ANONYMOUS_USER_ID && $user->getPref("public_profile") != "g")
{
return;
}
$cmd = $ilCtrl->getCmd();
$ret = $this->$cmd();
$tpl->getStandardTemplate();
$tpl->setContent($ret);
$tpl->show();
}
}

+ Here is the call graph for this function:

ilPublicUserProfileGUI::getAdditional ( )

Get Additonal Information.

Returns
array Additonal Information

Definition at line 89 of file class.ilPublicUserProfileGUI.php.

References $additional.

Referenced by getHTML().

{
}

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::getAsRows ( )

Get Output as Table Rows.

Returns
boolean Output as Table Rows

Definition at line 69 of file class.ilPublicUserProfileGUI.php.

Referenced by getHTML().

{
return $this->asrows;
}

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::getBackUrl ( )

Get Back Link URL.

Returns
string Back Link URL

Definition at line 111 of file class.ilPublicUserProfileGUI.php.

Referenced by getHTML(), and setTabs().

{
return $this->backurl;
}

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::getHTML (   $a_preview = false)

get public profile html code

Parameters
boolean$no_ctrlworkaround for old insert public profile implementation

Definition at line 158 of file class.ilPublicUserProfileGUI.php.

References $additional, $ilCtrl, $ilSetting, $lng, $tpl, ilObject\_exists(), ilUserDefinedFields\_getInstance(), ilMailFormCall\_getLinkTarget(), ilObjUser\_getPersonalPicturePath(), ilLink\_getStaticLink(), getAdditional(), getAsRows(), getBackUrl(), ilUtil\getImagePath(), getUserId(), ilUtil\getWebspaceDir(), ilGoogleMapUtil\isActivated(), and setTabs().

Referenced by view().

{
global $ilSetting, $lng, $ilCtrl, $lng, $ilSetting, $ilTabs;
if (!$a_preview)
{
$this->setTabs("profile");
}
// get user object
if (!ilObject::_exists($this->getUserId()))
{
return "";
}
$user = new ilObjUser($this->getUserId());
$tpl = new ilTemplate("tpl.usr_public_profile.html", true, true,
"Services/User");
// Back Link
if ($this->getBackUrl() != "")
{
// $tpl->setCurrentBlock("back_url");
// $tpl->setVariable("TXT_BACK", $lng->txt("back"));
// $tpl->setVariable("HREF_BACK", $this->getBackUrl());
// $tpl->parseCurrentBlock();
}
if (!$this->getAsRows())
{
$tpl->touchBlock("table_end");
$tpl->setCurrentBlock("table_start");
$tpl->setVariable("USR_PROFILE", $lng->txt("profile_of")." ".$user->getLogin());
$tpl->parseCurrentBlock();
}
$tpl->setVariable("ROWCOL1", "tblrow1");
$tpl->setVariable("ROWCOL2", "tblrow2");
// Check from Database if value
// of public_profile = "y" show user infomation
if ($user->getPref("public_profile") != "y" &&
($user->getPref("public_profile") != "g" || !$ilSetting->get('enable_global_profiles')))
{
return;
}
$tpl->setVariable("TXT_MAIL", $lng->txt("send_mail"));
// Disabled (smeyer), since tags are not allowed for GET parameters
/*
$mail_to = ilMail::_getUserInternalMailboxAddress(
$user->getId(),
$user->getLogin(),
$user->getFirstname(),
$user->getLastname()
);
$tpl->setVariable("MAIL_USR_LOGIN", urlencode(
$mail_to)
);
*/
require_once 'Services/Mail/classes/class.ilMailFormCall.php';
$tpl->setVariable('HREF_MAIL', ilMailFormCall::_getLinkTarget(basename($_SERVER['REQUEST_URI']), '', array(), array('type' => 'new', 'rcp_to' => urlencode($user->getLogin()))));
$first_name = "";
if($user->getPref("public_title") == "y")
{
$first_name .= $user->getUTitle()." ";
}
$first_name .= $user->getFirstName();
$tpl->setVariable("TXT_NAME", $lng->txt("name"));
$tpl->setVariable("FIRSTNAME", $first_name);
$tpl->setVariable("LASTNAME", $user->getLastName());
// vcard
$tpl->setCurrentBlock("vcard");
$tpl->setVariable("TXT_VCARD", $lng->txt("vcard"));
$tpl->setVariable("TXT_DOWNLOAD_VCARD", $lng->txt("vcard_download"));
$ilCtrl->setParameter($this, "user", $this->getUserId());
$tpl->setVariable("HREF_VCARD", $ilCtrl->getLinkTarget($this, "deliverVCard"));
//$tpl->setVariable("IMG_VCARD", ilUtil::getImagePath("vcard.png"));
// link to global profile
if ($user->prefs["public_profile"] == "g" && $ilSetting->get('enable_global_profiles'))
{
$tpl->setCurrentBlock("link");
$tpl->setVariable("TXT_LINK", $lng->txt("usr_link_to_profile"));
include_once("./classes/class.ilLink.php");
$tpl->setVariable("HREF_LINK",
ilLink::_getStaticLink($user->getId(), "usr"));
$tpl->parseCurrentBlock();
}
$webspace_dir = ilUtil::getWebspaceDir("user");
$check_dir = ilUtil::getWebspaceDir();
$imagefile = $webspace_dir."/usr_images/".$user->getPref("profile_image")."?dummy=".rand(1,999999);
$check_file = $check_dir."/usr_images/".$user->getPref("profile_image");
if (!@is_file($check_file))
{
$imagefile = $check_file =
ilObjUser::_getPersonalPicturePath($user->getId(), "small", false, true);
}
if ($user->getPref("public_upload")=="y" && $imagefile != "")
{
//Getting the flexible path of image form ini file
//$webspace_dir = ilUtil::getWebspaceDir("output");
$tpl->setCurrentBlock("image");
$tpl->setVariable("TXT_IMAGE",$lng->txt("image"));
$tpl->setVariable("IMAGE_PATH", $imagefile);
$tpl->setVariable("IMAGE_ALT", $lng->txt("personal_picture"));
$tpl->parseCurrentBlock();
}
// address
if ($user->getPref("public_street") == "y" || $user->getPref("public_zipcode") == "y"
|| $user->getPref("public_city") == "y" || $user->getPref("public_countr") == "y")
{
$tpl->setCurrentBlock("address");
$tpl->setVariable("TXT_ADDRESS", $lng->txt("address"));
$val_arr = array ("getStreet" => "street",
"getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country", "getSelectedCountry" => "sel_country");
foreach ($val_arr as $key => $value)
{
// if value "y" show information
if ($user->getPref("public_".$value) == "y")
{
if ($user->$key() != "")
{
if ($value == "sel_country")
{
$lng->loadLanguageModule("meta");
$tpl->setVariable("COUNTRY",
$lng->txt("meta_c_".$user->$key()));
}
else
{
$tpl->setVariable(strtoupper($value), $user->$key());
}
}
}
}
$tpl->parseCurrentBlock();
}
// institution / department
if ($user->getPref("public_institution") == "y" || $user->getPref("public_department") == "y")
{
$tpl->setCurrentBlock("inst_dep");
$sep = "";
if ($user->getPref("public_institution") == "y")
{
$h = $lng->txt("institution");
$v = $user->getInstitution();
$sep = " / ";
}
if ($user->getPref("public_department") == "y")
{
$h.= $sep.$lng->txt("department");
$v.= $sep.$user->getDepartment();
}
$tpl->setVariable("TXT_INST_DEP", $h);
$tpl->setVariable("INST_DEP", $v);
$tpl->parseCurrentBlock();
}
// contact
$val_arr = array(
"getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
"getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email");
$v = $sep = "";
foreach ($val_arr as $key => $value)
{
// if value "y" show information
if ($user->getPref("public_".$value) == "y")
{
$v.= $sep.$lng->txt($value).": ".$user->$key();
$sep = "<br />";
}
}
if ($ilSetting->get("usr_settings_hide_instant_messengers") != 1)
{
$im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
foreach ($im_arr as $im_name)
{
if ($im_id = $user->getInstantMessengerId($im_name))
{
if ($user->getPref("public_im_".$im_name) != "n")
{
$v.= $sep.$lng->txt('im_'.$im_name).": ".$im_id;
$sep = "<br />";
}
}
}
}
if ($v != "")
{
$tpl->parseCurrentBlock("contact");
$tpl->setVariable("TXT_CONTACT", $lng->txt("contact"));
$tpl->setVariable("CONTACT", $v);
$tpl->parseCurrentBlock();
}
$val_arr = array(
"getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
foreach ($val_arr as $key => $value)
{
// if value "y" show information
if ($user->getPref("public_".$value) == "y")
{
$tpl->setCurrentBlock("profile_data");
$tpl->setVariable("TXT_DATA", $lng->txt($value));
$tpl->setVariable("DATA", $user->$key());
$tpl->parseCurrentBlock();
}
}
// delicious row
//$d_set = new ilSetting("delicious");
if ($user->getPref("public_delicious") == "y")
{
$tpl->setCurrentBlock("delicious_row");
$tpl->setVariable("TXT_DELICIOUS", $lng->txt("delicious"));
$tpl->setVariable("TXT_DEL_ICON", $lng->txt("delicious"));
$tpl->setVariable("SRC_DEL_ICON", ilUtil::getImagePath("icon_delicious.gif"));
$tpl->setVariable("DEL_ACCOUNT", $user->getDelicious());
$tpl->parseCurrentBlock();
}
// map
include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
if (ilGoogleMapUtil::isActivated() && $user->getPref("public_location")
&& $user->getLatitude() != "")
{
$tpl->setVariable("TXT_LOCATION", $lng->txt("location"));
include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
$map_gui = new ilGoogleMapGUI();
$map_gui->setMapId("user_map");
$map_gui->setWidth("350px");
$map_gui->setHeight("230px");
$map_gui->setLatitude($user->getLatitude());
$map_gui->setLongitude($user->getLongitude());
$map_gui->setZoom($user->getLocationZoom());
$map_gui->setEnableNavigationControl(true);
$map_gui->addUserMarker($user->getId());
$tpl->setVariable("MAP_CONTENT", $map_gui->getHTML());
}
// additional defined user data fields
include_once './Services/User/classes/class.ilUserDefinedFields.php';
$this->user_defined_fields =& ilUserDefinedFields::_getInstance();
$user_defined_data = $user->getUserDefinedData();
foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
{
// public setting
if ($user->prefs["public_udf_".$definition["field_id"]] == "y")
{
if ($user_defined_data["f_".$definition["field_id"]] != "")
{
$tpl->setCurrentBlock("udf_data");
$tpl->setVariable("TXT_UDF_DATA", $definition["field_name"]);
$tpl->setVariable("UDF_DATA", $user_defined_data["f_".$definition["field_id"]]);
$tpl->parseCurrentBlock();
}
}
}
// additional information
if (is_array($additional))
{
foreach($additional as $key => $val)
{
$tpl->setCurrentBlock("profile_data");
$tpl->setVariable("TXT_DATA", $key);
$tpl->setVariable("DATA", $val);
$tpl->parseCurrentBlock();
}
}
return $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::getUserId ( )

Get User ID.

Returns
int User ID

Definition at line 49 of file class.ilPublicUserProfileGUI.php.

Referenced by deliverVCard(), getHTML(), setTabs(), and showUserPage().

{
return $this->userid;
}

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::setAdditional (   $a_additional)

Set Additonal Information.

Parameters
array$a_additionalAdditonal Information

Definition at line 79 of file class.ilPublicUserProfileGUI.php.

{
$this->additional = $a_additional;
}
ilPublicUserProfileGUI::setAsRows (   $a_asrows)

Set Output as Table Rows.

Parameters
boolean$a_asrowsOutput as Table Rows

Definition at line 59 of file class.ilPublicUserProfileGUI.php.

{
$this->asrows = $a_asrows;
}
ilPublicUserProfileGUI::setBackUrl (   $a_backurl)

Set Back Link URL.

Parameters
string$a_backurlBack Link URL

Definition at line 99 of file class.ilPublicUserProfileGUI.php.

References $ilCtrl.

Referenced by __construct().

{
global $ilCtrl;
$this->backurl = $a_backurl;
$ilCtrl->setParameter($this, "back_url", rawurlencode($a_backurl));
}

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::setTabs (   $a_active)

Set tabs.

Parameters
stringback url

Definition at line 612 of file class.ilPublicUserProfileGUI.php.

References $_GET, $ilCtrl, $lng, $tpl, ilObjUser\_getPersonalPicturePath(), getBackUrl(), ilUserUtil\getNamePresentation(), ilExtPublicProfilePage\getPagesOfUser(), and getUserId().

Referenced by getHTML(), and showUserPage().

{
global $ilTabs, $ilUser, $lng, $ilCtrl, $tpl;
include_once("./Services/User/classes/class.ilUserUtil.php");
$tpl->setTitle(ilUserUtil::getNamePresentation($this->getUserId()));
$tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), "xxsmall"));
$back = ($this->getBackUrl() != "")
? $this->getBackUrl()
: $_GET["back_url"];
if ($back != "")
{
$ilTabs->clearTargets();
$ilTabs->setBackTarget($lng->txt("back"),
$back);
}
include_once("./Services/User/classes/class.ilExtPublicProfilePage.php");
if (count($pages) > 0)
{
$ilTabs->addTab("profile",
$lng->txt("profile"),
$ilCtrl->getLinkTarget($this, "getHTML"));
}
foreach ($pages as $p)
{
$ilCtrl->setParameter($this, "user_page", $p["id"]);
$ilTabs->addTab("user_page_".$p["id"],
$p["title"],
$ilCtrl->getLinkTarget($this, "showUserPage"));
}
$ilTabs->activateTab($a_active);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

Definition at line 39 of file class.ilPublicUserProfileGUI.php.

Referenced by __construct(), executeCommand(), and view().

{
$this->userid = $a_userid;
}

+ Here is the caller graph for this function:

ilPublicUserProfileGUI::showUserPage ( )

Show user page.

Returns
string user page html

Definition at line 588 of file class.ilPublicUserProfileGUI.php.

References $_GET, $tpl, ilObjStyleSheet\getContentStylePath(), getUserId(), and setTabs().

{
global $ilUser, $tpl;
$this->setTabs("user_page_".$_GET["user_page"]);
include_once("./Services/User/classes/class.ilExtPublicProfilePageGUI.php");
$page_gui = new ilExtPublicProfilePageGUI($_GET["user_page"]);
if ($page_gui->getPageObject()->getUserId() == $this->getUserId())
{
$tpl->setCurrentBlock("ContentStyle");
$tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
$tpl->parseCurrentBlock();
return $page_gui->preview();
}
}

+ Here is the call graph for this function:

ilPublicUserProfileGUI::view ( )

View.

This one is called e.g. through the goto script

Definition at line 563 of file class.ilPublicUserProfileGUI.php.

References $_GET, $tpl, ilObject\_lookupType(), getHTML(), and setUserId().

{
global $tpl, $ilUser;
$user_id = (int) $_GET["user_id"];
$this->setUserId($user_id);
if (ilObject::_lookupType($user_id) != "usr")
{
return;
}
$user = new ilObjUser($user_id);
if ($ilUser->getId() == ANONYMOUS_USER_ID && $user->getPref("public_profile") != "g")
{
return;
}
$tpl->getStandardTemplate();
$tpl->setContent($this->getHTML());
// $tpl->show();
}

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: