本文整理汇总了PHP中Piwik\Piwik::checkUserIsSuperUserOrTheUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::checkUserIsSuperUserOrTheUser方法的具体用法?PHP Piwik::checkUserIsSuperUserOrTheUser怎么用?PHP Piwik::checkUserIsSuperUserOrTheUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::checkUserIsSuperUserOrTheUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUser
/**
* Updates a user in the database.
* Only login and password are required (case when we update the password).
* When the password changes, the key token for this user will change, which could break
* its API calls.
*
* @see addUser() for all the parameters
*/
public function updateUser($userLogin, $password = false, $email = false, $alias = false, $_isPasswordHashed = false)
{
Piwik::checkUserIsSuperUserOrTheUser($userLogin);
$this->checkUserIsNotAnonymous($userLogin);
$this->checkUserIsNotSuperUser($userLogin);
$userInfo = $this->getUser($userLogin);
if (empty($password)) {
$password = $userInfo['password'];
} else {
$password = Common::unsanitizeInputValue($password);
if (!$_isPasswordHashed) {
UsersManager::checkPassword($password);
$password = UsersManager::getPasswordHash($password);
}
}
if (empty($alias)) {
$alias = $userInfo['alias'];
}
if (empty($email)) {
$email = $userInfo['email'];
}
if ($email != $userInfo['email']) {
$this->checkEmail($email);
}
$alias = $this->getCleanAlias($alias, $userLogin);
$token_auth = $this->getTokenAuth($userLogin, $password);
$db = Db::get();
$db->update(Common::prefixTable("user"), array('password' => $password, 'alias' => $alias, 'email' => $email, 'token_auth' => $token_auth), "login = '{$userLogin}'");
Cache::deleteTrackerCache();
/**
* Triggered after an existing user has been updated.
*
* @param string $userLogin The user's login handle.
*/
Piwik::postEvent('UsersManager.updateUser.end', array($userLogin));
}
示例2: setLanguageForUser
/**
* Sets the language for the user
*
* @param string $login
* @param string $languageCode
* @return bool
*/
public function setLanguageForUser($login, $languageCode)
{
Piwik::checkUserIsSuperUserOrTheUser($login);
Piwik::checkUserIsNotAnonymous();
if (!$this->isLanguageAvailable($languageCode)) {
return false;
}
$paramsBind = array($login, $languageCode, $languageCode);
Db::query('INSERT INTO ' . Common::prefixTable('user_language') . ' (login, language)
VALUES (?,?)
ON DUPLICATE KEY UPDATE language=?', $paramsBind);
return true;
}
示例3: get
/**
* Returns a stored segment by ID
*
* @param $idSegment
* @throws Exception
* @return bool
*/
public function get($idSegment)
{
Piwik::checkUserHasSomeViewAccess();
if (!is_numeric($idSegment)) {
throw new Exception("idSegment should be numeric.");
}
$segment = Db::get()->fetchRow("SELECT * " . " FROM " . Common::prefixTable("segment") . " WHERE idsegment = ?", $idSegment);
if (empty($segment)) {
return false;
}
try {
if (!$segment['enable_all_users']) {
Piwik::checkUserIsSuperUserOrTheUser($segment['login']);
}
} catch (Exception $e) {
throw new Exception("You can only edit the custom segments you have created yourself. This segment was created and 'shared with you' by the Super User. " . "To modify this segment, you can first create a new one by clicking on 'Add new segment'. Then you can customize the segment's definition.");
}
if ($segment['deleted']) {
throw new Exception("This segment is marked as deleted. ");
}
return $segment;
}