Пример #1
0
 /**
  * add or remove folders.
  * 
  * @access public
  * @param $action add|remove (default: 'add')
  * @return void
  */
 public function folders($action = 'add')
 {
     $this->load->library('files/files');
     $this->load->model('files/file_folders_m');
     //$this->load->model('settings/settings_m');
     $folder_slug = 'photo-gallery';
     if ($action == 'add') {
         $parent_id = 0;
         //users uploaded image folder
         $user_folder = $this->file_folders_m->get_by(array('slug' => $folder_slug));
         if ($user_folder) {
             $folder = (array) $user_folder;
         } else {
             $user_folder = Files::create_folder($parent_id, 'Photo Gallery');
             $folder = $user_folder['data'];
         }
         if ($folder) {
             $setting_data = array('slug' => $folder['slug'], 'title' => $folder['name'], 'description' => 'Folder id for ' . $folder['name'], 'default' => 0, 'value' => $folder['id'], 'type' => 'text', 'options' => '', 'is_required' => 1, 'is_gui' => 1, 'module' => 'galleries');
         }
         $folder_setting = $this->db->where('slug', $folder_slug)->get('settings')->num_rows;
         if ($folder_setting == 0) {
             $this->db->insert('settings', $setting_data);
         } else {
             $this->db->where('slug', $folder_slug)->update('settings', $setting_data);
         }
         return TRUE;
     } else {
         // remove folder settings
         return (bool) $this->file_folders_m->delete_by('slug', $folder_slug);
     }
 }
Пример #2
0
 /**
  * Create a new folder
  *
  * Grabs the parent id and the name of the folder from POST data.
  */
 public function new_folder()
 {
     // This is just a safeguard if they circumvent the JS permissions
     if (!in_array('create_folder', Files::allowed_actions())) {
         show_error(lang('files:no_permissions'));
     }
     $parent_id = $this->input->post('parent');
     $name = $this->input->post('name');
     echo json_encode(Files::create_folder($parent_id, $name));
 }
Пример #3
0
 /**
  * Create a new folder
  *
  * Grabs the parent id and the name of the folder from POST data.
  */
 public function new_folder()
 {
     // This is just a safeguard if they circumvent the JS permissions
     if (!in_array('create_folder', Files::allowed_actions())) {
         show_error(lang('files:no_permissions'));
     }
     $parent_id = $this->input->post('parent');
     $name = $this->input->post('name');
     $result = Files::create_folder($parent_id, $name);
     $result['status'] and Events::trigger('file_folder_created', $result['data']);
     echo json_encode($result);
 }
