/** * Shows a form to add an event * will default to the current date if non is provided * @return */ function EditEventForm() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $eventID = Kit::GetParam('EventID', _GET, _INT, 0); if ($eventID == 0) { trigger_error(__('No event selected.'), E_USER_ERROR); } // Get the relevant details for this event $SQL = ""; $SQL .= "SELECT schedule.FromDT, "; $SQL .= " schedule.ToDT,"; $SQL .= " schedule.CampaignID, "; $SQL .= " schedule.userid, "; $SQL .= " schedule.is_priority, "; $SQL .= " schedule.DisplayGroupIDs, "; $SQL .= " schedule.recurrence_type, "; $SQL .= " schedule.recurrence_detail, "; $SQL .= " schedule.recurrence_range, "; $SQL .= " schedule.EventID, "; $SQL .= " schedule.DisplayOrder "; $SQL .= " FROM schedule "; $SQL .= " WHERE 1=1 "; $SQL .= sprintf(" AND schedule.EventID = %d", $eventID); Debug::LogEntry('audit', $SQL); if (!($result = $db->query($SQL))) { trigger_error($db->error()); trigger_error(__('Error getting details for this event.'), E_USER_ERROR); } $row = $db->get_assoc_row($result); $fromDT = Kit::ValidateParam($row['FromDT'], _INT); $toDT = Kit::ValidateParam($row['ToDT'], _INT); $displayGroupIds = explode(',', Kit::ValidateParam($row['DisplayGroupIDs'], _STRING)); $recType = Kit::ValidateParam($row['recurrence_type'], _STRING); $recDetail = Kit::ValidateParam($row['recurrence_detail'], _STRING); $recToDT = Kit::ValidateParam($row['recurrence_range'], _INT); $campaignId = Kit::ValidateParam($row['CampaignID'], _STRING); $isPriority = Kit::ValidateParam($row['is_priority'], _INT); $displayOrder = Kit::ValidateParam($row['DisplayOrder'], _INT); // Check that we have permission to edit this event. if (!$this->IsEventEditable($displayGroupIds)) { trigger_error(__('You do not have permission to edit this event.'), E_USER_ERROR); } $token_id = uniqid(); $token_field = '<input type="hidden" name="token_id" value="' . $token_id . '" />'; $token = Kit::Token($token_id); Theme::Set('form_id', 'EditEventForm'); Theme::Set('form_action', 'index.php?p=schedule&q=EditEvent'); Theme::Set('form_meta', $token_field . $token . '<input type="hidden" id="EventID" name="EventID" value="' . $eventID . '" />'); // Two tabs $tabs = array(); $tabs[] = FormManager::AddTab('general', __('General')); $tabs[] = FormManager::AddTab('repeats', __('Repeats')); Theme::Set('form_tabs', $tabs); $formFields = array(); // List of Display Groups $optionGroups = array(array('id' => 'group', 'label' => __('Groups')), array('id' => 'display', 'label' => __('Displays'))); $groups = array(); $displays = array(); $scheduleWithView = Config::GetSetting('SCHEDULE_WITH_VIEW_PERMISSION') == 'Yes'; foreach ($this->user->DisplayGroupList(-1) as $display) { // Can schedule with view, but no view permissions if ($scheduleWithView && $display['view'] != 1) { continue; } // Can't schedule with view, but no edit permissions if (!$scheduleWithView && $display['edit'] != 1) { continue; } $display['checked_text'] = in_array($display['displaygroupid'], $displayGroupIds) ? ' selected' : ''; if ($display['isdisplayspecific'] == 1) { $displays[] = $display; } else { $groups[] = $display; } } $formFields['general'][] = FormManager::AddMultiCombo('DisplayGroupIDs[]', __('Display'), $displayGroupIds, array('group' => $groups, 'display' => $displays), 'displaygroupid', 'displaygroup', __('Please select one or more displays / groups for this event to be shown on.'), 'd', '', true, '', '', '', $optionGroups, array(array('name' => 'data-live-search', 'value' => "true"), array('name' => 'data-selected-text-format', 'value' => "count > 4"))); // Time controls $formFields['general'][] = FormManager::AddText('starttimeControl', __('Start Time'), DateManager::getLocalDate($fromDT), __('Select the start time for this event'), 's', 'required'); $formFields['general'][] = FormManager::AddText('endtimeControl', __('End Time'), DateManager::getLocalDate($toDT), __('Select the end time for this event'), 'e', 'required'); // Add two hidden fields to always carry the ISO date $formFields['general'][] = FormManager::AddHidden('starttime', DateManager::getLocalDate($fromDT, "Y-m-d H:i", false)); $formFields['general'][] = FormManager::AddHidden('endtime', DateManager::getLocalDate($toDT, "Y-m-d H:i", false)); // Generate a list of layouts. $layouts = $user->CampaignList(NULL, false, false); $optionGroups = array(array('id' => 'campaign', 'label' => __('Campaigns')), array('id' => 'layout', 'label' => __('Layouts'))); $layoutOptions = array(); $campaignOptions = array(); foreach ($layouts as $layout) { if ($layout['islayoutspecific'] == 1) { $layoutOptions[] = array('id' => $layout['campaignid'], 'value' => $layout['campaign']); } else { $campaignOptions[] = array('id' => $layout['campaignid'], 'value' => $layout['campaign']); } } $formFields['general'][] = FormManager::AddCombo('CampaignID', __('Layout / Campaign'), $campaignId, array('campaign' => $campaignOptions, 'layout' => $layoutOptions), 'id', 'value', __('Please select a Layout or Campaign for this Event to show'), 'l', '', true, '', '', '', $optionGroups); $formFields['general'][] = FormManager::AddNumber('DisplayOrder', __('Display Order'), $displayOrder, __('Please select the order this event should appear in relation to others when there is more than one event scheduled'), 'o'); $formFields['general'][] = FormManager::AddCheckbox('is_priority', __('Priority'), $isPriority, __('Sets whether or not this event has priority. If set the event will be show in preference to other events.'), 'p'); $formFields['repeats'][] = FormManager::AddCombo('rec_type', __('Repeats'), $recType, array(array('id' => '', 'name' => __('None')), array('id' => 'Minute', 'name' => __('Per Minute')), array('id' => 'Hour', 'name' => __('Hourly')), array('id' => 'Day', 'name' => __('Daily')), array('id' => 'Week', 'name' => __('Weekly')), array('id' => 'Month', 'name' => __('Monthly')), array('id' => 'Year', 'name' => __('Yearly'))), 'id', 'name', __('What type of repeat is required?'), 'r'); $formFields['repeats'][] = FormManager::AddNumber('rec_detail', __('Repeat every'), $recDetail, __('How often does this event repeat?'), 'o', '', 'repeat-control-group'); $formFields['repeats'][] = FormManager::AddText('rec_rangeControl', __('Until'), $recToDT == 0 ? '' : DateManager::getLocalDate($recToDT), __('When should this event stop repeating?'), 'u', '', 'repeat-control-group'); $formFields['repeats'][] = FormManager::AddHidden('rec_range', DateManager::getLocalDate($recToDT, "Y-m-d H:i")); // Set some field dependencies $response->AddFieldAction('rec_type', 'init', '', array('.repeat-control-group' => array('display' => 'none'))); $response->AddFieldAction('rec_type', 'init', '', array('.repeat-control-group' => array('display' => 'block')), "not"); $response->AddFieldAction('rec_type', 'change', '', array('.repeat-control-group' => array('display' => 'none'))); $response->AddFieldAction('rec_type', 'change', '', array('.repeat-control-group' => array('display' => 'block')), "not"); Theme::Set('form_fields_general', $formFields['general']); Theme::Set('form_fields_repeats', $formFields['repeats']); $response->SetFormRequestResponse(NULL, __('Edit Event'), '800px', '600px'); $response->AddButton(__('Help'), "XiboHelpRender('index.php?p=help&q=Display&Topic=Schedule&Category=Edit')"); $response->AddButton(__('Delete'), 'XiboFormRender("index.php?p=schedule&q=DeleteForm&EventID=' . $eventID . '")'); $response->AddButton(__('Cancel'), 'XiboDialogClose()'); $response->AddButton(__('Save'), '$("#EditEventForm").attr("action", $("#EditEventForm").attr("action") + "&next=0").submit()'); $response->callBack = 'setupScheduleForm'; $response->Respond(); }
public function Step6() { // Form to collect the library location and server key $formFields = array(); $formFields[] = FormManager::AddHidden('step', 7); $formFields[] = FormManager::AddText('library_location', __('Library Location'), NULL, sprintf(__('%s needs somewhere to store the things you upload to be shown. Ideally, this should be somewhere outside the root of your web server - that is such that is not accessible by a web browser. Please input the full path to this folder. If the folder does not already exist, we will attempt to create it for you.'), Theme::GetConfig('app_name')), 'n'); $formFields[] = FormManager::AddText('server_key', __('Server Key'), Install::gen_secret(6), sprintf(__('%s needs you to choose a "key". This will be required each time you set-up a new client. It should be complicated, and hard to remember. It is visible in the CMS interface, so it need not be written down separately.'), Theme::GetConfig('app_name')), 'n'); $formFields[] = FormManager::AddCheckbox('stats', __('Statistics'), 1, sprintf(__('We\'d love to know you\'re running %s. If you\'re happy for us to collect anonymous statistics (version number, number of displays) then please leave the box ticked. Please un tick the box if your server does not have direct access to the internet.'), Theme::GetConfig('app_name')), 'n'); // Put up an error message if one has been set (and then unset it) if ($this->errorMessage != '') { Theme::Set('message', $this->errorMessage); Theme::Set('prepend', Theme::RenderReturn('message_box')); $this->errorMessage == ''; } // Return a rendered form Theme::Set('form_action', 'install.php'); Theme::Set('form_fields', $formFields); Theme::Set('form_buttons', array(FormManager::AddButton(__('Next')))); return Theme::RenderReturn('form_render'); }
public function Step2() { Kit::ClassLoader('install'); // Work out what is involved in this upgrade $_SESSION['upgradeFrom'] = Config::Version('DBVersion'); if ($_SESSION['upgradeFrom'] < 1) { $_SESSION['upgradeFrom'] = 1; } // Get a list of .sql and .php files for the upgrade $sql_files = Install::ls('*.sql', 'install/database', false, array('return_files')); $php_files = Install::ls('*.php', 'install/database', false, array('return_files')); // Sort by natural filename (eg 10 is bigger than 2) natcasesort($sql_files); natcasesort($php_files); $_SESSION['phpFiles'] = $php_files; $_SESSION['sqlFiles'] = $sql_files; $max_sql = Kit::ValidateParam(substr(end($sql_files), 0, -4), _INT); $max_php = Kit::ValidateParam(substr(end($php_files), 0, -4), _INT); $_SESSION['upgradeTo'] = max($max_sql, $max_php); if (!$_SESSION['upgradeTo']) { throw new Exception(__('Unable to calculate the upgradeTo value. Check for non-numeric SQL and PHP files in the "install / database" directory.')); } if ($_SESSION['upgradeTo'] < $_SESSION['upgradeFrom']) { $_SESSION['upgradeTo'] = $_SESSION['upgradeFrom']; } // Form to collect some information. $formFields = array(); $formButtons = array(); // Put up an error message if one has been set (and then unset it) if ($this->errorMessage != '') { Theme::Set('message', $this->errorMessage); Theme::Set('prepend', Theme::RenderReturn('message_box')); $this->errorMessage == ''; } $formFields[] = FormManager::AddHidden('step', 3); $formFields[] = FormManager::AddHidden('upgradeFrom', $_SESSION['upgradeFrom']); $formFields[] = FormManager::AddHidden('upgradeTo', $_SESSION['upgradeTo']); $formFields[] = FormManager::AddHidden('includes', true); $formFields[] = FormManager::AddMessage(sprintf(__('Upgrading from database version %d to %d'), $_SESSION['upgradeFrom'], $_SESSION['upgradeTo'])); // Loop for $i between upgradeFrom + 1 and upgradeTo. // If a php file exists for that upgrade, make an instance of it and call Questions so we can // Ask the user for input. for ($i = $_SESSION['upgradeFrom'] + 1; $i <= $_SESSION['upgradeTo']; $i++) { if (file_exists('install/database/' . $i . '.php')) { include_once 'install/database/' . $i . '.php'; $stepName = 'Step' . $i; // Check that a class called Step$i exists if (class_exists($stepName)) { $_SESSION['Step' . $i] = new $stepName($this->db); // Call Questions on the object and send the resulting hash to createQuestions routine $questionFields = $this->createQuestions($i, $_SESSION['Step' . $i]->Questions()); $formFields = array_merge($formFields, $questionFields); } else { $formFields[] = FormManager::AddMessage(sprintf(__('Warning: We included %s.php, but it did not include a class of appropriate name.'), $i)); } } } $formFields[] = FormManager::AddCheckbox('doBackup', 'I agree I have a valid database backup and can restore it should the upgrade process fail', 0, __('It is important to take a database backup before running the upgrade wizard. A backup is essential for recovering your CMS should there be a problem with the upgrade.'), 'b'); // Return a rendered form Theme::Set('form_action', 'index.php?p=upgrade'); Theme::Set('form_fields', $formFields); Theme::Set('form_buttons', array(FormManager::AddButton(__('Next')))); return Theme::RenderReturn('form_render'); }