Merge with master

This commit is contained in:
Romain Neutron
2012-01-31 22:22:54 +01:00
parent deb98a49b8
commit 067561a734
14 changed files with 271 additions and 227 deletions

View File

@@ -315,7 +315,7 @@ class 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);
} }

View File

@@ -56,7 +56,7 @@ class Edit extends RecordHelper
* *
* @var Array * @var Array
*/ */
protected $javascript_elements; protected $javascript_elements = array();
/** /**
* *

View File

@@ -545,7 +545,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$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;
} }

View File

@@ -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());

View File

@@ -1280,6 +1280,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
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));
@@ -1295,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);
} }

View File

@@ -18,142 +18,118 @@
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('-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'); $last_update = $cache_appbox->get('memcached_update');
if ($last_update) }
$last_update = new DateTime($last_update); catch (\Exception $e)
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))
{ {
$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']) switch ($row['type'])
{ {
case 'record': case 'record':
$cache_thumbnail->delete($sbas_id, $row['value'], false); $key = 'record_' . $sbas_id . '_' . $row['value'];
$cache_preview->delete($sbas_id, $row['value'], false); $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 $sql = 'DELETE FROM memcached
WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '" WHERE site_id = :site_id AND type="record" AND value = :value';
AND type="record" AND value="' . $row['value'] . '"';
$connsbas->query($sql); $params = array(
':site_id' => $registry->get('GV_ServerName')
, ':value' => $row['value']
);
$stmt = $connsbas->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
break; break;
case 'structure': 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 $sql = 'DELETE FROM memcached
WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '" WHERE site_id = :site_id AND type="structure" AND value = :value';
AND type="structure" AND value="' . $row['value'] . '"';
$connsbas->query($sql); $params = array(
':site_id' => $registry->get('GV_ServerName')
, ':value' => $row['value']
);
$stmt = $connsbas->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
break; break;
} }
} }
$connsbas->free_result($rs);
}
$date = new DateTime(); $date = new \DateTime();
$now = phraseadate::format_mysql($date); $now = $date->format(DATE_ISO8601);
$cache_appbox->set('memcached_update', $now); $cache_appbox->set('memcached_update', $now);
$conn = connection::getInstance(); $conn = \connection::getPDOConnection();
$sql = 'UPDATE sitepreff
SET memcached_update="' . $conn->escape_string($now) . '"';
$conn->query($sql);
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 * @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

@@ -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;

View File

@@ -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']); $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;
} }
@@ -1934,6 +1934,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/ */
public function get_data_from_cache($option = null) public function get_data_from_cache($option = null)
{ {
\cache_databox::refresh($this->get_sbas_id());
$databox = $this->get_databox(); $databox = $this->get_databox();
return $databox->get_data_from_cache($this->get_cache_key($option)); 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(); $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));
} }

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;

View File

@@ -1051,7 +1051,6 @@ class system_file extends SplFileObject
$li = $xptrdf->query('rdf:li', $bag->item(0)); $li = $xptrdf->query('rdf:li', $bag->item(0));
if ($li->length > 0) if ($li->length > 0)
{ {
// $tfields[$src] = array();
for ($ili = 0; $ili < $li->length; $ili++) for ($ili = 0; $ili < $li->length; $ili++)
{ {
$value = $base64_encoded ? base64_decode($li->item($ili)->nodeValue) : $li->item($ili)->nodeValue; $value = $base64_encoded ? base64_decode($li->item($ili)->nodeValue) : $li->item($ili)->nodeValue;

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)
{ {

View File

@@ -822,7 +822,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

@@ -102,7 +102,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox);
} }
?> ?>
</head> </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%;"> <div id="container" style="position:absolute;top:0;left:0;overflow:hidden;width:100%;height:100%;">
<?php <?php

View File

@@ -61,7 +61,7 @@ if ($parm["act"] == "START" || $parm["act"] == "WORK")
foreach ($lst as $basrec) foreach ($lst as $basrec)
{ {
$basrec = explode('_', $basrec); $basrec = explode('_', $basrec);
$record = new record_adapter($barec[0], $basrec[1]); $record = new record_adapter($basrec[0], $basrec[1]);
if ($record->is_grouping()) if ($record->is_grouping())
{ {