/** * Retrieve the current storage usage for the user that is signed in * * @return array ( array('free' => bytes, 'used' => bytes) ) */ public function getCurrentStorageUsageForSignedInUser() { $username = $this->user->getSignedInUsername(); $view = new FilesView('/' . $username . '/files'); $freeSpace = $view->free_space(); $usedSpace = $view->getFileInfo('/')->getSize(); return array('free' => $freeSpace, 'used' => $usedSpace); }
/** * Return the chart data you want to return based on the ChartConfig * * @param User $user * @param ActivityUsageRepository|StorageUsageRepository $repository * @param ChartConfig $chartConfig * @return mixed */ public function getChartUsage(User $user, $repository, ChartConfig $chartConfig) { if ($user->isAdminUser($user->getSignedInUsername())) { $data = $repository->findAllPerMonth(); } else { $data = $repository->findAllPerMonth($chartConfig->getUsername()); } return $data; }
/** * @param string $event */ public static function logActivity($event) { if (!self::$sendActivity) { return; } $user = new User(); $activity = new Activity($user->getSignedInUsername(), 'file:' . $event); self::$contentStatisticsClient->commit($activity); self::$contentStatisticsClient->push(); }
/** * Get a config by id * * @param integer $id * @return ChartConfig * @throws ChartConfigServiceException */ public function getChartConfigById($id) { $configs = $this->repository->findByUsername($this->user->getSignedInUsername()); foreach ($configs as $config) { if ($config->getId() == $id) { return $config; } } throw new ChartConfigServiceException("No config found for given id " . $id); }
/** * Return the chart data you want to return based on the ChartConfig * * @return array */ public function getChartUsage() { $return = array(); if ($this->user->isAdminUser($this->user->getSignedInUsername())) { $users = $this->users->getSystemUsers(); foreach ($users as $username) { $return[$username] = $this->getCollectionByUsername($username); } } else { $username = $this->chartConfig->getUsername(); $return[$username] = $this->getCollectionByUsername($username); } return $return; }
/** * Create default charts for the logged in user */ private function createDefaultChartsForLoggedInUser() { $this->chartCreator->createDefaultConfigFor($this->user->getSignedInUsername()); }