It is easy to check whether the user who starts a case is one of three users by looking at the @@USER_LOGGED system variable in a trigger:
Code: Select allfunction checkIfLogged() {
$aLoggedUsers = array(); //array of logged-in users from group, which is returned
$aMembers = PMFGetGroupUsers( PMFGetGroupUID("Users Logged for Task1") );
if (empty($aMembers)) {
return array();
}
$aMemberIDs = array()
foreach ($aMembers as $aMember) {
$aMemberIDs = $aMember['USR_UID'];
}
if (in_array(@@USER_LOGGED, $aMemberIDs)) {
return = array(@@USER_LOGGED);
}
}
//skip first task in process if at least one member of the "Users Logged for Task1" group isn't logged in:
if (count(checkIfLogged() == 0) {
@@nextAssignedUser == @@USER_LOGGED;
PMFDerivateCase(@@APPLICATION, @%INDEX, @@USER_LOGGED);
}
Set this trigger to fire before the first step in the first task of the process.
However, it is much harder to check if any of three users are logged into PM (but don't have to be the person starting the case).
Login sessions in PM are managed by PHP and they expire when the $_SESSION superglobal variable becomes empty. For security reasons, PHP doesn't allow you know which other users are logged in.
You can query the LOGIN_LOG.LOG_INIT_DATE in the database, which will tell you when users logged-in, but there is no reliable way to know whether their login sessions have expired or not. When the user clicks on the "Logout" link in PM, that datetime will be registered in the LOG_END_DATE field, but nothing is written to the database when a login session expires after 24 minutes of inactivity (that time can be configured under
Admin > System, "Cookie lifetime").
Here is the best that you can do:
Create a group named "Users Logged for Task1" and add users to it.
Then, use this trigger code:
Code: Select allfunction checkIfLogged() {
$aLoggedUsers = array(); //array of logged-in users from group, which is returned
$aMembers = PMFGetGroupUsers( PMFGetGroupUID("Users Logged for Task1") );
if (empty($aMembers)) {
return array();
}
$aMemberIDs = array()
foreach ($aMembers as $aMember) {
$aMemberIDs = $aMember['USR_UID'];
}
if (in_array(@@USER_LOGGED, $aMemberIDs)) {
$aLoggedUsers[] = @@USER_LOGGED;
}
//check if any of the members of the group have a login in the last 24 minutes:
$sMemberIDs = "'" . implode("','" $aMemberIDs) . "'";
$time24mAgo = date('Y-m-d H:i:s', strtotime('-24 minutes'));
$sql = "SELECT USR_UID FROM LOGIN_LOG WHERE LOG_INIT_DATE >= '$time24mAgo' AND
LOG_END_DATE IS NULL AND USR_UID IN ($sMemberIDs)";
$aLogins = executeQuery($sql);
foreach ($aLogins as $aLogin) {
$aLoggedUsers[] = $aLogin['USR_UID'];
}
//check if any of the users have added anything to the APP_HISTORY in the last 24 minutes:
$sqlHistory = "SELECT USR_UID FROM APP_HISTORY
WHERE HISTORY_DATE >= '$time24mAgo' AND USR_UID IN ($sMemberIDs)";
$aHistories = executeQuery($sqlHistory);
foreach ($aHistories as $aHistory) {
$aLoggedUsers[] = $aHistory['USR_UID'];
}
//check if any of the users have started or routed a case in the last 24 minutes:
$sqlDelegation = "SELECT USR_UID FROM APP_DELEGATION
WHERE USR_UID IN ($sMemberIDs) AND
(DEL_DELEGATE_DATE >= '$time24mAgo' OR DEL_FINISH_DATE >= '$time24mAgo')";
$aDelegations = executeQuery($sqlDelegation);
foreach ($aDelegations as $aDelegation) {
$aLoggedUsers[] = $aDelegation['USR_UID'];
}
return array_unique($aLoggedUsers);
}
//skip first task in process if at least one member of the "Users Logged for Task1" group isn't logged in:
if (count(checkIfLogged() == 0) {
@@nextAssignedUser == @@USER_LOGGED;
PMFDerivateCase(@@APPLICATION, @%INDEX, @@USER_LOGGED);
}
Set this trigger to fire before the first step in the first task of the process.
This code might require some debug but it gives you the basic idea.