/** * Loads our index/default welcome/dashboard screen */ public function view() { $form = new Form('config'); // add all config variables to our form $sql = sprintf('SELECT * FROM config'); $model = model()->open('config'); $records = $model->results(); if ($records) { foreach ($records as $record) { $value = $record['current_value'] == '' ? $record['default_value'] : $record['current_value']; $form->addField($record['config_key'], $value, $value); } } // process the form if submitted if ($form->isSubmitted()) { foreach (app()->params->getRawSource('post') as $field => $value) { $model->update(array('current_value' => $value), $field, 'config_key'); } sml()->say('Website settings have been updated successfully.'); router()->redirect('view'); } $data['form'] = $form; $model = model()->open('pages'); $model->where('page_is_live', 1); $data['pages'] = $model->results(); // $data['mods'] = app()->moduleControls(); $data['themes'] = $this->listThemes(); $data['live'] = settings()->getConfig('active_theme'); template()->addCss('style.css'); template()->addJs('admin/jquery.qtip.js'); template()->addJs('view.js'); template()->display($data); }
<h2><span>Currently Editing:</span> <?php print $form->cv('title'); ?> </h2> <?php } else { ?> <h2>Add News Item</h2> <?php } ?> <?php echo $form->printErrors(); ?> <?php echo sml()->printMessage(); ?> <form action="<?php print $this->action(); ?> " method="post" enctype="multipart/form-data"> <div class="frame"> <h3>News Details</h3> <fieldset> <ol> <li> <label for="title">Article Title:</label> <input id="title" name="title" type="text" value="<?php print htmlentities($form->cv('title'), ENT_QUOTES, 'UTF-8'); ?> " />
/** * Displays and processes the forgotten password reset form * @access public */ public function forgot() { if (user()->forgot() == 1) { sml()->say(text('users:forgot:say:success'), true); router()->redirect('login'); } elseif (user()->forgot() == -1) { sml()->say(text('users:forgot:say:error'), false); router()->redirect('forgot'); } template()->display(); }
/** * @abstract Deletes a single news record * @param integer $id * @access public */ public function delete($id = false) { if (model()->open('news')->delete($id)) { sml()->say('News entry has successfully been deleted.'); router()->redirect('view'); } }
/** * @abstract Deletes a menu item * @param integer $id * @access public */ public function delete($id) { $model->delete('courses', $id); sml()->say('The course has successfully been deleted.'); router()->redirect('view'); }
/** * @abstract Deletes a single news record * @param integer $id * @access public */ public function delete($id = false) { if (model()->open('forms')->delete($id)) { sml()->say('Your form has successfully been deleted.'); router()->redirect('view'); } }
/** * Displays the login failed message and returns to login * @access public */ public function login_failed() { sml()->say(text('users:login:say:error'), false); router()->redirect('users/login'); }
/** * @abstract Used to run uninstallation code from module * @param string $guid * @access public */ public function uninstall_module($guid) { // load the module and run the uninstall code $tmp_reg = app()->moduleRegistry($guid); if (isset($tmp_reg->classname)) { $classname = $tmp_reg->classname . (LOADING_SECTION ? '_' . LOADING_SECTION : false); app()->loadModule($guid); // call module uninstall function if available if (method_exists(app()->{$classname}, 'uninstall')) { app()->{$classname}->uninstall($guid); } // remove all connections from databases $model->query('DELETE FROM modules WHERE guid = "' . $guid . '"'); $model->query('UPDATE modules SET autoload_with = "" WHERE autoload_with = "' . $guid . '"'); $model->query('DELETE FROM permissions WHERE module = "' . $tmp_reg->classname . '"'); sml()->say('The ' . $tmp_reg->classname . ' module has been uninstalled successfully.'); } app()->router->returnToReferrer(); }
/** * Pulls and allows easy POSTing of configuration values. */ public function edit($user_id = NULL) { // Load the prefs we're allowed to edit $edit_prefs = app()->config('preference_configs_to_edit'); // Set the current/default values $record = array(); foreach ($edit_prefs as $pref) { $record[$pref] = app()->settings->getConfig($pref, $user_id); } // process the form if submitted if (post()->keyExists('preferences-submit')) { $config = model()->open('config'); foreach ($record as $field => $existing_value) { $record[$field] = post()->getRaw($field); $config->query(sprintf('DELETE FROM config WHERE config_key = "%s" AND user_id = "%s"', $field, $user_id)); $config->insert(array('current_value' => $record[$field], 'config_key' => $field, 'user_id' => $user_id)); } sml()->say('Your user preferences have been saved successfully.', true); } return new Prefs($record); }
/** * @abstract Deletes an event record * @param integer $id * @access public */ public function delete($id) { model()->open('contacts')->delete($id); sml()->say('Contact has successfully been deleted.'); router()->redirect('view'); }
/** * @abstract Displays and processes the forgotten password reset form * @access public */ public function forgot() { if (user()->forgot() == 1) { sml()->say('Your password has been reset. Please check your email.'); router()->redirect('login'); } elseif (user()->forgot() == -1) { sml()->say('We were unable to find any accounts matching that username.'); router()->redirect('forgot'); } template()->addView(template()->getTemplateDir() . DS . 'header.tpl.php'); template()->addView(template()->getModuleTemplateDir() . DS . 'forgot.tpl.php'); template()->addView(template()->getTemplateDir() . DS . 'footer.tpl.php'); template()->display(); }
/** * @abstract Deletes a page * @param integer $id * @access public */ public function delete($id = false) { if ($id) { app()->db->Execute(sprintf("DELETE FROM pages WHERE page_id = %s", app()->security->dbescape((int) $id))); app()->db->Execute(sprintf("UPDATE pages SET parent_id = 0 WHERE parent_id = %s", app()->security->dbescape((int) $id))); sml()->say('Page has been deleted successfully.'); router()->redirect('view'); } }