Merge branch 'master' of github.com:alchemy-fr/Phraseanet

This commit is contained in:
Romain Neutron
2012-02-08 11:24:46 +01:00
121 changed files with 1821 additions and 1520 deletions

93
builder.php Executable file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/env php
<?php
/*
* Build Phraseanet for download
*
*/
printf('Retrieve vendors ...' . PHP_EOL);
system('./vendors.php');
require_once __DIR__ . '/lib/classes/bootstrap.class.php';
\bootstrap::register_autoloads();
use Symfony\Component\Finder\Finder;
chdir(__DIR__);
set_time_limit(0);
printf('Remove files ...' . PHP_EOL);
$finder = new Finder();
$finder
->files()
->name('.gitmodules')
->name('.gitignore')
->name('check_cs.php')
->name('pom.xml')
->name('vendors.php')
->name('builder.php')
->ignoreDotFiles(false)
->ignoreVCS(false)
->in(__DIR__);
$files = array();
foreach ($finder as $file)
{
$files[] = $file->getPathname();
}
foreach ($files as $file)
{
echo "rm $file\n";
unlink($file);
}
$finder = new Finder();
$finder
->directories()
->name('test')
->name('tests')
->name('unitTest')
->name('demos')
->name('demo')
->name('example')
->name('examples')
->name('docs')
->name('documentation')
->name('doc')
->name('as-docs')
->name('hudson')
->name('.svn')
->name('.git')
->ignoreDotFiles(false)
->ignoreVCS(false)
->in(__DIR__);
$dirs = array();
foreach ($finder as $dir)
{
$dirs[] = $dir->getPathname();
}
foreach ($dirs as $dir)
{
if (!is_dir($dir))
{
continue;
}
$cmd = sprintf('rm -Rf %s' . PHP_EOL, escapeshellarg($dir));
printf($cmd);
system($cmd);
}
exit(0);

112
check_cs.php Executable file
View File

@@ -0,0 +1,112 @@
#!/usr/bin/env php
<?php
/*
* Coding Standards (a.k.a. CS)
*
* @Author Fabien Potencier
*
* @see https://github.com/symfony/symfony/blob/master/check_cs
*
* This script is designed to clean up the source files and thus follow coding
* conventions.
*
* @see http://symfony.com/doc/2.0/contributing/code/standards.html
*
*/
require_once __DIR__ . '/lib/bootstrap.php';
use Symfony\Component\Finder\Finder;
$fix = isset($argv[1]) && 'fix' == $argv[1];
$finder = new Finder();
$finder
->files()
->name('*.md')
->name('*.php')
->name('*.inc')
->name('*.php.dist')
->name('*.twig')
->name('*.xml')
->name('*.xml.dist')
->name('*.yml')
->in(
array(
__DIR__ . '/lib',
__DIR__ . '/bin',
__DIR__ . '/config',
__DIR__ . '/www',
__DIR__ . '/templates'
)
)
->notName(basename(__FILE__))
->exclude('.git')
->exclude('vendor')
;
$count = 0;
foreach ($finder as $file)
{
/* @var $file Symfony\Component\Finder\SplFileInfo */
$old = file_get_contents($file->getRealpath());
$new = $old;
// [Structure] Never use short tags (<?)
$new = str_replace('<? ', '<?php ', $new);
// [Structure] Indentation is done by steps of four spaces (tabs are never allowed)
$new = preg_replace_callback('/^( *)(\t+)/m', function ($matches) use ($new)
{
return $matches[1] . str_repeat(' ', strlen($matches[2]));
}, $new);
// [Structure] Use the linefeed character (0x0A) to end lines
$new = str_replace("\r\n", "\n", $new);
// [Structure] Don't add trailing spaces at the end of lines
$new = preg_replace('/[ \t]*$/m', '', $new);
// [Structure] Convert tabs to spaces
$new = preg_replace('/\t/m', ' ', $new);
// [Structure] Add a blank line before return statements
$new = preg_replace_callback('/(^.*$)\n(^ +return)/m', function ($match)
{
// don't add it if the previous line is ...
if (
preg_match('/\{$/m', $match[1]) || // ... ending with an opening brace
preg_match('/\:$/m', $match[1]) || // ... ending with a colon (e.g. a case statement)
preg_match('%^ *//%m', $match[1]) || // ... an inline comment
preg_match('/^$/m', $match[1]) // ... already blank
)
{
return $match[1] . "\n" . $match[2];
}
return $match[1] . "\n\n" . $match[2];
}, $new);
// [Structure] A file must always ends with a linefeed character
if (strlen($new) && "\n" != substr($new, -1))
{
$new .= "\n";
}
if ($new != $old)
{
$count++;
if ($fix)
{
file_put_contents($file->getRealpath(), $new);
}
printf('%4d) %s' . PHP_EOL, $count, $file->getRelativePathname());
}
}
exit($count ? 1 : 0);

View File

@@ -121,6 +121,7 @@ class ACL implements cache_cacheableInterface
$key = $record->get_serialize_key(); $key = $record->get_serialize_key();
if (array_key_exists($key, $this->_rights_records_document)) if (array_key_exists($key, $this->_rights_records_document))
return true; return true;
return false; return false;
@@ -188,6 +189,7 @@ class ACL implements cache_cacheableInterface
$key = $record->get_serialize_key(); $key = $record->get_serialize_key();
if (array_key_exists($key, $this->_rights_records_preview)) if (array_key_exists($key, $this->_rights_records_preview))
return true; return true;
return false; return false;
@@ -241,6 +243,7 @@ class ACL implements cache_cacheableInterface
public function apply_model(User_Interface $template_user, Array $base_ids) public function apply_model(User_Interface $template_user, Array $base_ids)
{ {
if (count($base_ids) == 0) if (count($base_ids) == 0)
return $this; return $this;
$sbas_ids = array(); $sbas_ids = array();
@@ -327,8 +330,16 @@ class ACL implements cache_cacheableInterface
// apply sb : unchecked boxes on template will be unchecked on user // apply sb : unchecked boxes on template will be unchecked on user
// checked boxes on template does nothing (left unchanged on user) // checked boxes on template does nothing (left unchanged on user)
// get masks from 64 bits int AS DECIMAL STRING to BINARY STRING // get masks from 64 bits int AS DECIMAL STRING to BINARY STRING
$mand = substr(str_repeat('0', 64) . databox_status::dec2bin($template_user->ACL()->get_mask_and($base_id)), -64);
$mxor = substr(str_repeat('0', 64) . databox_status::dec2bin($template_user->ACL()->get_mask_xor($base_id)), -64); $mask_and = $template_user->ACL()->get_mask_and($base_id);
$mask_xor = $template_user->ACL()->get_mask_xor($base_id);
$mask_and = ctype_digit($mask_and) ? $mask_and : '0';
$mask_xor = ctype_digit($mask_xor) ? $mask_xor : '0';
$mand = substr(str_repeat('0', 64) . databox_status::dec2bin($mask_and), -64);
$mxor = substr(str_repeat('0', 64) . databox_status::dec2bin($mask_xor), -64);
$m = array('aa' => '', 'ao' => '', 'xa' => '', 'xo' => ''); $m = array('aa' => '', 'ao' => '', 'xa' => '', 'xo' => '');
for ($i = 0; $i < 64; $i++) for ($i = 0; $i < 64; $i++)
{ {
@@ -382,6 +393,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
if ($this->is_limited($base_id)) if ($this->is_limited($base_id))
@@ -469,6 +481,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return $this->_rights_bas[$base_id]['restrict_dwnld']; return $this->_rights_bas[$base_id]['restrict_dwnld'];
@@ -485,6 +498,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return (int) $this->_rights_bas[$base_id]['remain_dwnld']; return (int) $this->_rights_bas[$base_id]['remain_dwnld'];
@@ -502,6 +516,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
$this->_rights_bas[$base_id]['remain_dwnld'] = $this->_rights_bas[$base_id]['remain_dwnld'] =
@@ -541,12 +556,14 @@ class ACL implements cache_cacheableInterface
$this->load_rights_sbas(); $this->load_rights_sbas();
if (!isset($this->_rights_sbas[$sbas_id])) if (!isset($this->_rights_sbas[$sbas_id]))
return false; return false;
if (!isset($this->_rights_sbas[$sbas_id][$right])) if (!isset($this->_rights_sbas[$sbas_id][$right]))
throw new Exception('This right does not exists'); throw new Exception('This right does not exists');
if ($this->_rights_sbas[$sbas_id][$right] === true) if ($this->_rights_sbas[$sbas_id][$right] === true)
return true; return true;
return false; return false;
@@ -562,6 +579,7 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return $this->_rights_bas[$base_id]['mask_and']; return $this->_rights_bas[$base_id]['mask_and'];
@@ -577,6 +595,7 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return $this->_rights_bas[$base_id]['mask_xor']; return $this->_rights_bas[$base_id]['mask_xor'];
@@ -620,21 +639,21 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
$ret = array(); $ret = array();
foreach($this->appbox->get_databoxes() as $databox) foreach($this->appbox->get_databoxes() as $databox)
{ {
if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids)) if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids))
{ {
continue; continue;
} }
foreach ($databox->get_collections() as $collection) foreach ($databox->get_collections() as $collection)
{ {
$continue = false; $continue = false;
if(!array_key_exists($collection->get_base_id(), $this->_rights_bas)) if(!array_key_exists($collection->get_base_id(), $this->_rights_bas))
continue; continue;
$base_id = $collection->get_base_id(); $base_id = $collection->get_base_id();
$datas = $this->_rights_bas[$base_id]; $datas = $this->_rights_bas[$base_id];
@@ -702,7 +721,7 @@ class ACL implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -718,6 +737,7 @@ class ACL implements cache_cacheableInterface
{ {
if ($this->_rights_records_preview) if ($this->_rights_records_preview)
return $this; return $this;
try try
@@ -730,7 +750,7 @@ class ACL implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'SELECT sbas_id, record_id, preview, document $sql = 'SELECT sbas_id, record_id, preview, document
FROM records_rights WHERE usr_id = :usr_id'; FROM records_rights WHERE usr_id = :usr_id';
@@ -771,6 +791,7 @@ class ACL implements cache_cacheableInterface
{ {
if ($this->_rights_sbas && $this->_global_rights) if ($this->_rights_sbas && $this->_global_rights)
return $this; return $this;
try try
@@ -782,7 +803,7 @@ class ACL implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'SELECT sbasusr.* FROM sbasusr, sbas $sql = 'SELECT sbasusr.* FROM sbasusr, sbas
@@ -832,6 +853,7 @@ class ACL implements cache_cacheableInterface
protected function load_rights_bas() protected function load_rights_bas()
{ {
if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited))
return $this; return $this;
try try
@@ -844,7 +866,7 @@ class ACL implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'SELECT u.* FROM basusr u, bas b, sbas s $sql = 'SELECT u.* FROM basusr u, bas b, sbas s
@@ -1335,6 +1357,7 @@ class ACL implements cache_cacheableInterface
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
return $this; return $this;
$this->give_access_to_base(array($base_id_dest)); $this->give_access_to_base(array($base_id_dest));
@@ -1501,6 +1524,7 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
if (!isset($this->_limited[$base_id])) if (!isset($this->_limited[$base_id]))
return null; return null;
return ($this->_limited[$base_id]); return ($this->_limited[$base_id]);
} }
@@ -1509,18 +1533,18 @@ class ACL implements cache_cacheableInterface
{ {
if ($limit) if ($limit)
{ {
$sql = 'UPDATE basusr $sql = 'UPDATE basusr
SET time_limited = 1 SET time_limited = 1
, limited_from = :limited_from , limited_from = :limited_from
, limited_to = :limited_to , limited_to = :limited_to
WHERE base_id = :base_id AND usr_id = :usr_id'; WHERE base_id = :base_id AND usr_id = :usr_id';
} }
else else
{ {
$sql = 'UPDATE basusr $sql = 'UPDATE basusr
SET time_limited = 0 SET time_limited = 0
, limited_from = :limited_from , limited_from = :limited_from
, limited_to = :limited_to , limited_to = :limited_to
WHERE base_id = :base_id AND usr_id = :usr_id'; WHERE base_id = :base_id AND usr_id = :usr_id';
} }

View File

@@ -551,7 +551,7 @@ class API_OAuth2_Adapter extends OAuth2
return $account; return $account;
} }
/** /**
* *
* @param int $usr_id * @param int $usr_id

View File

@@ -71,7 +71,7 @@ class API_V1_Log
/** /**
* *
* @var API_OAuth2_Account * @var API_OAuth2_Account
*/ */
protected $account; protected $account;
@@ -85,7 +85,7 @@ class API_V1_Log
* *
* @param appbox $appbox * @param appbox $appbox
* @param Request $request * @param Request $request
* @param API_OAuth2_Account $account * @param API_OAuth2_Account $account
*/ */
public function __construct(appbox &$appbox, $log_id) public function __construct(appbox &$appbox, $log_id)
{ {
@@ -93,16 +93,16 @@ class API_V1_Log
$this->id = (int) $log_id; $this->id = (int) $log_id;
$sql = ' $sql = '
SELECT SELECT
api_log_id, api_log_id,
api_account_id, api_account_id,
api_log_route, api_log_route,
api_log_date, api_log_date,
api_log_status_code, api_log_status_code,
api_log_format, api_log_format,
api_log_ressource, api_log_ressource,
api_log_general, api_log_general,
api_log_aspect, api_log_aspect,
api_log_action api_log_action
FROM FROM
api_logs api_logs
@@ -172,7 +172,7 @@ class API_V1_Log
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
return $this; return $this;
} }
@@ -184,7 +184,7 @@ class API_V1_Log
public function set_status_code($status_code) public function set_status_code($status_code)
{ {
$this->status_code = (int) $status_code; $this->status_code = (int) $status_code;
$sql = 'UPDATE api_log $sql = 'UPDATE api_log
SET api_log_status_code = :code SET api_log_status_code = :code
WHERE api_log_id = :log_id'; WHERE api_log_id = :log_id';
@@ -197,7 +197,7 @@ class API_V1_Log
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
return $this; return $this;
} }
@@ -208,12 +208,12 @@ class API_V1_Log
public function set_format($format) public function set_format($format)
{ {
if (!in_array($format, array('json', 'jsonp', 'yaml', 'unknow'))) if (!in_array($format, array('json', 'jsonp', 'yaml', 'unknow')))
throw new Exception_InvalidArgument(); throw new Exception_InvalidArgument();
$this->format = $format; $this->format = $format;
$sql = 'UPDATE api_log $sql = 'UPDATE api_log
SET api_log_format = :format SET api_log_format = :format
WHERE api_log_id = :log_id'; WHERE api_log_id = :log_id';
@@ -226,7 +226,7 @@ class API_V1_Log
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
return $this; return $this;
} }
@@ -239,9 +239,9 @@ class API_V1_Log
{ {
if (!in_array($format, array(self::DATABOXES_RESSOURCE,self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE))) if (!in_array($format, array(self::DATABOXES_RESSOURCE,self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE)))
throw new Exception_InvalidArgument(); throw new Exception_InvalidArgument();
$this->ressource = $ressource; $this->ressource = $ressource;
$sql = 'UPDATE api_log $sql = 'UPDATE api_log
SET api_log_ressource = :ressource SET api_log_ressource = :ressource
WHERE api_log_id = :log_id'; WHERE api_log_id = :log_id';
@@ -254,7 +254,7 @@ class API_V1_Log
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
return $this; return $this;
} }
@@ -266,7 +266,7 @@ class API_V1_Log
public function set_general($general) public function set_general($general)
{ {
$this->general = $general; $this->general = $general;
$sql = 'UPDATE api_log $sql = 'UPDATE api_log
SET api_log_general = :general SET api_log_general = :general
WHERE api_log_id = :log_id'; WHERE api_log_id = :log_id';
@@ -279,7 +279,7 @@ class API_V1_Log
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
return $this; return $this;
} }
@@ -291,7 +291,7 @@ class API_V1_Log
public function set_aspect($aspect) public function set_aspect($aspect)
{ {
$this->aspect = $aspect; $this->aspect = $aspect;
$sql = 'UPDATE api_log $sql = 'UPDATE api_log
SET api_log_aspect = :aspect SET api_log_aspect = :aspect
WHERE api_log_id = :log_id'; WHERE api_log_id = :log_id';
@@ -304,7 +304,7 @@ class API_V1_Log
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
return $this; return $this;
} }
@@ -316,7 +316,7 @@ class API_V1_Log
public function set_action($action) public function set_action($action)
{ {
$this->action = $action; $this->action = $action;
$sql = 'UPDATE api_log $sql = 'UPDATE api_log
SET api_log_action = :action SET api_log_action = :action
WHERE api_log_id = :log_id'; WHERE api_log_id = :log_id';
@@ -329,7 +329,7 @@ class API_V1_Log
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
return $this; return $this;
} }
@@ -338,8 +338,8 @@ class API_V1_Log
return $this->account; return $this->account;
} }
public static function create(appbox &$appbox, API_OAuth2_Account $account, $route, $status_code, $format, $ressource, $general = null, $aspect = null, $action = null) public static function create(appbox &$appbox, API_OAuth2_Account $account, $route, $status_code, $format, $ressource, $general = null, $aspect = null, $action = null)
{ {
$sql = ' $sql = '
INSERT INTO INSERT INTO
@@ -347,38 +347,38 @@ class API_V1_Log
api_log_id, api_log_id,
api_account_id, api_account_id,
api_log_route, api_log_route,
api_log_date, api_log_date,
api_log_status_code, api_log_status_code,
api_log_format, api_log_format,
api_log_ressource, api_log_ressource,
api_log_general, api_log_general,
api_log_aspect, api_log_aspect,
api_log_action api_log_action
) )
VALUES ( VALUES (
null, null,
:account_id, :account_id,
:route, :route,
NOW(), NOW(),
:status_code, :status_code,
:format, :format,
:ressource, :ressource,
:general, :general,
:aspect, :aspect,
:action :action
)'; )';
$params = array( $params = array(
':account_id' => $account->get_id(), ':account_id' => $account->get_id(),
':route' => $route, ':route' => $route,
':status_code' => $status_code, ':status_code' => $status_code,
':format' => $format, ':format' => $format,
':ressource' => $ressource, ':ressource' => $ressource,
':general' => $general, ':general' => $general,
':aspect' => $aspect, ':aspect' => $aspect,
':action' => $action ':action' => $action
); );
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();

View File

@@ -18,4 +18,4 @@
class Bridge_Exception extends Exception class Bridge_Exception extends Exception
{ {
} }

View File

@@ -68,4 +68,4 @@ class Controller_Admin_Fields implements ControllerProviderInterface
return $controllers; return $controllers;
} }
} }

View File

@@ -54,7 +54,7 @@ class Controller_Admin_Publications implements ControllerProviderInterface
$request = $app['request']; $request = $app['request'];
$feed = Feed_Adapter::create($appbox, $user, $request->get('title'), $request->get('subtitle')); $feed = Feed_Adapter::create($appbox, $user, $request->get('title'), $request->get('subtitle'));
if($request->get('public') == '1') if($request->get('public') == '1')
$feed->set_public (true); $feed->set_public (true);
elseif ($request->get('base_id')) elseif ($request->get('base_id'))
@@ -93,6 +93,7 @@ class Controller_Admin_Publications implements ControllerProviderInterface
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
if (!$feed->is_owner($user)) if (!$feed->is_owner($user))
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it')); return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
$request = $app['request']; $request = $app['request'];
@@ -121,23 +122,29 @@ class Controller_Admin_Publications implements ControllerProviderInterface
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
if (!$feed->is_owner($user)) if (!$feed->is_owner($user))
return new Response('ERROR:you are not allowed'); return new Response('ERROR:you are not allowed');
if ($_FILES['Filedata']['error'] !== 0) if ($_FILES['Filedata']['error'] !== 0)
return new Response('ERROR:error while upload'); return new Response('ERROR:error while upload');
$file = new system_file($_FILES['Filedata']['tmp_name']); $file = new system_file($_FILES['Filedata']['tmp_name']);
if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif'))) if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
return new Response('ERROR:bad filetype'); return new Response('ERROR:bad filetype');
if ($file->getSize() > 200000) if ($file->getSize() > 200000)
return new Response('ERROR:file too large'); return new Response('ERROR:file too large');
$datas = $file->get_technical_datas(); $datas = $file->get_technical_datas();
if (!isset($datas[system_file::TC_DATAS_WIDTH]) || !isset($datas[system_file::TC_DATAS_HEIGHT])) if (!isset($datas[system_file::TC_DATAS_WIDTH]) || !isset($datas[system_file::TC_DATAS_HEIGHT]))
return new Response('ERROR:file is not square'); return new Response('ERROR:file is not square');
if ($datas[system_file::TC_DATAS_WIDTH] != $datas[system_file::TC_DATAS_HEIGHT]) if ($datas[system_file::TC_DATAS_WIDTH] != $datas[system_file::TC_DATAS_HEIGHT])
return new Response('ERROR:file is not square'); return new Response('ERROR:file is not square');
$feed->set_icon($file); $feed->set_icon($file);

View File

@@ -260,7 +260,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
$response = new Response($CSVDatas, 200, array('Content-Type' => 'text/plain')); $response = new Response($CSVDatas, 200, array('Content-Type' => 'text/plain'));
$response->headers->set('Content-Disposition', 'attachment; filename=export.txt'); $response->headers->set('Content-Disposition', 'attachment; filename=export.txt');
return $response; return $response;
} }
); );

View File

@@ -54,7 +54,7 @@ class Controller_Prod_Records_Edit implements ControllerProviderInterface
return $twig->render($template, array('edit' => $editing, 'message' => '')); return $twig->render($template, array('edit' => $editing, 'message' => ''));
} }
); );
return $controllers; return $controllers;
} }

View File

@@ -57,4 +57,4 @@ class Controller_Prod_Records_MoveCollection implements ControllerProviderInterf
return $controllers; return $controllers;
} }
} }

View File

@@ -174,4 +174,4 @@ class Controller_Prod_Records_Tooltip implements ControllerProviderInterface
return $controllers; return $controllers;
} }
} }

View File

@@ -44,17 +44,17 @@ class Controller_RSSFeeds implements ControllerProviderInterface
{ {
$content = new Feed_XML_RSS(); $content = new Feed_XML_RSS();
} }
if ($format == Feed_Adapter::FORMAT_ATOM) if ($format == Feed_Adapter::FORMAT_ATOM)
{ {
$content = new Feed_XML_Atom(); $content = new Feed_XML_Atom();
} }
if($format == Feed_Adapter::FORMAT_COOLIRIS) if($format == Feed_Adapter::FORMAT_COOLIRIS)
{ {
$content = new Feed_XML_Cooliris(); $content = new Feed_XML_Cooliris();
} }
if ($user instanceof User_Adapter) if ($user instanceof User_Adapter)
$link = $feed->get_user_link($registry, $user, $format, $page); $link = $feed->get_user_link($registry, $user, $format, $page);
else else
@@ -82,7 +82,7 @@ class Controller_RSSFeeds implements ControllerProviderInterface
} }
foreach ($entries->get_entries() as $entry) foreach ($entries->get_entries() as $entry)
$content->set_item($entry); $content->set_item($entry);
$render = $content->render(); $render = $content->render();
$response = new Response($render, 200, array('Content-Type' => $content->get_mimetype())); $response = new Response($render, 200, array('Content-Type' => $content->get_mimetype()));
$response->setCharset('UTF-8'); $response->setCharset('UTF-8');
@@ -176,8 +176,8 @@ class Controller_RSSFeeds implements ControllerProviderInterface
return $display_feed($feed, Feed_Adapter::FORMAT_COOLIRIS , $page); return $display_feed($feed, Feed_Adapter::FORMAT_COOLIRIS , $page);
}); });
return $controllers; return $controllers;
} }
} }

View File

