Example #1
0
 static function get_profile()
 {
     $profile = MObject::get('user', MAuth::user_id());
     if ($profile->get_id()) {
         return $profile;
     }
     return null;
 }
Example #2
0
 private function route($env)
 {
     $request = mapi_request();
     switch ($env) {
         case 'manager':
             if (isset($request['module'])) {
                 $this->set_module(MGet::string('module'));
             }
             if (isset($request['task'])) {
                 $this->set_task(MGet::string('task'));
             }
             if (isset($request['object'])) {
                 $this->set_num_object_id(MGet::string('object'));
             }
             break;
         case 'frontend':
             $routing = 'default';
             $pref = MObject::get('preference', 'routing');
             if ($pref && is_object($pref) && 'sef' == $pref->get_value()) {
                 $routing = 'sef';
             }
             // sef routing here
             if (isset($request['module'])) {
                 $this->set_module(MGet::string('module'));
             }
             if (isset($request['task'])) {
                 $this->set_task(MGet::string('task'));
             }
             if (isset($request['object'])) {
                 $this->set_num_object_id(MGet::string('object'));
             }
             break;
     }
     MAuth::init();
     if ('manager' == $env) {
         if ('register' != $this->module) {
             if ('login' != $this->module && !MAuth::is_auth()) {
                 $this->reset_to('login');
             } elseif ('login' == $this->module && MAuth::is_auth() && !isset($_POST['do-logout'])) {
                 $this->reset_to('dashboard');
             }
         } else {
             if (MAuth::is_auth()) {
                 $this->reset_to('dashboard');
             }
         }
         if ('login' != $this->module && 'register' != $this->module) {
             //if ( ! MAuth::check_perm( self::$this->module, $this->task ) ) $this->reset_to( 'denied' );
         }
     }
 }
Example #3
0
 public function login()
 {
     $this->set_page_title('#mappiamo - Login');
     if (isset($_POST['do-login'])) {
         if (isset($_POST['remember'])) {
             MAuth::$remember = true;
         }
         MAuth::do_login();
     }
     if (isset($_POST['do-logout'])) {
         MAuth::do_logout();
     }
     $this->view();
 }
Example #4
0
 public function update()
 {
     if (!MAuth::user_id()) {
         return null;
     }
     $user = null;
     if ($this->id && MValidate::id($this->id)) {
         $user = ORM::for_table('users')->find_one($this->id);
     }
     if (!$user || !$this->setup_object($user, true)) {
         return null;
     }
     $user->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     if (MAuth::user_id()) {
         $user->modifiedby = MAuth::user_id();
     } else {
         $user->modifiedby = 1;
     }
     if ($user->save()) {
         mapi_report_message('User data sucessfully updated.', 'success');
     }
 }
Example #5
0
  		<li><a href="index.php?module=muser&task=user_list">Users list <span class="glyphicon glyphicon-user"></span></a></li>
  		<li><a href="index.php?module=muser&task=user_add">Add new user <span class="glyphicon glyphicon-plus"></span></a></li>

  		<li class="divider"></li>

  		<li><a href="index.php?module=preferences">Preferences <span class="glyphicon glyphicon-cog"></span></a></li>

      <li class="divider"></li>

<?php 
}
?>

      <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php 
MPut::_html(MAuth::user());
?>
 <span class="caret"></span></a>
                <ul class="dropdown-menu">
                        <li>
                                <a href="index.php?module=profile">
                                        Profile <span class="glyphicon glyphicon-user"></span>
                                </a>
                        </li>
                        <li>
                                <a href="javascript:void(0)" onclick="$( '#logout-form' ).submit();">
                                        <form action="index.php?module=login" method="post" id="logout-form">
                                                <input type="hidden" name="do-logout" value="1" />
                                                Logout <span class="glyphicon glyphicon-off"></span>
                                        </form>
                                </a>
Example #6
0
 public function update($report = true)
 {
     if (!MAuth::user_id()) {
         return null;
     }
     $page = null;
     if ($this->id && MValidate::id($this->id)) {
         $page = ORM::for_table('pages')->find_one(intval($this->id));
     }
     if (!$page || !$this->setup_object($page)) {
         return null;
     }
     $page->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     $page->modifiedby = MAuth::user_id();
     if ($page->save() && $report) {
         mapi_report_message('Sucessfully updated.', 'success');
     }
 }
 protected function update_record()
 {
     if (!$this->permission()) {
         return mapi_report('No permission to edit this content');
     }
     $record = null;
     if ($this->id && MValidate::id($this->id)) {
         $record = ORM::for_table('contents')->find_one($this->id);
     }
     if (!$record || !$this->setup_object($record)) {
         return null;
     }
     $record->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     $record->modifiedby = MAuth::user_id();
     return $record;
 }
Example #8
0
 private static function setup_perms()
 {
     self::$perms = array('dashboard' => array('min' => 3), 'mcontent' => array('min' => 3), 'mcategory' => array('min' => 3), 'mpage' => array('min' => 2), 'mmenu' => array('min' => 2), 'mmodule' => array('min' => 1), 'mtemplate' => array('min' => 1), 'mwidget' => array('min' => 1), 'muser' => array('min' => 1), 'preferences' => array('min' => 1), 'majax' => array('min' => 3));
 }
Example #9
0
 public function __construct()
 {
     parent::__construct();
     $this->connect();
 }
Example #10
0
 public function update($report = true)
 {
     if (!$this->permission()) {
         return mapi_report('No permission to edit this category');
     }
     if (!MAuth::user_id()) {
         return null;
     }
     $category = null;
     if ($this->id && MValidate::id($this->id)) {
         $category = ORM::for_table('categories')->find_one(intval($this->id));
     }
     if (!$category || !$this->setup_object($category)) {
         return null;
     }
     $category->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     $category->modifiedby = MAuth::user_id();
     if ($category->save() && $report) {
         mapi_report_message('Your category was sucessfully updated.', 'success');
     }
 }