public function action_room() { $base = new Model_Base(); $options = $base->getOptions(); if (!isset($options['room']) || $options['room'] != 'TRUE') { Controller::redirect('/'); } $this->template->title = 'Личный кабинет'; $this->template->page_title = 'Личный кабинет'; $this->template->keywords = 'Личный кабинет'; $this->template->description = 'Личный кабинет'; $data = array(); $errors = array(); $widgets = $this->getWidgets(0); $auth = Auth::instance(); // var_dump($auth->hash($_POST['password'])); if (is_array($widgets)) { foreach ($widgets as $position => $widget) { $this->template->{$position} = $widget; } } if (!$auth->logged_in('visitor')) { if (isset($_POST['login'])) { $username = Arr::get($_POST, 'username', ''); $password = Arr::get($_POST, 'password', ''); if ($auth->login($username, $password)) { //print('Залогинен'); $session = Session::instance(); $auth_redirect = $session->get('auth_redirect', ''); $session->delete('auth_redirect'); Controller::redirect('/user'); } else { //print('Ошибка'); $errors[] = 'Не верный логин или пароль.'; } } $this->template->block_center[] = View::factory('widgets/w_auth')->bind('errors', $errors); } else { $param = $this->request->param('act'); $materals = new Model_Material('group'); //получаем пользователя $user = $auth->get_user(); if ($param == 'show') { $user_orders = Module::create(array("controller" => "user/cabinet/orders", "action" => "index", "options" => array())); //echo $user_orders["body"]; //получаем материалы пользователя $data['materials'] = $materals->getUserMaterials($user->id); //$this->template->block_center[] = $user_orders["body"]; //return new View($file, $data); /*$page = View::factory('widgets/w_room') ->bind('errors', $errors) ->bind('messages', $messages) ->bind('data', $data); var_dump($page);*/ // --- tests ------------------------------------------------------------- $this->template->title = 'Личный кабинет'; $this->template->page_title = 'Личный кабинет'; $this->template->keywords = 'Личный кабинет'; $this->template->description = 'Личный кабинет'; $auth = Auth::instance(); if ($auth->logged_in() != 0) { $this->template->content = View::factory('admin/admIndex'); } else { $this->template->content = View::factory('admin/admLogin'); if (isset($_POST['enter'])) { $username = Arr::get($_POST, 'username', ''); $password = Arr::get($_POST, 'password', ''); if ($auth->login($username, $password)) { //print('Залогинен'); $session = Session::instance(); $auth_redirect = $session->get('auth_redirect', ''); $session->delete('auth_redirect'); Controller::redirect($auth_redirect); } else { //print('Ошибка'); $this->template->error = 'Не верный логин или пароль.'; } } } // --- tests ------------------------------------------------------------- //exit(); } elseif ($param == 'edit') { $materialId = $this->request->param('id'); //получаем материал $data['material'] = $materals->getMaterial($materialId, $user->id); if ($data['material']) { $gid = $materals->getGroupFromMid($materialId); $data['fieldset'] = $materals->getFieldsSet($gid); //получаем поля $data['fields'] = $materals->getFields($materialId, TRUE); } else { $errors[] = 'Данный материал не найден'; } } elseif ($param == 'settings') { if (isset($_POST['save_settings'])) { //сохраняем настройки $modelUser = new Model_User(); $res = $modelUser->saveUser($_POST, $user->id); if (is_array($res)) { $errors = $res; } else { $messages[] = $res; } } $data['user'] = ORM::factory('User', array('id' => $user->id)); } $this->template->block_center[] = View::factory('widgets/w_room')->bind('errors', $errors)->bind('messages', $messages)->bind('data', $data); } }