Example #1
0
 protected function handleResponseModifyObject()
 {
     $bValid = true;
     // Validate the response
     // Need to listen to POST and GET
     $aResponse = array_merge($_GET, $_POST);
     // FIXME: Maybe change all to POST
     $FHANDLER = new CoreRequestHandler($aResponse);
     // Check for needed params
     if ($bValid && !$FHANDLER->isSetAndNotEmpty('map')) {
         $bValid = false;
     }
     if ($bValid && !$FHANDLER->isSetAndNotEmpty('id')) {
         $bValid = false;
     }
     // All fields: Regex check
     if ($bValid && !$FHANDLER->match('map', MATCH_MAP_NAME)) {
         $bValid = false;
     }
     if ($bValid && $FHANDLER->isSetAndNotEmpty('id') && !$FHANDLER->match('id', MATCH_OBJECTID)) {
         $bValid = false;
     }
     if ($bValid) {
         $this->verifyMapExists($FHANDLER->get('map'));
     }
     // FIXME: Recode to FHANDLER
     $aOpts = $aResponse;
     // Remove the parameters which are not options of the object
     unset($aOpts['act']);
     unset($aOpts['mod']);
     unset($aOpts['map']);
     unset($aOpts['ref']);
     unset($aOpts['id']);
     unset($aOpts['lang']);
     // Also remove all "helper fields" which begin with a _
     foreach ($aOpts as $key => $val) {
         if (strpos($key, '_') === 0) {
             unset($aOpts[$key]);
         }
     }
     // Store response data
     if ($bValid === true) {
         // Return the data
         return array('map' => $FHANDLER->get('map'), 'id' => $FHANDLER->get('id'), 'refresh' => $FHANDLER->get('ref'), 'opts' => $aOpts);
     } else {
         return false;
     }
 }