@@ -51,8 +51,8 @@ class Controller_Setup_Installer implements ControllerProviderInterface
$request = $app['request']; $request = $app['request'];
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/'; $servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
setup::write_config($servername); setup::write_config($servername);
$php_constraint = setup::check_php_version(); $php_constraint = setup::check_php_version();
$writability_constraints = setup::check_writability(new Setup_Registry()); $writability_constraints = setup::check_writability(new Setup_Registry());
$extension_constraints = setup::check_php_extension(); $extension_constraints = setup::check_php_extension();
@@ -89,11 +89,11 @@ class Controller_Setup_Installer implements ControllerProviderInterface
return $app->redirect('/setup/installer/step2/'); return $app->redirect('/setup/installer/step2/');
} }
$ld_path = array(dirname(__FILE__) . '/../../../../templates/web'); $ld_path = array(dirname(__FILE__) . '/../../../../templates/web');
$loader = new Twig_Loader_Filesystem($ld_path); $loader = new Twig_Loader_Filesystem($ld_path);
$twig = new Twig_Environment($loader); $twig = new Twig_Environment($loader);
$html = $twig->render( $html = $twig->render(
'/setup/index.twig' '/setup/index.twig'
, array_merge($constraints_coll, array( , array_merge($constraints_coll, array(
@@ -111,12 +111,12 @@ class Controller_Setup_Installer implements ControllerProviderInterface
$controllers->get('/step2/', function() use ($app) $controllers->get('/step2/', function() use ($app)
{ {
phrasea::use_i18n(Session_Handler::get_locale()); phrasea::use_i18n(Session_Handler::get_locale());
$ld_path = array(dirname(__FILE__) . '/../../../../templates/web'); $ld_path = array(dirname(__FILE__) . '/../../../../templates/web');
$loader = new Twig_Loader_Filesystem($ld_path); $loader = new Twig_Loader_Filesystem($ld_path);
$twig = new Twig_Environment($loader); $twig = new Twig_Environment($loader);
$twig->addExtension(new Twig_Extensions_Extension_I18n()); $twig->addExtension(new Twig_Extensions_Extension_I18n());
$request = $app['request']; $request = $app['request'];
@@ -287,7 +287,7 @@ class Controller_Setup_Installer implements ControllerProviderInterface
$appbox->get_session()->authenticate($auth); $appbox->get_session()->authenticate($auth);
$redirection = '/admin/?section=taskmanager&notice=install_success'; $redirection = '/admin/index.php?section=taskmanager&notice=install_success';
return $app->redirect($redirection); return $app->redirect($redirection);
} }
@@ -303,4 +303,4 @@ class Controller_Setup_Installer implements ControllerProviderInterface
return $controllers; return $controllers;
} }
} }

View File

@@ -86,4 +86,4 @@ class Controller_Setup_Upgrader implements ControllerProviderInterface
return $controllers; return $controllers;
} }
} }

View File

@@ -50,7 +50,7 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
if ($dbname && $connection_ok === true) if ($dbname && $connection_ok === true)
@@ -83,7 +83,7 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }

View File

@@ -57,4 +57,4 @@ class Controller_Utils_PathFileTest implements ControllerProviderInterface
return $controllers; return $controllers;
} }
} }

View File

