<?php
if( !defined('ACTION_HANDLING') ) {
die("HaHa!");
}
$appEngine->forwardInvalidModule(!$appEngine->isAuthenticationActive());
$appEngine->checkUserAuthentication(true, ACL_MOD_PROJECTMANAGER, ACL_ACTION_ASSIGN);
$selusers = get_request_var("selected_users");
$selpaths = get_request_var("selected_accesspaths");
if ($selusers == null || $selpaths == null)
{
$appTemplate->addDefine("WARNING");
$appTemplate->addReplacement("WARNINGMSG", tr("You have to select at least one access-path and one user."));
}
else
{
$selusersCount = count($selusers);
$selpathsCount = count($selpaths);
$doneList = array();
$warnList = array();
$failedList = array();
for ($i=0; $i<$selusersCount; $i++)
{
for ($j=0; $j<$selpathsCount; $j++)
{
// It is not possible to set an admin for root.
if ($selpaths[$j] == "/")
{
$warnList[] = $selpaths[$j];
continue;
}
$b = $appEngine->getAclManager()->assignAccessPathAdmin($selpaths[$j], $selusers[$i]);
if ($b)
$doneList[] = $selpaths[$j];
else
$failedList[] = $selpaths[$j];
}
}
$appEngine->getAclManager()->save();
//////////////////////////////////////////////////////////////////////////////
// Result
//////////////////////////////////////////////////////////////////////////////
if (count($doneList) > 0)
{
$msg = tr("The following Access-Path's has been assigned:");
$msg.= "<br>";
$msg.= "<ul>";
$doneList = array_unique($doneList);
foreach ($doneList as &$valPath)
{
$msg.= "<li>".$valPath."</li>";
}
$msg.= "</ul>";
$appTemplate->addDefine("INFO");
$appTemplate->addReplacement("INFOMSG", $msg);
}
if (count($warnList) > 0)
{
$msg = tr("It is not possible to set an Project-Manager for the following path's:");
$msg.= "<br>";
$msg.= "<ul>";
$warnList = array_unique($warnList);
foreach ($warnList as &$valPath)
{
$msg.= "<li>".$valPath."</li>";
}
$msg.= "</ul>";
$appTemplate->addDefine("WARNING");
$appTemplate->addReplacement("WARNINGMSG", $msg);
}
if (count($failedList) > 0)
{
$msg = tr("Due to an unknown error, the following Access-Path's could not been handled:");
$msg.= "<br>";
$msg.= "<ul>";
$failedList = array_unique($failedList);
foreach ($failedList as &$valPath)
{
$msg.= "<li>".$valPath."</li>";
}
$msg.= "</ul>";
$appTemplate->addDefine("ERROR");
$appTemplate->addReplacement("ERRORMSG", $msg);
}
}
?>