Exemplo n.º 1
0
 public function saveRaces()
 {
     $this->log->showLog(2, "Access saveRaces()");
     // die;
     global $xoopsDB, $saveHandler, $createdby, $timestamp, $defaultorganization_id;
     $tablename = "sim_races";
     $pkey = "races_id";
     $keyword = "Races";
     $controlfieldname = "races_name";
     $insertCount = $saveHandler->ReturnInsertCount();
     $this->log->showLog(3, "Start Insert({$insertCount} records)");
     if ($insertCount > 0) {
         $arrfield = array($controlfieldname, "races_description", "isactive", "defaultlevel", "created", "createdby", "updated", "updatedby", "organization_id");
         $arrfieldtype = array('%s', '%s', '%d', '%d', '%s', '%d', '%s', '%d', '%d');
         // Yes there are INSERTs to perform...
         for ($currentRecord = 0; $currentRecord < $insertCount; $currentRecord++) {
             $arrvalue = array($saveHandler->ReturnInsertField($currentRecord, $controlfieldname), $saveHandler->ReturnInsertField($currentRecord, "races_description"), $saveHandler->ReturnInsertField($currentRecord, "isactive"), $saveHandler->ReturnInsertField($currentRecord, "defaultlevel"), $timestamp, $createdby, $timestamp, $createdby, $defaultorganization_id);
             $controlvalue = $saveHandler->ReturnInsertField($currentRecord, $controlfieldname);
             $this->InsertRecord($tablename, $arrfield, $arrvalue, $arrfieldtype, $controlvalue, $pkey);
             // Now we execute this query
         }
     }
     $updateCount = $saveHandler->ReturnUpdateCount();
     $this->log->showLog(3, "Start update({$updateCount} records)");
     if ($updateCount > 0) {
         $arrfield = array($controlfieldname, "races_description", "isactive", "defaultlevel", "updated", "updatedby", "isdeleted");
         $arrfieldtype = array('%s', '%s', '%d', '%d', '%s', '%d', '%d');
         // Yes there are UPDATEs to perform...
         for ($currentRecord = 0; $currentRecord < $updateCount; $currentRecord++) {
             $arrvalue = array($saveHandler->ReturnUpdateField($currentRecord, $controlfieldname), $saveHandler->ReturnUpdateField($currentRecord, "races_description"), $saveHandler->ReturnUpdateField($currentRecord, "isactive"), $saveHandler->ReturnUpdateField($currentRecord, "defaultlevel"), $timestamp, $createdby, $saveHandler->ReturnUpdateField($currentRecord, "isdeleted"));
             $controlvalue = $saveHandler->ReturnUpdateField($currentRecord, $controlfieldname);
             $this->UpdateRecord($tablename, $pkey, $saveHandler->ReturnUpdateField($currentRecord), $arrfield, $arrvalue, $arrfieldtype, $controlvalue);
         }
     }
     $ispurge = 0;
     $deleteCount = $saveHandler->ReturnDeleteCount();
     $this->log->showLog(3, "Start delete/purge({$deleteCount} records)");
     include "class/{$keyword}.inc.php";
     $o = new Races();
     if ($deleteCount > 0) {
         for ($currentRecord = 0; $currentRecord < $deleteCount; $currentRecord++) {
             $record_id = $saveHandler->ReturnDeleteField($currentRecord);
             $o->fetchRaces($record_id);
             $controlvalue = $o->races_name;
             $isdeleted = $o->isdeleted;
             if ($o->allowDelete($record_id)) {
                 $this->DeleteRecord($tablename, $pkey, $record_id, $controlvalue, $isdeleted);
             } else {
                 $this->failfeedback .= "Cannot delete {$keyword}: {$o->races_name} <br/>";
             }
         }
     }
     //$this->failfeedback.="asdasdpasd<br/>\n";
     //$this->failfeedback.="123 3443<br/>\n";
     //$this->failfeedback.="234 45656523 234<br/>\n";
     if ($this->failfeedback != "") {
         $this->failfeedback .= "Warning!<br/>\n" . $this->failfeedback;
     }
     $saveHandler->setErrorMessage($this->failfeedback);
     die;
     $saveHandler->CompleteSave();
 }
Exemplo n.º 2
0
         } else {
             $log->showLog(1, "Can't create races '{$o->races_name}', please verified your data!");
             $token = $s->createToken($tokenlife, "CREATE_RCE");
             $o->getInputForm("new", -1, $token);
             $o->showRacesTable();
         }
     } else {
         // if the token is not valid or the token is expired, it back to previous form with previous inputed data
         $log->showLog(1, "Can't create races '{$o->races_name}' due to token expired!");
         $token = $s->createToken($tokenlife, "CREATE_RCE");
         $o->getInputForm("new", -1, $token);
         $o->showRacesTable();
     }
     break;
 case "edit":
     if ($o->fetchRaces($o->races_id)) {
         //create a new token for editing a form
         $token = $s->createToken($tokenlife, "CREATE_RCE");
         $o->getInputForm("edit", $o->races, $token);
         $o->showRacesTable();
     } else {
         //if can't find particular races from database, return error message
         redirect_header("races.php", 3, "<b style='color:red'>Some error on viewing your races data, probably database corrupted.</b>");
     }
     break;
 case "update":
     if ($s->check(true, $token, "CREATE_RCE")) {
         $o->updatedby = $xoopsUser->getVar('uid');
         //get current uid
         if ($o->updateRaces()) {
             //if data save successfully