本文整理汇总了PHP中Piwik_SitesManager_API::getSitesIdWithAdminAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_SitesManager_API::getSitesIdWithAdminAccess方法的具体用法?PHP Piwik_SitesManager_API::getSitesIdWithAdminAccess怎么用?PHP Piwik_SitesManager_API::getSitesIdWithAdminAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_SitesManager_API
的用法示例。
在下文中一共展示了Piwik_SitesManager_API::getSitesIdWithAdminAccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$view = Piwik_View::factory('UsersManager');
$IdSitesAdmin = Piwik_SitesManager_API::getSitesIdWithAdminAccess();
$idSiteSelected = 1;
if(count($IdSitesAdmin) > 0)
{
$defaultWebsiteId = $IdSitesAdmin[0];
$idSiteSelected = Piwik_Common::getRequestVar('idsite', $defaultWebsiteId);
}
if($idSiteSelected==='all')
{
$usersAccessByWebsite = array();
}
else
{
$usersAccessByWebsite = Piwik_UsersManager_API::getUsersAccessFromSite( $idSiteSelected );
}
// requires super user access
$usersLogin = Piwik_UsersManager_API::getUsersLogin();
// we dont want to display the user currently logged so that the user can't change his settings from admin to view...
$currentlyLogged = Piwik::getCurrentUserLogin();
foreach($usersLogin as $login)
{
if(!isset($usersAccessByWebsite[$login]))
{
$usersAccessByWebsite[$login] = 'noaccess';
}
}
unset($usersAccessByWebsite[$currentlyLogged]);
ksort($usersAccessByWebsite);
$users = array();
if(Zend_Registry::get('access')->isSuperUser())
{
$users = Piwik_UsersManager_API::getUsers();
}
$view->idSiteSelected = $idSiteSelected;
$view->users = $users;
$view->usersAccessByWebsite = $usersAccessByWebsite;
$view->formUrl = Piwik_Url::getCurrentUrl();
$view->websites = Piwik_SitesManager_API::getSitesWithAdminAccess();
$this->setGeneralVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}
示例2: setUserAccess
/**
* Set an access level to a given user for a list of websites ID.
*
* If access = 'noaccess' the current access (if any) will be deleted.
* If access = 'view' or 'admin' the current access level is deleted and updated with the new value.
*
* @param string Access to grant. Must have one of the following value : noaccess, view, admin
* @param string The user login
* @param int|array The array of idSites on which to apply the access level for the user.
* If the value is "all" then we apply the access level to all the websites ID for which the current authentificated user has an 'admin' access.
*
* @exception if the user doesn't exist
* @exception if the access parameter doesn't have a correct value
* @exception if any of the given website ID doesn't exist
*
* @return bool true on success
*/
static public function setUserAccess( $userLogin, $access, $idSites)
{
self::checkAccessType( $access );
self::checkUserExists( $userLogin);
self::checkUserIsNotSuperUser($userLogin);
if($userLogin == 'anonymous'
&& $access == 'admin')
{
throw new Exception(Piwik_TranslateException("UsersManager_ExceptionAdminAnonymous"));
}
// in case idSites is null we grant access to all the websites on which the current connected user
// has an 'admin' access
if($idSites === 'all')
{
$idSites = Piwik_SitesManager_API::getSitesIdWithAdminAccess();
}
// in case the idSites is an integer we build an array
elseif(!is_array($idSites))
{
$idSites = Piwik_Site::getIdSitesFromIdSitesString($idSites);
}
// it is possible to set user access on websites only for the websites admin
// basically an admin can give the view or the admin access to any user for the websites he manages
Piwik::checkUserHasAdminAccess( $idSites );
self::deleteUserAccess( $userLogin, $idSites);
// delete UserAccess
$db = Zend_Registry::get('db');
// if the access is noaccess then we don't save it as this is the default value
// when no access are specified
if($access != 'noaccess')
{
foreach($idSites as $idsite)
{
$db->insert( Piwik::prefixTable("access"),
array( "idsite" => $idsite,
"login" => $userLogin,
"access" => $access)
);
}
}
// we reload the access list which doesn't yet take in consideration this new user access
Zend_Registry::get('access')->reloadAccess();
}