Ejemplo n.º 1
0
 public function uploadLogo($Id = NULL)
 {
     if ($Id != NULL) {
         $partner_model = $this->Partner_model->getById($Id);
         if ($partner_model != NULL) {
             $uplPath = $this->config->item('resource_folder') . '/Logo';
             $uplConfig['upload_path'] = $uplPath;
             //$uplConfig['allowed_types'] = $this->config->item('video_allowed_type');
             // TODO [hdang.sea] : using specific types is not successfull now
             $uplConfig['allowed_types'] = '*';
             $this->load->library('upload', $uplConfig);
             if ($this->upload->do_upload('Logo')) {
                 $data = $this->upload->data();
                 $resource = new Resource_model();
                 $resource->Path = $uplPath . '/' . $data['file_name'];
                 $resourceId = $resource->save();
                 $oldResource = $this->Resource_model->getById($partner_model->IdLogo);
                 $partner_model->Path = $resource->Path;
                 $partner_model->IdLogo = $resourceId;
                 $partner_model->save();
                 $resource->Id = $resourceId;
                 $oldResource->delete($oldResource->Id);
                 echo 1;
             }
         }
     }
 }
Ejemplo n.º 2
0
Archivo: menu.php Proyecto: trk/ionize
 /**
  * Menus list
  *
  */
 function index()
 {
     $menus = $this->menu_model->get_list(array('order_by' => 'ordering ASC'));
     foreach ($menus as &$menu) {
         $backend_roles_resources = $this->resource_model->get_element_roles_resources('menu', $menu['id_menu'], self::$_AUTHORITY_BACKEND_ACTIONS, 'backend');
         $menu['backend_roles_resources'] = $backend_roles_resources;
         $menu['backend_role_ids'] = $this->rule_model->get_element_role_ids('menu', $menu['id_menu'], 'backend');
     }
     $this->template['menus'] = $menus;
     $this->output('menu/index');
 }
Ejemplo n.º 3
0
 public function uploadBanner($Id = NULL)
 {
     if ($Id != NULL) {
         $banner_model = $this->Banner_model->getById($Id);
         if ($banner_model != NULL) {
             $uplPath = $this->config->item('resource_folder') . '/banner';
             $uplConfig['upload_path'] = $uplPath;
             $uplConfig['allowed_types'] = $this->config->item('img_allowed_type');
             $uplConfig['max_size'] = $this->config->item('img_max_size');
             $uplConfig['max_width'] = $this->config->item('img_max_width');
             $uplConfig['max_height'] = $this->config->item('img_max_height');
             $this->load->library('upload', $uplConfig);
             if ($this->upload->do_upload('imgBanner')) {
                 $data = $this->upload->data();
                 $resource = new Resource_model();
                 $resource->Path = $uplPath . '/' . $data['file_name'];
                 $resourceId = $resource->save();
                 $oldResource = $this->Resource_model->getById($banner_model->IdResource);
                 $banner_model->IdResource = $resourceId;
                 $tempId = $banner_model->save();
                 $oldResource->delete();
                 echo base_url() . $resource->Path;
             }
         }
     }
 }
Ejemplo n.º 4
0
 public function get_options($rel)
 {
     // IDs
     $rel = explode(".", $rel);
     $id_page = !empty($rel[1]) ? $rel[0] : '0';
     $id_article = !empty($rel[1]) ? $rel[1] : NULL;
     $resource = $this->_get_resource_name('backend', 'article', $id_article);
     if (Authority::can('edit', $resource, NULL, TRUE)) {
         // Edit article if ID exists
         if (!is_null($id_article)) {
             $article = $this->article_model->get_by_id($id_article);
             if (!empty($article)) {
                 $this->load_modules_addons($article);
                 // Page context of the current edited article
                 $article['id_page'] = $id_page;
                 // Merge article's data with template
                 $this->template = array_merge($this->template, $article);
                 $this->article_model->feed_lang_template($id_article, $this->template);
                 // Add article types to template
                 $data = $this->article_type_model->get_types_select();
                 if (!empty($data)) {
                     $data = array('' => lang('ionize_select_no_type')) + $data;
                     $this->template['all_article_types'] = $data;
                 } else {
                     $this->template['all_article_types'] = NULL;
                 }
                 $this->template['article_type_current'] = $article['id_type'];
                 // Linked pages list
                 $this->template['pages_list'] = $this->article_model->get_pages_list($id_article);
                 // Categories
                 $categories = $this->category_model->get_categories_select();
                 $current_categories = $this->category_model->get_current_categories('article', $id_article);
                 $this->template['categories'] = form_dropdown('categories[]', $categories, $current_categories, 'class="select w100p" multiple="multiple"');
                 // Permissions
                 $frontend_roles_resources = $this->resource_model->get_element_roles_resources('article', $id_article, self::$_AUTHORITY_FRONTEND_ACTIONS, 'frontend');
                 $this->template['frontend_roles_resources'] = $frontend_roles_resources;
                 $backend_roles_resources = $this->resource_model->get_element_roles_resources('article', $id_article, self::$_AUTHORITY_BACKEND_ACTIONS, 'backend');
                 $this->template['backend_roles_resources'] = $backend_roles_resources;
                 // Default Deny Action
                 if (empty($article['deny_code'])) {
                     $this->template['deny_code'] = '404';
                 }
                 // Roles which have permission set for this page
                 $this->template['frontend_role_ids'] = $this->rule_model->get_element_role_ids('article', $id_article);
                 $this->template['backend_role_ids'] = $this->rule_model->get_element_role_ids('article', $id_article, 'backend');
                 // Output
                 $this->output('article/options');
             } else {
                 // Article not found
                 $this->error(lang('ionize_message_article_not_exist'));
             }
         } else {
             // Article not found
             $this->error(lang('ionize_message_article_not_exist'));
         }
     } else {
         $this->output(self::$_DENY_DEFAULT_VIEW);
     }
 }
