Esempio n. 1
0
 /**
  * Initializes this component.
  *
  * @param Connector $connector The connector signed in.
  * @param string $login The login of the user to load data, if null, it will take the signed in user.
  * @throws \Exception If the Connector is not signed in.
  */
 public function __construct(Connector $connector, $login = null)
 {
     $connector->checkSignedIn();
     $this->connector = $connector;
     // Retrieving information about the specified user or signed in user
     if ($login == null) {
         $url = str_replace('{LOGIN}', $this->connector->getUser()->getLogin(), self::URL_NETSOUL);
     } else {
         $url = str_replace('{LOGIN}', $login, self::URL_NETSOUL);
     }
     $response = $this->connector->request($url);
     $this->data = DataExtractor::retrieve($response);
     // Parsing the data
     $logs = array();
     foreach ($this->data as $log) {
         // Building the dates
         $datetime = null;
         if ($timestamp = DataExtractor::extract($log, array(0))) {
             $datetime = new \DateTime();
             $datetime->setTimestamp($timestamp);
         }
         // Building the log
         $log = array('timestamp' => $timestamp, 'datetime' => $datetime, 'time_active' => DataExtractor::extract($log, array(1)), 'time_inactive' => DataExtractor::extract($log, array(2)), 'timeout_active' => DataExtractor::extract($log, array(3)), 'timeout_inactive' => DataExtractor::extract($log, array(4)), 'time_average' => DataExtractor::extract($log, array(5)));
         // Adding the log the temporary array
         $logs[$log['timestamp']] = $log;
     }
     // Replace the temporary array
     $this->data = $logs;
 }
Esempio n. 2
0
 /**
  * Initializes this component.
  *
  * @param Connector $connector The Connector signed in.
  * @param int $school_year The school year.
  * @param string $code_module The module code.
  * @param string $code_instance The instance code.
  */
 public function __construct(Connector $connector, $school_year, $code_module, $code_instance)
 {
     $connector->checkSignedIn();
     $this->connector = $connector;
     // Retrieving information about the module
     $url = str_replace(array('{SCHOOL_YEAR}', '{CODE_MODULE}', '{CODE_INSTANCE}'), array($school_year, $code_module, $code_instance), self::URL_MODULE);
     $response = $this->connector->request($url);
     $this->data = DataExtractor::retrieve($response);
 }
Esempio n. 3
0
 /**
  * Initializes this component.
  *
  * @param Connector $connector The connector signed in.
  * @param string $login The login of the user to load data, if null, it will take the signed in user.
  * @throws \Exception If the Connector is not signed in.
  */
 public function __construct(Connector $connector, $login = null)
 {
     $connector->checkSignedIn();
     $this->connector = $connector;
     // Retrieving information about the specified user or signed in user
     if ($login == null) {
         $url = self::URL_SIGNED_IN_USER;
     } else {
         $url = str_replace('{LOGIN}', $login, self::URL_USER);
     }
     $response = $this->connector->request($url);
     $this->data = DataExtractor::retrieve($response);
 }