Esempio n. 1
0
 case "edit":
     if ($o->fetchYear($o->year_id)) {
         //create a new token for editing a form
         $token = $s->createToken($tokenlife, "CREATE_RCE");
         $o->getInputForm("edit", $o->year, $token);
         $o->showYearTable();
     } else {
         //if can't find particular year from database, return error message
         redirect_header("year.php", 3, "<b style='color:red'>Some error on viewing your year data, probably database corrupted.</b>");
     }
     break;
 case "update":
     if ($s->check(false, $token, "CREATE_RCE")) {
         $o->updatedby = $xoopsUser->getVar('uid');
         //get current uid
         if ($o->updateYear()) {
             //if data save successfully
             redirect_header("year.php?action=edit&year_id={$o->year_id}", $pausetime, "Your data is saved.");
         } else {
             redirect_header("year.php?action=edit&year_id={$o->year_id}", $pausetime, "<b style='color:red'>Warning! Can't save '{$o->year_name}', please make sure all value is insert properly.</b>");
         }
     } else {
         redirect_header("year.php?action=edit&year_id={$o->year_id}", $pausetime, "<b style='color:red'>Warning! Can't save the data '{$o->year_name}' due to token expired, please reenter data after form refresh.</b>");
     }
     break;
 case "delete":
     if ($s->check(false, $token, "CREATE_RCE")) {
         if ($o->deleteYear($o->year_id)) {
             redirect_header("year.php", $pausetime, "Data removed successfully.");
         } else {
             redirect_header("year.php?action=edit&year_id={$o->year_id}", $pausetime, "<b style='color:red'>Warning! Can't delete\n\t\t\t\t\tdata from database due to dependency issue.</b>");