本文整理汇总了PHP中Piwik\Piwik::isUserHasViewAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::isUserHasViewAccess方法的具体用法?PHP Piwik::isUserHasViewAccess怎么用?PHP Piwik::isUserHasViewAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::isUserHasViewAccess方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefaultReport
/**
* Returns default site ID that Piwik should load.
*
* _Note: This value is a Piwik setting set by each user._
*
* @return bool|int
* @api
*/
public function getDefaultReport()
{
// User preference: default website ID to load
$defaultReport = $this->api->getUserPreference(Piwik::getCurrentUserLogin(), APIUsersManager::PREFERENCE_DEFAULT_REPORT);
if (!is_numeric($defaultReport)) {
return $defaultReport;
}
if ($defaultReport && Piwik::isUserHasViewAccess($defaultReport)) {
return $defaultReport;
}
return false;
}
示例2: getDefaultWebsiteId
/**
* Returns default site ID that Piwik should load.
*
* _Note: This value is a Piwik setting set by each user._
*
* @return bool|int
* @api
*/
public function getDefaultWebsiteId()
{
$defaultWebsiteId = false;
// User preference: default website ID to load
$defaultReport = APIUsersManager::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), APIUsersManager::PREFERENCE_DEFAULT_REPORT);
if (is_numeric($defaultReport)) {
$defaultWebsiteId = $defaultReport;
}
if ($defaultWebsiteId && Piwik::isUserHasViewAccess($defaultWebsiteId)) {
return $defaultWebsiteId;
}
$sitesId = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
if (!empty($sitesId)) {
return $sitesId[0];
}
return false;
}
示例3: isUserCanAddNewSegment
public function isUserCanAddNewSegment($idSite)
{
if (Piwik::isUserIsAnonymous()) {
return false;
}
$requiredAccess = Config::getInstance()->General['adding_segment_requires_access'];
$authorized = $requiredAccess == 'view' && Piwik::isUserHasViewAccess($idSite) || $requiredAccess == 'admin' && Piwik::isUserHasAdminAccess($idSite) || $requiredAccess == 'superuser' && Piwik::hasUserSuperUserAccess();
return $authorized;
}
示例4: getSegmentsMetadata
public function getSegmentsMetadata($idSites = array(), $_hideImplementationData = true)
{
$segments = array();
foreach (Dimension::getAllDimensions() as $dimension) {
foreach ($dimension->getSegments() as $segment) {
$segments[] = $segment->toArray();
}
}
/**
* Triggered when gathering all available segment dimensions.
*
* This event can be used to make new segment dimensions available.
*
* **Example**
*
* public function getSegmentsMetadata(&$segments, $idSites)
* {
* $segments[] = array(
* 'type' => 'dimension',
* 'category' => Piwik::translate('General_Visit'),
* 'name' => 'General_VisitorIP',
* 'segment' => 'visitIp',
* 'acceptedValues' => '13.54.122.1, etc.',
* 'sqlSegment' => 'log_visit.location_ip',
* 'sqlFilter' => array('Piwik\IP', 'P2N'),
* 'permission' => $isAuthenticatedWithViewAccess,
* );
* }
*
* @param array &$dimensions The list of available segment dimensions. Append to this list to add
* new segments. Each element in this list must contain the
* following information:
*
* - **type**: Either `'metric'` or `'dimension'`. `'metric'` means
* the value is a numeric and `'dimension'` means it is
* a string. Also, `'metric'` values will be displayed
* under **Visit (metrics)** in the Segment Editor.
* - **category**: The segment category name. This can be an existing
* segment category visible in the segment editor.
* - **name**: The pretty name of the segment. Can be a translation token.
* - **segment**: The segment name, eg, `'visitIp'` or `'searches'`.
* - **acceptedValues**: A string describing one or two exacmple values, eg
* `'13.54.122.1, etc.'`.
* - **sqlSegment**: The table column this segment will segment by.
* For example, `'log_visit.location_ip'` for the
* **visitIp** segment.
* - **sqlFilter**: A PHP callback to apply to segment values before
* they are used in SQL.
* - **permission**: True if the current user has view access to this
* segment, false if otherwise.
* @param array $idSites The list of site IDs we're getting the available segments
* for. Some segments (such as Goal segments) depend on the
* site.
*/
Piwik::postEvent('API.getSegmentDimensionMetadata', array(&$segments, $idSites));
$isAuthenticatedWithViewAccess = Piwik::isUserHasViewAccess($idSites) && !Piwik::isUserIsAnonymous();
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_UserId', 'segment' => 'userId', 'acceptedValues' => 'any non empty unique string identifying the user (such as an email address or a username).', 'sqlSegment' => 'log_visit.idvisitor', 'sqlFilterValue' => array('Piwik\\Common', 'convertUserIdToVisitorIdBin'), 'sqlFilter' => array($this, 'checkSegmentMatchTypeIsValidForUser'), 'permission' => $isAuthenticatedWithViewAccess);
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_VisitorID', 'segment' => 'visitorId', 'acceptedValues' => '34c31e04394bdc63 - any 16 Hexadecimal chars ID, which can be fetched using the Tracking API function getVisitorId()', 'sqlSegment' => 'log_visit.idvisitor', 'sqlFilterValue' => array('Piwik\\Common', 'convertVisitorIdToBin'), 'permission' => $isAuthenticatedWithViewAccess);
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => Piwik::translate('General_Visit') . " ID", 'segment' => 'visitId', 'acceptedValues' => 'Any integer. ', 'sqlSegment' => 'log_visit.idvisit', 'permission' => $isAuthenticatedWithViewAccess);
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_VisitorIP', 'segment' => 'visitIp', 'acceptedValues' => '13.54.122.1. </code>Select IP ranges with notation: <code>visitIp>13.54.122.0;visitIp<13.54.122.255', 'sqlSegment' => 'log_visit.location_ip', 'sqlFilterValue' => array('Piwik\\IP', 'P2N'), 'permission' => $isAuthenticatedWithViewAccess);
foreach ($segments as &$segment) {
$segment['name'] = Piwik::translate($segment['name']);
$segment['category'] = Piwik::translate($segment['category']);
if ($_hideImplementationData) {
unset($segment['sqlFilter']);
unset($segment['sqlFilterValue']);
unset($segment['sqlSegment']);
}
}
usort($segments, array($this, 'sortSegments'));
return $segments;
}
示例5: getSegmentsMetadata
public function getSegmentsMetadata($idSites = array(), $_hideImplementationData = true)
{
$isAuthenticatedWithViewAccess = Piwik::isUserHasViewAccess($idSites) && !Piwik::isUserIsAnonymous();
$segments = array();
foreach (Dimension::getAllDimensions() as $dimension) {
foreach ($dimension->getSegments() as $segment) {
if ($segment->isRequiresAtLeastViewAccess()) {
$segment->setPermission($isAuthenticatedWithViewAccess);
}
$segments[] = $segment->toArray();
}
}
/**
* Triggered when gathering all available segment dimensions.
*
* This event can be used to make new segment dimensions available.
*
* **Example**
*
* public function getSegmentsMetadata(&$segments, $idSites)
* {
* $segments[] = array(
* 'type' => 'dimension',
* 'category' => Piwik::translate('General_Visit'),
* 'name' => 'General_VisitorIP',
* 'segment' => 'visitIp',
* 'acceptedValues' => '13.54.122.1, etc.',
* 'sqlSegment' => 'log_visit.location_ip',
* 'sqlFilter' => array('Piwik\IP', 'P2N'),
* 'permission' => $isAuthenticatedWithViewAccess,
* );
* }
*
* @param array &$dimensions The list of available segment dimensions. Append to this list to add
* new segments. Each element in this list must contain the
* following information:
*
* - **type**: Either `'metric'` or `'dimension'`. `'metric'` means
* the value is a numeric and `'dimension'` means it is
* a string. Also, `'metric'` values will be displayed
* under **Visit (metrics)** in the Segment Editor.
* - **category**: The segment category name. This can be an existing
* segment category visible in the segment editor.
* - **name**: The pretty name of the segment. Can be a translation token.
* - **segment**: The segment name, eg, `'visitIp'` or `'searches'`.
* - **acceptedValues**: A string describing one or two exacmple values, eg
* `'13.54.122.1, etc.'`.
* - **sqlSegment**: The table column this segment will segment by.
* For example, `'log_visit.location_ip'` for the
* **visitIp** segment.
* - **sqlFilter**: A PHP callback to apply to segment values before
* they are used in SQL.
* - **permission**: True if the current user has view access to this
* segment, false if otherwise.
* @param array $idSites The list of site IDs we're getting the available segments
* for. Some segments (such as Goal segments) depend on the
* site.
*/
Piwik::postEvent('API.getSegmentDimensionMetadata', array(&$segments, $idSites));
foreach ($segments as &$segment) {
$segment['name'] = Piwik::translate($segment['name']);
$segment['category'] = Piwik::translate($segment['category']);
if ($_hideImplementationData) {
unset($segment['sqlFilter']);
unset($segment['sqlFilterValue']);
unset($segment['sqlSegment']);
}
}
usort($segments, array($this, 'sortSegments'));
return $segments;
}
示例6: canUserAddNotesFor
/**
* Returns true if the current user can add notes for a specific site.
*
* @param int $idSite The site to add notes to.
* @return bool
*/
public static function canUserAddNotesFor($idSite)
{
return Piwik::isUserHasViewAccess($idSite) && !Piwik::isUserIsAnonymous();
}
示例7: getSegmentsMetadata
public function getSegmentsMetadata($idSites = array(), $_hideImplementationData = true)
{
$segments = array();
/**
* Triggered when gathering all available segment dimensions.
*
* This event can be used to make new segment dimensions available.
*
* **Example**
*
* public function getSegmentsMetadata(&$segments, $idSites)
* {
* $segments[] = array(
* 'type' => 'dimension',
* 'category' => Piwik::translate('General_Visit'),
* 'name' => 'General_VisitorIP',
* 'segment' => 'visitIp',
* 'acceptedValues' => '13.54.122.1, etc.',
* 'sqlSegment' => 'log_visit.location_ip',
* 'sqlFilter' => array('Piwik\IP', 'P2N'),
* 'permission' => $isAuthenticatedWithViewAccess,
* );
* }
*
* @param array &$dimensions The list of available segment dimensions. Append to this list to add
* new segments. Each element in this list must contain the
* following information:
*
* - **type**: Either `'metric'` or `'dimension'`. `'metric'` means
* the value is a numeric and `'dimension'` means it is
* a string. Also, `'metric'` values will be displayed
* under **Visit (metrics)** in the Segment Editor.
* - **category**: The segment category name. This can be an existing
* segment category visible in the segment editor.
* - **name**: The pretty name of the segment. Can be a translation token.
* - **segment**: The segment name, eg, `'visitIp'` or `'searches'`.
* - **acceptedValues**: A string describing one or two exacmple values, eg
* `'13.54.122.1, etc.'`.
* - **sqlSegment**: The table column this segment will segment by.
* For example, `'log_visit.location_ip'` for the
* **visitIp** segment.
* - **sqlFilter**: A PHP callback to apply to segment values before
* they are used in SQL.
* - **permission**: True if the current user has view access to this
* segment, false if otherwise.
* @param array $idSites The list of site IDs we're getting the available segments
* for. Some segments (such as Goal segments) depend on the
* site.
*/
Piwik::postEvent('API.getSegmentDimensionMetadata', array(&$segments, $idSites));
$isAuthenticatedWithViewAccess = Piwik::isUserHasViewAccess($idSites) && !Piwik::isUserIsAnonymous();
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_VisitorID', 'segment' => 'visitorId', 'acceptedValues' => '34c31e04394bdc63 - any 16 Hexadecimal chars ID, which can be fetched using the Tracking API function getVisitorId()', 'sqlSegment' => 'log_visit.idvisitor', 'sqlFilterValue' => array('Piwik\\Common', 'convertVisitorIdToBin'), 'permission' => $isAuthenticatedWithViewAccess);
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => Piwik::translate('General_Visit') . " ID", 'segment' => 'visitId', 'acceptedValues' => 'Any integer. ', 'sqlSegment' => 'log_visit.idvisit', 'permission' => $isAuthenticatedWithViewAccess);
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_VisitorIP', 'segment' => 'visitIp', 'acceptedValues' => '13.54.122.1. </code>Select IP ranges with notation: <code>visitIp>13.54.122.0;visitIp<13.54.122.255', 'sqlSegment' => 'log_visit.location_ip', 'sqlFilterValue' => array('Piwik\\IP', 'P2N'), 'permission' => $isAuthenticatedWithViewAccess);
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_NbActions', 'segment' => 'actions', 'sqlSegment' => 'log_visit.visit_total_actions');
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_NbSearches', 'segment' => 'searches', 'sqlSegment' => 'log_visit.visit_total_searches', 'acceptedValues' => 'To select all visits who used internal Site Search, use: &segment=searches>0');
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_ColumnVisitDuration', 'segment' => 'visitDuration', 'sqlSegment' => 'log_visit.visit_total_time');
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => Piwik::translate('General_VisitType'), 'segment' => 'visitorType', 'acceptedValues' => 'new, returning, returningCustomer' . ". " . Piwik::translate('General_VisitTypeExample', '"&segment=visitorType==returning,visitorType==returningCustomer"'), 'sqlSegment' => 'log_visit.visitor_returning', 'sqlFilterValue' => function ($type) {
return $type == "new" ? 0 : ($type == "returning" ? 1 : 2);
});
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_DaysSinceLastVisit', 'segment' => 'daysSinceLastVisit', 'sqlSegment' => 'log_visit.visitor_days_since_last');
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_DaysSinceFirstVisit', 'segment' => 'daysSinceFirstVisit', 'sqlSegment' => 'log_visit.visitor_days_since_first');
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_NumberOfVisits', 'segment' => 'visitCount', 'sqlSegment' => 'log_visit.visitor_count_visits');
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_VisitConvertedGoal', 'segment' => 'visitConverted', 'acceptedValues' => '0, 1', 'sqlSegment' => 'log_visit.visit_goal_converted');
$segments[] = array('type' => 'dimension', 'category' => Piwik::translate('General_Visit'), 'name' => Piwik::translate('General_EcommerceVisitStatusDesc'), 'segment' => 'visitEcommerceStatus', 'acceptedValues' => implode(", ", self::$visitEcommerceStatus) . '. ' . Piwik::translate('General_EcommerceVisitStatusEg', '"&segment=visitEcommerceStatus==ordered,visitEcommerceStatus==orderedThenAbandonedCart"'), 'sqlSegment' => 'log_visit.visit_goal_buyer', 'sqlFilterValue' => __NAMESPACE__ . '\\API::getVisitEcommerceStatus');
$segments[] = array('type' => 'metric', 'category' => Piwik::translate('General_Visit'), 'name' => 'General_DaysSinceLastEcommerceOrder', 'segment' => 'daysSinceLastEcommerceOrder', 'sqlSegment' => 'log_visit.visitor_days_since_order');
foreach ($segments as &$segment) {
$segment['name'] = Piwik::translate($segment['name']);
$segment['category'] = Piwik::translate($segment['category']);
if ($_hideImplementationData) {
unset($segment['sqlFilter']);
unset($segment['sqlFilterValue']);
unset($segment['sqlSegment']);
}
}
usort($segments, array($this, 'sortSegments'));
return $segments;
}
示例8: view
/**
* Main method
*/
public function view()
{
/** List of available groups */
$groups = array();
$conf = self::conf();
$d = dir($conf['logPath']);
/** Fix by Kowalikus: get the list of sites the current user has view access to */
$idSite = (int) Common::getRequestVar('idSite');
if (Piwik::isUserHasViewAccess($idSite) === false) {
return false;
}
while (($dir = $d->read()) !== false) {
if ($dir[0] === '.' || !is_dir($d->path . $dir)) {
continue;
}
$pos = strpos($dir, ',');
if ($pos === false) {
continue;
}
$site = (int) substr($dir, 0, $pos);
/** Fix by Kowalikus: check if current user has view access */
if ($site !== $idSite) {
continue;
}
$groups[] = '<option value="' . $dir . '">' . ($pos === false ? $dir : substr($dir, $pos + 1)) . '</option>';
}
$d->close();
/** Sort groups in alphabetical order */
sort($groups);
$__selectGroups = implode("\n", $groups);
/** Screen sizes */
$__selectScreens = '';
for ($i = 0; $i < count($conf['__screenSizes']); $i++) {
$__selectScreens .= '<option value="' . $conf['__screenSizes'][$i] . '">' . ($conf['__screenSizes'][$i] === 0 ? Piwik::Translate('ClickHeat_LANG_ALL') : $conf['__screenSizes'][$i] . 'px') . '</option>';
}
/** Browsers */
$__selectBrowsers = '';
foreach ($conf['__browsersList'] as $label => $name) {
$__selectBrowsers .= '<option value="' . $label . '">' . ($label === 'all' ? Piwik::Translate('ClickHeat_LANG_ALL') : ($label === 'unknown' ? Piwik::Translate('ClickHeat_LANG_UNKNOWN') : $name)) . '</option>';
}
/** Date */
$date = strtotime(Common::getRequestVar('date'));
if ($date === false) {
if ($conf['yesterday'] === true) {
$date = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
} else {
$date = time();
}
}
$__day = (int) date('d', $date);
$__month = (int) date('m', $date);
$__year = (int) date('Y', $date);
$range = Common::getRequestVar('period');
$range = $range[0];
if (!in_array($range, array('d', 'm', 'w'))) {
$range = 'd';
}
if ($range === 'w') {
$startDay = $conf['start'] === 'm' ? 1 : 0;
while (date('w', $date) != $startDay) {
$date = mktime(0, 0, 0, date('m', $date), date('d', $date) - 1, date('Y', $date));
}
$__day = (int) date('d', $date);
$__month = (int) date('m', $date);
$__year = (int) date('Y', $date);
} elseif ($range === 'm') {
$__day = 1;
}
$view = new View('@ClickHeat/view');
$view->assign('clickheat_host', 'http://' . $_SERVER['SERVER_NAME']);
$view->assign('clickheat_path', CLICKHEAT_PATH);
$view->assign('clickheat_index', CLICKHEAT_INDEX_PATH);
//$view->assign('clickheat_group', LANG_GROUP);
$view->assign('clickheat_groups', $__selectGroups);
//$view->assign('clickheat_browser', LANG_BROWSER);
$view->assign('clickheat_browsers', $__selectBrowsers);
//$view->assign('clickheat_screen', LANG_SCREENSIZE);
$view->assign('clickheat_screens', $__selectScreens);
//$view->assign('clickheat_heatmap', LANG_HEATMAP);
$view->clickheat_loading = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_ERROR_LOADING'));
$view->clickheat_cleaner = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_CLEANER_RUNNING'));
$view->clickheat_admincookie = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_JAVASCRIPT_ADMIN_COOKIE'));
$view->clickheat_alpha = $conf['alpha'];
$view->clickheat_iframes = $conf['hideIframes'] === true ? 'true' : 'false';
$view->clickheat_flashes = $conf['hideFlashes'] === true ? 'true' : 'false';
$view->clickheat_force_heatmap = $conf['heatmap'] === true ? ' checked="checked"' : '';
$view->clickheat_jsokay = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_ERROR_JAVASCRIPT'));
$view->clickheat_day = $__day;
$view->clickheat_month = $__month;
$view->clickheat_year = $__year;
$view->clickheat_range = $range;
$view->clickheat_menu = '<a href="#" onclick="adminCookie(); return false;">' . Piwik::Translate('ClickHeat_LANG_LOG_MY_CLICKS') . '</a><br /><a href="#" onclick="showJsCode(); return false;">Javascript</a>';
echo $view->render();
}