@@ -14,8 +14,8 @@ require_once __DIR__ . '/../vendor/dailymotion-sdk-php/Dailymotion.php';
class DailymotionWithoutOauth2 extends Dailymotion class DailymotionWithoutOauth2 extends Dailymotion
{ {
/** /**
* Call a remote method. * Call a remote method.
* *
@@ -37,7 +37,7 @@ class DailymotionWithoutOauth2 extends Dailymotion
'call' => $method, 'call' => $method,
'args' => $args, 'args' => $args,
)); ));
$status_code = null; $status_code = null;
try try
{ {
@@ -45,7 +45,7 @@ class DailymotionWithoutOauth2 extends Dailymotion
} }
catch (DailymotionAuthException $e) catch (DailymotionAuthException $e)
{ {
if ($e->error === 'invalid_token') if ($e->error === 'invalid_token')
{ {
throw new Bridge_Exception_ActionAuthNeedReconnect(); throw new Bridge_Exception_ActionAuthNeedReconnect();
@@ -84,8 +84,8 @@ class DailymotionWithoutOauth2 extends Dailymotion
return $result['result']; return $result['result'];
} }
/** /**
* Upload a file on the Dailymotion servers and generate an URL to be used with API methods. * Upload a file on the Dailymotion servers and generate an URL to be used with API methods.
* *
@@ -100,6 +100,7 @@ class DailymotionWithoutOauth2 extends Dailymotion
$this->timeout = null; $this->timeout = null;
$result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true); $result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true);
$this->timeout = $timeout; $this->timeout = $timeout;
return $result['url']; return $result['url'];
} }
} }

View File

@@ -10,12 +10,12 @@
*/ */
/** /**
* *
* @package Exception * @package Exception
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
class Exception_Setup_FixBadEmailAddresses extends Exception class Exception_Setup_FixBadEmailAddresses extends Exception
{ {
} }

View File

@@ -26,7 +26,7 @@ abstract class Feed_Abstract
*/ */
const FORMAT_ATOM = 'atom'; const FORMAT_ATOM = 'atom';
/** /**
* *
*/ */
const FORMAT_COOLIRIS = 'cooliris'; const FORMAT_COOLIRIS = 'cooliris';

View File

@@ -57,7 +57,7 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
const CACHE_ENTRY_NUMBER = 'entrynumber'; const CACHE_ENTRY_NUMBER = 'entrynumber';
const CACHE_USER_TOKEN = 'usr_token'; const CACHE_USER_TOKEN = 'usr_token';
const MAX_ENTRIES = 20; const MAX_ENTRIES = 20;
/** /**

View File

@@ -357,11 +357,11 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
return $this->publisher; return $this->publisher;
} }
/** /**
* *
* @param User_adapter $user * @param User_adapter $user
* @return boolean * @return boolean
*/ */
public function is_publisher(User_adapter $user) public function is_publisher(User_adapter $user)
{ {

View File

@@ -370,9 +370,11 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
$medium = strtolower($content->get_record()->get_type()); $medium = strtolower($content->get_record()->get_type());
if (!in_array($medium, array('image', 'audio', 'video'))) if (!in_array($medium, array('image', 'audio', 'video')))
return $this; return $this;
if (!$preview_permalink || !$thumbnail_permalink) if (!$preview_permalink || !$thumbnail_permalink)
return $this; return $this;
//add item node to channel node //add item node to channel node

View File

@@ -324,7 +324,7 @@ class Session_Handler
{ {
if (!$this->phrasea_session instanceof Session_Phrasea) if (!$this->phrasea_session instanceof Session_Phrasea)
throw new \Exception('No phrasea session available'); throw new \Exception('No phrasea session available');
$this->phrasea_session->open(); $this->phrasea_session->open();
return $this; return $this;
@@ -395,6 +395,7 @@ class Session_Handler
foreach ($user->ACL()->get_granted_sbas() as $databox) foreach ($user->ACL()->get_granted_sbas() as $databox)
{ {
Session_Logger::create($databox, $browser, $this, $user); Session_Logger::create($databox, $browser, $this, $user);
\cache_databox::insertClient($databox);
} }
$this->set_usr_lastconn($conn, $user->get_id()); $this->set_usr_lastconn($conn, $user->get_id());
@@ -596,7 +597,7 @@ class Session_Handler
'ssel_id' => $row['ssel_id'], 'ssel_id' => $row['ssel_id'],
'from' => $row['owner'], 'from' => $row['owner'],
'validate_id' => $row['validate_id'], 'validate_id' => $row['validate_id'],
'url' => $registry->get('GV_ServerName') 'url' => $registry->get('GV_ServerName')
. 'lightbox/validate/'.$row['ssel_id'].'/?LOG=' . $row['value'] . 'lightbox/validate/'.$row['ssel_id'].'/?LOG=' . $row['value']
); );

View File

@@ -55,14 +55,14 @@ class Setup_Upgrade
{ {
throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started'); throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started');
} }
$this->appbox = $appbox; $this->appbox = $appbox;
if(count(User_Adapter::get_wrong_email_users($appbox)) > 0) if(count(User_Adapter::get_wrong_email_users($appbox)) > 0)
{ {
throw new Exception_Setup_FixBadEmailAddresses('Please fix the database before starting'); throw new Exception_Setup_FixBadEmailAddresses('Please fix the database before starting');
} }
$this->write_lock(); $this->write_lock();
return $this; return $this;

View File

@@ -907,6 +907,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public static function get_usr_id_from_email($email) public static function get_usr_id_from_email($email)
{ {
if (is_null($email)) if (is_null($email))
return false; return false;
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
@@ -1255,7 +1256,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public function get_applied_template() public function get_applied_template()
{ {
return $this->applied_template; return $this->applied_template;
} }
@@ -1277,7 +1278,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected function load_preferences() protected function load_preferences()
{ {
if ($this->_prefs) if ($this->_prefs)
return $this; return $this;
$registry = \registry::get_instance();
$sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id'; $sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id)); $stmt->execute(array(':id' => $this->id));
@@ -1293,6 +1298,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
if (!isset($this->_prefs[$k])) if (!isset($this->_prefs[$k]))
{ {
if($k == 'start_page_query' && $registry->get('GV_defaultQuery'))
{
$v = $registry->get('GV_defaultQuery');
}
$this->_prefs[$k] = $v; $this->_prefs[$k] = $v;
$this->update_pref($k, $v); $this->update_pref($k, $v);
} }
@@ -1370,7 +1380,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $this; return $this;
@@ -1565,6 +1575,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
$this->load_preferences(); $this->load_preferences();
if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value) if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value)
return $value; return $value;
$ok = true; $ok = true;
@@ -1602,6 +1613,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
if (!$session->is_authenticated()) if (!$session->is_authenticated())
return; return;
$ses_id = $session->get_ses_id(); $ses_id = $session->get_ses_id();
@@ -1660,7 +1672,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
} }
@@ -1724,7 +1736,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return false; return false;
@@ -1810,7 +1822,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $locale; return $locale;
@@ -1876,6 +1888,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public function get_nonce() public function get_nonce()
{ {
if ($this->nonce) if ($this->nonce)
return $this->nonce; return $this->nonce;
$nonce = false; $nonce = false;

View File

@@ -269,7 +269,7 @@ class User_Query implements User_QueryInterface
$extra = $this->include_phantoms ? ' OR sbas_id IS NULL ' : ''; $extra = $this->include_phantoms ? ' OR sbas_id IS NULL ' : '';
$not_sbas_id = array_diff($this->active_sbas, $this->sbas_ids); $not_sbas_id = array_diff($this->active_sbas, $this->sbas_ids);
if (count($not_sbas_id) > 0 && count($not_sbas_id) < count($this->sbas_ids)) if (count($not_sbas_id) > 0 && count($not_sbas_id) < count($this->sbas_ids))
{ {
$sql .= sprintf(' AND ((sbas_id != %s ) ' . $extra . ')' $sql .= sprintf(' AND ((sbas_id != %s ) ' . $extra . ')'
@@ -489,6 +489,7 @@ class User_Query implements User_QueryInterface
public function get_total() public function get_total()
{ {
if ($this->total) if ($this->total)
return $this->total; return $this->total;
$conn = $this->appbox->get_connection(); $conn = $this->appbox->get_connection();
@@ -637,6 +638,7 @@ class User_Query implements User_QueryInterface
public function on_base_ids(Array $base_ids = null) public function on_base_ids(Array $base_ids = null)
{ {
if (!$base_ids) if (!$base_ids)
return $this; return $this;
$this->bases_restrictions = true; $this->bases_restrictions = true;
@@ -661,6 +663,7 @@ class User_Query implements User_QueryInterface
public function on_sbas_ids(Array $sbas_ids = null) public function on_sbas_ids(Array $sbas_ids = null)
{ {
if (!$sbas_ids) if (!$sbas_ids)
return $this; return $this;
$this->sbas_restrictions = true; $this->sbas_restrictions = true;

View File

@@ -215,7 +215,7 @@ class appbox extends base
$stmt = $this->get_connection()->prepare($sqlupd); $stmt = $this->get_connection()->prepare($sqlupd);
$stmt->execute(array(':ordre' => $ordre, ':base_id' => $collection->get_base_id())); $stmt->execute(array(':ordre' => $ordre, ':base_id' => $collection->get_base_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$collection->get_databox()->delete_data_from_cache(\databox::CACHE_COLLECTIONS); $collection->get_databox()->delete_data_from_cache(\databox::CACHE_COLLECTIONS);
return $this; return $this;

View File

@@ -180,6 +180,12 @@ abstract class base implements cache_cacheableInterface
*/ */
public function get_data_from_cache($option = null) public function get_data_from_cache($option = null)
{ {
if($this->get_base_type() == self::DATA_BOX)
{
\cache_databox::refresh($this->id);
}
return $this->get_cache()->get($this->get_cache_key($option)); return $this->get_cache()->get($this->get_cache_key($option));
} }

View File

@@ -327,6 +327,7 @@ class basket_adapter implements cache_cacheableInterface
public function get_first_element() public function get_first_element()
{ {
foreach ($this->get_elements() as $basket_element) foreach ($this->get_elements() as $basket_element)
return $basket_element; return $basket_element;
return null; return null;
} }
@@ -338,6 +339,7 @@ class basket_adapter implements cache_cacheableInterface
public function get_validation_end_date() public function get_validation_end_date()
{ {
if (!$this->valid || !$this->validation_end_date) if (!$this->valid || !$this->validation_end_date)
return null; return null;
return $this->validation_end_date; return $this->validation_end_date;
} }
@@ -349,6 +351,7 @@ class basket_adapter implements cache_cacheableInterface
public function is_validation_finished() public function is_validation_finished()
{ {
if (!$this->valid || !$this->validation_end_date) if (!$this->valid || !$this->validation_end_date)
return null; return null;
$now = new DateTime(); $now = new DateTime();
@@ -362,6 +365,7 @@ class basket_adapter implements cache_cacheableInterface
public function is_confirmed() public function is_confirmed()
{ {
if (!$this->valid) if (!$this->valid)
return null; return null;
return $this->validation_is_confirmed; return $this->validation_is_confirmed;
@@ -370,14 +374,17 @@ class basket_adapter implements cache_cacheableInterface
public function is_releasable() public function is_releasable()
{ {
if (!$this->valid) if (!$this->valid)
return false; return false;
if ($this->is_confirmed()) if ($this->is_confirmed())
return false; return false;
foreach ($this->get_elements() as $element) foreach ($this->get_elements() as $element)
{ {
if ($element->get_my_agreement() == '0') if ($element->get_my_agreement() == '0')
return false; return false;
} }
@@ -477,7 +484,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'SELECT s.pushFrom, n.id as noview, s.usr_id as owner, s.rid $sql = 'SELECT s.pushFrom, n.id as noview, s.usr_id as owner, s.rid
@@ -542,7 +549,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -585,6 +592,7 @@ class basket_adapter implements cache_cacheableInterface
public function sort($order) public function sort($order)
{ {
if (!$this->valid || !in_array($order, array('asc', 'desc'))) if (!$this->valid || !in_array($order, array('asc', 'desc')))
return; return;
$this->load_elements(); $this->load_elements();
@@ -630,7 +638,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception_Record_AdapterNotFound $e) catch (Exception_Record_AdapterNotFound $e)
{ {
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -745,7 +753,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -900,7 +908,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
} }
@@ -1016,6 +1024,7 @@ class basket_adapter implements cache_cacheableInterface
public function set_read() public function set_read()
{ {
if (!$this->noview) if (!$this->noview)
return true; return true;
$session = $this->appbox->get_session(); $session = $this->appbox->get_session();
@@ -1075,7 +1084,7 @@ class basket_adapter implements cache_cacheableInterface
foreach ($this->get_elements() as $basket_element) foreach ($this->get_elements() as $basket_element)
{ {
$basket_element->validate($me, $user, $insert_id, $can_hd); $basket_element->validate($me, $user, $insert_id, $can_hd);
if ($can_hd && $me->ACL()->has_hd_grant($basket_element->get_record())) if ($can_hd && $me->ACL()->has_hd_grant($basket_element->get_record()))
$user->ACL()->grant_hd_on($basket_element->get_record(), $me, 'validate'); $user->ACL()->grant_hd_on($basket_element->get_record(), $me, 'validate');
else else
@@ -1131,15 +1140,19 @@ class basket_adapter implements cache_cacheableInterface
if ($this->is_mine) if ($this->is_mine)
{ {
if ($this->is_validation_finished()) if ($this->is_validation_finished())
return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1));
else else
return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1));
} }
else else
{ {
if ($this->validation_see_others) if ($this->validation_see_others)
return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1)); return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1));
else else
return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name()); return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name());
} }
} }
@@ -1248,6 +1261,7 @@ class basket_adapter implements cache_cacheableInterface
protected function load_elements() protected function load_elements()
{ {
if (!is_null($this->elements)) if (!is_null($this->elements))
return; return;
$this->elements = array(); $this->elements = array();
@@ -1274,7 +1288,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -1372,7 +1386,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return array('error' => true, 'status' => 0); return array('error' => true, 'status' => 0);
@@ -1412,7 +1426,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$ret = array('error' => false, 'status' => 0); $ret = array('error' => false, 'status' => 0);
@@ -1525,11 +1539,14 @@ class basket_adapter implements cache_cacheableInterface
public function remove_from_ssel($sselcont_id) public function remove_from_ssel($sselcont_id)
{ {
if (!$this->is_mine) if (!$this->is_mine)
return array('error' => 'error', 'status' => 0); return array('error' => 'error', 'status' => 0);
if ($this->is_grouping) if ($this->is_grouping)
return $this->remove_grouping_elements($sselcont_id); return $this->remove_grouping_elements($sselcont_id);
else else
return $this->remove_basket_elements($sselcont_id); return $this->remove_basket_elements($sselcont_id);
} }
@@ -1869,7 +1886,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $appbox->delete_data_from_cache($ssel_ids); return $appbox->delete_data_from_cache($ssel_ids);
@@ -1897,7 +1914,7 @@ class basket_adapter implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'SELECT id, usr_id, confirmed, can_agree, can_see_others $sql = 'SELECT id, usr_id, confirmed, can_agree, can_see_others

View File

@@ -548,20 +548,20 @@ class basket_element_adapter implements cache_cacheableInterface
} }
$this->delete_data_from_cache(); $this->delete_data_from_cache();
$sql = 'SELECT distinct v.usr_id FROM ssel s, validate v $sql = 'SELECT distinct v.usr_id FROM ssel s, validate v
WHERE v.ssel_id = s.ssel_id AND s.ssel_id = :ssel_id'; WHERE v.ssel_id = s.ssel_id AND s.ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $this->get_ssel_id())); $stmt->execute(array(':ssel_id' => $this->get_ssel_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach($rs as $row) foreach($rs as $row)
{ {
$appbox->delete_data_from_cache('basket_element_' . $row['usr_id'] . '_' . $this->sselcont_id); $appbox->delete_data_from_cache('basket_element_' . $row['usr_id'] . '_' . $this->sselcont_id);
} }
try try
{ {
$basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id); $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id);
@@ -654,23 +654,23 @@ class basket_element_adapter implements cache_cacheableInterface
$stmt->closeCursor(); $stmt->closeCursor();
$this->delete_data_from_cache(); $this->delete_data_from_cache();
$sql = 'SELECT distinct v.usr_id FROM ssel s, validate v $sql = 'SELECT distinct v.usr_id FROM ssel s, validate v
WHERE v.ssel_id = s.ssel_id AND s.ssel_id = :ssel_id'; WHERE v.ssel_id = s.ssel_id AND s.ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $this->get_ssel_id())); $stmt->execute(array(':ssel_id' => $this->get_ssel_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach($rs as $row) foreach($rs as $row)
{ {
$appbox->delete_data_from_cache('basket_element_' . $row['usr_id'] . '_' . $this->sselcont_id); $appbox->delete_data_from_cache('basket_element_' . $row['usr_id'] . '_' . $this->sselcont_id);
} }
$basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id); $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id);
$basket->delete_cache(); $basket->delete_cache();
return $this; return $this;
} }

View File

@@ -151,7 +151,7 @@ class basketCollection
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
$session = $appbox->get_session(); $session = $appbox->get_session();
$sql = 'SELECT n.ssel_id FROM sselnew n $sql = 'SELECT n.ssel_id FROM sselnew n
WHERE n.usr_id = :usr_id '; WHERE n.usr_id = :usr_id ';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':usr_id' => $session->get_usr_id())); $stmt->execute(array(':usr_id' => $session->get_usr_id()));
@@ -164,12 +164,12 @@ class basketCollection
try try
{ {
$basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id()); $basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id());
if ($basket->is_valid() && !$basket->is_my_valid() && $basket->is_validation_finished()) if ($basket->is_valid() && !$basket->is_my_valid() && $basket->is_validation_finished())
throw new Exception('Finished'); throw new Exception('Finished');
$baskets[] = $basket; $baskets[] = $basket;
} }
catch(Exception $e) catch(Exception $e)
{ {

View File

@@ -154,7 +154,7 @@ class bootstrap
Twig_Autoloader::register(); Twig_Autoloader::register();
Twig_Extensions_Autoloader::register(); Twig_Extensions_Autoloader::register();
/** /**
* Load symfony components needed * Load symfony components needed
*/ */

View File

@@ -18,142 +18,125 @@
class cache_databox class cache_databox
{ {
/**
*
* @var cache_databox
*/
private static $_instance = false;
/**
*
* @var cache
*/
protected $_c_obj = false;
/**
*
* @return cache_databox
*/
function __construct()
{
$this->_c_obj = cache_adapter::getInstance(registry::get_instance());
return $this;
}
/**
* @return cache_databox
*/
public static function getInstance()
{
if (!(self::$_instance instanceof self))
self::$_instance = new self();
return self::$_instance;
}
/**
*
* @param string $type
* @param string $what
* @return boolean
*/
public function get($type, $what)
{
return $this->_c_obj->get('_databox_' . $type . '_' . $what);
}
/**
*
* @param string $type
* @param string $what
* @param mixed content $bin
* @return boolean
*/
public function set($type, $what, $bin)
{
return $this->_c_obj->set('_databox_' . $type . '_' . $what, $bin);
}
/**
*
* @param string $type
* @param string $what
* @return boolean
*/
public function delete($type, $what)
{
return $this->_c_obj->delete('_databox_' . $type . '_' . $what);
}
/** /**
* *
* @param int $sbas_id * @param int $sbas_id
* @return cache_databox * @return cache_databox
*/ */
function refresh($sbas_id) public static function refresh($sbas_id)
{ {
$date = new DateTime('-30 seconds'); $databox = \databox::get_instance((int) $sbas_id);
$registry = registry::get_instance(); $date = new \DateTime('-3 seconds');
$cache_appbox = cache_appbox::getInstance(); $appbox = \appbox::get_instance();
$last_update = $cache_appbox->get('memcached_update');
if ($last_update)
$last_update = new DateTime($last_update);
else
$last_update = new DateTime('-10 years');
if ($date <= $last_update || !$cache_appbox->is_ok()) $registry = \registry::get_instance();
return $this; $last_update = null;
$connsbas = connection::getInstance($sbas_id); try
if (!$connsbas)
return $this;
$sql = 'SELECT type, value FROM memcached
WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '"';
if ($rs = $connsbas->query($sql))
{ {
$cache_thumbnail = cache_thumbnail::getInstance(); $last_update = $appbox->get_data_from_cache('memcached_update_' . $sbas_id);
$cache_preview = cache_preview::getInstance(); }
while ($row = $connsbas->fetch_assoc($rs)) catch (\Exception $e)
{ {
switch ($row['type'])
{
case 'record':
$cache_thumbnail->delete($sbas_id, $row['value'], false);
$cache_preview->delete($sbas_id, $row['value'], false);
$sql = 'DELETE FROM memcached
WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '"
AND type="record" AND value="' . $row['value'] . '"';
$connsbas->query($sql);
break;
case 'structure':
$cache_appbox->delete('list_bases');
$sql = 'DELETE FROM memcached
WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '"
AND type="structure" AND value="' . $row['value'] . '"';
$connsbas->query($sql);
break;
}
}
$connsbas->free_result($rs);
} }
$date = new DateTime(); if ($last_update)
$now = phraseadate::format_mysql($date); $last_update = new \DateTime($last_update);
$cache_appbox->set('memcached_update', $now); else
$last_update = new \DateTime('-10 years');
$conn = connection::getInstance(); if ($date <= $last_update || !$appbox->get_cache()->ping())
$sql = 'UPDATE sitepreff {
SET memcached_update="' . $conn->escape_string($now) . '"'; return;
$conn->query($sql); }
return $this; $connsbas = \connection::getPDOConnection($sbas_id);
$sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id';
$stmt = $connsbas->prepare($sql);
$stmt->execute(array(':site_id' => $registry->get('GV_ServerName')));
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
switch ($row['type'])
{
case 'record':
$key = 'record_' . $sbas_id . '_' . $row['value'];
$databox->delete_data_from_cache($key);
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SUBDEFS;
$databox->delete_data_from_cache($key);
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_GROUPING;
$databox->delete_data_from_cache($key);
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_MIME;
$databox->delete_data_from_cache($key);
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_ORIGINAL_NAME;
$databox->delete_data_from_cache($key);
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SHA256;
$databox->delete_data_from_cache($key);
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_STATUS;
$databox->delete_data_from_cache($key);
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_TECHNICAL_DATAS;
$databox->delete_data_from_cache($key);
$sql = 'DELETE FROM memcached
WHERE site_id = :site_id AND type="record" AND value = :value';
$params = array(
':site_id' => $registry->get('GV_ServerName')
, ':value' => $row['value']
);
$stmt = $connsbas->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$record = new \record_adapter($sbas_id, $row['value']);
$record->get_caption()->delete_data_from_cache();
foreach ($record->get_caption()->get_fields() as $field)
{
$field->delete_data_from_cache();
}
break;
case 'structure':
$appbox->delete_data_from_cache(\appbox::CACHE_LIST_BASES);
$appbox->delete_data_from_cache(\appbox::CACHE_SBAS_IDS);
$sql = 'DELETE FROM memcached
WHERE site_id = :site_id AND type="structure" AND value = :value';
$params = array(
':site_id' => $registry->get('GV_ServerName')
, ':value' => $row['value']
);
$stmt = $connsbas->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
break;
}
}
$date = new \DateTime();
$now = $date->format(DATE_ISO8601);
$appbox->set_data_to_cache($now, 'memcached_update_' . $sbas_id);
$conn = \connection::getPDOConnection();
$sql = 'UPDATE sitepreff SET memcached_update = :date';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':date' => $now));
$stmt->closeCursor();
return;
} }
/** /**
@@ -163,28 +146,57 @@ class cache_databox
* @param mixed content $value * @param mixed content $value
* @return Void * @return Void
*/ */
function update($sbas_id, $type, $value='') public static function update($sbas_id, $type, $value = '')
{ {
$connbas = connection::getPDOConnection($sbas_id); $connbas = \connection::getPDOConnection($sbas_id);
$registry = registry::get_instance(); $registry = \registry::get_instance();
$sql = 'SELECT distinct site_id as site_id $sql = 'SELECT distinct site_id as site_id
FROM clients FROM clients
WHERE site_id != :site_id'; WHERE site_id != :site_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':site_id' => $registry->get('GV_ServerName'))); $stmt->execute(array(':site_id' => $registry->get('GV_ServerName')));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$sql = 'REPLACE INTO memcached (site_id, type, value) $sql = 'REPLACE INTO memcached (site_id, type, value)
VALUES (:site_id, :type, :value)'; VALUES (:site_id, :type, :value)';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
foreach ($rs as $row) foreach ($rs as $row)
{ {
$stmt->execute(array(':site_id' => $row['site_id'], ':type' => $type, ':value' => $value)); $stmt->execute(array(':site_id' => $row['site_id'], ':type' => $type, ':value' => $value));
} }
$stmt->closeCursor();
return;
}
public static function insertClient(\databox $databox)
{
$connbas = $databox->get_connection();
$registry = \registry::get_instance();
$sql = 'SELECT site_id FROM clients WHERE site_id = :site_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':site_id' => $registry->get('GV_ServerName')));
$rowCount = $stmt->rowCount();
$stmt->closeCursor();
if ($rowCount > 0)
{
return;
}
$sql = 'INSERT INTO clients (site_id) VALUES (:site_id)';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':site_id' => $registry->get('GV_ServerName')));
$stmt->closeCursor(); $stmt->closeCursor();
return; return;

View File

@@ -208,7 +208,7 @@ class caption_field implements cache_cacheableInterface
{ {
if(strlen($separator) > 1) if(strlen($separator) > 1)
$separator = $separator[0]; $separator = $separator[0];
if (trim($separator) === '') if (trim($separator) === '')
$separator = ' '; $separator = ' ';
else else

View File

@@ -60,6 +60,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
protected function retrieve_fields() protected function retrieve_fields()
{ {
if (is_array($this->fields)) if (is_array($this->fields))
return $this->fields; return $this->fields;
$fields = array(); $fields = array();
@@ -96,7 +97,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
$this->fields = $rec_fields; $this->fields = $rec_fields;
@@ -133,6 +134,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
{ {
$fields = $this->retrieve_fields(); $fields = $this->retrieve_fields();
if (isset($this->dces_elements[$label])) if (isset($this->dces_elements[$label]))
return $fields[$this->dces_elements[$label]]; return $fields[$this->dces_elements[$label]];
return null; return null;
} }

View File

@@ -200,9 +200,9 @@ class collection implements cache_cacheableInterface
$stmt = $this->get_connection()->prepare($sql); $stmt = $this->get_connection()->prepare($sql);
$stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id())); $stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$this->pub_wm = $publi; $this->pub_wm = $publi;
$this->delete_data_from_cache(); $this->delete_data_from_cache();
} }
@@ -223,9 +223,9 @@ class collection implements cache_cacheableInterface
$stmt->closeCursor(); $stmt->closeCursor();
$this->name = $name; $this->name = $name;
$this->delete_data_from_cache(); $this->delete_data_from_cache();
phrasea::reset_baseDatas(); phrasea::reset_baseDatas();
return $this; return $this;
@@ -404,7 +404,7 @@ class collection implements cache_cacheableInterface
$stmt = $this->get_connection()->prepare($sql); $stmt = $this->get_connection()->prepare($sql);
$stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id())); $stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$this->delete_data_from_cache(); $this->delete_data_from_cache();
return $this->prefs; return $this->prefs;

View File

@@ -171,7 +171,10 @@ class connection
public static function close_PDO_connection($name) public static function close_PDO_connection($name)
{ {
if (isset(self::$_PDO_instance[$name])) if (isset(self::$_PDO_instance[$name]))
{
self::$_PDO_instance[$name] = null;
unset(self::$_PDO_instance[$name]); unset(self::$_PDO_instance[$name]);
}
return; return;
} }

View File

@@ -142,7 +142,7 @@ class databox extends base
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -157,7 +157,7 @@ class databox extends base
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
@@ -451,6 +451,7 @@ class databox extends base
$stmt->closeCursor(); $stmt->closeCursor();
if ($row) if ($row)
return self::get_instance((int) $row['sbas_id']); return self::get_instance((int) $row['sbas_id']);
try try
@@ -463,7 +464,7 @@ class databox extends base
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'USE `' . $dbname . '`'; $sql = 'USE `' . $dbname . '`';
@@ -575,6 +576,7 @@ class databox extends base
public function get_meta_structure() public function get_meta_structure()
{ {
if ($this->meta_struct) if ($this->meta_struct)
return $this->meta_struct; return $this->meta_struct;
try try
@@ -697,6 +699,7 @@ class databox extends base
} }
} }
if ($n > $limit) if ($n > $limit)
return true; return true;
return false; return false;
@@ -986,7 +989,7 @@ class databox extends base
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
if (isset($field['regname'])) if (isset($field['regname']))
@@ -1220,6 +1223,7 @@ class databox extends base
public function get_structure() public function get_structure()
{ {
if ($this->structure) if ($this->structure)
return $this->structure; return $this->structure;
$this->structure = $this->retrieve_structure(); $this->structure = $this->retrieve_structure();
@@ -1234,7 +1238,7 @@ class databox extends base
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$structure = null; $structure = null;
@@ -1260,6 +1264,7 @@ class databox extends base
public function get_cterms() public function get_cterms()
{ {
if ($this->cterms) if ($this->cterms)
return $this->cterms; return $this->cterms;
$sql = "SELECT value FROM pref WHERE prop='cterms'"; $sql = "SELECT value FROM pref WHERE prop='cterms'";
@@ -1426,6 +1431,7 @@ class databox extends base
public function get_cgus() public function get_cgus()
{ {
if ($this->cgus) if ($this->cgus)
return $this->cgus; return $this->cgus;
$this->load_cgus(); $this->load_cgus();
@@ -1443,7 +1449,7 @@ class databox extends base
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'SELECT value, locale, updated_on FROM pref WHERE prop ="ToU"'; $sql = 'SELECT value, locale, updated_on FROM pref WHERE prop ="ToU"';

View File

@@ -94,12 +94,12 @@ class databox_cgu
$terms = array(); $terms = array();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
if(!$home) if(!$home)
{ {
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
} }
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
{ {
try try

View File

@@ -554,7 +554,7 @@ class databox_field implements cache_cacheableInterface
{ {
if (strpos($separator, ';') === false) if (strpos($separator, ';') === false)
$separator .= ';'; $separator .= ';';
$this->separator = $separator; $this->separator = $separator;
return $this; return $this;

View File

@@ -160,8 +160,20 @@ class databox_status
$sbas_ids = $user->ACL()->get_granted_sbas(); $sbas_ids = $user->ACL()->get_granted_sbas();
$see_all = array();
foreach ($sbas_ids as $databox) foreach ($sbas_ids as $databox)
{ {
$see_all[$databox->get_sbas_id()] = false;
foreach($databox->get_collections() as $collection)
{
if($user->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus'))
{
$see_all[$databox->get_sbas_id()] = true;
break;
}
}
try try
{ {
$statuses[$databox->get_sbas_id()] = $databox->get_statusbits(); $statuses[$databox->get_sbas_id()] = $databox->get_statusbits();
@@ -177,15 +189,15 @@ class databox_status
foreach ($statuses as $sbas_id => $status) foreach ($statuses as $sbas_id => $status)
{ {
$see_all = false; $see_this = isset($see_all[$sbas_id]) ? $see_all[$sbas_id] : false;
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
$see_all = true; $see_this = true;
foreach ($status as $bit => $props) foreach ($status as $bit => $props)
{ {
if ($props['searchable'] == 0 && !$see_all) if ($props['searchable'] == 0 && !$see_this)
continue; continue;
$set = false; $set = false;
@@ -479,7 +491,7 @@ class databox_status
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
$status = '0'; $status = '0';
if(substr($stat1, 0, 2) === '0x') if(substr($stat1, 0, 2) === '0x')
{ {
$stat1 = self::hex2bin(substr($stat1, 2)); $stat1 = self::hex2bin(substr($stat1, 2));
@@ -518,7 +530,7 @@ class databox_status
{ {
$stat2 = self::hex2bin(substr($stat2, 2)); $stat2 = self::hex2bin(substr($stat2, 2));
} }
$sql = 'select bin(0b' . trim($stat1) . ' & ~0b' . trim($stat2) . ') as result'; $sql = 'select bin(0b' . trim($stat1) . ' & ~0b' . trim($stat2) . ') as result';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -548,7 +560,7 @@ class databox_status
{ {
$stat2 = self::hex2bin(substr($stat2, 2)); $stat2 = self::hex2bin(substr($stat2, 2));
} }
$sql = 'select bin(0b' . trim($stat1) . ' | 0b' . trim($stat2) . ') as result'; $sql = 'select bin(0b' . trim($stat1) . ' | 0b' . trim($stat2) . ') as result';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -567,12 +579,12 @@ class databox_status
public static function dec2bin($status) public static function dec2bin($status)
{ {
$status = (string) $status; $status = (string) $status;
if(!ctype_digit($status)) if(!ctype_digit($status))
{ {
throw new \Exception('Non-decimal value'); throw new \Exception('Non-decimal value');
} }
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
$sql = 'select bin(' . $status . ') as result'; $sql = 'select bin(' . $status . ') as result';
@@ -583,7 +595,7 @@ class databox_status
$stmt->closeCursor(); $stmt->closeCursor();
$status = '0'; $status = '0';
if ($row) if ($row)
{ {
$status = $row['result']; $status = $row['result'];
@@ -599,12 +611,12 @@ class databox_status
{ {
$status = substr($status, 2); $status = substr($status, 2);
} }
if(!ctype_xdigit($status)) if(!ctype_xdigit($status))
{ {
throw new \Exception('Non-hexadecimal value'); throw new \Exception('Non-hexadecimal value');
} }
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
$sql = 'select BIN( CAST( 0x'.trim($status).' AS UNSIGNED ) ) as result'; $sql = 'select BIN( CAST( 0x'.trim($status).' AS UNSIGNED ) ) as result';
@@ -615,7 +627,7 @@ class databox_status
$stmt->closeCursor(); $stmt->closeCursor();
$status = '0'; $status = '0';
if ($row) if ($row)
{ {
$status = $row['result']; $status = $row['result'];

View File

@@ -213,7 +213,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
function mail($to, $from, $datas) function mail($to, $from, $datas)
{ {
$subject = sprintf(_('admin::register: Inscription automatique sur %s') $subject = sprintf(_('admin::register: Inscription automatique sur %s')
, GV_homeTitle); , $this->registry->get('GV_homeTitle'));
$body = "<div>" . _('admin::register: un utilisateur s\'est inscrit') $body = "<div>" . _('admin::register: un utilisateur s\'est inscrit')
. "</div>\n"; . "</div>\n";

View File

@@ -76,6 +76,7 @@ class gatekeeper
$session = $appbox->get_session(); $session = $appbox->get_session();
if (http_request::is_command_line()) if (http_request::is_command_line())
return; return;
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF']))
@@ -104,7 +105,7 @@ class gatekeeper
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -121,6 +122,7 @@ class gatekeeper
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php' if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php' || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
return; return;
phrasea::redirect('/login/?redirect=/thesaurus2'); phrasea::redirect('/login/?redirect=/thesaurus2');
break; break;
@@ -129,6 +131,7 @@ class gatekeeper
break; break;
case 'admin': case 'admin':
if ($this->_script_name === 'runscheduler.php') if ($this->_script_name === 'runscheduler.php')
return; return;
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
break; break;
@@ -148,6 +151,7 @@ class gatekeeper
return; return;
case 'setup': case 'setup':
if ($appbox->upgradeavailable()) if ($appbox->upgradeavailable())
return; return;
else else
phrasea::redirect('/login/'); phrasea::redirect('/login/');
@@ -264,6 +268,7 @@ class gatekeeper
$parm = $request->get_parms('LOG'); $parm = $request->get_parms('LOG');
if (is_null($parm["LOG"])) if (is_null($parm["LOG"]))
return $this; return $this;
try try
@@ -281,11 +286,12 @@ class gatekeeper
try try
{ {
$datas = random::helloToken($parm['LOG']); $datas = random::helloToken($parm['LOG']);
return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/"); return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
} }
catch (Exception_NotFound $e) catch (Exception_NotFound $e)
{ {
} }
return $this; return $this;

View File

@@ -33,7 +33,7 @@ class geonames
{ {
return ''; return '';
} }
$registry = registry::get_instance(); $registry = registry::get_instance();
$url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/') $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
. 'get_name.php?geonameid=' . 'get_name.php?geonameid='
@@ -94,6 +94,7 @@ class geonames
$cityName = self::clean_input($cityName); $cityName = self::clean_input($cityName);
if (strlen($cityName) === 0) if (strlen($cityName) === 0)
return $output; return $output;
$registry = registry::get_instance(); $registry = registry::get_instance();
@@ -134,6 +135,7 @@ class geonames
public function find_geoname_from_ip($ip) public function find_geoname_from_ip($ip)
{ {
if (array_key_exists($ip, $this->cache_ips)) if (array_key_exists($ip, $this->cache_ips))
return $this->cache_ips[$ip]; return $this->cache_ips[$ip];
$output = array( $output = array(

View File

@@ -93,7 +93,7 @@ class http_request
return true; return true;
return false; return false;
} }
public function is_secure() public function is_secure()
{ {
return ( return (

View File

@@ -138,7 +138,7 @@ class lazaretFile
$record = new record_adapter($sbas_id, $record_id); $record = new record_adapter($sbas_id, $record_id);
$record->substitute_subdef('document', new system_file($pathfile)); $record->substitute_subdef('document', new system_file($pathfile));
$this->delete(); $this->delete();
return $this; return $this;

View File

@@ -143,6 +143,8 @@ class mail
public static function mail_confirm_registered($email) public static function mail_confirm_registered($email)
{ {
$registry = \registry::get_instance();
$subject = _('login::register: sujet email : confirmation de votre adresse email'); $subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "<div>" . _('login::register: merci d\'avoir confirme votre adresse email') . "</div>\n"; $body = "<div>" . _('login::register: merci d\'avoir confirme votre adresse email') . "</div>\n";

View File

@@ -34,4 +34,4 @@ return call_user_func(
}); });
return $app; return $app;
}); });

View File

@@ -58,6 +58,7 @@ return call_user_func(
{ {
$browser = Browser::getInstance(); $browser = Browser::getInstance();
if (!$browser->isMobile()) if (!$browser->isMobile())
return new Response(''); return new Response('');
$twig = new supertwig(); $twig = new supertwig();

View File

@@ -70,10 +70,11 @@ return call_user_func(function()
return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200); return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200);
} }
return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200); return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200);
} }
}); });
return $app; return $app;
}); });

View File

@@ -34,10 +34,13 @@ return call_user_func(function()
{ {
$browser = Browser::getInstance(); $browser = Browser::getInstance();
if ($browser->isMobile()) if ($browser->isMobile())
return $app->redirect("/login/?redirect=/lightbox"); return $app->redirect("/login/?redirect=/lightbox");
elseif ($browser->isNewGeneration()) elseif ($browser->isNewGeneration())
return $app->redirect("/login/?redirect=/prod"); return $app->redirect("/login/?redirect=/prod");
else else
return $app->redirect("/login/?redirect=/client"); return $app->redirect("/login/?redirect=/client");
}); });
@@ -70,6 +73,7 @@ return call_user_func(function()
/** /**
* Mount all aps * Mount all aps
*/ */
return $app; return $app;
} }
); );

View File

@@ -49,8 +49,10 @@ return call_user_func(function()
$app->get('/', function() use ($app) $app->get('/', function() use ($app)
{ {
if ($app['install'] === true) if ($app['install'] === true)
return $app->redirect('/setup/installer/'); return $app->redirect('/setup/installer/');
if ($app['upgrade'] === true) if ($app['upgrade'] === true)
return $app->redirect('/setup/upgrader/'); return $app->redirect('/setup/upgrader/');
}); });
@@ -63,6 +65,7 @@ return call_user_func(function()
$app->error(function($e) use ($app) $app->error(function($e) use ($app)
{ {
if ($e instanceof Exception_Setup_PhraseaAlreadyInstalled) if ($e instanceof Exception_Setup_PhraseaAlreadyInstalled)
return $app->redirect('/login'); return $app->redirect('/login');
return new Response( return new Response(
@@ -77,4 +80,4 @@ return call_user_func(function()
}); });
return $app; return $app;
}); });

View File

@@ -77,6 +77,7 @@ class module_admin
); );
$twig = new supertwig(); $twig = new supertwig();
return $twig->render('admin/tree.html.twig', $params); return $twig->render('admin/tree.html.twig', $params);
} }

View File

@@ -42,7 +42,7 @@ class module_admin_route_users
return $this; return $this;
} }
public function export(Symfony\Component\HttpFoundation\Request $request) public function export(Symfony\Component\HttpFoundation\Request $request)
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
@@ -143,8 +143,8 @@ class module_admin_route_users
if (is_null($v)) if (is_null($v))
$this->query_parms[$k] = false; $this->query_parms[$k] = false;
} }
$query = new User_Query($appbox); $query = new User_Query($appbox);
$templates = $query $templates = $query
->only_templates(true) ->only_templates(true)

View File

@@ -183,7 +183,7 @@ class module_admin_route_users_edit
$templates = $query $templates = $query
->only_templates(true) ->only_templates(true)
->execute()->get_results(); ->execute()->get_results();
$this->users_datas = $rs; $this->users_datas = $rs;
$out = array( $out = array(
'datas' => $this->users_datas, 'datas' => $this->users_datas,
@@ -543,10 +543,10 @@ class module_admin_route_users_edit
} }
$users = $this->users; $users = $this->users;
$user = User_adapter::getInstance(array_pop($users), appbox::get_instance()); $user = User_adapter::getInstance(array_pop($users), appbox::get_instance());
if ($user->is_template()) if ($user->is_template() || $user->is_special())
{ {
return $this; return $this;
} }
@@ -594,29 +594,29 @@ class module_admin_route_users_edit
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$template = \User_adapter::getInstance($this->request->get('template'), $appbox); $template = \User_adapter::getInstance($this->request->get('template'), $appbox);
if ($template->get_template_owner()->get_id() != $session->get_usr_id()) if ($template->get_template_owner()->get_id() != $session->get_usr_id())
{ {
throw new \Exception_Forbidden('You are not the owner of the template'); throw new \Exception_Forbidden('You are not the owner of the template');
} }
$current_user = \User_adapter::getInstance($session->get_usr_id(), $appbox); $current_user = \User_adapter::getInstance($session->get_usr_id(), $appbox);
$base_ids = array_keys($current_user->ACL()->get_granted_base(array('canadmin'))); $base_ids = array_keys($current_user->ACL()->get_granted_base(array('canadmin')));
foreach ($this->users as $usr_id) foreach ($this->users as $usr_id)
{ {
$user = \User_adapter::getInstance($usr_id, $appbox); $user = \User_adapter::getInstance($usr_id, $appbox);
if($user->is_template()) if($user->is_template())
{ {
continue; continue;
} }
$user->ACL()->apply_model($template, $base_ids); $user->ACL()->apply_model($template, $base_ids);
} }
return $this; return $this;
} }

View File

@@ -338,7 +338,7 @@ return call_user_func(function()
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return new Response(json_encode($result), 200, array("content-type" => "application/json")); return new Response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -367,7 +367,7 @@ return call_user_func(function()
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return new response(json_encode($result), 200, array("content-type" => "application/json")); return new response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -387,7 +387,7 @@ return call_user_func(function()
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return new Response(json_encode($result), 200, array("content-type" => "application/json")); return new Response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -405,7 +405,7 @@ return call_user_func(function()
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return new Response(json_encode($result), 200, array("content-type" => "application/json")); return new Response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -430,4 +430,4 @@ return call_user_func(function()
return $app; return $app;
}); });

View File

@@ -29,7 +29,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception; use Symfony\Component\HttpKernel\Exception;
return call_user_func(function(){ return call_user_func(function(){
$app = new Silex\Application(); $app = new Silex\Application();
@@ -42,7 +42,7 @@ $app["appbox"] = appbox::get_instance();
$app['p4user'] = null; $app['p4user'] = null;
/** /**
* @var API_OAuth2_Token * @var API_OAuth2_Token
*/ */
$app['token'] = null; $app['token'] = null;
@@ -121,6 +121,7 @@ $parseRoute = function ($route, Response $response)
} }
} }
} }
return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action); return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
}; };
@@ -139,6 +140,7 @@ $app->before(function($request) use ($app)
$app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken()); $app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
if ($session->is_authenticated()) if ($session->is_authenticated())
return; return;
if ($oauth2_adapter->has_ses_id()) if ($oauth2_adapter->has_ses_id())
{ {
@@ -150,7 +152,7 @@ $app->before(function($request) use ($app)
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
} }
$auth = new Session_Authentication_None($app['p4user']); $auth = new Session_Authentication_None($app['p4user']);
@@ -171,7 +173,7 @@ $app->after(function (Request $request, Response $response) use ($app, $parseRou
$route = $parseRoute($pathInfo, $response); $route = $parseRoute($pathInfo, $response);
$log = API_V1_Log::create( $log = API_V1_Log::create(
$app["appbox"], $app["appbox"],
$account, $account,
$request->getMethod() . " " . $pathInfo, $request->getMethod() . " " . $pathInfo,
$response->getStatusCode(), $response->getStatusCode(),
$response->headers->get('content-type'), $response->headers->get('content-type'),
@@ -659,7 +661,7 @@ $app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
*/ */
$app->error(function (\Exception $e) use ($app) $app->error(function (\Exception $e) use ($app)
{ {
if ($e instanceof API_V1_exception_methodnotallowed) if ($e instanceof API_V1_exception_methodnotallowed)
$code = API_V1_result::ERROR_METHODNOTALLOWED; $code = API_V1_result::ERROR_METHODNOTALLOWED;
elseif ($e instanceof Exception\MethodNotAllowedHttpException) elseif ($e instanceof Exception\MethodNotAllowedHttpException)
@@ -745,4 +747,4 @@ $app->error(function (\Exception $e) use ($app)
//// public function add_user(\Symfony\Component\HttpFoundation\Request $app['request']); //// public function add_user(\Symfony\Component\HttpFoundation\Request $app['request']);
return $app; return $app;
}); });

View File

@@ -46,14 +46,14 @@ class module_console_systemUpgrade extends Command
$output->writeln('This version of Phraseanet requires a config/config.inc'); $output->writeln('This version of Phraseanet requires a config/config.inc');
$output->writeln('Would you like it to be created based on your settings ?'); $output->writeln('Would you like it to be created based on your settings ?');
$dialog = $this->getHelperSet()->get('dialog'); $dialog = $this->getHelperSet()->get('dialog');
do do
{ {
$continue = mb_strtolower($dialog->ask($output, '<question>' . _('Create automatically') . ' (Y/n)</question>', 'y')); $continue = mb_strtolower($dialog->ask($output, '<question>' . _('Create automatically') . ' (Y/n)</question>', 'y'));
} }
while (!in_array($continue, array('y', 'n'))); while (!in_array($continue, array('y', 'n')));
if ($continue == 'y') if ($continue == 'y')
{ {
require __DIR__ . "/../../../../config/_GV.php"; require __DIR__ . "/../../../../config/_GV.php";
@@ -64,16 +64,16 @@ class module_console_systemUpgrade extends Command
.'$debug=false;'."\n" .'$debug=false;'."\n"
.'$debug=true;'."\n" .'$debug=true;'."\n"
.''; .'';
file_put_contents(__DIR__ . "/../../../../config/config.inc", $datas); file_put_contents(__DIR__ . "/../../../../config/config.inc", $datas);
} }
else else
{ {
throw new RuntimeException('Phraseanet is not set up'); throw new RuntimeException('Phraseanet is not set up');
} }
} }
} }
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';

View File

@@ -75,7 +75,7 @@ class module_prod
else else
$dates[$name] = array('sbas' => array($sbas_id), 'fieldname' => $name); $dates[$name] = array('sbas' => array($sbas_id), 'fieldname' => $name);
} }
if (isset($fields[$name])) if (isset($fields[$name]))
{ {
$fields[$name]['sbas'][] = $sbas_id; $fields[$name]['sbas'][] = $sbas_id;

View File

@@ -46,7 +46,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
* *
* @var Array * @var Array
*/ */
protected $javascript_elements; protected $javascript_elements = array();
/** /**
* *
@@ -244,7 +244,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$_lst[$indice]['type'] = $record->get_type(); $_lst[$indice]['type'] = $record->get_type();
} }
@@ -450,11 +450,12 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
if (!is_array($request->get('mds'))) if (!is_array($request->get('mds')))
return $this; return $this;
$sbas_id = (int) $request->get('sbid'); $sbas_id = (int) $request->get('sbid');

View File

@@ -500,6 +500,7 @@ class module_report
public function getOrder($k = false) public function getOrder($k = false)
{ {
if ($k === false) if ($k === false)
return $this->tab_order; return $this->tab_order;
return $this->tab_order[$k]; return $this->tab_order[$k];
} }
@@ -819,6 +820,7 @@ class module_report
public function buildReport($tab = false, $groupby = false, $on = false) public function buildReport($tab = false, $groupby = false, $on = false)
{ {
if (sizeof($this->report) > 0) if (sizeof($this->report) > 0)
return $this->report; return $this->report;
$conn = connection::getPDOConnection($this->sbas_id); $conn = connection::getPDOConnection($this->sbas_id);

View File

@@ -935,7 +935,7 @@ class module_report_activity extends module_report
AND (" . $collfilter['sql'] . ") AND (" . $collfilter['sql'] . ")
GROUP by ddate GROUP by ddate
ORDER BY ddate ASC"; ORDER BY ddate ASC";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -951,7 +951,7 @@ class module_report_activity extends module_report
{ {
$res[$key] = number_format($act, 2, '.', ''); $res[$key] = number_format($act, 2, '.', '');
} }
return $res; return $res;
} }
@@ -1102,7 +1102,7 @@ class module_report_activity extends module_report
AND (" . $collfilter['sql'] . ") AND (" . $collfilter['sql'] . ")
GROUP BY ddate GROUP BY ddate
ORDER BY activity ASC "; ORDER BY activity ASC ";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -1112,6 +1112,7 @@ class module_report_activity extends module_report
$date = new DateTime($row['ddate']); $date = new DateTime($row['ddate']);
$result[$date->format(DATE_ATOM)] = $row['activity']; $result[$date->format(DATE_ATOM)] = $row['activity'];
} }
return $result; return $result;
} }

View File

@@ -157,8 +157,10 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
public function isValid() public function isValid()
{ {
if (isset($this->dashboard) && sizeof($this->dashboard) > 0) if (isset($this->dashboard) && sizeof($this->dashboard) > 0)
return true; return true;
else else
return false; return false;
} }
@@ -348,11 +350,11 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$i++; $i++;
} }
return; return;
} }

View File

@@ -75,9 +75,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$tmp = new self($sbasid, $sbas_coll, $dmin, $dmax); $tmp = new self($sbasid, $sbas_coll, $dmin, $dmax);
$appbox->set_data_to_cache($tmp, $cache_id); $appbox->set_data_to_cache($tmp, $cache_id);
@@ -131,7 +131,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
* @return <void> * @return <void>
*/ */
public function process() public function process()
{ {
try try
{ {
//Get number of DLs //Get number of DLs
@@ -250,8 +250,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
} }
catch(PDOException $e) catch(PDOException $e)
{ {
} }
return; return;
} }

View File

@@ -149,8 +149,10 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function isValid() public function isValid()
{ {
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0) if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0)
return true; return true;
else else
return false; return false;
} }
@@ -162,10 +164,11 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function getTop($nbtop) public function getTop($nbtop)
{ {
if (!is_int($nbtop)) if (!is_int($nbtop))
return array(); return array();
$tmp = array(); $tmp = array();
if ($this->isValid()) if ($this->isValid())
{ {
foreach ($this->arraySorted as $k => $v) foreach ($this->arraySorted as $k => $v)
@@ -182,6 +185,7 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
} }
} }
} }
return $tmp; return $tmp;
} }

View File

@@ -38,7 +38,7 @@ class module_report_download extends module_report
'mime' => 'subdef.mime', 'mime' => 'subdef.mime',
'file' => 'subdef.file' 'file' => 'subdef.file'
); );
/** /**
* constructor * constructor
* *

View File

@@ -603,10 +603,10 @@ class module_report_nav extends module_report
, 'titre' => $record->get_title() , 'titre' => $record->get_title()
, 'taille' => $document->get_size() , 'taille' => $document->get_size()
); );
$this->setDisplayNav(); $this->setDisplayNav();
$this->setReport(); $this->setReport();
return $this->report; return $this->report;
} }

View File

@@ -55,7 +55,7 @@ class patch_320f implements patchInterface
function apply(base &$appbox) function apply(base &$appbox)
{ {
$feeds = array(); $feeds = array();
try try
{ {
$sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"'; $sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"';
@@ -65,9 +65,9 @@ class patch_320f implements patchInterface
} }
catch(Exception $e) catch(Exception $e)
{ {
} }
$sql = 'SELECT ssel_id, usr_id, name, descript, pub_date $sql = 'SELECT ssel_id, usr_id, name, descript, pub_date
, updater, pub_restrict, homelink , updater, pub_restrict, homelink
FROM ssel WHERE (public = "1" or homelink="1") and migrated = 0'; FROM ssel WHERE (public = "1" or homelink="1") and migrated = 0';
@@ -123,7 +123,7 @@ class patch_320f implements patchInterface
} }
} }
$sql = 'UPDATE ssel SET deleted = "1", migrated="1" $sql = 'UPDATE ssel SET deleted = "1", migrated="1"
WHERE ssel_id = :ssel_id'; WHERE ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $row['ssel_id'])); $stmt->execute(array(':ssel_id' => $row['ssel_id']));

View File

@@ -202,8 +202,8 @@ class random
self::cleanTokens(); self::cleanTokens();
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
$sql = 'SELECT * FROM tokens $sql = 'SELECT * FROM tokens
WHERE value = :token WHERE value = :token
AND (expire_on > NOW() OR expire_on IS NULL)'; AND (expire_on > NOW() OR expire_on IS NULL)';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':token' => $token)); $stmt->execute(array(':token' => $token));

View File

@@ -180,7 +180,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$connbas = $this->databox->get_connection(); $connbas = $this->databox->get_connection();
@@ -530,7 +530,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return null; return null;
@@ -580,7 +580,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$sql = 'SELECT BIN(status) as status FROM record $sql = 'SELECT BIN(status) as status FROM record
WHERE record_id = :record_id'; WHERE record_id = :record_id';
@@ -617,6 +617,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
throw new Exception_Media_SubdefNotFound (); throw new Exception_Media_SubdefNotFound ();
if (isset($this->subdefs[$name])) if (isset($this->subdefs[$name]))
return $this->subdefs[$name]; return $this->subdefs[$name];
if (!$this->subdefs) if (!$this->subdefs)
@@ -657,7 +658,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$connbas = $this->get_databox()->get_connection(); $connbas = $this->get_databox()->get_connection();
@@ -756,8 +757,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if ($data) if ($data)
{ {
if (isset($this->technical_datas[$data])) if (isset($this->technical_datas[$data]))
return $this->technical_datas[$data]; return $this->technical_datas[$data];
else else
return false; return false;
} }
@@ -860,7 +863,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
); );
} }
$sql = 'UPDATE record $sql = 'UPDATE record
SET originalname = :originalname WHERE record_id = :record_id'; SET originalname = :originalname WHERE record_id = :record_id';
$params = array( $params = array(
@@ -1114,7 +1117,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$this->delete_data_from_cache(self::CACHE_SUBDEFS); $this->delete_data_from_cache(self::CACHE_SUBDEFS);
@@ -1227,7 +1230,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$db_field = \databox_field::get_instance($this->get_databox(), $param['meta_struct_id']); $db_field = \databox_field::get_instance($this->get_databox(), $param['meta_struct_id']);
if ($db_field->is_readonly() === false && !$force_readonly) if ($db_field->is_readonly() === true && !$force_readonly)
{ {
continue; continue;
} }
@@ -1340,7 +1343,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$this->delete_data_from_cache(self::CACHE_STATUS); $this->delete_data_from_cache(self::CACHE_STATUS);
@@ -1355,6 +1358,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_reg_name() public function get_reg_name()
{ {
if (!$this->is_grouping()) if (!$this->is_grouping())
return false; return false;
$balisename = ''; $balisename = '';
@@ -1551,6 +1555,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
$hd = $this->get_subdef('document'); $hd = $this->get_subdef('document');
if ($hd->is_physically_present()) if ($hd->is_physically_present())
return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file()); return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file());
return null; return null;
} }
@@ -1773,7 +1778,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$this->delete_data_from_cache(self::CACHE_SUBDEFS); $this->delete_data_from_cache(self::CACHE_SUBDEFS);
} }
@@ -1829,6 +1834,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
$databox = $this->get_databox(); $databox = $this->get_databox();
\cache_databox::update($this->get_sbas_id(), 'record', $this->get_record_id());
return $databox->delete_data_from_cache($this->get_cache_key($option)); return $databox->delete_data_from_cache($this->get_cache_key($option));
} }
@@ -1867,7 +1874,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -1887,6 +1894,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_container_baskets() public function get_container_baskets()
{ {
if ($this->container_basket) if ($this->container_basket)
return $this->container_basket; return $this->container_basket;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();

View File

@@ -86,7 +86,7 @@ class record_preview extends record_adapter
* @param boolean $reload_train * @param boolean $reload_train
* @return record_preview * @return record_preview
*/ */
public function __construct($env, $pos, $contId, $reload_train, searchEngine_adapter $search_engine =null, $query='') public function __construct($env, $pos, $contId, $reload_train, searchEngine_adapter $search_engine = null, $query = '')
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$number = null; $number = null;
@@ -95,7 +95,7 @@ class record_preview extends record_adapter
switch ($env) switch ($env)
{ {
case "RESULT": case "RESULT":
$results = $search_engine->query_per_offset($query, (int) ($pos), 1); $results = $search_engine->query_per_offset($query, (int) ($pos), 1);
$mypreview = array(); $mypreview = array();
if ($results->get_datas()->is_empty()) if ($results->get_datas()->is_empty())
@@ -104,22 +104,22 @@ class record_preview extends record_adapter
} }
foreach ($results->get_datas() as $record) foreach ($results->get_datas() as $record)
{ {
$number = $pos; $number = $pos;
$sbas_id = $record->get_sbas_id(); $sbas_id = $record->get_sbas_id();
$record_id = $record->get_record_id(); $record_id = $record->get_record_id();
break; break;
} }
break; break;
case "REG": case "REG":
$contId = explode('_', $contId); $contId = explode('_', $contId);
$sbas_id = $contId[0]; $sbas_id = $contId[0];
$record_id = $contId[1]; $record_id = $contId[1];
$this->container = new record_adapter($sbas_id, $record_id); $this->container = new record_adapter($sbas_id, $record_id);
if ($pos == 0) if ($pos == 0)
{ {
$number = 0; $number = 0;
$title = _('preview:: regroupement '); $title = _('preview:: regroupement ');
} }
else else
{ {
@@ -127,12 +127,12 @@ class record_preview extends record_adapter
$children = $this->container->get_children(); $children = $this->container->get_children();
foreach ($children as $child) foreach ($children as $child)
{ {
$sbas_id = $child->get_sbas_id(); $sbas_id = $child->get_sbas_id();
$record_id = $child->get_record_id(); $record_id = $child->get_record_id();
if ($child->get_number() == $pos) if ($child->get_number() == $pos)
break; break;
} }
$number = $pos; $number = $pos;
$this->total = $children->get_count(); $this->total = $children->get_count();
} }
@@ -142,7 +142,7 @@ class record_preview extends record_adapter
$this->container = $basket; $this->container = $basket;
$this->total = count($basket->get_elements()); $this->total = count($basket->get_elements());
$i = 0; $i = 0;
$first = true; $first = true;
foreach ($basket->get_elements() as $element) foreach ($basket->get_elements() as $element)
@@ -150,29 +150,29 @@ class record_preview extends record_adapter
$i++; $i++;
if ($first) if ($first)
{ {
$sbas_id = $element->get_record()->get_sbas_id(); $sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id(); $record_id = $element->get_record()->get_record_id();
$this->name = $basket->get_name(); $this->name = $basket->get_name();
$number = $element->get_order(); $number = $element->get_order();
} }
$first = false; $first = false;
if ($element->get_order() == $pos) if ($element->get_order() == $pos)
{ {
$sbas_id = $element->get_record()->get_sbas_id(); $sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id(); $record_id = $element->get_record()->get_record_id();
$this->name = $basket->get_name(); $this->name = $basket->get_name();
$number = $element->get_order(); $number = $element->get_order();
} }
} }
break; break;
case "FEED": case "FEED":
$entry = Feed_Entry_Adapter::load_from_id($appbox, $contId); $entry = Feed_Entry_Adapter::load_from_id($appbox, $contId);
// $basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id()); // $basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id());
$this->container = $entry; $this->container = $entry;
$this->total = count($entry->get_content()); $this->total = count($entry->get_content());
$i = 0; $i = 0;
$first = true; $first = true;
foreach ($entry->get_content() as $element) foreach ($entry->get_content() as $element)
@@ -180,19 +180,19 @@ class record_preview extends record_adapter
$i++; $i++;
if ($first) if ($first)
{ {
$sbas_id = $element->get_record()->get_sbas_id(); $sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id(); $record_id = $element->get_record()->get_record_id();
$this->name = $entry->get_title(); $this->name = $entry->get_title();
$number = $element->get_ord(); $number = $element->get_ord();
} }
$first = false; $first = false;
if ($element->get_ord() == $pos) if ($element->get_ord() == $pos)
{ {
$sbas_id = $element->get_record()->get_sbas_id(); $sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id(); $record_id = $element->get_record()->get_record_id();
$this->name = $entry->get_title(); $this->name = $entry->get_title();
$number = $element->get_ord(); $number = $element->get_ord();
} }
} }
break; break;
@@ -202,7 +202,7 @@ class record_preview extends record_adapter
return $this; return $this;
} }
public function get_train($pos = 0, $query='', searchEngine_adapter $search_engine=null) public function get_train($pos = 0, $query = '', searchEngine_adapter $search_engine = null)
{ {
if ($this->train) if ($this->train)
return $this->train; return $this->train;
@@ -211,8 +211,8 @@ class record_preview extends record_adapter
{ {
case 'RESULT': case 'RESULT':
$perPage = 56; $perPage = 56;
$index = ($pos - 3) < 0 ? 0 : ($pos - 3); $index = ($pos - 3) < 0 ? 0 : ($pos - 3);
$page = (int) ceil($pos / $perPage); $page = (int) ceil($pos / $perPage);
$results = $search_engine->query_per_offset($query, $index, $perPage); $results = $search_engine->query_per_offset($query, $index, $perPage);
$this->train = $results->get_datas(); $this->train = $results->get_datas();
@@ -264,27 +264,27 @@ class record_preview extends record_adapter
* *
* @return String * @return String
*/ */
public function get_title($highlight = '', searchEngine_adapter $search_engine=null) public function get_title($highlight = '', searchEngine_adapter $search_engine = null)
{ {
if ($this->title) if ($this->title)
return $this->title; return $this->title;
$this->title = collection::getLogo($this->get_base_id()) . ' '; $this->title = collection::getLogo($this->get_base_id()) . ' ';
switch ($this->env) switch ($this->env)
{ {
case "RESULT": case "RESULT":
$this->title .= sprintf( $this->title .= sprintf(
_('preview:: resultat numero %s '), '<span id="current_result_n">' . ($this->number + 1) _('preview:: resultat numero %s '), '<span id="current_result_n">' . ($this->number + 1)
. '</span> : ' . '</span> : '
); );
$this->title .= parent::get_title($highlight, $search_engine); $this->title .= parent::get_title($highlight, $search_engine);
break; break;
case "BASK": case "BASK":
$this->title .= $this->name . ' - ' . parent::get_title($highlight, $search_engine) $this->title .= $this->name . ' - ' . parent::get_title($highlight, $search_engine)
. ' (' . $this->get_number() . '/' . $this->total . ') '; . ' (' . $this->get_number() . '/' . $this->total . ') ';
break; break;
case "REG": case "REG":
$title = parent::get_title(); $title = parent::get_title();
@@ -295,7 +295,7 @@ class record_preview extends record_adapter
else else
{ {
$this->title .= sprintf( $this->title .= sprintf(
_('%s %d/%d '), $title, $this->get_number() . '/' . $this->total '%s %d/%d ', $title, $this->get_number(), $this->total
); );
} }
break; break;
@@ -327,16 +327,16 @@ class record_preview extends record_adapter
$tab = array(); $tab = array();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$report = $user->ACL()->has_right_on_base($this->get_base_id(), 'canreport'); $report = $user->ACL()->has_right_on_base($this->get_base_id(), 'canreport');
$connsbas = connection::getPDOConnection($this->get_sbas_id()); $connsbas = connection::getPDOConnection($this->get_sbas_id());
$sql = 'SELECT d . * , l.user, l.usrid as usr_id, l.site $sql = 'SELECT d . * , l.user, l.usrid as usr_id, l.site
FROM log_docs d, log l FROM log_docs d, log l
WHERE d.log_id = l.id WHERE d.log_id = l.id
AND d.record_id = :record_id '; AND d.record_id = :record_id ';
@@ -346,14 +346,14 @@ class record_preview extends record_adapter
{ {
$sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")'; $sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")';
$params[':usr_id'] = $session->get_usr_id(); $params[':usr_id'] = $session->get_usr_id();
$params[':site'] = $registry->get('GV_sit'); $params[':site'] = $registry->get('GV_sit');
} }
$sql .= 'ORDER BY d.date, usrid DESC'; $sql .= 'ORDER BY d.date, usrid DESC';
$stmt = $connsbas->prepare($sql); $stmt = $connsbas->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) foreach ($rs as $row)
@@ -376,7 +376,7 @@ class record_preview extends record_adapter
if (!isset($tab[$hour][$site][$action][$row['usr_id']])) if (!isset($tab[$hour][$site][$action][$row['usr_id']]))
{ {
$user = null; $user = null;
try try
{ {
$user = \User_Adapter::getInstance($row['usr_id'], $appbox); $user = \User_Adapter::getInstance($row['usr_id'], $appbox);
@@ -387,20 +387,20 @@ class record_preview extends record_adapter
} }
$tab[$hour][$site][$action][$row['usr_id']] = $tab[$hour][$site][$action][$row['usr_id']] =
array( array(
'final' => array() 'final' => array()
, 'comment' => array() , 'comment' => array()
, 'user' => $user , 'user' => $user
); );
} }
if (!in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final'])) if (!in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final']))
$tab[$hour][$site][$action][$row['usr_id']]['final'][] = $tab[$hour][$site][$action][$row['usr_id']]['final'][] =
$row['final']; $row['final'];
if (!in_array($row['comment'], $tab[$hour][$site][$action][$row['usr_id']]['comment'])) if (!in_array($row['comment'], $tab[$hour][$site][$action][$row['usr_id']]['comment']))
$tab[$hour][$site][$action][$row['usr_id']]['comment'][] = $tab[$hour][$site][$action][$row['usr_id']]['comment'][] =
$row['comment']; $row['comment'];
} }
$this->short_history = array_reverse($tab); $this->short_history = array_reverse($tab);
@@ -416,12 +416,12 @@ class record_preview extends record_adapter
{ {
if (!is_null($this->view_popularity)) if (!is_null($this->view_popularity))
return $this->view_popularity; return $this->view_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$report = $user->ACL()->has_right_on_base( $report = $user->ACL()->has_right_on_base(
$this->get_base_id(), 'canreport'); $this->get_base_id(), 'canreport');
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
if (!$report && !$registry->get('GV_google_api')) if (!$report && !$registry->get('GV_google_api'))
@@ -432,16 +432,16 @@ class record_preview extends record_adapter
} }
$views = $dwnls = array(); $views = $dwnls = array();
$top = 1; $top = 1;
$day = 30; $day = 30;
$min = 0; $min = 0;
$average = 0; $average = 0;
while ($day >= 0) while ($day >= 0)
{ {
$datetime = new DateTime('-' . $day . ' days'); $datetime = new DateTime('-' . $day . ' days');
$date = date_format($datetime, 'Y-m-d'); $date = date_format($datetime, 'Y-m-d');
$views[$date] = $dwnls[$date] = 0; $views[$date] = $dwnls[$date] = 0;
$day--; $day--;
} }
@@ -454,14 +454,14 @@ class record_preview extends record_adapter
GROUP BY datee ORDER BY datee ASC'; GROUP BY datee ORDER BY datee ASC';
$connsbas = connection::getPDOConnection($this->get_sbas_id()); $connsbas = connection::getPDOConnection($this->get_sbas_id());
$stmt = $connsbas->prepare($sql); $stmt = $connsbas->prepare($sql);
$stmt->execute( $stmt->execute(
array( array(
':record_id' => $this->get_record_id(), ':record_id' => $this->get_record_id(),
':site' => $registry->get('GV_sit') ':site' => $registry->get('GV_sit')
) )
); );
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) foreach ($rs as $row)
@@ -469,8 +469,8 @@ class record_preview extends record_adapter
if (isset($views[$row['datee']])) if (isset($views[$row['datee']]))
{ {
$views[$row['datee']] = (int) $row['views']; $views[$row['datee']] = (int) $row['views'];
$top = max((int) $row['views'], $top); $top = max((int) $row['views'], $top);
$min = isset($min) ? min($row['views'], $min) : $row['views']; $min = isset($min) ? min($row['views'], $min) : $row['views'];
$average += $row['views']; $average += $row['views'];
} }
} }
@@ -478,26 +478,26 @@ class record_preview extends record_adapter
$topScale = round($top * 1.2); $topScale = round($top * 1.2);
$average = $average / 30; $average = $average / 30;
$max = round(($top) * 100 / ($topScale)); $max = round(($top) * 100 / ($topScale));
$min = round($min * 100 / ($topScale)); $min = round($min * 100 / ($topScale));
$average = round($average * 100 / ($topScale)); $average = round($average * 100 / ($topScale));
$width = 350; $width = 350;
$height = 150; $height = 150;
$url = 'http://chart.apis.google.com/chart?' . $url = 'http://chart.apis.google.com/chart?' .
'chs=' . $width . 'x' . $height . 'chs=' . $width . 'x' . $height .
'&chd=t:' . implode(',', $views) . '&chd=t:' . implode(',', $views) .
'&cht=lc' . '&cht=lc' .
'&chf=bg,s,00000000' . '&chf=bg,s,00000000' .
'&chxt=x,y,r' . '&chxt=x,y,r' .
'&chds=0,' . $topScale . '&chds=0,' . $topScale .
'&chls=2.0&chxtc=2,-350' . '&chls=2.0&chxtc=2,-350' .
'&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|' '&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
. date_format(new DateTime('-15 days'), 'd M') . '|' . date_format(new DateTime('-15 days'), 'd M') . '|'
. date_format(new DateTime(), 'd M') . '|1:|0|' . date_format(new DateTime(), 'd M') . '|1:|0|'
. round($top / 2, 2) . '|' . $top . round($top / 2, 2) . '|' . $top
. '|2:|min|average|max' . . '|2:|min|average|max' .
'&chxp=2,' . $min . ',' . $average . ',' . $max; '&chxp=2,' . $min . ',' . $average . ',' . $max;
$this->view_popularity = new media_adapter($url, $width, $height); $this->view_popularity = new media_adapter($url, $width, $height);
@@ -513,12 +513,12 @@ class record_preview extends record_adapter
{ {
if (!is_null($this->refferer_popularity)) if (!is_null($this->refferer_popularity))
return $this->refferer_popularity; return $this->refferer_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$report = $user->ACL()->has_right_on_base( $report = $user->ACL()->has_right_on_base(
$this->get_base_id(), 'canreport'); $this->get_base_id(), 'canreport');
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
if (!$report && !$registry->get('GV_google_api')) if (!$report && !$registry->get('GV_google_api'))
@@ -538,7 +538,7 @@ class record_preview extends record_adapter
$stmt = $connsbas->prepare($sql); $stmt = $connsbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$referrers = array(); $referrers = array();
@@ -566,24 +566,24 @@ class record_preview extends record_adapter
if (strpos($row['referrer'], $registry->get('GV_ServerName') . 'permalink/') !== false) if (strpos($row['referrer'], $registry->get('GV_ServerName') . 'permalink/') !== false)
{ {
if (strpos($row['referrer'], '/view/') !== false) if (strpos($row['referrer'], '/view/') !== false)
$row['referrer'] = _('report::presentation page preview'); $row['referrer'] = _('report::presentation page preview');
else else
$row['referrer'] = _('report::acces direct'); $row['referrer'] = _('report::acces direct');
} }
if (!isset($referrers[$row['referrer']])) if (!isset($referrers[$row['referrer']]))
$referrers[$row['referrer']] = 0; $referrers[$row['referrer']] = 0;
$referrers[$row['referrer']] += (int) $row['views']; $referrers[$row['referrer']] += (int) $row['views'];
} }
$width = 550; $width = 550;
$height = 100; $height = 100;
$url = 'http://chart.apis.google.com/chart?' $url = 'http://chart.apis.google.com/chart?'
. 'cht=p3&chf=bg,s,00000000&chd=t:' . 'cht=p3&chf=bg,s,00000000&chd=t:'
. implode(',', $referrers) . implode(',', $referrers)
. '&chs=' . $width . 'x' . $height . '&chs=' . $width . 'x' . $height
. '&chl=' . '&chl='
. urlencode(implode('|', array_keys($referrers))) . ''; . urlencode(implode('|', array_keys($referrers))) . '';
$this->refferer_popularity = new media_adapter($url, $width, $height); $this->refferer_popularity = new media_adapter($url, $width, $height);
@@ -599,13 +599,13 @@ class record_preview extends record_adapter
if (!is_null($this->download_popularity)) if (!is_null($this->download_popularity))
return $this->download_popularity; return $this->download_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$report = $user->ACL()->has_right_on_base( $report = $user->ACL()->has_right_on_base(
$this->get_base_id(), 'canreport'); $this->get_base_id(), 'canreport');
$ret = false; $ret = false;
if (!$report && !$registry->get('GV_google_api')) if (!$report && !$registry->get('GV_google_api'))
@@ -616,16 +616,16 @@ class record_preview extends record_adapter
} }
$views = $dwnls = array(); $views = $dwnls = array();
$top = 1; $top = 1;
$day = 30; $day = 30;
$min = 0; $min = 0;
$average = 0; $average = 0;
while ($day >= 0) while ($day >= 0)
{ {
$datetime = new DateTime('-' . $day . ' days'); $datetime = new DateTime('-' . $day . ' days');
$date = date_format($datetime, 'Y-m-d'); $date = date_format($datetime, 'Y-m-d');
$views[$date] = $dwnls[$date] = 0; $views[$date] = $dwnls[$date] = 0;
$day--; $day--;
} }
@@ -640,14 +640,14 @@ class record_preview extends record_adapter
GROUP BY datee ORDER BY datee ASC'; GROUP BY datee ORDER BY datee ASC';
$connsbas = connection::getPDOConnection($this->get_sbas_id()); $connsbas = connection::getPDOConnection($this->get_sbas_id());
$stmt = $connsbas->prepare($sql); $stmt = $connsbas->prepare($sql);
$stmt->execute( $stmt->execute(
array( array(
':record_id' => $this->get_record_id(), ':record_id' => $this->get_record_id(),
':site' => $registry->get('GV_sit') ':site' => $registry->get('GV_sit')
) )
); );
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$top = 10; $top = 10;
@@ -657,23 +657,23 @@ class record_preview extends record_adapter
if (isset($dwnls[$row['datee']])) if (isset($dwnls[$row['datee']]))
{ {
$dwnls[$row['datee']] = (int) $row['dwnl']; $dwnls[$row['datee']] = (int) $row['dwnl'];
$top = max(((int) $row['dwnl'] + 10), $top); $top = max(((int) $row['dwnl'] + 10), $top);
} }
} }
$width = 250; $width = 250;
$height = 150; $height = 150;
$url = 'http://chart.apis.google.com/chart?' . $url = 'http://chart.apis.google.com/chart?' .
'chs=' . $width . 'x' . $height . 'chs=' . $width . 'x' . $height .
'&chd=t:' . implode(',', $dwnls) . '&chd=t:' . implode(',', $dwnls) .
'&cht=lc' . '&cht=lc' .
'&chf=bg,s,00000000' . '&chf=bg,s,00000000' .
'&chxt=x,y' . '&chxt=x,y' .
'&chds=0,' . $top . '&chds=0,' . $top .
'&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|' '&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
. date_format(new DateTime('-15 days'), 'd M') . '|' . date_format(new DateTime('-15 days'), 'd M') . '|'
. date_format(new DateTime(), 'd M') . '|1:|0|' . date_format(new DateTime(), 'd M') . '|1:|0|'
. round($top / 2) . '|' . $top . ''; . round($top / 2) . '|' . $top . '';
$ret = new media_adapter($url, $width, $height); $ret = new media_adapter($url, $width, $height);
$this->download_popularity = $ret; $this->download_popularity = $ret;

