Пример #1
0
 /**
  * Display a list of EmbedContent data.
  *
  * @return void
  */
 public function index($offset = 0)
 {
     // Deleting anything?
     if (isset($_POST['delete'])) {
         $this->auth->restrict($this->permissionDelete);
         $checked = $this->input->post('checked');
         if (is_array($checked) && count($checked)) {
             // If any of the deletions fail, set the result to false, so
             // failure message is set if any of the attempts fail, not just
             // the last attempt
             $result = true;
             foreach ($checked as $pid) {
                 /*******Physically delete the template from its location******/
                 $template_to_be_deleted = $this->embedcontent_model->find_by('id', $pid);
                 $file_to_delete = $template_to_be_deleted->name;
                 $deletepath = $this->config->item('smartembed_static_site_location') . $file_to_delete;
                 $is_file_delete = false;
                 /////////////////////////////////////////////////////////////////////
                 $is_file_delete = deleteFolderAndAllFiles($deletepath);
                 /********************************************/
                 $deleted = $this->embedcontent_model->delete($pid);
                 if ($deleted == false || $is_file_delete == false) {
                     $result = false;
                 }
             }
             if ($result) {
                 Template::set_message(count($checked) . ' ' . lang('embedcontent_delete_success'), 'success');
             } else {
                 Template::set_message(lang('embedcontent_delete_failure') . $this->embedcontent_model->error, 'error');
             }
         }
     }
     $pagerUriSegment = 5;
     $pagerBaseUrl = site_url(SITE_AREA . '/embeds/embedcontent/index') . '/';
     $limit = $this->settings_lib->item('site.list_limit') ?: 15;
     $this->load->library('pagination');
     $pager['base_url'] = $pagerBaseUrl;
     $pager['total_rows'] = $this->embedcontent_model->count_all();
     $pager['per_page'] = $limit;
     $pager['uri_segment'] = $pagerUriSegment;
     $this->pagination->initialize($pager);
     $this->embedcontent_model->limit($limit, $offset);
     $records = $this->embedcontent_model->find_all();
     $templatenames = array();
     if ($records) {
         foreach ($records as $record) {
             $name = $this->templates_model->getTemplateById((string) $record->templateid)->name;
             array_push($templatenames, $name);
         }
         Template::set('templatenames', $templatenames);
     }
     Template::set('records', $records);
     Template::set('toolbar_title', lang('embedcontent_manage'));
     Template::render();
 }
Пример #2
0
 protected function delete_related_records($primary_key)
 {
     $this->load->model('editedembed/editedembed_model');
     $this->load->model('history/history_model');
     $this->load->helper('manage_files');
     if (!is_null($primary_key)) {
         $wheres = array('embedid' => $primary_key);
         //clean up the public iframe folder
         $this->history_model->delete_where($wheres);
         $editedembeds = $this->editedembed_model->where_in('embedid', $primary_key)->find_all();
         if ($editedembeds == null) {
             return true;
         }
         foreach ($editedembeds as $editembed) {
             $deletepath = $this->config->item('smartembed_static_site_location') . $editembed->name;
             $is_file_delete = deleteFolderAndAllFiles($deletepath);
             $this->editedembed_model->delete($editembed->id);
         }
     }
     return true;
 }