Пример #4
0
 public function install()
 {
     //Load file library
     $this->load->library('files/files');
     //We will create a root fodler that will contains all the
     //Galleries folder just to keep a clean view in the files module
     $root_folder = Files::create_folder(0, lang('galleries:folder:name'));
     //Let's try to add a new stream for the galleries
     if (!($galleries_stream = $this->streams->streams->add_stream(lang('galleries:streams:galleries:name'), 'galleries', 'galleries', '', lang('galleries:streams:galleries:description')))) {
         //Something went wrong so uninstall the module
         $this->uninstall();
         return false;
     }
     //Let's try to add a new stream for the categories
     if (!($categories_stream = $this->streams->streams->add_stream(lang('galleries:streams:categories:name'), 'galleries_categories', 'galleries_categories', '', lang('galleries:streams:categories:description')))) {
         //Something went wrong so uninstall the module
         $this->uninstall();
         return false;
     }
     /*
      *	This array will contains all the field we need for the main section.
      *	What we need:
      *		- Name
      *		- Slug
      *		- Intro
      *		- Description
      *		- Images folder ( One folder per gallery )
      *		- Cover Image
      *		- Category
      *		- Enable comments
      *		- Title SEO
      *		- Keywords SEO
      *		- Description SEP
      */
     $str_enable_comments = "no : " . lang('global:no') . "\nyes : " . lang('global:yes');
     $str_publish = "no : " . lang('global:no') . "\nyes : " . lang('global:yes');
     $galleries_fields = array(array('name' => lang('galleries:fields:name'), 'slug' => 'galleries_name', 'namespace' => 'galleries', 'type' => 'text', 'instructions' => lang('galleries:fields:instr:name'), 'assign' => 'galleries', 'title_column' => true, 'required' => true, 'unique' => true), array('name' => lang('galleries:fields:slug'), 'slug' => 'galleries_slug', 'namespace' => 'galleries', 'type' => 'slug', 'extra' => array('space_type' => '-', 'slug_field' => 'galleries_name'), 'instructions' => lang('galleries:fields:instr:slug'), 'assign' => 'galleries', 'title_column' => false, 'required' => true, 'unique' => true), array('name' => lang('galleries:fields:category'), 'slug' => 'galleries_category', 'namespace' => 'galleries', 'type' => 'relationship', 'extra' => array('choose_stream' => $categories_stream), 'instructions' => lang('galleries:fields:instr:category'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false), array('name' => lang('galleries:fields:folder'), 'slug' => 'galleries_folder', 'namespace' => 'galleries', 'type' => 'folders_list', 'extra' => array('parent' => $root_folder['data']['id']), 'instructions' => lang('galleries:fields:instr:folder'), 'assign' => 'galleries', 'title_column' => false, 'required' => true, 'unique' => true), array('name' => lang('galleries:fields:cover'), 'slug' => 'galleries_cover', 'namespace' => 'galleries', 'type' => 'text', 'instructions' => lang('galleries:fields:instr:cover'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => true), array('name' => lang('galleries:fields:intro'), 'slug' => 'galleries_intro', 'namespace' => 'galleries', 'type' => 'wysiwyg', 'extra' => array('editor_type' => 'simple', 'allow_tags' => 'y'), 'instructions' => lang('galleries:fields:instr:intro'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false), array('name' => lang('galleries:fields:description'), 'slug' => 'galleries_description', 'namespace' => 'galleries', 'type' => 'wysiwyg', 'extra' => array('editor_type' => 'advanced', 'allow_tags' => 'y'), 'instructions' => lang('galleries:fields:instr:description'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false), array('name' => lang('galleries:fields:published'), 'slug' => 'galleries_is_published', 'namespace' => 'galleries', 'type' => 'choice', 'extra' => array('choice_data' => $str_publish, 'choice_type' => 'dropdown', 'default_value' => 'yes'), 'instructions' => lang('galleries:fields:instr:published'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false), array('name' => lang('galleries:fields:enable_comments'), 'slug' => 'galleries_comments_enabled', 'namespace' => 'galleries', 'type' => 'choice', 'extra' => array('choice_data' => $str_enable_comments, 'choice_type' => 'dropdown', 'default_value' => 'no'), 'instructions' => lang('galleries:fields:instr:enable_comments'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false), array('name' => lang('galleries:fields:seo_title'), 'slug' => 'galleries_seo_title', 'namespace' => 'galleries', 'type' => 'text', 'instructions' => lang('galleries:fields:instr:seo_title'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false), array('name' => lang('galleries:fields:seo_keywords'), 'slug' => 'galleries_seo_keywords', 'namespace' => 'galleries', 'type' => 'keywords', 'extra' => array('return_type' => 'string'), 'instructions' => lang('galleries:fields:instr:seo_keywords'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false), array('name' => lang('galleries:fields:seo_description'), 'slug' => 'galleries_seo_description', 'namespace' => 'galleries', 'type' => 'textarea', 'instructions' => lang('galleries:fields:instr:seo_description'), 'assign' => 'galleries', 'title_column' => false, 'required' => false, 'unique' => false));
     /*
      *	This array will contains all the fiedls we need to create the category section.
      *	We just need:
      *		- Name
      *		- Slug
      */
     $categories_fields = array(array('name' => lang('galleries:categories:fields:name'), 'slug' => 'galleries_categories_name', 'namespace' => 'galleries_categories', 'type' => 'text', 'instructions' => lang('galleries:categories:fields:instr:name'), 'assign' => 'galleries_categories', 'title_column' => true, 'required' => true, 'unique' => true), array('name' => lang('galleries:categories:fields:slug'), 'slug' => 'galleries_categories_slug', 'namespace' => 'galleries_categories', 'type' => 'slug', 'extra' => array('space_type' => '-', 'slug_field' => 'galleries_categories_name'), 'instructions' => lang('galleries:categories:fields:instr:slug'), 'assign' => 'galleries_categories', 'title_column' => false, 'required' => true, 'unique' => true));
     //Add the fields to the streams
     $this->streams->fields->add_fields($categories_fields);
     $this->streams->fields->add_fields($galleries_fields);
     //All done
     return true;
 }
Пример #5
0
 /**
  * add or remove folders.
  * 
  * @access public
  * @param $action add|remove (default: 'add')
  * @return void
  */
 public function folders($action = 'add')
 {
     $this->load->library('files/files');
     $this->load->model('files/file_folders_m');
     $slug = 'testimonials';
     if ($action == 'add') {
         if (!$this->file_folders_m->get_by('slug', $slug)) {
             $parent_id = 0;
             Files::create_folder($parent_id, 'Testimonials', 'local');
         }
         return TRUE;
     } else {
         $this->file_folders_m->delete_by('slug', $slug);
     }
     return TRUE;
 }
Пример #6
0
 public function stream($action = 'add')
 {
     if ($action == 'add') {
         $folder_name = array('service-folder' => 'Service Folder');
         $folder = $this->file_folders_m->get_by('slug', key($folder_name));
         if (!$folder) {
             $folder = Files::create_folder(0, reset($folder_name), 'local');
             $fid = $folder['data']['id'];
         }
     } else {
         $folder_name = array('service-folder' => 'Service Folder');
         $this->file_folders_m->delete_by('slug', key($folder_name));
     }
     if ($action == 'add') {
         $this->load->driver('Streams');
         $this->load->language('service/service');
         // Add service streams
         if (!$this->streams->streams->add_stream('lang:service:service', 'service', 'service', null, null)) {
             return false;
         }
         //add some fields
         $fields = array();
         $template = array('namespace' => 'service', 'assign' => 'service', 'type' => 'text', 'title_column' => FALSE, 'unique' => FALSE);
         $fields = array(array('name' => 'Title', 'slug' => 'title', 'type' => 'text', 'extra' => array('max_length' => 100), 'namespace' => 'service', 'assign' => 'service', 'title_column' => true, 'required' => true, 'unique' => true), array('name' => 'Service Slug', 'slug' => 'service_slug', 'type' => 'slug', 'namespace' => 'service', 'assign' => 'service', 'extra' => array('space_type' => '-', 'slug_field' => 'title'), 'required' => true, 'unique' => true), array('name' => 'Description', 'slug' => 'description', 'namespace' => 'service', 'assign' => 'service', 'type' => 'wysiwyg', 'extra' => array('editor_type' => 'advanced'), 'required' => true), array('name' => 'Image', 'slug' => 'image', 'namespace' => 'service', 'assign' => 'service', 'type' => 'image', 'extra' => array('allowed_types' => 'jpg|jpeg|png|gif', 'folder' => $fid)), array('name' => 'Icon', 'slug' => 'icon', 'namespace' => 'service', 'assign' => 'service', 'type' => 'text'), array('name' => 'Service Quote', 'slug' => 'quote', 'namespace' => 'service', 'assign' => 'service', 'type' => 'text'), array('name' => 'Status', 'slug' => 'status', 'namespace' => 'service', 'assign' => 'service', 'type' => 'choice', 'extra' => array('choice_data' => "0 : Draft\n1 : Live", 'choice_type' => 'dropdown', 'default_value' => 1), 'required' => true), array('name' => 'Featured', 'slug' => 'featured', 'namespace' => 'service', 'assign' => 'service', 'type' => 'choice', 'extra' => array('choice_data' => "0 : No\n1 : Yes", 'choice_type' => 'dropdown', 'default_value' => 0), 'required' => true));
         // Combine
         foreach ($fields as &$field) {
             $field = array_merge($template, $field);
         }
         // Add fields to stream
         $this->streams->fields->add_fields($fields);
         $this->streams->streams->update_stream('service', 'service', array('view_options' => array('id', 'title', 'status', 'featured')));
     } else {
         $this->load->driver('Streams');
         $this->streams->utilities->remove_namespace('service');
     }
     return TRUE;
 }
Пример #7
0
 /**
  * add or remove result folders.
  * 
  * @access public
  * @param $action add|remove (default: 'add')
  * @return void
  */
 public function news_folder($action = 'add')
 {
     $this->load->library('files/files');
     $this->load->model('files/file_folders_m');
     //$this->load->model('settings/settings_m');
     $slug = 'news-attachments';
     if ($action == 'add') {
         if (!$this->file_folders_m->get_by('slug', $slug)) {
             $parent_id = 0;
             Files::create_folder($parent_id, 'News Attachments', 'local');
         }
         return TRUE;
     } else {
         $this->file_folders_m->delete_by('slug', $slug);
     }
     return TRUE;
 }
Пример #8
0
 public function new_folder()
 {
     $folder_name = $this->input->post('name');
     $parent_folder = (int) $this->input->post('folder_id');
     $results = Files::create_folder($parent_folder, $folder_name);
     $this->session->set_flashdata($results['status'] ? 'success' : 'notice', $results['message']);
     $redirect_to = $this->input->post('redirect_to') ? $this->input->post('redirect_to') : 'admin/imagepicker/index/' . $input['folder_id'];
     redirect($redirect_to);
 }
Пример #9
0
 public function install()
 {
     // Load required items
     $this->load->driver('Streams');
     $this->load->language($this->language_file);
     $this->load->model('firesale/categories_m');
     $this->load->model('firesale/products_m');
     $this->load->library('files/files');
     ################
     ## CATEGORIES ##
     ################
     // Create categories stream
     if (!$this->streams->streams->add_stream(lang('firesale:sections:categories'), 'firesale_categories', 'firesale_categories', NULL, NULL)) {
         return FALSE;
     }
     // Get stream data
     $categories = $this->streams->streams->get_stream('firesale_categories', 'firesale_categories');
     // Add fields
     $fields = array();
     $template = array('namespace' => 'firesale_categories', 'assign' => 'firesale_categories', 'type' => 'text', 'title_column' => FALSE, 'required' => TRUE, 'unique' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_parent', 'slug' => 'parent', 'type' => 'relationship', 'extra' => array('max_length' => 5, 'choose_stream' => $categories->id), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_status', 'slug' => 'status', 'type' => 'choice', 'extra' => array('choice_data' => "0 : lang:firesale:label_draft\n1 : lang:firesale:label_live", 'choice_type' => 'dropdown', 'default_value' => 0));
     $fields[] = array('name' => 'lang:firesale:label_title', 'slug' => 'title', 'type' => 'text', 'title_column' => TRUE, 'extra' => array('max_length' => 255), 'unique' => TRUE);
     $fields[] = array('name' => 'lang:firesale:label_slug', 'slug' => 'slug', 'type' => 'slug', 'extra' => array('max_length' => 255, 'slug_field' => 'title', 'space_type' => '-'), 'unique' => TRUE);
     $fields[] = array('name' => 'lang:firesale:label_description', 'slug' => 'description', 'type' => 'wysiwyg', 'extra' => array('editor_type' => 'simple'));
     // Combine
     foreach ($fields as $key => $field) {
         $fields[$key] = array_merge($template, $field);
     }
     // Add fields to stream
     $this->streams->fields->add_fields($fields);
     // Change default parent value
     $this->db->query("ALTER TABLE `" . SITE_REF . "_firesale_categories` CHANGE `parent` `parent` INT( 11 ) NULL DEFAULT '0';");
     // Add an initial category
     $cat = array('id' => 1, 'created' => date("Y-m-d H:i:s"), 'created_by' => 1, 'ordering_count' => 0, 'parent' => 0, 'status' => 1, 'title' => 'Uncategorised', 'slug' => 'uncategorised', 'description' => 'This is your initial product category, which can\'t be deleted; however you can rename it if you wish.');
     $this->db->insert('firesale_categories', $cat);
     ##############
     ## PRODUCTS ##
     ##############
     // Format stock status
     $stockstatus = '';
     foreach ($this->products_m->_stockstatus as $key => $val) {
         $stockstatus .= "{$key} : lang:{$val}\n";
     }
     // Create products stream
     if (!$this->streams->streams->add_stream(lang('firesale:sections:products'), 'firesale_products', 'firesale_products', NULL, NULL)) {
         return FALSE;
     }
     // Get stream data
     $products = $this->streams->streams->get_stream('firesale_products', 'firesale_products');
     // Add fields
     $fields = array();
     $template = array('namespace' => 'firesale_products', 'assign' => 'firesale_products', 'type' => 'text', 'title_column' => FALSE, 'required' => TRUE, 'unique' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_id', 'slug' => 'code', 'extra' => array('max_length' => 64), 'unique' => TRUE);
     $fields[] = array('name' => 'lang:firesale:label_title', 'slug' => 'title', 'type' => 'text', 'title_column' => TRUE, 'extra' => array('max_length' => 255), 'unique' => TRUE);
     $fields[] = array('name' => 'lang:firesale:label_slug', 'slug' => 'slug', 'type' => 'slug', 'extra' => array('max_length' => 255, 'slug_field' => 'title', 'space_type' => '-'));
     $fields[] = array('name' => 'lang:firesale:label_category', 'slug' => 'category', 'type' => 'multiple', 'extra' => array('choose_stream' => $categories->id), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_rrp', 'slug' => 'rrp', 'type' => 'text', 'instructions' => 'lang:firesale:inst_rrp', 'extra' => array('max_length' => 10, 'pattern' => '^\\d+(?:,\\d{3})*\\.\\d{2}$'));
     $fields[] = array('name' => 'lang:firesale:label_rrp_tax', 'slug' => 'rrp_tax', 'type' => 'text', 'extra' => array('max_length' => 10, 'pattern' => '^\\d+(?:,\\d{3})*\\.\\d{2}$'));
     $fields[] = array('name' => 'lang:firesale:label_price', 'slug' => 'price', 'type' => 'text', 'instructions' => 'lang:firesale:inst_price', 'extra' => array('max_length' => 10, 'pattern' => '^\\d+(?:,\\d{3})*\\.\\d{2}$'));
     $fields[] = array('name' => 'lang:firesale:label_price_tax', 'slug' => 'price_tax', 'type' => 'text', 'extra' => array('max_length' => 10, 'pattern' => '^\\d+(?:,\\d{3})*\\.\\d{2}$'));
     $fields[] = array('name' => 'lang:firesale:label_status', 'slug' => 'status', 'type' => 'choice', 'extra' => array('choice_data' => "0 : lang:firesale:label_draft\n1 : lang:firesale:label_live", 'choice_type' => 'dropdown', 'default_value' => 1));
     $fields[] = array('name' => 'lang:firesale:label_stock', 'slug' => 'stock', 'type' => 'integer');
     $fields[] = array('name' => 'lang:firesale:label_stock_status', 'slug' => 'stock_status', 'type' => 'choice', 'extra' => array('choice_data' => $stockstatus, 'choice_type' => 'dropdown', 'default_value' => 1));
     $fields[] = array('name' => 'lang:firesale:label_description', 'slug' => 'description', 'type' => 'wysiwyg', 'extra' => array('editor_type' => 'advanced'));
     // Combine
     foreach ($fields as $key => $field) {
         $fields[$key] = array_merge($template, $field);
     }
     // Add fields to stream
     $this->streams->fields->add_fields($fields);
     // Change engine and add fulltext
     $this->db->query("ALTER TABLE `" . SITE_REF . "_firesale_products` ENGINE = MyISAM,\n\t\t\t\t\t\t  ADD FULLTEXT (`title`, `description`),\n\t\t\t\t\t\t  CHANGE `rrp` `rrp` DECIMAL( 10, 2 ) DEFAULT '0.00',\n\t\t\t\t\t\t  CHANGE `rrp_tax` `rrp_tax` DECIMAL( 10, 2 ) DEFAULT '0.00',\n\t\t\t\t\t\t  CHANGE `price` `price` DECIMAL( 10, 2 ) DEFAULT '0.00',\n\t\t\t\t\t\t  CHANGE `price_tax` `price_tax` DECIMAL( 10, 2 ) DEFAULT '0.00';");
     ######################
     ## PAYMENT GATEWAYS ##
     ######################
     // Create gateways stream
     if (!$this->streams->streams->add_stream(lang('firesale:sections:gateways'), 'firesale_gateways', 'firesale_gateways', NULL, NULL)) {
         return FALSE;
     }
     // Get stream data
     $gateways = $this->streams->streams->get_stream('firesale_gateways', 'firesale_gateways');
     // Add fields
     $fields = array();
     $template = array('namespace' => 'firesale_gateways', 'assign' => 'firesale_gateways', 'type' => 'text', 'title_column' => FALSE, 'required' => TRUE, 'unique' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_title', 'slug' => 'name', 'type' => 'text', 'title_column' => TRUE, 'extra' => array('max_length' => 255), 'unique' => TRUE);
     $fields[] = array('name' => 'lang:firesale:label_slug', 'slug' => 'slug', 'type' => 'slug', 'extra' => array('max_length' => 255, 'slug_field' => 'name', 'space_type' => '-'));
     $fields[] = array('name' => 'lang:firesale:label_description', 'slug' => 'desc', 'type' => 'wysiwyg', 'extra' => array('editor_type' => 'advanced'));
     $fields[] = array('name' => 'lang:firesale:label_status', 'slug' => 'enabled', 'type' => 'choice', 'extra' => array('choice_data' => "0 : lang:firesale:label_draft\n1 : lang:firesale:label_live", 'choice_type' => 'dropdown', 'default_value' => 0));
     // Combine
     foreach ($fields as $key => $field) {
         $fields[$key] = array_merge($template, $field);
     }
     // Add fields to stream
     $this->streams->fields->add_fields($fields);
     // Add the gateway settings table
     $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . SITE_REF . "_firesale_gateway_settings` (\n\t\t\t  `id` int(11) NOT NULL,\n\t\t\t  `key` varchar(64) NOT NULL,\n\t\t\t  `value` text NOT NULL\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n\t\t");
     // Load the gateways class
     $this->load->library('firesale/gateways');
     // Install the core gateways
     $this->gateways->install_core();
     #####################
     ## ADDRESS HISTORY ##
     #####################
     // Create orders stream
     if (!$this->streams->streams->add_stream(lang('firesale:sections:addresses'), 'firesale_addresses', 'firesale_addresses', NULL, NULL)) {
         return FALSE;
     }
     // Get stream data
     $addresses = $this->streams->streams->get_stream('firesale_addresses', 'firesale_addresses');
     // Add fields
     $fields = array();
     $template = array('namespace' => 'firesale_addresses', 'assign' => 'firesale_addresses', 'type' => 'text', 'title_column' => FALSE, 'required' => TRUE, 'unique' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_title', 'slug' => 'title', 'type' => 'text', 'title_column' => TRUE, 'extra' => array('max_length' => 255), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_company', 'slug' => 'company', 'extra' => array('max_length' => 255), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_firstname', 'slug' => 'firstname', 'extra' => array('max_length' => 100));
     $fields[] = array('name' => 'lang:firesale:label_lastname', 'slug' => 'lastname', 'extra' => array('max_length' => 100));
     $fields[] = array('name' => 'lang:firesale:label_email', 'slug' => 'email', 'extra' => array('max_length' => 255));
     $fields[] = array('name' => 'lang:firesale:label_phone', 'slug' => 'phone', 'extra' => array('max_length' => 255), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_address1', 'slug' => 'address1', 'extra' => array('max_length' => 255));
     $fields[] = array('name' => 'lang:firesale:label_address2', 'slug' => 'address2', 'extra' => array('max_length' => 255), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_city', 'slug' => 'city', 'extra' => array('max_length' => 255));
     $fields[] = array('name' => 'lang:firesale:label_county', 'slug' => 'county', 'extra' => array('max_length' => 255));
     $fields[] = array('name' => 'lang:firesale:label_postcode', 'slug' => 'postcode', 'extra' => array('max_length' => 40));
     $fields[] = array('name' => 'lang:firesale:label_country', 'slug' => 'country', 'type' => 'country');
     // Combine
     foreach ($fields as $key => $field) {
         $fields[$key] = array_merge($template, $field);
     }
     // Add fields to stream
     $this->streams->fields->add_fields($fields);
     ############################
     ## ORDERS & ORDER HISTORY ##
     ############################
     // Format order status options
     $orderstatus = "1 : lang:firesale:orders:status_unpaid\n" . "2 : lang:firesale:orders:status_paid\n" . "3 : lang:firesale:orders:status_dispatched\n" . "4 : lang:firesale:orders:status_processing\n" . "5 : lang:firesale:orders:status_refunded\n" . "6 : lang:firesale:orders:status_cancelled";
     // Create orders stream
     if (!$this->streams->streams->add_stream(lang('firesale:sections:orders'), 'firesale_orders', 'firesale_orders', NULL, NULL)) {
         return FALSE;
     }
     // Get stream data
     $orders = $this->streams->streams->get_stream('firesale_orders', 'firesale_orders');
     // Add fields
     $fields = array();
     $template = array('namespace' => 'firesale_orders', 'assign' => 'firesale_orders', 'type' => 'text', 'title_column' => FALSE, 'required' => TRUE, 'unique' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_ip', 'slug' => 'ip', 'type' => 'text', 'extra' => array('max_length' => 32), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_gateway', 'slug' => 'gateway', 'type' => 'relationship', 'extra' => array('max_length' => 5, 'choose_stream' => $gateways->id), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_status', 'slug' => 'order_status', 'type' => 'choice', 'extra' => array('choice_data' => $orderstatus, 'choice_type' => 'dropdown', 'default_value' => '1'));
     $fields[] = array('name' => 'lang:firesale:label_price_sub', 'slug' => 'price_sub', 'extra' => array('max_length' => 10), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_price_ship', 'slug' => 'price_ship', 'extra' => array('max_length' => 10), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_price_total', 'slug' => 'price_total', 'extra' => array('max_length' => 10), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_ship_to', 'slug' => 'ship_to', 'type' => 'relationship', 'extra' => array('choose_stream' => $addresses->id), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_bill_to', 'slug' => 'bill_to', 'type' => 'relationship', 'extra' => array('choose_stream' => $addresses->id), 'required' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_shipping', 'slug' => 'shipping', 'type' => 'integer', 'required' => FALSE);
     // Combine
     foreach ($fields as $key => $field) {
         $fields[$key] = array_merge($template, $field);
     }
     // Add fields to stream
     $this->streams->fields->add_fields($fields);
     // Modify table
     $this->db->query("ALTER TABLE `" . SITE_REF . "_firesale_orders`\n\t\t\t\t\t\t  CHANGE `price_sub` `price_sub` DECIMAL( 10, 2 ) DEFAULT '0.00',\n\t\t\t\t\t\t  CHANGE `price_ship` `price_ship` DECIMAL( 10, 2 ) DEFAULT '0.00',\n\t\t\t\t\t\t  CHANGE `price_total` `price_total` DECIMAL( 10, 2 ) DEFAULT '0.00';");
     // Create orders items stream
     if (!$this->streams->streams->add_stream(lang('firesale:sections:orders_items'), 'firesale_orders_items', 'firesale_orders_items', NULL, NULL)) {
         return FALSE;
     }
     // Add fields
     $fields = array();
     $template = array('namespace' => 'firesale_orders_items', 'assign' => 'firesale_orders_items', 'type' => 'text', 'title_column' => FALSE, 'required' => TRUE, 'unique' => FALSE);
     $fields[] = array('name' => 'lang:firesale:label_order', 'slug' => 'order_id', 'type' => 'relationship', 'extra' => array('max_length' => 5, 'choose_stream' => $orders->id));
     $fields[] = array('name' => 'lang:firesale:label_product', 'slug' => 'product_id', 'type' => 'relationship', 'extra' => array('max_length' => 5, 'choose_stream' => $products->id));
     $fields[] = array('name' => 'lang:firesale:label_id', 'slug' => 'code', 'extra' => array('max_length' => 64), 'unique' => TRUE);
     $fields[] = array('name' => 'lang:firesale:label_title', 'slug' => 'name', 'type' => 'text', 'title_column' => TRUE, 'extra' => array('max_length' => 255), 'unique' => TRUE);
     $fields[] = array('name' => 'lang:firesale:label_price', 'slug' => 'price', 'type' => 'text', 'extra' => array('max_length' => 10, 'pattern' => '^\\d+(?:,\\d{3})*\\.\\d{2}$'));
     $fields[] = array('name' => 'lang:firesale:label_quantity', 'slug' => 'qty', 'type' => 'integer', 'required' => FALSE);
     // Combine
     foreach ($fields as $key => $field) {
         $fields[$key] = array_merge($template, $field);
     }
     // Add fields to stream
     $this->streams->fields->add_fields($fields);
     ##################
     ## TRANSACTIONS ##
     ##################
     $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . SITE_REF . "_firesale_transactions` (\n\t\t\t  `txn_id` varchar(50) NOT NULL,\n\t\t\t  `order_id` int(11) NOT NULL,\n\t\t\t  `gateway` varchar(100) NOT NULL,\n\t\t\t  `amount` decimal(10,2) NOT NULL,\n\t\t\t  `message` text NOT NULL,\n\t\t\t  `status` varchar(100) NOT NULL,\n\t\t\t  PRIMARY KEY  (`txn_id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n\t\t");
     ###########
     ## OTHER ##
     ###########
     // Add settings
     $this->settings('add');
     // Add email templates
     $this->templates('add');
     // Create files folder
     Files::create_folder(0, 'Product Images');
     // Return
     return TRUE;
 }
Пример #10
0
 public function upload($id)
 {
     // Get product
     $row = $this->row_m->get_row($id, $this->stream, FALSE);
     $folder = $this->products_m->get_file_folder_by_slug($row->slug);
     // Create folder?
     if (!$folder) {
         $parent = $this->products_m->get_file_folder_by_slug('product-images');
         $folder = Files::create_folder($parent->id, $row->title);
         $folder = (object) $folder['data'];
     }
     // Check for folder
     if (is_object($folder)) {
         // Upload it
         $status = Files::upload($folder->id);
         // Make square?
         $this->products_m->make_square($status);
         // Ajax status
         unset($status['data']);
         echo json_encode($status);
         exit;
     }
     // Seems it was unsuccessful
     echo json_encode(array('status' => FALSE, 'message' => 'Error uploading image'));
     exit;
 }
Пример #11
0
 public function install()
 {
     $this->load->driver('Streams');
     $this->load->library('files/files');
     // Make the Uploads folder and store its ID in the settings table
     if (($folder = Files::create_folder(0, $this->module_name)) == true) {
         $folder_id = $folder['data']['id'];
         $this->db->insert('settings', array('slug' => $this->module_name . '_folder', 'title' => $this->module_name . ' Folder', 'description' => 'A ' . $this->module_name . ' Folder ID Holder', '`default`' => '0', '`value`' => $folder_id, 'type' => 'text', '`options`' => '', 'is_required' => 1, 'is_gui' => 0, 'module' => $this->module_name));
     }
     // Add Streams - profiles
     $stream_slug = "profiles";
     if ($this->streams->streams->add_stream('lang:' . $this->module_name . ':title:' . $stream_slug, $stream_slug, $this->module_name, $this->module_name . '_', null) == true) {
         $stream_id = $this->db->where('stream_namespace', $this->module_name)->where('stream_slug', $stream_slug)->limit(1)->get('data_streams')->row()->id;
         $this->db->insert('settings', array('slug' => 'sim_' . $stream_slug . '_stream_id', 'title' => $this->module_name . ' ' . $stream_slug . ' stream id', 'description' => $this->module_name . ' ' . $stream_slug . 'stream id holder', '`default`' => '0', '`value`' => $stream_id, 'type' => 'text', '`options`' => '', 'is_required' => 1, 'is_gui' => 0, 'module' => $this->module_name));
         $stream_id = null;
     }
     // Add Fields profiles
     $field_slug = "profile_name";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('max_length' => 200), 'assign' => $stream_slug, 'title_column' => true, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "profile_slug";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('slug_field' => 'profile_name', 'space_type' => '_'), 'assign' => 'profiles', 'title_column' => false, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "example_file";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'file', 'extra' => array('folder' => $folder_id, 'allowed_types' => '*'), 'assign' => $stream_slug, 'title_column' => false, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "delimiter";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('max_length' => 5, 'default_value' => ','), 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'instructions' => 'lang:' . $this->module_name . ':fields:' . $field_slug . ':instructions', 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "eol";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('max_length' => 5, 'default_value' => '\\n'), 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "enclosure";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('max_length' => 5, 'default_value' => ''), 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "stream_identifier";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'integer', 'assign' => $stream_slug, 'title_column' => false, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "unzip";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'choice', 'extra' => array('choice_type' => 'dropdown', 'choice_data' => "0 : No \n " . "1 : Yes", 'default_value' => '0'), 'assign' => $stream_slug, 'instructions' => 'lang:' . $this->module_name . ':fields:' . $field_slug . '_instructions', 'title_column' => false, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "datasource";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'choice', 'extra' => array('choice_type' => 'dropdown', 'choice_data' => "0 : File", 'default_value' => '0'), 'assign' => $stream_slug, 'instructions' => 'lang:' . $this->module_name . ':fields:' . $field_slug . '_instructions', 'title_column' => false, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "source_format";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'choice', 'extra' => array('choice_type' => 'dropdown', 'choice_data' => "xml : XML \n " . "csv : CSV \n " . "txt : TXT \n " . "json : JSON \n " . "rss : RSS ", 'default_value' => '0'), 'assign' => $stream_slug, 'instructions' => 'lang:' . $this->module_name . ':fields:' . $field_slug . '_instructions', 'title_column' => false, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     //STEP 2 OF PROFILE
     $field_slug = "xml_path_loop";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('max_length' => 200), 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'instructions' => 'lang:' . $this->module_name . ':fields:' . $field_slug . '_instructions', 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "unique_keys";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array("max_length" => 555, "default_value" => ""), 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "active";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'choice', 'extra' => array('choice_type' => 'dropdown', 'choice_data' => "0 : Non \n " . "1 : Oui", 'default_value' => '0'), 'assign' => $stream_slug, 'instructions' => 'lang:' . $this->module_name . ':fields:' . $field_slug . '_instructions', 'title_column' => false, 'required' => false, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     // Add Streams - equalities
     $stream_slug = "mapping";
     if ($this->streams->streams->add_stream('lang:' . $this->module_name . ':title:' . $stream_slug, $stream_slug, $this->module_name, $this->module_name . '_', null) == true) {
         $stream_id = $this->db->where('stream_namespace', $this->module_name)->where('stream_slug', $stream_slug)->limit(1)->get('data_streams')->row()->id;
         $this->db->insert('settings', array('slug' => 'sim_' . $stream_slug . '_stream_id', 'title' => $this->module_name . ' ' . $stream_slug . ' stream id', 'description' => $this->module_name . ' ' . $stream_slug . 'stream id holder', '`default`' => '0', '`value`' => $stream_id, 'type' => 'text', '`options`' => '', 'is_required' => 1, 'is_gui' => 0, 'module' => $this->module_name));
         $stream_id = null;
     }
     // Add Fields equalities
     $field_slug = "stream_field";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('max_length' => 200), 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "entry_number";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'extra' => array('max_length' => 200), 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "profile_relation_stream";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'relationship', 'extra' => array('choose_stream' => Settings::get('sim_profiles_stream_id')), 'title_column' => false, 'assign' => $stream_slug, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     } else {
         die('error');
     }
     // Add Streams - LOG
     $stream_slug = "logs";
     if ($this->streams->streams->add_stream('lang:' . $this->module_name . ':title:' . $stream_slug, $stream_slug, $this->module_name, $this->module_name . '_', null) == true) {
         $stream_id = $this->db->where('stream_namespace', $this->module_name)->where('stream_slug', $stream_slug)->limit(1)->get('data_streams')->row()->id;
         $this->db->insert('settings', array('slug' => 'sim_' . $stream_slug . '_stream_id', 'title' => $this->module_name . ' ' . $stream_slug . ' stream id', 'description' => $this->module_name . ' ' . $stream_slug . 'stream id holder', '`default`' => '0', '`value`' => $stream_id, 'type' => 'text', '`options`' => '', 'is_required' => 1, 'is_gui' => 0, 'module' => $this->module_name));
         $stream_id = null;
     }
     $update_data = array('view_options' => array('created', 'updated', 'profile_rel_logs', 'filename'));
     $this->streams->streams->update_stream($stream_slug, $this->module_name, $update_data);
     // Add Fields logs
     $field_slug = "profile_rel_logs";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'relationship', 'extra' => array('choose_stream' => Settings::get('sim_profiles_stream_id')), 'assign' => $stream_slug, 'title_column' => true, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "filename";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'text', 'assign' => $stream_slug, 'title_column' => false, 'required' => true, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     $field_slug = "log_detail";
     if ($this->db->where('field_namespace', $this->module_name)->where('field_slug', $field_slug)->limit(1)->get('data_fields')->num_rows() == null) {
         $field = array('name' => 'lang:' . $this->module_name . ':fields:' . $field_slug, 'slug' => $field_slug, 'namespace' => $this->module_name, 'type' => 'textarea', 'assign' => $stream_slug, 'title_column' => false, 'required' => false, 'unique' => false);
         $this->streams->fields->add_field($field);
     }
     //the lock setting
     $this->db->insert('settings', array('slug' => 'stream_import_lock_info', 'title' => 'Lock info for Stream Importer Module', 'description' => 'Tell you if the stream importer is running, and the start date.', '`default`' => '0', '`value`' => '0', 'type' => 'text', '`options`' => '', 'is_required' => 1, 'is_gui' => 0, 'module' => $this->module_name));
     return true;
 }