/**
  * Process action on page load
  */
 public function loadPassingsPage()
 {
     $table = $this->createPassingTableOnce();
     if (!fRequest::check('passing_id')) {
         return;
     }
     $this->processAction($table->current_action(), fRequest::get('passing_id', 'array'));
 }
Exemple #2
0
 /**
  * Performs the upload action for file uploads during fActiveRecord::populate()
  * 
  * @internal
  * 
  * @param  fActiveRecord $object            The fActiveRecord instance
  * @param  array         &$values           The current values
  * @param  array         &$old_values       The old values
  * @param  array         &$related_records  Any records related to this record
  * @param  array         &$cache            The cache array for the record
  * @return void
  */
 public static function populate($object, &$values, &$old_values, &$related_records, &$cache)
 {
     $class = get_class($object);
     foreach (self::$file_upload_columns[$class] as $column => $directory) {
         if (fUpload::check($column) || fRequest::check('existing-' . $column) || fRequest::check('delete-' . $column)) {
             $method = 'upload' . fGrammar::camelize($column, TRUE);
             $object->{$method}();
         }
     }
 }
 /**
  * Gets the current sort direction
  *
  * @param  string $default_direction  The default direction, `'asc'` or `'desc'`
  * @return string  The direction, `'asc'` or `'desc'`
  */
 public static function getSortDirection($default_direction)
 {
     // Reset value if requested
     if (self::wasResetRequested()) {
         self::setPreviousSortDirection(NULL);
         return;
     }
     if (self::getPreviousSortDirection() && !fRequest::check('dir')) {
         self::$sort_direction = self::getPreviousSortDirection();
         self::$loaded_values['dir'] = self::$sort_direction;
     } else {
         self::$sort_direction = fRequest::getValid('dir', array($default_direction, $default_direction == 'asc' ? 'desc' : 'asc'));
         self::setPreviousSortDirection(self::$sort_direction);
     }
     return self::$sort_direction;
 }
