Просмотр исходного кода

Example of module's Update script.

AntonLV 13 лет назад
Родитель
Сommit
a2bdcd4547

+ 78 - 0
modules/boonex/sites/updates/update_100_200/install/config.php

@@ -0,0 +1,78 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'title' => 'Sites',
+    'version_from' => '1.0.0',
+	'version_to' => '2.0.0',
+    'vendor' => 'BoonEx',
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/sites/updates/update_100_200/',
+	'home_uri' => 'sites_update_100_200',
+
+	'module_dir' => 'boonex/sites/',
+	'module_uri' => 'sites',
+
+    'db_prefix' => 'bx_sites_',
+    'class_prefix' => 'BxSites',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+		'show_introduction' => 0,
+		'change_permissions' => 0,
+		'execute_sql' => 1,
+        'update_files' => 0,
+        'update_languages' => 1,
+		'recompile_global_paramaters' => 0,
+        'recompile_main_menu' => 0,
+        'recompile_member_menu' => 0,
+        'recompile_site_stats' => 0,
+        'recompile_page_builder' => 0,
+        'recompile_profile_fields' => 0,
+        'recompile_comments' => 0,
+        'recompile_member_actions' => 0,
+        'recompile_tags' => 0,
+        'recompile_votes' => 0,
+        'recompile_categories' => 0,
+        'recompile_search' => 0,
+        'recompile_injections' => 0,
+        'recompile_permalinks' => 0,
+        'recompile_alerts' => 0,
+		'clear_db_cache' => 0,
+        'show_conclusion' => 0
+    ),
+
+	/**
+     * Category for language keys.
+     */
+    'language_category' => 'Sites',
+
+    /**
+     * Permissions Section
+     */
+    'install_permissions' => array(),
+    'uninstall_permissions' => array(),
+
+    /**
+     * Introduction and Conclusion Section.
+     */
+    'install_info' => array(
+        'introduction' => 'inst_intro.html',
+        'conclusion' => 'inst_concl.html'
+    ),
+    'uninstall_info' => array(
+        'introduction' => 'uninst_intro.html',
+        'conclusion' => 'uninst_concl.html'
+    )
+);

+ 2 - 0
modules/boonex/sites/updates/update_100_200/install/info/inst_concl.html

@@ -0,0 +1,2 @@
+Congratulation!!! 
+P.S. It's easy to install and easy to use. :)

+ 1 - 0
modules/boonex/sites/updates/update_100_200/install/info/inst_intro.html

@@ -0,0 +1 @@
+Follow the instructions carefully!!!

+ 1 - 0
modules/boonex/sites/updates/update_100_200/install/info/uninst_concl.html

@@ -0,0 +1 @@
+You don't like our module  :(

+ 1 - 0
modules/boonex/sites/updates/update_100_200/install/info/uninst_intro.html

@@ -0,0 +1 @@
+NO, NO, NO... Don't do it.

+ 15 - 0
modules/boonex/sites/updates/update_100_200/install/installer.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ */
+
+bx_import('BxDolStudioUpdater');
+
+class BxSitesUpdater extends BxDolStudioUpdater
+{
+    function __construct($aConfig)
+	{
+        parent::__construct($aConfig);
+    }
+}

+ 10 - 0
modules/boonex/sites/updates/update_100_200/install/langs/en.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="en" flag="gb" title="English">
+	<string_del name="_bx_sites_paypal_err_subscribe" />
+	<string_del name="_bx_sites_paypal_msg_subscribe" />
+
+	<string_add name="_bx_sites_updated_successfully"><![CDATA[The module was successfully updated!]]></string_add>
+
+	<string_upd name="_bx_sites"><![CDATA[Sites (Updated)]]></string_upd>
+	<string_upd name="_bx_sites_form_site"><![CDATA[Sites (Updated)]]></string_upd>
+</resources>

+ 31 - 0
modules/boonex/sites/updates/update_100_200/install/sql/install.sql

