public static function checkDbTables() { // database tables installer if (!\Meta\Db::tableExists('db_migrations')) { // import the whole initial databse file \Meta\Db::execute(file_get_contents(abspath('sql/database.sql'))); Flash::success(t('Database imported.')); redirect(page_home()); } }
public function onValidated() { $uid = \User\User::logged()->id; $data = $this->getData(); Db::saveSafe('users', $data); Flash::success(t('Profile saved')); // change password $pass = $data['password_new']; if (strlen($pass) > 0) { Db::update('users', array('password' => md5($pass)), array('id' => $uid)); Flash::success(t('Password changed')); } redirect(url(current_path())); }
private function proccessForm() { // submit if ($this->hasSubmitted()) { foreach ($this->fields as $field) { $field instanceof Field; $field->proccessField($this); } if ($this->validateForm()) { $this->onValidated(); } else { Flash::error(t('One or more problem(s) occurred with the form...')); } } }
public function onBeforeRender() { // logout actin if (is_action('logout')) { User::logout(); redirect(page_home()); } // login form if (is_post()) { $username = filter_input(INPUT_POST, 'username'); $password = filter_input(INPUT_POST, 'password'); $backTo = filter_input(INPUT_GET, 'back_to'); if (User::authenticate($username, $password)) { $url = strlen($backTo) > 0 ? urldecode($backTo) : page_home(); redirect($url); } else { Flash::error(t('Invalid username or password!')); } } $this->add(render('user-login.php')); }
if ($title) { ?> <div class="row"> <div class="col-lg-12"> <h3 class="page-header"><?php echo $title; ?> </h3> </div> <!-- /.col-lg-12 --> </div> <?php } ?> <?php echo \Meta\Flash::getMessages(); ?> <?php echo $content; ?> </div> <!-- /#page-wrapper --> </div> <!-- /#wrapper --> <!-- Metis Menu Plugin JavaScript --> <script src="public/sb-admin2/bower_components/metisMenu/dist/metisMenu.min.js"></script>
public function onAfterSave() { Flash::success(t('Record saved')); redirect(current_path()); }
function demo_check() { // demo protection if (is_demo()) { \Meta\Flash::warning(demo_msg()); redirect(current_path()); } }
public static function init() { if (!is_writable(\Meta\FileSystem::getFilesPath())) { \Meta\Flash::warning(t('The file system directory is not writable. To set permission, type: <b>chmod 777 ' . \Meta\FileSystem::getFilesPath() . ' -R</b>')); } }
public function onDelete() { \Meta\Db::delete($this->table, array('id' => $_GET['id'])); \Meta\Flash::success(t('Record deleted')); redirect(current_path()); }