mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
revert patch 370a7
This commit is contained in:
@@ -51,213 +51,125 @@ class patch_370a7 implements patchInterface
|
|||||||
return $this->concern;
|
return $this->concern;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* transform tasks 'workflow 01' to 'workflow 02'
|
|
||||||
* will group tasks(01) with same period to a single task(02)
|
|
||||||
*
|
|
||||||
* @param base $appbox
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function apply(base &$appbox)
|
public function apply(base &$appbox)
|
||||||
{
|
{
|
||||||
$task_manager = new task_manager($appbox);
|
$Core = \bootstrap::getCore();
|
||||||
|
|
||||||
|
$em = $Core->getEntityManager();
|
||||||
|
|
||||||
|
//order matters for foreign keys constraints
|
||||||
|
//truncate all altered tables
|
||||||
|
$this->truncateTable($em, 'Entities\\LazaretFile');
|
||||||
|
$this->truncateTable($em, 'Entities\\LazaretSession');
|
||||||
|
$this->truncateTable($em, 'Entities\\LazaretAttribute');
|
||||||
|
$this->truncateTable($em, 'Entities\\LazaretCheck');
|
||||||
|
|
||||||
$ttasks = array();
|
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
$sql = 'SELECT task_id, active, name, class, settings FROM task2 WHERE class=\'task_period_workflow01\' OR class=\'task_period_ftv\'';
|
|
||||||
if (($stmt = $conn->prepare($sql)) !== FALSE) {
|
|
||||||
$stmt->execute();
|
|
||||||
$ttasks = $row = $stmt->fetchAll();
|
|
||||||
$stmt->closeCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
$tdom = array(); // key = period
|
//get all old lazaret file & transform them to \Entities\LazaretFile object
|
||||||
$taskstodel = array();
|
$sql = 'SELECT * FROM lazaret';
|
||||||
foreach ($ttasks as $task) {
|
$stmt = $conn->prepare($sql);
|
||||||
$active = true;
|
$stmt->execute();
|
||||||
$warning = array();
|
$rs = $stmt->fetchAll();
|
||||||
|
|
||||||
/*
|
// suspend auto-commit
|
||||||
* migrating task 'workflow01' or 'task_period_ftv'
|
$em->getConnection()->beginTransaction();
|
||||||
*/
|
|
||||||
$x = $task['settings'];
|
|
||||||
if (($sx = simplexml_load_string($x)) !== FALSE) {
|
|
||||||
$period = (int) ($sx->period);
|
|
||||||
|
|
||||||
if ( ! array_key_exists('_' . $period, $tdom)) {
|
$transfertLazaretFile = $success = false;
|
||||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$dom->formatOutput = true;
|
if ($stmt->rowCount() > 0) {
|
||||||
$dom->preserveWhiteSpace = false;
|
try {
|
||||||
$ts = $dom->appendChild($dom->createElement('tasksettings'));
|
foreach ($rs as $row) {
|
||||||
$ts->appendChild($dom->createElement('period'))->appendChild($dom->createTextNode(60 * $period));
|
|
||||||
$ts->appendChild($dom->createElement('logsql'))->appendChild($dom->createTextNode('1'));
|
$filePath = __DIR__ . '/../../../tmp/lazaret/' . $row['filepath'];
|
||||||
$tasks = $ts->appendChild($dom->createElement('tasks'));
|
|
||||||
$tdom['_' . $period] = array('dom' => $dom, 'tasks' => $tasks);
|
if (file_exists($filePath)) {
|
||||||
} else {
|
$media = \MediaVorus\MediaVorus::guess(new \SplFileInfo($filePath));
|
||||||
$dom = &$tdom['_' . $period]['dom'];
|
|
||||||
$tasks = &$tdom['_' . $period]['tasks'];
|
$collection = \collection::get_from_base_id($row['base_id']);
|
||||||
|
|
||||||
|
$borderFile = new \Alchemy\Phrasea\Border\File($media, $collection);
|
||||||
|
|
||||||
|
$lazaretSession = new \Entities\LazaretSession();
|
||||||
|
$lazaretSession->setUsrId($row['usr_id']);
|
||||||
|
|
||||||
|
$lazaretFile = new \Entities\LazaretFile();
|
||||||
|
$lazaretFile->setBaseId($row['base_id']);
|
||||||
|
|
||||||
|
if (null === $row['uuid']) {
|
||||||
|
$uuid = $borderFile->getUUID(true);
|
||||||
|
$lazaretFile->setUuid($uuid);
|
||||||
|
} else {
|
||||||
|
$lazaretFile->setUuid($row['uuid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $row['sha256']) {
|
||||||
|
$sha256 = $media->getHash('sha256');
|
||||||
|
$lazaretFile->setSha256($sha256);
|
||||||
|
} else {
|
||||||
|
$lazaretFile->setSha256($row['sha256']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$lazaretFile->setOriginalName($row['filename']);
|
||||||
|
$lazaretFile->setPathname(__DIR__ . '/../../../tmp/lazaret/' . $row['filepath']);
|
||||||
|
$lazaretFile->setCreated(new \DateTime($row['created_on']));
|
||||||
|
$lazaretFile->setSession($lazaretSession);
|
||||||
|
|
||||||
|
$em->persist($lazaretFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
$em->flush();
|
||||||
* migrating task 'workflow01'
|
|
||||||
*/
|
|
||||||
if ($task['class'] === 'task_period_workflow01') {
|
|
||||||
$t = $tasks->appendChild($dom->createElement('task'));
|
|
||||||
$t->setAttribute('active', '0');
|
|
||||||
// $t->setAttribute('name', 'imported from \'' . $task->getTitle() . '\'');
|
|
||||||
$t->setAttribute('name', 'imported from \'' . $task['name'] . '\'');
|
|
||||||
$t->setAttribute('action', 'update');
|
|
||||||
|
|
||||||
if ($sx->sbas_id) {
|
$transfertLazaretFile = true;
|
||||||
$sbas_id = trim($sx->sbas_id);
|
} catch (\Exception $e) {
|
||||||
if ($sbas_id != '' && is_numeric($sbas_id)) {
|
$em->getConnection()->rollback();
|
||||||
$t->setAttribute('sbas_id', $sx->sbas_id);
|
$em->close();
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad sbas_id '%s'", $sbas_id);
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("missing sbas_id");
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 'from' section
|
|
||||||
$from = $t->appendChild($dom->createElement('from'));
|
|
||||||
if ($sx->coll0) {
|
|
||||||
if (($coll0 = trim($sx->coll0)) != '') {
|
|
||||||
if (is_numeric($coll0)) {
|
|
||||||
$n = $from->appendChild($dom->createElement('coll'));
|
|
||||||
$n->setAttribute('compare', '=');
|
|
||||||
$n->setAttribute('id', $coll0);
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad (from) coll_id '%s'", $coll0);
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($sx->status0 && trim($sx->status0) != '') {
|
|
||||||
$st = explode('_', trim($sx->status0));
|
|
||||||
if (count($st) == 2) {
|
|
||||||
$bit = (int) ($st[0]);
|
|
||||||
if ($bit >= 0 && $bit <= 63 && ($st[1] == '0' || $st[1] == '1')) {
|
|
||||||
$from->appendChild($dom->createElement('status'))
|
|
||||||
->setAttribute('mask', $st[1] . str_repeat('x', $bit - 1));
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad (from) status '%s'", trim($sx->status0));
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad (from) status '%s'", trim($sx->status0));
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 'to' section
|
|
||||||
$to = $t->appendChild($dom->createElement('to'));
|
|
||||||
if ($sx->coll1) {
|
|
||||||
if (($coll1 = trim($sx->coll1)) != '') {
|
|
||||||
if (is_numeric($coll1)) {
|
|
||||||
$n = $to->appendChild($dom->createElement('coll'));
|
|
||||||
$n->setAttribute('id', $coll1);
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad (to) coll_id '%s'", $coll1);
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($sx->status1 && trim($sx->status1) != '') {
|
|
||||||
$st = explode('_', trim($sx->status1));
|
|
||||||
if (count($st) == 2) {
|
|
||||||
$bit = (int) ($st[0]);
|
|
||||||
if ($bit >= 0 && $bit <= 63 && ($st[1] == '0' || $st[1] == '1')) {
|
|
||||||
$to->appendChild($dom->createElement('status'))
|
|
||||||
->setAttribute('mask', $st[1] . str_repeat('x', $bit - 1));
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad (to) status '%s'", trim($sx->status1));
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad (to) status '%s'", trim($sx->status1));
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($active && $task['active'] == '1') {
|
|
||||||
$t->setAttribute('active', '1');
|
|
||||||
}
|
|
||||||
foreach ($warning as $w) {
|
|
||||||
$t->appendChild($dom->createComment($w));
|
|
||||||
}
|
|
||||||
|
|
||||||
$taskstodel[] = $task['task_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* migrating task 'task_period_ftv'
|
|
||||||
*/
|
|
||||||
if ($task['class'] === 'task_period_ftv') {
|
|
||||||
foreach ($sx->tasks->task as $sxt) {
|
|
||||||
$active = true;
|
|
||||||
$warning = array();
|
|
||||||
|
|
||||||
$t = $dom->importNode(dom_import_simplexml($sxt), true);
|
|
||||||
$t->setAttribute('active', '0');
|
|
||||||
// $t->setAttribute('name', 'imported from \'' . $task->getTitle() . '\'');
|
|
||||||
$t->setAttribute('name', 'imported from \'' . $task['name'] . '\'');
|
|
||||||
$t->setAttribute('action', 'update');
|
|
||||||
|
|
||||||
if ($sx->sbas_id) {
|
|
||||||
$sbas_id = trim($sx->sbas_id);
|
|
||||||
if ($sbas_id != '' && is_numeric($sbas_id)) {
|
|
||||||
$t->setAttribute('sbas_id', $sx->sbas_id);
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("Bad sbas_id '%s'", $sbas_id);
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$warning[] = sprintf("missing sbas_id");
|
|
||||||
$active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($active && $task['active'] == '1') {
|
|
||||||
$t->setAttribute('active', '1');
|
|
||||||
}
|
|
||||||
foreach ($warning as $w) {
|
|
||||||
$t->appendChild($dom->createComment($w));
|
|
||||||
}
|
|
||||||
|
|
||||||
$x = new DOMXPath($dom);
|
|
||||||
$nlfrom = $x->query('from', $t);
|
|
||||||
if ($nlfrom->length == 1) {
|
|
||||||
$nlcoll = $x->query('colls', $nlfrom->item(0));
|
|
||||||
if ($nlcoll->length > 0) {
|
|
||||||
$nn = $dom->createElement('coll');
|
|
||||||
$nn->setAttribute('compare', '=');
|
|
||||||
$nn->setAttribute('id', $nlcoll->item(0)->getAttribute('id'));
|
|
||||||
$nlfrom->item(0)->replaceChild($nn, $nlcoll->item(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$tasks->appendChild($t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$taskstodel[] = $task['task_id'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($taskstodel) > 0) {
|
if ($transfertLazaretFile) {
|
||||||
$conn->exec('DELETE FROM task2 WHERE task_id IN(' . implode(',', $taskstodel) . ')');
|
try {
|
||||||
|
$sql = 'DROP TABLE lazaret';
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
//success deletion, commit all changes
|
||||||
|
$em->getConnection()->commit();
|
||||||
|
|
||||||
|
$success = true;
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
$em->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
$stmt->closeCursor();
|
||||||
* save new tasks
|
|
||||||
*/
|
if ( ! $success) {
|
||||||
foreach ($tdom as $newtask) {
|
throw new \RuntimeException(sprintf("Patch %s failed", __CLASS__));
|
||||||
$task = task_abstract::create($appbox, 'task_period_workflow02', $newtask['dom']->saveXML());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function truncateTable(\Doctrine\ORM\EntityManager $em, $className)
|
||||||
|
{
|
||||||
|
$cmd = $em->getClassMetadata($className);
|
||||||
|
$connection = $em->getConnection();
|
||||||
|
$dbPlatform = $connection->getDatabasePlatform();
|
||||||
|
$connection->beginTransaction();
|
||||||
|
try {
|
||||||
|
$query = $dbPlatform->getTruncateTableSql($cmd->getTableName());
|
||||||
|
$connection->executeUpdate($query);
|
||||||
|
$connection->commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$connection->rollback();
|
||||||
|
// throw e to stop patch execution if one truncate failed
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
263
lib/classes/patch/370a8.class.php
Normal file
263
lib/classes/patch/370a8.class.php
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2012 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class patch_370a8 implements patchInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $release = '3.7.0.0.a8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Array
|
||||||
|
*/
|
||||||
|
private $concern = array(base::APPLICATION_BOX);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
public function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* transform tasks 'workflow 01' to 'workflow 02'
|
||||||
|
* will group tasks(01) with same period to a single task(02)
|
||||||
|
*
|
||||||
|
* @param base $appbox
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function apply(base &$appbox)
|
||||||
|
{
|
||||||
|
$task_manager = new task_manager($appbox);
|
||||||
|
|
||||||
|
$ttasks = array();
|
||||||
|
$conn = $appbox->get_connection();
|
||||||
|
$sql = 'SELECT task_id, active, name, class, settings FROM task2 WHERE class=\'task_period_workflow01\' OR class=\'task_period_ftv\'';
|
||||||
|
if (($stmt = $conn->prepare($sql)) !== FALSE) {
|
||||||
|
$stmt->execute();
|
||||||
|
$ttasks = $row = $stmt->fetchAll();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
$tdom = array(); // key = period
|
||||||
|
$taskstodel = array();
|
||||||
|
foreach ($ttasks as $task) {
|
||||||
|
$active = true;
|
||||||
|
$warning = array();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* migrating task 'workflow01' or 'task_period_ftv'
|
||||||
|
*/
|
||||||
|
$x = $task['settings'];
|
||||||
|
if (($sx = simplexml_load_string($x)) !== FALSE) {
|
||||||
|
$period = (int) ($sx->period);
|
||||||
|
|
||||||
|
if ( ! array_key_exists('_' . $period, $tdom)) {
|
||||||
|
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
$dom->formatOutput = true;
|
||||||
|
$dom->preserveWhiteSpace = false;
|
||||||
|
$ts = $dom->appendChild($dom->createElement('tasksettings'));
|
||||||
|
$ts->appendChild($dom->createElement('period'))->appendChild($dom->createTextNode(60 * $period));
|
||||||
|
$ts->appendChild($dom->createElement('logsql'))->appendChild($dom->createTextNode('1'));
|
||||||
|
$tasks = $ts->appendChild($dom->createElement('tasks'));
|
||||||
|
$tdom['_' . $period] = array('dom' => $dom, 'tasks' => $tasks);
|
||||||
|
} else {
|
||||||
|
$dom = &$tdom['_' . $period]['dom'];
|
||||||
|
$tasks = &$tdom['_' . $period]['tasks'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* migrating task 'workflow01'
|
||||||
|
*/
|
||||||
|
if ($task['class'] === 'task_period_workflow01') {
|
||||||
|
$t = $tasks->appendChild($dom->createElement('task'));
|
||||||
|
$t->setAttribute('active', '0');
|
||||||
|
// $t->setAttribute('name', 'imported from \'' . $task->getTitle() . '\'');
|
||||||
|
$t->setAttribute('name', 'imported from \'' . $task['name'] . '\'');
|
||||||
|
$t->setAttribute('action', 'update');
|
||||||
|
|
||||||
|
if ($sx->sbas_id) {
|
||||||
|
$sbas_id = trim($sx->sbas_id);
|
||||||
|
if ($sbas_id != '' && is_numeric($sbas_id)) {
|
||||||
|
$t->setAttribute('sbas_id', $sx->sbas_id);
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad sbas_id '%s'", $sbas_id);
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("missing sbas_id");
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 'from' section
|
||||||
|
$from = $t->appendChild($dom->createElement('from'));
|
||||||
|
if ($sx->coll0) {
|
||||||
|
if (($coll0 = trim($sx->coll0)) != '') {
|
||||||
|
if (is_numeric($coll0)) {
|
||||||
|
$n = $from->appendChild($dom->createElement('coll'));
|
||||||
|
$n->setAttribute('compare', '=');
|
||||||
|
$n->setAttribute('id', $coll0);
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad (from) coll_id '%s'", $coll0);
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($sx->status0 && trim($sx->status0) != '') {
|
||||||
|
$st = explode('_', trim($sx->status0));
|
||||||
|
if (count($st) == 2) {
|
||||||
|
$bit = (int) ($st[0]);
|
||||||
|
if ($bit >= 0 && $bit <= 63 && ($st[1] == '0' || $st[1] == '1')) {
|
||||||
|
$from->appendChild($dom->createElement('status'))
|
||||||
|
->setAttribute('mask', $st[1] . str_repeat('x', $bit - 1));
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad (from) status '%s'", trim($sx->status0));
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad (from) status '%s'", trim($sx->status0));
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 'to' section
|
||||||
|
$to = $t->appendChild($dom->createElement('to'));
|
||||||
|
if ($sx->coll1) {
|
||||||
|
if (($coll1 = trim($sx->coll1)) != '') {
|
||||||
|
if (is_numeric($coll1)) {
|
||||||
|
$n = $to->appendChild($dom->createElement('coll'));
|
||||||
|
$n->setAttribute('id', $coll1);
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad (to) coll_id '%s'", $coll1);
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($sx->status1 && trim($sx->status1) != '') {
|
||||||
|
$st = explode('_', trim($sx->status1));
|
||||||
|
if (count($st) == 2) {
|
||||||
|
$bit = (int) ($st[0]);
|
||||||
|
if ($bit >= 0 && $bit <= 63 && ($st[1] == '0' || $st[1] == '1')) {
|
||||||
|
$to->appendChild($dom->createElement('status'))
|
||||||
|
->setAttribute('mask', $st[1] . str_repeat('x', $bit - 1));
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad (to) status '%s'", trim($sx->status1));
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad (to) status '%s'", trim($sx->status1));
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($active && $task['active'] == '1') {
|
||||||
|
$t->setAttribute('active', '1');
|
||||||
|
}
|
||||||
|
foreach ($warning as $w) {
|
||||||
|
$t->appendChild($dom->createComment($w));
|
||||||
|
}
|
||||||
|
|
||||||
|
$taskstodel[] = $task['task_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* migrating task 'task_period_ftv'
|
||||||
|
*/
|
||||||
|
if ($task['class'] === 'task_period_ftv') {
|
||||||
|
foreach ($sx->tasks->task as $sxt) {
|
||||||
|
$active = true;
|
||||||
|
$warning = array();
|
||||||
|
|
||||||
|
$t = $dom->importNode(dom_import_simplexml($sxt), true);
|
||||||
|
$t->setAttribute('active', '0');
|
||||||
|
// $t->setAttribute('name', 'imported from \'' . $task->getTitle() . '\'');
|
||||||
|
$t->setAttribute('name', 'imported from \'' . $task['name'] . '\'');
|
||||||
|
$t->setAttribute('action', 'update');
|
||||||
|
|
||||||
|
if ($sx->sbas_id) {
|
||||||
|
$sbas_id = trim($sx->sbas_id);
|
||||||
|
if ($sbas_id != '' && is_numeric($sbas_id)) {
|
||||||
|
$t->setAttribute('sbas_id', $sx->sbas_id);
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("Bad sbas_id '%s'", $sbas_id);
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$warning[] = sprintf("missing sbas_id");
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($active && $task['active'] == '1') {
|
||||||
|
$t->setAttribute('active', '1');
|
||||||
|
}
|
||||||
|
foreach ($warning as $w) {
|
||||||
|
$t->appendChild($dom->createComment($w));
|
||||||
|
}
|
||||||
|
|
||||||
|
$x = new DOMXPath($dom);
|
||||||
|
$nlfrom = $x->query('from', $t);
|
||||||
|
if ($nlfrom->length == 1) {
|
||||||
|
$nlcoll = $x->query('colls', $nlfrom->item(0));
|
||||||
|
if ($nlcoll->length > 0) {
|
||||||
|
$nn = $dom->createElement('coll');
|
||||||
|
$nn->setAttribute('compare', '=');
|
||||||
|
$nn->setAttribute('id', $nlcoll->item(0)->getAttribute('id'));
|
||||||
|
$nlfrom->item(0)->replaceChild($nn, $nlcoll->item(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
$tasks->appendChild($t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$taskstodel[] = $task['task_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($taskstodel) > 0) {
|
||||||
|
$conn->exec('DELETE FROM task2 WHERE task_id IN(' . implode(',', $taskstodel) . ')');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* save new tasks
|
||||||
|
*/
|
||||||
|
foreach ($tdom as $newtask) {
|
||||||
|
$task = task_abstract::create($appbox, 'task_period_workflow02', $newtask['dom']->saveXML());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user