Exemplo n.º 1
0
 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());
     }
 }
Exemplo n.º 2
0
 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()));
 }
Exemplo n.º 3
0
 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...'));
         }
     }
 }
Exemplo n.º 4
0
 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'));
 }
Exemplo n.º 5
0
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>


Exemplo n.º 6
0
 public function onAfterSave()
 {
     Flash::success(t('Record saved'));
     redirect(current_path());
 }
Exemplo n.º 7
0
function demo_check()
{
    // demo protection
    if (is_demo()) {
        \Meta\Flash::warning(demo_msg());
        redirect(current_path());
    }
}
Exemplo n.º 8
0
 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>'));
     }
 }
Exemplo n.º 9
0
 public function onDelete()
 {
     \Meta\Db::delete($this->table, array('id' => $_GET['id']));
     \Meta\Flash::success(t('Record deleted'));
     redirect(current_path());
 }