Ejemplo n.º 5
0
Archivo: role.php Proyecto: trk/ionize
 /**
  * Edit
  *
  */
 public function edit()
 {
     $role = $this->role_model->get($this->input->post('id_role'));
     $this->template['role'] = $role;
     // Get roles list
     // TODO: Filter roles on level ?
     $roles = $this->role_model->get_list();
     $this->template['roles'] = array_filter($roles, array($this, '_filter_roles'));
     // All Admin Resources
     $resources = $this->resource_model->get_tree();
     $this->template['json_resources'] = json_encode($resources, TRUE);
     // All Modules Resources
     $modules_resources = Modules()->get_resources();
     $resources = $this->resource_model->build_resources_tree($modules_resources);
     $this->template['json_modules_resources'] = json_encode($resources, TRUE);
     // Role's permissions
     $rules = $this->rule_model->get_list(array('id_role' => $role['id_role']));
     $this->template['has_all'] = $this->_has_all_permissions($rules);
     $this->template['json_rules'] = json_encode($rules, TRUE);
     $this->output('role/edit');
 }
Ejemplo n.º 6
0
Archivo: page.php Proyecto: trk/ionize
 /**
  * Displays the options side panel
  *
  * @param   int		$id_page     Page ID
  *
  */
 public function get_options($id_page)
 {
     $resource = $this->_get_resource_name('backend', 'page', $id_page);
     if (Authority::can('edit', $resource, null, true)) {
         // Data
         $page = $this->page_model->get_by_id($id_page);
         if (!empty($page)) {
             // Correct the menu ID (for phantom pages)
             if ($page['id_menu'] == '0') {
                 $page['id_menu'] = '1';
             }
             // Page data
             $this->template = array_merge($this->template, $page);
             $this->page_model->feed_lang_template($id_page, $this->template);
             // Load the module's addons
             $this->load_modules_addons($page);
             // Dropdown menus
             $data = $this->menu_model->get_select();
             $this->template['menus'] = form_dropdown('id_menu', $data, $this->template['id_menu'], 'id="id_menu" class="select"');
             // Subnav menu
             $subnav_page = $this->page_model->get_by_id($page['id_subnav']);
             $selected_subnav = !empty($subnav_page['id_menu']) ? $subnav_page['id_menu'] : '-1';
             $this->template['subnav_menu'] = form_dropdown('id_subnav_menu', $data, $selected_subnav, 'id="id_subnav_menu" class="select"');
             // Dropdown Views
             $views = array();
             if (is_file(FCPATH . 'themes/' . Settings::get('theme') . '/config/views.php')) {
                 require_once FCPATH . 'themes/' . Settings::get('theme') . '/config/views.php';
             }
             // Dropdown Page views
             $data = isset($views['page']) ? $views['page'] : array();
             if (count($data) > 0) {
                 $data = $this->_get_views_dropdown_data($data, 'Page');
                 $data = array('' => lang('ionize_select_default_view')) + $data;
                 $this->template['views'] = form_dropdown('view', $data, $this->template['view'], 'class="select"');
                 $this->template['single_views'] = form_dropdown('view_single', $data, $this->template['view_single'], 'class="select"');
             }
             // Dropdown article list views (templates)
             $data = isset($views['article']) ? $views['article'] : array();
             if (count($data) > 0) {
                 $data = $this->_get_views_dropdown_data($data, 'Article');
                 $data = array('' => lang('ionize_select_default_view')) + $data;
                 $this->template['article_list_views'] = form_dropdown('article_list_view', $data, $this->template['article_list_view'], 'class="select"');
                 $this->template['article_views'] = form_dropdown('article_view', $data, $this->template['article_view'], 'class="select"');
             }
             // Roles & Rules
             $frontend_roles_resources = $this->resource_model->get_element_roles_resources('page', $id_page, self::$_AUTHORITY_FRONTEND_ACTIONS, 'frontend');
             $this->template['frontend_roles_resources'] = $frontend_roles_resources;
             $backend_roles_resources = $this->resource_model->get_element_roles_resources('page', $id_page, self::$_AUTHORITY_BACKEND_ACTIONS, 'backend');
             $this->template['backend_roles_resources'] = $backend_roles_resources;
             // Roles which have permission set for this page
             $this->template['frontend_role_ids'] = $this->rule_model->get_element_role_ids('page', $id_page);
             $this->template['backend_role_ids'] = $this->rule_model->get_element_role_ids('page', $id_page, 'backend');
             // Default Deny Action
             if (empty($page['deny_code'])) {
                 $this->template['deny_code'] = '404';
             }
             // Types
             $types = $this->type_model->get_select('page', lang('ionize_select_no_type'));
             if (count($types) > 1) {
                 $this->template['types'] = form_dropdown('id_type', $types, $this->template['id_type'], 'class="select"');
             }
             // Categories
             $categories = $this->category_model->get_categories_select();
             $current_categories = $this->category_model->get_current_categories('page', $id_page);
             $this->template['categories'] = form_dropdown('categories[]', $categories, $current_categories, 'class="select w100p" multiple="multiple"');
             // Output
             $this->output('page/options');
         } else {
             $this->error(lang('ionize_message_page_not_exist'));
         }
     }
 }
