after user deletion, 13 pending user records remain in today table; to purge those records I've introduced quick fix in deleteObject.php:
/** ===========================================================================
* Delete the current object : call corresponding method in SqlElement Class
*/
require_once "../tool/projeqtor.php";
// Get the object class from request
if (! array_key_exists('objectClassName',$_REQUEST)) {
throwError('className parameter not found in REQUEST');
}
$className=$_REQUEST['objectClassName'];
if ($className=='Project') {
Project::$_deleteProjectInProgress=true;
}
$objectId = RequestHandler::getId('objectId');
// Get the object from session(last status before change)
$fromContextMenu = RequestHandler::getBoolean('fromContextMenu');
if($fromContextMenu){
$obj=new $className($objectId);
}else{
$obj=SqlElement::getCurrentObject(null,null,true,false);
}
if (! is_object($obj)) {
throwError('last saved object is not a real object');
}
// compare expected class with object class
if ($className!=get_class($obj)) {
throwError('last save object (' . get_class($obj) . ') is not of the expected class (' . $className . ').');
}
if (array_key_exists('confirmed',$_REQUEST) ) {
if ($_REQUEST['confirmed']=='true') {
SqlElement::setDeleteConfirmed();
}
}
Sql::beginTransaction();
$obj=new $className($obj->id); // Get the last saved version, to fetch last version for array of objects
$peName=$className.'PlanningElement';
$topItemType=null;
$topItemId=null;
// delete from database
if (property_exists($obj,$peName)) {
PlanningElement::$_noDispatch=true;
$topItemType=$obj->$peName->topRefType;
$topItemId=$obj->$peName->topRefId;
}
$deleteObjectInProgress=true;
$result=$obj->delete();
$resultStatus=getLastOperationStatus($result);
if ($resultStatus=='OK' and $topItemType and $topItemId) {
PlanningElement::$_noDispatch=false;
PlanningElement::updateSynthesis($topItemType, $topItemId);
$pe=SqlElement::getSingleSqlElementFromCriteria('PlanningElement', array('refType'=>$topItemType,'refId'=>$topItemId));
$pe->renumberWbs();
}
BudgetElement::dispatchFinalize();
//mk add
if ($className=='User') {
$idUser=$_REQUEST['id'];
$tod=new Today();
$crit= array('idUser'=>$idUser);
$rec=$tod->getSqlElementsFromCriteria($crit);
foreach ($rec as $uid) {
$uid->delete();
}
}
//end mk add
// Message of correct saving
if ($resultStatus=="ERROR") {
Sql::rollbackTransaction();
echo '
';
} else if ($resultStatus=="OK" ) {
Sql::commitTransaction();
echo '
';
SqlElement::unsetCurrentObject();
} else if ($resultStatus=="INVALID") {
Sql::rollbackTransaction();
echo '
';
} else {
Sql::commitTransaction();
echo '
';
}
echo '';
Great idea.
Maybe could be improved as deleting a resource or a contact will also delete the user...
We'll improve this.