本文整理汇总了PHP中Piwik_SitesManager_API::getSitesWithAdminAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_SitesManager_API::getSitesWithAdminAccess方法的具体用法?PHP Piwik_SitesManager_API::getSitesWithAdminAccess怎么用?PHP Piwik_SitesManager_API::getSitesWithAdminAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_SitesManager_API
的用法示例。
在下文中一共展示了Piwik_SitesManager_API::getSitesWithAdminAccess方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$view = new Piwik_View('SitesManager/templates/SitesManager.tpl');
$sites = Piwik_SitesManager_API::getSitesWithAdminAccess();
foreach ($sites as &$site) {
$site['alias_urls'] = Piwik_SitesManager_API::getSiteUrlsFromId($site['idsite']);
}
$view->adminSites = $sites;
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}
示例2: 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();
}
示例3: index
function index()
{
$view = Piwik_View::factory('SitesManager');
$sites = Piwik_SitesManager_API::getSitesWithAdminAccess();
foreach ($sites as &$site) {
$site['alias_urls'] = Piwik_SitesManager_API::getSiteUrlsFromId($site['idsite']);
}
$view->adminSites = $sites;
$this->setGeneralVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}
示例4: index
/**
* This method displays a text containing an help about "How to build plugins for Piwik".
* This help is then used on http://dev.piwik.org/trac/wiki/Plugins/GlobalFunctions
*
*/
function index()
{
$out = '';
$out .= '<i>This page aims to list the different functions you can use when programming plugins for Piwik.</i><br>';
$out .= '<b>Be careful, the following APIs may change in the near future as Piwik is still in development.</b><br>';
$out .= '<h2>General</h2>';
$out .= '<h3>Accessible from your plugin controller</h3>';
$out .= '<code>$this->date</code> = current selected <b>Piwik_Date</b> object (<a href="http://dev.piwik.org/trac/browser/trunk/core/Date.php">class</a>)<br/>';
$out .= '<code>$period = Piwik_Common::getRequestVar("period");</code> - Get the current selected period<br/>';
$out .= '<code>$idSite = Piwik_Common::getRequestVar("idSite");</code> - Get the selected idSite<br/>';
$out .= '<code>$site = new Piwik_Site($idSite);</code> - Build the Piwik_Site object (<a href="http://dev.piwik.org/trac/browser/trunk/core/Site.php">class</a>)<br/>';
$out .= '<code>$this->str_date</code> = current selected date in YYYY-MM-DD format<br/>';
$out .= '<h3>Misc</h3>';
$out .= '<code>Piwik_AddMenu( $mainMenuName, $subMenuName, $url );</code> - Adds an entry to the menu in the Piwik interface (See the example in the <a href="http://dev.piwik.org/trac/browser/trunk/plugins/UserCountry/UserCountry.php#L146">UserCountry Plugin file</a>)<br/>';
$out .= '<code>Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="http://dev.piwik.org/trac/browser/trunk/plugins/UserCountry/UserCountry.php#L143">UserCountry Plugin file</a> or any other plugin)<br/>';
$out .= '<code>Piwik::prefixTable("site")</code> = <b>' . Piwik::prefixTable("site") . '</b><br/>';
$out .= '<h2>User access</h2>';
$out .= '<code>Piwik::getCurrentUserLogin()</code> = <b>' . Piwik::getCurrentUserLogin() . '</b><br/>';
$out .= '<code>Piwik::isUserHasSomeAdminAccess()</code> = <b>' . self::boolToString(Piwik::isUserHasSomeAdminAccess()) . '</b><br/>';
$out .= '<code>Piwik::isUserHasAdminAccess( array $idSites = array(1,2) )</code> = <b>' . self::boolToString(Piwik::isUserHasAdminAccess(array(1,2) )) . '</b><br/>';
$out .= '<code>Piwik::isUserHasViewAccess( array $idSites = array(1) ) </code> = <b>' . self::boolToString(Piwik::isUserHasViewAccess(array(1))) . '</b><br/>';
$out .= '<code>Piwik::isUserIsSuperUser()</code> = <b>' . self::boolToString(Piwik::isUserIsSuperUser()) . '</b><br/>';
$out .= '<h2>Execute SQL queries</h2>';
$txtQuery = "SELECT token_auth FROM ".Piwik::prefixTable('user')." WHERE login = ?";
$result = Piwik_FetchOne($txtQuery, array('anonymous'));
$out .= '<code>Piwik_FetchOne("'.$txtQuery.'", array("anonymous"))</code> = <b>' . var_export($result,true) . '</b><br/>';
$out .= '<br>';
$query = Piwik_Query($txtQuery, array('anonymous'));
$fetched = $query->fetch();
$token_auth = $fetched['token_auth'];
$out .= '<code>$query = Piwik_Query("'.$txtQuery.'", array("anonymous"))</code><br>';
$out .= '<code>$fetched = $query->fetch();</code><br>';
$out .= 'At this point, we have: <code>$fetched[\'token_auth\'] == <b>'.var_export($token_auth,true) . '</b></code><br/>';
$out .= '<h2>Example Sites information API</h2>';
$out .= '<code>Piwik_SitesManager_API::getSitesWithViewAccess()</code> = <b><pre>' .var_export(Piwik_SitesManager_API::getSitesWithViewAccess(),true) . '</pre></b><br/>';
$out .= '<code>Piwik_SitesManager_API::getSitesWithAdminAccess()</code> = <b><pre>' .var_export(Piwik_SitesManager_API::getSitesWithAdminAccess(),true) . '</pre></b><br/>';
$out .= '<h2>Example API Users information</h2>';
$out .= 'View the list of API methods you can call on <a href="http://dev.piwik.org/trac/wiki/API/Reference#Methods">API reference</a><br/>';
$out .= 'For example you can try <code>Piwik_UsersManager_API::getUsersSitesFromAccess("view");</code> or <code>Piwik_UsersManager_API::deleteUser("userToDelete");</code><br/>';
$out .= '<h2>Smarty plugins</h2>';
$out .= 'There are some builtin plugins for Smarty especially developped for Piwik. <br>
You can find them on the <a href="http://dev.piwik.org/trac/browser/trunk/core/SmartyPlugins">SVN at /trunk/core/SmartyPlugins</a>. <br>
More documentation to come about smarty plugins.<br/>';
echo $out;
}
示例5: test_getSitesWithAdminAccess
/**
* normal case, admin and view and noaccess website => return only admin
*/
function test_getSitesWithAdminAccess()
{
$idsite = Piwik_SitesManager_API::addSite("site1", array("http://piwik.net", "http://piwik.com/test/"));
$idsite = Piwik_SitesManager_API::addSite("site2", array("http://piwik.com/test/"));
$idsite = Piwik_SitesManager_API::addSite("site3", array("http://piwik.org"));
$resultWanted = array(0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net"), 1 => array("idsite" => 3, "name" => "site3", "main_url" => "http://piwik.org"));
FakeAccess::setIdSitesAdmin(array(1, 3));
$sites = Piwik_SitesManager_API::getSitesWithAdminAccess();
// we dont test the ts_created
unset($sites[0]['ts_created']);
unset($sites[1]['ts_created']);
$this->assertEqual($sites, $resultWanted);
}