@@ -0,0 +1,31 @@
+--
+-- Table structure for table `[db_prefix]updated`
+--
+
+CREATE TABLE IF NOT EXISTS `[db_prefix]updated` (
+  `id` int(11) unsigned NOT NULL auto_increment,
+  `author_id` int(11) unsigned NOT NULL default '0',  
+  `caption` varchar(100) NOT NULL default '',
+  `snippet` text NOT NULL,
+  `content` mediumtext NOT NULL,
+  `when` int(11) NOT NULL default '0',
+  `uri` varchar(100) NOT NULL default '',
+  `tags` varchar(255) NOT NULL default '',
+  `categories` varchar(255) NOT NULL default '',
+  `comment` tinyint(0) NOT NULL default '0',
+  `vote` tinyint(0) NOT NULL default '0',
+  `date` int(11) NOT NULL default '0',
+  `status` tinyint(4) NOT NULL default '0',
+  `featured` tinyint(4) NOT NULL default '0',
+  `rate` int(11) NOT NULL default '0',
+  `rate_count` int(11) NOT NULL default '0',
+  `view_count` int(11) NOT NULL default '0',
+  `cmts_count` int(11) NOT NULL default '0',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `uri` (`uri`),
+  FULLTEXT KEY `search_group` (`caption`, `content`, `tags`, `categories`),
+  FULLTEXT KEY `search_caption` (`caption`),
+  FULLTEXT KEY `search_content` (`content`),
+  FULLTEXT KEY `search_tags` (`tags`),
+  FULLTEXT KEY `search_categories` (`categories`)
+) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

+ 158 - 0
modules/boonex/sites/updates/update_100_200/source/classes/BxSitesUpdated.php

