public function parseForm()
 {
     $reserved = array('form_name', 'return_url', 'mail_to', 'Submit');
     $form_name = Application::param('form_name');
     $mail_to = Application::param('mail_to');
     $return_url = Application::param('return_url');
     $submission_no_query = SimpleQuery::create('SELECT COUNT(DISTINCT submission_no) AS count FROM ant_antenna_data WHERE form_name=\'' . $form_name . '\'');
     $submission_no_results = $submission_no_query->next();
     $submission_no = $submission_no_results['count'];
     $form_data = array();
     foreach (Application::post() as $key => $value) {
         if (!in_array($key, $reserved)) {
             $data = new AntennaData();
             $data->construct('', $form_name, $submission_no, $key, $value, '0');
             $data->saveLater();
             $form_data[$key] = $value;
         }
     }
     $data->purge();
     $this->emailSubmission($form_name, $mail_to, $form_data, $submission_no[count]);
 }
Example #2
0
 public function testAddRouteMethodShouldReturnAnInstanceOfRoute()
 {
     $app = new Application();
     $this->assertInstanceOf('yoshi\\Route', $app->get('/test', function (Response $response) {
         $response->contents('GET /test');
     }));
     $this->assertInstanceOf('yoshi\\Route', $app->post('/test', function (Response $response) {
         $response->contents('POST /test');
     }));
     $this->assertInstanceOf('yoshi\\Route', $app->put('/test', function (Response $response) {
         $response->contents('PUT /test');
     }));
     $this->assertInstanceOf('yoshi\\Route', $app->delete('/test', function (Response $response) {
         $response->contents('DELETE /test');
     }));
     $this->assertInstanceOf('yoshi\\Route', $app->head('/test', function (Response $response) {
         $response->contents('HEAD /test');
     }));
     $this->assertInstanceOf('yoshi\\Route', $app->options('/test', function (Response $response) {
         $response->contents('OPTIONS /test');
     }));
 }
Example #3
0
 function validate($field = '')
 {
     $params = Application::post();
     $ret = true;
     $cur_ret = true;
     if (count($this->requirements)) {
         if ($field) {
             $ret = $this->validateRequirements($field, $this->requirements[$field], $params);
         } else {
             foreach ($this->requirements as $name => $reqs) {
                 if (isset($this->skip_validation[$name])) {
                     unset($this->skip_validation[$name]);
                 } else {
                     $cur_ret = $this->validateRequirements($name, $reqs, $params);
                     if ($ret) {
                         $ret = $cur_ret;
                     }
                 }
             }
         }
     }
     return $ret;
 }
 /**
  * Take an associative array of variables and assign them to the fields
  * of this DbObject's table object
  *
  * This method is really just a wrapper for the Table's 
  * assignFieldValues method, but it must go through the DbObject
  * to determine whether or not it will be ready to insert.
  *
  * The value array is one where the key is the field name and the 
  * value of each element is the value to be assigned to the field,
  * so it is well suited to validation forms sent through POST 
  * HTTP queries.
  *
  * Data used in this method is automatically secured against SQL injection using
  * the {@link Query::clean()} method.
  *
  * This method will merely match up data in the array given (or $_POST by default)
  * using the keys, to the appoprirate fields. All data validation should be done
  * using the FormML validation engine (see {@link Form}).
  *
  * @param vars               - (option) the variables to verify, default is $_POST
  * @access public
  * @see Form,FormValidationRequirement,Table::assignFieldValues
  */
 public function parse($vars = '')
 {
     $this->read();
     if (!$vars) {
         $vars = Application::post();
     }
     $this->table()->assignFieldValues($vars);
 }
 /**
  * Return all parameters, $_POST,$_GET and user parameters
  * @return array - all parameters to the application
  * @access public
  * @static
  */
 public static function parameters()
 {
     $ret = Application::post();
     $ret = ArrayUtility::merge($ret, Application::get());
     $ret = ArrayUtility::merge($ret, Session::getRegistered('userParams'));
     return $ret;
 }