Update tasks

This commit is contained in:
Romain Neutron
2012-09-21 15:02:24 +02:00
parent baf3f6692a
commit bafb4edca9
15 changed files with 140 additions and 153 deletions

View File

@@ -9,6 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Monolog\Logger; use Monolog\Logger;
@@ -46,20 +47,13 @@ class task_Scheduler
return $this; return $this;
} }
protected static function get_connection()
{
return appbox::get_instance(\bootstrap::getCore())->get_connection();
}
/** /**
* @throws Exception if scheduler is already running * @throws Exception if scheduler is already running
* @todo doc all possible exception * @todo doc all possible exception
*/ */
public function run() public function run()
{ {
$registry = $this->dependencyContainer['phraseanet.registry'];
$appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
//prevent scheduler to fail if GV_cli is not provided //prevent scheduler to fail if GV_cli is not provided
if ( ! is_executable($registry->get('GV_cli'))) { if ( ! is_executable($registry->get('GV_cli'))) {
@@ -115,7 +109,7 @@ class task_Scheduler
$this->log(sprintf("running scheduler with method %s", $this->method)); $this->log(sprintf("running scheduler with method %s", $this->method));
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection(); $conn = $this->dependencyContainer['phraseanet.appbox']->get_connection();
$taskPoll = array(); // the poll of tasks $taskPoll = array(); // the poll of tasks
@@ -124,10 +118,10 @@ class task_Scheduler
$sql = "UPDATE sitepreff SET schedstatus='started'"; $sql = "UPDATE sitepreff SET schedstatus='started'";
$conn->exec($sql); $conn->exec($sql);
$task_manager = new task_manager($appbox); $task_manager = new task_manager($this->dependencyContainer);
// set every 'auto-start' task to start // set every 'auto-start' task to start
foreach ($task_manager->getTasks($this->dependencyContainer) as $task) { foreach ($task_manager->getTasks() as $task) {
if ($task->isActive()) { if ($task->isActive()) {
if ( ! $task->getPID()) { if ( ! $task->getPID()) {
/* @var $task task_abstract */ /* @var $task task_abstract */
@@ -161,7 +155,7 @@ class task_Scheduler
sleep(1); sleep(1);
} }
try { try {
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection(); $conn = $this->dependencyContainer['phraseanet.appbox']->get_connection();
} catch (ErrorException $e) { } catch (ErrorException $e) {
$ping = false; $ping = false;
} }
@@ -214,7 +208,7 @@ class task_Scheduler
$taskPoll[$tkey]["todel"] = true; $taskPoll[$tkey]["todel"] = true;
} }
foreach ($task_manager->getTasks($this->dependencyContainer, true) as $task) { foreach ($task_manager->getTasks(true) as $task) {
$tkey = "t_" . $task->getID(); $tkey = "t_" . $task->getID();
$status = $task->getState(); $status = $task->getState();

View File

@@ -107,12 +107,12 @@ abstract class task_abstract
$this->taskid = (integer) $taskid; $this->taskid = (integer) $taskid;
phrasea::use_i18n(Session_Handler::get_locale()); phrasea::use_i18n($this->dependencyContainer['locale']);
$this->launched_by = array_key_exists("REQUEST_URI", $_SERVER) ? self::LAUCHED_BY_BROWSER : self::LAUCHED_BY_COMMANDLINE; $this->launched_by = array_key_exists("REQUEST_URI", $_SERVER) ? self::LAUCHED_BY_BROWSER : self::LAUCHED_BY_COMMANDLINE;
try { try {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (Exception $e) { } catch (Exception $e) {
$this->log($e->getMessage()); $this->log($e->getMessage());
$this->log(("Warning : abox connection lost, restarting in 10 min.")); $this->log(("Warning : abox connection lost, restarting in 10 min."));
@@ -163,7 +163,7 @@ abstract class task_abstract
public function getState() public function getState()
{ {
static $stmt = NULL; static $stmt = NULL;
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
if ( ! $stmt) { if ( ! $stmt) {
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid'; $sql = 'SELECT status FROM task2 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -225,7 +225,7 @@ abstract class task_abstract
throw new Exception_InvalidArgument(sprintf('unknown status `%s`', $status)); throw new Exception_InvalidArgument(sprintf('unknown status `%s`', $status));
} }
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET status = :status WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET status = :status WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -241,7 +241,7 @@ abstract class task_abstract
*/ */
public function setActive($active) public function setActive($active)
{ {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET active = :active WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET active = :active WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -261,7 +261,7 @@ abstract class task_abstract
public function setTitle($title) public function setTitle($title)
{ {
$title = strip_tags($title); $title = strip_tags($title);
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET name = :title WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET name = :title WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -289,7 +289,7 @@ abstract class task_abstract
throw new Exception_InvalidArgument('Bad XML'); throw new Exception_InvalidArgument('Bad XML');
} }
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET settings = :settings WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET settings = :settings WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -309,7 +309,7 @@ abstract class task_abstract
*/ */
public function resetCrashCounter() public function resetCrashCounter()
{ {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET crashed = 0 WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET crashed = 0 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -336,7 +336,7 @@ abstract class task_abstract
*/ */
public function incrementCrashCounter() public function incrementCrashCounter()
{ {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET crashed = crashed + 1 WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET crashed = crashed + 1 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -402,7 +402,7 @@ abstract class task_abstract
$this->runner = $runner; $this->runner = $runner;
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET runner = :runner WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET runner = :runner WHERE task_id = :taskid';
$params = array( $params = array(
@@ -432,14 +432,13 @@ abstract class task_abstract
public function delete() public function delete()
{ {
if ( ! $this->getPID()) { // do not delete a running task if ( ! $this->getPID()) { // do not delete a running task
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$registry = registry::get_instance();
$sql = "DELETE FROM task2 WHERE task_id = :task_id"; $sql = "DELETE FROM task2 WHERE task_id = :task_id";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':task_id' => $this->getID())); $stmt->execute(array(':task_id' => $this->getID()));
$stmt->closeCursor(); $stmt->closeCursor();
$lock_file = $registry->get('GV_RootPath') . 'tmp/locks/task_' . $this->getID() . '.lock'; $lock_file = __DIR__ . '/../../../tmp/locks/task_' . $this->getID() . '.lock';
@unlink($lock_file); @unlink($lock_file);
} }
} }
@@ -449,7 +448,7 @@ abstract class task_abstract
*/ */
public function setLastExecTime() public function setLastExecTime()
{ {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET last_exec_time=NOW() WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET last_exec_time=NOW() WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':taskid' => $this->getID())); $stmt->execute(array(':taskid' => $this->getID()));
@@ -463,7 +462,7 @@ abstract class task_abstract
*/ */
public function getLastExecTime() public function getLastExecTime()
{ {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'SELECT last_exec_time FROM task2 WHERE task_id = :taskid'; $sql = 'SELECT last_exec_time FROM task2 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -558,9 +557,7 @@ abstract class task_abstract
*/ */
private function getLockfilePath() private function getLockfilePath()
{ {
$core = \bootstrap::getCore(); $lockdir = $this->dependencyContainer['phraseanet.registry']->get('GV_RootPath') . 'tmp/locks/';
$lockdir = $core->getRegistry()->get('GV_RootPath') . 'tmp/locks/';
$lockfilePath = ($lockdir . 'task_' . $this->getID() . '.lock'); $lockfilePath = ($lockdir . 'task_' . $this->getID() . '.lock');
return $lockfilePath; return $lockfilePath;
@@ -849,9 +846,7 @@ abstract class task_abstract
$tid = $app['phraseanet.appbox']->get_connection()->lastInsertId(); $tid = $app['phraseanet.appbox']->get_connection()->lastInsertId();
$core = \bootstrap::getCore(); return new $class_name($tid, $app, $app['monolog']);
return new $class_name($tid, $app, $core['monolog']);
} }
public function getUsage() public function getUsage()
@@ -885,7 +880,7 @@ abstract class task_abstract
$p = ($todo > 0) ? ((100 * $done) / $todo) : -1; $p = ($todo > 0) ? ((100 * $done) / $todo) : -1;
try { try {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET completed = :p WHERE task_id = :taskid'; $sql = 'UPDATE task2 SET completed = :p WHERE task_id = :taskid';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array( $stmt->execute(array(

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -28,7 +30,7 @@ abstract class task_appboxAbstract extends task_abstract
$this->running = TRUE; $this->running = TRUE;
while ($this->running) { while ($this->running) {
try { try {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (Exception $e) { } catch (Exception $e) {
$this->log($e->getMessage()); $this->log($e->getMessage());
if ($this->getRunner() == self::RUNNER_SCHEDULER) { if ($this->getRunner() == self::RUNNER_SCHEDULER) {
@@ -71,7 +73,7 @@ abstract class task_appboxAbstract extends task_abstract
break; break;
} }
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
try { try {
$this->loadSettings(simplexml_load_string($row['settings'])); $this->loadSettings(simplexml_load_string($row['settings']));
} catch (Exception $e) { } catch (Exception $e) {

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -32,7 +34,7 @@ abstract class task_databoxAbstract extends task_abstract
$this->running = TRUE; $this->running = TRUE;
while ($this->running) { while ($this->running) {
try { try {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (PDOException $e) { } catch (PDOException $e) {
$this->log($e->getMessage()); $this->log($e->getMessage());
if ($this->getRunner() == self::RUNNER_SCHEDULER) { if ($this->getRunner() == self::RUNNER_SCHEDULER) {
@@ -81,9 +83,9 @@ abstract class task_databoxAbstract extends task_abstract
} }
$this->sbas_id = (int) $row['sbas_id']; $this->sbas_id = (int) $row['sbas_id'];
$this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id)); $this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id, $app));
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
try { try {
// get the records to process // get the records to process
$databox = $appbox->get_databox((int) $row['sbas_id']); $databox = $appbox->get_databox((int) $row['sbas_id']);

View File

@@ -9,7 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use \Monolog\Logger; use Alchemy\Phrasea\Core\Configuration;
use Monolog\Logger;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
/** /**
@@ -24,12 +25,12 @@ class task_manager
const STATE_STARTED = 'started'; const STATE_STARTED = 'started';
const STATE_TOSTOP = 'tostop'; const STATE_TOSTOP = 'tostop';
protected $appbox; protected $app;
protected $tasks; protected $tasks;
public function __construct(appbox &$appbox) public function __construct(Application $app)
{ {
$this->appbox = $appbox; $this->app = $app;
return $this; return $this;
} }
@@ -68,18 +69,16 @@ class task_manager
public function getTasks($refresh = false, Logger $logger = null) public function getTasks($refresh = false, Logger $logger = null)
{ {
if ($this->tasks && ! $refresh) { if ($this->tasks && !$refresh) {
return $this->tasks; return $this->tasks;
} }
$core = \bootstrap::getCore(); if (!$logger) {
$logger = $this->app['monolog'];
if ( ! $logger) {
$logger = $core['monolog'];
} }
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC"; $sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(); $stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -90,11 +89,11 @@ class task_manager
$row['pid'] = NULL; $row['pid'] = NULL;
$classname = $row['class']; $classname = $row['class'];
if ( ! class_exists($classname)) { if (!class_exists($classname)) {
continue; continue;
} }
try { try {
$tasks[$row['task_id']] = new $classname($row['task_id'], $app, $logger); $tasks[$row['task_id']] = new $classname($row['task_id'], $this->app, $logger);
} catch (Exception $e) { } catch (Exception $e) {
} }
@@ -110,17 +109,15 @@ class task_manager
* @param int $task_id * @param int $task_id
* @return task_abstract * @return task_abstract
*/ */
public function getTask(Application $app, $task_id, Logger $logger = null) public function getTask($task_id, Logger $logger = null)
{ {
$core = \bootstrap::getCore(); if (!$logger) {
$logger = $this->app['monolog'];
if ( ! $logger) {
$logger = $core['monolog'];
} }
$tasks = $this->getTasks($app, false, $logger); $tasks = $this->getTasks(false, $logger);
if ( ! isset($tasks[$task_id])) { if (!isset($tasks[$task_id])) {
throw new Exception_NotFound('Unknown task_id ' . $task_id); throw new Exception_NotFound('Unknown task_id ' . $task_id);
} }
@@ -145,11 +142,11 @@ class task_manager
self::STATE_TOSTOP self::STATE_TOSTOP
); );
if ( ! in_array($status, $av_status)) if (!in_array($status, $av_status))
throw new Exception(sprintf('unknown status `%s` ', $status)); throw new Exception(sprintf('unknown status `%s` ', $status));
$sql = "UPDATE sitepreff SET schedstatus = :schedstatus, schedqtime=NOW()"; $sql = "UPDATE sitepreff SET schedstatus = :schedstatus, schedqtime=NOW()";
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':schedstatus' => $status)); $stmt->execute(array(':schedstatus' => $status));
$stmt->closeCursor(); $stmt->closeCursor();
@@ -158,19 +155,17 @@ class task_manager
public function getSchedulerState() public function getSchedulerState()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore());
$sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay $sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay
, schedqtime AS updated_on , schedqtime AS updated_on
, schedstatus AS status FROM sitepreff"; , schedstatus AS status FROM sitepreff";
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(); $stmt->execute();
$ret = $stmt->fetch(PDO::FETCH_ASSOC); $ret = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$pid = NULL; $pid = NULL;
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/'; $lockdir = $this->app['phraseanet.registry']->get('GV_RootPath') . 'tmp/locks/';
if (($schedlock = fopen($lockdir . 'scheduler.lock', 'a+')) != FALSE) { if (($schedlock = fopen($lockdir . 'scheduler.lock', 'a+')) != FALSE) {
if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) { if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) {
// already locked : running ! // already locked : running !
@@ -190,7 +185,7 @@ class task_manager
if ($pid === NULL && $ret['status'] !== 'stopped') { if ($pid === NULL && $ret['status'] !== 'stopped') {
// auto fix // auto fix
$this->appbox->get_connection()->exec('UPDATE sitepreff SET schedstatus=\'stopped\''); $this->app['phraseanet.appbox']->get_connection()->exec('UPDATE sitepreff SET schedstatus=\'stopped\'');
$ret['status'] = 'stopped'; $ret['status'] = 'stopped';
} }
$ret['pid'] = $pid; $ret['pid'] = $pid;
@@ -200,17 +195,17 @@ class task_manager
public static function getAvailableTasks() public static function getAvailableTasks()
{ {
$registry = registry::get_instance(); $taskdir = array(
$taskdir = array($registry->get('GV_RootPath') . "lib/classes/task/period/" __DIR__ . "/period/",
, $registry->get('GV_RootPath') . "config/classes/task/period/" __DIR__ . "/../../../config/classes/task/period/",
); );
$tasks = array(); $tasks = array();
foreach ($taskdir as $path) { foreach ($taskdir as $path) {
if (($hdir = @opendir($path)) != FALSE) { if (($hdir = @opendir($path)) != FALSE) {
$max = 9999; $max = 9999;
while (($max -- > 0) && (($file = readdir($hdir)) !== false)) { while (($max-- > 0) && (($file = readdir($hdir)) !== false)) {
if ( ! is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php") { if (!is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php") {
continue; continue;
} }

View File

@@ -8,6 +8,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -445,7 +447,7 @@ class task_period_RecordMover extends task_appboxAbstract
} }
try { try {
$connbas = connection::getPDOConnection($task['sbas_id']); $connbas = connection::getPDOConnection($this->dependencyContainer, $task['sbas_id']);
} catch (Exception $e) { } catch (Exception $e) {
$this->log(sprintf("can't connect sbas %s", $task['sbas_id'])); $this->log(sprintf("can't connect sbas %s", $task['sbas_id']));
continue; continue;
@@ -457,7 +459,7 @@ class task_period_RecordMover extends task_appboxAbstract
$tmp = array('sbas_id' => $task['sbas_id'], 'record_id' => $row['record_id'], 'action' => $task['action']); $tmp = array('sbas_id' => $task['sbas_id'], 'record_id' => $row['record_id'], 'action' => $task['action']);
$rec = new record_adapter($task['sbas_id'], $row['record_id']); $rec = new record_adapter($this->dependencyContainer, $task['sbas_id'], $row['record_id']);
switch ($task['action']) { switch ($task['action']) {
case 'UPDATE': case 'UPDATE':
@@ -500,16 +502,16 @@ class task_period_RecordMover extends task_appboxAbstract
protected function processOneContent(appbox $appbox, Array $row) protected function processOneContent(appbox $appbox, Array $row)
{ {
$logsql = (int) ($this->sxTaskSettings->logsql) > 0; $logsql = (int) ($this->sxTaskSettings->logsql) > 0;
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$databox = $appbox->get_databox($row['sbas_id']); $databox = $appbox->get_databox($row['sbas_id']);
$rec = new record_adapter($row['sbas_id'], $row['record_id']); $rec = new record_adapter($this->dependencyContainer, $row['sbas_id'], $row['record_id']);
switch ($row['action']) { switch ($row['action']) {
case 'UPDATE': case 'UPDATE':
// change collection ? // change collection ?
if (array_key_exists('coll', $row)) { if (array_key_exists('coll', $row)) {
$coll = collection::get_from_coll_id($databox, $row['coll']); $coll = collection::get_from_coll_id($this->dependencyContainer, $databox, $row['coll']);
$rec->move_to_collection($coll, $appbox); $rec->move_to_collection($coll, $appbox);
if ($logsql) { if ($logsql) {
$this->log(sprintf("on sbas %s move rid %s to coll %s \n", $row['sbas_id'], $row['record_id'], $coll->get_coll_id())); $this->log(sprintf("on sbas %s move rid %s to coll %s \n", $row['sbas_id'], $row['record_id'], $coll->get_coll_id()));
@@ -572,7 +574,7 @@ class task_period_RecordMover extends task_appboxAbstract
*/ */
private function calcSQL($sxtask, $playTest = false) private function calcSQL($sxtask, $playTest = false)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$sbas_id = (int) ($sxtask['sbas_id']); $sbas_id = (int) ($sxtask['sbas_id']);
@@ -741,7 +743,7 @@ class task_period_RecordMover extends task_appboxAbstract
*/ */
private function calcWhere($sbas_id, &$sxtask) private function calcWhere($sbas_id, &$sxtask)
{ {
$connbas = connection::getPDOConnection($sbas_id); $connbas = connection::getPDOConnection($this->dependencyContainer, $sbas_id);
$tw = array(); $tw = array();
$join = ''; $join = '';
@@ -845,7 +847,7 @@ class task_period_RecordMover extends task_appboxAbstract
*/ */
private function playTest($sbas_id, $sql) private function playTest($sbas_id, $sql)
{ {
$connbas = connection::getPDOConnection($sbas_id); $connbas = connection::getPDOConnection($this->dependencyContainer, $sbas_id);
$result = array('rids' => array(), 'err' => '', 'n' => null); $result = array('rids' => array(), 'err' => '', 'n' => null);
$result['n'] = $connbas->query('SELECT COUNT(*) AS n FROM (' . $sql . ') AS x')->fetchColumn(); $result['n'] = $connbas->query('SELECT COUNT(*) AS n FROM (' . $sql . ') AS x')->fetchColumn();

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -72,8 +74,8 @@ class task_period_apibridge extends task_appboxAbstract
protected function processOneContent(appbox $appbox, Array $row) protected function processOneContent(appbox $appbox, Array $row)
{ {
try { try {
$account = Bridge_Account::load_account($appbox, $row['account_id']); $account = Bridge_Account::load_account($this->dependencyContainer, $row['account_id']);
$element = new Bridge_Element($appbox, $account, $row['id']); $element = new Bridge_Element($this->dependencyContainer, $account, $row['id']);
$this->log("process " . $element->get_id() . " with status " . $element->get_status()); $this->log("process " . $element->get_id() . " with status " . $element->get_status());
@@ -138,7 +140,6 @@ class task_period_apibridge extends task_appboxAbstract
*/ */
protected function update_element(Bridge_Element &$element) protected function update_element(Bridge_Element &$element)
{ {
$Core = bootstrap::getCore();
$account = $element->get_account(); $account = $element->get_account();
$connector_status = $account->get_api()->get_element_status($element); $connector_status = $account->get_api()->get_element_status($element);
@@ -167,7 +168,7 @@ class task_period_apibridge extends task_appboxAbstract
, '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()
); );
$events_mngr = $Core['events-manager']; $events_mngr = $this->dependencyContainer['events-manager'];
$events_mngr->trigger('__BRIDGE_UPLOAD_FAIL__', $params); $events_mngr->trigger('__BRIDGE_UPLOAD_FAIL__', $params);
break; break;

View File

@@ -8,6 +8,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Metadata\Tag as PhraseaTag; use Alchemy\Phrasea\Metadata\Tag as PhraseaTag;
use Alchemy\Phrasea\Border\Attribute as BorderAttribute; use Alchemy\Phrasea\Border\Attribute as BorderAttribute;
use MediaVorus\MediaVorus; use MediaVorus\MediaVorus;
@@ -196,7 +197,7 @@ class task_period_archive extends task_abstract
*/ */
public function getInterfaceHTML() public function getInterfaceHTML()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
ob_start(); ob_start();
?> ?>
@@ -260,13 +261,13 @@ class task_period_archive extends task_abstract
{ {
$this->debug = false; $this->debug = false;
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
$this->sxTaskSettings = simplexml_load_string($this->settings); $this->sxTaskSettings = simplexml_load_string($this->settings);
$base_id = (int) ($this->sxTaskSettings->base_id); $base_id = (int) ($this->sxTaskSettings->base_id);
$this->sbas_id = \phrasea::sbasFromBas($base_id); $this->sbas_id = \phrasea::sbasFromBas($this->dependencyContainer, $base_id);
if ( ! $this->sbas_id) { if ( ! $this->sbas_id) {
$this->log('base_id unknown'); $this->log('base_id unknown');
@@ -349,7 +350,7 @@ class task_period_archive extends task_abstract
$loop = 0; $loop = 0;
while ($this->running) { while ($this->running) {
try { try {
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (Exception $e) { } catch (Exception $e) {
$this->log($e->getMessage()); $this->log($e->getMessage());
if ($this->getRunner() == self::RUNNER_SCHEDULER) { if ($this->getRunner() == self::RUNNER_SCHEDULER) {
@@ -497,8 +498,8 @@ class task_period_archive extends task_abstract
{ {
clearstatcache(); clearstatcache();
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
connection::getPDOConnection(); connection::getPDOConnection($this->dependencyContainer);
$appbox->get_databox($this->sbas_id)->get_connection(); $appbox->get_databox($this->sbas_id)->get_connection();
$path_in = p4string::delEndSlash(trim((string) ($this->sxTaskSettings->hotfolder))); $path_in = p4string::delEndSlash(trim((string) ($this->sxTaskSettings->hotfolder)));
@@ -1407,7 +1408,7 @@ class task_period_archive extends task_abstract
*/ */
private function archiveGrp(\DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, array &$nodesToDel) private function archiveGrp(\DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, array &$nodesToDel)
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$xpath = new DOMXPath($dom); $xpath = new DOMXPath($dom);
// grp folders stay in place // grp folders stay in place
@@ -1432,7 +1433,7 @@ class task_period_archive extends task_abstract
// if the .grp does not have a representative doc, let's use a generic file // if the .grp does not have a representative doc, let's use a generic file
if ( ! ($rep = $node->getAttribute('grp_representation'))) { if ( ! ($rep = $node->getAttribute('grp_representation'))) {
$registry = registry::get_instance(); $registry = $this->dependencyContainer['phraseanet.registry'];
try { try {
$this->dependencyContainer['filesystem']->copy(p4string::addEndSlash($registry->get('GV_RootPath')) . 'www/skins/icons/substitution/regroup_doc.png', $genericdoc = ($path . '/group.jpg'), true); $this->dependencyContainer['filesystem']->copy(p4string::addEndSlash($registry->get('GV_RootPath')) . 'www/skins/icons/substitution/regroup_doc.png', $genericdoc = ($path . '/group.jpg'), true);
@@ -1461,7 +1462,7 @@ class task_period_archive extends task_abstract
try { try {
$databox = $appbox->get_databox($this->sbas_id); $databox = $appbox->get_databox($this->sbas_id);
$collection = collection::get_from_coll_id($databox, (int) $cid); $collection = collection::get_from_coll_id($this->dependencyContainer, $databox, (int) $cid);
if ($captionFileName === null) { if ($captionFileName === null) {
$story = $this->createStory($collection, $path . '/' . $representationFileName, null); $story = $this->createStory($collection, $path . '/' . $representationFileName, null);
} else { } else {
@@ -1614,20 +1615,19 @@ class task_period_archive extends task_abstract
$stat1 = '0'; $stat1 = '0';
} }
$core = \bootstrap::getCore(); $media = $this->dependencyContainer['mediavorus']->guess($pathfile);
$media = $core['mediavorus']->guess(new \SplFileInfo($pathfile));
$databox = $collection->get_databox(); $databox = $collection->get_databox();
$metadatasStructure = $databox->get_meta_structure(); $metadatasStructure = $databox->get_meta_structure();
$metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getEntity()->getMetadatas()); $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) { if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) {
$caption = $this->readXMLForDatabox($metadatasStructure, $captionFile); $caption = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$captionStatus = $this->parseStatusBit(simplexml_load_file($captionFile)); $captionStatus = $this->parseStatusBit(simplexml_load_file($captionFile));
if ($captionStatus) { if ($captionStatus) {
$status = databox_status::operation_or($status, $captionStatus); $status = databox_status::operation_or($this->dependencyContainer, $status, $captionStatus);
} }
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption); $metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption);
@@ -1635,11 +1635,11 @@ class task_period_archive extends task_abstract
$metas = $this->bagToArray($metadatasStructure, $metadatas); $metas = $this->bagToArray($metadatasStructure, $metadatas);
$story = record_adapter::createStory($collection); $story = record_adapter::createStory($this->dependencyContainer, $collection);
$story->substitute_subdef('document', $media, $this->dependencyContainer['filesystem'], $core['media-alchemyst'], $core['mediavorus']); $story->substitute_subdef('document', $media, $this->dependencyContainer);
$story->set_metadatas($metas, true); $story->set_metadatas($metas, true);
$story->set_binary_status(databox_status::operation_or($stat0, $stat1)); $story->set_binary_status(databox_status::operation_or($this->dependencyContainer, $stat0, $stat1));
$story->rebuild_subdefs(); $story->rebuild_subdefs();
$story->reindex(); $story->reindex();
@@ -1678,29 +1678,28 @@ class task_period_archive extends task_abstract
$stat1 = '0'; $stat1 = '0';
} }
$core = \bootstrap::getCore(); $status = databox_status::operation_or($this->dependencyContainer, $stat0, $stat1);
$status = databox_status::operation_or($stat0, $stat1);
$media = $core['mediavorus']->guess(new \SplFileInfo($pathfile)); $media = $this->dependencyContainer['mediavorus']->guess($pathfile);
$databox = $collection->get_databox(); $databox = $collection->get_databox();
$metadatasStructure = $databox->get_meta_structure(); $metadatasStructure = $databox->get_meta_structure();
$metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getEntity()->getMetadatas()); $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) { if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) {
$caption = $this->readXMLForDatabox($metadatasStructure, $captionFile); $caption = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$captionStatus = $this->parseStatusBit(simplexml_load_file($captionFile)); $captionStatus = $this->parseStatusBit(simplexml_load_file($captionFile));
if ($captionStatus) { if ($captionStatus) {
$status = databox_status::operation_or($status, $captionStatus); $status = databox_status::operation_or($this->dependencyContainer, $status, $captionStatus);
} }
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption); $metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption);
} }
$file = new \Alchemy\Phrasea\Border\File($media, $collection); $file = new \Alchemy\Phrasea\Border\File($media, $collection);
$file->addAttribute(new BorderAttribute\Status($status)); $file->addAttribute(new BorderAttribute\Status($this->dependencyContainer, $status));
$file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfFilepath(), new \PHPExiftool\Driver\Value\Mono($media->getFile()->getRealPath())))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfFilepath(), new \PHPExiftool\Driver\Value\Mono($media->getFile()->getRealPath()))));
$file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfDirname(), new \PHPExiftool\Driver\Value\Mono(dirname($media->getFile()->getRealPath()))))); $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfDirname(), new \PHPExiftool\Driver\Value\Mono(dirname($media->getFile()->getRealPath())))));
@@ -1714,7 +1713,7 @@ class task_period_archive extends task_abstract
} }
if ($grp_rid) { if ($grp_rid) {
$file->addAttribute(new BorderAttribute\Story(new record_adapter($databox->get_sbas_id(), $grp_rid))); $file->addAttribute(new BorderAttribute\Story(new record_adapter($this->dependencyContainer, $databox->get_sbas_id(), $grp_rid)));
} }
$record = null; $record = null;
@@ -1723,7 +1722,7 @@ class task_period_archive extends task_abstract
$record = $element; $record = $element;
}; };
$core['border-manager']->process($this->getLazaretSession(), $file, $postProcess, $force); $this->dependencyContainer['border-manager']->process($this->getLazaretSession(), $file, $postProcess, $force);
return $record; return $record;
} }
@@ -1828,11 +1827,11 @@ class task_period_archive extends task_abstract
* @param integer $grp_rid * @param integer $grp_rid
* @param array $nodesToDel out, filled with files to delete * @param array $nodesToDel out, filled with files to delete
*/ */
private function archiveFileAndCaption(\DOMDOcument$dom, \DOMElement $node, \DOMElement $captionFileNode = null, $path, $path_archived, $path_error, $grp_rid, array &$nodesToDel) private function archiveFileAndCaption(\DOMDocument $dom, \DOMElement $node, \DOMElement $captionFileNode = null, $path, $path_archived, $path_error, $grp_rid, array &$nodesToDel)
{ {
$ret = false; $ret = false;
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$file = $node->getAttribute('name'); $file = $node->getAttribute('name');
$cid = $node->getAttribute('cid'); $cid = $node->getAttribute('cid');
$captionFileName = $captionFileNode ? $captionFileNode->getAttribute('name') : null; $captionFileName = $captionFileNode ? $captionFileNode->getAttribute('name') : null;
@@ -1864,7 +1863,7 @@ class task_period_archive extends task_abstract
try { try {
$databox = $appbox->get_databox($this->sbas_id); $databox = $appbox->get_databox($this->sbas_id);
$collection = collection::get_from_coll_id($databox, (int) $cid); $collection = collection::get_from_coll_id($this->dependencyContainer, $databox, (int) $cid);
if ($captionFileName === null) { if ($captionFileName === null) {
$record = $this->createRecord($collection, $path . '/' . $file, null, $grp_rid); $record = $this->createRecord($collection, $path . '/' . $file, null, $grp_rid);
@@ -2043,12 +2042,10 @@ class task_period_archive extends task_abstract
return $this->lazaretSession; return $this->lazaretSession;
} }
$core = \bootstrap::getCore();
$lazaretSession = new \Entities\LazaretSession(); $lazaretSession = new \Entities\LazaretSession();
$core['EM']->persist($lazaretSession); $this->dependencyContainer['EM']->persist($lazaretSession);
$core['EM']->flush(); $this->dependencyContainer['EM']->flush();
$this->lazaretSession = $lazaretSession; $this->lazaretSession = $lazaretSession;

View File

@@ -435,7 +435,7 @@ class task_period_cindexer extends task_abstract
$args_nopwd[] = '--run'; $args_nopwd[] = '--run';
} }
$registry = registry::get_instance(); $registry = $this->dependencyContainer['phraseanet.registry'];
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs'); $logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
$this->new_status = NULL; // new status to set at the end $this->new_status = NULL; // new status to set at the end

View File

@@ -48,7 +48,7 @@ class task_period_emptyColl extends task_appboxAbstract
return array(); return array();
} }
$collection = collection::get_from_base_id($this->base_id); $collection = collection::get_from_base_id($this->dependencyContainer, $this->base_id);
$this->total_records = $collection->get_record_amount(); $this->total_records = $collection->get_record_amount();
$collection->empty_collection(200); $collection->empty_collection(200);
$this->records_done += $this->total_records; $this->records_done += $this->total_records;

View File

@@ -250,7 +250,7 @@ class task_period_ftp extends task_appboxAbstract
$sql = "SELECT id FROM ftp_export WHERE crash>=nbretry $sql = "SELECT id FROM ftp_export WHERE crash>=nbretry
AND date < :date"; AND date < :date";
$params = array(':date' => phraseadate::format_mysql(new DateTime('-30 days'))); $params = array(':date' => $this->dependencyContainer['date-formatter']->format_mysql(new DateTime('-30 days')));
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
@@ -404,8 +404,8 @@ class task_period_ftp extends task_appboxAbstract
$subdef = $file['subdef']; $subdef = $file['subdef'];
try { try {
$sbas_id = phrasea::sbasFromBas($base_id); $sbas_id = phrasea::sbasFromBas($this->dependencyContainer, $base_id);
$record = new record_adapter($sbas_id, $record_id); $record = new record_adapter($this->dependencyContainer, $sbas_id, $record_id);
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]); $sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
@@ -464,12 +464,12 @@ class task_period_ftp extends task_appboxAbstract
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':file_id' => $file['id'])); $stmt->execute(array(':file_id' => $file['id']));
$stmt->closeCursor(); $stmt->closeCursor();
$this->logexport($appbox->get_session(), $record, $obj, $ftpLog); $this->logexport($record, $obj, $ftpLog);
} catch (Exception $e) { } catch (Exception $e) {
$state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' . $state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' .
' (Export du Document) : Transfert cancelled (le document n\'existe plus)') ' (Export du Document) : Transfert cancelled (le document n\'existe plus)')
, basename($localfile), $record_id , basename($localfile), $record_id
, phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n<br/>"; , phrasea::sbas_names(phrasea::sbasFromBas($this->dependencyContainer, $base_id), $app)) . "\n<br/>";
$this->logger->addDebug($line); $this->logger->addDebug($line);
@@ -601,7 +601,7 @@ class task_period_ftp extends task_appboxAbstract
public function send_mails(appbox $appbox, $id) public function send_mails(appbox $appbox, $id)
{ {
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
$registry = registry::get_instance(); $registry = $this->dependencyContainer['phraseanet.registry'];
$sql = 'SELECT filename, base_id, record_id, subdef, error, done' $sql = 'SELECT filename, base_id, record_id, subdef, error, done'
. ' FROM ftp_export_elements WHERE ftp_export_id = :export_id'; . ' FROM ftp_export_elements WHERE ftp_export_id = :export_id';
@@ -620,13 +620,13 @@ class task_period_ftp extends task_appboxAbstract
$transferts[] = $transferts[] =
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s') '<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"] , $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"])) , phrasea::sbas_names(phrasea::sbasFromBas($this->dependencyContainer, $row["base_id"]), $app)
, phrasea::bas_names($row['base_id']), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>'; , phrasea::bas_names($row['base_id'], $app), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>';
} else { } else {
$transferts[] = $transferts[] =
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s') '<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"] , $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"])), phrasea::bas_names($row['base_id']) , phrasea::sbas_names(phrasea::sbasFromBas($this->dependencyContainer, $row["base_id"]), $app), phrasea::bas_names($row['base_id'], $app)
, $row['subdef']) . ' : ' . _('Transfert Annule') . '</li>'; , $row['subdef']) . ' : ' . _('Transfert Annule') . '</li>';
$transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes'); $transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes');
} }
@@ -671,15 +671,15 @@ class task_period_ftp extends task_appboxAbstract
, $registry->get('GV_homeTitle'), $ftp_server , $registry->get('GV_homeTitle'), $ftp_server
); );
mail::ftp_sent($sendermail, $subject, $sender_message); mail::ftp_sent($this->dependencyContainer, $sendermail, $subject, $sender_message);
mail::ftp_receive($mail, $receiver_message); mail::ftp_receive($this->dependencyContainer, $mail, $receiver_message);
} }
public function logexport(Session_Handler $session, record_adapter $record, $obj, $ftpLog) public function logexport(record_adapter $record, $obj, $ftpLog)
{ {
foreach ($obj as $oneObj) { foreach ($obj as $oneObj) {
$session->get_logger($record->get_databox()) $this->app['phraseanet.logger']($record->get_databox())
->log($record, Session_Logger::EVENT_EXPORTFTP, $ftpLog, ''); ->log($record, Session_Logger::EVENT_EXPORTFTP, $ftpLog, '');
} }

View File

@@ -8,6 +8,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -310,9 +312,8 @@ class task_period_outofdate extends task_abstract
// ==================================================================== // ====================================================================
public function getInterfaceHTML() public function getInterfaceHTML()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$session = $appbox->get_session(); $user = $this->dependencyContainer['phraseanet.user'];
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
ob_start(); ob_start();
$sbas_list = $user->ACL()->get_granted_sbas(array('bas_manage')); $sbas_list = $user->ACL()->get_granted_sbas(array('bas_manage'));
@@ -437,13 +438,13 @@ class task_period_outofdate extends task_abstract
protected function run2() protected function run2()
{ {
$ret = ''; $ret = '';
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
$this->sxTaskSettings = simplexml_load_string($this->settings); $this->sxTaskSettings = simplexml_load_string($this->settings);
$this->sbas_id = (int) ($this->sxTaskSettings->sbas_id); $this->sbas_id = (int) ($this->sxTaskSettings->sbas_id);
$this->connbas = connection::getPDOConnection($this->sbas_id); $this->connbas = connection::getPDOConnection($this->dependencyContainer, $this->sbas_id);
$this->running = true; $this->running = true;
$this->tmask = array(); $this->tmask = array();
@@ -465,7 +466,7 @@ class task_period_outofdate extends task_abstract
} }
try { try {
$connbas = connection::getPDOConnection($this->sbas_id); $connbas = connection::getPDOConnection($this->dependencyContainer, $this->sbas_id);
if ( ! $connbas->ping()) { if ( ! $connbas->ping()) {
throw new Exception('Mysql has gone away'); throw new Exception('Mysql has gone away');
} }
@@ -500,7 +501,7 @@ class task_period_outofdate extends task_abstract
} else { } else {
$period = 60; $period = 60;
} }
$this->connbas = connection::getPDOConnection($this->sbas_id); $this->connbas = connection::getPDOConnection($this->dependencyContainer, $this->sbas_id);
$duration = time(); $duration = time();
@@ -519,7 +520,7 @@ class task_period_outofdate extends task_abstract
$duration = time() - $duration; $duration = time() - $duration;
if ($duration < $period) { if ($duration < $period) {
sleep($period - $duration); sleep($period - $duration);
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->dependencyContainer);
} }
break; break;
case 'MAXRECSDONE': case 'MAXRECSDONE':
@@ -731,7 +732,7 @@ class task_period_outofdate extends task_abstract
{ {
$ret = NULL; $ret = NULL;
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm2 = $request->get_parms( $parm2 = $request->get_parms(
'ACT', 'bid' 'ACT', 'bid'

View File

@@ -159,9 +159,9 @@ class task_period_subdef extends task_databoxAbstract
, $this->sbas_id, $record_id)); , $this->sbas_id, $record_id));
try { try {
$record = new record_adapter($this->sbas_id, $record_id); $record = new record_adapter($this->dependencyContainer, $this->sbas_id, $record_id);
$record->generate_subdefs($databox, $this->logger); $record->generate_subdefs($databox, $this->dependencyContainer);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->log( $this->log(
sprintf( sprintf(
@@ -205,7 +205,7 @@ class task_period_subdef extends task_databoxAbstract
)); ));
try { try {
$connbas = connection::getPDOConnection($this->sbas_id); $connbas = connection::getPDOConnection($this->dependencyContainer, $this->sbas_id);
$sql = 'UPDATE record $sql = 'UPDATE record
SET status=(status & ~0x03), SET status=(status & ~0x03),
jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ') jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ')

View File

@@ -8,6 +8,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -261,9 +263,8 @@ class task_period_workflow01 extends task_databoxAbstract
public function getInterfaceHTML() public function getInterfaceHTML()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$session = $appbox->get_session(); $user = $this->dependencyContainer['phraseanet.user'];
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
ob_start(); ob_start();
?> ?>
<form name="graphicForm" onsubmit="return(false);" method="post"> <form name="graphicForm" onsubmit="return(false);" method="post">
@@ -430,9 +431,8 @@ class task_period_workflow01 extends task_databoxAbstract
{ {
$request = http_request::getInstance(); $request = http_request::getInstance();
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$session = $appbox->get_session(); $user = $this->dependencyContainer['phraseanet.user'];
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$parm = $request->get_parms("bid"); $parm = $request->get_parms("bid");

View File

@@ -8,6 +8,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Core\Configuration;
use PHPExiftool\Driver\Metadata; use PHPExiftool\Driver\Metadata;
use PHPExiftool\Driver\Value; use PHPExiftool\Driver\Value;
use PHPExiftool\Driver\Tag; use PHPExiftool\Driver\Tag;
@@ -172,10 +173,8 @@ class task_period_writemeta extends task_databoxAbstract
public function getInterfaceHTML() public function getInterfaceHTML()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = $this->dependencyContainer['phraseanet.appbox'];
$session = $appbox->get_session(); $sbas_ids = $this->dependencyContainer['phraseanet.user']->ACL()->get_granted_sbas(array('bas_manage'));
$sbas_ids = User_Adapter::getInstance($session->get_usr_id(), $appbox)
->ACL()->get_granted_sbas(array('bas_manage'));
ob_start(); ob_start();
if (count($sbas_ids) > 0) { if (count($sbas_ids) > 0) {
@@ -236,7 +235,7 @@ class task_period_writemeta extends task_databoxAbstract
$record_id = $row['record_id']; $record_id = $row['record_id'];
$jeton = $row['jeton']; $jeton = $row['jeton'];
$record = new record_adapter($this->sbas_id, $record_id); $record = new record_adapter($this->dependencyContainer, $this->sbas_id, $record_id);
$type = $record->get_type(); $type = $record->get_type();
$subdefs = $record->get_subdefs(); $subdefs = $record->get_subdefs();
@@ -312,7 +311,6 @@ class task_period_writemeta extends task_databoxAbstract
$writer->write($file, $metadatas); $writer->write($file, $metadatas);
$this->log(sprintf('Success writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)', $this->sbas_id, $record_id, $name)); $this->log(sprintf('Success writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)', $this->sbas_id, $record_id, $name));
} catch (\PHPExiftool\Exception\Exception $e) { } catch (\PHPExiftool\Exception\Exception $e) {
$this->log(sprintf('Failure writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)', $this->sbas_id, $record_id, $name)); $this->log(sprintf('Failure writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)', $this->sbas_id, $record_id, $name));
} }