private function saveProcess()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         View::setMessageFlash("danger", "Form tidak valid");
         return FALSE;
     }
     // form validation
     if (!filter_input(INPUT_POST, "form_token") || Form::isFormTokenValid(filter_input(INPUT_POST, "form_token"))) {
         View::setMessageFlash("danger", "Form tidak valid");
         return FALSE;
     }
     // required fields
     $filter = array("name" => FILTER_SANITIZE_STRING, "phone" => FILTER_SANITIZE_STRING, "address" => FILTER_SANITIZE_STRING);
     $input = filter_input_array(INPUT_POST, $filter);
     if (in_array('', $input) || in_array(NULL, $input)) {
         View::setMessageFlash("danger", "Kolom tidak boleh kosong");
         return FALSE;
     }
     // set member object
     $staff = Authentication::getUser();
     $staff->setData('name', $input['name']);
     $staff->setData('phone', $input['phone']);
     $staff->setData('address', $input['address']);
     if (!($update = $staff->update())) {
         View::setMessageFlash("danger", "Penyimpanan Gagal");
         return;
     }
     View::setMessageFlash("success", "Penyimpanan Berhasil");
 }
Exemple #2
0
 public static function getMenu()
 {
     $menus = array();
     /**
      * collect menu by role, also add active parent and menu
      */
     $user_role = Authentication::getUser()->getRole();
     foreach (self::$menu_collection as $slug => $menu) {
         if ($menu['role'] == 'all' || in_array($user_role, $menu['role'])) {
             // set active
             if (count($menu['sub']) > 0) {
                 if (self::$activeParent == $slug) {
                     $menu['active'] = "active";
                     $menu['open'] = "open";
                 }
             } else {
                 if (self::$activeMenu == $slug) {
                     $menu['active'] = "active";
                 }
             }
             $submenu = $menu['sub'];
             $menu['sub'] = array();
             foreach ($submenu as $slug => $sub) {
                 if (self::$activeMenu == $slug) {
                     $sub['active'] = "active";
                 }
                 if ($sub['role'] == 'all' || in_array($user_role, $sub['role'])) {
                     array_push($menu['sub'], $sub);
                 }
             }
             array_push($menus, $menu);
         }
     }
     return $menus;
 }
Exemple #3
0
 public function render()
 {
     $this->data['user'] = Authentication::getUser()->getData();
     $this->data['content'] = $this->content;
     View::renderPage($this->view, $this->setup, $this->data);
 }