Exemplo n.º 1
0
 public function addMenus()
 {
     Piwik_AddMenu('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5);
     if (!Piwik::isUserIsAnonymous()) {
         $login = Piwik::getCurrentUserLogin();
         $dashboards = self::getAllDashboards($login);
         if (count($dashboards) > 1) {
             $pos = 0;
             foreach ($dashboards as $dashboard) {
                 Piwik_AddMenu('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos);
                 $pos++;
             }
         }
     }
 }
Exemplo n.º 2
0
 public function index()
 {
     $view = Piwik_View::factory('index');
     $this->setGeneralVariablesView($view);
     $view->countWebsites = count(Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess());
     // get report types
     $reportTypes = Piwik_PDFReports_API::getReportTypes();
     $view->reportTypes = $reportTypes;
     $view->defaultReportType = self::DEFAULT_REPORT_TYPE;
     $view->defaultReportFormat = Piwik_PDFReports::DEFAULT_REPORT_FORMAT;
     $reportsByCategoryByType = array();
     $reportFormatsByReportType = array();
     $allowMultipleReportsByReportType = array();
     foreach ($reportTypes as $reportType => $reportTypeIcon) {
         // get report formats
         $reportFormatsByReportType[$reportType] = Piwik_PDFReports_API::getReportFormats($reportType);
         $allowMultipleReportsByReportType[$reportType] = Piwik_PDFReports_API::allowMultipleReports($reportType);
         // get report metadata
         $reportsByCategory = array();
         $availableReportMetadata = Piwik_PDFReports_API::getReportMetadata($this->idSite, $reportType);
         foreach ($availableReportMetadata as $reportMetadata) {
             $reportsByCategory[$reportMetadata['category']][] = $reportMetadata;
         }
         $reportsByCategoryByType[$reportType] = $reportsByCategory;
     }
     $view->reportsByCategoryByReportType = $reportsByCategoryByType;
     $view->reportFormatsByReportType = $reportFormatsByReportType;
     $view->allowMultipleReportsByReportType = $allowMultipleReportsByReportType;
     $reports = array();
     $reportsById = array();
     if (!Piwik::isUserIsAnonymous()) {
         $reports = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
         foreach ($reports as &$report) {
             $report['recipients'] = Piwik_PDFReports_API::getReportRecipients($report);
             $reportsById[$report['idreport']] = $report;
         }
     }
     $view->reports = $reports;
     $view->reportsJSON = Piwik_Common::json_encode($reportsById);
     $view->downloadOutputType = Piwik_PDFReports_API::OUTPUT_INLINE;
     $periods = array_merge(array('never' => Piwik_Translate('General_Never')), Piwik_PDFReports::getPeriodToFrequency());
     // Do not display date range in selector
     unset($periods['range']);
     $view->periods = $periods;
     $view->defaultPeriod = Piwik_PDFReports::DEFAULT_PERIOD;
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     echo $view->render();
 }
Exemplo n.º 3
0
 /**
  * Returns true if Segmentation is allowed for this user
  * 
  * @return bool
  */
 public static function isSegmentationEnabled()
 {
     return !Piwik::isUserIsAnonymous() || Zend_Registry::get('config')->General->anonymous_user_enable_use_segments_API;
 }
Exemplo n.º 4
0
	/**
	 * Removes fields that are not meant to be displayed (md5 config hash)
	 * Or that the user should only access if he is super user or admin (cookie, IP)
	 *
	 * @return void
	 */
	private function cleanVisitorDetails( &$visitorDetails, $idSite )
	{
		$toUnset = array('config_id');
		if(Piwik::isUserIsAnonymous())
		{
			$toUnset[] = 'idvisitor';
			$toUnset[] = 'location_ip';
		}
		foreach($toUnset as $keyName)
		{
			if(isset($visitorDetails[$keyName]))
			{
				unset($visitorDetails[$keyName]);
			}
		}
	}
Exemplo n.º 5
0
	/**
	 * Get the dashboard layout for the current user (anonymous or loggued user) 
	 *
	 * @return string $layout
	 */
	protected function getLayout()
	{
		$idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int' );

		if(Piwik::isUserIsAnonymous())
		{
			$session = new Piwik_Session_Namespace("Piwik_Dashboard");
			if(!isset($session->dashboardLayout))
			{
				return false;
			}
			$layout = $session->dashboardLayout;
		}
		else
		{
			$layout = $this->getLayoutForUser(Piwik::getCurrentUserLogin(),$idDashboard);
		}
	
		// layout was JSON.stringified
		$layout = html_entity_decode($layout);
		$layout = str_replace("\\\"", "\"", $layout);

		// compatibility with the old layout format
		if(!empty($layout)
			&& strstr($layout, '[[') == false) {
			$layout = "'$layout'";
		}
		$layout = $this->removeDisabledPluginFromLayout($layout);
		return $layout;
	}
Exemplo n.º 6
0
 /**
  * Get the dashboard layout for the current user (anonymous or loggued user)
  *
  * @param int $idDashboard
  * @return string $layout
  */
 protected function getLayout($idDashboard)
 {
     if (Piwik::isUserIsAnonymous()) {
         $session = new Piwik_Session_Namespace("Piwik_Dashboard");
         if (!isset($session->dashboardLayout)) {
             return $this->getDefaultLayout();
         }
         $layout = $session->dashboardLayout;
     } else {
         $layout = $this->getLayoutForUser(Piwik::getCurrentUserLogin(), $idDashboard);
     }
     if (!empty($layout)) {
         $layout = $this->removeDisabledPluginFromLayout($layout);
     }
     if ($layout === false) {
         $layout = $this->getDefaultLayout();
     }
     return $layout;
 }
Exemplo n.º 7
0
 /**
  * Returns true if Segmentation is allowed for this user
  * 
  * @return bool
  */
 public static function isSegmentationEnabled()
 {
     return !Piwik::isUserIsAnonymous() || Piwik_Config::getInstance()->General['anonymous_user_enable_use_segments_API'];
 }
Exemplo n.º 8
0
 /**
  * Get the dashboard layout for the current user (anonymous or loggued user) 
  *
  * @return string $layout
  */
 protected function getLayout()
 {
     // Currently not used
     $idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int');
     if (Piwik::isUserIsAnonymous()) {
         $session = new Piwik_Session_Namespace("Piwik_Dashboard");
         if (!isset($session->dashboardLayout)) {
             return $this->getDefaultLayout();
         }
         $layout = $session->dashboardLayout;
     } else {
         $layout = $this->getLayoutForUser(Piwik::getCurrentUserLogin(), $idDashboard);
     }
     if (!empty($layout)) {
         // layout was JSON.stringified
         $layout = html_entity_decode($layout);
         $layout = str_replace("\\\"", "\"", $layout);
         $layout = $this->removeDisabledPluginFromLayout($layout);
     }
     return $layout;
 }
Exemplo n.º 9
0
 /**
  * @param Piwik_Event_Notification $notification notification object
  */
 public static function template_reportParametersPDFReports($notification)
 {
     if (Piwik::isUserIsAnonymous()) {
         return;
     }
     $out =& $notification->getNotificationObject();
     $view = Piwik_View::factory('ReportParameters');
     $view->reportType = self::MOBILE_TYPE;
     $view->phoneNumbers = Piwik_MobileMessaging_API::getInstance()->getActivatedPhoneNumbers();
     $out .= $view->render();
 }