本文整理汇总了PHP中Hubzero\User\Profile::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::getInstance方法的具体用法?PHP Profile::getInstance怎么用?PHP Profile::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Profile
的用法示例。
在下文中一共展示了Profile::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* Up
**/
public function up()
{
$query = "describe jos_citations uid";
$this->db->setQuery($query);
$uidField = $this->db->loadObject();
// if we have an INT already, were good to go
if (strtolower($uidField->Type) == 'int(11)') {
return;
}
// load all citations
$query = "SELECT id, uid FROM `jos_citations`";
$this->db->setQuery($query);
$citations = $this->db->loadObjectList();
foreach ($citations as $citation) {
if (!is_numeric($citation->uid)) {
$newId = 62;
$profile = \Hubzero\User\Profile::getInstance($citation->uid);
if (is_object($profile)) {
$newId = $profile->get('uidNumber');
}
$query = "UPDATE `jos_citations` SET uid=" . $this->db->quote($newId) . " WHERE id=" . $this->db->quote($citation->id);
$this->db->setQuery($query);
$this->db->query();
}
}
// change column name
$query = "ALTER TABLE `jos_citations` CHANGE uid uid INT(11);";
$this->db->setQuery($query);
$this->db->query();
}
示例2: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($referenceid = 0)
{
$this->set('referenceid', $referenceid)->set('category', 'user')->set('option', $this->_segments['option']);
$this->_segments['id'] = $referenceid;
$this->_segments['active'] = 'wishlist';
$this->_item = \Hubzero\User\Profile::getInstance($this->get('scope_id'));
}
示例3: display
/**
* Display module content
*
* @return void
*/
public function display()
{
$this->verified = 0;
if (!User::isGuest()) {
$profile = Profile::getInstance(User::get('id'));
if ($profile->get('emailConfirmed') == 1 || $profile->get('emailConfirmed') == 3) {
$this->verified = 1;
}
}
// Figure out whether this is a guess or temporary account created during the auth_link registration process
if (User::isGuest() || is_numeric(User::get('username')) && User::get('username') < 0) {
$this->guestOrTmpAccount = true;
} else {
$this->guestOrTmpAccount = false;
}
$this->referrer = Request::getVar('REQUEST_URI', '', 'server');
$this->referrer = str_replace('&', '&', $this->referrer);
$this->referrer = base64_encode($this->referrer);
$browser = new Detector();
$this->os = $browser->platform();
$this->os_version = $browser->platformVersion();
$this->browser = $browser->name();
$this->browser_ver = $browser->version();
$this->css()->js()->js('jQuery(document).ready(function(jq) { HUB.Modules.ReportProblems.initialize("' . $this->params->get('trigger', '#tab') . '"); });');
$this->supportParams = Component::params('com_support');
require $this->getLayoutPath();
}
示例4: plgSupportCaptcha
/**
* Constructor
*
* @param object &$subject Event observer
* @param array $config Optional config values
* @return void
*/
public function plgSupportCaptcha(&$subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
if (!User::isGuest()) {
$profile = \Hubzero\User\Profile::getInstance(User::get('id'));
if ($profile->get('emailConfirmed') == 1 || $profile->get('emailConfirmed') == 3) {
$this->_verified = true;
}
}
}
示例5: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($scope_id = 0)
{
$this->set('scope_id', $scope_id);
$this->_segments['id'] = $scope_id;
$this->_segments['active'] = 'blog';
$this->_item = Profile::getInstance($scope_id);
$config = Plugin::params('members', 'blog');
$id = String::pad($this->get('scope_id'));
$this->set('path', str_replace('{{uid}}', $id, $config->get('uploadpath', '/site/members/{{uid}}/blog')));
$this->set('scope', $this->get('scope_id') . '/blog');
$this->set('option', $this->_segments['option']);
}
示例6: run
/**
* Generate module contents
*
* @return void
*/
public function run()
{
include_once Component::path('com_members') . DS . 'tables' . DS . 'profile.php';
include_once Component::path('com_members') . DS . 'tables' . DS . 'association.php';
$database = \App::get('db');
$this->row = null;
$this->profile = null;
// Randomly choose one
$filters = array('limit' => 1, 'show' => trim($this->params->get('show')), 'start' => 0, 'sortby' => "RAND()", 'search' => '', 'authorized' => false, 'show' => trim($this->params->get('show')));
if ($min = $this->params->get('min_contributions')) {
$filters['contributions'] = $min;
}
$mp = new \Components\Members\Tables\Profile($database);
$rows = $mp->getRecords($filters, false);
if (count($rows) > 0) {
$this->row = $rows[0];
}
// Load their bio
$this->profile = Profile::getInstance($this->row->uidNumber);
if (trim(strip_tags($this->profile->get('bio'))) == '') {
return '';
}
// Did we have a result to display?
if ($this->row) {
$this->cls = trim($this->params->get('moduleclass_sfx'));
$this->txt_length = trim($this->params->get('txt_length'));
$config = Component::params('com_members');
$rparams = new Registry($this->profile->get('params'));
$this->params = $config;
$this->params->merge($rparams);
if ($this->params->get('access_bio') == 0 || $this->params->get('access_bio') == 1 && !User::isGuest()) {
$this->txt = $this->profile->getBio('parsed');
} else {
$this->txt = '';
}
// Member profile
$this->title = $this->row->name;
if (!trim($this->title)) {
$this->title = $this->row->givenName . ' ' . $this->row->surname;
}
$this->id = $this->row->uidNumber;
$this->thumb = $this->profile->getPicture();
$this->filters = $filters;
require $this->getLayoutPath();
}
}
示例7: onAfterRoute
/**
* Hook for after parsing route
*
* @return void
*/
public function onAfterRoute()
{
if (App::isSite() && !User::isGuest()) {
$exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles', 'com_members.register.unconfirmed.profiles', 'com_members.register.change.profiles', 'com_members.register.resend.profiles', 'com_members.register.confirm.profiles'];
$current = Request::getWord('option', '');
$current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
$current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
$current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
$xprofile = \Hubzero\User\Profile::getInstance(User::get('id'));
if (is_object($xprofile) && $xprofile->get('emailConfirmed') != 1 && $xprofile->get('emailConfirmed') != 3 && !in_array($current, $exceptions)) {
Request::setVar('option', 'com_members');
Request::setVar('controller', 'register');
Request::setVar('task', 'unconfirmed');
$this->event->stop();
}
}
}
示例8: creator
/**
* Get the creator of this entry
*
* Accepts an optional property name. If provided
* it will return that property value. Otherwise,
* it returns the entire user object
*
* @return mixed
*/
public function creator($property = null)
{
if (!$this->_creator instanceof Profile) {
$this->_creator = Profile::getInstance($this->get('addedBy'));
if (!$this->_creator) {
$this->_creator = new Profile();
}
}
if ($property) {
$property = $property == 'id' ? 'uidNumber' : $property;
if ($property == 'picture') {
return $this->_creator->getPicture();
}
return $this->_creator->get($property);
}
return $this->_creator;
}
示例9: creator
/**
* Get the creator of this entry
*
* Accepts an optional property name. If provided
* it will return that property value. Otherwise,
* it returns the entire object
*
* @param string $property Property to retrieve
* @param mixed $default Default value if property not set
* @return mixed
*/
public function creator($property = null, $default = null)
{
if (!$this->_creator instanceof Profile) {
$this->_creator = Profile::getInstance($this->get('created_by'));
if (!$this->_creator) {
$this->_creator = new Profile();
}
if ($this->_creator->get('uidNumber') && !trim($this->_creator->get('name'))) {
$user = User::getInstance($this->_creator->get('uidNumber'));
$this->_creator->set('name', $user->get('name', Lang::txt('(unknown)')));
}
}
if ($property) {
$property = $property == 'id' ? 'uidNumber' : $property;
return $this->_creator->get($property, $default);
}
return $this->_creator;
}
示例10: addTask
/**
* Add a user as a manager of a course
*
* @return void
*/
public function addTask()
{
// Check for request forgeries
Request::checkToken(['get', 'post']);
if ($this->getError()) {
return $this->displayTask();
}
// Incoming host
$m = Request::getVar('author', '');
$mbrs = explode(',', $m);
$mbrs = array_map('trim', $mbrs);
foreach ($mbrs as $mbr) {
$user = null;
if (!strstr($mbr, ' ')) {
$user = Profile::getInstance($mbr);
}
// Make sure the user exists
if (!is_object($user) || !$user->get('username')) {
$user = new Profile();
$user->set('name', $mbr);
}
$author = new Author($this->database);
$author->cid = $this->citation->id;
$author->author = $user->get('name');
$author->uidNumber = $user->get('uidNumber');
$author->organization = $user->get('organization');
$author->givenName = $user->get('givenName');
$author->middleName = $user->get('middleName');
$author->surname = $user->get('surname');
$author->email = $user->get('email');
if (!$author->check()) {
$this->setError($author->getError());
continue;
}
if (!$author->store()) {
$this->setError($author->getError());
continue;
}
}
// Push through to the view
$this->displayTask();
}
示例11: displaySite
/**
* Display module contents
*
* @return void
*/
public function displaySite()
{
// Get all sessions
$sessions = SessionHelper::getAllSessions(array('distinct' => 1, 'client' => 0));
// Vars to hold guests & logged in members
$this->guestCount = 0;
$this->loggedInCount = 0;
$this->loggedInList = array();
// Get guest and logged in counts/list
foreach ($sessions as $session) {
if ($session->guest == 1) {
$this->guestCount++;
} else {
$this->loggedInCount++;
$profile = Profile::getInstance($session->userid);
if ($profile) {
$this->loggedInList[] = $profile;
}
}
}
// Render view
require $this->getLayoutPath('default');
}
示例12: collectAuthorData
/**
* Collect author data
*
* @access public
* @return string
*/
public function collectAuthorData($author, $ordering, $uid, &$item)
{
$firstName = NULL;
$lastName = NULL;
$org = NULL;
$error = NULL;
// Check that user ID exists
if (trim($uid)) {
if (!intval($uid)) {
$error = Lang::txt('COM_PUBLICATIONS_BATCH_ITEM_ERROR_INVALID_USER_ID') . ': ' . trim($uid);
$item['errors'][] = $error;
} else {
$profile = \Hubzero\User\Profile::getInstance($uid);
if (!$profile || !$profile->get('uidNumber')) {
$error = Lang::txt('COM_PUBLICATIONS_BATCH_ITEM_ERROR_USER_NOT_FOUND') . ': ' . trim($uid);
$item['errors'][] = $error;
} else {
$firstName = $profile->get('givenName');
$lastName = $profile->get('lastName');
$org = $profile->get('organization');
}
}
}
$pAuthor = new Tables\Author($this->database);
$pAuthor->user_id = trim($uid);
$pAuthor->ordering = $ordering;
$pAuthor->credit = '';
$pAuthor->role = '';
$pAuthor->status = 1;
$pAuthor->organization = isset($author->organization) && $author->organization ? trim($author->organization) : $org;
$pAuthor->firstName = isset($author->firstname) && $author->firstname ? trim($author->firstname) : $firstName;
$pAuthor->lastName = isset($author->lastname) && $author->lastname ? trim($author->lastname) : $lastName;
$pAuthor->name = trim($pAuthor->firstName . ' ' . $pAuthor->lastName);
// Check if project member
$objO = $this->project->table('Owner');
$owner = $objO->getOwnerId($this->project->get('id'), $uid, $pAuthor->name);
$pAuthor->project_owner_id = $owner;
if (!$pAuthor->name) {
$item['errors'][] = Lang::txt('COM_PUBLICATIONS_BATCH_ITEM_ERROR_AUTHOR_NAME_REQUIRED');
}
// Add author record
$authorRecord = array('author' => $pAuthor, 'owner' => $owner, 'error' => $error);
$item['authors'][] = $authorRecord;
}
示例13: creator
/**
* Get the creator of this entry
*
* Accepts an optional property name. If provided
* it will return that property value. Otherwise,
* it returns the entire JUser object
*
* @return mixed
*/
public function creator($property = null)
{
if (!$this->_creator instanceof \Hubzero\User\Profile) {
$this->_creator = \Hubzero\User\Profile::getInstance($this->get('user_id'));
if (!$this->_creator) {
$this->_creator = new \Hubzero\User\Profile();
}
}
if ($property) {
$property = $property == 'id' ? 'uidNumber' : $property;
if ($property == 'picture') {
return $this->_creator->getPicture($this->get('anonymous'));
}
return $this->_creator->get($property);
}
return $this->_creator;
}
示例14: _authorCheck
/**
* Split a user's name into its parts if not already done
*
* @param integer $id User ID
* @return void
*/
private function _authorCheck($id)
{
$xprofile = Profile::getInstance($id);
if ($xprofile->get('givenName') == '' && $xprofile->get('middleName') == '' && $xprofile->get('surname') == '') {
$bits = explode(' ', $xprofile->get('name'));
$xprofile->set('surname', array_pop($bits));
if (count($bits) >= 1) {
$xprofile->set('givenName', array_shift($bits));
}
if (count($bits) >= 1) {
$xprofile->set('middleName', implode(' ', $bits));
}
}
}
示例15: onAfterDeleteUser
/**
* Method is called after user data is deleted from the database
*
* @param array $user holds the user data
* @param boolean $success true if user was succesfully stored in the database
* @param string $msg message
* @return boolean True on success
*/
public function onAfterDeleteUser($user, $succes, $msg)
{
$xprofile = \Hubzero\User\Profile::getInstance($user['id']);
// remove user from groups
\Hubzero\User\Helper::removeUserFromGroups($user['id']);
if (is_object($xprofile)) {
$xprofile->delete();
}
\Hubzero\Auth\Link::delete_by_user_id($user['id']);
// Check if quota exists for the user
require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'users_quotas.php';
$quota = new \Components\Members\Tables\UsersQuotas($this->database);
$quota->load(array('user_id' => $user['id']));
if ($quota->id) {
$quota->delete();
}
return true;
}