RomanL 8 лет назад
Родитель
Сommit
4a2a5a5900

+ 40 - 0
modules/boonex/quoteofday/classes/BxQuoteofdayConfig.php

@@ -0,0 +1,40 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) Vendor
+ * 
+ * @defgroup    Quote of the Day
+ * @ingroup     VendorModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModuleConfig');
+
+class BxQuoteofdayConfig extends BxDolModuleConfig 
+{
+	function __construct($aModule) 
+    {
+	    parent::__construct($aModule);
+		$this->CNF = array (
+			'OBJECT_GRID' => 'bx_quoteofday_internal',
+			'CACHEKEY' => 'bx_quoteofday',
+			 // database tables
+            'TABLE_ENTRIES' => $aModule['db_prefix'] . 'internal',
+			
+			 // database fields
+            'FIELD_ID' => 'id',
+            'FIELD_AUTHOR' => 'author',
+            'FIELD_ADDED' => 'added',
+            'FIELD_TEXT' => 'text',
+			'FIELD_STATUS' => 'status',
+        	'FIELD_STATUS_ADMIN' => 'status_admin',
+		);
+		
+		$this->_aGridObjects = array(
+        	'common' => $this->CNF['OBJECT_GRID'],
+        );
+		
+    }   
+}
+
+/** @} */

+ 38 - 0
modules/boonex/quoteofday/classes/BxQuoteofdayDb.php

@@ -0,0 +1,38 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) Vendor
+ * 
+ * @defgroup    Quote of the Day module
+ * @ingroup     VendorModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModuleDb');
+
+class BxQuoteofdayDb extends BxBaseModGeneralDb
+{
+	
+	
+	function __construct(&$oConfig) 
+    {
+		parent::__construct($oConfig);	
+    }
+	
+	public function getHiddenItemsCount()
+	{
+		$CNF=$this->_oConfig->CNF;
+		$sSql = $this->prepare("SELECT COUNT(*) FROM ".$CNF['TABLE_ENTRIES']." WHERE ".$CNF['FIELD_STATUS']."!='active' OR ".$CNF['FIELD_STATUS_ADMIN']."!='active' ");
+		return $this->getOne($sSql);
+	}
+	
+	public function getData()
+	{
+		$CNF = &$this->_oConfig->CNF;
+		return  $this->getColumn ("SELECT `".$CNF['FIELD_TEXT']."` FROM ".$CNF['TABLE_ENTRIES']." WHERE ".$CNF['FIELD_STATUS']."='active' AND ".$CNF['FIELD_STATUS_ADMIN']."='active'");
+	}
+	
+}
+
+
+/** @} */

+ 111 - 0
modules/boonex/quoteofday/classes/BxQuoteofdayGridInternal.php

@@ -0,0 +1,111 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup     Quote of the Day module
+ * @ingroup     UnaModules
+ * 
+ * @{
+ */
+
+class BxQuoteofdayGridInternal extends BxTemplGrid
+{
+	protected $MODULE;
+	protected $_oModule;
+	
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        $this->MODULE = 'bx_quoteofday';
+    	$this->_oModule = BxDolModule::getInstance($this->MODULE);
+        parent::__construct ($aOptions, $oTemplate);
+    }
+	
+	protected function _getCellText($mixedValue, $sKey, $aField, $aRow)
+    {
+        $mixedValue=strip_tags(htmlspecialchars_decode($mixedValue));
+        return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
+    }
+	
+	
+	public function performActionAdd()
+    {
+		$oCheckAllowedViewValue=$this->_oModule->checkAcl();
+		if ($oCheckAllowedViewValue !== CHECK_ACTION_RESULT_ALLOWED)
+			return "";
+			
+		$sAction = 'add';
+		$oForm = BxDolForm::getObjectInstance('bx_quoteofday','bx_quoteofday_entry_add'); // get form instance for specified form object and display
+		if (!$oForm)
+			return '';
+		$oForm->aFormAttrs['action']=BX_DOL_URL_ROOT . 'grid.php?' . bx_encode_url_params($_GET, array('ids', '_r'));
+		$oForm->initChecker();
+        if($oForm->isSubmittedAndValid()) {
+			$mixedResult = $oForm->insert(array('added' => time()));
+			if(is_numeric($mixedResult))
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $mixedResult);
+            else
+                $aRes = array('msg' => $mixedResult);
+			echoJson($aRes);
+        }
+        else {
+			
+            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx_quoteofday_form_add', _t('_bx_quoteofday_form_add_title'), 	$this->_oModule->_oTemplate->parseHtmlByName('manage_item.html', array(
+                'form_id' => $oForm->id,
+                'form' => $oForm->getCode(true),
+                'object' => $this->_sObject,
+                'action' => $sAction
+            )));
+           echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => true))));
+        }
+	}
+    
+	public function performActionEdit()
+    {
+		$oCheckAllowedViewValue=$this->_oModule->checkAcl();
+		if ($oCheckAllowedViewValue !== CHECK_ACTION_RESULT_ALLOWED)
+			return "";
+		
+		$sAction = 'edit';
+		$aIds = bx_get('ids');
+		$iId = $aIds[0];
+		$oForm = BxDolForm::getObjectInstance('bx_quoteofday','bx_quoteofday_entry_edit'); // get form instance for specified form object and display
+		if (!$oForm)
+			return '';
+		$oForm->aFormAttrs['action']=BX_DOL_URL_ROOT . 'grid.php?' . bx_encode_url_params($_GET, array('_r'));
+		$aContentInfo=array();
+		$aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
+		$oForm->initChecker($aContentInfo, array());
+        if($oForm->isSubmittedAndValid()) {
+			$mixedResult = $oForm->update($iId);
+			if(is_numeric($mixedResult))
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $mixedResult);
+            else
+                $aRes = array('msg' => $mixedResult);
+			echoJson($aRes);
+        }
+        else {
+			
+            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx_quoteofday_form_edit', _t('_bx_quoteofday_form_edit_title'), 	$this->_oModule->_oTemplate->parseHtmlByName('manage_item.html', array(
+                'form_id' => $oForm->id,
+                'form' => $oForm->getCode(true),
+                'object' => $this->_sObject,
+                'action' => $sAction
+            )));
+           echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => true))));
+        }
+	}
+    
+    public function performActionPublish()
+    {
+        $aIds = bx_get('ids');
+		$iId = $aIds[0];
+        $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
+        $this->_oModule->PutQuoteToCache($aContentInfo["text"]);
+        $aRes = array('msg' => _t('_bx_quoteofday_grid_action_title_adm_publish_text'));
+        echoJson($aRes);
+    }
+	
+}
+
+/** @} */