View File

@@ -131,8 +131,10 @@ class registry implements registryInterface
$this->load(); $this->load();
if(!$this->cache->is_set($key) && !is_null($defaultvalue)) if(!$this->cache->is_set($key) && !is_null($defaultvalue))
return $defaultvalue; return $defaultvalue;
else else
return $this->cache->get($key); return $this->cache->get($key);
} }

View File

@@ -143,7 +143,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
public function set_options(searchEngine_options $options) public function set_options(searchEngine_options $options)
{ {
$this->options = $options; $this->options = $options;
$this->opt_search_type = (int) $options->get_search_type(); $this->opt_search_type = (int) $options->get_search_type();
$this->opt_bases = $options->get_bases(); $this->opt_bases = $options->get_bases();
$this->opt_fields = $options->get_fields(); $this->opt_fields = $options->get_fields();
@@ -397,7 +397,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
$total_time = 0; $total_time = 0;
$sort = ''; $sort = '';
if($this->options->get_sortby()) if($this->options->get_sortby())
{ {
switch($this->options->get_sortord()) switch($this->options->get_sortord())
@@ -412,7 +412,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
} }
$sort .= '0' . $this->options->get_sortby(); $sort .= '0' . $this->options->get_sortby();
} }
foreach ($this->queries as $sbas_id => $qry) foreach ($this->queries as $sbas_id => $qry)
{ {
$this->results[$sbas_id] = phrasea_query2( $this->results[$sbas_id] = phrasea_query2(
@@ -651,7 +651,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{ {
$val = $field['value']; $val = $field['value'];
} }
$ret[] = $val; $ret[] = $val;
} }

View File

@@ -752,9 +752,9 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
'before_match' => "<em>", 'before_match' => "<em>",
'after_match' => "</em>" 'after_match' => "</em>"
); );
$fields_to_send = array(); $fields_to_send = array();
foreach($fields as $k=>$f) foreach($fields as $k=>$f)
{ {
$fields_to_send[$k] = $f['value']; $fields_to_send[$k] = $f['value'];

View File

@@ -353,7 +353,7 @@ class searchEngine_options implements Serializable
{ {
if (!is_null($min_date) && trim($min_date) !== '') if (!is_null($min_date) && trim($min_date) !== '')
{ {
$this->date_min = DateTime::createFromFormat('d/m/Y h:i:s', $min_date.' 00:00:00'); $this->date_min = DateTime::createFromFormat('d/m/Y H:i:s', $min_date.' 00:00:00');
} }
return $this; return $this;
@@ -377,7 +377,7 @@ class searchEngine_options implements Serializable
{ {
if (!is_null($max_date) && trim($max_date) !== '') if (!is_null($max_date) && trim($max_date) !== '')
{ {
$this->date_max = DateTime::createFromFormat('d/m/Y h:i:s', $max_date.' 23:59:59'); $this->date_max = DateTime::createFromFormat('d/m/Y H:i:s', $max_date.' 23:59:59');
} }
return $this; return $this;
@@ -454,13 +454,13 @@ class searchEngine_options implements Serializable
{ {
$tmpvalue = (array) $value; $tmpvalue = (array) $value;
$value = array(); $value = array();
foreach($tmpvalue as $k=>$data) foreach($tmpvalue as $k=>$data)
{ {
$k = ctype_digit($k) ? (int) $k : $k; $k = ctype_digit($k) ? (int) $k : $k;
$value[$k] = $data; $value[$k] = $data;
} }
} }
$this->$key = $value; $this->$key = $value;

View File

@@ -36,8 +36,8 @@ class set_export extends set_abstract
*/ */
public function __construct($lst, $sstid) public function __construct($lst, $sstid)
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
@@ -53,7 +53,7 @@ class set_export extends set_abstract
foreach ($basket->get_elements() as $basket_element) foreach ($basket->get_elements() as $basket_element)
{ {
$base_id = $basket_element->get_record()->get_base_id(); $base_id = $basket_element->get_record()->get_base_id();
$record_id = $basket_element->get_record()->get_record_id(); $record_id = $basket_element->get_record()->get_record_id();
if (!isset($remain_hd[$base_id])) if (!isset($remain_hd[$base_id]))
@@ -69,11 +69,11 @@ class set_export extends set_abstract
} }
$current_element = $download_list[] = $current_element = $download_list[] =
new record_exportElement( new record_exportElement(
$basket_element->get_record()->get_sbas_id(), $basket_element->get_record()->get_sbas_id(),
$record_id, $record_id,
$basket->get_name() . '/', $basket->get_name() . '/',
$remain_hd[$base_id] $remain_hd[$base_id]
); );
$remain_hd[$base_id] = $current_element->get_remain_hd(); $remain_hd[$base_id] = $current_element->get_remain_hd();
@@ -82,7 +82,7 @@ class set_export extends set_abstract
else else
{ {
$tmp_lst = explode(';', $lst); $tmp_lst = explode(';', $lst);
$n = 1; $n = 1;
foreach ($tmp_lst as $basrec) foreach ($tmp_lst as $basrec)
{ {
$basrec = explode('_', $basrec); $basrec = explode('_', $basrec);
@@ -104,7 +104,7 @@ class set_export extends set_abstract
foreach ($record->get_children() as $child_basrec) foreach ($record->get_children() as $child_basrec)
{ {
$base_id = $child_basrec->get_base_id(); $base_id = $child_basrec->get_base_id();
$record_id = $child_basrec->get_record_id(); $record_id = $child_basrec->get_record_id();
if (!isset($remain_hd[$base_id])) if (!isset($remain_hd[$base_id]))
@@ -112,7 +112,7 @@ class set_export extends set_abstract
if ($user->ACL()->is_restricted_download($base_id)) if ($user->ACL()->is_restricted_download($base_id))
{ {
$remain_hd[$base_id] = $remain_hd[$base_id] =
$user->ACL()->remaining_download($base_id); $user->ACL()->remaining_download($base_id);
} }
else else
{ {
@@ -121,11 +121,11 @@ class set_export extends set_abstract
} }
$current_element = $download_list[] = $current_element = $download_list[] =
new record_exportElement( new record_exportElement(
$child_basrec->get_sbas_id(), $child_basrec->get_sbas_id(),
$record_id, $record_id,
$regfield['regname'] . '_' . $n . '/', $regfield['regname'] . '_' . $n . '/',
$remain_hd[$base_id] $remain_hd[$base_id]
); );
$remain_hd[$base_id] = $current_element->get_remain_hd(); $remain_hd[$base_id] = $current_element->get_remain_hd();
@@ -133,7 +133,7 @@ class set_export extends set_abstract
} }
else else
{ {
$base_id = $record->get_base_id(); $base_id = $record->get_base_id();
$record_id = $record->get_record_id(); $record_id = $record->get_record_id();
if (!isset($remain_hd[$base_id])) if (!isset($remain_hd[$base_id]))
@@ -141,7 +141,7 @@ class set_export extends set_abstract
if ($user->ACL()->is_restricted_download($base_id)) if ($user->ACL()->is_restricted_download($base_id))
{ {
$remain_hd[$base_id] = $remain_hd[$base_id] =
$user->ACL()->remaining_download($base_id); $user->ACL()->remaining_download($base_id);
} }
else else
{ {
@@ -149,13 +149,13 @@ class set_export extends set_abstract
} }
} }
$current_element = $current_element =
$download_list[$basrec[0] . '_' . $basrec[1]] = $download_list[$basrec[0] . '_' . $basrec[1]] =
new record_exportElement( new record_exportElement(
$record->get_sbas_id(), $record->get_sbas_id(),
$record_id, $record_id,
'', '',
$remain_hd[$base_id] $remain_hd[$base_id]
); );
$remain_hd[$base_id] = $current_element->get_remain_hd(); $remain_hd[$base_id] = $current_element->get_remain_hd();
@@ -180,10 +180,10 @@ class set_export extends set_abstract
if (!isset($display_download[$name])) if (!isset($display_download[$name]))
{ {
$display_download[$name] = array( $display_download[$name] = array(
'size' => 0, 'size' => 0,
'total' => 0, 'total' => 0,
'available' => 0, 'available' => 0,
'refused' => array() 'refused' => array()
); );
} }
@@ -195,12 +195,12 @@ class set_export extends set_abstract
$display_download[$name]['label'] = $properties['label']; $display_download[$name]['label'] = $properties['label'];
$this->total_download++; $this->total_download++;
$display_download[$name]['size'] += $display_download[$name]['size'] +=
$download_element->get_size($name); $download_element->get_size($name);
} }
else else
{ {
$display_download[$name]['refused'][] = $display_download[$name]['refused'][] =
$download_element->get_thumbnail(); $download_element->get_thumbnail();
} }
} }
foreach ($download_element->get_orderable() as $name => $properties) foreach ($download_element->get_orderable() as $name => $properties)
@@ -208,9 +208,9 @@ class set_export extends set_abstract
if (!isset($display_orderable[$name])) if (!isset($display_orderable[$name]))
{ {
$display_orderable[$name] = array( $display_orderable[$name] = array(
'total' => 0, 'total' => 0,
'available' => 0, 'available' => 0,
'refused' => array() 'refused' => array()
); );
} }
@@ -224,7 +224,7 @@ class set_export extends set_abstract
else else
{ {
$display_orderable[$name]['refused'][] = $display_orderable[$name]['refused'][] =
$download_element->get_thumbnail(); $download_element->get_thumbnail();
} }
} }
} }
@@ -237,10 +237,10 @@ class set_export extends set_abstract
$display_ftp = array(); $display_ftp = array();
$hasadminright = $user->ACL()->has_right('addrecord') $hasadminright = $user->ACL()->has_right('addrecord')
|| $user->ACL()->has_right('deleterecord') || $user->ACL()->has_right('deleterecord')
|| $user->ACL()->has_right('modifyrecord') || $user->ACL()->has_right('modifyrecord')
|| $user->ACL()->has_right('coll_manage') || $user->ACL()->has_right('coll_manage')
|| $user->ACL()->has_right('coll_modify_struct'); || $user->ACL()->has_right('coll_modify_struct');
$this->ftp_datas = array(); $this->ftp_datas = array();
@@ -253,7 +253,7 @@ class set_export extends set_abstract
if ($hasadminright) if ($hasadminright)
{ {
$sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP, $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
usr.pwdFTP,usr.destFTP,prefixFTPfolder,usr.passifFTP, usr.pwdFTP,usr.destFTP,prefixFTPfolder,usr.passifFTP,
usr.retryFTP,usr.usr_mail usr.retryFTP,usr.usr_mail
FROM (usr INNER JOIN basusr FROM (usr INNER JOIN basusr
@@ -269,7 +269,7 @@ class set_export extends set_abstract
} }
elseif ($registry->get('GV_ftp_for_user')) elseif ($registry->get('GV_ftp_for_user'))
{ {
$sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP, $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
usr.pwdFTP,usr.destFTP,prefixFTPfolder, usr.pwdFTP,usr.destFTP,prefixFTPfolder,
usr.passifFTP,usr.retryFTP,usr.usr_mail usr.passifFTP,usr.retryFTP,usr.usr_mail
FROM (usr INNER JOIN basusr FROM (usr INNER JOIN basusr
@@ -285,43 +285,43 @@ class set_export extends set_abstract
} }
$datas[] = array( $datas[] = array(
'name' => _('export::ftp: reglages manuels'), 'name' => _('export::ftp: reglages manuels'),
'usr_id' => '0', 'usr_id' => '0',
'addrFTP' => '', 'addrFTP' => '',
'loginFTP' => '', 'loginFTP' => '',
'pwdFTP' => '', 'pwdFTP' => '',
'ssl' => '0', 'ssl' => '0',
'destFTP' => '', 'destFTP' => '',
'prefixFTPfolder' => 'Export_' . date("Y-m-d_H.i.s"), 'prefixFTPfolder' => 'Export_' . date("Y-m-d_H.i.s"),
'passifFTP' => false, 'passifFTP' => false,
'retryFTP' => 5, 'retryFTP' => 5,
'mailFTP' => '', 'mailFTP' => '',
'sendermail' => $user->get_email() 'sendermail' => $user->get_email()
); );
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$datas[] = array( $datas[] = array(
'name' => $row["usr_login"], 'name' => $row["usr_login"],
'usr_id' => $row['usr_id'], 'usr_id' => $row['usr_id'],
'addrFTP' => $row['addrFTP'], 'addrFTP' => $row['addrFTP'],
'loginFTP' => $row['loginFTP'], 'loginFTP' => $row['loginFTP'],
'pwdFTP' => $row['pwdFTP'], 'pwdFTP' => $row['pwdFTP'],
'ssl' => $row['sslFTP'], 'ssl' => $row['sslFTP'],
'destFTP' => $row['destFTP'], 'destFTP' => $row['destFTP'],
'prefixFTPfolder' => 'prefixFTPfolder' =>
(strlen(trim($row['prefixFTPfolder'])) > 0 ? (strlen(trim($row['prefixFTPfolder'])) > 0 ?
trim($row['prefixFTPfolder']) : trim($row['prefixFTPfolder']) :
'Export_' . date("Y-m-d_H.i.s")), 'Export_' . date("Y-m-d_H.i.s")),
'passifFTP' => ($row['passifFTP'] > 0), 'passifFTP' => ($row['passifFTP'] > 0),
'retryFTP' => $row['retryFTP'], 'retryFTP' => $row['retryFTP'],
'mailFTP' => $row['usr_mail'], 'mailFTP' => $row['usr_mail'],
'sendermail' => $user->get_email() 'sendermail' => $user->get_email()
); );
} }
@@ -411,8 +411,8 @@ class set_export extends set_abstract
{ {
throw new Exception('No subdefs given'); throw new Exception('No subdefs given');
} }
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$unicode = new unicode(); $unicode = new unicode();
@@ -431,11 +431,11 @@ class set_export extends set_abstract
$id = count($files); $id = count($files);
$files[$id] = array( $files[$id] = array(
'base_id' => $download_element->get_base_id(), 'base_id' => $download_element->get_base_id(),
'record_id' => $download_element->get_record_id(), 'record_id' => $download_element->get_record_id(),
'original_name' => '', 'original_name' => '',
'export_name' => '', 'export_name' => '',
'subdefs' => array() 'subdefs' => array()
); );
$sbas_id = phrasea::sbasFromBas($download_element->get_base_id()); $sbas_id = phrasea::sbasFromBas($download_element->get_base_id());
@@ -445,12 +445,12 @@ class set_export extends set_abstract
$desc = $download_element->get_xml(); $desc = $download_element->get_xml();
$files[$id]['original_name'] = $files[$id]['original_name'] =
$files[$id]['export_name'] = $files[$id]['export_name'] =
$download_element->get_original_name(); $download_element->get_original_name();
$files[$id]['original_name'] = $files[$id]['original_name'] =
trim($files[$id]['original_name']) != '' ? trim($files[$id]['original_name']) != '' ?
$files[$id]['original_name'] : $id; $files[$id]['original_name'] : $id;
$infos = pathinfo($files[$id]['original_name']); $infos = pathinfo($files[$id]['original_name']);
@@ -462,7 +462,7 @@ class set_export extends set_abstract
$title = strip_tags($download_element->get_title()); $title = strip_tags($download_element->get_title());
$files[$id]['export_name'] = $unicode->remove_nonazAZ09($title, true); $files[$id]['export_name'] = $unicode->remove_nonazAZ09($title, true);
$rename_done = true; $rename_done = true;
} }
else else
{ {
@@ -470,12 +470,12 @@ class set_export extends set_abstract
} }
$sizeMaxAjout = 0; $sizeMaxAjout = 0;
$sizeMaxExt = 0; $sizeMaxExt = 0;
$sd = $download_element->get_subdefs(); $sd = $download_element->get_subdefs();
foreach ($download_element->get_downloadable() as $name => $properties) foreach ($download_element->get_downloadable() as $name => $properties)
{ {
if ($properties === false || !in_array($name, $subdefs)) if ($properties === false || !in_array($name, $subdefs))
{ {
continue; continue;
@@ -486,7 +486,7 @@ class set_export extends set_abstract
} }
set_time_limit(100); set_time_limit(100);
$subdef_export = $subdef_alive = false; $subdef_export = $subdef_alive = false;
$n_files++; $n_files++;
@@ -497,32 +497,32 @@ class set_export extends set_abstract
case 'caption': case 'caption':
case 'caption-yaml': case 'caption-yaml':
$subdef_export = true; $subdef_export = true;
$subdef_alive = true; $subdef_alive = true;
break; break;
case 'thumbnail': case 'thumbnail':
$tmp_pathfile = array( $tmp_pathfile = array(
'path' => $sd[$name]->get_path() 'path' => $sd[$name]->get_path()
, 'file' => $sd[$name]->get_file() , 'file' => $sd[$name]->get_file()
); );
$subdef_export = true; $subdef_export = true;
$subdef_alive = true; $subdef_alive = true;
break; break;
case 'document': case 'document':
$subdef_export = true; $subdef_export = true;
$path = recordutils_image::stamp( $path = recordutils_image::stamp(
$download_element->get_base_id() $download_element->get_base_id()
, $download_element->get_record_id() , $download_element->get_record_id()
, true , true
); );
$tmp_pathfile = array( $tmp_pathfile = array(
'path' => $sd[$name]->get_path() 'path' => $sd[$name]->get_path()
, 'file' => $sd[$name]->get_file() , 'file' => $sd[$name]->get_file()
); );
if (file_exists($path)) if (file_exists($path))
{ {
$tmp_pathfile = array( $tmp_pathfile = array(
'path' => dirname($path) 'path' => dirname($path)
, 'file' => basename($path) , 'file' => basename($path)
); );
$subdef_alive = true; $subdef_alive = true;
} }
@@ -532,24 +532,24 @@ class set_export extends set_abstract
$subdef_export = true; $subdef_export = true;
$tmp_pathfile = array( $tmp_pathfile = array(
'path' => $sd[$name]->get_path() 'path' => $sd[$name]->get_path()
, 'file' => $sd[$name]->get_file() , 'file' => $sd[$name]->get_file()
); );
if (!$user->ACL()->has_right_on_base( if (!$user->ACL()->has_right_on_base(
$download_element->get_base_id() $download_element->get_base_id()
, "nowatermark" , "nowatermark"
) )
&& $sd[$name]->get_type() == media_subdef::TYPE_IMAGE) && $sd[$name]->get_type() == media_subdef::TYPE_IMAGE)
{ {
$path = recordutils_image::watermark( $path = recordutils_image::watermark(
$download_element->get_base_id() $download_element->get_base_id()
, $download_element->get_record_id() , $download_element->get_record_id()
); );
if (file_exists($path)) if (file_exists($path))
{ {
$tmp_pathfile = array( $tmp_pathfile = array(
'path' => dirname($path) 'path' => dirname($path)
, 'file' => basename($path) , 'file' => basename($path)
); );
$subdef_alive = true; $subdef_alive = true;
} }
@@ -568,44 +568,44 @@ class set_export extends set_abstract
case 'caption': case 'caption':
if ($name == 'caption-yaml') if ($name == 'caption-yaml')
{ {
$suffix = '_captionyaml'; $suffix = '_captionyaml';
$extension = 'yml'; $extension = 'yml';
$mime = 'text/x-yaml'; $mime = 'text/x-yaml';
} }
else else
{ {
$suffix = '_caption'; $suffix = '_caption';
$extension = 'xml'; $extension = 'xml';
$mime = 'text/xml'; $mime = 'text/xml';
} }
$files[$id]["subdefs"][$name]["ajout"] = $suffix; $files[$id]["subdefs"][$name]["ajout"] = $suffix;
$files[$id]["subdefs"][$name]["exportExt"] = $extension; $files[$id]["subdefs"][$name]["exportExt"] = $extension;
$files[$id]["subdefs"][$name]["label"] = $properties['label']; $files[$id]["subdefs"][$name]["label"] = $properties['label'];
$files[$id]["subdefs"][$name]["path"] = null; $files[$id]["subdefs"][$name]["path"] = null;
$files[$id]["subdefs"][$name]["file"] = null; $files[$id]["subdefs"][$name]["file"] = null;
$files[$id]["subdefs"][$name]["size"] = 0; $files[$id]["subdefs"][$name]["size"] = 0;
$files[$id]["subdefs"][$name]["folder"] = $download_element->get_directory(); $files[$id]["subdefs"][$name]["folder"] = $download_element->get_directory();
$files[$id]["subdefs"][$name]["mime"] = $mime; $files[$id]["subdefs"][$name]["mime"] = $mime;
break; break;
case 'document': case 'document':
case 'preview': case 'preview':
case 'thumbnail': case 'thumbnail':
$infos = pathinfo(p4string::addEndSlash($tmp_pathfile["path"]) . $infos = pathinfo(p4string::addEndSlash($tmp_pathfile["path"]) .
$tmp_pathfile["file"]); $tmp_pathfile["file"]);
$files[$id]["subdefs"][$name]["ajout"] = $files[$id]["subdefs"][$name]["ajout"] =
$properties['class'] == 'document' ? '' : "_" . $name; $properties['class'] == 'document' ? '' : "_" . $name;
$files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"]; $files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"];
$files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"]; $files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"];
$files[$id]["subdefs"][$name]["label"] = $properties['label']; $files[$id]["subdefs"][$name]["label"] = $properties['label'];
$files[$id]["subdefs"][$name]["size"] = $sd[$name]->get_size(); $files[$id]["subdefs"][$name]["size"] = $sd[$name]->get_size();
$files[$id]["subdefs"][$name]["mime"] = $sd[$name]->get_mime(); $files[$id]["subdefs"][$name]["mime"] = $sd[$name]->get_mime();
$files[$id]["subdefs"][$name]["folder"] = $files[$id]["subdefs"][$name]["folder"] =
$download_element->get_directory(); $download_element->get_directory();
$files[$id]["subdefs"][$name]["exportExt"] = $files[$id]["subdefs"][$name]["exportExt"] =
isset($infos['extension']) ? $infos['extension'] : ''; isset($infos['extension']) ? $infos['extension'] : '';
$size += $sd[$name]->get_size(); $size += $sd[$name]->get_size();
@@ -613,12 +613,12 @@ class set_export extends set_abstract
} }
$longueurAjoutCourant = $longueurAjoutCourant =
mb_strlen($files[$id]["subdefs"][$name]["ajout"]); mb_strlen($files[$id]["subdefs"][$name]["ajout"]);
$sizeMaxAjout = max($longueurAjoutCourant, $sizeMaxAjout); $sizeMaxAjout = max($longueurAjoutCourant, $sizeMaxAjout);
$longueurExtCourant = $longueurExtCourant =
mb_strlen($files[$id]["subdefs"][$name]["exportExt"]); mb_strlen($files[$id]["subdefs"][$name]["exportExt"]);
$sizeMaxExt = max($longueurExtCourant, $sizeMaxExt); $sizeMaxExt = max($longueurExtCourant, $sizeMaxExt);
} }
} }
@@ -628,34 +628,34 @@ class set_export extends set_abstract
$start_length = mb_strlen($name); $start_length = mb_strlen($name);
if ($start_length > $max_length) if ($start_length > $max_length)
$name = mb_substr($name, 0, $max_length); $name = mb_substr($name, 0, $max_length);
$n = 1; $n = 1;
while (in_array(mb_strtolower($name), $file_names)) while (in_array(mb_strtolower($name), $file_names))
{ {
$n++; $n++;
$suffix = "-" . $n; // pour diese si besoin $suffix = "-" . $n; // pour diese si besoin
$max_length = 31 - $sizeMaxExt - $sizeMaxAjout - mb_strlen($suffix); $max_length = 31 - $sizeMaxExt - $sizeMaxAjout - mb_strlen($suffix);
$name = mb_strtolower($files[$id]["export_name"]); $name = mb_strtolower($files[$id]["export_name"]);
if ($start_length > $max_length) if ($start_length > $max_length)
$name = mb_substr($name, 0, $max_length) . $suffix; $name = mb_substr($name, 0, $max_length) . $suffix;
else else
$name = $name . $suffix; $name = $name . $suffix;
} }
$file_names[] = mb_strtolower($name); $file_names[] = mb_strtolower($name);
$files[$id]["export_name"] = $name; $files[$id]["export_name"] = $name;
$files[$id]["export_name"] = $unicode->remove_nonazAZ09($files[$id]["export_name"]); $files[$id]["export_name"] = $unicode->remove_nonazAZ09($files[$id]["export_name"]);
$files[$id]["original_name"] = $unicode->remove_nonazAZ09($files[$id]["original_name"]); $files[$id]["original_name"] = $unicode->remove_nonazAZ09($files[$id]["original_name"]);
$i = 0; $i = 0;
$name = utf8_decode($files[$id]["export_name"]); $name = utf8_decode($files[$id]["export_name"]);
$tmp_name = ""; $tmp_name = "";
$good_keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', $good_keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '-', '_', '.', '#'); '4', '5', '6', '7', '8', '9', '-', '_', '.', '#');
while (isset($name[$i])) while (isset($name[$i]))
{ {
@@ -673,19 +673,19 @@ class set_export extends set_abstract
if (in_array('caption', $subdefs)) if (in_array('caption', $subdefs))
{ {
$caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/' $caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/'
. time() . $session->get_usr_id() . time() . $session->get_usr_id()
. $session->get_ses_id() . '/'; . $session->get_ses_id() . '/';
system_file::mkdir($caption_dir); system_file::mkdir($caption_dir);
$desc = self::get_caption( $desc = self::get_caption(
$download_element->get_base_id() $download_element->get_base_id()
, $download_element->get_record_id() , $download_element->get_record_id()
); );
$file = $files[$id]["export_name"] $file = $files[$id]["export_name"]
. $files[$id]["subdefs"]['caption']["ajout"] . '.' . $files[$id]["subdefs"]['caption']["ajout"] . '.'
. $files[$id]["subdefs"]['caption']["exportExt"]; . $files[$id]["subdefs"]['caption']["exportExt"];
$path = $caption_dir; $path = $caption_dir;
@@ -701,22 +701,22 @@ class set_export extends set_abstract
if (in_array('caption-yaml', $subdefs)) if (in_array('caption-yaml', $subdefs))
{ {
$caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/' $caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/'
. time() . $session->get_usr_id() . time() . $session->get_usr_id()
. $session->get_ses_id() . '/'; . $session->get_ses_id() . '/';
system_file::mkdir($caption_dir); system_file::mkdir($caption_dir);
$desc = self::get_caption( $desc = self::get_caption(
$download_element->get_base_id() $download_element->get_base_id()
, $download_element->get_record_id() , $download_element->get_record_id()
, true , true
, 'yaml' , 'yaml'
); );
$file = $files[$id]["export_name"] $file = $files[$id]["export_name"]
. $files[$id]["subdefs"]['caption-yaml']["ajout"] . '.' . $files[$id]["subdefs"]['caption-yaml']["ajout"] . '.'
. $files[$id]["subdefs"]['caption-yaml']["exportExt"]; . $files[$id]["subdefs"]['caption-yaml']["exportExt"];
$path = $caption_dir; $path = $caption_dir;
@@ -732,10 +732,10 @@ class set_export extends set_abstract
} }
$this->list = array( $this->list = array(
'files' => $files, 'files' => $files,
'names' => $file_names, 'names' => $file_names,
'size' => $size, 'size' => $size,
'count' => $n_files 'count' => $n_files
); );
@@ -769,13 +769,13 @@ class set_export extends set_abstract
random::updateToken($token, serialize($list)); random::updateToken($token, serialize($list));
$str_in = array("à", "á", "â", "ã", "ä", "å", "ç", "è", "é", "ê", $str_in = array("à", "á", "â", "ã", "ä", "å", "ç", "è", "é", "ê",
"ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô",
"õ", "ö", "ù", "ú", "û", "ü", "ý", "ÿ"); "õ", "ö", "ù", "ú", "û", "ü", "ý", "ÿ");
$str_out = array("a", "a", "a", "a", "a", "a", "c", "e", "e", "e", $str_out = array("a", "a", "a", "a", "a", "a", "c", "e", "e", "e",
"e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o",
"o", "o", "u", "u", "u", "u", "y", "y"); "o", "o", "u", "u", "u", "u", "y", "y");
$caption_dirs = $unlinks = array(); $caption_dirs = $unlinks = array();
foreach ($files as $record) foreach ($files as $record)
{ {
@@ -787,9 +787,9 @@ class set_export extends set_abstract
if (is_file($path)) if (is_file($path))
{ {
$name = $obj["folder"] $name = $obj["folder"]
. $record["export_name"] . $record["export_name"]
. $obj["ajout"] . $obj["ajout"]
. '.' . $obj["exportExt"]; . '.' . $obj["exportExt"];
$name = str_replace($str_in, $str_out, $name); $name = str_replace($str_in, $str_out, $name);
@@ -799,7 +799,7 @@ class set_export extends set_abstract
{ {
if (!in_array(dirname($path), $caption_dirs)) if (!in_array(dirname($path), $caption_dirs))
$caption_dirs[] = dirname($path); $caption_dirs[] = dirname($path);
$unlinks[] = $path; $unlinks[] = $path;
} }
} }
} }
@@ -842,7 +842,7 @@ class set_export extends set_abstract
$dom->encoding = 'UTF-8'; $dom->encoding = 'UTF-8';
$dom_record = $dom->createElement('record'); $dom_record = $dom->createElement('record');
$dom_desc = $dom->createElement('description'); $dom_desc = $dom->createElement('description');
$dom_record->appendChild($dom_desc); $dom_record->appendChild($dom_desc);
$dom->appendChild($dom_record); $dom->appendChild($dom_record);
@@ -850,19 +850,19 @@ class set_export extends set_abstract
$restrict = array(); $restrict = array();
$sbas_id = phrasea::sbasFromBas($bas); $sbas_id = phrasea::sbasFromBas($bas);
$record = new record_adapter($sbas_id, $rec); $record = new record_adapter($sbas_id, $rec);
$desc = $record->get_xml(); $desc = $record->get_xml();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$databox = databox::get_instance($sbas_id); $databox = databox::get_instance($sbas_id);
$struct = $databox->get_structure(); $struct = $databox->get_structure();
$rights = true; $rights = true;
if ($check_rights && $session->is_authenticated()) if ($check_rights && $session->is_authenticated())
{ {
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$rights = $user->ACL()->has_right_on_base($bas, 'canmodifrecord'); $rights = $user->ACL()->has_right_on_base($bas, 'canmodifrecord');
if ($rights == false) if ($rights == false)
@@ -875,7 +875,7 @@ class set_export extends set_abstract
foreach ($z[0] as $ki => $vi) foreach ($z[0] as $ki => $vi)
{ {
if (isset($vi["export"]) if (isset($vi["export"])
&& ($vi["export"] == "0" || $vi["export"] == "off")) && ($vi["export"] == "0" || $vi["export"] == "off"))
$restrict[$ki] = true; $restrict[$ki] = true;
} }
} }
@@ -885,36 +885,27 @@ class set_export extends set_abstract
$buffer = array(); $buffer = array();
if ($sxe = simplexml_load_string($desc)) foreach ($record->get_caption()->get_fields() as $field)
{ {
$z = $sxe->xpath('/record/description'); if (($rights || !isset($restrict[$field->get_name()])))
if ($z && is_array($z))
{ {
foreach ($z[0] as $ki => $vi) switch ($format)
{ {
if (($rights || !isset($restrict[$ki]))) case 'yaml':
{ case 'yml':
$vi = $field->get_value();
if (ctype_digit($vi))
$vi = (int) $vi;
switch ($format) $buffer[$field->get_name()] = $vi;
{ break;
case 'yaml': case 'xml':
case 'yml': default:
$dom_el = $dom->createElement($field->get_name());
$vi = trim($vi); $dom_el->appendChild($dom->createTextNode($field->get_value(true)));
if (ctype_digit($vi)) $dom_desc->appendChild($dom_el);
$vi = (int) $vi; break;
$buffer[trim($ki)] = $vi;
break;
case 'xml':
default:
$dom_el = $dom->createElement($ki);
$dom_el->appendChild($dom->createTextNode(trim($vi)));
$dom_desc->appendChild($dom_el);
break;
}
}
} }
} }
} }
@@ -954,7 +945,7 @@ class set_export extends set_abstract
$registry = registry::get_instance(); $registry = registry::get_instance();
$disposition = in_array($disposition, array('inline', 'attachment')) ? $disposition = in_array($disposition, array('inline', 'attachment')) ?
$disposition : 'attachment'; $disposition : 'attachment';
$response = new Symfony\Component\HttpFoundation\Response(); $response = new Symfony\Component\HttpFoundation\Response();
@@ -964,17 +955,17 @@ class set_export extends set_abstract
if ($registry->get('GV_modxsendfile') && strpos($file, $registry->get('GV_X_Accel_Redirect')) !== false) if ($registry->get('GV_modxsendfile') && strpos($file, $registry->get('GV_X_Accel_Redirect')) !== false)
{ {
$file_xaccel = str_replace( $file_xaccel = str_replace(
array( array(
$registry->get('GV_X_Accel_Redirect'), $registry->get('GV_X_Accel_Redirect'),
$registry->get('GV_RootPath') . 'tmp/download/', $registry->get('GV_RootPath') . 'tmp/download/',
$registry->get('GV_RootPath') . 'tmp/lazaret/' $registry->get('GV_RootPath') . 'tmp/lazaret/'
) )
, array( , array(
'/' . $registry->get('GV_X_Accel_Redirect_mount_point') . '/', '/' . $registry->get('GV_X_Accel_Redirect_mount_point') . '/',
'/download/', '/download/',
'/lazaret/' '/lazaret/'
) )
, $file , $file
); );
$response->headers->set('X-Sendfile', $file); $response->headers->set('X-Sendfile', $file);
$response->headers->set('X-Accel-Redirect', $file_xaccel); $response->headers->set('X-Accel-Redirect', $file_xaccel);
@@ -989,13 +980,13 @@ class set_export extends set_abstract
else else
{ {
/** /**
* *
* Header "Pragma: public" SHOULD be present. * Header "Pragma: public" SHOULD be present.
* In case it is not present, download on IE 8 and previous over HTTPS * In case it is not present, download on IE 8 and previous over HTTPS
* will fail. * will fail.
* *
* @todo : merge this shitty fix with Response object. * @todo : merge this shitty fix with Response object.
* *
*/ */
if (!headers_sent()) if (!headers_sent())
{ {
@@ -1007,6 +998,7 @@ class set_export extends set_abstract
$response->headers->set('Content-Disposition', $disposition . "; filename=" . $exportname . ";"); $response->headers->set('Content-Disposition', $disposition . "; filename=" . $exportname . ";");
$response->headers->set('Content-Length', filesize($file)); $response->headers->set('Content-Length', filesize($file));
$response->setContent(file_get_contents($file)); $response->setContent(file_get_contents($file));
return $response; return $response;
} }
} }
@@ -1034,7 +1026,7 @@ class set_export extends set_abstract
header("Content-Length: " . strlen($data)); header("Content-Length: " . strlen($data));
header("Cache-Control: max-age=3600, must-revalidate "); header("Cache-Control: max-age=3600, must-revalidate ");
header("Content-Disposition: " . $disposition header("Content-Disposition: " . $disposition
. "; filename=" . $exportname . ";"); . "; filename=" . $exportname . ";");
echo $data; echo $data;
@@ -1052,9 +1044,9 @@ class set_export extends set_abstract
public static function log_download(Array $list, $type, $anonymous = false, $comment = '') public static function log_download(Array $list, $type, $anonymous = false, $comment = '')
{ {
//download //download
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$user = false; $user = false;
if ($anonymous) if ($anonymous)
{ {
@@ -1068,8 +1060,8 @@ class set_export extends set_abstract
$files = $list['files']; $files = $list['files'];
$event_names = array( $event_names = array(
'mail-export' => Session_Logger::EVENT_EXPORTMAIL, 'mail-export' => Session_Logger::EVENT_EXPORTMAIL,
'download' => Session_Logger::EVENT_EXPORTDOWNLOAD 'download' => Session_Logger::EVENT_EXPORTDOWNLOAD
); );
$event_name = isset($event_names[$type]) ? $event_names[$type] : Session_Logger::EVENT_EXPORTDOWNLOAD; $event_name = isset($event_names[$type]) ? $event_names[$type] : Session_Logger::EVENT_EXPORTDOWNLOAD;
@@ -1078,18 +1070,18 @@ class set_export extends set_abstract
{ {
foreach ($record["subdefs"] as $o => $obj) foreach ($record["subdefs"] as $o => $obj)
{ {
$sbas_id = phrasea::sbasFromBas($record['base_id']); $sbas_id = phrasea::sbasFromBas($record['base_id']);
$record_object = new record_adapter($sbas_id, $record['record_id']); $record_object = new record_adapter($sbas_id, $record['record_id']);
$session->get_logger($record_object->get_databox()) $session->get_logger($record_object->get_databox())
->log($record_object, $event_name, $o, $comment); ->log($record_object, $event_name, $o, $comment);
if ($o != "caption") if ($o != "caption")
{ {
$log["rid"] = $record_object->get_record_id(); $log["rid"] = $record_object->get_record_id();
$log["subdef"] = $o; $log["subdef"] = $o;
$log["poids"] = $obj["size"]; $log["poids"] = $obj["size"];
$log["shortXml"] = $record_object->get_xml(); $log["shortXml"] = $record_object->get_xml();
$tmplog[$record_object->get_base_id()][] = $log; $tmplog[$record_object->get_base_id()][] = $log;
if (!$anonymous && $o == 'document') if (!$anonymous && $o == 'document')
$user->ACL()->remove_remaining($record_object->get_base_id()); $user->ACL()->remove_remaining($record_object->get_base_id());
@@ -1100,9 +1092,9 @@ class set_export extends set_abstract
} }
$export_types = array( $export_types = array(
'download' => 0, 'download' => 0,
'mail-export' => 2, 'mail-export' => 2,
'ftp' => 4 'ftp' => 4
); );
$list_base = array_unique(array_keys($tmplog)); $list_base = array_unique(array_keys($tmplog));
@@ -1120,9 +1112,9 @@ class set_export extends set_abstract
if ($user->ACL()->is_restricted_download($base_id)) if ($user->ACL()->is_restricted_download($base_id))
{ {
$params = array( $params = array(
':remain_dl' => $user->ACL()->remaining_download($base_id) ':remain_dl' => $user->ACL()->remaining_download($base_id)
, ':base_id' => $base_id , ':base_id' => $base_id
, ':usr_id' => $user->get_id() , ':usr_id' => $user->get_id()
); );
$stmt->execute($params); $stmt->execute($params);

View File

@@ -19,9 +19,11 @@ use Symfony\Component\Console\Output\OutputInterface;
class task_Scheduler class task_Scheduler
{ {
const TASKDELAYTOQUIT = 60; const TASKDELAYTOQUIT = 60;
protected $output; protected $output;
protected static $connection;
protected function log($message) protected function log($message)
{ {
@@ -31,12 +33,12 @@ class task_Scheduler
} }
$registry = registry::get_instance(); $registry = registry::get_instance();
$logdir = $registry->get('GV_RootPath') . 'logs/'; $logdir = $registry->get('GV_RootPath') . 'logs/';
logs::rotate($logdir . "scheduler.log"); logs::rotate($logdir . "scheduler.log");
$date_obj = new DateTime(); $date_obj = new DateTime();
$message = sprintf("%s %s \n", $date_obj->format(DATE_ATOM), $message); $message = sprintf("%s %s \n", $date_obj->format(DATE_ATOM), $message);
file_put_contents($logdir . "scheduler.log", $message, FILE_APPEND); file_put_contents($logdir . "scheduler.log", $message, FILE_APPEND);
@@ -47,14 +49,19 @@ class task_Scheduler
{ {
require dirname(__FILE__) . '/../../../config/connexion.inc'; require dirname(__FILE__) . '/../../../config/connexion.inc';
return new connection_pdo('appbox', $hostname, $port, $user, $password, $dbname); if (!self::$connection)
{
self::$connection = new connection_pdo ('appbox', $hostname, $port, $user, $password, $dbname);
}
return self::$connection;
} }
public function run(OutputInterface $output = null, $log_tasks = true) public function run(OutputInterface $output = null, $log_tasks = true)
{ {
require_once dirname(__FILE__) . '/../../bootstrap.php'; require_once dirname(__FILE__) . '/../../bootstrap.php';
$this->output = $output; $this->output = $output;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$system = system_server::get_platform(); $system = system_server::get_platform();
@@ -63,7 +70,7 @@ class task_Scheduler
for ($try = 0; true; $try++) for ($try = 0; true; $try++)
{ {
$schedlock = fopen(($lockfile = ($lockdir . 'scheduler.lock')), 'a+'); $schedlock = fopen(($lockfile = ($lockdir . 'scheduler.lock')), 'a+');
if (flock($schedlock, LOCK_EX | LOCK_NB) != true) if (flock($schedlock, LOCK_EX | LOCK_NB) != true)
{ {
$this->log(sprintf("failed to lock '%s' (try=%s/4)", $lockfile, $try)); $this->log(sprintf("failed to lock '%s' (try=%s/4)", $lockfile, $try));
@@ -96,7 +103,7 @@ class task_Scheduler
$sleeptime = 3; $sleeptime = 3;
$sql = "UPDATE sitepreff SET schedstatus='started', schedpid = :pid"; $sql = "UPDATE sitepreff SET schedstatus='started', schedpid = :pid";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':pid' => getmypid())); $stmt->execute(array(':pid' => getmypid()));
$stmt->closeCursor(); $stmt->closeCursor();
@@ -139,14 +146,14 @@ class task_Scheduler
$this->log(sprintf("Warning : abox connection lost, restarting in 10 min.")); $this->log(sprintf("Warning : abox connection lost, restarting in 10 min."));
} }
sleep(60 * 10); sleep(60 * 10);
$conn = self::get_connection(); $conn = self::get_connection();
$connwaslost = true; $connwaslost = true;
} }
if ($connwaslost) if ($connwaslost)
{ {
$this->log("abox connection restored"); $this->log("abox connection restored");
$sql = 'UPDATE task SET crashed=0'; $sql = 'UPDATE task SET crashed=0';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$stmt->closeCursor(); $stmt->closeCursor();
@@ -155,10 +162,10 @@ class task_Scheduler
} }
$schedstatus = ''; $schedstatus = '';
$sql = "SELECT schedstatus FROM sitepreff"; $sql = "SELECT schedstatus FROM sitepreff";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if ($row) if ($row)
@@ -168,13 +175,13 @@ class task_Scheduler
if ($schedstatus == 'tostop') if ($schedstatus == 'tostop')
{ {
$sql = 'UPDATE sitepreff SET schedstatus = "stopping"'; $sql = 'UPDATE sitepreff SET schedstatus = "stopping"';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$stmt->closeCursor(); $stmt->closeCursor();
// if scheduler is stopped, stop the tasks // if scheduler is stopped, stop the tasks
$sql = 'UPDATE task2 SET status="tostop" WHERE status != "stopped" and status != "manual"'; $sql = 'UPDATE task2 SET status="tostop" WHERE status != "stopped" and status != "manual"';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$stmt->closeCursor(); $stmt->closeCursor();
@@ -194,10 +201,10 @@ class task_Scheduler
$ttask[$tkey]["todel"] = true; $ttask[$tkey]["todel"] = true;
} }
$sql = "SELECT * FROM task2"; $sql = "SELECT * FROM task2";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($task_manager->get_tasks(true) as $task) foreach ($task_manager->get_tasks(true) as $task)
@@ -218,27 +225,27 @@ class task_Scheduler
case "WINDOWS": case "WINDOWS":
case "LINUX": case "LINUX":
$cmd = $phpcli . ' -f ' $cmd = $phpcli . ' -f '
. $registry->get('GV_RootPath') . $registry->get('GV_RootPath')
. "bin/console task:run " . "bin/console task:run "
. $task->get_task_id() . $task->get_task_id()
. " --runner=scheduler "; . " --runner=scheduler ";
break; break;
} }
$ttask[$tkey] = array( $ttask[$tkey] = array(
"task" => $task, "task" => $task,
"current_status" => $task->get_status(), "current_status" => $task->get_status(),
"process" => null, "process" => null,
"cmd" => $cmd, "cmd" => $cmd,
"killat" => null, "killat" => null,
"pipes" => null "pipes" => null
); );
$this->log( $this->log(
sprintf( sprintf(
"new Task %s, status=%s" "new Task %s, status=%s"
, $ttask[$tkey]["task"]->get_task_id() , $ttask[$tkey]["task"]->get_task_id()
, $task->get_status() , $task->get_status()
) )
); );
} }
else else
@@ -246,17 +253,17 @@ class task_Scheduler
if ($ttask[$tkey]["current_status"] != $task->get_status()) if ($ttask[$tkey]["current_status"] != $task->get_status())
{ {
$this->log( $this->log(
sprintf( sprintf(
"Task %s, oldstatus=%s, newstatus=%s" "Task %s, oldstatus=%s, newstatus=%s"
, $ttask[$tkey]["task"]->get_task_id() , $ttask[$tkey]["task"]->get_task_id()
, $ttask[$tkey]["current_status"] , $ttask[$tkey]["current_status"]
, $task->get_status() , $task->get_status()
) )
); );
$ttask[$tkey]["current_status"] = $task->get_status(); $ttask[$tkey]["current_status"] = $task->get_status();
} }
$ttask[$tkey]["task"] = $task; $ttask[$tkey]["task"] = $task;
} }
$ttask[$tkey]["todel"] = false; $ttask[$tkey]["todel"] = false;
} }
@@ -275,32 +282,32 @@ class task_Scheduler
* Launch task that are not yet launched * Launch task that are not yet launched
*/ */
$runningtask = 0; $runningtask = 0;
$common_status = array( $common_status = array(
task_abstract::STATUS_STARTED task_abstract::STATUS_STARTED
, task_abstract::RETURNSTATUS_STOPPED , task_abstract::RETURNSTATUS_STOPPED
); );
foreach ($ttask as $tkey => $tv) foreach ($ttask as $tkey => $tv)
{ {
if (!in_array($ttask[$tkey]["task"]->get_status(), $common_status)) if (!in_array($ttask[$tkey]["task"]->get_status(), $common_status))
{ {
$this->log( $this->log(
sprintf( sprintf(
'task %s has status %s' 'task %s has status %s'
, $ttask[$tkey]["task"]->get_task_id() , $ttask[$tkey]["task"]->get_task_id()
, $ttask[$tkey]["task"]->get_status() , $ttask[$tkey]["task"]->get_status()
) )
); );
} }
switch ($ttask[$tkey]["task"]->get_status()) switch ($ttask[$tkey]["task"]->get_status())
{ {
default: default:
$this->log( $this->log(
sprintf( sprintf(
'Unknow status `%s`' 'Unknow status `%s`'
, $ttask[$tkey]["task"]->get_status() , $ttask[$tkey]["task"]->get_status()
) )
); );
break; break;
case task_abstract::RETURNSTATUS_TORESTART: case task_abstract::RETURNSTATUS_TORESTART:
@@ -319,31 +326,31 @@ class task_Scheduler
if ($schedstatus == 'started' && !$ttask[$tkey]["process"]) if ($schedstatus == 'started' && !$ttask[$tkey]["process"])
{ {
$descriptors = array( $descriptors = array(
1 => array("pipe", "w") 1 => array("pipe", "w")
, 2 => array("pipe", "w") , 2 => array("pipe", "w")
); );
if ($log_tasks === true) if ($log_tasks === true)
{ {
$descriptors[1] = array( $descriptors[1] = array(
"file" "file"
, $logdir . "task_$tkey.log" , $logdir . "task_$tkey.log"
, "a+" , "a+"
); );
$descriptors[2] = array( $descriptors[2] = array(
"file" "file"
, $logdir . "task_$tkey.error.log" , $logdir . "task_$tkey.error.log"
, "a+" , "a+"
); );
} }
$ttask[$tkey]["process"] = proc_open( $ttask[$tkey]["process"] = proc_open(
$ttask[$tkey]["cmd"] $ttask[$tkey]["cmd"]
, $descriptors , $descriptors
, $ttask[$tkey]["pipes"] , $ttask[$tkey]["pipes"]
, $registry->get('GV_RootPath') . "bin/" , $registry->get('GV_RootPath') . "bin/"
, null , null
, array('bypass_shell' => true) , array('bypass_shell' => true)
); );
if (is_resource($ttask[$tkey]["process"])) if (is_resource($ttask[$tkey]["process"]))
@@ -356,12 +363,12 @@ class task_Scheduler
if ($ttask[$tkey]['task']->get_pid() !== null) if ($ttask[$tkey]['task']->get_pid() !== null)
{ {
$this->log( $this->log(
sprintf( sprintf(
"Task %s '%s' started (pid=%s)" "Task %s '%s' started (pid=%s)"
, $ttask[$tkey]['task']->get_task_id() , $ttask[$tkey]['task']->get_task_id()
, $ttask[$tkey]["cmd"] , $ttask[$tkey]["cmd"]
, $ttask[$tkey]['task']->get_pid() , $ttask[$tkey]['task']->get_pid()
) )
); );
$runningtask++; $runningtask++;
} }
@@ -375,12 +382,12 @@ class task_Scheduler
$ttask[$tkey]["process"] = null; $ttask[$tkey]["process"] = null;
$this->log( $this->log(
sprintf( sprintf(
"Task %s '%s' failed to start %d times" "Task %s '%s' failed to start %d times"
, $ttask[$tkey]["task"]->get_task_id() , $ttask[$tkey]["task"]->get_task_id()
, $ttask[$tkey]["cmd"] , $ttask[$tkey]["cmd"]
, $ttask[$tkey]["task"]->get_crash_counter() , $ttask[$tkey]["task"]->get_crash_counter()
) )
); );
$ttask[$tkey]["task"]->increment_crash_counter(); $ttask[$tkey]["task"]->increment_crash_counter();
@@ -411,7 +418,7 @@ class task_Scheduler
if ($proc_status['running']) if ($proc_status['running'])
$runningtask++; $runningtask++;
else else
$crashed = true; $crashed = true;
} }
else else
{ {
@@ -433,11 +440,11 @@ class task_Scheduler
$ttask[$tkey]["process"] = null; $ttask[$tkey]["process"] = null;
$this->log( $this->log(
sprintf( sprintf(
"Task %s crashed %d times" "Task %s crashed %d times"
, $ttask[$tkey]["task"]->get_task_id() , $ttask[$tkey]["task"]->get_task_id()
, $ttask[$tkey]["task"]->get_crash_counter() , $ttask[$tkey]["task"]->get_crash_counter()
) )
); );
@@ -459,7 +466,7 @@ class task_Scheduler
{ {
if ($ttask[$tkey]["killat"] === NULL) if ($ttask[$tkey]["killat"] === NULL)
$ttask[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT; $ttask[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
if (($dt = $ttask[$tkey]["killat"] - time()) < 0) if (($dt = $ttask[$tkey]["killat"] - time()) < 0)
{ {
$ppid = $ttask[$tkey]['task']->get_pid(); $ppid = $ttask[$tkey]['task']->get_pid();
$pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`); $pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`);
@@ -473,11 +480,11 @@ class task_Scheduler
} }
$this->log( $this->log(
sprintf( sprintf(
"SIGKILL sent to task %s (pid=%s)" "SIGKILL sent to task %s (pid=%s)"
, $ttask[$tkey]["task"]->get_task_id() , $ttask[$tkey]["task"]->get_task_id()
, $ttask[$tkey]["task"]->get_pid() , $ttask[$tkey]["task"]->get_pid()
) )
); );
proc_terminate($ttask[$tkey]["process"], 9); proc_terminate($ttask[$tkey]["process"], 9);
@@ -493,11 +500,11 @@ class task_Scheduler
else else
{ {
$this->log( $this->log(
sprintf( sprintf(
"waiting task %s to quit (kill in %d seconds)" "waiting task %s to quit (kill in %d seconds)"
, $ttask[$tkey]["task"]->get_task_id() , $ttask[$tkey]["task"]->get_task_id()
, $dt , $dt
) )
); );
$runningtask++; $runningtask++;
} }
@@ -523,6 +530,7 @@ class task_Scheduler
{ {
$conn->close(); $conn->close();
unset($conn); unset($conn);
self::$connection = null;
$to_reopen = true; $to_reopen = true;
} }
sleep($sleeptime); sleep($sleeptime);
@@ -532,7 +540,7 @@ class task_Scheduler
} }
} }
$sql = "UPDATE sitepreff SET schedstatus='stopped', schedpid='0'"; $sql = "UPDATE sitepreff SET schedstatus='stopped', schedpid='0'";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$stmt->closeCursor(); $stmt->closeCursor();

View File

@@ -112,7 +112,7 @@ class task_manager
return $row; return $row;
} }
public static function getAvailableTasks() public static function getAvailableTasks()
{ {
$registry = registry::get_instance(); $registry = registry::get_instance();
@@ -150,6 +150,7 @@ class task_manager
closedir($hdir); closedir($hdir);
} }
} }
return $tasks; return $tasks;
} }
} }

View File

@@ -825,7 +825,20 @@ class task_period_archive extends task_abstract
$xp = new DOMXPath($dom); $xp = new DOMXPath($dom);
while (($file = $listFolder->read()) !== NULL) if(($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml')))
{
// on gere le magicfile
if(($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '')
{
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
if($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
return;
elseif($magicmethod == 'UNLOCK' && !file_exists($path . '/' . $magicfile))
return;
}
}
while(($file = $listFolder->read()) !== NULL)
{ {
if ($this->isIgnoredFile($file)) if ($this->isIgnoredFile($file))
continue; continue;

View File

@@ -459,7 +459,7 @@ class task_period_ftp extends task_appboxAbstract
if (in_array(trim($basefolder), array('.', './', ''))) if (in_array(trim($basefolder), array('.', './', '')))
$basefolder = '/'; $basefolder = '/';
foreach ($ftp_export['files'] as $fileid => $file) foreach ($ftp_export['files'] as $fileid => $file)
{ {
$base_id = $file["base_id"]; $base_id = $file["base_id"];
@@ -567,7 +567,7 @@ class task_period_ftp extends task_appboxAbstract
{ {
if($this->debug) if($this->debug)
echo "\nlogfile \n"; echo "\nlogfile \n";
$date = new DateTime(); $date = new DateTime();
$remote_file = $date->format('U'); $remote_file = $date->format('U');
@@ -575,12 +575,12 @@ class task_period_ftp extends task_appboxAbstract
FROM ftp_export_elements FROM ftp_export_elements
WHERE ftp_export_id = :ftp_export_id WHERE ftp_export_id = :ftp_export_id
AND error = "0" AND done="1"'; AND error = "0" AND done="1"';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':ftp_export_id'=>$id)); $stmt->execute(array(':ftp_export_id'=>$id));
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$buffer = '#transfert finished '.$date->format(DATE_ATOM)."\n\n"; $buffer = '#transfert finished '.$date->format(DATE_ATOM)."\n\n";
foreach ($rs as $row) foreach ($rs as $row)
@@ -602,7 +602,7 @@ class task_period_ftp extends task_appboxAbstract
$ftp_client->chdir($ftp_export["destfolder"]); $ftp_client->chdir($ftp_export["destfolder"]);
$ftp_client->put($remotefile, $tmpfile); $ftp_client->put($remotefile, $tmpfile);
unlink($tmpfile); unlink($tmpfile);
} }
@@ -766,7 +766,7 @@ class task_period_ftp extends task_appboxAbstract
_('task::ftp:Status about your FTP transfert from %1$s to %2$s') _('task::ftp:Status about your FTP transfert from %1$s to %2$s')
, $registry->get('GV_homeTitle'), $ftp_server , $registry->get('GV_homeTitle'), $ftp_server
); );
mail::ftp_sent($sendermail, $subject, $sender_message); mail::ftp_sent($sendermail, $subject, $sender_message);
mail::ftp_receive($mail, $receiver_message); mail::ftp_receive($mail, $receiver_message);

View File

@@ -162,6 +162,7 @@ class task_period_outofdate extends task_abstract
parent.calcSQL(); parent.calcSQL();
</script> </script>
<?php <?php
return(""); return("");
} }
else // ... so we NEVER come here else // ... so we NEVER come here
@@ -218,11 +219,12 @@ class task_period_outofdate extends task_abstract
jQuery.map($(this).serializeArray(), function(n, i){ jQuery.map($(this).serializeArray(), function(n, i){
json[n['name']] = n['value']; json[n['name']] = n['value'];
}); });
return json; return json;
}; };
})( jQuery ); })( jQuery );
function chgxmltxt(textinput, fieldname) function chgxmltxt(textinput, fieldname)
{ {
var limits = { 'period':{min:1, 'max':1440} , 'delay':{min:0} } ; var limits = { 'period':{min:1, 'max':1440} , 'delay':{min:0} } ;
@@ -274,7 +276,7 @@ class task_period_outofdate extends task_abstract
} }
$("#cmd").html(s); $("#cmd").html(s);
} }
}); });
} }
function chgsbas(sbaspopup) function chgsbas(sbaspopup)
@@ -289,7 +291,7 @@ class task_period_outofdate extends task_abstract
, async:false , async:false
, success:function(data) , success:function(data)
{ {
// console.log(data); // console.log(data);
var html = "<option value=\"\">...</option>"; var html = "<option value=\"\">...</option>";
for(i in data.date_fields) for(i in data.date_fields)
html += "\n<option class=\"jsFilled\" value=\"" + data.date_fields[i] + "\">" + data.date_fields[i] + "</option>"; html += "\n<option class=\"jsFilled\" value=\"" + data.date_fields[i] + "\">" + data.date_fields[i] + "</option>";
@@ -308,12 +310,13 @@ class task_period_outofdate extends task_abstract
for(fld=0; fld<=2; fld++) for(fld=0; fld<=2; fld++)
$("#status"+fld).html(html); $("#status"+fld).html(html);
} }
}); });
return; return;
} }
<?php <?php
/* /*
@@ -682,12 +685,13 @@ class task_period_outofdate extends task_abstract
} }
$ret = ($nchanged > 0 ? $nchanged : 'NORECSTODO'); $ret = ($nchanged > 0 ? $nchanged : 'NORECSTODO');
return($ret); return($ret);
} }
/* /*
function doRecords() function doRecords()
{ {
@@ -911,9 +915,9 @@ class task_period_outofdate extends task_abstract
private function calcSQL($sxTaskSettings) private function calcSQL($sxTaskSettings)
{ {
$ret = array(); $ret = array();
$this->sxTaskSettings = $sxTaskSettings; $this->sxTaskSettings = $sxTaskSettings;
$date1 = $date2 = NULL; $date1 = $date2 = NULL;
$field1 = $field2 = ''; $field1 = $field2 = '';
@@ -1007,7 +1011,7 @@ class task_period_outofdate extends task_abstract
SET " . $sqlset[0] . SET " . $sqlset[0] .
" WHERE " . $w; " WHERE " . $w;
// printf("%d : %s \n%s", __LINE__, $sql, var_export($params, true)); // printf("%d : %s \n%s", __LINE__, $sql, var_export($params, true));
$ret[] = array('sql'=>$sql, 'params'=>$params); $ret[] = array('sql'=>$sql, 'params'=>$params);
// $stmt = $this->connbas->prepare($sql); // $stmt = $this->connbas->prepare($sql);
@@ -1274,7 +1278,7 @@ class task_period_outofdate extends task_abstract
} }
catch(Exception $e) catch(Exception $e)
{ {
} }
} }
break; break;

View File

@@ -68,6 +68,7 @@ class task_period_upgradetov32 extends task_abstract
{ {
printf("sbas_id '" . $this->sbas_id . "' invalide\n"); printf("sbas_id '" . $this->sbas_id . "' invalide\n");
$this->return_value = self::RETURNSTATUS_STOPPED; $this->return_value = self::RETURNSTATUS_STOPPED;
return; return;
} }
@@ -241,7 +242,7 @@ class task_period_upgradetov32 extends task_abstract
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
@@ -369,11 +370,13 @@ class task_period_upgradetov32 extends task_abstract
if ($n_done >= 5000) if ($n_done >= 5000)
{ {
$this->return_value = task_abstract::RETURNSTATUS_TORESTART; $this->return_value = task_abstract::RETURNSTATUS_TORESTART;
return; return;
} }
if ($memory > 100) if ($memory > 100)
{ {
$this->return_value = task_abstract::RETURNSTATUS_TORESTART; $this->return_value = task_abstract::RETURNSTATUS_TORESTART;
return; return;
} }
} }
@@ -408,9 +411,9 @@ class task_period_upgradetov32 extends task_abstract
$stmt->closeCursor(); $stmt->closeCursor();
$this->setProgress(0, 0); $this->setProgress(0, 0);
$this->return_value = self::RETURNSTATUS_TODELETE; $this->return_value = self::RETURNSTATUS_TODELETE;
flush(); flush();
return; return;

View File

@@ -307,7 +307,7 @@ class task_period_writemeta extends task_databoxAbstract
$fields = $record->get_caption()->get_fields(); $fields = $record->get_caption()->get_fields();
$subCMD = ''; $subCMD = '';
if ($record->get_uuid()) if ($record->get_uuid())
{ {
$subCMD .= '-XMP-exif:ImageUniqueID='; $subCMD .= '-XMP-exif:ImageUniqueID=';
@@ -315,7 +315,7 @@ class task_period_writemeta extends task_databoxAbstract
$subCMD .= '-IPTC:UniqueDocumentID='; $subCMD .= '-IPTC:UniqueDocumentID=';
$subCMD .= escapeshellarg($record->get_uuid()); $subCMD .= escapeshellarg($record->get_uuid());
} }
foreach ($fields as $field) foreach ($fields as $field)
{ {
$meta = $field->get_databox_field(); $meta = $field->get_databox_field();
@@ -326,23 +326,23 @@ class task_period_writemeta extends task_databoxAbstract
$multi = $meta->is_multi(); $multi = $meta->is_multi();
$type = $meta->get_type(); $type = $meta->get_type();
$datas = $field->get_value(); $datas = $field->get_value();
if ($multi) if ($multi)
{ {
$datas = $field->get_value(); $datas = $field->get_value();
foreach ($datas as $value) foreach ($datas as $value)
{ {
$value = $this->format_value($type, $value); $value = $this->format_value($type, $value);
$subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'=';
$subCMD .= escapeshellarg($value).' '; $subCMD .= escapeshellarg($value).' ';
} }
} }
else else
{ {
$datas = $this->format_value($type, $datas); $datas = $this->format_value($type, $datas);
$subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'=';
$subCMD .= escapeshellarg($datas).' '; $subCMD .= escapeshellarg($datas).' ';
} }
} }
@@ -355,17 +355,18 @@ class task_period_writemeta extends task_databoxAbstract
$cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original '); $cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original ');
if ($name != 'document' || $this->clear_doc) if ($name != 'document' || $this->clear_doc)
$cmd .= '-all:all= '; $cmd .= '-all:all= ';
$cmd .= ' -codedcharacterset=utf8 '; $cmd .= ' -codedcharacterset=utf8 ';
$cmd .= $subCMD.' '.escapeshellarg($file); $cmd .= $subCMD.' '.escapeshellarg($file);
$this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name)); $this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name));
$s = trim(shell_exec($cmd)); $s = trim(shell_exec($cmd));
$this->log("\t" . $s); $this->log("\t" . $s);
} }
return $this; return $this;
} }

View File

@@ -655,48 +655,48 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testis_limited() public function testis_limited()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$found = false; $found = false;
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
{ {
foreach ($databox->get_collections() as $collection) foreach ($databox->get_collections() as $collection)
{ {
$base_id = $collection->get_base_id(); $base_id = $collection->get_base_id();
if(!self::$user->ACL()->has_access_to_base($base_id)) if(!self::$user->ACL()->has_access_to_base($base_id))
continue; continue;
$this->assertFalse(self::$user->ACL()->is_limited($base_id)); $this->assertFalse(self::$user->ACL()->is_limited($base_id));
self::$user->ACL()->set_limits($base_id, true, new DateTime('-1 day'), new DateTime('+1 day')); self::$user->ACL()->set_limits($base_id, true, new DateTime('-1 day'), new DateTime('+1 day'));
$this->assertFalse(self::$user->ACL()->is_limited($base_id)); $this->assertFalse(self::$user->ACL()->is_limited($base_id));
self::$user->ACL()->set_limits($base_id, false, new DateTime('-1 day'), new DateTime('+1 day')); self::$user->ACL()->set_limits($base_id, false, new DateTime('-1 day'), new DateTime('+1 day'));
$this->assertFalse(self::$user->ACL()->is_limited($base_id)); $this->assertFalse(self::$user->ACL()->is_limited($base_id));
self::$user->ACL()->set_limits($base_id, true, new DateTime('+1 day'), new DateTime('+2 day')); self::$user->ACL()->set_limits($base_id, true, new DateTime('+1 day'), new DateTime('+2 day'));
$this->assertTrue(self::$user->ACL()->is_limited($base_id)); $this->assertTrue(self::$user->ACL()->is_limited($base_id));
self::$user->ACL()->set_limits($base_id, true, new DateTime('-2 day'), new DateTime('-1 day')); self::$user->ACL()->set_limits($base_id, true, new DateTime('-2 day'), new DateTime('-1 day'));
$this->assertTrue(self::$user->ACL()->is_limited($base_id)); $this->assertTrue(self::$user->ACL()->is_limited($base_id));
self::$user->ACL()->set_limits($base_id, true, new DateTime('-2 day'), new DateTime('+2 day')); self::$user->ACL()->set_limits($base_id, true, new DateTime('-2 day'), new DateTime('+2 day'));
$this->assertFalse(self::$user->ACL()->is_limited($base_id)); $this->assertFalse(self::$user->ACL()->is_limited($base_id));
self::$user->ACL()->set_limits($base_id, false, new DateTime('-2 day'), new DateTime('+2 day')); self::$user->ACL()->set_limits($base_id, false, new DateTime('-2 day'), new DateTime('+2 day'));
$this->assertFalse(self::$user->ACL()->is_limited($base_id)); $this->assertFalse(self::$user->ACL()->is_limited($base_id));
$found = true; $found = true;
} }
} }
if(!$found) if(!$found)
$this->fail ('Unable to test'); $this->fail ('Unable to test');
} }
@@ -704,50 +704,50 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testget_limits() public function testget_limits()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$found = false; $found = false;
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
{ {
foreach ($databox->get_collections() as $collection) foreach ($databox->get_collections() as $collection)
{ {
$base_id = $collection->get_base_id(); $base_id = $collection->get_base_id();
if(!self::$user->ACL()->has_access_to_base($base_id)) if(!self::$user->ACL()->has_access_to_base($base_id))
continue; continue;
$minusone = new DateTime('-1 day'); $minusone = new DateTime('-1 day');
$plusone = new DateTime('+1 day'); $plusone = new DateTime('+1 day');
self::$user->ACL()->set_limits($base_id, true, $minusone, $plusone); self::$user->ACL()->set_limits($base_id, true, $minusone, $plusone);
$limits = self::$user->ACL()->get_limits($base_id); $limits = self::$user->ACL()->get_limits($base_id);
$this->assertEquals($limits['dmin'], $minusone); $this->assertEquals($limits['dmin'], $minusone);
$this->assertEquals($limits['dmax'], $plusone); $this->assertEquals($limits['dmax'], $plusone);
$minustwo = new DateTime('-2 day'); $minustwo = new DateTime('-2 day');
$plustwo = new DateTime('-2 day'); $plustwo = new DateTime('-2 day');
self::$user->ACL()->set_limits($base_id, true, $minustwo, $plustwo); self::$user->ACL()->set_limits($base_id, true, $minustwo, $plustwo);
$limits = self::$user->ACL()->get_limits($base_id); $limits = self::$user->ACL()->get_limits($base_id);
$this->assertEquals($limits['dmin'], $minustwo); $this->assertEquals($limits['dmin'], $minustwo);
$this->assertEquals($limits['dmax'], $plustwo); $this->assertEquals($limits['dmax'], $plustwo);
self::$user->ACL()->set_limits($base_id, false); self::$user->ACL()->set_limits($base_id, false);
$this->assertNull(self::$user->ACL()->get_limits($base_id)); $this->assertNull(self::$user->ACL()->get_limits($base_id));
$found = true; $found = true;
} }
} }
if(!$found) if(!$found)
$this->fail ('Unable to test'); $this->fail ('Unable to test');
} }

View File

@@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../bootstrap.php';
*/ */
/** /**
* *
* @package * @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
@@ -25,17 +25,17 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface
public function __construct() public function __construct()
{ {
} }
public function get_created_on() public function get_created_on()
{ {
} }
public function get_description() public function get_description()
{ {
} }
public function get_id() public function get_id()
@@ -45,12 +45,12 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface
public function get_thumbnail($width = 120, $height = 90) public function get_thumbnail($width = 120, $height = 90)
{ {
} }
public function get_title() public function get_title()
{ {
} }
public function get_type() public function get_type()
@@ -60,12 +60,12 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface
public function get_updated_on() public function get_updated_on()
{ {
} }
public function get_url() public function get_url()
{ {
} }
} }
@@ -78,27 +78,27 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
public function __construct() public function __construct()
{ {
} }
public function get_category() public function get_category()
{ {
} }
public function get_created_on() public function get_created_on()
{ {
} }
public function get_description() public function get_description()
{ {
} }
public function get_duration() public function get_duration()
{ {
} }
public function get_id() public function get_id()
@@ -108,17 +108,17 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
public function get_rating() public function get_rating()
{ {
} }
public function get_thumbnail() public function get_thumbnail()
{ {
} }
public function get_title() public function get_title()
{ {
} }
public function get_type() public function get_type()
@@ -128,22 +128,22 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
public function get_updated_on() public function get_updated_on()
{ {
} }
public function get_url() public function get_url()
{ {
} }
public function get_view_count() public function get_view_count()
{ {
} }
public function is_private() public function is_private()
{ {
} }
} }
@@ -159,17 +159,17 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
protected function initialize_transport() protected function initialize_transport()
{ {
} }
protected function set_auth_params() protected function set_auth_params()
{ {
} }
protected function set_transport_authentication_params() protected function set_transport_authentication_params()
{ {
} }
public function get_terms_url() public function get_terms_url()
@@ -178,7 +178,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
} }
/** /**
* *
* @return Array * @return Array
*/ */
public function connect() public function connect()
@@ -188,7 +188,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
/** /**
* *
* @return Bridge_Api_Interface * @return Bridge_Api_Interface
*/ */
public function reconnect() public function reconnect()
{ {
@@ -197,7 +197,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
/** /**
* *
* @return Bridge_Api_Interface * @return Bridge_Api_Interface
*/ */
public function disconnect() public function disconnect()
{ {
@@ -206,7 +206,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
/** /**
* *
* @return boolean * @return boolean
*/ */
public function is_connected() public function is_connected()
{ {
@@ -214,16 +214,16 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
} }
/** /**
* *
* @return Bridge_Api_Interface * @return Bridge_Api_Interface
*/ */
public function set_locale($locale) public function set_locale($locale)
{ {
} }
/** /**
* *
* @return string * @return string
*/ */
public function get_name() public function get_name()
@@ -232,39 +232,39 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
} }
/** /**
* *
* @return string * @return string
*/ */
public function get_icon_url() public function get_icon_url()
{ {
} }
/** /**
* *
* @return string * @return string
*/ */
public function get_image_url() public function get_image_url()
{ {
} }
/** /**
* *
* @return string * @return string
*/ */
public function get_url() public function get_url()
{ {
} }
/** /**
* *
* @return string * @return string
*/ */
public function get_infos() public function get_infos()
{ {
} }
public function get_object_class_from_type($type) public function get_object_class_from_type($type)
@@ -292,12 +292,12 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
public function get_element_types() public function get_element_types()
{ {
} }
public function get_container_types() public function get_container_types()
{ {
} }
public function get_element_from_id($element_id, $object) public function get_element_from_id($element_id, $object)
@@ -305,6 +305,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$element = new Bridge_Api_Apitest_Element(); $element = new Bridge_Api_Apitest_Element();
$element->id = $element_id; $element->id = $element_id;
$element->type = $object; $element->type = $object;
return $element; return $element;
} }
@@ -313,12 +314,13 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$container = new Bridge_Api_Apitest_Containers(); $container = new Bridge_Api_Apitest_Containers();
$container->id = $element_id; $container->id = $element_id;
$container->type = $object; $container->type = $object;
return $container; return $container;
} }
public function get_category_list() public function get_category_list()
{ {
} }
public function get_user_name() public function get_user_name()
@@ -340,6 +342,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$element_collection->add_element(new Bridge_Api_Apitest_Element()); $element_collection->add_element(new Bridge_Api_Apitest_Element());
$i++; $i++;
} }
return $element_collection; return $element_collection;
} }
@@ -352,61 +355,62 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$container_collection->add_element(new Bridge_Api_Apitest_Containers()); $container_collection->add_element(new Bridge_Api_Apitest_Containers());
$i++; $i++;
} }
return $container_collection; return $container_collection;
} }
public function update_element($object, $object_id, Array $datas) public function update_element($object, $object_id, Array $datas)
{ {
} }
public function create_container($container_type, Request $request) public function create_container($container_type, Request $request)
{ {
} }
public function add_element_to_container($element_type, $element_id, $destination, $container_id) public function add_element_to_container($element_type, $element_id, $destination, $container_id)
{ {
} }
public function delete_object($object, $object_id) public function delete_object($object, $object_id)
{ {
} }
/** /**
* *
* @return Closure * @return Closure
*/ */
public function acceptable_records() public function acceptable_records()
{ {
} }
public function get_element_status(Bridge_Element $element) public function get_element_status(Bridge_Element $element)
{ {
} }
public function map_connector_to_element_status($status) public function map_connector_to_element_status($status)
{ {
} }
public function get_error_message_from_status($connector_status) public function get_error_message_from_status($connector_status)
{ {
} }
public function upload(record_adapter &$record, array $options = array()) public function upload(record_adapter &$record, array $options = array())
{ {
} }
public function is_valid_object_id($object_id) public function is_valid_object_id($object_id)
{ {
} }
public function is_configured() public function is_configured()
@@ -416,27 +420,27 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
public function check_upload_constraints(array $datas, record_adapter $record) public function check_upload_constraints(array $datas, record_adapter $record)
{ {
} }
public function get_upload_datas(Request $request, record_adapter $record) public function get_upload_datas(Request $request, record_adapter $record)
{ {
} }
public function is_multiple_upload() public function is_multiple_upload()
{ {
} }
public function check_update_constraints(Array $datas) public function check_update_constraints(Array $datas)
{ {
} }
public function get_update_datas(Request $request) public function get_update_datas(Request $request)
{ {
} }
} }
@@ -446,12 +450,12 @@ class Bridge_Api_Auth_None extends Bridge_Api_Auth_Abstract implements Bridge_Ap
public function connect($param) public function connect($param)
{ {
} }
public function parse_request_token() public function parse_request_token()
{ {
} }
public function reconnect() public function reconnect()
@@ -476,12 +480,12 @@ class Bridge_Api_Auth_None extends Bridge_Api_Auth_Abstract implements Bridge_Ap
public function get_auth_signatures() public function get_auth_signatures()
{ {
} }
public function set_parameters(Array $parameters) public function set_parameters(Array $parameters)
{ {
} }
} }

