Пример #1
0
 protected function buildResult(Application $app, $rs)
 {
     $i = 0;
     foreach ($rs as $row) {
         if ($i >= $this->nb_record) {
             break;
         }
         foreach ($this->champ as $key => $value) {
             if ($row[$value]) {
                 if ($value == 'date') {
                     $this->result[$i][$value] = $this->pretty_string ? $app['date-formatter']->getPrettyString(new DateTime($row[$value])) : $row[$value];
                 } elseif ($value == 'size') {
                     $this->result[$i][$value] = p4string::format_octets($row[$value]);
                 } else {
                     $this->result[$i][$value] = $row[$value];
                 }
             } else {
                 if ($value == 'comment') {
                     $this->result[$i][$value] = ' ';
                 } else {
                     $this->result[$i][$value] = '<i>' . $this->app->trans('report:: non-renseigne') . '</i>';
                 }
             }
         }
         $i++;
     }
 }
Пример #2
0
 public function testFormat_octets()
 {
     $size = 1024;
     $this->assertEquals('1 ko', p4string::format_octets($size));
     $size = 824;
     $this->assertEquals('824 o', p4string::format_octets($size));
     $size = 102;
     $this->assertEquals('102 o', p4string::format_octets($size));
     $size = 10245335;
     $this->assertRegExp('/^9[,\\.]{1}77 Mo$/', p4string::format_octets($size));
     $size = 10245335;
     $this->assertRegExp('/^9[,\\.]{1}771 Mo$/', p4string::format_octets($size, 3));
     $this->assertEquals('10 Mo', p4string::format_octets($size, 0));
     $size = 9990245335123153;
     $this->assertRegexp('/^9086[,\\.]{1}08 To$/', p4string::format_octets($size));
     $size = 2048;
     $this->assertEquals('2 ko', p4string::format_octets($size));
 }
Пример #3
0
 /**
  *
  * @param  record_adapter $record
  * @return array
  */
 private function check_record_constraints(record_adapter $record)
 {
     $errors = [];
     if (!$record->get_hd_file() instanceof \SplFileInfo) {
         $errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique");
     }
     //Record must rely on real file
     if ($record->get_duration() > self::AUTH_VIDEO_DURATION) {
         $errors["duration"] = $this->translator->trans("La taille maximale d'une video est de %duration% minutes.", ['%duration%' => self::AUTH_VIDEO_DURATION / 60]);
     }
     if ($record->get_technical_infos('size') > self::AUTH_VIDEO_SIZE) {
         $errors["size"] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", ['%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE)]);
     }
     return $errors;
 }
Пример #4
0
 private function formatResult($column, $value, $i)
 {
     if ($value) {
         if ($column == 'coll_id') {
             $this->result[$i][$column] = $this->formatCollId($value);
         } elseif ($column == 'ddate') {
             $this->result[$i][$column] = $this->formatDateValue($value);
         } elseif ($column == 'size') {
             $this->result[$i][$column] = p4string::format_octets($value);
         } else {
             $this->result[$i][$column] = $value;
         }
     } else {
         if ($column == 'comment') {
             $this->result[$i][$column] = '';
         } else {
             $this->result[$i][$column] = $this->formatEmptyValue();
         }
     }
 }
Пример #5
0
 /**
  * Render the html upload form
  *
  * @param Application $app     A Silex application
  * @param Request     $request The current request
  *
  * @return Response
  */
 public function getUploadForm(Application $app, Request $request)
 {
     $maxFileSize = $this->getUploadMaxFileSize();
     return $app['twig']->render('prod/upload/upload.html.twig', ['collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())), 'maxFileSize' => $maxFileSize, 'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)]);
 }
