Example #1
0
function addRequest($cacheid, $userid)
{
    global $tpl;
    // cache exists?
    $cache = new cache($cacheid);
    if ($cache->exist() == false) {
        $tpl->error(ERROR_CACHE_NOT_EXISTS);
    }
    $adopt_result = $cache->addAdoption($userid);
    if ($adopt_result === true) {
        $tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
    } else {
        $tpl->assign('error', $adopt_result);
        listRequestsByCacheId($cacheid);
    }
}
Example #2
0
     $submit = isset($_REQUEST['submit']) ? $_REQUEST['submit'] + 0 : 0;
     $username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
     $tpl->assign('adoptusername', $username);
     if ($submit == 1) {
         $userid = sql_value("SELECT `user_id` FROM `user` WHERE `username`='&1'", 0, $username);
         if ($userid == 0) {
             $tpl->assign('error', 'userunknown');
         } else {
             if ($tou != 1) {
                 $tpl->assign('error', 'tou');
             } else {
                 addRequest($cacheid, $userid);
             }
         }
     }
     listRequestsByCacheId($cacheid);
 } else {
     if ($action == 'cancel') {
         $cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid'] + 0 : 0;
         $userid = isset($_REQUEST['userid']) ? $_REQUEST['userid'] + 0 : 0;
         cancelRequest($cacheid, $userid);
     } else {
         if ($action == 'commit') {
             $cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid'] + 0 : 0;
             $submit = isset($_REQUEST['submit']) ? $_REQUEST['submit'] + 0 : 0;
             $tou = isset($_REQUEST['tou']) ? $_REQUEST['tou'] + 0 : 0;
             if ($submit == 1 && $tou == 1) {
                 commitRequest($cacheid);
             } else {
                 showAdoptScreen($cacheid, $submit);
             }