<?php
/**
* iF.SVNAdmin
* Copyright (c) 2010 by Manuel Freiholz
* http://www.insanefactory.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
*/
if( !defined('ACTION_HANDLING') ) {
die("HaHa!");
}
$appEngine->forwardInvalidModule( !$appEngine->isAccessPathEditActive() );
$appEngine->checkUserAuthentication(true, ACL_MOD_ACCESSPATH, ACL_ACTION_DELETE);
$selected = get_request_var('selected_accesspaths');
if ($selected == NULL)
{
$appTemplate->addDefine("WARNING");
$appTemplate->addReplacement("WARNINGMSG", tr("You have to select at least one access-path."));
}
else
{
$doneList = array();
$noPermList = array();
$failedList = array();
for ($i=0; $i<count($selected); $i++)
{
$u = new \svnadmin\core\entities\AccessPath;
$u->path = $selected[$i];
// Is the user restricted to some paths? (project-manager)
if ($appEngine->isAuthenticationActive())
{
$currentUsername = $appEngine->getSessionUsername();
if ($appEngine->getAclManager()->isUserAccessPathManager($currentUsername))
{
if (!$appEngine->getAclManager()->isUserAdminOfPath($currentUsername, $u->path))
{
$noPermList[] = $u->path;
continue;
}
}
}
// Remove all project-manager assignments to the access-path.
if ($appEngine->isAclManagerActive())
{
$appEngine->getAclManager()->removeAssignmentsToPath($selected[$i]);
}
// Remove the access-path.
$b = $appEngine->getAccessPathEditProvider()->deleteAccessPath($u);
if($b)
$doneList[] = $selected[$i];
else
$failedList[] = $selected[$i];
}
$appEngine->getAccessPathEditProvider()->save();
if ($appEngine->isAclManagerActive())
$appEngine->getAclManager()->save();
//////////////////////////////////////////////////////////////////////////////
// Result
//////////////////////////////////////////////////////////////////////////////
if (count($doneList) > 0)
{
$msg = tr("The following Access-Path's has been deleted:");
$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($noPermList) > 0)
{
$msg = tr("You have no permission to delete the following Access-Path's, they have been skipped:");
$msg.= "<br>";
$msg.= "<ul>";
$noPermList = array_unique($noPermList);
foreach ($noPermList 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);
}
}
?>