View File

@@ -1,8 +1,8 @@
<?php <?php
/** /**
* @example * @example
* *
try try
{ {
$validator = new W3CFeedRawValidator($xml); $validator = new W3CFeedRawValidator($xml);
@@ -22,7 +22,7 @@
{ {
print "\n" . $e->getMessage(); print "\n" . $e->getMessage();
} }
* *
*/ */
/** /**
@@ -30,7 +30,7 @@
*/ */
class W3CFeedValidatorException extends Exception class W3CFeedValidatorException extends Exception
{ {
} }
/** /**
@@ -55,7 +55,7 @@ class W3CFeedUrlValidator extends W3CFeedValidator
/** /**
* The URL of the document to validate * The URL of the document to validate
* @var string * @var string
*/ */
private $url; private $url;
@@ -88,12 +88,13 @@ class W3CFeedUrlValidator extends W3CFeedValidator
{ {
throw new W3CFeedValidatorException("Unable to request W3C API"); throw new W3CFeedValidatorException("Unable to request W3C API");
} }
return new W3CFeedValidatorResponse($response); return new W3CFeedValidatorResponse($response);
} }
/** /**
* Check if an url is valid * Check if an url is valid
* @param string $url * @param string $url
* @return boolean * @return boolean
*/ */
private function isValidUrl($url) private function isValidUrl($url)
@@ -112,14 +113,14 @@ class W3CFeedRawValidator extends W3CFeedValidator
/** /**
* The source of the document to validate * The source of the document to validate
* @var string * @var string
*/ */
private $rawData; private $rawData;
/** /**
* Constructor * Constructor
* Init instance which the specified data to validate * Init instance which the specified data to validate
* @param string $rawData * @param string $rawData
*/ */
public function __construct($rawData) public function __construct($rawData)
{ {
@@ -151,6 +152,7 @@ class W3CFeedRawValidator extends W3CFeedValidator
{ {
throw new W3CFeedValidatorException("Unable to request W3C API"); throw new W3CFeedValidatorException("Unable to request W3C API");
} }
return new W3CFeedValidatorResponse($response); return new W3CFeedValidatorResponse($response);
} }
@@ -209,36 +211,40 @@ class W3CFeedValidatorResponse
$string .= $name . "=>" . $detail . "\n"; $string .= $name . "=>" . $detail . "\n";
} }
} }
return $string; return $string;
} }
/** /**
* Check if the XML is valid * Check if the XML is valid
* @return boolean * @return boolean
*/ */
public function isValid() public function isValid()
{ {
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:validity"; $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:validity";
return $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== "false"; return $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== "false";
} }
/** /**
* Check for errors * Check for errors
* @return boolean * @return boolean
*/ */
public function hasError() public function hasError()
{ {
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorcount"; $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorcount";
return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0; return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0;
} }
/** /**
* check fro warnings * check fro warnings
* @return boolean * @return boolean
*/ */
public function hasWarning() public function hasWarning()
{ {
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warningcount"; $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warningcount";
return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0; return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0;
} }
@@ -271,8 +277,8 @@ class W3CFeedValidatorResponse
* 1 => etc .. * 1 => etc ..
* } * }
* } * }
* *
* @return array * @return array
*/ */
public function getWarnings() public function getWarnings()
{ {
@@ -286,12 +292,13 @@ class W3CFeedValidatorResponse
$warnings[] = $this->domNodeToArray($warning); $warnings[] = $this->domNodeToArray($warning);
} }
} }
return $warnings; return $warnings;
} }
/** /**
* Get an array with all errors as follow * Get an array with all errors as follow
* @return array * @return array
*/ */
public function getErrors() public function getErrors()
{ {
@@ -305,14 +312,15 @@ class W3CFeedValidatorResponse
$errors[] = $this->domNodeToArray($error); $errors[] = $this->domNodeToArray($error);
} }
} }
return $errors; return $errors;
} }
/** /**
* @source http://www.ermshaus.org/2010/12/php-transform-domnode-to-array * @source http://www.ermshaus.org/2010/12/php-transform-domnode-to-array
* *
* Transforms the contents of a DOMNode to an associative array * Transforms the contents of a DOMNode to an associative array
* *
* XML node names become array keys, attributes will be discarded. If $node * XML node names become array keys, attributes will be discarded. If $node
* doesn't contain child nodes, a string will be returned. * doesn't contain child nodes, a string will be returned.
* *

View File

@@ -10,7 +10,7 @@
*/ */
/** /**
* *
* @package * @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
@@ -29,7 +29,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
const USER_AGENT_IPHONE = 'Mozilla/5.0 (iPod; U; CPU iPhone OS 2_1 like Mac OS X; fr-fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F137 Safari/525.20'; const USER_AGENT_IPHONE = 'Mozilla/5.0 (iPod; U; CPU iPhone OS 2_1 like Mac OS X; fr-fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F137 Safari/525.20';
/** /**
* *
* @var Symfony\Component\HttpKernel\Client * @var Symfony\Component\HttpKernel\Client
*/ */
protected $client; protected $client;
@@ -330,7 +330,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* *
* @var collection * @var collection
*/ */
protected static $collection; protected static $collection;
protected static $time_start; protected static $time_start;
@@ -340,7 +340,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
{ {
if (!self::$time_start) if (!self::$time_start)
self::$time_start = microtime(true); self::$time_start = microtime(true);
if(!setup::is_installed()) if(!setup::is_installed())
exit("Phraseanet is not set up\n"); exit("Phraseanet is not set up\n");
@@ -431,12 +431,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$basket_coll = new basketCollection($appbox, self::$user->get_id()); $basket_coll = new basketCollection($appbox, self::$user->get_id());
$baskets = $basket_coll->get_baskets(); $baskets = $basket_coll->get_baskets();
foreach($baskets['baskets'] as $basket) foreach($baskets['baskets'] as $basket)
{ {
$basket->delete(); $basket->delete();
} }
basket_adapter::create($appbox, 'TEST', self::$user); basket_adapter::create($appbox, 'TEST', self::$user);
$appbox->get_session()->authenticate(new Session_Authentication_None(self::$user)); $appbox->get_session()->authenticate(new Session_Authentication_None(self::$user));
@@ -919,11 +919,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
{ {
return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date); return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
} }
protected function set_user_agent($user_agent) protected function set_user_agent($user_agent)
{ {
$browser = Browser::getInstance(); $browser = Browser::getInstance();
$browser->setUserAgent($user_agent); $browser->setUserAgent($user_agent);
} }
} }

