/** * Display a combined form for date and time * @param $label Label of the form * @param $name name of the form fields * @param $datetime Value of the fields, in unix time * @param $postOverride If the POST variable should override the value in the form * @return string */ function datetime($label, $name, $datetime = false, $postOverride = true) { if ($postOverride && ($r = Short::parseDateAndTime($name, $datetime))) { $datetime = $r; } return new Li(new Datepicker($label, $name . '[date]', $datetime), new Timepickr(false, $name . '[time]', $datetime)); }
function saveChanges() { $_POST->setType('etitle', 'string'); $_POST->setType('eimg', 'string'); $_POST->setType('etxt', 'string'); $_POST->setType('active', 'string'); $_POST->setType('regstop', 'string'); $_POST->setType('attendance', 'string'); $_POST->setType('reminder', 'bool'); $_POST->setType('contact', 'numeric'); $_POST->setType('attending_groups', 'numeric', true); $_POST->setType('visibility', 'numeric', true); if ($_POST['etitle']) { $this->that->Name = $_POST['etitle']; $this->that->start = Short::parseDateAndTime('estart', false); $this->that->end = Short::parseDateAndTime('eend', false); $this->that->Image = $_POST['eimg']; $this->that->registration_ends = strtotime($_POST['regstop']); $this->that->setActive(Short::parseDateAndTime('active'), $this->that->end); $this->that->contact = $_POST['contact']; $this->that->attendance = isset($_POST['attendance']); $this->that->attending_groups = $_POST['attending_groups']; $this->that->reminder = $_REQUEST['reminder']; $this->updateVisibility($_POST['visibility']); Flash::queue(__('Event updated'), 'confirmation'); } }
function render() { $id = idfy($this->name); if (is_array($this->value)) { $value = Short::parseDateAndTime($this->value); } global $CONFIG; JS::loadjQuery(true); JS::lib('jquery/jquery.timePicker'); Head::add('timePicker', 'css-lib'); Head::add('$(function(){$("input.time").timePicker();});', 'js-raw'); return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="time' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '" value="' . (is_numeric($this->value) ? date('H:i', $this->value) : $this->value) . '" />' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>'; }
function saveChanges() { $_POST->setType('title', 'string'); $_POST->setType('template', 'string'); $_POST->setType('alias', 'string'); $_POST->setType('commentsEnabled', 'bool'); if (!$_POST['title']) { return false; } $this->that->Name = $_POST['title']; $this->that->resetAlias(explode(',', $_POST['alias'])); $this->that->setActive(Short::parseDateAndTime('activate'), Short::parseDateAndTime('deactivate')); $this->that->settings['comments'] = isset($_POST['commentsEnabled']); if ($_POST['template']) { $this->that->template = $_POST['template']; } Flash::queue(__('Your changes were saved'), 'confirmation'); return true; }
function saveChanges() { $_POST->setType('etitle', 'string'); $_POST->setType('etxt', 'string'); $_POST->setType('estart', 'any'); $_POST->setType('eend', 'any'); if (!$_POST['etitle']) { Flash::create(__('Please enter a title')); return; } if (!$_POST['etxt']) { Flash::create(__('Please enter a text')); return; } $this->that->Name = $_POST['etitle']; $this->that->Image = $_POST['eimg']; $this->that->setActive(Short::parseDateAndTime('estart'), Short::parseDateAndTime('eend', false)); $this->that->saveContent(array('Text' => $_POST['etxt'])); $Controller->forceReload($this->that); Flash::create(__('Your data was saved'), 'confirmation'); }
/** * In this function, most actions of the module are carried out * and the page generation is started, distibuted and rendered. * @return void * @see solidbase/lib/Page#run() */ function run() { global $Templates, $USER, $CONFIG, $Controller, $DB; if (!$this->may($USER, READ | EDIT)) { errorPage('401'); return false; } /** * User input types */ $_REQUEST->setType('esave', 'any'); $_REQUEST->setType('view', 'string'); $_REQUEST->setType('edit', array('numeric', '#new#')); $_REQUEST->setType('del', 'numeric'); $_REQUEST->setType('lang', 'string'); $_POST->setType('einscal', 'any'); $_POST->setType('etitle', 'string'); $_POST->setType('activated', 'any'); $_POST->setType('eimg', 'numeric'); $_POST->setType('etxt', 'any'); $_POST->setType('eupdate', 'any'); $_POST->setType('flows', 'string', true); if ($_REQUEST['del']) { if ($Controller->{$_REQUEST['del']} && $Controller->{$_REQUEST['del']}->delete()) { Flash::create(__('Item removed'), 'confirmation'); } } /** * Save item */ do { $start = $stop = 0; $item = false; if ($_REQUEST['edit'] && $_REQUEST['esave']) { if (is_numeric($_REQUEST['edit'])) { $item = new NewsItem($_REQUEST['edit'], $_REQUEST['lang']); if (!$item || !is_a($item, 'FlowItem') || !$item->mayI(EDIT)) { Flash::create(__('Invalid item'), 'warning'); break; } } //FIXME: Further validation? if ($_POST['einscal']) { if (($start = Short::parseDateAndTime('cstart')) === false) { Flash::create(__('Invalid starttime'), 'warning'); break; } if (($stop = Short::parseDateAndTime('cend')) === false) { $stop = $start += 3600; } } if (!$_POST['etitle']) { Flash::create(__('Please enter a title')); break; } if (!$_POST['etxt']) { Flash::create(__('Please enter a text')); break; } if ($_REQUEST['edit'] === 'new') { $item = $Controller->newObj('FlowItem', $_REQUEST['lang']); $_REQUEST['edit'] = $item->ID; } if ($item) { $item->Name = $_POST['etitle']; $item->Image = $_POST['eimg']; $item->setActive(Short::parseDateAndTime('estart'), Short::parseDateAndTime('eend')); $item->Activated = isset($_POST['activated']); $item->saveContent(array('Text' => $_POST['etxt'])); if ($_POST['einscal']) { if ($item->Cal) { Calendar::editEvent($item->Cal, $_POST['etitle'], $_POST['etxt'], false, $start, $stop); } else { $item->Cal = Calendar::newEvent($_POST['etitle'], $_POST['etxt'], false, $start, $stop, 'News'); } } if (!$_POST['eupdate']) { foreach ($_POST['flows'] as $flow) { Flow::touch($item->ID, $flow); } } $Controller->forceReload($item); Flash::create(__('Your data was saved'), 'confirmation'); $_REQUEST->clear('edit'); $_POST->clear('einscal', 'etitle', 'etxt', 'cstart', 'cend', 'estart', 'eend', 'flows'); } else { Flash::create(__('Unexpected error'), 'warning'); break; } } } while (false); /** * Here, the page request and permissions decide what should be shown to the user */ if (is_numeric($_REQUEST['edit'])) { $this->editView($_REQUEST['edit'], $_REQUEST['lang']); } else { $this->content = array('header' => __('Flows'), 'main' => $this->mainView()); } $Templates->admin->render(); }