Exemple #1
0
 public function post_index()
 {
     $module = array('name' => Input::get('name'), 'controller' => Input::get('controller'), 'order' => Input::get('order'), 'description' => Input::get('description'));
     $new_module = Module::create($module);
     if ($new_module) {
         return Redirect::to_action('modules');
     }
 }
 public function run()
 {
     Module::create(array('name' => 'dictionaries', 'on' => 1, 'order' => 0));
     Module::create(array('name' => 'pages', 'on' => 1, 'order' => 1));
     Module::create(array('name' => 'galleries', 'on' => 1, 'order' => 2));
     Module::create(array('name' => 'seo', 'on' => 1, 'order' => 3));
     Module::create(array('name' => 'uploads', 'on' => 1, 'order' => 4));
     Module::create(array('name' => 'system', 'on' => 1, 'order' => 999));
 }
 public function postModule()
 {
     $json_request = array('status' => TRUE, 'responseText' => 'Сохранено');
     if ($module = Module::where('name', Input::get('name'))->first()) {
         $module->update(array('on' => Input::get('value')));
         $module->touch();
     } else {
         Module::create(array('name' => Input::get('name'), 'on' => Input::get('value')));
     }
     if (Input::get('value') == 1) {
         $json_request['responseText'] = "Модуль «" . SystemModules::getModules(Input::get('name'), 'title') . "» включен";
     } else {
         $json_request['responseText'] = "Модуль «" . SystemModules::getModules(Input::get('name'), 'title') . "» выключен";
     }
     #$json_request['responseText'] = print_r(SystemModules::getModules(Input::get('name')), 1);
     return Response::json($json_request, 200);
 }
Exemple #4
0
 function __construct()
 {
     /* load all the modules */
     global $MODULES;
     $modules = $MODULES;
     $init_params = array();
     foreach ($modules as $module_name) {
         $params = NULL;
         if (is_array($module_name) === true) {
             /* 1st element is module name, others are constructor params */
             $params = $module_name;
             $module_name = array_shift($params);
         }
         $init_params[$module_name] = $params;
         $mod = Module::create($this, $module_name);
         if ($mod === NULL) {
             error_log('fatal; invalid module: ' . print_r($module_name, true));
             die;
         }
         /* reverse array so its in 'get' order, as thats more common */
         array_unshift($this->_modules, $mod);
     }
     /* tell the modules setup is complete - bottom up */
     $this->_init($init_params);
 }
Exemple #5
0
 public function action_cabinet()
 {
     // Не авторизован
     if (!Auth::instance()->logged_in()) {
         HTTP::redirect("/user/auth");
     }
     // action правого блока и title страницы
     $cabinet_content_action = $this->request->param("id");
     switch ($this->request->param("id")) {
         default:
             $title = 'Личный кабинет';
             $cabinet_content_action = 'index';
             break;
         case "order":
             $title = 'Детали заказа';
             break;
         case "orders":
             $title = 'Заказы';
             break;
         case "settings":
             $title = 'Настройки';
             break;
     }
     $this->title($title);
     $this->page_title($title);
     $this->keywords($title);
     $this->description($title);
     $model = array("title" => $title, "modules" => array());
     // Боковое меню кабинета
     $model["modules"]["left_menu"] = Module::create(array("controller" => "user/cabinet/Left_Menu", "action" => "index", "options" => array()))["body"];
     // Правый блок кабинета
     $model["modules"]["cabinet_content"] = Module::create(array("controller" => "user/cabinet/Cabinet_Content", "action" => $cabinet_content_action, "options" => array()))["body"];
     $this->render('user/cabinet/cabinet.php', $model, "response");
 }
Exemple #6
0
 function create()
 {
     $this->model->required[] = 'password';
     $this->model->add_validation('email', array(&$this->model, 'is_new_email'), 'The email is empty or already exists');
     parent::create();
 }
function module_create_form_submit($data)
{
    /*
     * Validating information on the Database
     */
    $error = validate_module_info($data);
    if ($error) {
        natural_set_message($error, 'error');
        return FALSE;
        exit(0);
    }
    $data['project_path'] = NATURAL_WEB_ROOT;
    $data['project_name'] = NATURAL_PLATFORM;
    $data['field_1'] = 'name';
    $data['field_label_1'] = 'Name';
    $data['field_2'] = 'author';
    $data['field_label_2'] = 'Author';
    $data['module'] = $data['label'];
    if (is_numeric($data['table_name'])) {
        $class_name = str_replace("_", " ", $data['module']);
        $data['module_name'] = $data['module'];
        $data['module'] = str_replace(" ", "_", strtolower($data['module']));
    } else {
        $class_name = str_replace("_", " ", $data['table_name']);
        $data['module_name'] = $data['table_name'];
        $data['module'] = str_replace(" ", "_", strtolower($data['table_name']));
        $query = "DESCRIBE " . "" . $data['table_name'] . "";
        $pdo = new PDO(NATURAL_PDO_DSN_READ, NATURAL_PDO_USER_READ, NATURAL_PDO_PASS_READ);
        $q = $pdo->prepare($query);
        $q->execute();
        $columns = $q->fetchAll(PDO::FETCH_COLUMN);
        if (count($columns) > 0) {
            for ($i = 1; $i < 3; $i++) {
                $key = 'field_' . $i;
                $keylabel = 'field_label_' . $i;
                //$data[key] = 'b.name';
                $data[$key] = $columns[$i];
                //$data[$keylabel] = 'Name';
                $data[$keylabel] = ucwords(str_replace("_", " ", strtolower($columns[$i])));
            }
        }
    }
    $class_name = ucwords($class_name);
    $data['class_name'] = str_replace(" ", "", $class_name);
    //$data['path'] = NATURAL_WEB_ROOT . "modules/" . $data['module'] . "/";
    $data['path'] = '../' . $data['module'] . '/';
    //Creating directory for the module
    create_module_structure($data);
    if ($data['create_api'] == 1) {
        create_module_api($data);
    }
    if ($data['create_forms'] == 1) {
        //calling function on natural module module/natural/natural.func.php
        create_form($data['module_name']);
    }
    if ($data['create_class']) {
        //create_module_class($data);
    }
    if ($data['create_menu'] == 1) {
        create_module_menu($data);
    }
    //Saving information to the Natural Database
    $module = new Module();
    $submit['version'] = 1;
    $submit['module'] = strtolower(str_replace(" ", "_", $data['module']));
    $submit['label'] = ucwords($data['label']);
    $submit['description'] = ucwords($data['label']);
    $submit['license_quantity'] = 0;
    $submit['last_update'] = date("Y-m-d H:i:s");
    $submit['status'] = 1;
    $response = $module->create($submit);
    if ($response['id'] > 0) {
        return module_list($response['id']);
    } else {
        return false;
    }
    if ($module->affected) {
        natural_set_message('Module ' . $data['module'] . ' created successfully!', 'success');
        return module_list($module->id);
    } else {
        natural_set_message('Could not save this Module at this time', 'error');
        return false;
    }
}
Exemple #8
0
 function create()
 {
     $redirect = !isset($_POST['send_email']);
     $id = parent::create($redirect);
     $this->_send_email($id);
 }
 public function run()
 {
     Module::create(array('name' => 'system', 'on' => 1, 'order' => 999));
 }
Exemple #10
0
 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);
     }
 }