Merged in norah/processmaker/BUG-12021 (pull request #872)

Corrections Audit Log
This commit is contained in:
Julio Cesar Laura Avendaño
2014-10-08 15:36:40 -04:00
40 changed files with 855 additions and 20 deletions

View File

@@ -631,6 +631,27 @@ function fieldSave()
$conf->saveObject($result, "casesList", $action, "", "", "");
$msgLog = '';
if($action == 'todo') {
$list = 'Inbox';
} elseif ($action == 'sent') {
$list = 'Participated';
} else {
$list = ucwords($action);
}
for ($i=4; $i<count( $arrayNewSecond ); $i++) {
if ($i == count( $arrayNewSecond )-1) {
$msgLog .= $arrayNewSecond[$i]['label'];
} else {
$msgLog .= $arrayNewSecond[$i]['label'].'-';
}
}
G::auditLog("Set ".$list." List Columns", $msgLog);
echo G::json_encode($result);
}

View File

@@ -224,6 +224,8 @@ switch ($_POST['action']) {
$dep_uid = $_REQUEST['uid'];
$dep_manager = $_REQUEST['manager'];
$dep_status = $_REQUEST['status'];
$dep_parent = $_REQUEST['parent'];
$editDepartment['DEP_PARENT'] = $dep_parent;
$editDepartment['DEP_UID'] = $dep_uid;
$editDepartment['DEPO_TITLE'] = $dep_name;
$editDepartment['DEP_STATUS'] = $dep_status;
@@ -231,6 +233,13 @@ switch ($_POST['action']) {
$oDept = new Department();
$oDept->update( $editDepartment );
$oDept->updateDepartmentManager( $dep_uid );
if ($dep_parent == '') {
G::auditLog("UpdateDepartament", $dep_name." (".$dep_uid.") ");
} else {
G::auditLog("UpdateSubDepartament", $dep_name." (".$dep_uid.") ");
}
echo '{success: true}';
} catch (exception $e) {
echo '{success: false}';

View File

@@ -177,6 +177,13 @@ try {
}
$result["success"] = $addon->setEnabled(($action == "enable"));
if ($action == "enable") {
G::auditLog("EnablePlugin", $_REQUEST['addon']);
} else {
G::auditLog("DisablePlugin", $_REQUEST['addon']);
}
break;
case "install":
$status = 1;

View File

@@ -270,6 +270,7 @@ switch ($option) {
if ($result["status"] == "OK") {
$response["status"] = $result["status"]; //OK
$response["message"] = $result["message"];
G::auditLog("InstallPlugin", $file);
} else {
throw (new Exception($result["message"]));
}

View File

@@ -149,7 +149,10 @@ switch ($_POST['action']) {
unset( $newGroup['GRP_UID'] );
$group = new Groupwf();
$group->create( $newGroup );
G::auditLog("CreateGroup", $newGroup['GRP_TITLE']);
echo '{success: true}';
break;
case 'saveEditGroup':
G::LoadClass( 'groups' );
@@ -158,6 +161,7 @@ switch ($_POST['action']) {
$editGroup['GRP_TITLE'] = trim( $_POST['name'] );
$group = new Groupwf();
$group->update( $editGroup );
G::auditLog("UpdateGroup", $editGroup['GRP_TITLE']." (".$_POST['grp_uid'].") ");
echo '{success: true}';
break;
case 'deleteGroup':
@@ -167,6 +171,7 @@ switch ($_POST['action']) {
return;
}
$group->remove( urldecode( $_POST['GRP_UID'] ) );
G::auditLog("DeleteGroup", $_POST['GRP_NAME']." (".$_POST['GRP_UID'].") ");
require_once 'classes/model/TaskUser.php';
$oProcess = new TaskUser();
$oCriteria = new Criteria( 'workflow' );

View File

@@ -104,6 +104,7 @@ if (isset( $_REQUEST['action'] )) {
$pcat->setCategoryUid( G::GenerateUniqueID() );
$pcat->setCategoryName( $catName );
$pcat->save();
G::auditLog("CreateCategory", $catName);
echo '{success: true}';
} catch (Exception $ex) {
echo '{success: false, error: ' . $ex->getMessage() . '}';
@@ -134,6 +135,7 @@ if (isset( $_REQUEST['action'] )) {
$pcat->setCategoryUid( $catUID );
$pcat->setCategoryName( $catName );
$pcat->save();
g::auditLog("UpdateCategory", $catName." (".$catUID.") ");
echo '{success: true}';
} catch (Exception $ex) {
echo '{success: false, error: ' . $ex->getMessage() . '}';
@@ -153,7 +155,9 @@ if (isset( $_REQUEST['action'] )) {
$catUID = $_REQUEST['cat_uid'];
$cat = new ProcessCategory();
$cat->setCategoryUid( $catUID );
$catName = $cat->loadByCategoryId( $catUID );
$cat->delete();
G::auditLog("DeleteCategory", $catName." (".$catUID.") ");
echo '{success: true}';
} catch (Exception $ex) {
echo '{success: false, error: ' . $ex->getMessage() . '}';

View File

@@ -260,7 +260,7 @@ switch ($request) {
$result = new StdClass();
$result->success = true;
$result->msg = G::LoadTranslation('ID_TITLE_COMPLETED');
G::auditLog("BuildCache");
echo G::json_encode( $result );
} catch (Exception $e) {

View File

@@ -0,0 +1,18 @@
<?php
global $RBAC;
if ($RBAC->userCanAccess("PM_SETUP") != 1) {
G::SendTemporalMessage("ID_USER_HAVENT_RIGHTS_PAGE", "error", "labels");
exit(0);
}
$c = new Configurations();
$configPage = $c->getConfiguration( "auditLogList", "pageSize", null, $_SESSION["USER_LOGGED"] );
$config = array ();
$config["pageSize"] = (isset( $configPage["pageSize"] )) ? $configPage["pageSize"] : 20;
$oHeadPublisher = &headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript( "setup/auditLog", true );
$oHeadPublisher->assign( "CONFIG", $config );
G::RenderPage( "publish", "extJs" );

View File

@@ -0,0 +1,141 @@
<?php
function mktimeDate ($date)
{
$arrayAux = getdate( strtotime( $date ) );
$mktDate = mktime( $arrayAux["hours"], $arrayAux["minutes"], $arrayAux["seconds"], $arrayAux["mon"], $arrayAux["mday"], $arrayAux["year"] );
return $mktDate;
}
function auditLogArraySet ($str, $filter)
{
$arrayAux = explode( "|", $str );
$date = "";
$workspace = "";
$action = "";
$user = "";
$description = "";
if (count( $arrayAux ) > 1) {
$date = (isset( $arrayAux[0] )) ? trim( $arrayAux[0] ) : "";
$workspace = (isset( $arrayAux[1] )) ? trim( $arrayAux[1] ) : "";
$ip = (isset( $arrayAux[2] )) ? trim( $arrayAux[2] ) : "";
$user = (isset( $arrayAux[4] )) ? trim( $arrayAux[4] ) : "";
$action = (isset( $arrayAux[5] )) ? trim( $arrayAux[5] ) : "";
$description = (isset( $arrayAux[6] )) ? trim( $arrayAux[6] ) : "";
}
$mktDate = (! empty( $date )) ? mktimeDate( $date ) : 0;
//Filter
$sw = 1;
if ($workspace != $filter["workspace"]) {
$sw = 0;
}
if ($filter["dateFrom"] && $mktDate > 0) {
if (! (mktimeDate( $filter["dateFrom"] ) <= $mktDate)) {
$sw = 0;
}
}
if ($filter["dateTo"] && $mktDate > 0) {
if (! ($mktDate <= mktimeDate( $filter["dateTo"] . " 23:59:59" ))) {
$sw = 0;
}
}
if ($filter["description"]) {
$sw = 0;
$string = $filter["description"];
if ( (stristr($date, $string) !== false) || (stristr($ip, $string) !== false) || (stristr($user, $string) !== false) || (stristr($action, $string) !== false) || (stristr($description, $string) !== false) ) {
$sw = 1;
}
}
$arrayData = array ();
if ($sw == 1) {
$arrayData = array ("DATE" => $date, "USER" => $user, "IP" =>$ip, "ACTION" => $action, "DESCRIPTION" => $description);
}
return $arrayData;
}
function getAuditLogData ($filter, $r, $i)
{
$arrayData = array ();
$strAux = null;
$count = 0;
$file = PATH_DATA . "log" . PATH_SEP . "audit.log";
if (file_exists($file)) {
$arrayFileData = file($file);
for ($k = 0; $k < count($arrayFileData); $k++) {
$strAux = $arrayFileData[$k];
if ($strAux) {
$arrayAux = auditLogArraySet($strAux, $filter);
if (count($arrayAux) > 0) {
$count = $count + 1;
if ($count > $i && count($arrayData) < $r) {
$arrayData[] = $arrayAux;
}
}
}
}
}
return array($count, $arrayData);
}
$option = (isset( $_REQUEST["option"] )) ? $_REQUEST["option"] : null;
$response = array ();
switch ($option) {
case "LST":
$pageSize = $_REQUEST["pageSize"];
$workspace = SYS_SYS;
$description = $_REQUEST["description"];
$dateFrom = $_REQUEST["dateFrom"];
$dateTo = $_REQUEST["dateTo"];
$arrayFilter = array ("workspace" => $workspace,"description" => $description,"dateFrom" => str_replace( "T00:00:00", null, $dateFrom ),"dateTo" => str_replace( "T00:00:00", null, $dateTo )
);
$limit = isset( $_REQUEST["limit"] ) ? $_REQUEST["limit"] : $pageSize;
$start = isset( $_REQUEST["start"] ) ? $_REQUEST["start"] : 0;
list ($count, $data) = getAuditLogData( $arrayFilter, $limit, $start );
$response = array ("success" => true,"resultTotal" => $count,"resultRoot" => $data
);
break;
case "EMPTY":
$status = 1;
try {
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
if (file_exists( $file )) {
unlink( $file );
}
$response["status"] = "OK";
} catch (Exception $e) {
$response["message"] = $e->getMessage();
$status = 0;
}
if ($status == 0) {
$response["status"] = "ERROR";
}
break;
}
echo G::json_encode( $response );

View File

@@ -0,0 +1,16 @@
<?php
global $RBAC;
$RBAC->requirePermissions( 'PM_SETUP' );
$oHeadPublisher = & headPublisher::getSingleton();
G::LoadClass( 'serverConfiguration' );
$oServerConf = & serverConf::getSingleton();
$sflag = $oServerConf->getAuditLogProperty( 'AL_OPTION', SYS_SYS );
$auditLogChecked = $sflag == 1 ? true : false;
$oHeadPublisher->addExtJsScript( 'setup/auditLogConfig', true ); //adding a javascript file .js
$oHeadPublisher->assign( 'auditLogChecked', $auditLogChecked );
G::RenderPage( 'publish', 'extJs' );

View File

@@ -0,0 +1,33 @@
<?php
global $G_TMP_MENU;
switch ($_GET['action']) {
case 'saveOption':
try {
G::LoadClass( 'serverConfiguration' );
$oServerConf = & serverConf::getSingleton();
/*you can use SYS_TEMP or SYS_SYS ON AUDIT_LOG_CONF to save for each workspace*/
$oServerConf->unsetAuditLogProperty( 'AL_TYPE', SYS_SYS );
if (isset( $_POST['acceptAL'] )) {
$oServerConf->setAuditLogProperty( 'AL_OPTION', 1, SYS_SYS );
$oServerConf->unsetAuditLogProperty( 'AL_NEXT_DATE', SYS_SYS );
$response->enable = true;
G::auditLog("Enable AuditLog");
} else {
$oServerConf->setAuditLogProperty( 'AL_OPTION', 0, SYS_SYS );
$oServerConf->unsetAuditLogProperty( 'AL_NEXT_DATE', SYS_SYS );
$oServerConf->setAuditLogProperty( 'AL_TYPE', 'endaudit', SYS_SYS );
$response->enable = false;
G::auditLog("Disable AuditLog");
}
$response->success = true;
} catch (Exception $e) {
$response->success = false;
$response->msg = $e->getMessage();
}
echo G::json_encode( $response );
break;
}

View File

@@ -3,22 +3,28 @@ try {
$response = new stdClass;
if (isset( $_POST['javascriptCache'] ) || isset( $_POST['metadataCache'] ) || isset( $_POST['htmlCache'] )) {
$msgLog = '';
if (isset( $_POST['javascriptCache'] )) {
G::rm_dir( PATH_C . 'ExtJs' );
$response->javascript = true;
$msgLog .= 'Javascript cache ';
}
if (isset( $_POST['metadataCache'] )) {
G::rm_dir( PATH_C . 'xmlform' );
$response->xmlform = true;
$msgLog .= 'Forms Metadata cache ';
}
if (isset( $_POST['htmlCache'] )) {
G::rm_dir( PATH_C . 'smarty' );
$response->smarty = true;
$msgLog .= 'Forms Html Templates cache ';
}
$response->success = true;
G::auditLog("ClearCache", $msgLog);
} else {
$response->success = false;
}

View File

@@ -144,6 +144,7 @@ switch ($option) {
}
$response["status"] = "OK";
G::auditLog("Cron", "ClearCron");
} catch (Exception $e) {
$response["message"] = $e->getMessage();
$status = 0;

View File

@@ -46,6 +46,8 @@ switch ($request) {
$conf->aConfig = $config;
$conf->saveConfig( "ENVIRONMENT_SETTINGS", "" );
G::auditLog("UpdateEnvironmentSettings", "UserNameDisplayFormat -> ".$_POST["userFormat"]." GlobalDateFormat -> ".$_POST["dateFormat"]." HideProcessInformation -> ".$_POST["hideProcessInf"]." DateFormat -> ".$_POST["casesListDateFormat"]." NumberOfRowsPerPage -> ".$_POST["casesListRowNumber"]." RefreshTimeSeconds -> ".$_POST["txtCasesRefreshTime"]);
$response = new stdclass();
$response->success = true;
$response->msg = G::LoadTranslation( "ID_SAVED_SUCCESSFULLY" );

View File

@@ -30,10 +30,13 @@ switch ($request) {
$conf->saveConfig( 'ENVIRONMENT_SETTINGS', '' );
$lang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : 'en';
//remove from memcache when this value is updated/created
$memcache->delete( 'flagForgotPassword' );
$response->success = true;
G::auditLog("UpdateLoginSettings", "DefaultLanguage->".$lang." EnableForgotPassword->".$_REQUEST['forgotPasswd']);
echo G::json_encode( $response );
break;

View File

@@ -12,11 +12,13 @@ switch ($_GET['action']) {
$oServerConf->setHeartbeatProperty( 'HB_OPTION', 1, 'HEART_BEAT_CONF' );
$oServerConf->unsetHeartbeatProperty( 'HB_NEXT_BEAT_DATE', 'HEART_BEAT_CONF' );
$response->enable = true;
G::auditLog("EnableHeartBeat");
} else {
$oServerConf->setHeartbeatProperty( 'HB_OPTION', 0, 'HEART_BEAT_CONF' );
$oServerConf->unsetHeartbeatProperty( 'HB_NEXT_BEAT_DATE', 'HEART_BEAT_CONF' );
$oServerConf->setHeartbeatProperty( 'HB_BEAT_TYPE', 'endbeat', 'HEART_BEAT_CONF' );
$response->enable = false;
G::auditLog("DisableHeartBeat");
}
$response->success = true;

View File

@@ -170,6 +170,7 @@ function newSkin ($baseSkin = 'classic')
file_put_contents( $configFileFinal, $xmlConfiguration );
$response['success'] = true;
$response['message'] = G::LoadTranslation( 'ID_SKIN_SUCCESS_CREATE' );
G::auditLog("CreateSkin", $skinName);
print_r( G::json_encode( $response ) );
} catch (Exception $e) {
$response['success'] = false;
@@ -285,6 +286,7 @@ function importSkin ()
$response['success'] = true;
$response['message'] = G::LoadTranslation( 'ID_SKIN_SUCCESSFUL_IMPORTED' );
G::auditLog("ImportSkin", $skinName);
print_r( G::json_encode( $response ) );
} catch (Exception $e) {
$response['success'] = false;
@@ -329,7 +331,7 @@ function exportSkin ($skinToExport = "")
$response['success'] = true;
$response['message'] = $skinTar;
G::auditLog("ExportSkin", $skinName);
print_r( G::json_encode( $response ) );
} catch (Exception $e) {
$response['success'] = false;
@@ -355,6 +357,7 @@ function deleteSkin ()
G::rm_dir( PATH_CUSTOM_SKINS . $folderId );
$response['success'] = true;
$response['message'] = "$folderId deleted";
G::auditLog("DeleteSkin", $folderId);
} catch (Exception $e) {
$response['success'] = false;
$response['error'] = $response['message'] = $e->getMessage();

View File

@@ -187,6 +187,7 @@ switch ($_POST['action']) {
require_once 'classes/model/Users.php';
$oUser = new Users();
$oUser->create($aData);
G::auditLog("CreateUser", $aData['USR_USERNAME']);
if ($_FILES['USR_PHOTO']['error'] != 1) {
//print (PATH_IMAGES_ENVIRONMENT_USERS);
@@ -363,6 +364,7 @@ switch ($_POST['action']) {
require_once 'classes/model/Users.php';
$oUser = new Users();
$oUser->update($aData);
G::auditLog("UpdateUser", $aData['USR_USERNAME']." (".$aData['USR_UID'].") ");
if ($_FILES['USR_PHOTO']['error'] != 1) {
if ($_FILES['USR_PHOTO']['tmp_name'] != '') {
$aAux = explode('.', $_FILES['USR_PHOTO']['name']);

View File

@@ -201,6 +201,7 @@ try {
$oUser = new Users();
$aFields = $oUser->load($UID);
$aFields['USR_STATUS'] = 'CLOSED';
$userName = $aFields['USR_USERNAME'];
$aFields['USR_USERNAME'] = '';
$oUser->update($aFields);
@@ -216,8 +217,8 @@ try {
$criteria->add(ProcessUserPeer::USR_UID, $UID, Criteria::EQUAL);
$criteria->add(ProcessUserPeer::PU_TYPE, "SUPERVISOR", Criteria::EQUAL);
ProcessUserPeer::doDelete($criteria);
G::auditLog("DeleteUser", $userName." (".$UID.") ");
break;
case 'changeUserStatus':
$response = new stdclass();
@@ -228,6 +229,9 @@ try {
$userData = $userInstance->load($_REQUEST['USR_UID']);
$userData['USR_STATUS'] = $_REQUEST['NEW_USR_STATUS'];
$userInstance->update($userData);
$msg = $_REQUEST['NEW_USR_STATUS'] == 'ACTIVE'? "Enable User" : "Disable User";
G::auditLog($msg, $userData['USR_USERNAME']." (".$userData['USR_UID'].") ");
$response->status = 'OK';
} else {
$response->status = 'ERROR';
@@ -353,6 +357,7 @@ try {
}
$aData['USR_AUTH_USER_DN'] = $auth_dn;
$RBAC->updateUser($aData);
g::auditLog("AssignAuthenticationSource", $aData['USR_USERNAME'].' ('.$aData['USR_UID'].') assign to '.$aData['USR_AUTH_TYPE']);
echo '{success: true}';
break;
case 'usersList':