function before_filter(&$action, &$args) { parent::before_filter($action, $args); // Remove cid URLHelper::removeLinkParam('cid'); unset($_SESSION['SessionSeminar']); $this->set_layout($GLOBALS['template_factory']->open('layouts/base_without_infobox')); Navigation::activateItem('/profile/index'); URLHelper::addLinkParam('username', Request::username('username')); PageLayout::setHelpKeyword('Basis.Homepage'); SkipLinks::addIndex(_('Benutzerprofil'), 'user_profile', 100); $this->user = User::findCurrent(); // current logged in user $this->perm = $GLOBALS['perm']; // perms of current logged in user $this->current_user = User::findByUsername(Request::username('username', $this->user->username)); // current selected user // get additional informations to selected user $this->profile = new ProfileModel($this->current_user->user_id, $this->user->user_id); // set the page title depending on user selection if ($this->current_user['user_id'] == $this->user->id && !$this->current_user['locked']) { PageLayout::setTitle(_('Mein Profil')); UserConfig::get($this->user->id)->store('PROFILE_LAST_VISIT', time()); } elseif ($this->current_user['user_id'] && ($this->perm->have_perm('root') || !$this->current_user['locked'] && get_visibility_by_id($this->current_user['user_id']))) { PageLayout::setTitle(_('Profil') . ' - ' . $this->current_user->getFullname()); object_add_view($this->current_user->user_id); } else { PageLayout::setTitle(_('Profil')); $action = 'not_available'; } }
/** * Export of a single user * * @param User $user Userobject * @return String vCard export string */ private static function exportUser(User $user) { // If user is not visible export nothing if (!get_visibility_by_id($user->id)) { return ""; } // vCard exportheader $vCard['BEGIN'] = 'VCARD'; $vCard['VERSION'] = '3.0'; $vCard['PRODID'] = 'Stud.IP//' . $GLOBALS['UNI_NAME_CLEAN'] . '//DE'; $vCard['REV'] = date('Y-m-d H:i:s'); $vCard['TZ'] = date('O'); // User specific data //Fullname $vCard['FN'] = studip_utf8encode($user->getFullname()); //Name $vCard['N'][] = studip_utf8encode($user->Nachname); $vCard['N'][] = studip_utf8encode($user->Vorname); $vCard['N'][] = studip_utf8encode($user->info->title_rear); $vCard['N'][] = studip_utf8encode($user->info->title_front); // Adress if (Visibility::verify('privadr', $user->id)) { $vCard['ADR;TYPE=HOME'] = studip_utf8encode($user->info->privadr); } // Tel if (Visibility::verify('private_phone', $user->id)) { $vCard['TEL;TYPE=HOME'] = studip_utf8encode($user->info->privatnr); } if (Visibility::verify('private_cell', $user->id)) { $vCard['TEL;TYPE=CELL'] = studip_utf8encode($user->info->privatcell); } // Email if (get_local_visibility_by_id($user->id, 'email')) { $vCard['EMAIL'] = studip_utf8encode($user->email); } // Photo if (Visibility::verify('picture', $user->id)) { // Fetch avatar $avatar = Avatar::getAvatar($user->id); // Only export if if ($avatar->is_customized()) { $vCard['PHOTO;JPEG;ENCODING=BASE64'] = base64_encode(file_get_contents($avatar->getFilename(Avatar::NORMAL))); } } // vCard end $vCard['END'] = 'VCARD'; // Produce string foreach ($vCard as $index => $value) { $exportString .= $value ? $index . ':' . (is_array($value) ? join(';', $value) : $value) . "\r\n" : ""; } return $exportString; }
static function findUser($id) { if (get_visibility_by_id($id)) { $user_data = User::find($id)->getData(); if ($user_data["visible"] == "no" || $user_data["visible"] == "never") { return null; } $inst_fields = "Institut_id, user_id, sprechzeiten, raum, Telefon, Fax, visible"; $query = "SELECT {$inst_fields} FROM `user_inst` WHERE user_inst.user_id = '{$id}' AND user_inst.externdefault='1'"; $stmt = \DBManager::get()->query($query); $user_inst = $stmt->fetchAll(); if (!empty($user_inst[0]["Institut_id"])) { $inst = \Institute::find($user_inst[0]["Institut_id"]); $institute = array("inst_name" => $inst->name, "inst_strasse" => $inst->strasse, "inst_url" => $inst->url, "inst_plz" => $inst->plz, "inst_telefon" => $inst->telefon, "inst_email" => $inst->email, "inst_fax" => $inst->fax); } else { $user_inst = null; } return array("user_data" => $user_data, "user_inst" => $user_inst[0], "inst_info" => $institute); } return null; }
<td width="99%" valign="top" style="padding: 10px;"> <h1><?php echo htmlReady($current_user->getFullname()); ?> </h1> <? if(!empty($motto)) : ?> <h3><?php echo htmlReady($motto); ?> </h3> <?endif?> <? if (!get_visibility_by_id($current_user->user_id)) : ?> <? if ($current_user->user_id != $user->user_id) : ?> <p> <font color="red"><?php echo _("(Dieser Nutzer ist unsichtbar.)"); ?> </font> </p> <? else : ?> <p> <font color="red"><?php echo _("(Sie sind unsichtbar. Deshalb können nur Sie diese Seite sehen.)"); ?> </font> </p> <? endif ?>
/** * return the online status of the passed user, one of three possible * states is returned: * - available * - away * - offline * * @staticvar type $online_status * * @param string $user_id * * @return string */ static function getOnlineStatus($user_id) { static $online_status; // check if the corresponding user's profile is visible if (get_visibility_by_id($user_id) == false) { return 'offline'; } if ($GLOBALS['user']->id == $user_id) { return 'available'; } if (!$online_status) { $online_users = get_users_online(10); foreach ($online_users as $username => $data) { if ($data['last_action'] >= 300) { $online_status[$data['user_id']] = 'away'; } else { $online_status[$data['user_id']] = 'available'; } } } return $online_status[$user_id] ?: 'offline'; }
public static function haveRangePermission($operation, $range_id, $user_id = '') { static $news_range_perm_cache; if (isset($news_range_perm_cache[$user_id . $range_id . $operation])) { return $news_range_perm_cache[$user_id . $range_id . $operation]; } if (!$user_id) { $user_id = $GLOBALS['auth']->auth['uid']; } if ($GLOBALS['perm']->have_perm('root', $user_id)) { return $news_range_perm_cache[$user_id . $range_id . $operation] = true; } $type = get_object_type($range_id, array('global', 'sem', 'inst', 'fak', 'user')); switch ($type) { case 'global': if ($operation == 'view') { return $news_range_perm_cache[$user_id . $range_id . $operation] = true; } break; case 'fak': case 'inst': case 'sem': if ($operation == 'view' && ($type != 'sem' || $GLOBALS['perm']->have_studip_perm('user', $range_id) || get_config('ENABLE_FREE_ACCESS') && Seminar::getInstance($range_id)->read_level == 0)) { return $news_range_perm_cache[$user_id . $range_id . $operation] = true; } if ($operation == 'edit' or $operation == 'copy') { if ($GLOBALS['perm']->have_studip_perm('tutor', $range_id)) { return $news_range_perm_cache[$user_id . $range_id . $operation] = true; } } break; case 'user': if ($operation == 'view') { if ($range_id == $user_id or get_visibility_by_id($range_id)) { return $news_range_perm_cache[$user_id . $range_id . $operation] = true; } } elseif ($operation == 'edit' or $operation == 'copy') { if ($GLOBALS['perm']->have_profile_perm('user', $range_id)) { return $news_range_perm_cache[$user_id . $range_id . $operation] = true; } } break; } return $news_range_perm_cache[$user_id . $range_id . $operation] = false; }
private function requireUser($user_id) { $user = \User::find($user_id); // TODO: checks visibility using the global perm object! if (!$user || !get_visibility_by_id($user_id)) { $this->notFound(sprintf("Could not find user with id: %s", htmlReady($user_id))); } return $user; }