Merged in mcuiza/processmaker/PM-4435 (pull request #3393)

PM-4435
This commit is contained in:
Julio Cesar Laura Avendaño
2015-12-14 15:53:11 -04:00

View File

@@ -49,17 +49,19 @@ class ListParticipatedLast extends BaseListParticipatedLast
$data['DEL_CURRENT_USR_USERNAME'] = $aRow['USR_USERNAME'];
$data['DEL_CURRENT_USR_FIRSTNAME'] = $aRow['USR_FIRSTNAME'];
$data['DEL_CURRENT_USR_LASTNAME'] = $aRow['USR_LASTNAME'];
}
} else {
$data['USR_UID'] = $_SESSION['USER_LOGGED'];
$row = $this->getRowFromList($data);
if(is_array($row) && sizeof($row)) {
$this->remove($row['APP_UID'], $row['USR_UID'], $row['DEL_INDEX'], true);
}
}
$users = new Users();
$users->refreshTotal($data['USR_UID'], 'add', 'participated');
}
} else {
$getData['USR_UID'] = $_SESSION['USER_LOGGED'];
$getData['APP_UID'] = $data['APP_UID'];
$row = $this->getRowFromList($getData);
if(is_array($row) && sizeof($row)) {
$set = array("DEL_CURRENT_USR_USERNAME" => "","DEL_CURRENT_USR_FIRSTNAME" => "","DEL_CURRENT_USR_LASTNAME" => "","APP_TAS_TITLE" => $data['APP_TAS_TITLE']);
$this->updateCurrentUser($row, $set);
}
}
if($this->primaryKeysExists($data)) {
return;
@@ -159,7 +161,7 @@ class ListParticipatedLast extends BaseListParticipatedLast
* @throws type
*
*/
public function remove ($app_uid, $usr_uid, $del_index, $force = false)
public function remove ($app_uid, $usr_uid, $del_index)
{
try {
$flagDelete = false;
@@ -171,25 +173,20 @@ class ListParticipatedLast extends BaseListParticipatedLast
$criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid);
$criteria->add(ListParticipatedLastPeer::DEL_INDEX, $del_index);
if(!$this->isTheOne($app_uid, $usr_uid) || $force) {
$result = ListParticipatedLastPeer::doDelete($criteria);
$flagDelete = true;
}
} else {
$criteria = new Criteria("workflow");
$criteria->add(ListParticipatedLastPeer::APP_UID, $app_uid);
$criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid);
$rsCriteria = ListParticipatedLastPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
$criteria2 = clone $criteria;
if(!$this->isTheOne($app_uid, $usr_uid) || $force) {
$result = ListParticipatedLastPeer::doDelete($criteria2);
$flagDelete = true;
}
}
}
if ($flagDelete) {
$user = new Users();
@@ -383,15 +380,20 @@ class ListParticipatedLast extends BaseListParticipatedLast
return false;
}
public function isTheOne($app_uid, $usr_uid) {
$criteria = new Criteria("workflow");
$criteria->add(ListParticipatedLastPeer::APP_UID, $app_uid);
$criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid);
$rsCriteria = ListParticipatedLastPeer::doCount($criteria);
if ($rsCriteria == 1) {
return true;
public function updateCurrentUser($where, $set)
{
$con = Propel::getConnection('workflow');
//Update - WHERE
$criteriaWhere = new Criteria("workflow");
$criteriaWhere->add(ListParticipatedLastPeer::APP_UID, $where["APP_UID"], Criteria::EQUAL);
$criteriaWhere->add(ListParticipatedLastPeer::USR_UID, $where["USR_UID"], Criteria::EQUAL);
$criteriaWhere->add(ListParticipatedLastPeer::DEL_INDEX, $where["DEL_INDEX"], Criteria::EQUAL);
//Update - SET
$criteriaSet = new Criteria("workflow");
foreach($set as $k => $v) {
eval('$criteriaSet->add( ListParticipatedLastPeer::'.$k.',$v, Criteria::EQUAL);');
}
return false;
BasePeer::doUpdate($criteriaWhere, $criteriaSet, $con);
}
}