本文整理汇总了PHP中JUser::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::getTable方法的具体用法?PHP JUser::getTable怎么用?PHP JUser::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::getTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTable
/**
* Testing getTable().
*
* @param string The type of table
* @param string The prefix for the table
* @param string The expected class of the table
* @param string The expected name of the table
*
* @return void
*
* @dataProvider casesGetTable
*/
public function testGetTable($type, $prefix, $expClass, $expName)
{
$table = $this->object->getTable($type, $prefix);
$this->assertThat($table, $expClass ? $this->isInstanceOf($expClass) : $this->isFalse(), 'Table is not instance of JTableUser');
if ($expClass) {
$this->assertThat($table->getTableName(), $this->equalTo($expName), 'Failed table name check');
}
}
示例2: createUser
function createUser($username)
{
$new_user = new JUser();
$this->db->setQuery("SELECT email, isAdm FROM #__user WHERE name = " . $this->db->Quote($username));
$r = $this->db->loadRow();
$email = $r[0];
$isAdm = $r[1];
jimport('joomla.application.component.helper');
$config =& JComponentHelper::getParams('com_users');
if ($isAdm) {
$usertype = 'Super Administrator';
} else {
$usertype = $config->get('new_usertype', 'Registered');
}
$acl =& JFactory::getACL();
$new_user->set('id', 0);
$new_user->set('name', $username);
$new_user->set('username', $username);
$new_user->set('email', $email);
$new_user->set('gid', $acl->get_group_id('', $usertype));
$new_user->set('usertype', $usertype);
$new_user->set('registeredDate', date('Y-m-d H:i:s'));
$new_user->set('lastVisitDate', date('Y-m-d H:i:s'));
$table =& $new_user->getTable();
$new_user->params = $new_user->_params->toString();
$table->bind($new_user->getProperties());
// $new_user->save();
if ($table->store()) {
return $table->get('id');
}
}
示例3: display
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$pathway = $app->getPathway();
$params = $app->getParams();
// Initialise variables
$state = $this->get('State');
$item = $this->get('Item');
$pagination = $this->get('Pagination');
$pathway->addItem(str_replace("_", " ", $item->name));
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
if ($item === false) {
return JError::raiseError(404, JText::_('COM_TRACKER_NO_TORRENT'));
}
if ($user->get('guest') && $params->get('allow_guest') == 0) {
$app->redirect('index.php', JText::_('COM_TRACKER_NOT_LOGGED_IN'), 'error');
}
if ($user->get('guest') && $params->get('allow_guest') == 1) {
$user = JUser::getTable('user', 'TrackerTable');
$user->load($params->get('guest_user'));
}
$this->assignRef('state', $state);
$this->assignRef('item', $item);
$this->assignRef('params', $params);
parent::display($tpl);
}
示例4: fetch
/**
* Fetch the user for the given user identifier from the backend
*
* @param string $identifier A unique user identifier, (i.e a username or email address)
* @return KUserInterface|null Returns a UserInterface object or NULL if the user could not be found.
*/
public function fetch($identifier)
{
$table = JUser::getTable();
if ($table->load($identifier)) {
$user = JUser::getInstance(0);
$user->setProperties($table->getProperties());
$params = new JRegistry();
$params->loadString($table->params);
$user->setParameters($params);
$data = array('id' => $user->id, 'email' => $user->email, 'name' => $user->name, 'username' => $user->username, 'password' => $user->password, 'salt' => '', 'groups' => JAccess::getGroupsByUser($user->id), 'roles' => JAccess::getAuthorisedViewLevels($user->id), 'authentic' => !$user->guest, 'enabled' => !$user->block, 'expired' => (bool) $user->activation, 'attributes' => $user->getParameters()->toArray());
$user = $this->create($data);
} else {
$user = null;
}
return $user;
}
示例5: intval
if ($listads->ad_payment_type == 0) {
echo JText::_('IMPRS');
} else {
if ($listads->ad_payment_type == 1) {
echo JText::_('CLICKS');
} else {
echo JText::_('PERDATE');
}
}
}
}
?>
</td>
<td>
<?php
$table = JUser::getTable();
$user_id = intval($listads->ad_creator);
$creaternm = '';
if ($table->load($user_id)) {
$creaternm = JFactory::getUser($listads->ad_creator);
}
// print_r($listads->ad_creator);
echo !$creaternm ? JText::_('NO_USER') : $creaternm->username;
?>
</td>
<!--Zone Name -->
<td>
<?php
$zone_name = '';
$zone_name = $model->adzonename($listads->ad_id, $listads->ad_zone);
示例6: __construct
public function __construct($app)
{
parent::__construct($app);
$this->_user = JFactory::getUser();
$this->_table = $this->_user->getTable();
}
示例7: save
/**
* Saves a JUser object to the database. This method has been adapted from
* the JUser::save() method to bypass ACL checks for super users. It still
* calls the onUserBeforeSave and onUserAfterSave events.
*
* @param JUser &$user Object to save.
* @param Boolean $dispatch True to call the listening plugins or False to skip dispatching
*
* @return boolean True on success or False on failure.
*
* @since 2.0
* @throws Exception
*/
public static function save(JUser &$user, $dispatch = true)
{
// Create the user table object
$table = $user->getTable();
$user->params = (string) $user->getParameters();
$table->bind($user->getProperties());
$username = $user->username;
// Check and store the object.
if (!$table->check())
{
throw new Exception(JText::sprintf('LIB_SHUSERHELPER_ERR_10511', $username, $table->getError()), 10511);
}
$my = JFactory::getUser();
if ($dispatch)
{
// Check if we are creating a new user
$isNew = empty($user->id);
// Get the old user
$oldUser = new JUser($user->id);
// Fire the onUserBeforeSave event.
JPluginHelper::importPlugin('user');
$dispatcher = JDispatcher::getInstance();
$result = $dispatcher->trigger('onUserBeforeSave', array($oldUser->getProperties(), $isNew, $user->getProperties()));
if (in_array(false, $result, true))
{
// Plugin will have to raise its own error or throw an exception.
return false;
}
}
// Store the user data in the database
if (!($result = $table->store()))
{
throw new Exception(JText::sprintf('LIB_SHUSERHELPER_ERR_10512', $username, $table->getError()), 10512);
}
// Set the id for the JUser object in case we created a new user.
if (empty($user->id))
{
$user->id = $table->get('id');
}
if ($my->id == $table->id)
{
$registry = new JRegistry;
$registry->loadString($table->params);
$my->setParameters($registry);
}
if ($dispatch)
{
// Fire the onUserAfterSave event
$dispatcher->trigger('onUserAfterSave', array($user->getProperties(), $isNew, $result, $user->getError()));
}
return $result;
}
示例8: migrateVotes
/**
* Migrates all votes
*
* @return void
* @since 1.0
*/
protected function migrateVotes()
{
$selectQuery = $this->_db2->getQuery(true)->select('a.*')->from($this->table_votes . ' AS a');
if (!$this->otherDatabase) {
if (!$this->checkTime()) {
$this->refresh('votes');
}
$this->writeLogfile('Start migrating votes');
if ($this->checkOwner) {
$selectQuery->leftJoin('#__users AS u ON a.userid = u.id')->where('u.id IS NOT NULL');
}
$query = 'INSERT INTO ' . _JOOM_TABLE_VOTES . ' ' . $selectQuery;
$this->_db->setQuery($query);
if ($this->runQuery()) {
$this->writeLogfile('Votes successfully migrated');
} else {
$this->writeLogfile('Error migrating the votes');
}
return;
}
$this->prepareTable($selectQuery);
while ($row = $this->getNextObject()) {
if (!$this->checkOwner || JUser::getTable()->load($row->userid)) {
$this->createVote($row);
}
if (!$this->checkTime()) {
$this->refresh('votes');
}
}
$this->resetTable();
}
示例9: saveUserRegistration
//.........这里部分代码省略.........
if ($aecConfig->cfg['plans_first']) {
aecErrorAlert($alert, $action = 'window.history.go(-2);');
} else {
aecErrorAlert($alert, $action = 'window.history.go(-3);');
}
}
}
} elseif (aecComponentHelper::detect_component('JUSER')) {
// This is a JUSER registration, borrowing their code to save the user
saveRegistration('com_acctexp');
$query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $var['username'] . '\'';
$db->setQuery($query);
$uid = $db->loadResult();
JUser::saveUser_ext($uid);
//synchronize dublicate user data
$query = 'SELECT `id`' . ' FROM #__juser_integration' . ' WHERE `published` = \'1\'' . ' AND `export_status` = \'1\'';
$db->setQuery($query);
$components = $db->loadObjectList();
if (!empty($components)) {
foreach ($components as $component) {
$synchronize = require_integration($component->id);
$synchronize->synchronizeFrom($uid);
}
}
} elseif (aecComponentHelper::detect_component('JOMSOCIAL') && !$overrideJS) {
} else {
$data = array('username' => $var['username'], 'password' => $var['password'], 'password2' => $var['password2'], 'email' => $var['email'], 'name' => $var['name']);
if (isset($var['jform']['profile'])) {
$data['profile'] = $var['jform']['profile'];
}
if (defined('JPATH_MANIFESTS')) {
$params = JComponentHelper::getParams('com_users');
// Initialise the table with JUser.
JUser::getTable('User', 'JTable');
$user = new JUser();
// Prepare the data for the user object.
$useractivation = $params->get('useractivation');
// Check if the user needs to activate their account.
if (($useractivation == 1 || $useractivation == 2) && !$overrideActivation) {
jimport('joomla.user.helper');
$data['activation'] = xJ::getHash();
$data['block'] = 1;
}
$usersConfig = JComponentHelper::getParams('com_users');
$system = $usersConfig->get('new_usertype', 2);
$data['groups'][] = $system;
// Bind the data.
if (!$user->bind($data)) {
JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('users');
// Store the data.
if (!$user->save()) {
JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
return false;
}
} else {
// This is a joomla registration, borrowing their code to save the user
// Check for request forgeries
if (!$internal) {
JRequest::checkToken() or die('Invalid Token');
}
// Get required system objects
$user = clone JFactory::getUser();
示例10: register
/**
* Method to save the form data.
*
* @access public
* @param array $data The form data.
* @return mixed The user id on success, false on failure.
* @since 1.0
*/
function register($temp)
{
$config =& JFactory::getConfig();
$params =& JComponentHelper::getParams('com_users');
// Initialise the table with JUser.
JUser::getTable('User', 'JTable');
$user = new JUser();
$data = (array) $this->getData();
// Merge in the registration data.
foreach ($data as $k => $v) {
$temp[$k] = $v;
}
$data = $temp;
// Prepare the data for the user object.
$data['email'] = $data['email1'];
$data['password'] = $data['password1'];
// Check if the user needs to activate their account.
if ($params->get('useractivation')) {
jimport('joomla.user.helper');
$data['activation'] = JUtility::getHash(JUserHelper::genRandomPassword());
$data['block'] = 1;
}
// Bind the data.
if (!$user->bind($data)) {
$this->setError(JText::sprintf('USERS REGISTRATION BIND FAILED', $user->getError()));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('users');
// Store the data.
if (!$user->save()) {
$this->setError($user->getError());
return false;
}
// Compile the notification mail values.
$data = $user->getProperties();
$data['fromname'] = $config->getValue('fromname');
$data['mailfrom'] = $config->getValue('mailfrom');
$data['sitename'] = $config->getValue('sitename');
// Handle account activation/confirmation e-mails.
if ($params->get('useractivation')) {
// Set the link to activate the user account.
$uri =& JURI::getInstance();
$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
$data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
// Get the registration activation e-mail.
$message = 'com_users.registration.activate';
} else {
// Get the registration confirmation e-mail.
$message = 'com_users.registration.confirm';
}
// Load the message template and bind the data.
jimport('joomla.utilities.simpletemplate');
$template = JxSimpleTemplate::getInstance($message);
$template->bind($data);
// Send the registration e-mail.
$return = JUtility::sendMail($data['mailfrom'], $data['fromname'], $data['email'], $template->getTitle(), $template->getBody());
// Check for an error.
if ($return !== true) {
$this->setError(JText::_('USERS REGISTRATION SEND MAIL FAILED'));
return false;
}
return $user->id;
}
示例11: __construct
/**
* Instantiate the controller.
*
* @param string $type The content type
* @param JInput $input The input object.
* @param JApplicationBase $app The application object.
*
* @since 1.0
*/
public function __construct($name, $type, JInput $input = null, JApplicationBase $app = null)
{
// Setup dependencies.
$this->app = isset($app) ? $app : $this->loadApplication();
$this->input = isset($input) ? $input : $this->loadInput();
// Set type
$this->type = $type;
// Init user load table
JUser::getTable('user', 'WebServiceTable');
// Init a local user
$this->user = new JUser();
// Init model
$modelClass = 'WebServiceModels' . ucfirst($name);
// If the controller class does not exist panic.
if (!class_exists($modelClass) || !is_subclass_of($modelClass, 'JModel')) {
throw new RuntimeException(sprintf('Unable to locate models `%s`.', $modelClass), 404);
}
$this->model = new $modelClass(new JContentFactory());
}
示例12: __construct
/**
* Instantiate the controller.
*
* @param string $type The content type
* @param JInput $input The input object.
* @param JApplicationBase $app The application object.
*
* @since 1.0
*/
public function __construct($type, JInput $input = null, JApplicationBase $app = null)
{
// Setup dependencies.
$this->app = isset($app) ? $app : $this->loadApplication();
$this->input = isset($input) ? $input : $this->loadInput();
// Set type
$this->type = $type;
// Init user load table
JUser::getTable('user', 'WebServiceTable');
// Init a local user
$this->user = new JUser();
// Init model
$this->model = new WebServiceModelBase(new JContentFactory());
}
示例13: jSelectUser_user
<?php
JHtml::_('behavior.modal');
$this->app->html->_('behavior.tooltip');
// init vars
$settings = $this->app->zoocart->getConfig();
$this->app->document->addScriptDeclaration("function jSelectUser_user(uid, name){\n\tdocument.getElementById('user_id').value = uid;\n\tdocument.getElementById('user_name').innerHTML = name;\n\tSqueezeBox.close();\n}");
// Keepalive behavior
JHTML::_('behavior.keepalive');
// filter output
JFilterOutput::objectHTMLSafe($this->resource, ENT_QUOTES, array('params', 'billing_address', 'shipping_address', 'shipping_method'));
$renderer = $this->app->renderer->create('address')->addPath(array($this->app->path->path('component.site:'), $this->app->path->path('zoocart:')));
$uid = $this->resource && $this->resource->user_id ? $this->resource->user_id : ($uid = $this->app->user->get()->id);
if (!JUser::getTable()->load($uid)) {
$uname = JText::sprintf('PLG_ZOOCART_ORDER_USER', $uid);
$umail = '';
} else {
$user = $this->app->user->get($uid);
$uname = $user->name;
$umail = $user->email;
}
$config = $this->app->zoocart->getConfig();
// Detect if shipping enabled:
$enable_shipping = $config->get('enable_shipping', 0);
?>
<div id="zoocart-orders">
<!-- main menu -->
<?php
echo $this->partial('zlmenu');
?>
示例14: sprintf
echo $row->id;
?>
" />
</td>
<td>
<a href="<?php
echo $this->component->link(array('controller' => $this->controller, 'task' => 'edit', 'cid[]' => $row->id));
?>
">#<?php
echo sprintf('%05d', $row->id);
?>
</a>
</td>
<td>
<?php
echo JUser::getTable()->load($row->user_id) ? JFactory::getUser($row->user_id)->name : JText::sprintf('PLG_ZOOCART_ORDER_USER', $row->user_id);
?>
</td>
<td>
<?php
echo $address_renderer->render('address.billing', array('item' => $row->getBillingAddress()));
?>
</td>
<td>
<?php
echo $address_renderer->render('address.shipping', array('item' => $row->getShippingAddress()));
?>
</td>
<td>
<?php
echo $this->app->zoocart->currency->format($row->getSubtotal());
示例15: display
//.........这里部分代码省略.........
}
// Finally, set document title
$document->setTitle($doc_title);
// ************************
// Set document's META tags
// ************************
// Workaround for Joomla not setting the default value for 'robots', so component must do it
$app_params = $app->getParams();
if ($_mp = $app_params->get('robots')) {
$document->setMetadata('robots', $_mp);
}
if ($category->id) {
// possibly not set for author items OR my items
if (FLEXI_J16GE) {
if ($category->metadesc) {
$document->setDescription($category->metadesc);
}
if ($category->metakey) {
$document->setMetadata('keywords', $category->metakey);
}
// meta_params are always set if J1.6+ and category id is set
if ($meta_params->get('robots')) {
$document->setMetadata('robots', $meta_params->get('robots'));
}
// ?? Deprecated <title> tag is used instead by search engines
if ($app->getCfg('MetaTitle') == '1') {
$meta_title = $meta_params->get('page_title') ? $meta_params->get('page_title') : $category->title;
$document->setMetaData('title', $meta_title);
}
if ($app->getCfg('MetaAuthor') == '1') {
if ($meta_params->get('author')) {
$meta_author = $meta_params->get('author');
} else {
$table = JUser::getTable();
$meta_author = $table->load($category->created_user_id) ? $table->name : '';
}
$document->setMetaData('author', $meta_author);
}
} else {
// ?? Deprecated <title> tag is used instead by search engines
if ($app->getCfg('MetaTitle') == '1') {
$document->setMetaData('title', $category->title);
}
}
}
// Overwrite with menu META data if menu matched
if (FLEXI_J16GE) {
if ($menu_matches) {
if ($_mp = $menu->params->get('menu-meta_description')) {
$document->setDescription($_mp);
}
if ($_mp = $menu->params->get('menu-meta_keywords')) {
$document->setMetadata('keywords', $_mp);
}
if ($_mp = $menu->params->get('robots')) {
$document->setMetadata('robots', $_mp);
}
if ($_mp = $menu->params->get('secure')) {
$document->setMetadata('secure', $_mp);
}
}
}
// ************************************
// Add rel canonical html head link tag (TODO: improve multi-page handing)
// ************************************
$base = $uri->getScheme() . '://' . $uri->getHost();