fixed several adoption problems, fixes #216

- adoption did not work at all since commit cd53979 (because of action="... fix)
- redirect to wrong page after withdrawing adoption offer
- cryptic error message "unknown error" when offering to a disabled user
- messages semantic errors and formatting
This commit is contained in:
following
2013-06-05 13:37:23 +02:00
parent 91d98f7e81
commit 07a1ae0185
4 changed files with 42 additions and 32 deletions
+12 -13
View File
@@ -17,6 +17,8 @@
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'listbyuser';
$tpl->assign('action', $action);
$tpl->assign('error', '');
if (isset($_REQUEST['cacheid']))
$tpl->assign('cacheid', $_REQUEST['cacheid']+0);
if ($action == 'listbycache')
{
@@ -150,20 +152,13 @@ function addRequest($cacheid, $userid)
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
if ($cache->allowEdit() == false)
$tpl->error(ERROR_NO_ACCESS);
if ($cache->getUserId() == $userid)
{
$tpl->assign('error', 'sameuser');
$tpl->display();
}
$adopt_result = $cache->addAdoption($userid);
if ($adopt_result === true)
$tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
else
{
if ($cache->addAdoption($userid) == false)
$tpl->error(ERROR_UNKNOWN);
$tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
$tpl->assign('error',$adopt_result);
listRequestsByCacheId($cacheid);
}
}
@@ -197,6 +192,10 @@ function cancelRequest($cacheid, $userid)
if ($cache->cancelAdoption($userid) == false)
$tpl->error(ERROR_UNKNOWN);
$tpl->redirect('adoptcache.php');
if ($userid == $login->userid)
$tpl->redirect('adoptcache.php');
else
$tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
}
?>