+ 148 - 0
modules/boonex/quoteofday/classes/BxQuoteofdayModule.php

@@ -0,0 +1,148 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) Vendor
+ * 
+ * @defgroup    Quote of the Day module
+ * @ingroup     VendorModules
+ *
+ * @{
+ */
+define('BX_QOD_SOURCE_INTERNAL', 'internal');
+define('BX_QOD_SOURCE_RSS', 'rss');
+
+bx_import('BxDolModule');
+
+class BxQuoteofdayModule extends BxBaseModGeneralModule 
+{
+    function __construct(&$aModule) 
+    {
+        parent::__construct($aModule);
+    }
+
+	// ====== SERVICE METHODS
+	public function serviceGetSources()
+    {
+		//RL-TO-IMPROVE GET SOURCES FROM DB AND MULTISELECT
+        $aResult = array();
+        $aChoices = array(BX_QOD_SOURCE_INTERNAL, BX_QOD_SOURCE_RSS);
+        foreach($aChoices as $sChoice) 
+		 	$aResult[$sChoice]=_t('_bx_quoteofday_source_'. $sChoice);
+        return $aResult;
+    }
+	
+	public function serviceGetMenuAddonManageTools()
+	{
+		return $this->_oDb->getHiddenItemsCount();
+	}
+	
+	//##### get current Quote  #####
+	/*public function actionGetQuote()
+    {
+		echo $this->serviceGetQuote();
+	}
+	*/
+	
+	public function serviceGetQuote()
+    {
+		$oCachObject = $this->_oDb->getDbCacheObject();
+		return $oCachObject->getData($this->_oConfig->CNF['CACHEKEY']);
+	}
+	
+	
+	//##### Set current Quote from cron #####
+	/*public function actionSetQuote()
+    {
+		echo $this->serviceSetQuote();
+	}*/
+	
+	
+	public function serviceSetQuote()
+    {
+		$sRssUrl = getParam('bx_quoteofday_rss_url');
+		$iRssMaxItems = intval(getParam('bx_quoteofday_rss_max_items'));
+		$aSources=explode(',',getParam('bx_quoteofday_source'));
+		
+		$aData=array();
+		
+		//##### Get data from internal set #####
+		if (in_array(BX_QOD_SOURCE_INTERNAL,$aSources))
+		{
+			$aData=array_merge($aData,$this->getInternalData());
+		}
+		
+		//##### Get data from rss #####
+		if (in_array(BX_QOD_SOURCE_RSS,$aSources) && $sRssUrl!="" && $iRssMaxItems>0)
+			$aData = array_merge($aData,$this->getRssData($sRssUrl,$iRssMaxItems));
+		
+		
+		$iDayOfYear = date('z');
+		//$iDayOfYear=rand(1,365);
+		$iIndex = $iDayOfYear % count($aData);
+        $this->PutQuoteToCache($aData[$iIndex]);
+	}
+    
+    
+    public function PutQuoteToCache($quoteText)
+    {
+        $oCachObject = $this->_oDb->getDbCacheObject();
+		$oCachObject->setData($this->_oConfig->CNF['CACHEKEY'],$quoteText);
+    }
+	
+	private function getInternalData()
+    {
+		return $this->_oDb->getData();
+	}
+	
+	private function getRssData($sRssUrl,$iRssMaxItems)
+    {
+		$oTmpRv=array();
+		$oXmlParser = BxDolXmlParser::getInstance();
+        $sXmlContent = file_get_contents($sRssUrl);
+		
+		$oTmp=$oXmlParser->getTags($sXmlContent, 'description');
+		if (is_array($oTmp))
+		{
+			$iC=0;
+			while (list($key,$value ) = each($oTmp)) {
+				if ($iC==$iRssMaxItems) break;
+				if (isset($value['value']) && $value['level']==4 && trim(strip_tags($value['value'])) != "")
+				{
+					array_push($oTmpRv,$value['value']);
+					$iC++;
+				}
+			}
+		}
+		return $oTmpRv;
+	}
+	
+	public function serviceGetQuotesManage()
+    {
+		$oCheckAllowedViewValue=$this->checkAcl();
+		if ($oCheckAllowedViewValue !== CHECK_ACTION_RESULT_ALLOWED)
+			return MsgBox($oCheckAllowedViewValue);
+	
+		$this->_oTemplate->addJs('jquery.form.min.js');
+		$oGrid = BxDolGrid::getObjectInstance($this->_oConfig->CNF['OBJECT_GRID']);
+		if(!$oGrid)
+			return '';
+		return $oGrid->getCode();
+	
+    }
+	
+	
+	 /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAcl ($isPerformAction = false)
+    {
+        // check ACL
+        $aCheck = checkActionModule($this->_iProfileId, 'manage entries', $this->getName(), $isPerformAction);
+        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return $aCheck[CHECK_ACTION_MESSAGE];
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+	 
+	
+}
+
+/** @} */

+ 32 - 0
modules/boonex/quoteofday/classes/BxQuoteofdayStudioPage.php

@@ -0,0 +1,32 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Forum Forum
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+define('BX_DOL_STUDIO_MOD_TYPE_QUOTES', 'quotes');
+
+class BxQuoteofdayStudioPage extends BxTemplStudioModule
+{
+	protected $_sModule;
+	protected $_oModule;
+
+    function __construct($sModule = "", $sPage = "")
+    {
+    	$this->_sModule = 'bx_quoteofday';
+    	$this->_oModule = BxDolModule::getInstance($this->_sModule);
+
+        parent::__construct($sModule, $sPage);
+		
+		$oPermalink = BxDolPermalinks::getInstance();
+      	$this->aMenuItems[] = array('name' =>BX_DOL_STUDIO_MOD_TYPE_QUOTES , 'icon' => 'bars', 'title' => '_bx_quoteofday_lmi_cpt_quotes', 'link' => BX_DOL_URL_ROOT . $oPermalink->permalink('page.php?i=quoteofday-manage'));
+    }
+
+}
+
+/** @} */

+ 21 - 0
modules/boonex/quoteofday/classes/BxQuoteofdayTemplate.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) Vendor
+ * 
+ * @defgroup    Quote of the Day module
+ * @ingroup     VendorModules
+ *
+ * @{
+ */
+
+bx_import ('BxDolModuleTemplate');
+
+class BxQuoteofdayTemplate extends BxDolModuleTemplate 
+{    
+	function __construct(&$oConfig, &$oDb) 
+    {
+	    parent::__construct($oConfig, $oDb);
+    }    
+}
+
+/** @} */

+ 80 - 0
modules/boonex/quoteofday/install/config.php

@@ -0,0 +1,80 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Quote of the Day
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_quoteofday',
+    'title' => 'Quote of the Day',
+    'note' => 'Quote of the Day module.',
+    'version' => '1.0.0',
+    'vendor' => 'BoonEx',
+	'help_url' => 'http://feed.una.io/?section={module_name}',
+
+    'compatible_with' => array(
+        '9.0.0-RC4'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/quoteofday/',
+    'home_uri' => 'quoteofday',
+
+    'db_prefix' => 'bx_quoteofday_',
+    'class_prefix' => 'BxQuoteofday',
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Quoteofday',
+
+    /**
+     * 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,
+        'clear_db_cache' => 1,
+    ),
+    'enable_success' => array(
+        'clear_db_cache' => 1,
+    ),
+    'disable' => array (
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'disable_failed' => array (
+        'clear_db_cache' => 1,
+    ),
+
+    /**
+     * Dependencies Section
+     */
+    'dependencies' => array(),
+
+    
+
+);
+
+/** @} */

+ 20 - 0
modules/boonex/quoteofday/install/installer.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Quote of the Day
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxQuoteofdayInstaller extends BxBaseModTextInstaller
+{
+    function __construct($aConfig)
+    {
+        parent::__construct($aConfig);
+    }
+}
+
+/** @} */

+ 29 - 0
modules/boonex/quoteofday/install/langs/en.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="en" flag="gb" title="English">
+	<string name="_bx_quoteofday"><![CDATA[Quote of the Day]]></string>
+	<string name="_bx_quoteofday_option_rss_url"><![CDATA[Url of external RSS feed]]></string>
+	<string name="_bx_quoteofday_lmi_cpt_quotes"><![CDATA[Quotes List]]></string>
+	<string name="_bx_quoteofday_source"><![CDATA[Source]]></string>
+	<string name="_bx_quoteofday_rss_max_items"><![CDATA[Max number of items from RSS]]></string>
+	<string name="_bx_quoteofday_source_internal"><![CDATA[Internal List]]></string>
+	<string name="_bx_quoteofday_source_rss"><![CDATA[Rss feed]]></string>
+	<string name="_bx_quoteofday_grid_column_title_adm_active"><![CDATA[Active]]></string>
+	<string name="_bx_quoteofday_grid_column_title_adm_text"><![CDATA[Text]]></string>
+	<string name="_bx_quoteofday_grid_column_title_adm_added"><![CDATA[Added]]></string>
+	<string name="_bx_quoteofday_grid_action_title_adm_add"><![CDATA[Add new]]></string>
+  <string name="_bx_quoteofday_grid_action_title_adm_edit"><![CDATA[Edit]]></string>
+  <string name="_bx_quoteofday_grid_action_title_adm_delete"><![CDATA[Delete]]></string>
+  <string name="_bx_quoteofday_grid_action_title_adm_publish"><![CDATA[Mark as Today Quote]]></string>
+  <string name="_bx_quoteofday_grid_action_title_adm_publish_text"><![CDATA[Item set as Today Quote]]></string>
+  <string name="_bx_quoteofday_form_entry_input_do_submit"><![CDATA[Save]]></string>
+	<string name="_bx_quoteofday_form_add_title"><![CDATA[Add new]]></string>
+	<string name="_bx_quoteofday_form_entry_input_text"><![CDATA[Text]]></string>
+	<string name="_bx_quoteofday_form_edit_title"><![CDATA[Edit]]></string>
+	<string name="_bx_quoteofday_page_title_manage"><![CDATA[Quote of the Day management]]></string>
+	<string name="_bx_quoteofday_page_block_title_manage"><![CDATA[Quote of the Day management]]></string>
+	<string name="_bx_quoteofday_page_block_title"><![CDATA[Quote of the Day]]></string>
+	<string name="_bx_quoteofday_form_entry_input_cancel"><![CDATA[Cancel]]></string>
+	<string name="_bx_quoteofday_acl_action_manage_entries"><![CDATA[use Quote of the Day management]]></string>
+	<string name="_bx_quoteofday_menu_item_title_system_admt_manage"><![CDATA[Quotes of the day - {addon} hidden]]></string>
+	<string name="_bx_quoteofday_form_entry_input_text_err"><![CDATA[Text field can't be empty]]></string>
+</resources>

+ 27 - 0
modules/boonex/quoteofday/install/sql/disable.sql

@@ -0,0 +1,27 @@
+
+-- SETTINGS
+SET @iTypeId = (SELECT `ID` FROM `sys_options_types` WHERE `name` = 'bx_quoteofday' LIMIT 1);
+SET @iCategId = (SELECT `ID` FROM `sys_options_categories` WHERE `type_id` = @iTypeId LIMIT 1);
+DELETE FROM `sys_options` WHERE `category_id` = @iCategId;
+DELETE FROM `sys_options_categories` WHERE `type_id` = @iTypeId;
+DELETE FROM `sys_options_types` WHERE `id` = @iTypeId;
+
+-- GRIDS
+DELETE FROM `sys_objects_grid` WHERE `object` IN ('bx_quoteofday_internal');
+DELETE FROM `sys_grid_fields` WHERE `object` IN ('bx_quoteofday_internal');
+DELETE FROM `sys_grid_actions` WHERE `object` IN ('bx_quoteofday_internal');
+
+-- CRON
+DELETE FROM sys_cron_jobs WHERE `name` in('bxquoteofday');
+
+-- PAGES
+DELETE FROM `sys_objects_page` WHERE `module` = 'bx_quoteofday';
+DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_quoteofday';
+
+-- MENU
+DELETE FROM `sys_menu_items` WHERE `module` = 'bx_quoteofday';
+
+-- ACL
+DELETE `sys_acl_actions`, `sys_acl_matrix` FROM `sys_acl_actions`, `sys_acl_matrix` WHERE `sys_acl_matrix`.`IDAction` = `sys_acl_actions`.`ID` AND `sys_acl_actions`.`Module` = 'bx_quoteofday';
+DELETE FROM `sys_acl_actions` WHERE `Module` = 'bx_quoteofday';
+

+ 77 - 0
modules/boonex/quoteofday/install/sql/enable.sql

@@ -0,0 +1,77 @@
+-- SETTINGS
+
+SET @iTypeOrder = (SELECT IFNULL(MAX(`order`), 0) + 1 FROM `sys_options_types` WHERE `group` = 'modules');
+
+INSERT INTO sys_options_types(`group`, name, caption, icon, `order`) 
+VALUES('modules', 'bx_quoteofday', '_bx_quoteofday_adm_stg_cpt_type', 'bx_quoteofday@modules/boonex/quoteofday/|std-icon.svg', IF(ISNULL(@iTypeOrder), 1, @iTypeOrder + 1));
+SET @iTypeId = LAST_INSERT_ID();
+
+INSERT INTO sys_options_categories(`type_id`, name, caption, hidden, `order`) VALUES(@iTypeId,  'bx_quoteofday_general', '_bx_quoteofday_adm_stg_cpt_category_general', 0, 1);
+SET @iCategoryId = LAST_INSERT_ID();
+
+
+INSERT INTO sys_options(category_id, name, caption, value, type, extra, `check`, check_params, check_error, `order`) VALUES
+(@iCategoryId, 'bx_quoteofday_source', '_bx_quoteofday_source', 'internal', 'list', 'a:2:{s:6:"module";s:13:"bx_quoteofday";s:6:"method";s:11:"get_sources";}', '', '', '', 1),
+(@iCategoryId, 'bx_quoteofday_rss_url', '_bx_quoteofday_option_rss_url', '', 'digit', '', '', '', '', 2),
+(@iCategoryId, 'bx_quoteofday_rss_max_items', '_bx_quoteofday_rss_max_items', '5', 'digit', '', '', '', '', 3);
+
+
+-- GRIDS: moderation tools
+INSERT INTO sys_objects_grid(object, source_type, source, `table`, field_id, field_order, field_active, paginate_url, paginate_per_page, paginate_simple, paginate_get_start, paginate_get_per_page, filter_fields, filter_fields_translatable, filter_mode, sorting_fields, sorting_fields_translatable, visible_for_levels, override_class_name, override_class_file) 
+VALUES('bx_quoteofday_internal', 'Sql', 'SELECT * FROM `bx_quoteofday_internal` WHERE 1 ', 'bx_quoteofday_internal', 'id', 'added', 'status', '', 20, NULL, 'start', '', 'text', '', 'auto', '', '', 2147483647, 'BxQuoteofdayGridInternal', 'modules/boonex/quoteofday/classes/BxQuoteofdayGridInternal.php');
+
+
+INSERT INTO sys_grid_fields(object, name, title, width, translatable, chars_limit, params, `order`) VALUES
+('bx_quoteofday_internal', 'checkbox', '_sys_select', '2%', 0, 0, '', 1),
+('bx_quoteofday_internal', 'switcher', '_bx_quoteofday_grid_column_title_adm_active', '8%', 0, 0, '', 2),
+('bx_quoteofday_internal', 'text', '_bx_quoteofday_grid_column_title_adm_text', '40%', 0, 35, '', 3),
+('bx_quoteofday_internal', 'actions', '', '20%', 0, 0, '', 5);
+
+
+
+INSERT INTO sys_grid_actions(object, type, name, title, icon, icon_only, confirm, `order`) VALUES
+('bx_quoteofday_internal', 'single', 'edit', '_bx_quoteofday_grid_action_title_adm_edit', 'pencil', 1, 0, 1),
+('bx_quoteofday_internal', 'single', 'publish', '_bx_quoteofday_grid_action_title_adm_publish', 'quote-right', 1, 0, 3),
+('bx_quoteofday_internal', 'single', 'delete', '_bx_quoteofday_grid_action_title_adm_delete', 'remove', 1, 1, 2),
+('bx_quoteofday_internal', 'bulk', 'delete', '_bx_quoteofday_grid_action_title_adm_delete', '', 0, 1, 1),
+('bx_quoteofday_internal', 'independent', 'add', '_bx_quoteofday_grid_action_title_adm_add', 'add', 0, 0, 1);
+
+-- CRON
+
+INSERT INTO sys_cron_jobs(`name`, `time`, class, `file`, service_call) VALUES('bx_quoteofday', '0 1 * * *', 'BxQuoteofdayModule', '', 'a:2:{s:6:"module";s:13:"bx_quoteofday";s:6:"method";s:9:"set_quote";}');
+
+-- PAGE: add block to homepage
+SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = 'sys_home' AND `cell_id` = 1 ORDER BY `order` DESC LIMIT 1);
+
+INSERT INTO sys_pages_blocks(object, cell_id, module, title_system, title, designbox_id, visible_for_levels, hidden_on, type, content, deletable, copyable, active, `order`) VALUES('sys_home', 1, 'bx_quoteofday', '', '_bx_quoteofday_page_block_title', 11, 2147483647, '0', 'service', 'a:2:{s:6:"module";s:13:"bx_quoteofday";s:6:"method";s:9:"get_quote";}', 1, 0, 1, IFNULL(@iBlockOrder, 0) + 1);
+
+-- PAGE: create entry
+
+
+INSERT INTO sys_objects_page(object, uri, title_system, title, module, cover, cover_image, layout_id, visible_for_levels, visible_for_levels_editable, url, meta_description, meta_keywords, meta_robots, cache_lifetime, cache_editable, deletable, override_class_name, override_class_file) VALUES('bx_quoteofday_manage', 'quoteofday-manage', '_bx_quoteofday_page_title_manage', '_bx_quoteofday_page_title_manage', 'bx_quoteofday', 1, 0, 5, 2147483647, 1, 'page.php?i=quoteofday-manage', '', '', '', 0, 1, 0, '', '');
+
+INSERT INTO sys_pages_blocks(object, cell_id, module, title_system, title, designbox_id, visible_for_levels, hidden_on, type, content, deletable, copyable, active, `order`) VALUES('bx_quoteofday_manage', 1, 'bx_quoteofday', '_bx_quoteofday_page_block_title_manage', '_bx_quoteofday_page_block_title_manage', 11, 2147483647, '0', 'service', 'a:2:{s:6:"module";s:13:"bx_quoteofday";s:6:"method";s:17:"get_quotes_manage";}', 0, 1, 1, 1);
+
+-- MENU: dashboard manage tools
+SET @iManageMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name`='sys_account_dashboard_manage_tools' LIMIT 1);
+INSERT INTO sys_menu_items(set_name, module, name, title_system, title, link, onclick, target, icon, addon, submenu_object, submenu_popup, visible_for_levels, active, copyable, editable, `order`) VALUES('sys_account_dashboard_manage_tools', 'bx_quoteofday', 'quoteofday-manage', '_bx_quoteofday_menu_item_title_system_admt_manage', '_bx_quoteofday_menu_item_title_system_admt_manage', 'page.php?i=quoteofday-manage', '', '_self', '', 'a:2:{s:6:"module";s:13:"bx_quoteofday";s:6:"method";s:27:"get_menu_addon_manage_tools";}', '', 0, 2147483647, 1, 0, 1, 6);
+
+-- ACL
+INSERT INTO sys_acl_actions(Module, Name, AdditionalParamName, Title, `Desc`, Countable, DisabledForLevels) VALUES('bx_quoteofday', 'manage entries', NULL, '_bx_quoteofday_acl_action_manage_entries', '', 1, 3);
+
+SET @iIdActionEntryEditAny = LAST_INSERT_ID();
+
+SET @iUnauthenticated = 1;
+SET @iAccount = 2;
+SET @iStandard = 3;
+SET @iUnconfirmed = 4;
+SET @iPending = 5;
+SET @iSuspended = 6;
+SET @iModerator = 7;
+SET @iAdministrator = 8;
+SET @iPremium = 9;
+
+INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
+-- manage_entries
+(@iModerator, @iIdActionEntryEditAny),
+(@iAdministrator, @iIdActionEntryEditAny);

+ 55 - 0
modules/boonex/quoteofday/install/sql/install.sql

@@ -0,0 +1,55 @@
+-- TABLE: data
+CREATE TABLE bx_quoteofday_internal (
+  id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  text text NOT NULL,
+  source1 tinyint(4) NOT NULL DEFAULT 0,
+  is_active1 tinyint(4) DEFAULT 0,
+  added int(11) DEFAULT NULL,
+  status enum ('active', 'hidden') DEFAULT 'active',
+  author1 varchar(255) DEFAULT NULL,
+  status_admin enum ('active', 'hidden') DEFAULT 'active',
+  PRIMARY KEY (id),
+  FULLTEXT INDEX title_text (text)
+)
+;
+
+
+-- FORMS
+SET @sName = 'bx_quoteofday';
+
+INSERT INTO sys_objects_form(object, module, title, action, form_attrs, submit_name, `table`, `key`, uri, uri_title, params, deletable, active, override_class_name, override_class_file) VALUES(@sName, @sName, '_bx_quoteofday_form_entry', '', 'a:1:{s:7:"enctype";s:19:"multipart/form-data";}', 'do_submit', 'bx_quoteofday_internal', 'id', '', '', '', 0, 1, '', '');
+
+INSERT INTO sys_form_displays(display_name, module, object, title, view_mode) VALUES
+('bx_quoteofday_entry_add', @sName, @sName, '_bx_quoteofday_form_entry_display_add', 0),
+('bx_quoteofday_entry_edit', @sName, @sName, '_bx_quoteofday_form_entry_display_edit', 0);
+
+INSERT INTO sys_form_inputs(`object`, module, name, value, `values`, checked, type, caption_system, caption, info, `required`, `unique`, collapsed, html, attrs, attrs_tr, attrs_wrapper, checker_func, checker_params, checker_error, db_pass, db_params, editable, deletable) VALUES
+(@sName, @sName, 'do_submit', '_bx_quoteofday_form_entry_input_do_submit', '', 0, 'submit', '_bx_quoteofday_form_entry_input_sys_do_submit', '', '', 0, 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+(@sName, @sName, 'text', '', '', 0, 'textarea', '_bx_quoteofday_form_entry_input_sys_text', '_bx_quoteofday_form_entry_input_text', '', 1, 0, 0, 2, '', '', '', 'Avail', '', '_bx_quoteofday_form_entry_input_text_err', 'XssHtml', '', 1, 0),
+(@sName, @sName, 'cancel', '_bx_quoteofday_form_entry_input_cancel', '', 0, 'button', '_bx_dev_bp_btn_sys_block_cancel', '', '', 0, 0, 0, 0, 'a:2:{s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', 'Avail', '', '', '', '', 0, 0),
+(@sName, @sName, 'controls', '', 'do_submit,cancel', 0, 'input_set', '', '', '', 0, 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0);
+
+INSERT INTO sys_form_display_inputs(display_name, input_name, visible_for_levels, active, `order`) VALUES
+('bx_quoteofday_entry_add', 'text', 2147483647, 1, 1),
+('bx_quoteofday_entry_add', 'controls', 2147483647, 1, 2),
+('bx_quoteofday_entry_add', 'do_submit', 2147483647, 1, 3),
+('bx_quoteofday_entry_add', 'cancel', 2147483647, 1, 4),
+('bx_quoteofday_entry_edit', 'text', 2147483647, 1, 1),
+('bx_quoteofday_entry_edit', 'controls', 2147483647, 1, 2),
+('bx_quoteofday_entry_edit', 'do_submit', 2147483647, 1, 3),
+('bx_quoteofday_entry_edit', 'cancel', 2147483647, 1, 4);
+
+-- STUDIO: page & widget
+INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
+(3, 'bx_quoteofday', '_bx_quoteofday', '_bx_quoteofday', 'bx_quoteofday@modules/boonex/quoteofday/|std-icon.svg');
+
+SET @iPageId = LAST_INSERT_ID();
+
+INSERT INTO sys_std_widgets(page_id, module, url, click, icon, caption, cnt_notices, cnt_actions, bookmark) 
+VALUES(@iPageId, 'bx_quoteofday', '{url_studio}module.php?name=bx_quoteofday', '', 'bx_quoteofday@modules/boonex/quoteofday/|std-icon.svg', '_bx_quoteofday', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}', 0);
+
+SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
+SET @iParentPageOrder = (SELECT IFNULL(MAX(`order`), 0) + 1 FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
+
+INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
+(@iParentPageId, LAST_INSERT_ID(), @iParentPageOrder);

+ 15 - 0
modules/boonex/quoteofday/install/sql/uninstall.sql

@@ -0,0 +1,15 @@
+-- TABLES
+DROP TABLE IF EXISTS `bx_quoteofday_internal`;
+
+-- FORMS
+DELETE FROM `sys_objects_form` WHERE `module` = 'bx_quoteofday';
+DELETE FROM `sys_form_displays` WHERE `module` = 'bx_quoteofday';
+DELETE FROM `sys_form_inputs` WHERE `module` = 'bx_quoteofday';
+DELETE FROM `sys_form_display_inputs` WHERE `display_name` IN ('bx_quoteofday_entry_add', 'bx_quoteofday_entry_edit');
+
+-- STUDIO WIDGET
+DELETE FROM `tp`, `tw`, `tpw`
+USING `sys_std_pages` AS `tp`, `sys_std_widgets` AS `tw`, `sys_std_pages_widgets` AS `tpw`
+WHERE `tp`.`id` = `tw`.`page_id` AND `tw`.`id` = `tpw`.`widget_id` AND `tp`.`name` = 'bx_quoteofday';
+
+

+ 18 - 0
modules/boonex/quoteofday/request.php

@@ -0,0 +1,18 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Quote of the Day
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+
+check_logged();
+
+BxBaseModTextRequest::processAsAction($GLOBALS['aModule'], $GLOBALS['aRequest']);
+
+/** @} */

+ 44 - 0
modules/boonex/quoteofday/template/images/icons/std-icon.svg

@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<svg width="600" height="600" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
+ <title>Group 2 Copy 4</title>
+ <desc>Created with Sketch.</desc>
+ <defs>
+  <linearGradient id="linearGradient-1" y2="100%" x2="50%" y1="0%" x1="50%">
+   <stop offset="0%" stop-opacity="0.2" stop-color="#FFFFFF"/>
+   <stop offset="100%" stop-opacity="0.13887" stop-color="#000000"/>
+  </linearGradient>
+  <path id="path-2" d="m285,135.71429c22.47768,0 40.71429,-18.23661 40.71429,-40.71429c0,-22.47768 -18.23661,-40.71429 -40.71429,-40.71429c-22.47768,0 -40.71429,18.23661 -40.71429,40.71429c0,22.47768 18.23661,40.71429 40.71429,40.71429l0,0z"/>
+  <path id="path-5" d="m356.25,0l-332.5,0c-13.23214,0 -23.75,10.77232 -23.75,24.00446l0,277.70536c0,13.23214 10.51786,24.00447 23.75,24.00447l332.5,0c13.23214,0 23.75,-10.77233 23.75,-24.00447l0,-277.70536c0,-13.23214 -10.51786,-24.00446 -23.75,-24.00446l0,0zm-87.45089,167.69196c-2.54465,-2.96875 -6.44643,-5.25892 -10.85715,-5.25892c-4.32589,0 -7.37946,2.03571 -10.85714,4.83482l-15.86161,13.40178c-3.30803,2.375 -5.9375,3.98661 -9.75446,3.98661c-3.64732,0 -6.95536,-1.35714 -9.33036,-3.47768c-0.84821,-0.76339 -2.375,-2.20536 -3.64732,-3.47768l-45.63393,-49.36607c-3.39285,-3.90178 -8.48214,-6.36161 -14.16518,-6.36161c-5.68303,0 -10.94196,2.79911 -14.25,6.61608l-107.2991,129.4375l0,-220.95983c0.84821,-5.76785 5.34375,-9.9241 11.1116,-9.9241l303.40625,0c5.85268,0 10.60268,4.32589 10.94197,10.17857l0.25446,220.875l-84.05803,-90.50447l0,0z"/>
+  <symbol viewBox="0 0 475.082 475.081" height="512px" width="512px" y="0px" x="0px" id="svg_6" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
+   <g>
+    <g>
+     <path fill="#FFFFFF" d="m164.454,36.547l-109.636,0c-15.229,0 -28.171,5.33 -38.832,15.987c-10.656,10.659 -15.986,23.601 -15.986,38.831l0,109.632c0,15.229 5.327,28.169 15.986,38.826c10.66,10.656 23.606,15.988 38.832,15.988l63.953,0c7.611,0 14.084,2.666 19.414,7.994c5.33,5.325 7.994,11.8 7.994,19.417l0,9.131c0,20.177 -7.139,37.397 -21.413,51.675c-14.275,14.271 -31.499,21.409 -51.678,21.409l-18.27,0c-4.952,0 -9.233,1.813 -12.851,5.427c-3.615,3.614 -5.424,7.898 -5.424,12.847l0,36.549c0,4.941 1.809,9.233 5.424,12.848c3.621,3.613 7.898,5.427 12.851,5.427l18.271,0c19.797,0 38.688,-3.86 56.676,-11.566c17.987,-7.707 33.546,-18.131 46.68,-31.265c13.131,-13.135 23.553,-28.691 31.261,-46.679c7.707,-17.987 11.562,-36.877 11.562,-56.671l0,-200.993c0,-15.23 -5.33,-28.171 -15.987,-38.828s-23.602,-15.986 -38.827,-15.986z"/>
+     <path fill="#FFFFFF" d="m459.089,52.534c-10.656,-10.657 -23.599,-15.987 -38.828,-15.987l-109.632,0c-15.229,0 -28.171,5.33 -38.828,15.987c-10.656,10.66 -15.984,23.601 -15.984,38.831l0,109.632c0,15.229 5.328,28.169 15.984,38.826c10.657,10.656 23.6,15.988 38.828,15.988l63.953,0c7.611,0 14.089,2.666 19.418,7.994c5.324,5.328 7.994,11.8 7.994,19.417l0,9.131c0,20.177 -7.139,37.397 -21.416,51.675c-14.274,14.271 -31.494,21.409 -51.675,21.409l-18.274,0c-4.948,0 -9.233,1.813 -12.847,5.427c-3.617,3.614 -5.428,7.898 -5.428,12.847l0,36.549c0,4.941 1.811,9.233 5.428,12.848c3.613,3.613 7.898,5.427 12.847,5.427l18.274,0c19.794,0 38.684,-3.86 56.674,-11.566c17.984,-7.707 33.541,-18.131 46.676,-31.265c13.134,-13.135 23.562,-28.695 31.265,-46.679c7.706,-17.983 11.563,-36.877 11.563,-56.671l0,-200.993c-0.003,-15.23 -5.328,-28.171 -15.992,-38.827z"/>
+    </g>
+   </g>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+   <g/>
+  </symbol>
+ </defs>
+ <g class="layer">
+  <title>Layer 1</title>
+  <path fill="#2BAF92" id="path" d="m552.26896,552.26896c47.73104,-47.73115 47.73104,-120.81063 47.73104,-252.26896c0,-131.45833 0,-204.53781 -47.73104,-252.26896c-47.73115,-47.73104 -120.81063,-47.73104 -252.26896,-47.73104c-131.45833,0 -204.53781,0 -252.26896,47.73104c-47.73104,47.73115 -47.73104,120.81063 -47.73104,252.26896c0,131.45833 0,204.53781 47.73104,252.26896c47.73115,47.73104 120.81063,47.73104 252.26896,47.73104c131.45833,0 204.53781,0 252.26896,-47.73104l0,0z"/>
+  <path fill="url(#linearGradient-1)" id="path-copy" d="m552.26896,552.26896c47.73104,-47.73115 47.73104,-120.81063 47.73104,-252.26896c0,-131.45833 0,-204.53781 -47.73104,-252.26896c-47.73115,-47.73104 -120.81063,-47.73104 -252.26896,-47.73104c-131.45833,0 -204.53781,0 -252.26896,47.73104c-47.73104,47.73115 -47.73104,120.81063 -47.73104,252.26896c0,131.45833 0,204.53781 47.73104,252.26896c47.73115,47.73104 120.81063,47.73104 252.26896,47.73104c131.45833,0 204.53781,0 252.26896,-47.73104l0,0z"/>
+  <use x="408.57053" y="365.813149" transform="matrix(0.42097994685173035,0,0,0.42097994685173035,0,0) " xlink:href="#svg_6" id="svg_7"/>
+  <g id="svg_8"/>
+ </g>
+</svg>

+ 19 - 0
modules/boonex/quoteofday/template/manage_item.html

@@ -0,0 +1,19 @@
+<div class="bx-pgt-new-key bx-def-color-bg-block">
+    <div class="bx-pgt-new-key-cnt">
+        __form__
+        <script type="text/javascript">
+            $(document).ready(function () {
+                $("#__form_id__").ajaxForm({ 
+                    dataType: "json",
+                    beforeSubmit: function (formData, jqForm, options) {
+                        bx_loading($("#__form_id__"), true);
+                    },
+                    success: function (data) {
+                        $(".bx-popup-applied:visible").dolPopupHide();
+                        glGrids.__object__.processJson(data, '__action__');
+                    }
+                });
+            });
+        </script>
+    </div>
+</div>