View File

@@ -10,7 +10,7 @@
*/ */
/** /**
* *
* @package * @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
@@ -40,7 +40,7 @@ abstract class PhraseanetPHPUnitAuthenticatedAbstract extends PhraseanetPHPUnitA
$session->logout(); $session->logout();
parent::tearDown(); parent::tearDown();
} }
// public static function setUpBeforeClass() // public static function setUpBeforeClass()
// { // {
// parent::setUpBeforeClass(); // parent::setUpBeforeClass();
@@ -55,4 +55,4 @@ abstract class PhraseanetPHPUnitAuthenticatedAbstract extends PhraseanetPHPUnitA
// parent::tearDownAfterClass(); // parent::tearDownAfterClass();
// } // }
} }

View File

@@ -10,7 +10,7 @@
*/ */
/** /**
* *
* @package * @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
@@ -34,4 +34,4 @@ abstract class PhraseanetWebTestCaseAbstract extends PhraseanetPHPUnitAbstract
$this->app = $this->createApplication(); $this->app = $this->createApplication();
} }
} }

View File

@@ -10,7 +10,7 @@
*/ */
/** /**
* *
* @package * @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
@@ -35,4 +35,4 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
$this->app = $this->createApplication(); $this->app = $this->createApplication();
} }
} }

View File

@@ -153,13 +153,13 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract
public function testDec2bin() public function testDec2bin()
{ {
$this->assertEquals('1010', databox_status::dec2bin('10')); $this->assertEquals('1010', databox_status::dec2bin('10'));
try try
{ {
} }
catch(Exception $e) catch(Exception $e)
{ {
} }
} }
@@ -167,7 +167,7 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract
{ {
$this->assertEquals('10100001', databox_status::hex2bin('0x0A1')); $this->assertEquals('10100001', databox_status::hex2bin('0x0A1'));
$this->assertEquals('10100001', databox_status::hex2bin('0A1')); $this->assertEquals('10100001', databox_status::hex2bin('0A1'));
try try
{ {
databox_status::hex2bin('G1'); databox_status::hex2bin('G1');
@@ -175,7 +175,7 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract
} }
catch(Exception $e) catch(Exception $e)
{ {
} }
} }

View File

@@ -117,7 +117,7 @@ class Feed_overviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$crawler = $this->client->request('GET', $url); $crawler = $this->client->request('GET', $url);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
if (self::$record_1->get_preview()->get_baseurl() !== '') if (self::$record_1->get_preview()->get_baseurl() !== '')
{ {
$this->assertEquals(302, $response->getStatusCode()); $this->assertEquals(302, $response->getStatusCode());

View File

@@ -64,6 +64,7 @@ class Module_Prod_Route_RecordFeedApp extends PhraseanetWebTestCaseAuthenticated
public function createApplication() public function createApplication()
{ {
$app = require __DIR__ . '/../../../../../classes/module/Prod.php'; $app = require __DIR__ . '/../../../../../classes/module/Prod.php';
return $app; return $app;
} }
@@ -211,7 +212,7 @@ class Module_Prod_Route_RecordFeedApp extends PhraseanetWebTestCaseAuthenticated
// } // }
// catch (Exception $e) // catch (Exception $e)
// { // {
// //
// } // }
// } // }
// //

View File

@@ -163,9 +163,9 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
/** /**
* XML is not verified due to Validator Service bug * XML is not verified due to Validator Service bug
*/ */
return; return;
try try
{ {
$validator = new W3CFeedRawValidator($xml); $validator = new W3CFeedRawValidator($xml);
@@ -253,7 +253,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
$offset_start = ($offset_start++) * $n_entries; $offset_start = ($offset_start++) * $n_entries;
$collection = $feed->get_entries($offset_start, $n_entries); $collection = $feed->get_entries($offset_start, $n_entries);
$entries = $collection->get_entries(); $entries = $collection->get_entries();
if (sizeof($entries) == 0) //no more if (sizeof($entries) == 0) //no more
break; break;
} }
$feed_entry = array_shift($entries); $feed_entry = array_shift($entries);
@@ -331,6 +331,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
{ {
$current_attributes[$attribute->name] = $attribute->value; $current_attributes[$attribute->name] = $attribute->value;
} }
return $current_attributes; return $current_attributes;
} }
@@ -470,7 +471,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
) )
); );
foreach ($fields as $key_field => $field) foreach ($fields as $key_field => $field)
{ {
if ($field["media_field"]["name"] == $node->nodeName) if ($field["media_field"]["name"] == $node->nodeName)
@@ -516,6 +517,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
unset($item_entries[$key]); //remove unset($item_entries[$key]); //remove
} }
}; };
return $remove; return $remove;
} }
@@ -562,7 +564,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
$offset_start = ($offset_start++) * $n_entries; $offset_start = ($offset_start++) * $n_entries;
$collection = $feed->get_entries($offset_start, $n_entries); $collection = $feed->get_entries($offset_start, $n_entries);
$entries = $collection->get_entries(); $entries = $collection->get_entries();
if (sizeof($entries) == 0) //no more if (sizeof($entries) == 0) //no more
break; break;
} }
$feed_entry = array_shift($entries); $feed_entry = array_shift($entries);
@@ -642,4 +644,4 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
} }
} }
} }

