本文整理汇总了PHP中Hubzero\User\Profile::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::get方法的具体用法?PHP Profile::get怎么用?PHP Profile::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Profile
的用法示例。
在下文中一共展示了Profile::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveTask
/**
* Save one or more authors
*
* @param integer $show Display author list when done?
* @param integer $id Resource ID
* @param array $authorsNew Authors to add
* @return void
*/
public function saveTask($show = 1, $id = 0, $authorsNew = array())
{
// Incoming resource ID
if (!$id) {
$id = Request::getInt('pid', 0);
}
if (!$id) {
$this->setError(Lang::txt('CONTRIBUTE_NO_ID'));
if ($show) {
$this->displayTask($id);
}
return;
}
// Incoming authors
$authid = Request::getInt('authid', 0, 'post');
$authorsNewstr = trim(Request::getVar('new_authors', '', 'post'));
$role = Request::getVar('role', '', 'post');
// Turn the string into an array of usernames
$authorsNew = empty($authorsNew) ? explode(',', $authorsNewstr) : $authorsNew;
// Instantiate a resource/contributor association object
$rc = new Contributor($this->database);
$rc->subtable = 'resources';
$rc->subid = $id;
// Get the last child in the ordering
$order = $rc->getLastOrder($id, 'resources');
$order = $order + 1;
// new items are always last
if (!$authid && isset($_POST['author'])) {
$this->database->setQuery('SELECT id FROM `#__users` WHERE username = ' . $this->database->quote($_POST['author']));
$authid = $this->database->loadResult();
}
// Was there an ID? (this will come from the author <select>)
if ($authid) {
// Check if they're already linked to this resource
$rc->loadAssociation($authid, $id, 'resources');
if ($rc->authorid) {
$this->setError(Lang::txt('COM_CONTRIBUTE_USER_IS_ALREADY_AUTHOR', $rc->name));
} else {
// Perform a check to see if they have a contributors page. If not, we'll need to make one
$xprofile = new Profile();
$xprofile->load($authid);
if ($xprofile) {
$this->_authorCheck($authid);
// New record
$rc->authorid = $authid;
$rc->ordering = $order;
$rc->name = addslashes($xprofile->get('name'));
$rc->role = addslashes($role);
$rc->organization = addslashes($xprofile->get('organization'));
$rc->createAssociation();
$order++;
}
}
}
$xprofile = null;
// Do we have new authors?
if (!empty($authorsNew)) {
jimport('joomla.user.helper');
// loop through each one
for ($i = 0, $n = count($authorsNew); $i < $n; $i++) {
$cid = trim($authorsNew[$i]);
if (is_numeric($cid)) {
$uid = intval($cid);
} else {
// Find the user's account info
$uid = \JUserHelper::getUserId(strtolower($cid));
if (!$uid) {
$cid = addslashes(trim($cid));
// No account
// This should mean we have an author that is not a site member
$rcc = new Contributor($this->database);
// Check to see if they're already an author
$rcc->loadAssociation($cid, $id, 'resources');
if ($rcc->authorid) {
$this->setError(Lang::txt('COM_CONTRIBUTE_USER_IS_ALREADY_AUTHOR', $cid));
continue;
}
// No name. Can't save record, so pass over it.
if (!trim($cid)) {
continue;
}
$rcc->subtable = 'resources';
$rcc->subid = $id;
$rcc->authorid = $rcc->getUserId($cid);
$rcc->ordering = $order;
$rcc->name = $cid;
$rcc->role = addslashes($role);
$rcc->createAssociation();
//$this->setError(Lang::txt('COM_CONTRIBUTE_UNABLE_TO_FIND_USER_ACCOUNT', $cid));
$order++;
continue;
}
//.........这里部分代码省略.........
示例2: editTask
/**
* Edit an entry
*
* @return void
*/
public function editTask($row = null)
{
Request::setVar('hidemainmenu', 1);
if (!is_object($row)) {
// Incoming ID
$id = Request::getVar('id', array(0));
$id = is_array($id) ? $id[0] : $id;
// Initiate database class and load info
$row = Quote::oneOrNew($id);
}
if (!$row->get('id')) {
if ($username = Request::getVar('username', '')) {
$profile = new Profile();
$profile->load($username);
$row->set('fullname', $profile->get('name'));
$row->set('org', $profile->get('organization'));
$row->set('user_id', $profile->get('uidNumber'));
}
}
$this->view->row = $row;
// Set any errors
foreach ($this->getErrors() as $error) {
$this->view->setError($error);
}
// Output the HTML
$this->view->setLayout('edit')->display();
}
示例3: saveTask
/**
* Save an entry and return to main listing
*
* @param integer $redirect Redirect to main listing?
* @return void
*/
public function saveTask($redirect = 1)
{
// Check for request forgeries
Request::checkToken();
// Incoming user ID
$id = Request::getInt('id', 0, 'post');
// Do we have an ID?
if (!$id) {
App::abort(500, Lang::txt('COM_MEMBERS_NO_ID'));
return;
}
// Incoming profile edits
$p = Request::getVar('profile', array(), 'post', 'none', 2);
// Load the profile
$profile = new Profile();
$profile->load($id);
// Set the new info
$profile->set('givenName', preg_replace('/\\s+/', ' ', trim($p['givenName'])));
$profile->set('middleName', preg_replace('/\\s+/', ' ', trim($p['middleName'])));
$profile->set('surname', preg_replace('/\\s+/', ' ', trim($p['surname'])));
$name = trim($p['givenName']) . ' ';
$name .= trim($p['middleName']) != '' ? trim($p['middleName']) . ' ' : '';
$name .= trim($p['surname']);
$name = preg_replace('/\\s+/', ' ', $name);
$profile->set('name', $name);
if (isset($p['vip'])) {
$profile->set('vip', $p['vip']);
} else {
$profile->set('vip', 0);
}
$profile->set('orcid', trim($p['orcid']));
$profile->set('url', trim($p['url']));
$profile->set('phone', trim($p['phone']));
$profile->set('orgtype', trim($p['orgtype']));
$profile->set('organization', trim($p['organization']));
$profile->set('bio', trim($p['bio']));
if (isset($p['public'])) {
$profile->set('public', $p['public']);
} else {
$profile->set('public', 0);
}
$profile->set('modifiedDate', Date::toSql());
$profile->set('homeDirectory', trim($p['homeDirectory']));
$profile->set('loginShell', trim($p['loginShell']));
$ec = Request::getInt('emailConfirmed', 0, 'post');
if ($ec) {
$profile->set('emailConfirmed', $ec);
} else {
$confirm = Helpers\Utility::genemailconfirm();
$profile->set('emailConfirmed', $confirm);
}
if (isset($p['email'])) {
$profile->set('email', trim($p['email']));
}
if (isset($p['mailPreferenceOption'])) {
$profile->set('mailPreferenceOption', trim($p['mailPreferenceOption']));
} else {
$profile->set('mailPreferenceOption', -1);
}
if (!empty($p['gender'])) {
$profile->set('gender', trim($p['gender']));
}
if (!empty($p['disability'])) {
if ($p['disability'] == 'yes') {
if (!is_array($p['disabilities'])) {
$p['disabilities'] = array();
}
if (count($p['disabilities']) == 1 && isset($p['disabilities']['other']) && empty($p['disabilities']['other'])) {
$profile->set('disability', array('no'));
} else {
$profile->set('disability', $p['disabilities']);
}
} else {
$profile->set('disability', array($p['disability']));
}
}
if (!empty($p['hispanic'])) {
if ($p['hispanic'] == 'yes') {
if (!is_array($p['hispanics'])) {
$p['hispanics'] = array();
}
if (count($p['hispanics']) == 1 && isset($p['hispanics']['other']) && empty($p['hispanics']['other'])) {
$profile->set('hispanic', array('no'));
} else {
$profile->set('hispanic', $p['hispanics']);
}
} else {
$profile->set('hispanic', array($p['hispanic']));
}
}
if (isset($p['race']) && is_array($p['race'])) {
$profile->set('race', $p['race']);
}
// Save the changes
//.........这里部分代码省略.........
示例4: newTask
/**
* Displays a form for creating a new support ticket
*
* @return void
*/
public function newTask($row = null)
{
if (!$row instanceof Ticket) {
$row = new Ticket();
$row->set('open', 1)->set('status', 0)->set('ip', Request::ip())->set('uas', Request::getVar('HTTP_USER_AGENT', '', 'server'))->set('referrer', base64_encode(Request::getVar('HTTP_REFERER', NULL, 'server')))->set('cookies', Request::getVar('sessioncookie', '', 'cookie') ? 1 : 0)->set('instances', 1)->set('section', 1)->set('tool', Request::getVar('tool', ''))->set('verified', 0);
if (!User::isGuest()) {
$row->set('name', User::get('name'));
$row->set('login', User::get('username'));
$row->set('email', User::get('email'));
}
}
$browser = new Detector();
$row->set('os', $browser->platform())->set('osver', $browser->platformVersion())->set('browser', $browser->name())->set('browserver', $browser->version());
if (!User::isGuest()) {
$profile = new Profile();
$profile->load(User::get('id'));
$emailConfirmed = $profile->get('emailConfirmed');
if ($emailConfirmed == 1 || $emailConfirmed == 3) {
$row->set('verified', 1);
}
}
// Output HTML
$lists = array();
if ($row->get('verified') && $this->acl->check('update', 'tickets') > 0) {
if (trim($this->config->get('group'))) {
$lists['owner'] = $this->_userSelectGroup('problem[owner]', '', 1, '', trim($this->config->get('group')));
} else {
$lists['owner'] = $this->_userSelect('problem[owner]', '', 1);
}
$lists['severities'] = Utilities::getSeverities($this->config->get('severities'));
$sr = new Tables\Resolution($this->database);
$lists['resolutions'] = $sr->getResolutions();
$sc = new Tables\Category($this->database);
$lists['categories'] = $sc->find('list');
}
// Set page title
$this->_buildTitle();
// Set the pathway
$this->_buildPathway();
foreach ($this->getErrors() as $error) {
$this->view->setError($error);
}
$this->view->set('acl', $this->acl)->set('title', $this->_title)->set('file_types', $this->config->get('file_ext'))->set('lists', $lists)->set('row', $row)->set('captchas', Event::trigger('support.onGetComponentCaptcha'))->setLayout('new')->display();
}
示例5: 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();
}
示例6: saveAuthors
/**
* Save a list of authors
*
* @param array $authors List of authors to add
* @param string $version Tool version
* @param integer $rid Resource ID
* @param integer $revision Revision number
* @param string $toolname Tool name
* @return boolean False if errors, True if not
*/
public function saveAuthors($authors, $version = 'dev', $rid = 0, $revision = 0, $toolname = '')
{
if (!$rid) {
return false;
}
if ($authors) {
$authors = Utils::transform($authors, 'uidNumber');
}
$dev_authors = $this->getToolAuthors('dev', $rid);
$dev_authors = Utils::transform($dev_authors, 'uidNumber');
if ($dev_authors && $version == 'dev') {
// update
$to_delete = array_diff($current_authors, $authors);
if ($to_delete) {
foreach ($to_delete as $del) {
$query = "DELETE FROM #__author_assoc WHERE authorid=" . $this->_db->quote($del) . " AND subid=" . $this->_db->quote($rid) . " AND subtable='resources'";
$this->_db->setQuery($query);
$this->_db->query();
}
}
}
// add new authors
if ($version == 'dev') {
// development version is updated
$to_delete = array_diff($dev_authors, $authors);
$rc = new \Components\Resources\Tables\Contributor($this->_db);
$rc->subtable = 'resources';
$rc->subid = $rid;
if ($to_delete) {
foreach ($to_delete as $del) {
$query = "DELETE FROM #__author_assoc WHERE authorid=" . $this->_db->quote($del) . " AND subid=" . $this->_db->quote($rid) . " AND subtable='resources'";
$this->_db->setQuery($query);
$this->_db->query();
}
}
// Get the last child in the ordering
$order = $rc->getLastOrder($rid, 'resources');
$order = $order + 1;
// new items are always last
foreach ($authors as $authid) {
// Check if they're already linked to this resource
$rc->loadAssociation($authid, $rid, 'resources');
if (!$rc->authorid) {
$xprofile = new Profile();
$xprofile->load($authid);
// New record
$rc->authorid = $authid;
$rc->ordering = $order;
$rc->name = addslashes($xprofile->get('name'));
$rc->organization = addslashes($xprofile->get('organization'));
$rc->createAssociation();
$order++;
}
}
} else {
if ($dev_authors) {
// new version is being published, transfer data from author_assoc
$i = 0;
foreach ($dev_authors as $authid) {
// Do we have name/org info in previous version?
$query = "SELECT name, organization FROM #__tool_authors ";
$query .= "WHERE toolname=" . $this->_db->quote($toolname) . " AND uid=" . $this->_db->quote($authid) . " AND revision < " . $this->_db->quote($revision);
$query .= " AND name IS NOT NULL AND organization IS NOT NULL ";
$query .= " ORDER BY revision DESC LIMIT 1";
$this->_db->setQuery($query);
$info = $this->_db->loadObjectList();
if ($info) {
$name = $info[0]->name;
$organization = $info[0]->organization;
} else {
$xprofile = new Profile();
$xprofile->load($authid);
$name = $xprofile->get('name');
$organization = $xprofile->get('organization');
}
$query = "INSERT INTO {$this->_tbl} (toolname, revision, uid, ordering, version_id, name, organization) VALUES ('" . $toolname . "','" . $revision . "','" . $authid . "','" . $i . "', '" . $version . "', '" . addslashes($name) . "', '" . addslashes($organization) . "')";
$this->_db->setQuery($query);
if (!$this->_db->query()) {
return false;
}
$i++;
}
}
}
return true;
}