Пример #6
0
 public function getUploadForm()
 {
     $maxFileSize = $this->getUploadMaxFileSize();
     return $this->render('prod/upload/upload.html.twig', ['collections' => $this->getGrantedCollections($this->getAclForUser()), 'maxFileSize' => $maxFileSize, 'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)]);
 }
Пример #7
0
 /**
  * Get the deail of download by users
  *
  * @param array  $tab config for the html table
  * @param String $on
  *
  * @return array
  */
 public function getDetailDownload($tab = false, $on = "")
 {
     empty($on) ? $on = "user" : "";
     //by default always report on user
     //set title
     $this->title = $this->app->trans('report:: Detail des telechargements');
     $sqlBuilder = new module_report_sql($this->app, $this);
     $filter = $sqlBuilder->getFilters()->getReportFilter();
     $params = array_merge([], $filter['params']);
     $sql = "\n            SELECT tt.usrid, TRIM(" . $on . ") AS " . $on . ", tt.final, sum(1) AS nb, sum(size) AS poid\n            FROM (\n                SELECT DISTINCT(log.id), TRIM(" . $on . ") AS " . $on . ", log_docs.record_id, log_docs.final, log.usrid\n                FROM log_docs\n                    INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)\n                    INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)\n                    INNER JOIN record ON (record.record_id = log_docs.record_id)\n                WHERE (" . $filter['sql'] . ")\n                AND (log_docs.action = 'download' OR log_docs.action = 'mail')\n            ) AS tt\n            LEFT JOIN subdef FORCE INDEX (unicite) ON (tt.record_id = subdef.record_id)\n            WHERE subdef.name = tt.final\n            GROUP BY " . $on . ", usrid\n            ORDER BY nb DESC;";
     $stmt = $sqlBuilder->getConnBas()->prepare($sql);
     $stmt->execute($params);
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $save_user = "";
     $i = -1;
     $total = ['nbdoc' => 0, 'poiddoc' => 0, 'nbprev' => 0, 'poidprev' => 0];
     $this->setChamp($rs);
     $this->setDisplay($tab);
     foreach ($rs as $row) {
         $user = $row[$on];
         if ($save_user != $user && !is_null($user) && !empty($user)) {
             if ($i >= 0) {
                 if ($this->result[$i]['nbprev'] + $this->result[$i]['nbdoc'] == 0 || $this->result[$i]['poiddoc'] + $this->result[$i]['poidprev'] == 0) {
                     unset($this->result[$i]);
                 }
                 if (isset($this->result[$i]['poiddoc']) && isset($this->result[$i]['poidprev'])) {
                     $this->result[$i]['poiddoc'] = p4string::format_octets($this->result[$i]['poiddoc']);
                     $this->result[$i]['poidprev'] = p4string::format_octets($this->result[$i]['poidprev']);
                 }
             }
             $i++;
             $this->result[$i]['nbprev'] = 0;
             $this->result[$i]['poidprev'] = 0;
             $this->result[$i]['nbdoc'] = 0;
             $this->result[$i]['poiddoc'] = 0;
         }
         //doc info
         if ($row['final'] == 'document' && !is_null($user) && !is_null($row['usrid'])) {
             $this->result[$i]['nbdoc'] = !is_null($row['nb']) ? $row['nb'] : 0;
             $this->result[$i]['poiddoc'] = !is_null($row['poid']) ? $row['poid'] : 0;
             $this->result[$i]['user'] = empty($row[$on]) ? "<i>" . $this->app->trans('report:: non-renseigne') . "</i>" : $row[$on];
             $total['nbdoc'] += $this->result[$i]['nbdoc'];
             $total['poiddoc'] += !is_null($row['poid']) ? $row['poid'] : 0;
             $this->result[$i]['usrid'] = $row['usrid'];
         }
         //preview info
         if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') && !is_null($user) && !is_null($row['usrid'])) {
             $this->result[$i]['nbprev'] += !is_null($row['nb']) ? $row['nb'] : 0;
             $this->result[$i]['poidprev'] += !is_null($row['poid']) ? $row['poid'] : 0;
             $this->result[$i]['user'] = empty($row[$on]) ? "<i>" . $this->app->trans('report:: non-renseigne') . "</i>" : $row[$on];
             $total['nbprev'] += !is_null($row['nb']) ? $row['nb'] : 0;
             $total['poidprev'] += !is_null($row['poid']) ? $row['poid'] : 0;
             $this->result[$i]['usrid'] = $row['usrid'];
         }
         $save_user = $user;
     }
     unset($this->result[$i]);
     $nb_row = $i + 1;
     $this->total = $nb_row;
     if ($this->total > 0) {
         $this->result[$nb_row]['user'] = '******';
         $this->result[$nb_row]['nbdoc'] = '<b>' . $total['nbdoc'] . '</b>';
         $this->result[$nb_row]['poiddoc'] = '<b>' . p4string::format_octets($total['poiddoc']) . '</b>';
         $this->result[$nb_row]['nbprev'] = '<b>' . $total['nbprev'] . '</b>';
         $this->result[$nb_row]['poidprev'] = '<b>' . p4string::format_octets($total['poidprev']) . '</b>';
     }
     $this->total = sizeof($this->result);
     $this->calculatePages();
     $this->setDisplayNav();
     $this->setReport();
     return $this->report;
 }
Пример #8
0
 /**
  *
  * @param  record_adapter $record
  * @return array
  */
 private function check_record_constraints(record_adapter $record)
 {
     $errors = [];
     //Record must rely on real file
     if (!$record->get_hd_file() instanceof \SplFileInfo) {
         $errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique");
     }
     $size = $record->get_technical_infos('size');
     $size = $size ? $size->getValue() : PHP_INT_MAX;
     if ($size > self::AUTH_PHOTO_SIZE) {
         $errors["size"] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", ['%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE)]);
     }
     return $errors;
 }