mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Merge with master
This commit is contained in:
@@ -315,7 +315,7 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
$appbox->get_session()->authenticate($auth);
|
||||
|
||||
$redirection = '/admin/?section=taskmanager¬ice=install_success';
|
||||
$redirection = '/admin/index.php?section=taskmanager¬ice=install_success';
|
||||
|
||||
return $app->redirect($redirection);
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class Edit extends RecordHelper
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $javascript_elements;
|
||||
protected $javascript_elements = array();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@@ -545,7 +545,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$user = \User_adapter::getInstance(array_pop($users), \appbox::get_instance());
|
||||
|
||||
if ($user->is_template())
|
||||
if ($user->is_template() || $user->is_special())
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
@@ -395,6 +395,7 @@ class Session_Handler
|
||||
foreach ($user->ACL()->get_granted_sbas() as $databox)
|
||||
{
|
||||
Session_Logger::create($databox, $browser, $this, $user);
|
||||
\cache_databox::insertClient($databox);
|
||||
}
|
||||
|
||||
$this->set_usr_lastconn($conn, $user->get_id());
|
||||
|
@@ -1280,6 +1280,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
if ($this->_prefs)
|
||||
|
||||
return $this;
|
||||
|
||||
$registry = \registry::get_instance();
|
||||
|
||||
$sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
|
||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':id' => $this->id));
|
||||
@@ -1295,6 +1298,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
{
|
||||
if (!isset($this->_prefs[$k]))
|
||||
{
|
||||
if($k == 'start_page_query' && $registry->get('GV_defaultQuery'))
|
||||
{
|
||||
$v = $registry->get('GV_defaultQuery');
|
||||
}
|
||||
|
||||
$this->_prefs[$k] = $v;
|
||||
$this->update_pref($k, $v);
|
||||
}
|
||||
|
235
lib/classes/cache/databox.class.php
vendored
235
lib/classes/cache/databox.class.php
vendored
@@ -18,142 +18,118 @@
|
||||
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
|
||||
* @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('-30 seconds');
|
||||
|
||||
$cache_appbox = cache_appbox::getInstance();
|
||||
$appbox = \appbox::get_instance();
|
||||
|
||||
$registry = \registry::get_instance();
|
||||
|
||||
$cache_appbox = $appbox->get_cache();
|
||||
|
||||
$last_update = null;
|
||||
|
||||
try
|
||||
{
|
||||
$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())
|
||||
|
||||
return $this;
|
||||
|
||||
$connsbas = connection::getInstance($sbas_id);
|
||||
|
||||
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))
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$cache_thumbnail = cache_thumbnail::getInstance();
|
||||
$cache_preview = cache_preview::getInstance();
|
||||
while ($row = $connsbas->fetch_assoc($rs))
|
||||
|
||||
}
|
||||
|
||||
if ($last_update)
|
||||
$last_update = new \DateTime($last_update);
|
||||
else
|
||||
$last_update = new \DateTime('-10 years');
|
||||
|
||||
if ($date <= $last_update || !$cache_appbox->ping())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$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':
|
||||
$cache_thumbnail->delete($sbas_id, $row['value'], false);
|
||||
$cache_preview->delete($sbas_id, $row['value'], false);
|
||||
$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="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '"
|
||||
AND type="record" AND value="' . $row['value'] . '"';
|
||||
$connsbas->query($sql);
|
||||
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();
|
||||
break;
|
||||
case 'structure':
|
||||
$cache_appbox->delete('list_bases');
|
||||
$cache_appbox->delete(\appbox::CACHE_LIST_BASES);
|
||||
$cache_appbox->delete(\appbox::CACHE_SBAS_IDS);
|
||||
|
||||
$sql = 'DELETE FROM memcached
|
||||
WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '"
|
||||
AND type="structure" AND value="' . $row['value'] . '"';
|
||||
$connsbas->query($sql);
|
||||
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;
|
||||
}
|
||||
}
|
||||
$connsbas->free_result($rs);
|
||||
}
|
||||
|
||||
$date = new DateTime();
|
||||
$now = phraseadate::format_mysql($date);
|
||||
$date = new \DateTime();
|
||||
$now = $date->format(DATE_ISO8601);
|
||||
|
||||
$cache_appbox->set('memcached_update', $now);
|
||||
|
||||
$conn = connection::getInstance();
|
||||
$sql = 'UPDATE sitepreff
|
||||
SET memcached_update="' . $conn->escape_string($now) . '"';
|
||||
$conn->query($sql);
|
||||
$conn = \connection::getPDOConnection();
|
||||
|
||||
return $this;
|
||||
$sql = 'UPDATE sitepreff SET memcached_update = :date';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute(array(':date' => $now));
|
||||
$stmt->closeCursor();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,28 +139,57 @@ class cache_databox
|
||||
* @param mixed content $value
|
||||
* @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
|
||||
FROM clients
|
||||
WHERE site_id != :site_id';
|
||||
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute(array(':site_id' => $registry->get('GV_ServerName')));
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'REPLACE INTO memcached (site_id, type, value)
|
||||
VALUES (:site_id, :type, :value)';
|
||||
|
||||
$stmt = $connbas->prepare($sql);
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
$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();
|
||||
|
||||
return;
|
||||
|
@@ -188,8 +188,10 @@ class connection
|
||||
public static function close_PDO_connection($name)
|
||||
{
|
||||
if (isset(self::$_PDO_instance[$name]))
|
||||
{
|
||||
self::$_PDO_instance[$name] = null;
|
||||
unset(self::$_PDO_instance[$name]);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -160,8 +160,20 @@ class databox_status
|
||||
|
||||
$sbas_ids = $user->ACL()->get_granted_sbas();
|
||||
|
||||
$see_all = array();
|
||||
|
||||
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
|
||||
{
|
||||
$statuses[$databox->get_sbas_id()] = $databox->get_statusbits();
|
||||
@@ -177,15 +189,15 @@ class databox_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'))
|
||||
$see_all = true;
|
||||
$see_this = true;
|
||||
|
||||
foreach ($status as $bit => $props)
|
||||
{
|
||||
|
||||
if ($props['searchable'] == 0 && !$see_all)
|
||||
if ($props['searchable'] == 0 && !$see_this)
|
||||
continue;
|
||||
|
||||
$set = false;
|
||||
|
@@ -1361,7 +1361,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
|
||||
$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;
|
||||
}
|
||||
@@ -1934,6 +1934,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
*/
|
||||
public function get_data_from_cache($option = null)
|
||||
{
|
||||
\cache_databox::refresh($this->get_sbas_id());
|
||||
|
||||
$databox = $this->get_databox();
|
||||
|
||||
return $databox->get_data_from_cache($this->get_cache_key($option));
|
||||
@@ -1961,6 +1963,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
}
|
||||
$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));
|
||||
}
|
||||
|
||||
|
@@ -353,7 +353,7 @@ class searchEngine_options implements Serializable
|
||||
{
|
||||
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;
|
||||
@@ -377,7 +377,7 @@ class searchEngine_options implements Serializable
|
||||
{
|
||||
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;
|
||||
|
@@ -1051,7 +1051,6 @@ class system_file extends SplFileObject
|
||||
$li = $xptrdf->query('rdf:li', $bag->item(0));
|
||||
if ($li->length > 0)
|
||||
{
|
||||
// $tfields[$src] = array();
|
||||
for ($ili = 0; $ili < $li->length; $ili++)
|
||||
{
|
||||
$value = $base64_encoded ? base64_decode($li->item($ili)->nodeValue) : $li->item($ili)->nodeValue;
|
||||
|
@@ -19,9 +19,11 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class task_Scheduler
|
||||
{
|
||||
|
||||
const TASKDELAYTOQUIT = 60;
|
||||
|
||||
protected $output;
|
||||
protected static $connection;
|
||||
|
||||
protected function log($message)
|
||||
{
|
||||
@@ -61,7 +63,12 @@ class task_Scheduler
|
||||
$password = $connexion->get('password');
|
||||
$dbname = $connexion->get('dbname');
|
||||
|
||||
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)
|
||||
@@ -537,6 +544,7 @@ class task_Scheduler
|
||||
{
|
||||
$conn->close();
|
||||
unset($conn);
|
||||
self::$connection = null;
|
||||
$to_reopen = true;
|
||||
}
|
||||
sleep($sleeptime);
|
||||
|
@@ -102,7 +102,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox);
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body style="overflow:hidden;">
|
||||
<body class="PNB" style="overflow:hidden;">
|
||||
<div id="container" style="position:absolute;top:0;left:0;overflow:hidden;width:100%;height:100%;">
|
||||
|
||||
<?php
|
||||
|
@@ -61,7 +61,7 @@ if ($parm["act"] == "START" || $parm["act"] == "WORK")
|
||||
foreach ($lst as $basrec)
|
||||
{
|
||||
$basrec = explode('_', $basrec);
|
||||
$record = new record_adapter($barec[0], $basrec[1]);
|
||||
$record = new record_adapter($basrec[0], $basrec[1]);
|
||||
|
||||
if ($record->is_grouping())
|
||||
{
|
||||
|
Reference in New Issue
Block a user