View File

@@ -100,7 +100,7 @@ class dashboardTest extends PhraseanetPHPUnitAbstract
{ {
if ($key == 'activity_added') if ($key == 'activity_added')
{ {
} }
$this->assertLessThanOrEqual($nbDay, count($dash)); $this->assertLessThanOrEqual($nbDay, count($dash));
} }
@@ -119,7 +119,7 @@ class dashboardTest extends PhraseanetPHPUnitAbstract
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }

View File

@@ -29,12 +29,9 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
*/ */
public function tearDown() public function tearDown()
{ {
} }
/**
* @covers {className}::{origMethodName}
*/
public function testSet_locale() public function testSet_locale()
{ {
$locale = 'BABA'; $locale = 'BABA';
@@ -42,10 +39,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($locale, $this->object->get_locale()); $this->assertEquals($locale, $this->object->get_locale());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_locale().
*/
public function testGet_locale() public function testGet_locale()
{ {
$locale = null; $locale = null;
@@ -53,10 +46,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($locale, $this->object->get_locale()); $this->assertEquals($locale, $this->object->get_locale());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_sort().
*/
public function testSet_sort() public function testSet_sort()
{ {
$by = 'NAME'; $by = 'NAME';
@@ -69,10 +58,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(searchEngine_options::SORT_MODE_DESC, $this->object->get_sortord()); $this->assertEquals(searchEngine_options::SORT_MODE_DESC, $this->object->get_sortord());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_sortby().
*/
public function testGet_sortby() public function testGet_sortby()
{ {
$by = 'NAME'; $by = 'NAME';
@@ -82,10 +67,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($sort, $this->object->get_sortord()); $this->assertEquals($sort, $this->object->get_sortord());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_sortord().
*/
public function testGet_sortord() public function testGet_sortord()
{ {
$by = 'NAME'; $by = 'NAME';
@@ -95,10 +76,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($sort, $this->object->get_sortord()); $this->assertEquals($sort, $this->object->get_sortord());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_use_stemming().
*/
public function testSet_use_stemming() public function testSet_use_stemming()
{ {
$bool = true; $bool = true;
@@ -109,10 +86,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($bool, $this->object->get_use_stemming()); $this->assertEquals($bool, $this->object->get_use_stemming());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_use_stemming().
*/
public function testGet_use_stemming() public function testGet_use_stemming()
{ {
$bool = true; $bool = true;
@@ -123,10 +96,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($bool, $this->object->get_use_stemming()); $this->assertEquals($bool, $this->object->get_use_stemming());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_search_type().
*/
public function testSet_search_type() public function testSet_search_type()
{ {
$type = "caca"; $type = "caca";
@@ -140,10 +109,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type()); $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_search_type().
*/
public function testGet_search_type() public function testGet_search_type()
{ {
$type = "caca"; $type = "caca";
@@ -157,10 +122,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type()); $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type());
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_bases().
*/
public function testSet_bases() public function testSet_bases()
{ {
$bases = array_keys(self::$user->ACL()->get_granted_base()); $bases = array_keys(self::$user->ACL()->get_granted_base());
@@ -168,10 +129,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(array_values($bases), array_values($this->object->get_bases())); $this->assertEquals(array_values($bases), array_values($this->object->get_bases()));
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_bases().
*/
public function testGet_bases() public function testGet_bases()
{ {
$bases = array_keys(self::$user->ACL()->get_granted_base()); $bases = array_keys(self::$user->ACL()->get_granted_base());
@@ -179,10 +136,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(array_values($bases), array_values($this->object->get_bases())); $this->assertEquals(array_values($bases), array_values($this->object->get_bases()));
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_fields().
*/
public function testSet_fields() public function testSet_fields()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -191,10 +144,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_fields().
*/
public function testGet_fields() public function testGet_fields()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -203,10 +152,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_status().
*/
public function testSet_status() public function testSet_status()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -215,10 +160,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_status().
*/
public function testGet_status() public function testGet_status()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -227,10 +168,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_record_type().
*/
public function testSet_record_type() public function testSet_record_type()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -239,10 +176,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_record_type().
*/
public function testGet_record_type() public function testGet_record_type()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -251,10 +184,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_min_date().
*/
public function testSet_min_date() public function testSet_min_date()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -263,10 +192,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_min_date().
*/
public function testGet_min_date() public function testGet_min_date()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -275,10 +200,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_max_date().
*/
public function testSet_max_date() public function testSet_max_date()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -287,10 +208,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_max_date().
*/
public function testGet_max_date() public function testGet_max_date()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -299,10 +216,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_date_fields().
*/
public function testSet_date_fields() public function testSet_date_fields()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -311,10 +224,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_date_fields().
*/
public function testGet_date_fields() public function testGet_date_fields()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -323,10 +232,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
); );
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testSerialize().
*/
public function testSerialize() public function testSerialize()
{ {
$bases = array_keys(self::$user->ACL()->get_granted_base()); $bases = array_keys(self::$user->ACL()->get_granted_base());
@@ -343,10 +248,6 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($this->object, unserialize(serialize($this->object))); $this->assertEquals($this->object, unserialize(serialize($this->object)));
} }
/**
* @covers {className}::{origMethodName}
* @todo Implement testUnserialize().
*/
public function testUnserialize() public function testUnserialize()
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
@@ -356,5 +257,3 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
} }
?>

View File

@@ -23,8 +23,8 @@ require_once dirname(__FILE__) . '/PhraseanetPHPUnitAbstract.class.inc';
class userTest extends PhraseanetPHPUnitAbstract class userTest extends PhraseanetPHPUnitAbstract
{ {
public function testMail() public function testMail()
{ {
$this->assertFalse(User_Adapter::get_usr_id_from_email(null)); $this->assertFalse(User_Adapter::get_usr_id_from_email(null));
@@ -32,10 +32,10 @@ class userTest extends PhraseanetPHPUnitAbstract
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
self::$user->set_email(null); self::$user->set_email(null);
$this->assertFalse(User_Adapter::get_usr_id_from_email(null)); $this->assertFalse(User_Adapter::get_usr_id_from_email(null));
self::$user->set_email(''); self::$user->set_email('');
$this->assertFalse(User_Adapter::get_usr_id_from_email(null)); $this->assertFalse(User_Adapter::get_usr_id_from_email(null));
self::$user->set_email('noone@example.com'); self::$user->set_email('noone@example.com');
$this->assertEquals(self::$user->get_id(), User_Adapter::get_usr_id_from_email('noone@example.com')); $this->assertEquals(self::$user->get_id(), User_Adapter::get_usr_id_from_email('noone@example.com'));
@@ -46,14 +46,14 @@ class userTest extends PhraseanetPHPUnitAbstract
} }
try try
{ {
self::$user->set_email('noonealt1@example.com'); self::$user->set_email('noonealt1@example.com');
$this->fail('A user already got this address'); $this->fail('A user already got this address');
} }
catch(Exception $e) catch(Exception $e)
{ {
} }
$this->assertFalse(User_Adapter::get_usr_id_from_email(null)); $this->assertFalse(User_Adapter::get_usr_id_from_email(null));
} }
} }

View File

@@ -15,5 +15,5 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
define('GV_version', '3.5.9.0'); define('GV_version', '3.5.10.0');
define('GV_version_name', 'Baobab'); define('GV_version_name', 'Baobab');

View File

@@ -124,7 +124,7 @@
<tr> <tr>
<td> <td>
{% if main_user is not empty %} {% if main_user is not empty %}
{% if main_user.is_special is not empty %} {% if main_user.is_special is not empty %}
{% if main_user.get_login() == 'invite' %} {% if main_user.get_login() == 'invite' %}
{% trans 'Reglages:: reglages d acces guest' %} {% trans 'Reglages:: reglages d acces guest' %}
@@ -199,7 +199,7 @@
<td></td> <td></td>
</tr> </tr>
{% endif %} {% endif %}
<tr> <tr>
<td style="width:122px;overflow:hidden;white-space:nowrap;"> <td style="width:122px;overflow:hidden;white-space:nowrap;">
{{rights['sbas_id']|sbas_name}} {{rights['sbas_id']|sbas_name}}
@@ -556,7 +556,7 @@
{% endif %} {% endif %}
</div> </div>
<div class="PNB10" style="top:auto;height:20px;"> <div class="PNB10" style="top:auto;height:20px;">
<button class="users_rights_valid">{% trans 'boutton::valider' %}</button> <button class="users_rights_valid">{% trans 'boutton::valider' %}</button>
<a href="/admin/users/search/" class="users_rights_cancel">{% trans 'boutton::retour' %}</a> <a href="/admin/users/search/" class="users_rights_cancel">{% trans 'boutton::retour' %}</a>
</div> </div>
</div> </div>

Some files were not shown because too many files have changed in this diff Show More