mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Merge pull request #1095 from jygaulier/fix-phras-141
[3.8.6][PHRAS-141] Delete action is not taken into account for tasks
This commit is contained in:
@@ -366,7 +366,6 @@ class task_period_RecordMover extends task_appboxAbstract
|
||||
switch ($task['action']) {
|
||||
|
||||
case 'UPDATE':
|
||||
|
||||
// change collection ?
|
||||
if (($x = (int) ($sxtask->to->coll['id'])) > 0) {
|
||||
$tmp['coll'] = $x;
|
||||
@@ -531,6 +530,8 @@ class task_period_RecordMover extends task_appboxAbstract
|
||||
*/
|
||||
private function calcUPDATE($sbas_id, &$sxtask, $playTest)
|
||||
{
|
||||
$connbas = connection::getPDOConnection($this->dependencyContainer, $sbas_id);
|
||||
|
||||
$tws = array(); // NEGATION of updates, used to build the 'test' sql
|
||||
//
|
||||
// set coll_id ?
|
||||
@@ -542,35 +543,38 @@ class task_period_RecordMover extends task_appboxAbstract
|
||||
$x = $sxtask->to->status['mask'];
|
||||
$mx = str_replace(' ', '0', ltrim(str_replace(array('0', 'x'), array(' ', ' '), $x)));
|
||||
$ma = str_replace(' ', '0', ltrim(str_replace(array('x', '0'), array(' ', '1'), $x)));
|
||||
if ($mx && $ma)
|
||||
$tws[] = '((status ^ 0b' . $mx . ') & 0b' . $ma . ')!=0';
|
||||
elseif ($mx)
|
||||
$tws[] = '(status ^ 0b' . $mx . ')!=0';
|
||||
elseif ($ma)
|
||||
$tws[] = '(status & 0b' . $ma . ')!=0';
|
||||
if ($mx && $ma) {
|
||||
$tws[] = '((status ^ ' . $connbas->quote('0b'.$mx) . ') & ' . $connbas->quote('0b'.$ma) . ')!=0';
|
||||
}
|
||||
elseif ($mx) {
|
||||
$tws[] = '(status ^ ' . $connbas->quote('0b'.$mx) . ')!=0';
|
||||
}
|
||||
elseif ($ma) {
|
||||
$tws[] = '(status & ' . $connbas->quote('0b'.$ma) . ')!=0';
|
||||
}
|
||||
|
||||
// compute the 'where' clause
|
||||
list($tw, $join) = $this->calcWhere($sbas_id, $sxtask);
|
||||
|
||||
// ... complete the where to buid the TEST
|
||||
if (count($tws) == 1)
|
||||
if (count($tws) == 1) {
|
||||
$tw[] = $tws[0];
|
||||
elseif (count($tws) > 1)
|
||||
}
|
||||
elseif (count($tws) > 1) {
|
||||
$tw[] = '(' . implode(') OR (', $tws) . ')';
|
||||
if (count($tw) == 1)
|
||||
$where = $tw[0];
|
||||
if (count($tw) > 1)
|
||||
$where = '(' . implode(') AND (', $tw) . ')';
|
||||
}
|
||||
|
||||
// build the TEST sql (select)
|
||||
$sql_test = 'SELECT record_id FROM record' . $join;
|
||||
if (count($tw) > 0)
|
||||
if (count($tw) > 0) {
|
||||
$sql_test .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')');
|
||||
}
|
||||
|
||||
// build the real sql (select)
|
||||
$sql = 'SELECT record_id FROM record' . $join;
|
||||
if (count($tw) > 0)
|
||||
if (count($tw) > 0) {
|
||||
$sql .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')');
|
||||
}
|
||||
|
||||
$ret = array(
|
||||
'real' => array(
|
||||
@@ -606,15 +610,16 @@ class task_period_RecordMover extends task_appboxAbstract
|
||||
list($tw, $join) = $this->calcWhere($sbas_id, $sxtask);
|
||||
|
||||
// build the TEST sql (select)
|
||||
$sql_test = 'SELECT SQL_CALC_FOUND_ROWS record_id FROM record' . $join;
|
||||
if (count($tw) > 0)
|
||||
$sql_test = 'SELECT record_id FROM record' . $join;
|
||||
if (count($tw) > 0) {
|
||||
$sql_test .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')');
|
||||
$sql_test .= ' LIMIT 10';
|
||||
}
|
||||
|
||||
// build the real sql (select)
|
||||
$sql = 'SELECT record_id FROM record' . $join;
|
||||
if (count($tw) > 0)
|
||||
if (count($tw) > 0) {
|
||||
$sql .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')');
|
||||
}
|
||||
|
||||
$ret = array(
|
||||
'real' => array(
|
||||
@@ -671,8 +676,9 @@ class task_period_RecordMover extends task_appboxAbstract
|
||||
$ijoin++;
|
||||
$comp = strtoupper($x['compare']);
|
||||
if (in_array($comp, array('<', '>', '<=', '>=', '=', '!='))) {
|
||||
$s = 'p' . $ijoin . '.name=\'' . $x['field'] . '\' AND p' . $ijoin . '.value' . $comp;
|
||||
$s .= '' . $connbas->quote($x['value']) . '';
|
||||
$s = 'p' . $ijoin . '.name=' . $connbas->quote($x['field']) . ' AND p' . $ijoin . '.value' . $comp
|
||||
. '' . $connbas->quote($x['value']) . '';
|
||||
// $s = 'p' . $ijoin . '.name=? AND p' . $ijoin . '.value' . $comp . '?';
|
||||
|
||||
$tw[] = $s;
|
||||
$join .= ' INNER JOIN prop AS p' . $ijoin . ' USING(record_id)';
|
||||
@@ -687,12 +693,15 @@ class task_period_RecordMover extends task_appboxAbstract
|
||||
$s = 'p' . $ijoin . '.name=\'' . $x['field'] . '\' AND NOW()';
|
||||
$s .= strtoupper($x['direction']) == 'BEFORE' ? '<' : '>=';
|
||||
$delta = (int) ($x['delta']);
|
||||
if ($delta > 0)
|
||||
if ($delta > 0) {
|
||||
$s .= '(p' . $ijoin . '.value+INTERVAL ' . $delta . ' DAY)';
|
||||
elseif ($delta < 0)
|
||||
}
|
||||
elseif ($delta < 0) {
|
||||
$s .= '(p' . $ijoin . '.value-INTERVAL ' . -$delta . ' DAY)';
|
||||
else
|
||||
}
|
||||
else {
|
||||
$s .= 'p' . $ijoin . '.value';
|
||||
}
|
||||
|
||||
$tw[] = $s;
|
||||
$join .= ' INNER JOIN prop AS p' . $ijoin . ' USING(record_id)';
|
||||
@@ -725,18 +734,11 @@ class task_period_RecordMover extends task_appboxAbstract
|
||||
$mx = str_replace(' ', '0', ltrim(str_replace(array('0', 'x'), array(' ', ' '), $x)));
|
||||
$ma = str_replace(' ', '0', ltrim(str_replace(array('x', '0'), array(' ', '1'), $x)));
|
||||
if ($mx && $ma) {
|
||||
$tw[] = '((status^0b' . $mx . ')&0b' . $ma . ')=0';
|
||||
$tw[] = '((status ^ ' . $connbas->quote('0b'.$mx) . ') & ' . $connbas->quote('0b'.$ma) . ')=0';
|
||||
} elseif ($mx) {
|
||||
$tw[] = '(status^0b' . $mx . ')=0';
|
||||
$tw[] = '(status ^ ' . $connbas->quote('0b'.$mx) . ')=0';
|
||||
} elseif ($ma) {
|
||||
$tw[] = '(status&0b' . $ma . ")=0";
|
||||
}
|
||||
|
||||
if (count($tw) == 1) {
|
||||
$where = $tw[0];
|
||||
}
|
||||
if (count($tw) > 1) {
|
||||
$where = '(' . implode(') AND (', $tw) . ')';
|
||||
$tw[] = '(status & ' . $connbas->quote('0b'.$ma) . ")=0";
|
||||
}
|
||||
|
||||
return array($tw, $join);
|
||||
|
Reference in New Issue
Block a user