2013-06-05 10:08:40 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
G::LoadClass("Task");
|
|
|
|
|
G::LoadClass("TaskUser");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* class, helping to set some not desirable settings but necesary
|
|
|
|
|
* @author reav
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2013-06-05 16:23:39 -04:00
|
|
|
abstract class patch
|
|
|
|
|
{
|
|
|
|
|
static protected $isPathchable = false;
|
2014-09-09 14:17:08 -04:00
|
|
|
static public $dbAdapter = 'mysql';
|
2013-06-05 16:23:39 -04:00
|
|
|
abstract static public function isApplicable();
|
|
|
|
|
abstract static public function execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class p11835 extends patch
|
2013-06-05 10:08:40 -04:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* Note.- Use before upgrade DB.
|
|
|
|
|
* Check if the table TASK has the field TAS_GROUP_VARIABLE
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2013-06-05 16:23:39 -04:00
|
|
|
static public function isApplicable()
|
2013-06-05 10:08:40 -04:00
|
|
|
{
|
2014-01-15 12:16:46 -04:00
|
|
|
if (! class_exists('System')) {
|
|
|
|
|
G::LoadClass("System");
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-05 10:08:40 -04:00
|
|
|
patch::$isPathchable = false;
|
|
|
|
|
$con = Propel::getConnection("workflow");
|
|
|
|
|
$stmt = $con->prepareStatement("describe TASK;");
|
|
|
|
|
$rs = $stmt->executeQuery();
|
|
|
|
|
$rs->next();
|
|
|
|
|
while($row = $rs->getRow()) {
|
2013-06-05 11:04:13 -04:00
|
|
|
if ($row ['Field'] == "TAS_GROUP_VARIABLE") {
|
|
|
|
|
$version = System::getVersion ();
|
2013-06-05 12:23:48 -04:00
|
|
|
$version = explode('-',$version);
|
|
|
|
|
if ($version[0] == '2.5.1') {
|
|
|
|
|
echo "Version " . $version[0] . " Patch\n";
|
2013-06-05 11:04:13 -04:00
|
|
|
patch::$isPathchable = true;
|
|
|
|
|
}
|
2013-06-05 10:08:40 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$rs->next();
|
|
|
|
|
}
|
|
|
|
|
return patch::$isPathchable;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 10:07:28 -04:00
|
|
|
public static function pmVersion($version)
|
|
|
|
|
{
|
|
|
|
|
if (preg_match("/^\D*([\d\.]+)\D*$/", $version, $matches)) {
|
|
|
|
|
$version = $matches[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $version;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-05 10:08:40 -04:00
|
|
|
/*
|
|
|
|
|
* Note.- Use after DB was upgraded.
|
|
|
|
|
* Set the patch, setting all the TAS_GROUP_VARIABLE to ''
|
|
|
|
|
* if the current task has asignated users, means SELF_SERVICE only,
|
|
|
|
|
* otherwise leave TAS_GROUP_VARIABLE as it is.
|
|
|
|
|
*/
|
2013-06-05 16:23:39 -04:00
|
|
|
static public function execute()
|
2013-06-05 10:08:40 -04:00
|
|
|
{
|
|
|
|
|
//Check if this is the version to apply the patch
|
|
|
|
|
$count = 0;
|
|
|
|
|
$task = new Task();
|
|
|
|
|
if ( patch::$isPathchable && method_exists($task,'getTasGroupVariable')) {
|
|
|
|
|
$con = Propel::getConnection("workflow");
|
2013-06-05 12:23:48 -04:00
|
|
|
$stmt = $con->prepareStatement("select TAS_UID from TASK where TAS_ASSIGN_TYPE = 'SELF_SERVICE';");
|
2013-06-05 10:08:40 -04:00
|
|
|
$recordSet = $stmt->executeQuery();
|
|
|
|
|
$recordSet->next();
|
|
|
|
|
$aRow = $recordSet->getRow();
|
|
|
|
|
while ($aRow) {
|
|
|
|
|
$tasUid = $aRow['TAS_UID'];
|
|
|
|
|
$conUser = Propel::getConnection("workflow");
|
|
|
|
|
$stmtUser = $conUser->prepareStatement("select * from TASK_USER where TAS_UID = '".$tasUid."';");
|
|
|
|
|
$recordSetTaskUser = $stmtUser->executeQuery();
|
|
|
|
|
if ($recordSetTaskUser->next()) {
|
|
|
|
|
echo "Patching uid: " . $tasUid . "\n";
|
|
|
|
|
//Set the values if they match the pattern
|
|
|
|
|
$conChange = Propel::getConnection("workflow");
|
2013-06-05 11:04:13 -04:00
|
|
|
$stmtChange = $conChange->prepareStatement("update TASK set TAS_GROUP_VARIABLE = '' where TAS_UID = '".$tasUid."';");
|
2013-06-05 10:08:40 -04:00
|
|
|
$recordResult = $stmtChange->executeQuery();
|
|
|
|
|
$count++;
|
|
|
|
|
}
|
|
|
|
|
$recordSet->next();
|
|
|
|
|
$aRow = $recordSet->getRow();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-08-12 10:07:28 -04:00
|
|
|
|
|
|
|
|
//Fix BUG-15394
|
2014-08-13 11:56:00 -04:00
|
|
|
|
2014-08-12 10:07:28 -04:00
|
|
|
G::LoadClass("configuration");
|
2014-08-13 11:19:00 -04:00
|
|
|
|
2014-08-12 10:07:28 -04:00
|
|
|
$conf = new Configurations();
|
|
|
|
|
|
|
|
|
|
if (!$conf->exists("HOTFIX")) {
|
|
|
|
|
//HOTFIX, Create empty record
|
|
|
|
|
$conf->aConfig = array();
|
|
|
|
|
$conf->saveConfig("HOTFIX", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$arrayHotfix = $conf->getConfiguration("HOTFIX", "");
|
|
|
|
|
$arrayHotfix = (is_array($arrayHotfix))? $arrayHotfix : array($arrayHotfix);
|
|
|
|
|
|
|
|
|
|
$pmVersion = self::pmVersion(System::getVersion()) . "";
|
|
|
|
|
|
2014-08-13 11:19:00 -04:00
|
|
|
if (($pmVersion == "2.5.2.4" || $pmVersion == "2.8") && !in_array("15394", $arrayHotfix)) {
|
2014-08-12 10:07:28 -04:00
|
|
|
$cnn = Propel::getConnection("workflow");
|
|
|
|
|
$stmt = $cnn->prepareStatement("UPDATE USERS_PROPERTIES SET USR_LOGGED_NEXT_TIME = 0");
|
|
|
|
|
$rs = $stmt->executeQuery();
|
|
|
|
|
|
|
|
|
|
//HOTFIX, Update record (add 15394)
|
|
|
|
|
$arrayHotfix[] = "15394";
|
|
|
|
|
|
|
|
|
|
$conf->aConfig = $arrayHotfix;
|
|
|
|
|
$conf->saveConfig("HOTFIX", "");
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-13 11:56:00 -04:00
|
|
|
//echo
|
2014-08-12 10:07:28 -04:00
|
|
|
echo $count . " records where patched to use SELF_SERVICE feature.\n";
|
2013-06-05 10:08:40 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|