Ejemplo n.º 7
0
 protected function handleEditValidationSuccess($account, $site = '')
 {
     if ($account->Id == NULL) {
         $uplPath = $this->config->item('resource_folder') . '/account';
         $uplConfig['upload_path'] = $uplPath;
         $uplConfig['allowed_types'] = $this->config->item('img_allowed_type');
         $uplConfig['max_size'] = $this->config->item('img_max_size');
         $uplConfig['max_width'] = $this->config->item('img_max_width');
         $uplConfig['max_height'] = $this->config->item('img_max_height');
         $this->load->library('upload', $uplConfig);
         if ($this->upload->do_upload('imgAvatar')) {
             $data = $this->upload->data();
             $resource = new Resource_model();
             $resource->Path = $uplPath . '/' . $data['file_name'];
             $resourceId = $resource->save();
         } else {
             $this->addDataForView($this->getModelVariableName(), $account);
             $this->addDataForView('err', $this->upload->display_errors('<div>', '</div>'));
             $this->template->load($this->template_admin, $this->getEditViewName(), $this->getDataForView());
             return;
         }
         if (isset($resourceId)) {
             $account->AvatarId = $resourceId;
         }
     }
     parent::handleEditValidationSuccess($account, $site);
 }
Ejemplo n.º 8
0
 public function uploadVideo($Id = NULL)
 {
     if ($Id != NULL) {
         $video_model = $this->Video_model->getById($Id);
         if ($video_model != NULL) {
             $uplPath = $this->config->item('resource_folder') . '/video';
             $uplConfig['upload_path'] = $uplPath;
             //$uplConfig['allowed_types'] = $this->config->item('video_allowed_type');
             // TODO [hdang.sea] : using specific types is not successfull now
             $uplConfig['allowed_types'] = '*';
             $this->load->library('upload', $uplConfig);
             if ($this->upload->do_upload('fileVideo')) {
                 $data = $this->upload->data();
                 $outputFile = $this->convertVideo($uplPath . '/' . $data['file_name']);
                 if ($outputFile) {
                     $resource = new Resource_model();
                     $resource->Path = $outputFile;
                     $resourceId = $resource->save();
                     $oldResource = $this->Resource_model->getById($video_model->IdResource);
                     $video_model->IdResource = $resourceId;
                     $tempId = $video_model->save();
                     $oldResource->delete();
                     echo $resourceId;
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
 public function uploadDocument($Id = NULL)
 {
     if ($Id != NULL) {
         $videoDocument_model = $this->VideoDocument_model->getById($Id);
         if ($videoDocument_model != NULL) {
             $uplPath = $this->config->item('resource_folder') . '/videoDocument';
             $uplConfig['upload_path'] = $uplPath;
             //$uplConfig['allowed_types'] = $this->config->item('video_allowed_type');
             // TODO [hdang.sea] : using specific types is not successfull now
             $uplConfig['allowed_types'] = '*';
             $this->load->library('upload', $uplConfig);
             if ($this->upload->do_upload('fileDocument')) {
                 $data = $this->upload->data();
                 $resource = new Resource_model();
                 $resource->Path = $uplPath . '/' . $data['file_name'];
                 $videoDocument_model->FileName = $data['file_name'];
                 $resourceId = $resource->save();
                 $oldResource = $this->Resource_model->getById($videoDocument_model->IdResource);
                 $videoDocument_model->IdResource = $resourceId;
                 $videoDocument_model->save();
                 $resource->Id = $resourceId;
                 $query = "SELECT * FROM video_videoDocument where IdVideo=? AND IdDocument=?";
                 $video_videoDocument = $this->db->query($query, array($oldResource, $videoDocument_model->Id));
                 if (!isset($video_videoDocument)) {
                     $video_videoDocument->IdDocument = $resourceId;
                     $video_videoDocument->save();
                 }
                 $oldResource->delete();
                 echo 1;
             }
         }
     }
 }