@@ -0,0 +1,158 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ */
+
+bx_import('BxDolTextModule');
+
+require_once('BxArlCalendar.php');
+require_once('BxArlCmts.php');
+require_once('BxArlVoting.php');
+require_once('BxArlSearchResult.php');
+require_once('BxArlData.php');
+
+/**
+ * Articles module by BoonEx
+ *
+ * This module is needed to manage site articles.
+ *
+ *
+ * Profile's Wall:
+ * no spy events
+ *
+ *
+ *
+ * Spy:
+ * no spy events
+ *
+ *
+ *
+ * Memberships/ACL:
+ * Doesn't depend on user's membership.
+ *
+ *
+ *
+ * Service methods:
+ *
+ * Get post block.
+ * @see BxArlModule::servicePostBlock
+ * BxDolService::call('articles', 'post_block');
+ * @note is needed for internal usage.
+ *
+ * Get edit block.
+ * @see BxArlModule::serviceEditBlock
+ * BxDolService::call('articles', 'edit_block', array($mixed));
+ * @note is needed for internal usage.
+ *
+ * Get administration block.
+ * @see BxArlModule::serviceAdminBlock
+ * BxDolService::call('articles', 'admin_block', array($iStart, $iPerPage, $sFilterValue));
+ * @note is needed for internal usage.
+ *
+ * Get block with all articles ordered by the time of posting.
+ * @see BxArlModule::serviceArchiveBlock
+ * BxDolService::call('articles', 'archive_block', array($iStart, $iPerPage));
+ * @note is needed for internal usage.
+ *
+ * Get block with articles marked as featured.
+ * @see BxArlModule::serviceFeaturedBlock
+ * BxDolService::call('articles', 'featured_block', array($iStart, $iPerPage));
+ * @note is needed for internal usage.
+ *
+ * Get block with articles ordered by their rating.
+ * @see BxArlModule::serviceTopRatedBlock
+ * BxDolService::call('articles', 'top_rated_block', array($iStart, $iPerPage));
+ * @note is needed for internal usage.
+ *
+ * Get block with all articles ordered by their popularity(number of views).
+ * @see BxArlModule::servicePopularBlock
+ * BxDolService::call('articles', 'popular_block', array($iStart, $iPerPage));
+ * @note is needed for internal usage.
+ *
+ *
+ * Alerts:
+ * Alerts type/unit - 'articles'
+ * The following alerts are rised
+ *
+ *  post - article is added
+ *      $iObjectId - article id
+ *      $iSenderId - admin's id
+ *
+ *  edit - article was modified
+ *      $iObjectId - article id
+ *      $iSenderId - admin's id
+ *
+ *  featured - article was marked as featured
+ *      $iObjectId - article id
+ *      $iSenderId - admin's id
+ *
+ *  publish - article was published
+ *      $iObjectId - article id
+ *      $iSenderId - admin's id
+ *
+ *  unpublish - article was unpublished
+ *      $iObjectId - article id
+ *      $iSenderId - admin's id
+ *
+ *  delete - article was deleted
+ *      $iObjectId - article id
+ *      $iSenderId - admin's id
+ *
+ */
+class BxArlModule extends BxDolTextModule
+{
+    /**
+     * Constructor
+     */
+    function BxArlModule($aModule)
+    {
+        parent::BxDolTextModule($aModule);
+
+        //--- Define Membership Actions ---//
+        defineMembershipActions(array('articles delete'), 'ACTION_ID_');
+    }
+
+    /**
+     * Service methods
+     */
+    function serviceArticlesRss($iLength = 0)
+    {
+        return $this->actionRss($iLength);
+    }
+
+    /**
+     * Action methods
+     */
+    function actionGetArticles($sSampleType = 'all', $iStart = 0, $iPerPage = 0)
+    {
+        return $this->actionGetEntries($sSampleType, $iStart, $iPerPage);
+    }
+
+    /**
+     * Private methods.
+     */
+    function _createObjectCalendar($iYear, $iMonth)
+    {
+        return new BxArlCalendar($iYear, $iMonth, $this->_oDb, $this->_oConfig);
+    }
+    function _createObjectCmts($iId)
+    {
+        return new BxArlCmts($this->_oConfig->getCommentsSystemName(), $iId);
+    }
+    function _createObjectVoting($iId)
+    {
+        return new BxArlVoting($this->_oConfig->getVotesSystemName(), $iId);
+    }
+    function _isDeleteAllowed($bPerform = false)
+    {
+        if(!isLogged())
+            return false;
+
+        if(isAdmin())
+            return true;
+
+        $aCheckResult = checkAction(getLoggedId(), ACTION_ID_ARTICLES_DELETE, $bPerform);
+        return $aCheckResult[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
+    }
+}

+ 97 - 0
modules/boonex/sites/updates/update_100_200/source/install/config.php

@@ -0,0 +1,97 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ * 
+ * @defgroup    Notes Notes
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_sites',
+    'title' => 'Sites',
+    'note' => 'Sites module.',
+    'version' => '2.0.0',
+    'vendor' => 'Boonex',
+    'product_url' => 'http://www.boonex.com/products/{uri}',
+    'update_url' => 'http://www.boonex.com/products/{uri}',
+
+    'compatible_with' => array(
+        '8.0.x'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/sites/',
+    'home_uri' => 'sites',
+
+    'db_prefix' => 'bx_sites_',
+    'class_prefix' => 'BxSites',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'execute_sql' => 1,
+        'update_languages' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'uninstall' => array (
+        'execute_sql' => 1,
+        'update_languages' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'enable' => array(
+        'execute_sql' => 1,
+        'recompile_main_menu' => 1,
+        'recompile_permalinks' => 1,
+        'recompile_alerts' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'disable' => array (
+        'execute_sql' => 1,
+        'recompile_main_menu' => 1,
+        'recompile_permalinks' => 1,
+        'recompile_alerts' => 1,
+        'clear_db_cache' => 1,
+    ),
+
+    /**
+     * Dependencies Section
+     */
+    'dependencies' => array(
+    ),
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Sites',
+
+    /**
+     * Permissions Section
+     */
+    'install_permissions' => array(),
+    'uninstall_permissions' => array(),
+
+    /**
+     * Introduction and Conclusion Section.
+     */
+    'install_info' => array(
+        'introduction' => '',
+        'conclusion' => ''
+    ),
+    'uninstall_info' => array(
+        'introduction' => '',
+        'conclusion' => ''
+    )
+);
+
+/** @} */