当前位置: 首页>>代码示例>>PHP>>正文


PHP JUser::getParameters方法代码示例

本文整理汇总了PHP中JUser::getParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::getParameters方法的具体用法?PHP JUser::getParameters怎么用?PHP JUser::getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUser的用法示例。


在下文中一共展示了JUser::getParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:78,代码来源:helper.php


注:本文中的JUser::getParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。