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


PHP Piwik::checkUserHasAdminAccess方法代码示例

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


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

示例1: deleteGoal

 public function deleteGoal($idSite, $idGoal)
 {
     Piwik::checkUserHasAdminAccess($idSite);
     Piwik_Query("UPDATE " . Piwik::prefixTable('goal') . "\n\t\t\t\t\t\t\t\t\t\tSET deleted = 1\n\t\t\t\t\t\t\t\t\t\tWHERE idsite = ? \n\t\t\t\t\t\t\t\t\t\t\tAND idgoal = ?", array($idSite, $idGoal));
     Zend_Registry::get('db')->query("DELETE FROM " . Piwik::prefixTable("log_conversion") . " WHERE idgoal = ?", $idGoal);
     Piwik_Common::regenerateCacheWebsiteAttributes($idSite);
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:API.php

示例2: deleteGoal

 public function deleteGoal($idSite, $idGoal)
 {
     Piwik::checkUserHasAdminAccess($idSite);
     $where[] = 'idsite = ' . Zend_Registry::get('db')->quote($idSite);
     $where[] = 'idgoal = ' . Zend_Registry::get('db')->quote($idGoal);
     Zend_Registry::get('db')->update(Piwik::prefixTable('goal'), array('deleted' => 1), $where);
     Zend_Registry::get('db')->delete(Piwik::prefixTable("log_conversion"), "idgoal={$idGoal}");
     Piwik_Common::regenerateCacheWebsiteAttributes($idSite);
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:9,代码来源:API.php

示例3: 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 $userLogin The user login
  * @param string $access Access to grant. Must have one of the following value : noaccess, view, admin
  * @param int|array $idSites 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.
  * 
  * @throws Exception if the user doesn't exist
  * @throws Exception if the access parameter doesn't have a correct value
  * @throws Exception if any of the given website ID doesn't exist
  * 
  * @return bool true on success
  */
 public function setUserAccess($userLogin, $access, $idSites)
 {
     $this->checkAccessType($access);
     $this->checkUserExists($userLogin);
     $this->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::getInstance()->getSitesIdWithAdminAccess();
     } 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);
     $this->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_Common::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();
     Piwik_Common::deleteTrackerCache();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:49,代码来源:API.php

示例4: deleteFunnel

 public function deleteFunnel($idSite, $idGoal, $idFunnel)
 {
     Piwik::checkUserHasAdminAccess($idSite);
     Piwik_Query("UPDATE " . Piwik_Common::prefixTable('funnel') . "\n\t\t\t\t\t\t\t\t\t\tSET deleted = 1\n\t\t\t\t\t\t\t\t\t\tWHERE idsite = ? \n\t\t\t\t\t\t\t\t\t\tAND idgoal = ?\n\t\t\t\t\t\t\t\t\t\tAND idfunnel = ?", array($idSite, $idGoal, $idFunnel));
     Piwik_Common::regenerateCacheWebsiteAttributes($idSite);
 }
开发者ID:ep123,项目名称:funnels,代码行数:6,代码来源:API.php

示例5: deleteGoal

 /**
  * Soft deletes a given Goal.
  * Stats data in the archives will still be recorded, but not displayed.
  * 
  * @param int $idSite
  * @param int $idGoal
  * @return void
  */
 public function deleteGoal($idSite, $idGoal)
 {
     Piwik::checkUserHasAdminAccess($idSite);
     Piwik_Query("UPDATE " . Piwik_Common::prefixTable('goal') . "\n\t\t\t\t\t\t\t\t\t\tSET deleted = 1\n\t\t\t\t\t\t\t\t\t\tWHERE idsite = ? \n\t\t\t\t\t\t\t\t\t\t\tAND idgoal = ?", array($idSite, $idGoal));
     Piwik_DeleteAllRows(Piwik_Common::prefixTable("log_conversion"), "WHERE idgoal = ?", 100000, array($idGoal));
     Piwik_Common::regenerateCacheWebsiteAttributes($idSite);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:15,代码来源:API.php

示例6: updateSite

 /**
  * Update an existing website.
  * If only one URL is specified then only the main url will be updated.
  * If several URLs are specified, both the main URL and the alias URLs will be updated.
  * 
  * @param int website ID defining the website to edit
  * @param string website name
  * @param string|array the website URLs
  * 
  * @exception if any of the parameter is not correct
  * 
  * @return bool true on success
  */
 public static function updateSite($idSite, $siteName, $urls = null)
 {
     Piwik::checkUserHasAdminAccess($idSite);
     self::checkName($siteName);
     // SQL fields to update
     $bind = array();
     if (!is_null($urls)) {
         $urls = self::cleanParameterUrls($urls);
         self::checkUrls($urls);
         self::checkAtLeastOneUrl($urls);
         $url = $urls[0];
         $bind['main_url'] = $url;
     }
     $bind['name'] = $siteName;
     $db = Zend_Registry::get('db');
     $db->update(Piwik::prefixTable("site"), $bind, "idsite = {$idSite}");
     // we now update the main + alias URLs
     self::deleteSiteAliasUrls($idSite);
     if (count($urls) > 1) {
         $insertedUrls = self::addSiteAliasUrls($idSite, array_slice($urls, 1));
     }
     self::postUpdateWebsite($idSite);
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:36,代码来源:API.php

示例7: updateSite

	/**
	 * Update an existing website.
	 * If only one URL is specified then only the main url will be updated.
	 * If several URLs are specified, both the main URL and the alias URLs will be updated.
	 * 
	 * @param int website ID defining the website to edit
	 * @param string website name
	 * @param string|array the website URLs
	 * @param string Comma separated list of IPs to exclude from being tracked (allows wildcards)
	 * @param string Timezone
	 * @param string Currency code
	 * @param string Group name where this website belongs
	 * @param string Date at which the statistics for this website will start. Defaults to today's date in YYYY-MM-DD format
	 * 
	 * @exception if any of the parameter is not correct
	 * 
	 * @return bool true on success
	 */
	public function updateSite( $idSite, $siteName, $urls = null, $ecommerce = null, $excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null)
	{
		Piwik::checkUserHasAdminAccess($idSite);

		$idSites = Piwik_SitesManager_API::getInstance()->getSitesId();
		if(!in_array($idSite, $idSites))
		{
			throw new Exception("website id = $idSite not found");
		}

		$this->checkName($siteName);
		
		// SQL fields to update
		$bind = array();
		
		if(!is_null($urls))
		{
			$urls = $this->cleanParameterUrls($urls);
			$this->checkUrls($urls);
			$this->checkAtLeastOneUrl($urls);
			$url = $urls[0];
			
			$bind['main_url'] = $url;
		}

		if(!is_null($currency))
		{
			$currency = trim($currency);
			$this->checkValidCurrency($currency);
			$bind['currency'] = $currency;
		}
		if(!is_null($timezone))
		{
			$timezone = trim($timezone);
			$this->checkValidTimezone($timezone);
			$bind['timezone'] = $timezone;
		}
		if(!is_null($group)
			&& Piwik::isUserIsSuperUser())
		{
			$bind['group'] = trim($group);
		}
		if(!is_null($ecommerce))
		{
			$bind['ecommerce'] = (int)(bool)$ecommerce;
		}
		if(!is_null($startDate))
		{
			$bind['ts_created'] = Piwik_Date::factory($startDate)->getDatetime();
		}
		$bind['excluded_ips'] = $this->checkAndReturnExcludedIps($excludedIps);
		$bind['excluded_parameters'] = $this->checkAndReturnExcludedQueryParameters($excludedQueryParameters);
		$bind['name'] = $siteName;
		$db = Zend_Registry::get('db');
		$db->update(Piwik_Common::prefixTable("site"), 
							$bind,
							"idsite = $idSite"
								);
								
		// we now update the main + alias URLs
		$this->deleteSiteAliasUrls($idSite);
		if(count($urls) > 1)
		{
			$insertedUrls = $this->addSiteAliasUrls($idSite, array_slice($urls,1));
		}
		$this->postUpdateWebsite($idSite);
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:85,代码来源:API.php

示例8: invalidateArchivedReports

 /**
  * When tracking data in the past (using Tracking API), this function
  * can be used to invalidate reports for the idSites and dates where new data
  * was added. 
  * DEV: If you call this API, the UI should display the data correctly, but will process
  *      in real time, which could be very slow after large data imports. 
  *      After calling this function via REST, you can manually force all data 
  *      to be reprocessed by visiting the script as the Super User:
  *      http://example.net/piwik/misc/cron/archive.php?token_auth=$SUPER_USER_TOKEN_AUTH_HERE 
  * REQUIREMENTS: On large piwik setups, you will need in PHP configuration: max_execution_time = 0
  * 	We recommend to use an hourly schedule of the script at misc/cron/archive.php 
  * 	More information: http://piwik.org/setup-auto-archiving/
  * 
  * @param string $idSites Comma separated list of idSite that have had data imported for the specified dates
  * @param string $dates Comma separated list of dates to invalidate for all these websites
  * @return array
  */
 public function invalidateArchivedReports($idSites, $dates)
 {
     $idSites = Piwik_Site::getIdSitesFromIdSitesString($idSites);
     if (empty($idSites)) {
         throw new Exception("Specify a value for &idSites= as a comma separated list of website IDs, for which your token_auth has 'admin' permission");
     }
     Piwik::checkUserHasAdminAccess($idSites);
     // Ensure the specified dates are valid
     $toInvalidate = $invalidDates = array();
     $dates = explode(',', $dates);
     $dates = array_unique($dates);
     foreach ($dates as $theDate) {
         try {
             $date = Piwik_Date::factory($theDate);
         } catch (Exception $e) {
             $invalidDates[] = $theDate;
             continue;
         }
         if ($date->toString() == $theDate) {
             $toInvalidate[] = $date;
         } else {
             $invalidDates[] = $theDate;
         }
     }
     // Lookup archive tables
     $tables = Piwik::getTablesInstalled();
     $archiveTables = Piwik::getTablesArchivesInstalled();
     // If using the feature "Delete logs older than N days"...
     $logsAreDeletedBeforeThisDate = Piwik_Config::getInstance()->Deletelogs['delete_logs_schedule_lowest_interval'];
     $logsDeleteEnabled = Piwik_Config::getInstance()->Deletelogs['delete_logs_enable'];
     $minimumDateWithLogs = false;
     if ($logsDeleteEnabled && $logsAreDeletedBeforeThisDate) {
         $minimumDateWithLogs = Piwik_Date::factory('today')->subDay($logsAreDeletedBeforeThisDate);
     }
     // Given the list of dates, process which tables they should be deleted from
     $minDate = false;
     $warningDates = $processedDates = array();
     /* @var $date Piwik_Date */
     foreach ($toInvalidate as $date) {
         // we should only delete reports for dates that are more recent than N days
         if ($minimumDateWithLogs && $date->isEarlier($minimumDateWithLogs)) {
             $warningDates[] = $date->toString();
         } else {
             $processedDates[] = $date->toString();
         }
         $month = $date->toString('Y_m');
         // For a given date, we must invalidate in the monthly archive table
         $datesByMonth[$month][] = $date->toString();
         // But also the year stored in January
         $year = $date->toString('Y_01');
         $datesByMonth[$year][] = $date->toString();
         // but also weeks overlapping several months stored in the month where the week is starting
         /* @var $week Piwik_Period_Week */
         $week = Piwik_Period::factory('week', $date);
         $week = $week->getDateStart()->toString('Y_m');
         $datesByMonth[$week][] = $date->toString();
         // Keep track of the minimum date for each website
         if ($minDate === false || $date->isEarlier($minDate)) {
             $minDate = $date;
         }
     }
     // In each table, invalidate day/week/month/year containing this date
     $sqlIdSites = implode(",", $idSites);
     foreach ($archiveTables as $table) {
         // Extract Y_m from table name
         $suffix = str_replace(array('archive_numeric_', 'archive_blob_'), '', Piwik_Common::unprefixTable($table));
         if (!isset($datesByMonth[$suffix])) {
             continue;
         }
         // Dates which are to be deleted from this table
         $datesToDeleteInTable = $datesByMonth[$suffix];
         // Build one statement to delete all dates from the given table
         $sql = $bind = array();
         $datesToDeleteInTable = array_unique($datesToDeleteInTable);
         foreach ($datesToDeleteInTable as $dateToDelete) {
             $sql[] = '(date1 <= ? AND ? <= date2)';
             $bind[] = $dateToDelete;
             $bind[] = $dateToDelete;
         }
         $sql = implode(" OR ", $sql);
         $query = "DELETE FROM {$table} " . " WHERE ( {$sql} ) " . " AND idsite IN (" . $sqlIdSites . ")";
         Piwik_Query($query, $bind);
         //			var_dump($query);var_dump($bind);
//.........这里部分代码省略.........
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:101,代码来源:API.php


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