Exemple #4
0
 /**
  * Sets the values for this record by getting values from the request through the fRequest class
  * 
  * @return fActiveRecord  The record object, to allow for method chaining
  */
 public function populate()
 {
     $class = get_class($this);
     if (fORM::getActiveRecordMethod($class, 'populate')) {
         return $this->__call('populate', array());
     }
     fORM::callHookCallbacks($this, 'pre::populate()', $this->values, $this->old_values, $this->related_records, $this->cache);
     $schema = fORMSchema::retrieve($class);
     $table = fORM::tablize($class);
     $column_info = $schema->getColumnInfo($table);
     foreach ($column_info as $column => $info) {
         if (fRequest::check($column)) {
             $method = 'set' . fGrammar::camelize($column, TRUE);
             $cast_to = $info['type'] == 'blob' ? 'binary' : NULL;
             $this->{$method}(fRequest::get($column, $cast_to));
         }
     }
     fORM::callHookCallbacks($this, 'post::populate()', $this->values, $this->old_values, $this->related_records, $this->cache);
     return $this;
 }
 /**
  * Sets the values for records in a one-to-many relationship with this record
  *
  * @internal
  *
  * @param  string  $class             The class to populate the related records of
  * @param  array   &$related_records  The related records existing for the fActiveRecord class
  * @param  string  $related_class     The related class to populate
  * @param  string  $route             The route to the related class
  * @param  boolean $recursive         If a recursive populate should be performed on the child records
  * @return void
  */
 public static function populateRecords($class, &$related_records, $related_class, $route = NULL, $recursive = FALSE)
 {
     fActiveRecord::validateClass($related_class);
     fActiveRecord::forceConfigure($related_class);
     $table = fORM::tablize($class);
     $related_table = fORM::tablize($related_class);
     $schema = fORMSchema::retrieve($class);
     $pk_columns = $schema->getKeys($related_table, 'primary');
     $first_pk_column = self::determineFirstPKColumn($class, $related_class, $route);
     $filter = self::determineRequestFilter($class, $related_class, $route);
     $pk_field = $filter . $first_pk_column;
     $records = array();
     $input_keys = array();
     if (fRequest::check($pk_field, TRUE)) {
         $related_keys = fRequest::get($pk_field);
         $input_keys = is_array($related_keys) ? array_keys($related_keys) : array(NULL);
     }
     foreach ($input_keys as $input_key) {
         fRequest::filter($filter, $input_key);
         // Try to load the value from the database first
         try {
             if (sizeof($pk_columns) == 1) {
                 $primary_key_values = fRequest::get($first_pk_column);
             } else {
                 $primary_key_values = array();
                 foreach ($pk_columns as $pk_column) {
                     $primary_key_values[$pk_column] = fRequest::get($pk_column);
                 }
             }
             $record = new $related_class($primary_key_values);
         } catch (fNotFoundException $e) {
             $record = new $related_class();
         }
         $record->populate($recursive);
         $records[] = $record;
         fRequest::unfilter();
     }
     $record_set = fRecordSet::buildFromArray($related_class, $records);
     self::setRecordSet($class, $related_records, $related_class, $record_set, $route);
     self::flagForAssociation($class, $related_records, $related_class, $route);
 }
 public function populate($recursive = FALSE)
 {
     $class = get_class($this);
     if (fORM::getActiveRecordMethod($class, 'populate')) {
         return $this->__call('populate', array());
     }
     fORM::callHookCallbacks($this, 'pre::populate()', $this->values, $this->old_values, $this->related_records, $this->cache);
     $schema = fORMSchema::retrieve($class);
     $table = fORM::tablize($class);
     $column_info = $schema->getColumnInfo($table);
     foreach ($column_info as $column => $info) {
         if (array_search($column, $this->protected_params) !== FALSE) {
             continue;
         }
         if (fRequest::check($column)) {
             $method = 'set' . fGrammar::camelize($column, TRUE);
             $cast_to = $info['type'] == 'blob' ? 'binary' : NULL;
             $this->{$method}(fRequest::get($column, $cast_to));
         }
     }
     fORM::callHookCallbacks($this, 'post::populate()', $this->values, $this->old_values, $this->related_records, $this->cache);
     if ($recursive) {
         $one_to_many_relationships = $schema->getRelationships($table, 'one-to-many');
         foreach ($one_to_many_relationships as $relationship) {
             $route_name = fORMSchema::getRouteNameFromRelationship('one-to-many', $relationship);
             $related_class = fORM::classize($relationship['related_table']);
             $method = 'populate' . fGrammar::pluralize($related_class);
             $this->{$method}(TRUE, $route_name);
         }
         $one_to_one_relationships = $schema->getRelationships($table, 'one-to-one');
         foreach ($one_to_one_relationships as $relationship) {
             $route_name = fORMSchema::getRouteNameFromRelationship('one-to-one', $relationship);
             $related_class = fORM::classize($relationship['related_table']);
             $this->__call('populate' . $related_class, array(TRUE, $route_name));
         }
     }
     return $this;
 }
 /**
  * Parses associations for many-to-many relationships from the page request
  *
  * @internal
  *
  * @param  string $class             The class to get link the related records to
  * @param  array  &$related_records  The related records existing for the fActiveRecord class
  * @param  string $related_class     The related class to populate
  * @param  string $route             The route to the related class
  * @return void
  */
 public static function linkRecords($class, &$related_records, $related_class, $route = NULL)
 {
     fActiveRecord::validateClass($related_class);
     fActiveRecord::forceConfigure($related_class);
     $table = fORM::tablize($class);
     $related_table = fORM::tablize($related_class);
     $schema = fORMSchema::retrieve($class);
     $route_name = fORMSchema::getRouteName($schema, $table, $related_table, $route, 'many-to-many');
     $relationship = fORMSchema::getRoute($schema, $table, $related_table, $route, 'many-to-many');
     $field_table = $relationship['related_table'];
     $field_column = '::' . $relationship['related_column'];
     $field = $field_table . $field_column;
     $field_with_route = $field_table . '{' . $route_name . '}' . $field_column;
     // If there is only one route and they specified the route instead of leaving it off, use that
     if ($route !== NULL || $route === NULL && !fRequest::check($field) && fRequest::check($field_with_route)) {
         $field = $field_with_route;
     }
     $record_set = fRecordSet::build($related_class, array($relationship['related_column'] . '=' => fRequest::get($field, 'array', array())));
     self::associateRecords($class, $related_records, $related_class, $record_set, $route_name);
 }
 public function testCheckNestedArraySyntax()
 {
     $_GET['foo'] = array('bar' => array('baz' => '1'));
     $this->assertEquals(TRUE, fRequest::check('foo[bar][baz]'));
 }
Exemple #9
0
 $check->populate();
 $period = fRequest::get('all_the_time_or_period');
 $hourStart = NULL;
 $hourEnd = NULL;
 $dayStart = NULL;
 $dayEnd = NULL;
 if ('period' == $period) {
     if (!fRequest::check("no_time_filter")) {
         $hourStart = fRequest::get('start_hr') . ":" . fRequest::get('start_min');
         $hourEnd = fRequest::get('end_hr') . ":" . fRequest::get('end_min');
         if ($hourStart == $hourEnd) {
             $hourStart = NULL;
             $hourEnd = NULL;
         }
     }
     if (!fRequest::check("no_day_filter")) {
         $dayStart = fRequest::get('start_day');
         $dayEnd = fRequest::get('end_day');
         if ($dayStart == $dayEnd) {
             $dayStart = NULL;
             $dayEnd = NULL;
         }
     }
 }
 $check->setHourStart($hourStart);
 $check->setHourEnd($hourEnd);
 $check->setDayStart($dayStart);
 $check->setDayEnd($dayEnd);
 fRequest::validateCSRFToken(fRequest::get('token'));
 $check->store();
 fMessaging::create('affected', fURL::get(), $check->getName());