Skip to content

Commit 77b13d7

Browse files
committed
fixes
1 parent cbbceb8 commit 77b13d7

File tree

10 files changed

+305
-246
lines changed

10 files changed

+305
-246
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Download and install the module through the Admin or Manually
99

1010
## How to use
1111

12+
### Quick Import
13+
14+
You can choose to run a _Quick Import_ which will act as a one-time import. Simply follow the steps in the Admin to complete.
15+
1216
### Profiles
1317

1418
Profiles can be used to setup a common import you will run multiple times. A Profile will store your destination Stream and field mapping to eliminate these steps in the future.
@@ -26,4 +30,4 @@ It's in beta for now, but we all need import system in our favorite CMS !
2630

2731
## Issues
2832

29-
Please submit any issues back to the Github issue tracker: <https://github.com/bergeo-fr/streams_import>
33+
Please submit any issues back to the Github issue tracker: <https://github.com/bergeo-fr/streams_import>

config/streams_import_c.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* We some security so we can call the importer on the front end
55
*/
66
$config['streams_import:hash'] = 'a874de040c2439d710d1b8e6c7bd59a0';
7-
$config['streams_import:unzip_folder'] = "uploads/default/files/temp_unzip/";
7+
$config['streams_import:unzip_folder'] = "uploads/default/files/temp_unzip2/";
88
$config['streams_import:archives_folder'] = "uploads/default/files/archives/";
99
$config['streams_import:anomalies_folder'] = "uploads/default/files/anomalies/";
10-
$config['streams_import:profiles_directory'] = "uploads/default/ftp/profiles/";
10+
$config['streams_import:profiles_directory'] = "uploads/default/ftp/profiles/web_users/";
11+
$config['streams_import:break_value'] = "{{do_no_insert}}";
12+
$config['streams_import:debug'] = true;

controllers/admin_logs.php

+52-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,60 @@ public function __construct()
3838
{
3939
parent::__construct();
4040
$this->lang->load('streams_import');
41+
$this->load->library('streams_import');
4142

4243
}
4344

4445
public function index($offset)
4546
{
47+
48+
$keyword = trim($this->input->post('keyword'));
49+
$start_date = trim($this->input->post('start_date'));
50+
$end_date = trim($this->input->post('end_date'));
51+
$profile = trim($this->input->post('profile'));
52+
53+
(!empty($keyword))? $where[] = " ( log_detail like '%".$keyword."%' ) " : false;
54+
(!empty($start_date))? $where[] = " ( created >= '".$start_date." 00:00:00' ) " : false;
55+
(!empty($end_date))? $where[] = " ( created <= '".$start_date." 00:00:00' ) " : false;
56+
(!empty($profile))? $where[] = " ( profile_rel_logs = ".$profile." ) " : false;
57+
58+
59+
$where_str = (!empty($where))?implode(' AND ', $where):' created <='.date("Y-m-d").' ';
60+
//Get the logs
61+
62+
// var_dump($where_str);
63+
64+
65+
$params = array(
66+
'namespace'=>$this->namespace,
67+
'stream' =>$this->section,
68+
'where' =>$where_str,
69+
'limit' =>'150',
70+
'paginate' =>'no',
71+
'pag_segment'=>4,
72+
73+
);
74+
75+
$results = $this->streams->entries->get_entries($params);
76+
77+
$data->entries = $results['entries'];
78+
$data->section = $this->section;
79+
$data->namespace = $this->section;
80+
$data->title = lang($this->namespace.':title:'.$this->section.':index');
81+
82+
$profiles = $this->db->select('id,profile_name')->get('streams_import_profiles');
83+
$data->profiles['0'] = '----';
84+
foreach ($profiles->result() as $profile) {
85+
$data->profiles[$profile->id] = $profile->profile_name;
86+
}
87+
88+
$this->template
89+
->append_js('admin/filter.js');
90+
91+
$this->input->is_ajax_request() ? $this->template->set_layout(false)->build('admin/'.$this->section.'/table',$data) : $this->template->build('admin/'.$this->section.'/index',$data);
92+
93+
94+
/*
4695
$extra =
4796
array(
4897
'title' => lang($this->namespace.':title:'.$this->section.':index'),
@@ -58,8 +107,9 @@ public function index($offset)
58107
'confirm' => false
59108
))
60109
);
61-
echo $this->streams->cp->entries_table($this->section, $this->namespace, $pagination = "50", $pagination_uri = "admin/streams_import/logs", $view_override = true, $extra);
62-
}
110+
111+
echo $this->streams->cp->entries_table($this->section, $this->namespace, $pagination = "50", $pagination_uri = "admin/streams_import/logs", $view_override = true, $extra);
112+
*/ }
63113

64114
public function create()
65115
{

controllers/admin_profiles.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,21 @@ private function get_stream_fields_list($stream_id)
375375
return $fieldlist;
376376
}
377377

378+
public function activation($profile_id, $activation)
379+
{
380+
$this->db->where('id',$profile_id );
381+
$data = array("active"=>$activation);
382+
$this->db->update('streams_import_profiles',$data);
383+
redirect('admin/' . $this->namespace . '/' . $this->section);
384+
}
378385

379386

380-
387+
388+
public function reset_lock()
389+
{
390+
Settings::set('stream_import_lock_info','0');
391+
return true;
392+
}
381393

382394
}
383395

details.php

+38-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Module_Streams_import extends Module
1313
{
1414

15-
public $version = 0.7;
15+
public $version = 0.9;
1616
public $module_name = 'streams_import';
1717

1818

@@ -326,6 +326,7 @@ public function install()
326326
);
327327
$this->streams->fields->add_field($field);
328328
}
329+
329330
$field_slug = "unique_keys";
330331
if ( $this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null )
331332
{
@@ -343,6 +344,29 @@ public function install()
343344
'unique' => false
344345
);
345346
$this->streams->fields->add_field($field);
347+
}
348+
349+
$field_slug = "active";
350+
if ( $this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null )
351+
{
352+
$field = array(
353+
'name' => 'lang:' . $this->module_name . ':fields:' . $field_slug,
354+
'slug' => $field_slug,
355+
'namespace' => $this->module_name,
356+
'type' => 'choice',
357+
'extra' => array(
358+
'choice_type'=> 'dropdown',
359+
'choice_data'=> "0 : Non \n ".
360+
"1 : Oui",
361+
'default_value'=>'0'
362+
),
363+
'assign' => $stream_slug,
364+
'instructions' => 'lang:' . $this->module_name . ':fields:' . $field_slug.'_instructions',
365+
'title_column' => false,
366+
'required' => false,
367+
'unique' => false
368+
);
369+
$this->streams->fields->add_field($field);
346370
}
347371

348372

@@ -503,6 +527,19 @@ public function install()
503527
);
504528
$this->streams->fields->add_field($field);
505529
}
530+
//the lock setting
531+
$this->db->insert('settings', array(
532+
'slug' => 'stream_import_lock_info',
533+
'title' => 'Lock info for Stream Importer Module',
534+
'description' => 'Tell you if the stream importer is running, and the start date.',
535+
'`default`' => '0',
536+
'`value`' => '0',
537+
'type' => 'text',
538+
'`options`' => '',
539+
'is_required' => 1,
540+
'is_gui' => 0,
541+
'module' => $this->module_name
542+
));
506543
return true;
507544
}
508545

@@ -526,7 +563,6 @@ public function uninstall()
526563
public function upgrade($old_version)
527564
{
528565

529-
530566
return true;
531567
}
532568

0 commit comments

Comments
 (0)