Commit 504c431a0cd11f88ed6353a97c5159d15f9b7435

Authored by Benjamin Renard
1 parent 80861345

Fix AmdaStats

Showing 1 changed file with 7 additions and 4 deletions   Show diff stats
php/classes/AmdaStats.php
... ... @@ -16,13 +16,13 @@ class AmdaStats {
16 16 private $task = array('request'=>'plot','condition'=>'mining', 'download'=>'print','statistic'=>'statistics',
17 17 'getparameter'=>'ws_print', 'getdataset' => 'ws_print', 'getorbites' => 'ws_print', 'getplot' => 'ws_plot');
18 18  
19   - public function __construct($user) {
  19 + public function __construct($user, $year = NULL) {
20 20 if (!is_dir(DATAPATH.'Statistics')) {
21 21 if (!mkdir(DATAPATH.'Statistics', 0775)) $this->success = false; //return -1;
22 22 if (!chgrp(DATAPATH.'Statistics', APACHE_USER)) $this->success = false; // return -1;
23 23 }
24 24  
25   - $this->statsFilePath = $this->getStatsFilePath($user);
  25 + $this->statsFilePath = $this->getStatsFilePath($user, $year);
26 26 }
27 27  
28 28 public function addTask($user, $task, $vars) {
... ... @@ -45,8 +45,11 @@ class AmdaStats {
45 45 return $this->concurrentAccessGuestFile(array($this,'_mergeStats'), array('inXml' => $inXml));
46 46 }
47 47  
48   - private function getStatsFilePath($user) {
49   - $thisYear = date("Y");
  48 + private function getStatsFilePath($user, $year) {
  49 + if (!isset($year))
  50 + $thisYear = date("Y");
  51 + else
  52 + $thisYear = $year;
50 53 if (empty($user)){
51 54 return DATAPATH."Statistics/Stats$thisYear.xml";
52 55 }
... ...