Exemplo n.º 1
0
function upgrade_module_1_3_2_2($object)
{
    if (!Shop::isFeatureActive()) {
        $categories = SimpleBlogCategory::getCategories(Context::getContext()->language->id, false);
        foreach ($categories as $id_category => $category) {
            $instance = new SimpleBlogCategory($id_category, Context::getContext()->language->id);
            $instance->associateTo(Shop::getCompleteListOfShopsID());
            unset($instance);
        }
    }
    return true;
}
Exemplo n.º 2
0
 public function prepareModuleSettings()
 {
     // Database
     $sql = array();
     include dirname(__FILE__) . '/init/install_sql.php';
     foreach ($sql as $s) {
         if (!Db::getInstance()->Execute($s)) {
             die('Error while creating DB');
         }
     }
     /**
     
             Update to 1.6.0.6 problem
     
             **/
     $sql = 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'tab`';
     $tab_columns = Db::getInstance()->executeS($sql);
     $createColumn = true;
     foreach ($tab_columns as $column) {
         if ($column['Field'] == 'hide_host_mode') {
             $createColumn = false;
         }
     }
     if ($createColumn == true) {
         Db::getInstance()->query('ALTER TABLE `' . _DB_PREFIX_ . 'tab` ADD `hide_host_mode` tinyint(1) NOT NULL DEFAULT 0 AFTER  `active`');
     }
     /**
     
             Tabs
     
             **/
     // Tabs
     $parent_tab = new Tab();
     $parent_tab->name = array();
     foreach (Language::getLanguages(true) as $lang) {
         $parent_tab->name[$lang['id_lang']] = $this->l('Blog for PrestaShop');
     }
     $parent_tab->class_name = 'AdminSimpleBlog';
     $parent_tab->id_parent = 0;
     $parent_tab->module = $this->name;
     $parent_tab->add();
     // Categories
     $tab = new Tab();
     $tab->name = array();
     foreach (Language::getLanguages(true) as $lang) {
         $tab->name[$lang['id_lang']] = $this->l('Categories');
     }
     $tab->class_name = 'AdminSimpleBlogCategories';
     $tab->id_parent = $parent_tab->id;
     $tab->module = $this->name;
     $tab->add();
     // Posts
     $tab = new Tab();
     $tab->name = array();
     foreach (Language::getLanguages(true) as $lang) {
         $tab->name[$lang['id_lang']] = $this->l('Posts');
     }
     $tab->class_name = 'AdminSimpleBlogPosts';
     $tab->id_parent = $parent_tab->id;
     $tab->module = $this->name;
     $tab->add();
     // Authors
     // $tab = new Tab();
     // $tab->name = array();
     // foreach (Language::getLanguages(true) as $lang)
     //     $tab->name[$lang['id_lang']] = $this->l('Authors');
     // $tab->class_name = 'AdminSimpleBlogAuthors';
     // $tab->id_parent = $parent_tab->id;
     // $tab->module = $this->name;
     // $tab->add();
     // Comments
     $tab = new Tab();
     $tab->name = array();
     foreach (Language::getLanguages(true) as $lang) {
         $tab->name[$lang['id_lang']] = $this->l('Comments');
     }
     $tab->class_name = 'AdminSimpleBlogComments';
     $tab->id_parent = $parent_tab->id;
     $tab->module = $this->name;
     $tab->add();
     // Tags
     $tab = new Tab();
     $tab->name = array();
     foreach (Language::getLanguages(true) as $lang) {
         $tab->name[$lang['id_lang']] = $this->l('Tags');
     }
     $tab->class_name = 'AdminSimpleBlogTags';
     $tab->id_parent = $parent_tab->id;
     $tab->module = $this->name;
     $tab->add();
     // Settings
     $tab = new Tab();
     $tab->name = array();
     foreach (Language::getLanguages(true) as $lang) {
         $tab->name[$lang['id_lang']] = $this->l('Settings');
     }
     $tab->class_name = 'AdminSimpleBlogSettings';
     $tab->id_parent = $parent_tab->id;
     $tab->module = $this->name;
     $tab->add();
     $id_lang = $this->context->language->id;
     // Default category
     $simple_blog_category = new SimpleBlogCategory();
     foreach (Language::getLanguages(true) as $lang) {
         $simple_blog_category->name[$lang['id_lang']] = 'News';
     }
     foreach (Language::getLanguages(true) as $lang) {
         $simple_blog_category->link_rewrite[$lang['id_lang']] = 'news';
     }
     $simple_blog_category->add();
     $simple_blog_category->associateTo(Shop::getCompleteListOfShopsID());
     // Post Types
     $default_post_type = new SimpleBlogPostType();
     $default_post_type->name = 'Post';
     $default_post_type->slug = 'post';
     $default_post_type->description = 'Default type of post';
     $default_post_type->add();
     $gallery_post_type = new SimpleBlogPostType();
     $gallery_post_type->name = 'Gallery';
     $gallery_post_type->slug = 'gallery';
     $gallery_post_type->add();
     $external_url_post_type = new SimpleBlogPostType();
     $external_url_post_type->name = 'External URL';
     $external_url_post_type->slug = 'url';
     $external_url_post_type->add();
     $video_post_type = new SimpleBlogPostType();
     $video_post_type->name = 'Video';
     $video_post_type->slug = 'video';
     $video_post_type->add();
     // Settings
     Configuration::updateValue('PH_BLOG_POSTS_PER_PAGE', '10');
     Configuration::updateValue('PH_BLOG_FB_COMMENTS', '1');
     Configuration::updateValue('PH_BLOG_SLUG', 'blog');
     Configuration::updateValue('PH_BLOG_COLUMNS', 'prestashop');
     Configuration::updateValue('PH_BLOG_LAYOUT', 'default');
     Configuration::updateValue('PH_BLOG_LIST_LAYOUT', 'grid');
     Configuration::updateValue('PH_BLOG_GRID_COLUMNS', '2');
     Configuration::updateValue('PH_BLOG_MAIN_TITLE', array($this->context->language->id => 'Blog - whats new?'));
     Configuration::updateValue('PH_BLOG_LOAD_FA', '0');
     Configuration::updateValue('PH_BLOG_DISPLAY_AUTHOR', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_DATE', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_THUMBNAIL', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_CATEGORY', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_SHARER', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_TAGS', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_DESCRIPTION', '1');
     // Thumbnails
     Configuration::updateValue('PH_BLOG_THUMB_METHOD', '1');
     Configuration::updateValue('PH_BLOG_THUMB_X', '600');
     Configuration::updateValue('PH_BLOG_THUMB_Y', '300');
     Configuration::updateValue('PH_BLOG_THUMB_X_WIDE', '900');
     Configuration::updateValue('PH_BLOG_THUMB_Y_WIDE', '350');
     // Recent Posts
     Configuration::updateValue('PH_RECENTPOSTS_NB', '4');
     Configuration::updateValue('PH_RECENTPOSTS_CAT', '0');
     Configuration::updateValue('PH_RECENTPOSTS_POSITION', 'home');
     Configuration::updateValue('PH_RECENTPOSTS_LAYOUT', 'grid');
     // @Since 1.1.4
     // Category description
     Configuration::updateValue('PH_BLOG_DISPLAY_CAT_DESC', '1');
     // @since 1.1.5
     Configuration::updateValue('PH_BLOG_POST_BY_AUTHOR', '1');
     // @since 1.1.7
     Configuration::updateValue('PH_BLOG_FB_INIT', '1');
     // @since 1.1.8
     Configuration::updateValue('PH_BLOG_DISPLAY_FEATURED', '1');
     // @since 1.1.9
     //Configuration::updateValue('PH_BLOG_INSTALL', '1');
     // @since 1.1.9.5
     Configuration::updateValue('PH_BLOG_DISPLAY_BREADCRUMBS', '1');
     // @since 1.2.0.0
     Configuration::updateValue('PH_BLOG_DISPLAY_CATEGORY_IMAGE', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_LIKES', '1');
     Configuration::updateValue('PH_BLOG_DISPLAY_VIEWS', '1');
     Configuration::updateValue('PH_CATEGORY_IMAGE_X', '900');
     Configuration::updateValue('PH_CATEGORY_IMAGE_Y', '250');
     Configuration::updateValue('PH_CATEGORY_SORTBY', 'position');
     // @since 1.2.0.6
     Configuration::updateValue('PH_BLOG_DATEFORMAT', 'd M Y, H:i');
     Configuration::updateValue('PH_RECENTPOSTS_GRID_COLUMNS', '2');
     Configuration::updateValue('PH_RELATEDPOSTS_GRID_COLUMNS', '2');
     /**
             
             Update 1.2.2.0 - 07.2014
     
             **/
     // Comments
     Configuration::updateGlobalValue('PH_BLOG_NATIVE_COMMENTS', '1');
     Configuration::updateGlobalValue('PH_BLOG_COMMENT_NOTIFICATIONS', '1');
     // Authors
     Configuration::updateGlobalValue('PH_BLOG_NEW_AUTHORS', '0');
     Configuration::updateGlobalValue('PH_BLOG_AUTHOR_INFO', '1');
     /**
             
             Update 1.2.2.3 - 08.2014
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_COMMENT_AUTO_APPROVAL', '0');
     /**
             
             Update 1.2.2.4 - 08.2014
     
             **/
     /**
             
             Update 1.2.2.5 - 08.2014
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_COMMENT_ALLOW', '1');
     Configuration::updateGlobalValue('PH_BLOG_COMMENT_STUFF_HIGHLIGHT', '1');
     Configuration::updateGlobalValue('PH_BLOG_COMMENT_NOTIFY_EMAIL', Configuration::get('PS_SHOP_EMAIL'));
     /**
             
             Update 1.2.2.6 - 09.2014
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_FACEBOOK_MODERATOR', '');
     Configuration::updateGlobalValue('PH_BLOG_FACEBOOK_APP_ID', '');
     Configuration::updateGlobalValue('PH_BLOG_FACEBOOK_COLOR_SCHEME', 'light');
     /**
     
             Update 1.2.2.8 - 09.2014
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_DISPLAY_MORE', '1');
     /**
     
             Update 1.2.2.9 - 09.2014
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_MASONRY_LAYOUT', '0');
     /**
     
             Update 1.3.1.6 - 10.2014
     
             **/
     if (function_exists('date_default_timezone_get')) {
         $timezone = @date_default_timezone_get();
     } else {
         $timezone = 'Europe/Warsaw';
     }
     Configuration::updateGlobalValue('PH_BLOG_TIMEZONE', $timezone);
     /**
     
             Update 1.3.1.9 - 11.2014
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_LOAD_FONT_AWESOME', 1);
     Configuration::updateGlobalValue('PH_BLOG_LOAD_BXSLIDER', 1);
     Configuration::updateGlobalValue('PH_BLOG_LOAD_MASONRY', 1);
     Configuration::updateGlobalValue('PH_BLOG_LOAD_FITVIDS', 1);
     /**
     
             Update 1.3.2.5 - 01.2015
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_DISPLAY_RELATED', 1);
     /**
     
             Update 1.3.2.8 - 02.2015
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_COMMENT_ALLOW_GUEST', false);
     Configuration::updateGlobalValue('PH_BLOG_COMMENTS_RECAPTCHA', true);
     Configuration::updateGlobalValue('PH_BLOG_COMMENTS_RECAPTCHA_SITE_KEY', '');
     Configuration::updateGlobalValue('PH_BLOG_COMMENTS_RECAPTCHA_SECRET_KEY', '');
     Configuration::updateGlobalValue('PH_BLOG_COMMENTS_RECAPTCHA_THEME', 'light');
     /**
     
             Update 1.3.2.9 - 02.2015
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_RELATED_PRODUCTS_USE_DEFAULT_LIST', false);
     /**
     
             Update 1.3.3 - 02.2015
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_ADVERTISING', true);
     /**
     
             Update 1.4.0 - 06.2015
     
             **/
     Configuration::updateGlobalValue('PH_BLOG_COMMENTS_SYSTEM', 'native');
     Configuration::updateGlobalValue('PH_BLOG_DISQUS_SHORTNAME', 'blogforprestashop');
     /**
             
                 For theme developers - you're welcome!
     
             **/
     if (file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/init/my-install.php')) {
         include_once _PS_MODULE_DIR_ . 'ph_simpleblog/init/my-install.php';
     }
     return true;
 }