本文整理汇总了PHP中Hubzero\User\Profile::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::load方法的具体用法?PHP Profile::load怎么用?PHP Profile::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Profile
的用法示例。
在下文中一共展示了Profile::load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例4: stateTask
/**
* Sets the emailConfirmed state of a member
*
* @return void
*/
public function stateTask($state = 1)
{
// Check for request forgeries
Request::checkToken(['get', 'post']);
// Incoming user ID
$ids = Request::getVar('id', array());
$ids = !is_array($ids) ? array($ids) : $ids;
// Do we have an ID?
if (empty($ids)) {
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_NO_ID'), 'error');
return;
}
foreach ($ids as $id) {
// Load the profile
$profile = new Profile();
$profile->load(intval($id));
if ($state) {
$profile->set('emailConfirmed', $state);
} else {
$confirm = Helpers\Utility::genemailconfirm();
$profile->set('emailConfirmed', $confirm);
}
if (!$profile->update()) {
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $profile->getError(), 'error');
return;
}
}
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_CONFIRMATION_CHANGED'));
}
示例5: 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;
}