public function do_submit() { $module = new _cms_module([], $this->mid); $field = new field_type([], $this->type); $type = '\\form\\field_' . $field->title; /** @var \form\field $field_type */ $field_type = new $type(''); if ($inner = $field_type->get_database_create_query()) { db::query('ALTER TABLE ' . $module->table_name . ' ADD `' . $this->field_name . '` ' . $field_type->get_database_create_query(), [], 1); } if ($field->title == 'mlink') { $source_module = new _cms_module(['table_name', 'primary_key'], $this->link_module); db::create_table_join(get::__class_name($this), $source_module->table_name); } $res = db::select('_cms_field')->retrieve('MAX(position) AS pos')->filter_field('mid', $this->mid)->execute()->fetchObject(); $insert = db::insert('_cms_field')->add_value('title', $this->title)->add_value('type', $field->title)->add_value('field_name', $this->field_name)->add_value('mid', $this->mid)->add_value('position', $res->pos + 1); if ($field->title == 'link' || $field->title == 'mlink') { $insert->add_value('link_module', $this->link_module)->add_value('link_field', $this->link_field); } $insert->execute(); table::rebuild_modules(); table::reset_module_fields($module->mid); ajax::update($module->get_fields_list()->get()); ajax::update($this->get_html()->get()); }
public function do_submit() { $flight = new flight(); $flight->set_from_request(); $flight->dim = 1; if (strtotime($this->date) + 30 * 24 * 60 * 60 < time()) { $this->force_delay = true; $flight->admin_info .= 'delayed as flight is old.'; } $track = new track(); $task = $track->set_task($this->coords); $flight_type = new flight_type(); $flight_type->do_retrieve(['ftid', 'multi', 'multi_defined'], ['where_equals' => ['fn' => $task->type]]); $flight->ftid = $flight_type->ftid; $flight->set_date($this->date); $flight->multi = !$this->ridge ? flight_type::get_multiplier($flight->ftid, $flight->season, $this->defined) : 1; $flight->base_score = $task->get_distance(); $flight->coords = $this->coords; $flight->score = $flight->base_score * $flight->multi; $flight->delayed = $this->force_delay ? true : $this->delay; $flight->do_save(); jquery::colorbox(['html' => 'Your flight has been added successfully', 'className' => 'success']); $form = new coordinates_form(); ajax::update($form->get_html()->get()); }
public function do_submit($no_session = false) { if (!$no_session) { foreach ($this->fields as $field) { if ($field instanceof field_boolean && !$this->{$field->field_name}) { session::un_set('cms', 'filter', $this->_mid, $field->field_name); } else { session::set($this->{$field->field_name}, 'cms', 'filter', $this->_mid, $field->field_name); } } } $module = new _cms_module(); $module->do_retrieve([], ['where_equals' => ['mid' => $this->_mid]]); $list = new _cms_table_list($module, 1); ajax::update($list->get_table()); }
public function do_submit() { $module = new _cms_module([], $this->mid); $field = new field_type([], $this->type); $old_field = new _cms_field([], $this->fid); $type = '\\form\\field_' . $field->title; /** @var \form\field $field_type */ $field_type = new $type(''); if ($inner = $field_type->get_database_create_query()) { db::query('ALTER TABLE ' . $module->table_name . ' MODIFY `' . $old_field->field_name . '` `' . $this->field_name . '` ' . $field_type->get_database_create_query(), [], 1); } if ($field->title == 'mlink' && $old_field->type !== 'mlink') { $source_module = new _cms_module(['table_name', 'primary_key'], $this->link_module); db::create_table_join(\classes\get::__class_name($this), $source_module->table_name); } $insert = db::update('_cms_field')->add_value('title', $this->title)->add_value('type', $field->title)->add_value('field_name', $this->field_name)->add_value('link_module', $this->link_module)->add_value('link_field', $this->link_field)->filter_field('fid', $this->fid); $insert->execute(); table::rebuild_modules(); table::reset_module_fields($module->mid); ajax::update($module->get_fields_list()->get()); ajax::update($this->get_html()->get()); }
/** * */ public function do_invalidate_form() { foreach ($this->validation_errors as $key => $val) { $field = $this->get_field_from_name($key); $field->add_class('has-error'); $field->add_wrapper_class('has-error'); } ajax::update($this->get_html()->get()); }
/** * */ public function do_update_selector() { $field = form::create('field_link', 'pid')->set_attr('link_module', '\\object\\pilot')->set_attr('link_field', 'name')->set_attr('options', ['order' => 'name']); $field->parent_form = $this; ajax::update($field->get_html()); }
public function add_flight() { $this->do_retrieve_from_id([], $_REQUEST['cid']); $coords = json_decode($this->coords); $form = new igc_upload_form(); $form->file = $_REQUEST['path']; $form->coords = implode(';', array_map(function ($coord) { $point = new lat_lng($coord->lat, $coord->lon); return geometry::lat_long_to_os($point); }, $coords)); $form->do_submit(); $form = new igc_form(); $form->vis_info = 'Flown in comp: ' . $this->type . ' Round ' . $this->round . ' Task ' . $this->task; $pilot = new pilot(); $parts = explode(' ', $_REQUEST['name']); if ($pilot->do_retrieve([], ['where_equals' => ['name' => $_REQUEST['name']]]) || $pilot->do_retrieve([], ['where_equals' => ['name' => implode(' ', array_reverse($parts))]])) { $form->pid = $pilot->get_primary_key(); $flight = new flight(); if ($flight->do_retrieve([], ['where_equals' => ['pid' => $pilot->get_primary_key()], 'order' => 'date DESC'])) { $form->gid = $flight->gid; $form->cid = $flight->cid; } } ajax::update(node::create('div#second_form', [], $form->get_html())); }
public static function do_paginate() { $module = new __cms_module(); $module->do_retrieve_from_id([], $_REQUEST['_mid']); $object = new static($module, $_REQUEST['value']); ajax::update($object->get_table()); }
/** * */ public function do_update_selector() { $field = form::create('field_link', 'gid')->set_attr('link_module', '\\object\\glider')->set_attr('link_field', ['manufacturer.title', 'name'])->set_attr('options', ['join' => ['manufacturer' => 'manufacturer.mid = glider.mid'], 'order' => 'manufacturer.title, glider.name']); $field->parent_form = $this; ajax::update($field->get_html()); }
public function do_submit() { $point = $this->get_source_as_wgs84(); $this->set_values_from_point($point); ajax::update($this->get_html()->get()); }
public function do_delete() { $module = new _cms_module([], $_REQUEST['mid']); $object = $module->get_class(); $class = $module->get_class_name(); $class::$retrieve_deleted = true; $object->do_retrieve_from_id(['deleted'], $_REQUEST['id']); if ($object->get_primary_key()) { if ($object->deleted) { db::delete(get::__class_name($class))->filter($object->get_primary_key_name() . '=' . $_REQUEST['id'])->execute(); } else { $object->deleted = true; $object->do_save(); } } $list = new object\_cms_table_list($module, 1); ajax::update($list->get_table()); }
public function do_search_submit() { $this->set_list(); ajax::update($this->get_list()); }
public function reset() { ajax::update($this->get_html()->get()); }
public function do_filter_submit() { $this->set_list(); ajax::update($this->get_list()); }
public function do_toggle_expand() { if (isset($_REQUEST['id'])) { $module = new _cms_module(); $module->do_retrieve([], ['where_equals' => ['mid' => $_REQUEST['mid']]]); if (_session::is_set('cms', 'expand', $module->mid)) { $value = _session::get('cms', 'expand', $module->mid); if (($key = array_search($_REQUEST['id'], $value)) !== false) { unset($value[$key]); } else { $value[] = $_REQUEST['id']; } _session::set($value, 'cms', 'expand', $module->mid); } else { _session::set([$_REQUEST['id']], 'cms', 'expand', $module->mid); } $list = new _cms_table_list($module, 1); _ajax::update($list->get_table()); } }
public function do_submit() { $flight = new flight(); $flight->set_from_request(); $flight->live = false; $flight->do_save(); if ($flight->fid) { $flight->move_temp_files($this->temp_id); $igc_parser = new igc_parser(); $igc_parser->load_data($flight->fid, false); $flight->did = $igc_parser->has_height_data() ? 3 : 2; $flight->winter = $igc_parser->is_winter(); $flight->set_date(strtotime($igc_parser->get_date())); $this->force_delay = false; if (!$this->check_date($igc_parser)) { $this->force_delay = true; $flight->admin_info .= 'delayed as flight is old.' . "\n"; } if ($igc_parser->get_validated() === 0) { $flight->admin_info .= 'G record invalid.' . "\n"; } $flight->defined = $this->type == 'task'; $flight->duration = $igc_parser->get_duration(); foreach (['od' => 'open_distance', 'or' => 'out_and_return', 'tr' => 'triangle', 'ft' => 'flat_triangle'] as $task_id => $name) { if ($task = $igc_parser->get_task($name)) { $flight->{$task_id . '_score'} = $task->get_distance(); $flight->{$task_id . '_time'} = $task->get_duration(); $flight->{$task_id . '_coordinates'} = $task->get_gridref(); if ($this->type == $task->type) { $flight->ftid = $this->type; $flight->base_score = $task->get_distance(); $flight->duration = $task->get_duration(); $flight->coords = $task->get_gridref(); } } } if ($flight->defined) { $task = $igc_parser->get_task('declared'); $flight->ftid = $task->type; if ($flight->ftid == \track\task::TYPE_OPEN_DISTANCE) { $flight->ftid = \track\task::TYPE_GOAL; } $flight->base_score = $task->get_distance(); $flight->duration = $task->get_duration(); $flight->coords = $task->get_gridref(); } $flight->multi = !$flight->ridge ? flight_type::get_multiplier($flight->ftid, $igc_parser->get_date('Y'), $flight->defined) : 1; $flight->score = $flight->multi * $flight->base_score; $flight->delayed = $this->force_delay || $this->delay; $flight->live = true; $flight->do_save(); jquery::colorbox(['html' => 'Your flight has been added successfully', 'className' => 'success']); $form = new igc_form(); ajax::update($form->get_html()->get()); $users = new_flight_notification::get_all([]); foreach ($users as $user) { $mail = new email(); $mail->load_template(root . '/template/email/basic.html'); $mail->set_recipients([$user->email]); $subject = 'New flight added'; if ($flight->delayed) { $subject .= ' - Delayed'; } if ($igc_parser->get_validated() === 0) { $subject .= ' - G record invalid'; } $mail->set_subject($subject); $mail->replacements = ['[content]' => ' <h2>New flight added: ' . $flight->get_primary_key() . '</h2> <table class="btn-primary" cellpadding="0" cellspacing="0" border="0"> <tr> <td> <a href="' . host . '/cms/edit/2/' . $flight->get_primary_key() . '">View in CMS</a> </td> </tr> </table>']; $mail->send(); } } else { jquery::colorbox(['html' => 'Your flight has failed to save', 'className' => 'success failure']); } }