diff --git a/modules/boonex/ads/classes/BxAdsConfig.php b/modules/boonex/ads/classes/BxAdsConfig.php index 90d5b94ecf..401592d4ab 100644 --- a/modules/boonex/ads/classes/BxAdsConfig.php +++ b/modules/boonex/ads/classes/BxAdsConfig.php @@ -13,6 +13,12 @@ class BxAdsConfig extends BxBaseModTextConfig { + protected $_oDb; + + protected $_aCurrency; + + protected $_bAuction; + function __construct($aModule) { parent::__construct($aModule); @@ -33,6 +39,9 @@ function __construct($aModule) 'TABLE_CATEGORIES' => $aModule['db_prefix'] . 'categories', 'TABLE_CATEGORIES_TYPES' => $aModule['db_prefix'] . 'categories_types', 'TABLE_INTERESTED_TRACK' => $aModule['db_prefix'] . 'interested_track', + 'TABLE_LICENSES' => $aModule['db_prefix'] . 'licenses', + 'TABLE_LICENSES_DELETED' => $aModule['db_prefix'] . 'licenses_deleted', + 'TABLE_OFFERS' => $aModule['db_prefix'] . 'offers', // database fields 'FIELD_ID' => 'id', @@ -40,13 +49,17 @@ function __construct($aModule) 'FIELD_ADDED' => 'added', 'FIELD_CHANGED' => 'changed', 'FIELD_TITLE' => 'title', + 'FIELD_NAME' => 'name', 'FIELD_TEXT' => 'text', 'FIELD_TEXT_ID' => 'ad-text', 'FIELD_CATEGORY' => 'category', 'FIELD_CATEGORY_VIEW' => 'category_view', 'FIELD_CATEGORY_SELECT' => 'category_select', 'FIELD_PRICE' => 'price', + 'FIELD_AUCTION' => 'auction', + 'FIELD_QUANTITY' => 'quantity', 'FIELD_YEAR' => 'year', + 'FIELD_NOTES_PURCHASED' => 'notes_purchased', 'FIELD_ALLOW_VIEW_TO' => 'allow_view_to', 'FIELD_COVER' => 'covers', 'FIELD_PHOTO' => 'pictures', @@ -66,8 +79,18 @@ function __construct($aModule) 'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified 'FIELDS_DELAYED_PROCESSING' => 'videos', // can be array of fields or comma separated string of field names + 'FIELD_OFR_ID' => 'id', + 'FIELD_OFR_CONTENT' => 'content_id', + 'FIELD_OFR_AUTHOR' => 'author_id', + 'FIELD_OFR_ADDED' => 'added', + 'FIELD_OFR_CHANGED' => 'changed', + 'FIELD_OFR_AMOUNT' => 'amount', + 'FIELD_OFR_QUANTITY' => 'quantity', + 'FIELD_OFR_STATUS' => 'status', + // page URIs 'URI_VIEW_ENTRY' => 'view-ad', + 'URI_VIEW_ENTRY_OFFERS' => 'view-ad-offers', 'URI_AUTHOR_ENTRIES' => 'ads-author', 'URI_ENTRIES_BY_CONTEXT' => 'ads-context', 'URI_ADD_ENTRY' => 'create-ad', @@ -80,10 +103,13 @@ function __construct($aModule) 'URL_CATEGORIES' => 'page.php?i=ads-categories', 'URL_MANAGE_COMMON' => 'page.php?i=ads-manage', 'URL_MANAGE_ADMINISTRATION' => 'page.php?i=ads-administration', + 'URL_LICENSES_COMMON' => 'page.php?i=ads-licenses', + 'URL_LICENSES_ADMINISTRATION' => 'page.php?i=ads-licenses-administration', 'GET_PARAM_CATEGORY' => 'category', // some params + 'PARAM_AUTO_APPROVE' => 'bx_ads_enable_auto_approve', 'PARAM_CHARS_SUMMARY' => 'bx_ads_summary_chars', 'PARAM_CHARS_SUMMARY_PLAIN' => 'bx_ads_plain_summary_chars', 'PARAM_NUM_RSS' => 'bx_ads_rss_num', @@ -92,6 +118,7 @@ function __construct($aModule) 'PARAM_LIFETIME' => 'bx_ads_lifetime', 'PARAM_USE_IIN' => 'bx_ads_internal_interested_notification', 'PARAM_CATEGORY_LEVEL_MAX' => 1, + 'PARAM_USE_AUCTION' => 'bx_ads_enable_auction', // objects 'OBJECT_STORAGE' => 'bx_ads_covers', @@ -135,6 +162,8 @@ function __construct($aModule) 'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_ads_entry_delete', 'OBJECT_FORM_POLL' => 'bx_ads_poll', 'OBJECT_FORM_POLL_DISPLAY_ADD' => 'bx_ads_poll_add', + 'OBJECT_FORM_OFFER' => 'bx_ads_offer', + 'OBJECT_FORM_OFFER_DISPLAY_ADD' => 'bx_ads_offer_add', 'OBJECT_MENU_ENTRY_ATTACHMENTS' => 'bx_ads_entry_attachments', // attachments menu in create/edit forms 'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_ads_view', // actions menu on view entry page 'OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL' => 'bx_ads_view_actions', // all actions menu on view entry page @@ -144,9 +173,14 @@ function __construct($aModule) 'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'ads-home', // first item in view entry submenu from main module submenu 'OBJECT_MENU_SNIPPET_META' => 'bx_ads_snippet_meta', // menu for snippet meta info 'OBJECT_MENU_MANAGE_TOOLS' => 'bx_ads_menu_manage_tools', //manage menu in content administration tools + 'OBJECT_MENU_LICENSES' => 'bx_ads_licenses_submenu', 'OBJECT_GRID_CATEGORIES' => 'bx_ads_categories', 'OBJECT_GRID_ADMINISTRATION' => 'bx_ads_administration', 'OBJECT_GRID_COMMON' => 'bx_ads_common', + 'OBJECT_GRID_LICENSES_ADMINISTRATION' => 'bx_ads_licenses_administration', + 'OBJECT_GRID_LICENSES' => 'bx_ads_licenses', + 'OBJECT_GRID_OFFERS' => 'bx_ads_offers', + 'OBJECT_GRID_OFFERS_ALL' => 'bx_ads_offers_all', 'OBJECT_UPLOADERS' => array('bx_ads_simple', 'bx_ads_html5'), // menu items which visibility depends on custom visibility checking @@ -170,6 +204,10 @@ function __construct($aModule) // email templates 'ETEMPLATE_INTERESTED' => 'bx_ads_interested', + 'ETEMPLATE_PURCHASED' => 'bx_ads_purchased', + 'ETEMPLATE_OFFER_ADDED' => 'bx_ads_offer_added', + 'ETEMPLATE_OFFER_ACCEPTED' => 'bx_ads_offer_accepted', + 'ETEMPLATE_OFFER_DECLINED' => 'bx_ads_offer_declined', // some language keys 'T' => array ( @@ -186,6 +224,7 @@ function __construct($aModule) 'grid_txt_account_manager' => '_bx_ads_grid_txt_account_manager', 'filter_item_active' => '_bx_ads_grid_filter_item_title_adm_active', 'filter_item_hidden' => '_bx_ads_grid_filter_item_title_adm_hidden', + 'filter_item_pending' => '_bx_ads_grid_filter_item_title_adm_pending', 'filter_item_select_one_filter1' => '_bx_ads_grid_filter_item_title_adm_select_one_filter1', 'menu_item_manage_my' => '_bx_ads_menu_item_title_manage_my', 'menu_item_manage_all' => '_bx_ads_menu_item_title_manage_all', @@ -209,13 +248,15 @@ function __construct($aModule) $this->_aJsClasses = array_merge($this->_aJsClasses, array( 'manage_tools' => 'BxAdsManageTools', 'studio' => 'BxAdsStudio', - 'entry' => 'BxAdsEntry' + 'entry' => 'BxAdsEntry', + 'form' => 'BxAdsForm', )); $this->_aJsObjects = array_merge($this->_aJsObjects, array( 'manage_tools' => 'oBxAdsManageTools', 'studio' => 'oBxAdsStudio', - 'entry' => 'oBxAdsEntry' + 'entry' => 'oBxAdsEntry', + 'form' => 'oBxAdsForm', )); $this->_aGridObjects = array( @@ -224,8 +265,41 @@ function __construct($aModule) 'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION'], ); + $sPrefix = str_replace('_', '-', $this->_sName); + $this->_aHtmlIds = array( + 'offer_popup' => $sPrefix . '-offer-popup', + ); + + $oPayments = BxDolPayments::getInstance(); + $this->_aCurrency = array( + 'code' => $oPayments->getOption('default_currency_code'), + 'sign' => $oPayments->getOption('default_currency_sign') + ); + $this->_bAttachmentsInTimeline = true; } + + public function init(&$oDb) + { + $this->_oDb = &$oDb; + + $this->_bAuction = getParam($this->CNF['PARAM_USE_AUCTION']) == 'on'; + } + + public function isAuction() + { + return $this->_bAuction; + } + + public function getCurrency() + { + return $this->_aCurrency; + } + + public function getEntryName($sName) + { + return uriGenerate($sName, $this->CNF['TABLE_ENTRIES'], $this->CNF['FIELD_NAME']); + } } /** @} */ diff --git a/modules/boonex/ads/classes/BxAdsDb.php b/modules/boonex/ads/classes/BxAdsDb.php index 54c8771807..05a579c41e 100644 --- a/modules/boonex/ads/classes/BxAdsDb.php +++ b/modules/boonex/ads/classes/BxAdsDb.php @@ -306,6 +306,48 @@ public function insertInterested($aParamsSet) return (int)$this->lastId(); } + public function registerLicense($iProfileId, $iEntryId, $iCount, $sOrder, $sLicense) + { + $CNF = &$this->_oConfig->CNF; + + $aQueryParams = array( + 'profile_id' => $iProfileId, + 'entry_id' => $iEntryId, + 'count' => $iCount, + 'order' => $sOrder, + 'license' => $sLicense + ); + + return (int)$this->query("INSERT INTO `" . $CNF['TABLE_LICENSES'] . "` SET " . $this->arrayToSQL($aQueryParams) . ", `added`=UNIX_TIMESTAMP()") > 0; + } + + public function unregisterLicense($iProfileId, $iEntryId, $sOrder, $sLicense) + { + $CNF = &$this->_oConfig->CNF; + + $sWhereClause = "`profile_id`=:profile_id AND `entry_id`=:entry_id AND `order`=:order AND `license`=:license"; + $aWhereBindings = array( + 'profile_id' => $iProfileId, + 'entry_id' => $iEntryId, + 'order' => $sOrder, + 'license' => $sLicense + ); + + //--- Move to deleted licenses table with 'refund' as reason. + $sQuery = "INSERT IGNORE INTO `" . $CNF['TABLE_LICENSES_DELETED'] . "` SELECT *, 'refund' AS `reason`, UNIX_TIMESTAMP() AS `deleted` FROM `" . $CNF['TABLE_LICENSES'] . "` WHERE " . $sWhereClause; + $this->query($sQuery, $aWhereBindings); + + $sQuery = "DELETE FROM `" . $CNF['TABLE_LICENSES'] . "` WHERE " . $sWhereClause; + return $this->query($sQuery, $aWhereBindings) !== false; + } + + public function updateLicense($aSet, $aWhere) + { + $CNF = &$this->_oConfig->CNF; + + return (int)$this->query("UPDATE `" . $CNF['TABLE_LICENSES'] . "` SET " . $this->arrayToSQL($aSet) . " WHERE " . (!empty($aWhere) ? $this->arrayToSQL($aWhere, ' AND ') : "1")) > 0; + } + protected function _getEntriesBySearchIds($aParams, &$aMethod, &$sSelectClause, &$sJoinClause, &$sWhereClause, &$sOrderClause, &$sLimitClause) { $CNF = &$this->_oConfig->CNF; @@ -334,6 +376,85 @@ protected function _getEntriesBySearchIds($aParams, &$aMethod, &$sSelectClause, parent::_getEntriesBySearchIds($aParams, $aMethod, $sSelectClause, $sJoinClause, $sWhereClause, $sOrderClause, $sLimitClause); } + + public function getOffersBy($aParams = array()) + { + $CNF = &$this->_oConfig->CNF; + + $aMethod = array('name' => 'getAll', 'params' => array(0 => 'query', 1 => array())); + $sSelectClause = $sJoinClause = $sWhereClause = $sGroupClause = $sOrderClause = $sLimitClause = ""; + + $sSelectClause = "`to`.*"; + + if(!empty($aParams['type'])) + switch($aParams['type']) { + case 'id': + $aMethod['name'] = 'getRow'; + $aMethod['params'][1]['id'] = (int)$aParams['id']; + + $sWhereClause = " AND `to`.`id`=:id"; + break; + + case 'content_author_id': + $aMethod['params'][1]['author_id'] = (int)$aParams['author_id']; + + $sJoinClause = "LEFT JOIN `" . $CNF['TABLE_ENTRIES'] . "` AS `te` ON `to`.`content_id`=`te`.`id`"; + $sWhereClause = " AND `te`.`author`=:author_id"; + + if(!empty($aParams['status'])) { + $aMethod['params'][1]['status'] = $aParams['status']; + + $sWhereClause .= " AND `to`.`status`=:status"; + } + + if(isset($aParams['count']) && $aParams['count'] === true) { + $aMethod['name'] = 'getOne'; + + $sSelectClause = "COUNT(`to`.`id`)"; + } + break; + + case 'content_and_author_ids': + if(!isset($aParams['all']) || $aParams['all'] !== true) + $aMethod['name'] = 'getRow'; + + $aMethod['params'][1]['content_id'] = (int)$aParams['content_id']; + $aMethod['params'][1]['author_id'] = (int)$aParams['author_id']; + + $sWhereClause = " AND `to`.`content_id`=:content_id AND `to`.`author_id`=:author_id"; + + if(!empty($aParams['status'])) { + $aMethod['params'][1]['status'] = $aParams['status']; + + $sWhereClause .= " AND `to`.`status`=:status"; + } + + $sOrderClause = "`to`.`added` DESC"; + break; + } + + if(!empty($sGroupClause)) + $sGroupClause = ' GROUP BY ' . $sGroupClause; + + if(!empty($sOrderClause)) + $sOrderClause = ' ORDER BY ' . $sOrderClause; + + if(!empty($sLimitClause)) + $sLimitClause = ' LIMIT ' . $sLimitClause; + + $aMethod['params'][0] = "SELECT " . $sSelectClause . " FROM `" . $CNF['TABLE_OFFERS'] . "` AS `to` " . $sJoinClause . " WHERE 1 " . $sWhereClause . $sGroupClause . $sOrderClause . $sLimitClause; + return call_user_func_array(array($this, $aMethod['name']), $aMethod['params']); + } + + public function updateOffer($aSet, $aWhere) + { + $CNF = &$this->_oConfig->CNF; + + if(!isset($aSet[$CNF['FIELD_OFR_CHANGED']])) + $aSet[$CNF['FIELD_OFR_CHANGED']] = time(); + + return (int)$this->query("UPDATE `" . $CNF['TABLE_OFFERS'] . "` SET " . $this->arrayToSQL($aSet) . " WHERE " . (!empty($aWhere) ? $this->arrayToSQL($aWhere, ' AND ') : "1")) > 0; + } } /** @} */ diff --git a/modules/boonex/ads/classes/BxAdsFormEntry.php b/modules/boonex/ads/classes/BxAdsFormEntry.php index 3cd4424171..d89315a2bb 100644 --- a/modules/boonex/ads/classes/BxAdsFormEntry.php +++ b/modules/boonex/ads/classes/BxAdsFormEntry.php @@ -26,6 +26,23 @@ public function __construct($aInfo, $oTemplate = false) $this->_initCategoryFields(); + if(isset($this->aInputs[$CNF['FIELD_TITLE']], $this->aInputs[$CNF['FIELD_NAME']])) { + $sJsObject = $this->_oModule->_oConfig->getJsObject('form'); + + $aMask = array('mask' => "javascript:%s.checkName('%s', '%s');", $sJsObject, $CNF['FIELD_TITLE'], $CNF['FIELD_NAME']); + if($this->aParams['display'] == $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'] && bx_get('id') !== false) { + $aMask['mask'] = "javascript:%s.checkName('%s', '%s', %d);"; + $aMask[] = (int)bx_get('id'); + } + + $sOnBlur = call_user_func_array('sprintf', array_values($aMask)); + $this->aInputs[$CNF['FIELD_TITLE']]['attrs']['onblur'] = $sOnBlur; + $this->aInputs[$CNF['FIELD_NAME']]['attrs']['onblur'] = $sOnBlur; + } + + if(isset($CNF['FIELD_AUCTION']) && isset($this->aInputs[$CNF['FIELD_AUCTION']]) && !$this->_oModule->_oConfig->isAuction()) + unset($this->aInputs[$CNF['FIELD_AUCTION']]); + if(isset($CNF['FIELD_COVER']) && isset($this->aInputs[$CNF['FIELD_COVER']])) { if($this->_oModule->checkAllowedSetThumb() === CHECK_ACTION_RESULT_ALLOWED) { $this->aInputs[$CNF['FIELD_COVER']]['storage_object'] = $CNF['OBJECT_STORAGE']; @@ -84,8 +101,16 @@ public function __construct($aInfo, $oTemplate = false) function getCode($bDynamicMode = false) { - $sInclude = $this->_oModule->_oTemplate->addJs(array('entry.js'), $bDynamicMode); - return ($bDynamicMode ? $sInclude : '') . $this->_oModule->_oTemplate->getJsCode('entry') . parent::getCode($bDynamicMode); + $sJs = $this->_oModule->_oTemplate->addJs(array('form.js'), $bDynamicMode); + + $sCode = ''; + if($bDynamicMode) + $sCode .= $sJs; + + $sCode .= $this->_oModule->_oTemplate->getJsCode('form'); + $sCode .= parent::getCode($bDynamicMode); + + return $sCode; } function initChecker ($aValues = array (), $aSpecificValues = array()) @@ -114,6 +139,9 @@ public function insert ($aValsToAdd = array(), $isIgnore = false) { $CNF = &$this->_oModule->_oConfig->CNF; + if(!$this->_oModule->_isModerator() && getParam($CNF['PARAM_AUTO_APPROVE']) != 'on') + $aValsToAdd[$CNF['FIELD_STATUS_ADMIN']] = BX_ADS_STATUS_PENDING; + $iContentId = parent::insert ($aValsToAdd, $isIgnore); if(!empty($iContentId)) $this->processFiles($CNF['FIELD_COVER'], $iContentId, true); @@ -165,6 +193,11 @@ protected function genCustomViewRowValuePrice(&$aInput) return isset($aInput['value']) && $aInput['value'] !== '' ? getParam('currency_sign') . bx_process_output($aInput['value']) : null; } + protected function genCustomViewRowValueQuantity(&$aInput) + { + return (int)$aInput['value'] > 0 ? (int)$aInput['value'] : 0; + } + protected function _getCoverGhostTmplVars($aContentInfo = array()) { $CNF = &$this->_oModule->_oConfig->CNF; diff --git a/modules/boonex/ads/classes/BxAdsFormOffer.php b/modules/boonex/ads/classes/BxAdsFormOffer.php new file mode 100644 index 0000000000..a749288404 --- /dev/null +++ b/modules/boonex/ads/classes/BxAdsFormOffer.php @@ -0,0 +1,49 @@ +_sModule = 'bx_ads'; + $this->_oModule = BxDolModule::getInstance($this->_sModule); + + parent::__construct($aInfo, $oTemplate); + } + + public function insert ($aValsToAdd = array(), $isIgnore = false) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + if(!isset($aValsToAdd[$CNF['FIELD_OFR_AUTHOR']])) + $aValsToAdd[$CNF['FIELD_OFR_AUTHOR']] = bx_get_logged_profile_id(); + + if(!isset($aValsToAdd[$CNF['FIELD_OFR_ADDED']])) + $aValsToAdd[$CNF['FIELD_OFR_ADDED']] = time(); + + return parent::insert ($aValsToAdd, $isIgnore); + } + + public function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + if(!isset($aValsToAdd[$CNF['FIELD_OFR_CHANGED']])) + $aValsToAdd[$CNF['FIELD_OFR_CHANGED']] = time(); + + return parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges); + } +} + +/** @} */ diff --git a/modules/boonex/ads/classes/BxAdsGridAdministration.php b/modules/boonex/ads/classes/BxAdsGridAdministration.php index 8f1cbd4b16..5c9a555f74 100644 --- a/modules/boonex/ads/classes/BxAdsGridAdministration.php +++ b/modules/boonex/ads/classes/BxAdsGridAdministration.php @@ -16,6 +16,10 @@ public function __construct ($aOptions, $oTemplate = false) $this->MODULE = 'bx_ads'; parent::__construct ($aOptions, $oTemplate); + + $CNF = &$this->_oModule->_oConfig->CNF; + + $this->_aFilter1Values[BX_ADS_STATUS_PENDING] = $CNF['T']['filter_item_' . BX_ADS_STATUS_PENDING]; } } diff --git a/modules/boonex/ads/classes/BxAdsGridCommon.php b/modules/boonex/ads/classes/BxAdsGridCommon.php index de345ddb48..75ba24ee7a 100644 --- a/modules/boonex/ads/classes/BxAdsGridCommon.php +++ b/modules/boonex/ads/classes/BxAdsGridCommon.php @@ -17,6 +17,41 @@ public function __construct ($aOptions, $oTemplate = false) parent::__construct ($aOptions, $oTemplate); } + + protected function _getCellStatusAdmin($mixedValue, $sKey, $aField, $aRow) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + if(!empty($CNF['T']['filter_item_' . $mixedValue])) + $mixedValue = $CNF['T']['filter_item_' . $mixedValue]; + else + $mixedValue = '_undefined'; + + return parent::_getCellDefault(_t($mixedValue), $sKey, $aField, $aRow); + } + + protected function _getCellSwitcher ($mixedValue, $sKey, $aField, $aRow) + { + if(!$this->_switcherState2Checked($aRow['status_admin'])) + return parent::_getCellDefault('', $sKey, $aField, $aRow); + + return parent::_getCellSwitcher ($mixedValue, $sKey, $aField, $aRow); + } + + protected function _isRowDisabled($aRow) + { + if(parent::_isRowDisabled($aRow)) + return true; + + return !$this->_switcherState2Checked($aRow['status_admin']); + } + + protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) + { + $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `author`=?", bx_get_logged_profile_id()); + + return $this->__getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage); + } } /** @} */ diff --git a/modules/boonex/ads/classes/BxAdsGridLicenses.php b/modules/boonex/ads/classes/BxAdsGridLicenses.php new file mode 100644 index 0000000000..9b0a6bb739 --- /dev/null +++ b/modules/boonex/ads/classes/BxAdsGridLicenses.php @@ -0,0 +1,32 @@ +_aQueryAppend['profile_id'])) + return array(); + + $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `tl`.`profile_id`=?", $this->_aQueryAppend['profile_id']); + + return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage); + } +} + +/** @} */ diff --git a/modules/boonex/ads/classes/BxAdsGridLicensesAdministration.php b/modules/boonex/ads/classes/BxAdsGridLicensesAdministration.php new file mode 100644 index 0000000000..564a5db00d --- /dev/null +++ b/modules/boonex/ads/classes/BxAdsGridLicensesAdministration.php @@ -0,0 +1,57 @@ +_sModule = 'bx_ads'; + $this->_oModule = BxDolModule::getInstance($this->_sModule); + if(!$oTemplate) + $oTemplate = $this->_oModule->_oTemplate; + + parent::__construct ($aOptions, $oTemplate); + + $this->_sDefaultSortingOrder = 'DESC'; + $this->_aQueryReset = array($this->_aOptions['order_get_field'], $this->_aOptions['order_get_dir'], $this->_aOptions['paginate_get_start'], $this->_aOptions['paginate_get_per_page']); + + $iProfileId = bx_get_logged_profile_id(); + if($iProfileId !== false) + $this->_aQueryAppend['profile_id'] = (int)$iProfileId; + } + + protected function _getCellProfileId($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault($this->_oModule->_oTemplate->getProfileLink($mixedValue), $sKey, $aField, $aRow); + } + + protected function _getCellEntry($mixedValue, $sKey, $aField, $aRow) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $mixedValue = $this->_oModule->_oTemplate->getEntryLink(array( + $CNF['FIELD_ID'] => $aRow['entry_id'], + $CNF['FIELD_TITLE'] => $mixedValue, + )); + + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE, true), $sKey, $aField, $aRow); + } +} + +/** @} */ diff --git a/modules/boonex/ads/classes/BxAdsGridOffers.php b/modules/boonex/ads/classes/BxAdsGridOffers.php new file mode 100644 index 0000000000..fe7fd89a18 --- /dev/null +++ b/modules/boonex/ads/classes/BxAdsGridOffers.php @@ -0,0 +1,130 @@ +_sModule = 'bx_ads'; + $this->_oModule = BxDolModule::getInstance($this->_sModule); + if(!$oTemplate) + $oTemplate = $this->_oModule->_oTemplate; + + parent::__construct ($aOptions, $oTemplate); + + if(($iContentId = bx_get('content_id')) !== false) + $this->setContentId($iContentId); + } + + public function setContentId($iContentId) + { + $this->_aQueryAppend['content_id'] = (int)$iContentId; + } + + public function performActionAccept() + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $iId = $this->_getId(); + if($iId && $this->_oModule->_oDb->updateOffer(array($CNF['FIELD_OFR_STATUS'] => BX_ADS_OFFER_STATUS_ACCEPTED), array($CNF['FIELD_OFR_ID'] => $iId))) { + $this->_oModule->onOfferAccepted($iId); + + $aResult = array('grid' => $this->getCode(false), 'blick' => $iId); + } + else + $aResult = array('msg' => _t('_bx_ads_txt_err_cannot_perform_action')); + + echoJson($aResult); + } + + public function performActionDecline() + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $iId = $this->_getId(); + if($iId && $this->_oModule->_oDb->updateOffer(array($CNF['FIELD_OFR_STATUS'] => BX_ADS_OFFER_STATUS_DECLINED), array($CNF['FIELD_OFR_ID'] => $iId))) { + $this->_oModule->onOfferDeclined($iId); + + $aResult = array('grid' => $this->getCode(false), 'blick' => $iId); + } + else + $aResult = array('msg' => _t('_bx_ads_txt_err_cannot_perform_action')); + + echoJson($aResult); + } + + protected function _getCellAuthorId($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault($this->_oModule->_oTemplate->getProfileLink($mixedValue), $sKey, $aField, $aRow); + } + + protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault(_t_format_currency($mixedValue), $sKey, $aField, $aRow); + } + + protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE, true), $sKey, $aField, $aRow); + } + + protected function _getCellStatus($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault(_t('_bx_ads_txt_offer_status_' . $mixedValue), $sKey, $aField, $aRow); + } + + protected function _getActionAccept ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + if($aRow[$CNF['FIELD_OFR_STATUS']] != BX_ADS_OFFER_STATUS_AWAITING) + return ''; + + return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow); + } + + protected function _getActionDecline ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + if($aRow[$CNF['FIELD_OFR_STATUS']] != BX_ADS_OFFER_STATUS_AWAITING) + return ''; + + return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow); + } + + protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) + { + if(empty($this->_aQueryAppend['content_id'])) + return array(); + + $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `content_id`=?", $this->_aQueryAppend['content_id']); + + return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage); + } + + protected function _getId() + { + $aIds = bx_get('ids'); + if(!empty($aIds) && is_array($aIds)) + return array_shift($aIds); + + if(($iId = bx_get('id')) !== false) + return (int)$iId; + + return false; + } +} + +/** @} */ diff --git a/modules/boonex/ads/classes/BxAdsGridOffersAll.php b/modules/boonex/ads/classes/BxAdsGridOffersAll.php new file mode 100644 index 0000000000..34c1b05974 --- /dev/null +++ b/modules/boonex/ads/classes/BxAdsGridOffersAll.php @@ -0,0 +1,82 @@ +_sModule = 'bx_ads'; + $this->_oModule = BxDolModule::getInstance($this->_sModule); + if(!$oTemplate) + $oTemplate = $this->_oModule->_oTemplate; + + $this->_iProfileId = bx_get_logged_profile_id(); + + parent::__construct ($aOptions, $oTemplate); + } + + protected function _getCellContentId($mixedValue, $sKey, $aField, $aRow) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $mixedValue = $this->_oModule->_oTemplate->getEntryLink(array( + $CNF['FIELD_ID'] => $aRow['content_id'], + $CNF['FIELD_TITLE'] => $aRow['content_title'], + )); + + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getActionView($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY_OFFERS'], array('id' => $aRow['content_id'])); + + $a['attr'] = array_merge($a['attr'], array( + "onclick" => "window.open('" . $sUrl . "','_self');" + )); + unset($a['attr']['bx_grid_action_single']); + + return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow); + } + + protected function _getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir, $bFieldsOnly = false) + { + return " GROUP BY `to`.`content_id` " . parent::_getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir, $bFieldsOnly); + } + + protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) + { + $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `te`.`author`=?", $this->_iProfileId); + + return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage); + } + + protected function _getId() + { + $aIds = bx_get('ids'); + if(!empty($aIds) && is_array($aIds)) + return array_shift($aIds); + + if(($iId = bx_get('id')) !== false) + return (int)$iId; + + return false; + } +} + +/** @} */ diff --git a/modules/boonex/ads/classes/BxAdsMenuView.php b/modules/boonex/ads/classes/BxAdsMenuView.php index ae09073201..13f582d793 100644 --- a/modules/boonex/ads/classes/BxAdsMenuView.php +++ b/modules/boonex/ads/classes/BxAdsMenuView.php @@ -14,18 +14,89 @@ */ class BxAdsMenuView extends BxBaseModTextMenuView { + /** + * Array with check_sum => JS_code pairs of all JS codes + * which should be added to the page. + */ + protected $_aJsCodes; + public function __construct($aObject, $oTemplate = false) { $this->MODULE = 'bx_ads'; parent::__construct($aObject, $oTemplate); + + $this->_aJsCodes = array(); + + $this->addMarkers(array( + 'js_object' => $this->_oModule->_oConfig->getJsObject('entry') + )); + } + + public function getCode () + { + return parent::getCode() . $this->getJsCode(); } - public function setContentId($iContentId) + public function getJsCode() { - parent::setContentId($iContentId); + if(empty($this->_aJsCodes) || !is_array($this->_aJsCodes)) + return ''; + + return implode('', $this->_aJsCodes); + } + + protected function _isVisible ($a) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + if(!parent::_isVisible($a)) + return false; + + $oPayment = BxDolPayments::getInstance(); + + $bResult = false; + switch ($a['name']) { + case 'add-to-cart': + if((float)$this->_aContentInfo[$CNF['FIELD_PRICE']] == 0 || (int)$this->_aContentInfo[$CNF['FIELD_QUANTITY']] <= 0) + break; + + $aJs = $oPayment->getAddToCartJs($this->_aContentInfo[$CNF['FIELD_AUTHOR']], $this->MODULE, $this->_aContentInfo[$CNF['FIELD_ID']], 1, true); + if(empty($aJs) || !is_array($aJs)) + break; + + list($sJsCode, $sJsMethod) = $aJs; + + $sJsCodeCheckSum = md5($sJsCode); + if(!isset($this->_aJsCodes[$sJsCodeCheckSum])) + $this->_aJsCodes[$sJsCodeCheckSum] = $sJsCode; + + $aCurrency = $this->_oModule->_oConfig->getCurrency(); + + $bResult = true; + $this->addMarkers(array( + 'add_to_cart_title' => _t('_bx_market_menu_item_title_add_to_cart', $aCurrency['sign'], $this->_aContentInfo[$CNF['FIELD_PRICE']]), + 'add_to_cart_onclick' => $sJsMethod + )); + break; + + case 'interested': + $bResult = $this->_aContentInfo[$CNF['FIELD_AUTHOR']] != bx_get_logged_profile_id(); + break; + + case 'make-offer': + $bResult = $this->_oModule->isAllowedMakeOffer($this->_aContentInfo); + break; + + case 'view-offers': + $bResult = $this->_oModule->isAllowedViewOffers($this->_aContentInfo); + break; + + default: + $bResult = true; + } - $this->addMarkers(array('js_object' => $this->_oModule->_oConfig->getJsObject('entry'))); + return $bResult; } } diff --git a/modules/boonex/ads/classes/BxAdsMenuViewActions.php b/modules/boonex/ads/classes/BxAdsMenuViewActions.php index 11630f78bc..8dff96fb32 100644 --- a/modules/boonex/ads/classes/BxAdsMenuViewActions.php +++ b/modules/boonex/ads/classes/BxAdsMenuViewActions.php @@ -21,11 +21,36 @@ public function __construct($aObject, $oTemplate = false) parent::__construct($aObject, $oTemplate); } + public function getCode () + { + $sCode = parent::getCode(); + + if(!empty($this->_oMenuActions)) + $sCode .= $this->_oMenuActions->getJsCode(); + + return $sCode; + } + protected function _getMenuItemInterested($aItem) { return $this->_getMenuItemByNameActions($aItem); } - + + protected function _getMenuItemAddToCart($aItem) + { + return $this->_getMenuItemByNameActions($aItem); + } + + protected function _getMenuItemMakeOffer($aItem) + { + return $this->_getMenuItemByNameActions($aItem); + } + + protected function _getMenuItemViewOffers($aItem) + { + return $this->_getMenuItemByNameActions($aItem); + } + protected function _getMenuItemEditAd($aItem) { return $this->_getMenuItemByNameActions($aItem); @@ -35,6 +60,7 @@ protected function _getMenuItemDeleteAd($aItem) { return $this->_getMenuItemByNameActions($aItem); } + protected function _getMenuItemReview($aItem, $aParams = array()) { $CNF = &$this->_oModule->_oConfig->CNF; diff --git a/modules/boonex/ads/classes/BxAdsModule.php b/modules/boonex/ads/classes/BxAdsModule.php index fd2ae1520e..aee9b34374 100644 --- a/modules/boonex/ads/classes/BxAdsModule.php +++ b/modules/boonex/ads/classes/BxAdsModule.php @@ -9,21 +9,39 @@ * @{ */ +define('BX_ADS_STATUS_ACTIVE', 'active'); +define('BX_ADS_STATUS_HIDDEN', 'hidden'); +define('BX_ADS_STATUS_PENDING', 'pending'); + +define('BX_ADS_OFFER_STATUS_ACCEPTED', 'accepted'); +define('BX_ADS_OFFER_STATUS_AWAITING', 'awaiting'); +define('BX_ADS_OFFER_STATUS_DECLINED', 'declined'); + /** * Ads module */ class BxAdsModule extends BxBaseModTextModule { + protected $_aOfferStatuses; + function __construct(&$aModule) { parent::__construct($aModule); + $this->_oConfig->init($this->_oDb); + $CNF = &$this->_oConfig->CNF; $this->_aSearchableNamesExcept = array_merge($this->_aSearchableNamesExcept, array( $CNF['FIELD_CATEGORY_VIEW'], $CNF['FIELD_CATEGORY_SELECT'] )); + + $this->_aOfferStatuses = array( + BX_ADS_OFFER_STATUS_ACCEPTED, + BX_ADS_OFFER_STATUS_AWAITING, + BX_ADS_OFFER_STATUS_DECLINED + ); } public function actionGetCategoryForm() @@ -39,6 +57,29 @@ public function actionGetCategoryForm() )); } + public function actionCheckName() + { + $CNF = &$this->_oConfig->CNF; + + $sName = ''; + + $sTitle = bx_process_input(bx_get($CNF['FIELD_TITLE'])); + if(empty($sTitle)) + return echoJson(array()); + + $iId = (int)bx_get($CNF['FIELD_ID']); + if(!empty($iId)) { + $aEntry = $this->_oDb->getContentInfoById($iId); + if(strcmp($sTitle, $aEntry[$CNF['FIELD_NAME']]) == 0) + $sName = $sTitle; + } + + echoJson(array( + 'title' => $sTitle, + 'name' => !empty($sName) ? $sName : $this->_oConfig->getEntryName($sTitle, $iId) + )); + } + public function actionInterested() { $CNF = &$this->_oConfig->CNF; @@ -86,6 +127,64 @@ public function actionInterested() return echoJson(array('msg' => _t('_bx_ads_txt_msg_author_notified'))); } + public function actionMakeOffer() + { + $CNF = &$this->_oConfig->CNF; + $sJsObject = $this->_oConfig->getJsObject('entry'); + + $iAuthorId = bx_get_logged_profile_id(); + $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT); + + $aContentInfo = $this->_oDb->getContentInfoById($iContentId); + if(empty($aContentInfo) || !is_array($aContentInfo)) + return echoJson(array()); + + $aOffer = $this->_oDb->getOffersBy(array( + 'type' => 'content_and_author_ids', + 'content_id' => $iContentId, + 'author_id' => $iAuthorId, + 'status' => BX_ADS_OFFER_STATUS_AWAITING + )); + + if(!empty($aOffer) && is_array($aOffer)) + return echoJson(array('code' => 1, 'msg' => _t('_bx_ads_txt_err_duplicate'))); + + $aOffer = $this->_oDb->getOffersBy(array( + 'type' => 'content_and_author_ids', + 'content_id' => $iContentId, + 'author_id' => $iAuthorId, + 'status' => BX_ADS_OFFER_STATUS_ACCEPTED + )); + + if(!empty($aOffer) && is_array($aOffer)) + return echoJson(array('code' => 1, 'msg' => _t('_bx_ads_txt_err_offer_accepted'))); + + $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_OFFER'], $CNF['OBJECT_FORM_OFFER_DISPLAY_ADD']); + $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'make_offer', array('id' => $iContentId)); + $oForm->initChecker(); + + if($oForm->isSubmittedAndValid()) { + $aValToAdd = array('content_id' => $iContentId, 'author_id' => $iAuthorId); + + $iId = (int)$oForm->insert($aValToAdd); + if($iId != 0) + $aResult = array('code' => 0, 'msg' => _t('_bx_ads_txt_msg_offer_added'), 'eval' => $sJsObject . '.onMakeOffer(oData);', 'id' => $iId); + else + $aResult = array('code' => 2, 'msg' => _t('_bx_ads_txt_err_cannot_perform_action')); + + $this->onOfferAdded($iId); + + return echoJson($aResult); + } + + $sContent = BxTemplFunctions::getInstance()->transBox($this->_oConfig->getHtmlIds('offer_popup'), $this->_oTemplate->parseHtmlByName('offer_popup.html', array( + 'form_id' => $oForm->getId(), + 'form' => $oForm->getCode(true) + ))); + + return echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false, 'removeOnClose' => true)))); + } + public function serviceGetSafeServices() { $a = parent::serviceGetSafeServices(); @@ -127,6 +226,7 @@ public function serviceGetSearchableFields($aInputsAdd = array()) $CNF = &$this->_oConfig->CNF; $aResult = parent::serviceGetSearchableFields(array_merge($aInputsAdd, $this->_getSearchableFields())); + unset($aResult[$CNF['FIELD_NOTES_PURCHASED']]); unset($aResult[$CNF['FIELD_CATEGORY_VIEW']], $aResult[$CNF['FIELD_CATEGORY_SELECT']]); unset($aResult[$CNF['FIELD_PRICE']], $aResult[$CNF['FIELD_YEAR']]); @@ -350,6 +450,698 @@ public function serviceGetNotificationsInterest($aEvent) ); } + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-page_blocks Page Blocks + * @subsubsection bx_ads-block_licenses block_licenses + * + * @code bx_srv('bx_ads', 'block_licenses', [...]); @endcode + * + * Get page block with a list of licenses purchased by currently logged member. + * + * @return an array describing a block to display on the site or false if there is no enough input data. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML. + * + * @see BxAdsModule::serviceBlockLicenses + */ + /** + * @ref bx_ads-block_licenses "block_licenses" + */ + public function serviceBlockLicenses() + { + return $this->_getBlockLicenses(); + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-page_blocks Page Blocks + * @subsubsection bx_ads-block_licenses_administration block_licenses_administration + * + * @code bx_srv('bx_ads', 'block_licenses_administration', [...]); @endcode + * + * Get page block with a list of all licenses. It's needed for moderators/administrators. + * + * @return an array describing a block to display on the site or false if there is no enough input data. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML. + * + * @see BxAdsModule::serviceBlockLicensesAdministration + */ + /** + * @ref bx_ads-block_licenses "block_licenses" + */ + public function serviceBlockLicensesAdministration() + { + return $this->_getBlockLicenses('administration'); + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-page_blocks Page Blocks + * @subsubsection bx_ads-block_licenses_note block_licenses_note + * + * @code bx_srv('bx_ads', 'block_licenses_note', [...]); @endcode + * + * Get page block with a notice for licenses usage. + * + * @return HTML string with block content to display on the site. + * + * @see BxAdsModule::serviceBlockLicensesNote + */ + /** + * @ref bx_ads-block_licenses_note "block_licenses_note" + */ + public function serviceBlockLicensesNote() + { + return MsgBox(_t('_bx_ads_page_block_content_licenses_note')); + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-get_payment_data get_payment_data + * + * @code bx_srv('bx_ads', 'get_payment_data', [...]); @endcode + * + * Get an array with module's description. Is needed for payments processing module. + * + * @return an array with module's description. + * + * @see BxAdsModule::serviceGetPaymentData + */ + /** + * @ref bx_ads-get_payment_data "get_payment_data" + */ + public function serviceGetPaymentData() + { + $CNF = &$this->_oConfig->CNF; + + $oPermalink = BxDolPermalinks::getInstance(); + + $aResult = $this->_aModule; + $aResult['url_browse_order_common'] = BX_DOL_URL_ROOT . $oPermalink->permalink($CNF['URL_LICENSES_COMMON'], array('filter' => '{order}')); + $aResult['url_browse_order_administration'] = BX_DOL_URL_ROOT . $oPermalink->permalink($CNF['URL_LICENSES_ADMINISTRATION'], array('filter' => '{order}')); + + return $aResult; + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-get_cart_item get_cart_item + * + * @code bx_srv('bx_ads', 'get_cart_item', [...]); @endcode + * + * Get an array with prodict's description. Is used in Shopping Cart in payments processing module. + * + * @param $mixedItemId product's ID or Unique Name. + * @return an array with prodict's description. Empty array is returned if something is wrong. + * + * @see BxAdsModule::serviceGetCartItem + */ + /** + * @ref bx_ads-get_cart_item "get_cart_item" + */ + public function serviceGetCartItem($mixedItemId) + { + $CNF = &$this->_oConfig->CNF; + + if(!$mixedItemId) + return array(); + + if(is_numeric($mixedItemId)) + $aItem = $this->_oDb->getContentInfoById((int)$mixedItemId); + else + $aItem = $this->_oDb->getContentInfoByName($mixedItemId); + + if(empty($aItem) || !is_array($aItem)) + return array(); + + $iItemId = (int)$aItem[$CNF['FIELD_ID']]; + $fItemPrice = (float)$aItem[$CNF['FIELD_PRICE']]; + + if($this->isAuction($aItem)) { + $iUserId = bx_get_logged_profile_id(); + + $aOffer = $this->_oDb->getOffersBy(array( + 'type' => 'content_and_author_ids', + 'content_id' => $iItemId, + 'author_id' => $iUserId, + 'status' => BX_ADS_OFFER_STATUS_ACCEPTED + )); + + if(!empty($aOffer) && is_array($aOffer)) + $fItemPrice = (float)$aOffer[$CNF['FIELD_OFR_AMOUNT']]; + } + + return array ( + 'id' => $iItemId, + 'author_id' => $aItem[$CNF['FIELD_AUTHOR']], + 'name' => $aItem[$CNF['FIELD_NAME']], + 'title' => $aItem[$CNF['FIELD_TITLE']], + 'description' => $aItem[$CNF['FIELD_TEXT']], + 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'], array('id' => $aItem[$CNF['FIELD_ID']])), + 'price_single' => $fItemPrice, + 'price_recurring' => '', + 'period_recurring' => 0, + 'period_unit_recurring' => '', + 'trial_recurring' => '' + ); + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-get_cart_items get_cart_items + * + * @code bx_srv('bx_ads', 'get_cart_items', [...]); @endcode + * + * Get an array with prodicts' descriptions by seller. Is used in Manual Order Processing in payments processing module. + * + * @param $iSellerId seller ID. + * @return an array with prodicts' descriptions. Empty array is returned if something is wrong or seller doesn't have any products. + * + * @see BxAdsModule::serviceGetCartItems + */ + /** + * @ref bx_ads-get_cart_items "get_cart_items" + */ + public function serviceGetCartItems($iSellerId) + { + $CNF = &$this->_oConfig->CNF; + + $iSellerId = (int)$iSellerId; + if(empty($iSellerId)) + return array(); + + $aItems = $this->_oDb->getEntriesByAuthor($iSellerId); + + $aResult = array(); + foreach($aItems as $aItem) + $aResult[] = array( + 'id' => $aItem[$CNF['FIELD_ID']], + 'author_id' => $aItem[$CNF['FIELD_AUTHOR']], + 'name' => $aItem[$CNF['FIELD_NAME']], + 'title' => $aItem[$CNF['FIELD_TITLE']], + 'description' => $aItem[$CNF['FIELD_TEXT']], + 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'], array('id' => $aItem[$CNF['FIELD_ID']])), + 'price_single' => $aItem[$CNF['FIELD_PRICE_SINGLE']], + 'price_recurring' => '', + 'period_recurring' => 0, + 'period_unit_recurring' => '', + 'trial_recurring' => '' + ); + + return $aResult; + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-register_cart_item register_cart_item + * + * @code bx_srv('bx_ads', 'register_cart_item', [...]); @endcode + * + * Register a processed single time payment inside the Ads module. Is called with payment processing module after the payment was registered there. + * + * @param $iClientId client ID. + * @param $iSellerId seller ID + * @param $iItemId item ID. + * @param $iItemCount the number of purchased items. + * @param $sOrder order number received from payment provider (PayPal, Stripe, etc) + * @param $sLicense license number genereted with payment processing module for internal usage + * @return an array with purchased prodict's description. Empty array is returned if something is wrong. + * + * @see BxAdsModule::serviceRegisterCartItem + */ + /** + * @ref bx_ads-register_cart_item "register_cart_item" + */ + public function serviceRegisterCartItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrder, $sLicense) + { + $CNF = &$this->_oConfig->CNF; + + $aItem = $this->serviceGetCartItem($iItemId); + if(empty($aItem) || !is_array($aItem)) + return array(); + + $aEntry = $this->_oDb->getContentInfoById($iItemId); + if(empty($aEntry) || !is_array($aEntry) || (int)$aEntry[$CNF['FIELD_QUANTITY']] <= 0) + return array(); + + if(!$this->_oDb->registerLicense($iClientId, $iItemId, $iItemCount, $sOrder, $sLicense)) + return array(); + + $this->_oDb->updateEntriesBy(array($CNF['FIELD_QUANTITY'] => (int)$aEntry[$CNF['FIELD_QUANTITY']] - $iItemCount), array($CNF['FIELD_ID'] => $iItemId)); + + bx_alert($this->getName(), 'license_register', 0, false, array( + 'product_id' => $iItemId, + 'profile_id' => $iClientId, + 'order' => $sOrder, + 'license' => $sLicense, + 'count' => $iItemCount + )); + + $oClient = BxDolProfile::getInstanceMagic($iClientId); + $oSeller = BxDolProfile::getInstanceMagic($iSellerId); + $sSellerUrl = $oSeller->getUrl(); + $sSellerName = $oSeller->getDisplayName(); + + $sNote = $aEntry[$CNF['FIELD_NOTES_PURCHASED']]; + if(empty($sNote)) + $sNote = _t('_bx_ads_txt_purchased_note', $sSellerUrl, $sSellerName); + + sendMailTemplate($CNF['ETEMPLATE_PURCHASED'], 0, $iClientId, array( + 'client_name' => $oClient->getDisplayName(), + 'entry_name' => $aEntry[$CNF['FIELD_TITLE']], + 'entry_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'], array('id' => $aEntry[$CNF['FIELD_ID']])), + 'vendor_url' => $sSellerUrl, + 'vendor_name' => $sSellerName, + 'count' => (int)$iItemCount, + 'license' => $sLicense, + 'notes' => $sNote, + )); + + return $aItem; + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-register_subscription_item register_subscription_item + * + * @code bx_srv('bx_ads', 'register_subscription_item', [...]); @endcode + * + * Register a processed subscription (recurring payment) inside the Ads module. Is called with payment processing module after the subscription was registered there. + * + * @param $iClientId client ID. + * @param $iSellerId seller ID + * @param $iItemId item ID. + * @param $iItemCount the number of purchased items. + * @param $sOrder order number received from payment provider (PayPal, Stripe, etc) + * @param $sLicense license number genereted with payment processing module for internal usage + * @return an array with subscribed prodict's description. Empty array is returned if something is wrong. + * + * @see BxAdsModule::serviceRegisterSubscriptionItem + */ + /** + * @ref bx_ads-register_subscription_item "register_subscription_item" + */ + public function serviceRegisterSubscriptionItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrder, $sLicense) + { + return array(); + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-reregister_cart_item reregister_cart_item + * + * @code bx_srv('bx_ads', 'reregister_cart_item', [...]); @endcode + * + * Reregister a single time payment inside the Ads module. Is called with payment processing module after the payment was reregistered there. + * + * @param $iClientId client ID. + * @param $iSellerId seller ID + * @param $iItemIdOld old item ID. + * @param $iItemIdNew new item ID. + * @param $sOrder order number received from payment provider (PayPal, Stripe, etc) + * @return an array with purchased prodict's description. Empty array is returned if something is wrong. + * + * @see BxAdsModule::serviceReregisterCartItem + */ + /** + * @ref bx_ads-reregister_cart_item "reregister_cart_item" + */ + public function serviceReregisterCartItem($iClientId, $iSellerId, $iItemIdOld, $iItemIdNew, $sOrder) + { + return array(); + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-reregister_subscription_item reregister_subscription_item + * + * @code bx_srv('bx_ads', 'reregister_subscription_item', [...]); @endcode + * + * Reregister a subscription (recurring payment) inside the Ads module. Is called with payment processing module after the subscription was reregistered there. + * + * @param $iClientId client ID. + * @param $iSellerId seller ID + * @param $iItemIdOld old item ID. + * @param $iItemIdNew new item ID. + * @param $sOrder order number received from payment provider (PayPal, Stripe, etc) + * @return an array with subscribed prodict's description. Empty array is returned if something is wrong. + * + * @see BxAdsModule::serviceReregisterSubscriptionItem + */ + /** + * @ref bx_ads-reregister_subscription_item "reregister_subscription_item" + */ + public function serviceReregisterSubscriptionItem($iClientId, $iSellerId, $iItemIdOld, $iItemIdNew, $sOrder) + { + return array(); + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-unregister_cart_item unregister_cart_item + * + * @code bx_srv('bx_ads', 'unregister_cart_item', [...]); @endcode + * + * Unregister an earlier processed single time payment inside the Ads module. Is called with payment processing module after the payment was unregistered there. + * + * @param $iClientId client ID. + * @param $iSellerId seller ID + * @param $iItemId item ID. + * @param $iItemCount the number of purchased items. + * @param $sOrder order number received from payment provider (PayPal, Stripe, etc) + * @param $sLicense license number genereted with payment processing module for internal usage + * @return boolean value determining where the payment was unregistered or not. + * + * @see BxAdsModule::serviceUnregisterCartItem + */ + /** + * @ref bx_ads-unregister_cart_item "unregister_cart_item" + */ + public function serviceUnregisterCartItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrder, $sLicense) + { + if(!$this->_oDb->unregisterLicense($iClientId, $iItemId, $sOrder, $sLicense)) + return false; + + bx_alert($this->getName(), 'license_unregister', 0, false, array( + 'product_id' => $iItemId, + 'profile_id' => $iClientId, + 'order' => $sOrder, + 'license' => $sLicense, + 'count' => $iItemCount + )); + + return true;; + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-unregister_subscription_item unregister_subscription_item + * + * @code bx_srv('bx_ads', 'unregister_subscription_item', [...]); @endcode + * + * Unregister an earlier processed subscription (recurring payment) inside the Ads module. Is called with payment processing module after the subscription was unregistered there. + * + * @param $iClientId client ID. + * @param $iSellerId seller ID + * @param $iItemId item ID. + * @param $iItemCount the number of purchased items. + * @param $sOrder order number received from payment provider (PayPal, Stripe, etc) + * @param $sLicense license number genereted with payment processing module for internal usage + * @return boolean value determining where the subscription was unregistered or not. + * + * @see BxAdsModule::serviceUnregisterSubscriptionItem + */ + /** + * @ref bx_ads-unregister_subscription_item "unregister_subscription_item" + */ + public function serviceUnregisterSubscriptionItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrder, $sLicense) + { + return true; + } + + /** + * @page service Service Calls + * @section bx_ads Ads + * @subsection bx_ads-payments Payments + * @subsubsection bx_ads-cancel_subscription_item cancel_subscription_item + * + * @code bx_srv('bx_ads', 'cancel_subscription_item', [...]); @endcode + * + * Cancel an earlier processed subscription (recurring payment) inside the Ads module. Is called with payment processing module after the subscription was canceled there. + * + * @param $iClientId client ID. + * @param $iSellerId seller ID + * @param $iItemId item ID. + * @param $iItemCount the number of purchased items. + * @param $sOrder order number received from payment provider (PayPal, Stripe, etc) + * @return boolean value determining where the subscription was canceled or not. + * + * @see BxAdsModule::serviceCancelSubscriptionItem + */ + /** + * @ref bx_ads-cancel_subscription_item "cancel_subscription_item" + */ + public function serviceCancelSubscriptionItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrder) + { + return true; + } + + public function serviceGetOffersCount($sStatus = '') + { + if(!$this->_oConfig->isAuction()) + return 0; + + if(empty($sStatus) || !in_array($sStatus, $this->_aOfferStatuses)) + $sStatus = BX_ADS_OFFER_STATUS_AWAITING; + + $iUserId = bx_get_logged_profile_id(); + return $this->_oDb->getOffersBy(array('type' => 'content_author_id', 'author_id' => $iUserId, 'status' => $sStatus, 'count' => true)); + } + + public function serviceGetLiveUpdates($sStatus, $aMenuItemParent, $aMenuItemChild, $iCount = 0) + { + if(!in_array($sStatus, $this->_aOfferStatuses)) + return false; + + $iUserId = bx_get_logged_profile_id(); + $iCountNew = $this->_oDb->getOffersBy(array('type' => 'content_author_id', 'author_id' => $iUserId, 'status' => $sStatus, 'count' => true)); + if($iCountNew == $iCount) + return false; + + return array( + 'count' => $iCountNew, // required + 'method' => 'bx_menu_show_live_update(oData)', // required + 'data' => array( + 'code' => BxDolTemplate::getInstance()->parseHtmlByTemplateName('menu_item_addon', array( + 'content' => '{count}' + )), + 'mi_parent' => $aMenuItemParent, + 'mi_child' => $aMenuItemChild + ), // optional, may have some additional data to be passed in JS method provided using 'method' param above. + ); + } + + public function serviceOffers() + { + $CNF = &$this->_oConfig->CNF; + + if(!$this->_oConfig->isAuction()) + return ''; + + $oGrid = BxDolGrid::getObjectInstance($CNF['OBJECT_GRID_OFFERS_ALL']); + if(!$oGrid) + return ''; + + return $oGrid->getCode(); + } + + public function serviceEntityOffers($iContentId = 0) + { + $CNF = &$this->_oConfig->CNF; + + if(!$this->_oConfig->isAuction()) + return ''; + + $oGrid = BxDolGrid::getObjectInstance($CNF['OBJECT_GRID_OFFERS']); + if(!$oGrid) + return ''; + + if(empty($iContentId) && ($_iContentId = bx_get('id')) !== false) + $iContentId = (int)$_iContentId; + + $oGrid->setContentId($iContentId); + return $oGrid->getCode(); + } + + public function serviceEntityOfferAccepted($iContentId = 0) + { + if(!$this->_oConfig->isAuction()) + return ''; + + $iUserId = bx_get_logged_profile_id(); + + if(empty($iContentId) && ($_iContentId = bx_get('id')) !== false) + $iContentId = (int)$_iContentId; + + $aContent = $this->_oDb->getContentInfoById($iContentId); + if(empty($aContent) || !is_array($aContent)) + return ''; + + $aOffer = $this->_oDb->getOffersBy(array( + 'type' => 'content_and_author_ids', + 'content_id' => $iContentId, + 'author_id' => $iUserId, + 'status' => BX_ADS_OFFER_STATUS_ACCEPTED + )); + + if(empty($aOffer) || !is_array($aOffer)) + return ''; + + return $this->_oTemplate->entryOfferAccepted($iUserId, $aContent, $aOffer); + } + + public function isAuction($aContentInfo) + { + $CNF = &$this->_oConfig->CNF; + + return $this->_oConfig->isAuction() && (int)$aContentInfo[$CNF['FIELD_AUCTION']] != 0; + } + + public function isAllowedMakeOffer($mixedContent, $isPerformAction = false) + { + return $this->checkAllowedMakeOffer($mixedContent, $isPerformAction) === CHECK_ACTION_RESULT_ALLOWED; + } + + public function checkAllowedMakeOffer($mixedContent, $isPerformAction = false) + { + $CNF = &$this->_oConfig->CNF; + + if(!is_array($mixedContent)) + $mixedContent = $this->_oDb->getContentInfoById((int)$mixedContent); + + if(!$this->isAuction($mixedContent)) + return _t('_sys_txt_access_denied'); + + if(!empty($mixedContent) && is_array($mixedContent) && $mixedContent[$CNF['FIELD_AUTHOR']] != bx_get_logged_profile_id()) + return CHECK_ACTION_RESULT_ALLOWED; + + return _t('_sys_txt_access_denied'); + } + + public function isAllowedViewOffers($mixedContent, $isPerformAction = false) + { + return $this->checkAllowedViewOffers($mixedContent, $isPerformAction) === CHECK_ACTION_RESULT_ALLOWED; + } + + public function checkAllowedViewOffers($mixedContent, $isPerformAction = false) + { + $CNF = &$this->_oConfig->CNF; + + if(!is_array($mixedContent)) + $mixedContent = $this->_oDb->getContentInfoById((int)$mixedContent); + + if(!$this->isAuction($mixedContent)) + return _t('_sys_txt_access_denied'); + + if($this->checkAllowedEditAnyEntry($isPerformAction) === CHECK_ACTION_RESULT_ALLOWED) + return CHECK_ACTION_RESULT_ALLOWED; + + if(!empty($mixedContent) && is_array($mixedContent) && $mixedContent[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id()) + return CHECK_ACTION_RESULT_ALLOWED; + + return _t('_sys_txt_access_denied'); + } + + public function onOfferAdded($iOfferId) + { + $CNF = &$this->_oConfig->CNF; + + $aOfferInfo = $this->_oDb->getOffersBy(array('type' => 'id', 'id' => $iOfferId)); + if(empty($aOfferInfo) || !is_array($aOfferInfo)) + return; + + $iContentId = (int)$aOfferInfo[$CNF['FIELD_OFR_CONTENT']]; + $aContentInfo = $this->_oDb->getContentInfoById($iContentId); + if(empty($aContentInfo) || !is_array($aContentInfo)) + return; + + $iViewer = bx_get_logged_profile_id(); + $oViewer = BxDolProfile::getInstanceMagic($iViewer); + + sendMailTemplate($CNF['ETEMPLATE_OFFER_ADDED'], 0, $aContentInfo[$CNF['FIELD_AUTHOR']], array( + 'viewer_name' => $oViewer->getDisplayName(), + 'viewer_url' => $oViewer->getUrl(), + 'ad_name' => $aContentInfo[$CNF['FIELD_TITLE']], + 'ad_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php', array( + 'i' => $CNF['URI_VIEW_ENTRY'], + $CNF['FIELD_ID'] => $iContentId + )) + )); + + $aParams = $this->_alertParamsOffer($aContentInfo, $aOfferInfo); + bx_alert($this->getName(), 'offer_added', $iOfferId, $aOfferInfo[$CNF['FIELD_OFR_AUTHOR']], $aParams); + } + + public function onOfferAccepted($iOfferId) + { + $CNF = &$this->_oConfig->CNF; + + $aOfferInfo = $this->_oDb->getOffersBy(array('type' => 'id', 'id' => $iOfferId)); + if(empty($aOfferInfo) || !is_array($aOfferInfo)) + return; + + $iContentId = (int)$aOfferInfo[$CNF['FIELD_OFR_CONTENT']]; + $aContentInfo = $this->_oDb->getContentInfoById($iContentId); + if(empty($aContentInfo) || !is_array($aContentInfo)) + return; + + $iOfferer = (int)$aOfferInfo[$CNF['FIELD_OFR_AUTHOR']]; + $oOfferer = BxDolProfile::getInstanceMagic($iOfferer); + + sendMailTemplate($CNF['ETEMPLATE_OFFER_ACCEPTED'], 0, $iOfferer, array( + 'offerer_name' => $oOfferer->getDisplayName(), + 'offerer_url' => $oOfferer->getUrl(), + 'ad_name' => $aContentInfo[$CNF['FIELD_TITLE']], + 'ad_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php', array( + 'i' => $CNF['URI_VIEW_ENTRY'], + $CNF['FIELD_ID'] => $iContentId + )) + )); + + $aParams = $this->_alertParamsOffer($aContentInfo, $aOfferInfo); + bx_alert($this->getName(), 'offer_accepted', $iOfferId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams); + } + + public function onOfferDeclined($iOfferId) + { + $CNF = &$this->_oConfig->CNF; + + $aOfferInfo = $this->_oDb->getOffersBy(array('type' => 'id', 'id' => $iOfferId)); + if(empty($aOfferInfo) || !is_array($aOfferInfo)) + return; + + $iContentId = (int)$aOfferInfo[$CNF['FIELD_OFR_CONTENT']]; + $aContentInfo = $this->_oDb->getContentInfoById($iContentId); + if(empty($aContentInfo) || !is_array($aContentInfo)) + return; + + $iOfferer = (int)$aOfferInfo[$CNF['FIELD_OFR_AUTHOR']]; + $oOfferer = BxDolProfile::getInstanceMagic($iOfferer); + + sendMailTemplate($CNF['ETEMPLATE_OFFER_DECLINED'], 0, $iOfferer, array( + 'offerer_name' => $oOfferer->getDisplayName(), + 'offerer_url' => $oOfferer->getUrl(), + 'ad_name' => $aContentInfo[$CNF['FIELD_TITLE']], + 'ad_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php', array( + 'i' => $CNF['URI_VIEW_ENTRY'], + $CNF['FIELD_ID'] => $iContentId + )) + )); + + $aParams = $this->_alertParamsOffer($aContentInfo, $aOfferInfo); + bx_alert($this->getName(), 'offer_declined', $iOfferId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams); + } + + /** * Common methods. */ @@ -500,6 +1292,41 @@ protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowsePa return $aResult; } + + protected function _getBlockLicenses($sType = '') + { + $CNF = &$this->_oConfig->CNF; + + $sGrid = $CNF['OBJECT_GRID_LICENSES' . (!empty($sType) ? '_' . strtoupper($sType) : '')]; + $oGrid = BxDolGrid::getObjectInstance($sGrid); + if(!$oGrid) + return ''; + + $this->_oDb->updateLicense(array('new' => 0), array('profile_id' => bx_get_logged_profile_id(), 'new' => 1)); + + $this->_oTemplate->addJs(array('licenses.js')); + return array( + 'content' => $this->_oTemplate->getJsCode('licenses', array('sObjNameGrid' => $sGrid)) . $oGrid->getCode(), + 'menu' => $CNF['OBJECT_MENU_LICENSES'] + ); + } + + protected function _alertParamsOffer($aContentInfo, $aOfferInfo) + { + $CNF = &$this->_oConfig->CNF; + + $aParams = array( + 'object_id' => (int)$aContentInfo[$CNF['FIELD_ID']], + 'object_author_id' => (int)$aContentInfo[$CNF['FIELD_AUTHOR']], + + 'offer_id' => (int)$aOfferInfo[$CNF['FIELD_OFR_ID']], + 'offer_author_id' => (int)$aOfferInfo[$CNF['FIELD_OFR_AUTHOR']], + ); + if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']])) + $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]; + + return $aParams; + } } /** @} */ diff --git a/modules/boonex/ads/classes/BxAdsPageEntry.php b/modules/boonex/ads/classes/BxAdsPageEntry.php index de00e721f9..21b40d97de 100644 --- a/modules/boonex/ads/classes/BxAdsPageEntry.php +++ b/modules/boonex/ads/classes/BxAdsPageEntry.php @@ -21,6 +21,24 @@ public function __construct($aObject, $oTemplate = false) parent::__construct($aObject, $oTemplate); } + public function getCode () + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $iEntryAuthor = (int)$this->_aContentInfo[$CNF['FIELD_AUTHOR']]; + $sEntryStatus = $this->_aContentInfo[$CNF['FIELD_STATUS_ADMIN']]; + if(($iEntryAuthor == bx_get_logged_profile_id() || $this->_oModule->_isModerator()) && $sEntryStatus != BX_ADS_STATUS_ACTIVE) + BxDolInformer::getInstance($this->_oModule->_oTemplate)->add('bx-ads-entry-' . $sEntryStatus, _t('_bx_ads_txt_msg_status_' . $sEntryStatus), BX_INFORMER_ALERT); + + $sResult = parent::getCode(); + if(!empty($sResult)) + $sResult .= $this->_oModule->_oTemplate->getJsCode('entry'); + + $this->_oModule->_oTemplate->addCss(array('entry.css')); + $this->_oModule->_oTemplate->addJs(array('entry.js')); + return $sResult; + } + protected function _setSubmenu($aParams) { parent::_setSubmenu(array_merge($aParams, array( diff --git a/modules/boonex/ads/classes/BxAdsPageLicenses.php b/modules/boonex/ads/classes/BxAdsPageLicenses.php new file mode 100644 index 0000000000..0cc0ff386c --- /dev/null +++ b/modules/boonex/ads/classes/BxAdsPageLicenses.php @@ -0,0 +1,32 @@ +MODULE = 'bx_ads'; + + parent::__construct($aObject, $oTemplate); + + $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu'); + if($oMenuSubmenu) { + $sMenuSubmenu = 'sys_account_dashboard'; + $oMenuSubmenu->setObjectSubmenu($sMenuSubmenu, array('title' => _t('_sys_menu_item_title_account_dashboard'), 'link' => '', 'icon' => '')); + + BxDolMenu::getObjectInstance($sMenuSubmenu)->setSelected($this->MODULE, 'dashboard-ads-licenses'); + } + } +} + +/** @} */ diff --git a/modules/boonex/ads/classes/BxAdsPageOffers.php b/modules/boonex/ads/classes/BxAdsPageOffers.php new file mode 100644 index 0000000000..4408531b81 --- /dev/null +++ b/modules/boonex/ads/classes/BxAdsPageOffers.php @@ -0,0 +1,22 @@ +MODULE = 'bx_ads'; + + parent::__construct($aObject, $oTemplate); + } +} + +/** @} */ diff --git a/modules/boonex/ads/classes/BxAdsTemplate.php b/modules/boonex/ads/classes/BxAdsTemplate.php index e33a325fc7..d14c751578 100644 --- a/modules/boonex/ads/classes/BxAdsTemplate.php +++ b/modules/boonex/ads/classes/BxAdsTemplate.php @@ -23,6 +23,28 @@ function __construct(&$oConfig, &$oDb) $this->aMethodsToCallAddJsCss[] = 'categories'; } + public function entryOfferAccepted($iUserId, $aContent, $aOffer) + { + $CNF = &$this->_oConfig->CNF; + + $sJsCode = $sJsMethod = ''; + $aJs = BxDolPayments::getInstance()->getAddToCartJs($aContent[$CNF['FIELD_AUTHOR']], $this->MODULE, $aContent[$CNF['FIELD_ID']], $aOffer[$CNF['FIELD_OFR_QUANTITY']], true); + if(!empty($aJs) && is_array($aJs)) + list($sJsCode, $sJsMethod) = $aJs; + + return $this->parseHtmlByName('entry-offer-accepted.html', array( + 'amount' => _t_format_currency($aOffer['amount']), + 'quantity' => _t('_bx_ads_txt_n_items', $aOffer['quantity']), + 'bx_if:show_pay' => array( + 'condition' => !empty($sJsMethod), + 'content' => array( + 'js_method' => $sJsMethod, + ) + ), + 'js_code' => $sJsCode + )); + } + public function entryBreadcrumb($aContentInfo, $aTmplVarsItems = array()) { $CNF = &$this->_oConfig->CNF; @@ -55,6 +77,19 @@ public function categoriesList($aParams = array()) return $sResult; } + public function getEntryLink($aEntry) + { + $CNF = &$this->_oConfig->CNF; + + return $this->getLink('entry-link', array( + 'href' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'], array( + 'id' => $aEntry[$CNF['FIELD_ID']] + )), + 'title' => bx_html_attribute($aEntry[$CNF['FIELD_TITLE']]), + 'content' => $aEntry[$CNF['FIELD_TITLE']] + )); + } + /** * Use Gallery image for both because currently there is no Unit types with small thumbnails. */ diff --git a/modules/boonex/ads/install/installer.php b/modules/boonex/ads/install/installer.php index d5ed43ac36..53f11f2dfc 100644 --- a/modules/boonex/ads/install/installer.php +++ b/modules/boonex/ads/install/installer.php @@ -11,10 +11,27 @@ class BxAdsInstaller extends BxBaseModTextInstaller { - function __construct($aConfig) + public function __construct($aConfig) { parent::__construct($aConfig); } + + public function enable($aParams) + { + $aResult = parent::enable($aParams); + + if($aResult['result']) + BxDolPayments::getInstance()->updateDependentModules($this->_aConfig['name'], true); + + return $aResult; + } + + public function disable($aParams) + { + BxDolPayments::getInstance()->updateDependentModules($this->_aConfig['name'], false); + + return parent::disable($aParams); + } } /** @} */ diff --git a/modules/boonex/ads/install/langs/en.xml b/modules/boonex/ads/install/langs/en.xml index f06b253a8f..a9611a87db 100644 --- a/modules/boonex/ads/install/langs/en.xml +++ b/modules/boonex/ads/install/langs/en.xml @@ -4,6 +4,7 @@ + @@ -12,6 +13,7 @@ + @@ -62,8 +64,17 @@ + + + + + + + + + @@ -74,6 +85,9 @@ + + + @@ -109,6 +123,21 @@ + + + + + + + + + + + + + + + @@ -201,12 +230,27 @@ + + + + + + + + + + + + + + + @@ -235,6 +279,12 @@ + + + + + + @@ -277,6 +327,16 @@ + + + + + + + + + + @@ -294,6 +354,7 @@ + @@ -302,9 +363,31 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -367,6 +450,35 @@ Hello, {profile_name}.

{viewer_name} is interested in your ad {ad_name}.

+{email_footer}]]>
+ + + + Hello, {client_name}.

+

You've purchased {entry_name} ad ({count} item(s)) from {vendor_name}.
Your license is {license}.

+

{notes}

+{email_footer}]]>
+ + + + Hello, {profile_name}.

+

{viewer_name} added an offer for your ad {ad_name}.

+{email_footer}]]>
+ + + + Hello, {offerer_name}.

+

Your offer for {ad_name} ad was accepted.

+{email_footer}]]>
+ + + + Hello, {offerer_name}.

+

Your offer for {ad_name} ad was declined.

{email_footer}]]>
All Ads in {1} ({2})]]> @@ -385,8 +497,21 @@ + {1} if you have any questions or need support.]]> + + + + + + + + + + + + diff --git a/modules/boonex/ads/install/sql/disable.sql b/modules/boonex/ads/install/sql/disable.sql index 98db0eb8e8..5ad9139c14 100644 --- a/modules/boonex/ads/install/sql/disable.sql +++ b/modules/boonex/ads/install/sql/disable.sql @@ -8,7 +8,7 @@ DELETE FROM `sys_options_types` WHERE `id` = @iTypeId; -- PAGES DELETE FROM `sys_objects_page` WHERE `module` = 'bx_ads'; -DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_ads' OR `object` IN ('bx_ads_create_entry', 'bx_ads_edit_entry', 'bx_ads_delete_entry', 'bx_ads_view_entry', 'bx_ads_view_entry_comments', 'bx_ads_home', 'bx_ads_popular', 'bx_ads_updated', 'bx_ads_categories', 'bx_ads_author', 'bx_ads_context', 'bx_ads_search', 'bx_ads_manage'); +DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_ads' OR `object` IN ('bx_ads_create_entry', 'bx_ads_edit_entry', 'bx_ads_delete_entry', 'bx_ads_view_entry', 'bx_ads_view_entry_comments', 'bx_ads_home', 'bx_ads_popular', 'bx_ads_updated', 'bx_ads_categories', 'bx_ads_author', 'bx_ads_context', 'bx_ads_search', 'bx_ads_manage', 'bx_ads_administration', 'bx_ads_licenses', 'bx_ads_licenses_administration', 'bx_ads_offers', 'bx_ads_offers_all'); -- MENU DELETE FROM `sys_objects_menu` WHERE `module` = 'bx_ads'; @@ -42,6 +42,9 @@ DELETE FROM `sys_grid_actions` WHERE `object` LIKE 'bx_ads_%'; -- UPLOADERS DELETE FROM `sys_objects_uploader` WHERE `object` LIKE 'bx_ads_%'; +-- LIVE UPDATES +DELETE FROM `sys_objects_live_updates` WHERE `name` = 'bx_ads'; + -- ALERTS SET @iHandler := (SELECT `id` FROM `sys_alerts_handlers` WHERE `name` = 'bx_ads' LIMIT 1); DELETE FROM `sys_alerts` WHERE `handler_id` = @iHandler; diff --git a/modules/boonex/ads/install/sql/enable.sql b/modules/boonex/ads/install/sql/enable.sql index bb5baa26c1..7aa0319119 100644 --- a/modules/boonex/ads/install/sql/enable.sql +++ b/modules/boonex/ads/install/sql/enable.sql @@ -10,15 +10,21 @@ VALUES (@iTypeId, 'bx_ads', '_bx_ads', 1); SET @iCategId = LAST_INSERT_ID(); INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_error`, `extra`, `order`) VALUES -('bx_ads_summary_chars', '700', @iCategId, '_bx_ads_option_summary_chars', 'digit', '', '', '', 1), -('bx_ads_plain_summary_chars', '240', @iCategId, '_bx_ads_option_plain_summary_chars', 'digit', '', '', '', 2), -('bx_ads_per_page_browse', '12', @iCategId, '_bx_ads_option_per_page_browse', 'digit', '', '', '', 10), -('bx_ads_per_page_profile', '6', @iCategId, '_bx_ads_option_per_page_profile', 'digit', '', '', '', 12), -('bx_ads_per_page_browse_showcase', '32', @iCategId, '_sys_option_per_page_browse_showcase', 'digit', '', '', '', 15), -('bx_ads_rss_num', '10', @iCategId, '_bx_ads_option_rss_num', 'digit', '', '', '', 20), +('bx_ads_enable_auto_approve', 'on', @iCategId, '_bx_ads_option_enable_auto_approve', 'checkbox', '', '', '', 0), +('bx_ads_enable_auction', '', @iCategId, '_bx_ads_option_enable_auction', 'checkbox', '', '', '', 2), +('bx_ads_internal_interested_notification', '', @iCategId, '_bx_ads_option_internal_interested_notification', 'checkbox', '', '', '', 3), + +('bx_ads_summary_chars', '700', @iCategId, '_bx_ads_option_summary_chars', 'digit', '', '', '', 10), +('bx_ads_plain_summary_chars', '240', @iCategId, '_bx_ads_option_plain_summary_chars', 'digit', '', '', '', 12), + +('bx_ads_per_page_browse', '12', @iCategId, '_bx_ads_option_per_page_browse', 'digit', '', '', '', 20), +('bx_ads_per_page_profile', '6', @iCategId, '_bx_ads_option_per_page_profile', 'digit', '', '', '', 22), +('bx_ads_per_page_browse_showcase', '32', @iCategId, '_sys_option_per_page_browse_showcase', 'digit', '', '', '', 24), +('bx_ads_rss_num', '10', @iCategId, '_bx_ads_option_rss_num', 'digit', '', '', '', 28), + ('bx_ads_searchable_fields', 'title,text', @iCategId, '_bx_ads_option_searchable_fields', 'list', '', '', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:21:"get_searchable_fields";}', 30), -('bx_ads_lifetime', '30', @iCategId, '_bx_ads_option_lifetime', 'digit', '', '', '', 40), -('bx_ads_internal_interested_notification', '', @iCategId, '_bx_ads_option_internal_interested_notification', 'checkbox', '', '', '', 50); + +('bx_ads_lifetime', '30', @iCategId, '_bx_ads_option_lifetime', 'digit', '', '', '', 40); -- PAGE: create entry @@ -55,12 +61,13 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t ('bx_ads_view_entry', 2, 'bx_ads', '', '_bx_ads_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:18:"entity_attachments";}', 0, 0, 1, 30), ('bx_ads_view_entry', 2, 'bx_ads', '', '_bx_ads_page_block_title_entry_reviews', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:14:"entity_reviews";}', 0, 0, 1, 50), ('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:15:"entity_location";}', 0, 0, 0, 0), -('bx_ads_view_entry', 3, 'bx_ads', '_bx_ads_page_block_title_sys_entry_context', '_bx_ads_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:14:"entity_context";}', 0, 0, 1, 1), -('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:11:"entity_info";}', 0, 0, 1, 10), -('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_reviews_rating', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:21:"entity_reviews_rating";}', 0, 0, 1, 20), -('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_location', 3, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"locations_map";s:6:"params";a:2:{i:0;s:6:"bx_ads";i:1;s:4:"{id}";}s:5:"class";s:20:"TemplServiceMetatags";}', 0, 0, 1, 30), -('bx_ads_view_entry', 2, 'bx_ads', '', '_bx_ads_page_block_title_entry_polls', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:12:"entity_polls";}', 0, 0, 1, 40), -('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_featured_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:15:"browse_featured";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 0, 1, 50), +('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_offer_accepted', 13, 2147483647, 'service', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:21:"entity_offer_accepted";s:6:"params";a:1:{i:0;s:4:"{id}";}}', 0, 0, 1, 10), +('bx_ads_view_entry', 3, 'bx_ads', '_bx_ads_page_block_title_sys_entry_context', '_bx_ads_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:14:"entity_context";}', 0, 0, 1, 20), +('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:11:"entity_info";}', 0, 0, 1, 30), +('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_reviews_rating', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:21:"entity_reviews_rating";}', 0, 0, 1, 40), +('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_entry_location', 3, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"locations_map";s:6:"params";a:2:{i:0;s:6:"bx_ads";i:1;s:4:"{id}";}s:5:"class";s:20:"TemplServiceMetatags";}', 0, 0, 1, 50), +('bx_ads_view_entry', 2, 'bx_ads', '', '_bx_ads_page_block_title_entry_polls', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:12:"entity_polls";}', 0, 0, 1, 60), +('bx_ads_view_entry', 3, 'bx_ads', '', '_bx_ads_page_block_title_featured_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:15:"browse_featured";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 0, 1, 70), ('bx_ads_view_entry', 4, 'bx_ads', '', '_bx_ads_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:14:"entity_actions";}', 0, 0, 0, 0), ('bx_ads_view_entry', 4, 'bx_ads', '', '_bx_ads_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:21:"entity_social_sharing";}', 0, 0, 0, 0); @@ -120,7 +127,6 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t ('bx_ads_home', 2, 'bx_ads', '', '_bx_ads_page_block_title_popular_keywords', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:14:"keywords_cloud";s:6:"params";a:2:{i:0;s:6:"bx_ads";i:1;s:6:"bx_ads";}s:5:"class";s:20:"TemplServiceMetatags";}', 0, 1, 1, 0), ('bx_ads_home', 2, 'bx_ads', '', '_bx_ads_page_block_title_categories', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:15:"categories_list";s:6:"params";a:1:{i:0;a:1:{s:10:"show_empty";b:1;}}}', 0, 1, 1, 1); - -- PAGE: search for entries INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES ('bx_ads_search', '_bx_ads_page_title_sys_entries_search', '_bx_ads_page_title_entries_search', 'bx_ads', 5, 2147483647, 1, 'ads-search', 'page.php?i=ads-search', '', '', '', 0, 1, 0, 'BxAdsPageBrowse', 'modules/boonex/ads/classes/BxAdsPageBrowse.php'); @@ -145,6 +151,36 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES ('bx_ads_administration', 1, 'bx_ads', '_bx_ads_page_block_title_system_manage_administration', '_bx_ads_page_block_title_manage', 11, 192, 'service', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:12:"manage_tools";s:6:"params";a:1:{i:0;s:14:"administration";}}', 0, 1, 0); +-- PAGE: manage own licenses +INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES +('bx_ads_licenses', '_bx_ads_page_title_sys_licenses', '_bx_ads_page_title_licenses', 'bx_ads', 5, 2147483647, 1, 'ads-licenses', '', '', '', '', 0, 1, 0, 'BxAdsPageLicenses', 'modules/boonex/ads/classes/BxAdsPageLicenses.php'); + +INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES +('bx_ads_licenses', 1, 'bx_ads', '', '_bx_ads_page_block_title_licenses_note', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:19:"block_licenses_note";}', 0, 0, 1, 0), +('bx_ads_licenses', 1, 'bx_ads', '', '_bx_ads_page_block_title_licenses', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:14:"block_licenses";}', 0, 0, 1, 1); + +-- PAGE: manage all licenses +INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES +('bx_ads_licenses_administration', '_bx_ads_page_title_sys_licenses_administration', '_bx_ads_page_title_licenses_administration', 'bx_ads', 5, 192, 1, 'ads-licenses-administration', '', '', '', '', 0, 1, 0, 'BxAdsPageLicenses', 'modules/boonex/ads/classes/BxAdsPageLicenses.php'); + +INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES +('bx_ads_licenses_administration', 1, 'bx_ads', '', '_bx_ads_page_block_title_licenses_administration', 11, 192, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:29:"block_licenses_administration";}', 0, 0, 1, 0); + +-- PAGE: view offers for entry +INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES +('bx_ads_offers', '_bx_ads_page_title_sys_offers', '_bx_ads_page_title_offers', 'bx_ads', 5, 2147483647, 1, 'view-ad-offers', '', '', '', '', 0, 1, 0, 'BxAdsPageOffers', 'modules/boonex/ads/classes/BxAdsPageOffers.php'); + +INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES +('bx_ads_offers', 1, 'bx_ads', '', '_bx_ads_page_block_title_entry_breadcrumb', 13, 2147483647, 'service', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:17:"entity_breadcrumb";s:6:"params";a:1:{i:0;s:4:"{id}";}}', 0, 0, 1, 1), +('bx_ads_offers', 1, 'bx_ads', '', '_bx_ads_page_block_title_offers', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:13:"entity_offers";s:6:"params";a:1:{i:0;s:4:"{id}";}}', 0, 0, 1, 2); + +-- PAGE: view all offers +INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES +('bx_ads_offers_all', '_bx_ads_page_title_sys_offers_all', '_bx_ads_page_title_offers_all', 'bx_ads', 5, 2147483647, 1, 'ads-offers', '', '', '', '', 0, 1, 0, '', ''); + +INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES +('bx_ads_offers_all', 1, 'bx_ads', '', '_bx_ads_page_block_title_offers_all', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:6:"offers";}', 0, 0, 1, 1); + -- 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`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES @@ -209,6 +245,9 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES ('bx_ads_view', 'bx_ads', 'interested', '_bx_ads_menu_item_title_system_interested_entry', '_bx_ads_menu_item_title_interested_entry', 'javascript:void(0)', 'javascript:{js_object}.interested(this, {content_id})', '', 'map-marker', '', 2147483646, 1, 0, 10), +('bx_ads_view', 'bx_ads', 'add-to-cart', '_bx_ads_menu_item_title_system_add_to_cart', '{add_to_cart_title}', 'javascript:void(0);', 'javascript:{add_to_cart_onclick}', '', 'cart-plus', '', 2147483647, 1, 0, 15), +('bx_ads_view', 'bx_ads', 'make-offer', '_bx_ads_menu_item_title_system_make_offer', '_bx_ads_menu_item_title_make_offer', 'javascript:void(0);', 'javascript:{js_object}.makeOffer(this, {content_id})', '', 'hand-holding-usd', '', 2147483647, 1, 0, 16), +('bx_ads_view', 'bx_ads', 'view-offers', '_bx_ads_menu_item_title_system_view_offers', '_bx_ads_menu_item_title_view_offers', 'page.php?i=view-ad-offers&id={content_id}', '', '', '', '', 2147483647, 1, 0, 17), ('bx_ads_view', 'bx_ads', 'edit-ad', '_bx_ads_menu_item_title_system_edit_entry', '_bx_ads_menu_item_title_edit_entry', 'page.php?i=edit-ad&id={content_id}', '', '', 'pencil-alt', '', 2147483647, 1, 0, 20), ('bx_ads_view', 'bx_ads', 'delete-ad', '_bx_ads_menu_item_title_system_delete_entry', '_bx_ads_menu_item_title_delete_entry', 'page.php?i=delete-ad&id={content_id}', '', '', 'remove', '', 2147483647, 1, 0, 30); @@ -221,6 +260,9 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES 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`, `order`) VALUES ('bx_ads_view_actions', 'bx_ads', 'interested', '_bx_ads_menu_item_title_system_interested_entry', '', '', '', '', '', '', '', 0, 2147483646, 1, 0, 10), +('bx_ads_view_actions', 'bx_ads', 'add-to-cart', '_bx_ads_menu_item_title_system_add_to_cart', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 15), +('bx_ads_view_actions', 'bx_ads', 'make-offer', '_bx_ads_menu_item_title_system_make_offer', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 16), +('bx_ads_view_actions', 'bx_ads', 'view-offers', '_bx_ads_menu_item_title_system_view_offers', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 17), ('bx_ads_view_actions', 'bx_ads', 'edit-ad', '_bx_ads_menu_item_title_system_edit_entry', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 20), ('bx_ads_view_actions', 'bx_ads', 'delete-ad', '_bx_ads_menu_item_title_system_delete_entry', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 30), ('bx_ads_view_actions', 'bx_ads', 'review', '_bx_ads_menu_item_title_system_review_entry', '', '', '', '', '', '', '', 0, 2147483647, 0, 0, 190), @@ -290,6 +332,22 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl ('bx_ads_snippet_meta', 'bx_ads', 'views', '_sys_menu_item_title_system_sm_views', '_sys_menu_item_title_sm_views', '', '', '', '', '', 2147483647, 0, 0, 1, 6), ('bx_ads_snippet_meta', 'bx_ads', 'comments', '_sys_menu_item_title_system_sm_comments', '_sys_menu_item_title_sm_comments', '', '', '', '', '', 2147483647, 0, 0, 1, 7); +-- MENU: licenses submenu +INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES +('bx_ads_licenses_submenu', '_bx_ads_menu_title_licenses_submenu', 'bx_ads_licenses_submenu', 'bx_ads', 6, 0, 1, '', ''); + +INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES +('bx_ads_licenses_submenu', 'bx_ads', '_bx_ads_menu_set_title_licenses_submenu', 0); + +INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `editable`, `order`) VALUES +('bx_ads_licenses_submenu', 'bx_ads', 'ads-licenses-administration', '_bx_ads_menu_item_title_system_ads_licenses_administration', '_bx_ads_menu_item_title_ads_licenses_administration', 'page.php?i=ads-licenses-administration', '', '_self', '', '', '', 192, 1, 0, 1, 1), +('bx_ads_licenses_submenu', 'bx_ads', 'ads-licenses', '_bx_ads_menu_item_title_system_ads_licenses', '_bx_ads_menu_item_title_ads_licenses', 'page.php?i=ads-licenses', '', '_self', '', '', '', 2147483646, 1, 0, 1, 2); + +-- MENU: notifications menu in account popup +SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_account_notifications' AND `active` = 1 AND `order` < 9999 ORDER BY `order` DESC LIMIT 1); +INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `visibility_custom`, `active`, `copyable`, `order`) VALUES +('sys_account_notifications', 'bx_ads', 'notifications-ads-offers', '_bx_ads_menu_item_title_system_offers_all', '_bx_ads_menu_item_title_offers_all', 'page.php?i=ads-offers&profile_id={member_id}', '', '', 'ad col-green2', 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:16:"get_offers_count";s:6:"params";a:1:{i:0;s:8:"awaiting";}}', '', 2147483646, '', 1, 0, @iNotifMenuOrder + 1); + -- MENU: profile stats SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_profile_stats' AND `active` = 1 LIMIT 1); INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES @@ -308,7 +366,12 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES -- 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`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES -('sys_account_dashboard_manage_tools', 'bx_ads', 'ads-administration', '_bx_ads_menu_item_title_system_admt_ads', '_bx_ads_menu_item_title_admt_ads', 'page.php?i=ads-administration', '', '_self', 'folder-open', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:27:"get_menu_addon_manage_tools";}', '', 192, 1, 0, @iManageMenuOrder + 1); +('sys_account_dashboard_manage_tools', 'bx_ads', 'ads-administration', '_bx_ads_menu_item_title_system_admt_ads', '_bx_ads_menu_item_title_admt_ads', 'page.php?i=ads-administration', '', '_self', 'ad col-green2', 'a:2:{s:6:"module";s:6:"bx_ads";s:6:"method";s:27:"get_menu_addon_manage_tools";}', '', 192, 1, 0, @iManageMenuOrder + 1); + +-- MENU: account dashboard +SET @iDashboardMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name`='sys_account_dashboard' LIMIT 1); +INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `editable`, `order`) VALUES +('sys_account_dashboard', 'bx_ads', 'dashboard-ads-licenses', '_bx_ads_menu_item_title_system_licenses', '_bx_ads_menu_item_title_licenses', 'page.php?i=ads-licenses', '', '', 'ad col-green2', '', '', 2147483646, 1, 0, 1, @iDashboardMenuOrder + 1); -- MENU: add menu item to profiles modules (trigger* menu sets are processed separately upon modules enable/disable) INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES @@ -425,11 +488,13 @@ INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable ('bx_ads_administration', 'added', '_bx_ads_grid_column_title_adm_added', '20%', 1, '25', '', 5), ('bx_ads_administration', 'author', '_bx_ads_grid_column_title_adm_author', '20%', 0, '25', '', 6), ('bx_ads_administration', 'actions', '', '20%', 0, '', '', 7), + ('bx_ads_common', 'checkbox', '_sys_select', '2%', 0, '', '', 1), ('bx_ads_common', 'switcher', '_bx_ads_grid_column_title_adm_active', '8%', 0, '', '', 2), ('bx_ads_common', 'title', '_bx_ads_grid_column_title_adm_title', '40%', 0, '35', '', 3), -('bx_ads_common', 'added', '_bx_ads_grid_column_title_adm_added', '30%', 1, '25', '', 4), -('bx_ads_common', 'actions', '', '20%', 0, '', '', 5); +('bx_ads_common', 'added', '_bx_ads_grid_column_title_adm_added', '15%', 0, '25', '', 4), +('bx_ads_common', 'status_admin', '_bx_ads_grid_column_title_adm_status_admin', '15%', 0, '16', '', 5), +('bx_ads_common', 'actions', '', '20%', 0, '', '', 6); INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon_only`, `confirm`, `order`) VALUES ('bx_ads_administration', 'bulk', 'delete', '_bx_ads_grid_action_title_adm_delete', '', 0, 1, 1), @@ -437,11 +502,59 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon ('bx_ads_administration', 'single', 'delete', '_bx_ads_grid_action_title_adm_delete', 'remove', 1, 1, 2), ('bx_ads_administration', 'single', 'settings', '_bx_ads_grid_action_title_adm_more_actions', 'cog', 1, 0, 3), ('bx_ads_administration', 'single', 'audit_content', '_bx_ads_grid_action_title_adm_audit_content', 'search', 1, 0, 4), + ('bx_ads_common', 'bulk', 'delete', '_bx_ads_grid_action_title_adm_delete', '', 0, 1, 1), ('bx_ads_common', 'single', 'edit', '_bx_ads_grid_action_title_adm_edit', 'pencil-alt', 1, 0, 1), ('bx_ads_common', 'single', 'delete', '_bx_ads_grid_action_title_adm_delete', 'remove', 1, 1, 2), ('bx_ads_common', 'single', 'settings', '_bx_ads_grid_action_title_adm_more_actions', 'cog', 1, 0, 3); +-- GRIDS: licenses +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_ads_licenses_administration', 'Sql', 'SELECT `tl`.`id` AS `id`, `tl`.`profile_id` AS `profile_id`, `tl`.`entry_id` AS `entry_id`, `te`.`title` AS `entry`, `tl`.`count` AS `count`, `tl`.`order` AS `transaction`, `tl`.`license` AS `license`, `tl`.`added` AS `added` FROM `bx_ads_licenses` AS `tl` LEFT JOIN `bx_ads_entries` AS `te` ON `tl`.`entry_id`=`te`.`id` WHERE 1 ', 'bx_ads_licenses', 'id', 'added', '', '', 20, NULL, 'start', '', 'te`.`title,tl`.`order,tl`.`license', '', 'like', '', '', 192, 'BxAdsGridLicensesAdministration', 'modules/boonex/ads/classes/BxAdsGridLicensesAdministration.php'), +('bx_ads_licenses', 'Sql', 'SELECT `tl`.`id` AS `id`, `tl`.`profile_id` AS `profile_id`, `tl`.`entry_id` AS `entry_id`, `te`.`title` AS `entry`, `tl`.`count` AS `count`, `tl`.`order` AS `transaction`, `tl`.`license` AS `license`, `tl`.`added` AS `added` FROM `bx_ads_licenses` AS `tl` LEFT JOIN `bx_ads_entries` AS `te` ON `tl`.`entry_id`=`te`.`id` WHERE 1 ', 'bx_ads_licenses', 'id', 'added', '', '', 20, NULL, 'start', '', 'te`.`title,tl`.`order,tl`.`license', '', 'like', '', '', 2147483647, 'BxAdsGridLicenses', 'modules/boonex/ads/classes/BxAdsGridLicenses.php'); + +INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES +('bx_ads_licenses_administration', 'profile_id', '_bx_ads_grid_column_title_lcs_profile_id', '20%', 0, '0', '', 1), +('bx_ads_licenses_administration', 'entry', '_bx_ads_grid_column_title_lcs_entry', '20%', 0, '0', '', 2), +('bx_ads_licenses_administration', 'count', '_bx_ads_grid_column_title_lcs_count', '5%', 0, '0', '', 3), +('bx_ads_licenses_administration', 'transaction', '_bx_ads_grid_column_title_lcs_transaction', '20%', 0, '32', '', 4), +('bx_ads_licenses_administration', 'license', '_bx_ads_grid_column_title_lcs_license', '15%', 0, '8', '', 5), +('bx_ads_licenses_administration', 'added', '_bx_ads_grid_column_title_lcs_added', '10%', 1, '25', '', 6), +('bx_ads_licenses_administration', 'actions', '', '10%', 0, '0', '', 7), + +('bx_ads_licenses', 'entry', '_bx_ads_grid_column_title_lcs_entry', '25%', 0, '0', '', 1), +('bx_ads_licenses', 'count', '_bx_ads_grid_column_title_lcs_count', '5%', 0, '0', '', 2), +('bx_ads_licenses', 'transaction', '_bx_ads_grid_column_title_lcs_transaction', '25%', 0, '32', '', 3), +('bx_ads_licenses', 'license', '_bx_ads_grid_column_title_lcs_license', '15%', 0, '8', '', 4), +('bx_ads_licenses', 'added', '_bx_ads_grid_column_title_lcs_added', '20%', 1, '25', '', 5), +('bx_ads_licenses', 'actions', '', '10%', 0, '0', '', 6); + +-- GRIDS: offers +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`, `show_total_count`, `override_class_name`, `override_class_file`) VALUES +('bx_ads_offers', 'Sql', 'SELECT * FROM `bx_ads_offers` WHERE 1 ', 'bx_ads_offers', 'id', 'added', '', '', 20, NULL, 'start', '', 'message', '', 'like', '', '', 2147483647, 1, 'BxAdsGridOffers', 'modules/boonex/ads/classes/BxAdsGridOffers.php'), +('bx_ads_offers_all', 'Sql', 'SELECT `to`.*, SUM(IF(`to`.`status`=''awaiting'', 1, 0)) AS `offers_awating`, COUNT(`to`.`id`) AS `offers_total`, `te`.`title` AS `content_title` FROM `bx_ads_offers` AS `to` LEFT JOIN `bx_ads_entries` AS `te` ON `to`.`content_id`=`te`.`id` WHERE 1 ', 'bx_ads_offers', 'id', 'added', '', '', 20, NULL, 'start', '', '', '', 'like', '', '', 2147483647, 0, 'BxAdsGridOffersAll', 'modules/boonex/ads/classes/BxAdsGridOffersAll.php'); + +INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES +('bx_ads_offers', 'checkbox', '_sys_select', '2%', 0, 0, '', 1), +('bx_ads_offers', 'author_id', '_bx_ads_grid_column_title_ofr_author_id', '20%', 0, 0, '', 2), +('bx_ads_offers', 'amount', '_bx_ads_grid_column_title_ofr_amount', '14%', 0, 0, '', 3), +('bx_ads_offers', 'quantity', '_bx_ads_grid_column_title_ofr_quantity', '5%', 0, 0, '', 4), +('bx_ads_offers', 'message', '_bx_ads_grid_column_title_ofr_message', '24%', 0, '32', '', 5), +('bx_ads_offers', 'added', '_bx_ads_grid_column_title_ofr_added', '10%', 0, 0, '', 6), +('bx_ads_offers', 'status', '_bx_ads_grid_column_title_ofr_status', '5%', 0, 8, '', 7), +('bx_ads_offers', 'actions', '', '20%', 0, '', '', 8), + +('bx_ads_offers_all', 'content_id', '_bx_ads_grid_column_title_ofrs_content_id', '60%', 0, 0, '', 1), +('bx_ads_offers_all', 'offers_awating', '_bx_ads_grid_column_title_ofrs_offers_awating', '10%', 0, 0, '', 2), +('bx_ads_offers_all', 'offers_total', '_bx_ads_grid_column_title_ofrs_offers_total', '10%', 0, 0, '', 3), +('bx_ads_offers_all', 'actions', '', '20%', 0, '', '', 4); + +INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon_only`, `confirm`, `order`) VALUES +('bx_ads_offers', 'single', 'accept', '_bx_ads_grid_action_title_ofr_accept', 'check', 1, 1, 1), +('bx_ads_offers', 'single', 'decline', '_bx_ads_grid_action_title_ofr_decline', 'times', 1, 1, 2), + +('bx_ads_offers_all', 'single', 'view', '_bx_ads_grid_action_title_ofr_view', 'share-square', 1, 0, 1); + -- GRIDS: categories manager 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_mode`, `sorting_fields`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES ('bx_ads_categories', 'Sql', 'SELECT * FROM `bx_ads_categories` WHERE 1 ', 'bx_ads_categories', 'id', 'order', 'active', '', 20, NULL, 'start', '', 'title,text', 'auto', '', 128, 'BxAdsGridCategories', 'modules/boonex/ads/classes/BxAdsGridCategories.php'); @@ -477,6 +590,11 @@ INSERT INTO `sys_objects_uploader` (`object`, `active`, `override_class_name`, ` ('bx_ads_files_html5', 1, 'BxAdsUploaderHTML5Attach', 'modules/boonex/ads/classes/BxAdsUploaderHTML5Attach.php'); +-- LIVE UPDATES +INSERT INTO `sys_objects_live_updates`(`name`, `frequency`, `service_call`, `active`) VALUES +('bx_ads', 1, 'a:3:{s:6:"module";s:6:"bx_ads";s:6:"method";s:16:"get_live_updates";s:6:"params";a:4:{i:0;s:8:"awaiting";i:1;a:2:{s:11:"menu_object";s:18:"sys_toolbar_member";s:9:"menu_item";s:7:"account";}i:2;a:2:{s:11:"menu_object";s:25:"sys_account_notifications";s:9:"menu_item";s:24:"notifications-ads-offers";}i:3;s:7:"{count}";}}', 1); + + -- ALERTS INSERT INTO `sys_alerts_handlers` (`name`, `class`, `file`, `service_call`) VALUES ('bx_ads', 'BxAdsAlertsResponse', 'modules/boonex/ads/classes/BxAdsAlertsResponse.php', ''); @@ -497,4 +615,8 @@ INSERT INTO `sys_cron_jobs` (`name`, `time`, `class`, `file`, `service_call`) VA -- EMAIL TEMPLATES INSERT INTO `sys_email_templates` (`Module`, `NameSystem`, `Name`, `Subject`, `Body`) VALUES -('bx_ads', '_bx_ads_et_txt_name_interested', 'bx_ads_interested', '_bx_ads_et_txt_subject_interested', '_bx_ads_et_txt_body_interested'); +('bx_ads', '_bx_ads_et_txt_name_interested', 'bx_ads_interested', '_bx_ads_et_txt_subject_interested', '_bx_ads_et_txt_body_interested'), +('bx_ads', '_bx_ads_et_txt_name_purchased', 'bx_ads_purchased', '_bx_ads_et_txt_subject_purchased', '_bx_ads_et_txt_body_purchased'), +('bx_ads', '_bx_ads_et_txt_name_offer_added', 'bx_ads_offer_added', '_bx_ads_et_txt_subject_offer_added', '_bx_ads_et_txt_body_offer_added'), +('bx_ads', '_bx_ads_et_txt_name_offer_accepted', 'bx_ads_offer_accepted', '_bx_ads_et_txt_subject_offer_accepted', '_bx_ads_et_txt_body_offer_accepted'), +('bx_ads', '_bx_ads_et_txt_name_offer_declined', 'bx_ads_offer_declined', '_bx_ads_et_txt_subject_offer_declined', '_bx_ads_et_txt_body_offer_declined'); diff --git a/modules/boonex/ads/install/sql/install.sql b/modules/boonex/ads/install/sql/install.sql index ee9050f14c..99169ff333 100644 --- a/modules/boonex/ads/install/sql/install.sql +++ b/modules/boonex/ads/install/sql/install.sql @@ -6,10 +6,14 @@ CREATE TABLE IF NOT EXISTS `bx_ads_entries` ( `changed` int(11) NOT NULL, `category` int(11) NOT NULL, `thumb` int(11) NOT NULL, + `name` varchar(255) NOT NULL, `title` varchar(255) NOT NULL, `price` float NOT NULL, + `auction` tinyint(4) NOT NULL DEFAULT '0', + `quantity` int(11) NOT NULL default '1', `year` int(11) NOT NULL, `text` mediumtext NOT NULL, + `notes_purchased` text NOT NULL, `labels` text NOT NULL, `location` text NOT NULL, `views` int(11) NOT NULL default '0', @@ -28,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `bx_ads_entries` ( `featured` int(11) NOT NULL default '0', `allow_view_to` varchar(16) NOT NULL DEFAULT '3', `status` enum('active','awaiting','hidden') NOT NULL DEFAULT 'active', - `status_admin` enum('active','hidden') NOT NULL DEFAULT 'active', + `status_admin` enum('active','hidden','pending') NOT NULL DEFAULT 'active', PRIMARY KEY (`id`), FULLTEXT KEY `title_text` (`title`,`text`) ); @@ -154,6 +158,37 @@ CREATE TABLE IF NOT EXISTS `bx_ads_interested_track` ( KEY `interested` (`entry_id`, `profile_id`) ); +-- TABLE: licenses +CREATE TABLE IF NOT EXISTS `bx_ads_licenses` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `profile_id` int(11) unsigned NOT NULL default '0', + `entry_id` int(11) unsigned NOT NULL default '0', + `count` int(11) unsigned NOT NULL default '0', + `order` varchar(32) NOT NULL default '', + `license` varchar(32) NOT NULL default '', + `added` int(11) unsigned NOT NULL default '0', + `new` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`id`), + KEY `product_id` (`entry_id`, `profile_id`), + KEY `license` (`license`) +); + +CREATE TABLE IF NOT EXISTS `bx_ads_licenses_deleted` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `profile_id` int(11) unsigned NOT NULL default '0', + `entry_id` int(11) unsigned NOT NULL default '0', + `count` int(11) unsigned NOT NULL default '0', + `order` varchar(32) NOT NULL default '', + `license` varchar(32) NOT NULL default '', + `added` int(11) unsigned NOT NULL default '0', + `new` tinyint(1) NOT NULL default '1', + `reason` varchar(16) NOT NULL default '', + `deleted` int(11) unsigned NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `product_id` (`entry_id`,`profile_id`), + KEY `license` (`license`) +); + -- TABLE: storages & transcoders CREATE TABLE IF NOT EXISTS `bx_ads_covers` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -453,6 +488,21 @@ CREATE TABLE IF NOT EXISTS `bx_ads_polls_answers_votes_track` ( KEY `vote` (`object_id`, `author_nip`) ); +-- TABLE: offers +CREATE TABLE IF NOT EXISTS `bx_ads_offers` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `content_id` int(11) NOT NULL default '0', + `author_id` int(11) NOT NULL default '0', + `added` int(11) NOT NULL default '0', + `changed` int(11) NOT NULL default '0', + `amount` float NOT NULL default '0', + `quantity` int(11) NOT NULL default '0', + `message` text NOT NULL, + `status` enum('accepted','awaiting','declined') NOT NULL DEFAULT 'awaiting', + PRIMARY KEY (`id`) +); + + -- STORAGES & TRANSCODERS SET @sStorageEngine = (SELECT `value` FROM `sys_options` WHERE `name` = 'sys_storage_default'); @@ -575,11 +625,15 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch ('bx_ads', 'bx_ads', 'polls', '', '', 0, 'custom', '_bx_ads_form_entry_input_sys_polls', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0), ('bx_ads', 'bx_ads', 'text', '', '', 0, 'textarea', '_bx_ads_form_entry_input_sys_text', '_bx_ads_form_entry_input_text', '', 1, 0, 2, '', '', '', 'Avail', '', '_bx_ads_form_entry_input_text_err', 'XssHtml', '', 1, 0), ('bx_ads', 'bx_ads', 'title', '', '', 0, 'text', '_bx_ads_form_entry_input_sys_title', '_bx_ads_form_entry_input_title', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_ads_form_entry_input_title_err', 'Xss', '', 1, 0), +('bx_ads', 'bx_ads', 'name', '1', '', 0, 'text', '_bx_ads_form_entry_input_sys_name', '_bx_ads_form_entry_input_name', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_ads_form_entry_input_name_err', 'Xss', '', 1, 0), ('bx_ads', 'bx_ads', 'price', '', '', 0, 'text', '_bx_ads_form_entry_input_sys_price', '_bx_ads_form_entry_input_price', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0), +('bx_ads', 'bx_ads', 'auction', 1, '', 0, 'checkbox', '_bx_ads_form_entry_input_sys_auction', '_bx_ads_form_entry_input_auction', '_bx_ads_form_entry_input_auction_info', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0), +('bx_ads', 'bx_ads', 'quantity', '', '', 0, 'text', '_bx_ads_form_entry_input_sys_quantity', '_bx_ads_form_entry_input_quantity', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_ads_form_entry_input_quantity_err', 'Xss', '', 1, 0), ('bx_ads', 'bx_ads', 'year', '', '', 0, 'text', '_bx_ads_form_entry_input_sys_year', '_bx_ads_form_entry_input_year', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0), ('bx_ads', 'bx_ads', 'category', '', '', 0, 'hidden', '_bx_ads_form_entry_input_sys_category', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 0, 0), ('bx_ads', 'bx_ads', 'category_view', '', '', 0, 'text', '_bx_ads_form_entry_input_sys_category_view', '_bx_ads_form_entry_input_category_view', '', 0, 0, 0, 'a:1:{s:8:"disabled";s:8:"disabled";}', '', '', '', '', '', '', '', 1, 0), -('bx_ads', 'bx_ads', 'category_select', '', '', 0, 'select', '_bx_ads_form_entry_input_sys_category_select', '_bx_ads_form_entry_input_category_select', '', 1, 0, 0, 'a:1:{s:8:"onchange";s:35:"oBxAdsEntry.onChangeCategory(this);";}', '', '', '', '', '', '', '', 0, 0), +('bx_ads', 'bx_ads', 'category_select', '', '', 0, 'select', '_bx_ads_form_entry_input_sys_category_select', '_bx_ads_form_entry_input_category_select', '', 1, 0, 0, 'a:1:{s:8:"onchange";s:34:"oBxAdsForm.onChangeCategory(this);";}', '', '', '', '', '', '', '', 0, 0), +('bx_ads', 'bx_ads', 'notes_purchased', '', '', 0, 'textarea', '_bx_ads_form_entry_input_sys_notes_purchased', '_bx_ads_form_entry_input_notes_purchased', '_bx_ads_form_entry_input_notes_purchased_inf', 0, 0, 3, '', '', '', '', '', '', 'XssHtml', '', 1, 0), ('bx_ads', 'bx_ads', 'added', '', '', 0, 'datetime', '_bx_ads_form_entry_input_sys_date_added', '_bx_ads_form_entry_input_date_added', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0), ('bx_ads', 'bx_ads', 'changed', '', '', 0, 'datetime', '_bx_ads_form_entry_input_sys_date_changed', '_bx_ads_form_entry_input_date_changed', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0), ('bx_ads', 'bx_ads', 'attachments', '', '', 0, 'custom', '_bx_ads_form_entry_input_sys_attachments', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0), @@ -594,31 +648,39 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for ('bx_ads_entry_price_add', 'category', 2147483647, 1, 1), ('bx_ads_entry_price_add', 'category_view', 2147483647, 1, 2), ('bx_ads_entry_price_add', 'title', 2147483647, 1, 3), -('bx_ads_entry_price_add', 'price', 2147483647, 1, 4), -('bx_ads_entry_price_add', 'text', 2147483647, 1, 5), -('bx_ads_entry_price_add', 'attachments', 2147483647, 1, 6), -('bx_ads_entry_price_add', 'pictures', 2147483647, 1, 7), -('bx_ads_entry_price_add', 'videos', 2147483647, 1, 8), -('bx_ads_entry_price_add', 'files', 2147483647, 1, 9), -('bx_ads_entry_price_add', 'polls', 2147483647, 1, 10), -('bx_ads_entry_price_add', 'covers', 2147483647, 1, 11), -('bx_ads_entry_price_add', 'allow_view_to', 2147483647, 1, 12), -('bx_ads_entry_price_add', 'location', 2147483647, 1, 13), -('bx_ads_entry_price_add', 'do_submit', 2147483647, 1, 14), +('bx_ads_entry_price_add', 'name', 2147483647, 1, 4), +('bx_ads_entry_price_add', 'price', 2147483647, 1, 5), +('bx_ads_entry_price_add', 'auction', 2147483647, 1, 6), +('bx_ads_entry_price_add', 'quantity', 2147483647, 1, 7), +('bx_ads_entry_price_add', 'text', 2147483647, 1, 8), +('bx_ads_entry_price_add', 'attachments', 2147483647, 1, 9), +('bx_ads_entry_price_add', 'pictures', 2147483647, 1, 10), +('bx_ads_entry_price_add', 'videos', 2147483647, 1, 11), +('bx_ads_entry_price_add', 'files', 2147483647, 1, 12), +('bx_ads_entry_price_add', 'polls', 2147483647, 1, 13), +('bx_ads_entry_price_add', 'covers', 2147483647, 1, 14), +('bx_ads_entry_price_add', 'allow_view_to', 2147483647, 1, 15), +('bx_ads_entry_price_add', 'notes_purchased', 2147483647, 1, 16), +('bx_ads_entry_price_add', 'location', 2147483647, 1, 17), +('bx_ads_entry_price_add', 'do_submit', 2147483647, 1, 18), ('bx_ads_entry_price_edit', 'category_view', 2147483647, 1, 1), ('bx_ads_entry_price_edit', 'title', 2147483647, 1, 2), -('bx_ads_entry_price_edit', 'price', 2147483647, 1, 3), -('bx_ads_entry_price_edit', 'text', 2147483647, 1, 4), -('bx_ads_entry_price_edit', 'attachments', 2147483647, 1, 5), -('bx_ads_entry_price_edit', 'pictures', 2147483647, 1, 6), -('bx_ads_entry_price_edit', 'videos', 2147483647, 1, 7), -('bx_ads_entry_price_edit', 'files', 2147483647, 1, 8), -('bx_ads_entry_price_edit', 'polls', 2147483647, 1, 9), -('bx_ads_entry_price_edit', 'covers', 2147483647, 1, 10), -('bx_ads_entry_price_edit', 'allow_view_to', 2147483647, 1, 11), -('bx_ads_entry_price_edit', 'location', 2147483647, 1, 12), -('bx_ads_entry_price_edit', 'do_submit', 2147483647, 1, 13), +('bx_ads_entry_price_edit', 'name', 2147483647, 1, 3), +('bx_ads_entry_price_edit', 'price', 2147483647, 1, 4), +('bx_ads_entry_price_edit', 'auction', 2147483647, 1, 5), +('bx_ads_entry_price_edit', 'quantity', 2147483647, 1, 6), +('bx_ads_entry_price_edit', 'text', 2147483647, 1, 7), +('bx_ads_entry_price_edit', 'attachments', 2147483647, 1, 8), +('bx_ads_entry_price_edit', 'pictures', 2147483647, 1, 9), +('bx_ads_entry_price_edit', 'videos', 2147483647, 1, 10), +('bx_ads_entry_price_edit', 'files', 2147483647, 1, 11), +('bx_ads_entry_price_edit', 'polls', 2147483647, 1, 12), +('bx_ads_entry_price_edit', 'covers', 2147483647, 1, 13), +('bx_ads_entry_price_edit', 'allow_view_to', 2147483647, 1, 14), +('bx_ads_entry_price_edit', 'notes_purchased', 2147483647, 1, 15), +('bx_ads_entry_price_edit', 'location', 2147483647, 1, 16), +('bx_ads_entry_price_edit', 'do_submit', 2147483647, 1, 17), ('bx_ads_entry_price_view', 'category_view', 2147483647, 1, 1), ('bx_ads_entry_price_view', 'price', 2147483647, 1, 2), @@ -628,39 +690,48 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for ('bx_ads_entry_price_year_add', 'category', 2147483647, 1, 1), ('bx_ads_entry_price_year_add', 'category_view', 2147483647, 1, 2), ('bx_ads_entry_price_year_add', 'title', 2147483647, 1, 3), -('bx_ads_entry_price_year_add', 'price', 2147483647, 1, 4), -('bx_ads_entry_price_year_add', 'year', 2147483647, 1, 5), -('bx_ads_entry_price_year_add', 'text', 2147483647, 1, 6), -('bx_ads_entry_price_year_add', 'attachments', 2147483647, 1, 7), -('bx_ads_entry_price_year_add', 'pictures', 2147483647, 1, 8), -('bx_ads_entry_price_year_add', 'videos', 2147483647, 1, 9), -('bx_ads_entry_price_year_add', 'files', 2147483647, 1, 10), -('bx_ads_entry_price_year_add', 'polls', 2147483647, 1, 11), -('bx_ads_entry_price_year_add', 'covers', 2147483647, 1, 12), -('bx_ads_entry_price_year_add', 'allow_view_to', 2147483647, 1, 13), -('bx_ads_entry_price_year_add', 'location', 2147483647, 1, 14), -('bx_ads_entry_price_year_add', 'do_submit', 2147483647, 1, 15), +('bx_ads_entry_price_year_add', 'name', 2147483647, 1, 4), +('bx_ads_entry_price_year_add', 'price', 2147483647, 1, 5), +('bx_ads_entry_price_year_add', 'auction', 2147483647, 1, 6), +('bx_ads_entry_price_year_add', 'quantity', 2147483647, 1, 7), +('bx_ads_entry_price_year_add', 'year', 2147483647, 1, 8), +('bx_ads_entry_price_year_add', 'text', 2147483647, 1, 9), +('bx_ads_entry_price_year_add', 'attachments', 2147483647, 1, 10), +('bx_ads_entry_price_year_add', 'pictures', 2147483647, 1, 11), +('bx_ads_entry_price_year_add', 'videos', 2147483647, 1, 12), +('bx_ads_entry_price_year_add', 'files', 2147483647, 1, 13), +('bx_ads_entry_price_year_add', 'polls', 2147483647, 1, 14), +('bx_ads_entry_price_year_add', 'covers', 2147483647, 1, 15), +('bx_ads_entry_price_year_add', 'allow_view_to', 2147483647, 1, 16), +('bx_ads_entry_price_year_add', 'notes_purchased', 2147483647, 1, 17), +('bx_ads_entry_price_year_add', 'location', 2147483647, 1, 18), +('bx_ads_entry_price_year_add', 'do_submit', 2147483647, 1, 19), ('bx_ads_entry_price_year_edit', 'category_view', 2147483647, 1, 1), ('bx_ads_entry_price_year_edit', 'title', 2147483647, 1, 2), -('bx_ads_entry_price_year_edit', 'price', 2147483647, 1, 3), -('bx_ads_entry_price_year_edit', 'year', 2147483647, 1, 4), -('bx_ads_entry_price_year_edit', 'text', 2147483647, 1, 5), -('bx_ads_entry_price_year_edit', 'attachments', 2147483647, 1, 6), -('bx_ads_entry_price_year_edit', 'pictures', 2147483647, 1, 7), -('bx_ads_entry_price_year_edit', 'videos', 2147483647, 1, 8), -('bx_ads_entry_price_year_edit', 'files', 2147483647, 1, 9), -('bx_ads_entry_price_year_edit', 'polls', 2147483647, 1, 10), -('bx_ads_entry_price_year_edit', 'covers', 2147483647, 1, 11), -('bx_ads_entry_price_year_edit', 'allow_view_to', 2147483647, 1, 12), -('bx_ads_entry_price_year_edit', 'location', 2147483647, 1, 13), -('bx_ads_entry_price_year_edit', 'do_submit', 2147483647, 1, 14), +('bx_ads_entry_price_year_edit', 'name', 2147483647, 1, 3), +('bx_ads_entry_price_year_edit', 'price', 2147483647, 1, 4), +('bx_ads_entry_price_year_edit', 'auction', 2147483647, 1, 5), +('bx_ads_entry_price_year_edit', 'quantity', 2147483647, 1, 6), +('bx_ads_entry_price_year_edit', 'year', 2147483647, 1, 7), +('bx_ads_entry_price_year_edit', 'text', 2147483647, 1, 8), +('bx_ads_entry_price_year_edit', 'attachments', 2147483647, 1, 9), +('bx_ads_entry_price_year_edit', 'pictures', 2147483647, 1, 10), +('bx_ads_entry_price_year_edit', 'videos', 2147483647, 1, 11), +('bx_ads_entry_price_year_edit', 'files', 2147483647, 1, 12), +('bx_ads_entry_price_year_edit', 'polls', 2147483647, 1, 13), +('bx_ads_entry_price_year_edit', 'covers', 2147483647, 1, 14), +('bx_ads_entry_price_year_edit', 'allow_view_to', 2147483647, 1, 15), +('bx_ads_entry_price_year_edit', 'notes_purchased', 2147483647, 1, 16), +('bx_ads_entry_price_year_edit', 'location', 2147483647, 1, 17), +('bx_ads_entry_price_year_edit', 'do_submit', 2147483647, 1, 18), ('bx_ads_entry_price_year_view', 'category_view', 2147483647, 1, 1), ('bx_ads_entry_price_year_view', 'price', 2147483647, 1, 2), -('bx_ads_entry_price_year_view', 'year', 2147483647, 1, 3), -('bx_ads_entry_price_year_view', 'added', 2147483647, 1, 4), -('bx_ads_entry_price_year_view', 'changed', 2147483647, 1, 5); +('bx_ads_entry_price_year_view', 'quantity', 2147483647, 1, 3), +('bx_ads_entry_price_year_view', 'year', 2147483647, 1, 4), +('bx_ads_entry_price_year_view', 'added', 2147483647, 1, 5), +('bx_ads_entry_price_year_view', 'changed', 2147483647, 1, 6); -- FORMS: poll 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 @@ -683,6 +754,29 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo ('bx_ads_poll_add', 'do_submit', 2147483647, 1, 4), ('bx_ads_poll_add', 'do_cancel', 2147483647, 1, 5); +-- FORMS: offer +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 +('bx_ads_offer', 'bx_ads', '_bx_ads_form_offer', '', '', 'do_submit', 'bx_ads_offers', 'id', '', '', '', 0, 1, 'BxAdsFormOffer', 'modules/boonex/ads/classes/BxAdsFormOffer.php'); + +INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `view_mode`) VALUES +('bx_ads_offer_add', 'bx_ads', 'bx_ads_offer', '_bx_ads_form_offer_display_add', 0); + +INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES +('bx_ads_offer', 'bx_ads', 'amount', '', '', 0, 'text', '_bx_ads_form_offer_input_sys_amount', '_bx_ads_form_offer_input_amount', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_ads_form_offer_input_amount_err', 'Xss', '', 1, 0), +('bx_ads_offer', 'bx_ads', 'quantity', '1', '', 0, 'text', '_bx_ads_form_offer_input_sys_quantity', '_bx_ads_form_offer_input_quantity', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_ads_form_offer_input_quantity_err', 'Xss', '', 1, 0), +('bx_ads_offer', 'bx_ads', 'message', '', '', 0, 'textarea', '_bx_ads_form_offer_input_sys_message', '_bx_ads_form_offer_input_message', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0), +('bx_ads_offer', 'bx_ads', 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0), +('bx_ads_offer', 'bx_ads', 'do_submit', '_bx_ads_form_offer_input_do_submit', '', 0, 'submit', '_bx_ads_form_offer_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0), +('bx_ads_offer', 'bx_ads', 'do_cancel', '_bx_ads_form_offer_input_do_cancel', '', 0, 'button', '_bx_ads_form_offer_input_do_cancel', '', '', 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";}', '', '', '', '', '', '', '', 0, 0); + +INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES +('bx_ads_offer_add', 'amount', 2147483647, 1, 1), +('bx_ads_offer_add', 'quantity', 2147483647, 1, 2), +('bx_ads_offer_add', 'message', 2147483647, 1, 3), +('bx_ads_offer_add', 'controls', 2147483647, 1, 4), +('bx_ads_offer_add', 'do_submit', 2147483647, 1, 5), +('bx_ads_offer_add', 'do_cancel', 2147483647, 1, 6); + -- COMMENTS INSERT INTO `sys_objects_cmts` (`Name`, `Module`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Html`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES diff --git a/modules/boonex/ads/install/sql/uninstall.sql b/modules/boonex/ads/install/sql/uninstall.sql index 752500298b..3dcfb1ee0c 100644 --- a/modules/boonex/ads/install/sql/uninstall.sql +++ b/modules/boonex/ads/install/sql/uninstall.sql @@ -1,6 +1,6 @@ -- TABLES -DROP TABLE IF EXISTS `bx_ads_entries`, `bx_ads_categories_types`, `bx_ads_categories`, `bx_ads_interested_track`, `bx_ads_covers`, `bx_ads_files`, `bx_ads_photos`, `bx_ads_photos_resized`, `bx_ads_videos`, `bx_ads_videos_resized`, `bx_ads_cmts`, `bx_ads_reviews`, `bx_ads_votes`, `bx_ads_votes_track`, `bx_ads_reactions`, `bx_ads_reactions_track`, `bx_ads_views_track`, `bx_ads_meta_keywords`, `bx_ads_meta_locations`, `bx_ads_meta_mentions`, `bx_ads_reports`, `bx_ads_reports_track`, `bx_ads_favorites_track`, `bx_ads_scores`, `bx_ads_scores_track`, `bx_ads_polls`, `bx_ads_polls_answers`, `bx_ads_polls_answers_votes`, `bx_ads_polls_answers_votes_track`; +DROP TABLE IF EXISTS `bx_ads_entries`, `bx_ads_categories_types`, `bx_ads_categories`, `bx_ads_interested_track`, `bx_ads_licenses`, `bx_ads_licenses_deleted`, `bx_ads_covers`, `bx_ads_files`, `bx_ads_photos`, `bx_ads_photos_resized`, `bx_ads_videos`, `bx_ads_videos_resized`, `bx_ads_cmts`, `bx_ads_reviews`, `bx_ads_votes`, `bx_ads_votes_track`, `bx_ads_reactions`, `bx_ads_reactions_track`, `bx_ads_views_track`, `bx_ads_meta_keywords`, `bx_ads_meta_locations`, `bx_ads_meta_mentions`, `bx_ads_reports`, `bx_ads_reports_track`, `bx_ads_favorites_track`, `bx_ads_scores`, `bx_ads_scores_track`, `bx_ads_polls`, `bx_ads_polls_answers`, `bx_ads_polls_answers_votes`, `bx_ads_polls_answers_votes_track`, `bx_ads_offers`; -- STORAGES & TRANSCODERS DELETE FROM `sys_objects_storage` WHERE `object` LIKE 'bx_ads_%'; diff --git a/modules/boonex/ads/js/entry.js b/modules/boonex/ads/js/entry.js index ec7452a8d5..024c11a902 100644 --- a/modules/boonex/ads/js/entry.js +++ b/modules/boonex/ads/js/entry.js @@ -15,6 +15,7 @@ function BxAdsEntry(oOptions) { this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect; this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed; this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds; + this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams; } BxAdsEntry.prototype.interested = function(oElement, iContentId) { @@ -38,34 +39,31 @@ BxAdsEntry.prototype.interested = function(oElement, iContentId) { ); }; -BxAdsEntry.prototype.onChangeCategory = function(oElement) { +BxAdsEntry.prototype.makeOffer = function(oElement, iContentId) { var $this = this; var oParams = this._getDefaultData(); - oParams['category'] = $(oElement).val(); + oParams['id'] = iContentId; - this.loadingInBlock(oElement, true); + if(oElement) + this.loadingInButton(oElement, true); jQuery.get ( - this._sActionsUrl + 'get_category_form', + this._sActionsUrl + 'make_offer', oParams, function(oData) { if(oElement) - $this.loadingInBlock(oElement, false); - - if(!oData || !oData.content && oData.content.length == 0) - return; - - var oContent = $(oData.content); - var sFormId = oContent.filter('form').attr('id'); - if(!sFormId) - return; + $this.loadingInButton(oElement, false); - $('form#' + sFormId).replaceWith(oContent); + processJsonData(oData); }, 'json' ); }; +BxAdsEntry.prototype.onMakeOffer = function(oData) { + +}; + BxAdsEntry.prototype.loadingInButton = function(e, bShow) { if($(e).length) bx_loading_btn($(e), bShow); @@ -78,11 +76,6 @@ BxAdsEntry.prototype.loadingInBox = function(e, bShow) { bx_loading(oParent, bShow); }; -BxAdsEntry.prototype.loadingInBlock = function(e, bShow) { - var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body'); - bx_loading(oParent, bShow); -}; - BxAdsEntry.prototype._getDefaultData = function() { var oDate = new Date(); return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()}); diff --git a/modules/boonex/ads/js/form.js b/modules/boonex/ads/js/form.js new file mode 100644 index 0000000000..c778251fcd --- /dev/null +++ b/modules/boonex/ads/js/form.js @@ -0,0 +1,102 @@ +/** + * Copyright (c) UNA, Inc - https://una.io + * MIT License - https://opensource.org/licenses/MIT + * + * @defgroup Ads Ads + * @ingroup UnaModules + * + * @{ + */ + +function BxAdsForm(oOptions) { + this._sActionsUri = oOptions.sActionUri; + this._sActionsUrl = oOptions.sActionUrl; + this._sObjName = oOptions.sObjName == undefined ? 'oBxAdsForm' : oOptions.sObjName; + this._iOwnerId = oOptions.iOwnerId == undefined ? 0 : oOptions.iOwnerId; + this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect; + this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed; + this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds; + this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams; +} + +BxAdsForm.prototype.onChangeCategory = function(oElement) { + var $this = this; + var oParams = this._getDefaultData(); + oParams['category'] = $(oElement).val(); + + this.loadingInBlock(oElement, true); + + jQuery.get ( + this._sActionsUrl + 'get_category_form', + oParams, + function(oData) { + if(oElement) + $this.loadingInBlock(oElement, false); + + if(!oData || !oData.content && oData.content.length == 0) + return; + + var oContent = $(oData.content); + var sFormId = oContent.filter('form').attr('id'); + if(!sFormId) + return; + + $('form#' + sFormId).replaceWith(oContent); + }, + 'json' + ); +}; + +BxAdsForm.prototype.checkName = function(sTitleId, sNameId, iId) { + var oDate = new Date(); + + var oName = jQuery("[name='" + sNameId + "']"); + var sName = oName.val(); + var bName = sName.length != 0; + + var oTitle = jQuery("[name='" + sTitleId + "']"); + var sTitle = oTitle.val(); + var bTitle = sTitle.length != 0; + + if(!bName && !bTitle) + return; + + var sTitleCheck = ''; + if(bName) + sTitleCheck = sName; + else if(bTitle) { + sTitleCheck = sTitle; + + sTitle = sTitle.replace(/[^A-Za-z0-9_]/g, '-'); + sTitle = sTitle.replace(/[-]{2,}/g, '-'); + oName.val(sTitle); + } + + jQuery.get( + this._sActionsUrl + 'check_name', + { + title: sTitleCheck, + id: iId && parseInt(iId) > 0 ? iId : 0, + _t: oDate.getTime() + }, + function(oData) { + if(!oData || oData.name == undefined) + return; + + oName.val(oData.name); + }, + 'json' + ); +}; + +BxAdsForm.prototype.loadingInBlock = function(e, bShow) { + var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body'); + bx_loading(oParent, bShow); +}; + +BxAdsForm.prototype._getDefaultData = function() { + var oDate = new Date(); + return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()}); +}; + +/** @} */ diff --git a/modules/boonex/ads/template/css/entry.css b/modules/boonex/ads/template/css/entry.css new file mode 100644 index 0000000000..255b0ed603 --- /dev/null +++ b/modules/boonex/ads/template/css/entry.css @@ -0,0 +1,9 @@ +/*--- Offer Accepted block ---*/ +.bx-ads-entry-offer-accepted { + position: relative; +} + +.bx-ads-eoa .bx-btn { + display: inline-block; + float: none; +} diff --git a/modules/boonex/ads/template/entry-link.html b/modules/boonex/ads/template/entry-link.html new file mode 100644 index 0000000000..20e10484bd --- /dev/null +++ b/modules/boonex/ads/template/entry-link.html @@ -0,0 +1 @@ +__content__ \ No newline at end of file diff --git a/modules/boonex/ads/template/entry-offer-accepted.html b/modules/boonex/ads/template/entry-offer-accepted.html new file mode 100644 index 0000000000..deee70db50 --- /dev/null +++ b/modules/boonex/ads/template/entry-offer-accepted.html @@ -0,0 +1,14 @@ +
+
+
+
__amount__
+
__quantity__
+
+ +
+ +
+
+ __js_code__ +
+
\ No newline at end of file diff --git a/modules/boonex/ads/template/link.html b/modules/boonex/ads/template/link.html new file mode 100644 index 0000000000..3c10e4307d --- /dev/null +++ b/modules/boonex/ads/template/link.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/boonex/ads/template/offer_popup.html b/modules/boonex/ads/template/offer_popup.html new file mode 100644 index 0000000000..e3fbc5466a --- /dev/null +++ b/modules/boonex/ads/template/offer_popup.html @@ -0,0 +1,20 @@ +
+
+ __form__ + +
+
\ No newline at end of file diff --git a/modules/boonex/russian/data/langs/bx_ads/ru.xml b/modules/boonex/russian/data/langs/bx_ads/ru.xml index d3a757717a..a5b290722d 100644 --- a/modules/boonex/russian/data/langs/bx_ads/ru.xml +++ b/modules/boonex/russian/data/langs/bx_ads/ru.xml @@ -4,6 +4,7 @@ + @@ -12,6 +13,7 @@ + @@ -67,6 +69,9 @@ + + + @@ -119,6 +124,21 @@ + + + + + + + + + + + + + + + @@ -210,6 +230,7 @@ + @@ -224,6 +245,12 @@ + + + + + + @@ -254,6 +281,10 @@ + + + + @@ -304,6 +335,8 @@ + + @@ -321,6 +354,7 @@ + @@ -329,6 +363,7 @@ + @@ -338,7 +373,21 @@ - + + + + + + + + + + + + + + + @@ -409,6 +458,27 @@

Здравствуйте, {client_name}.

Вы оплатили {entry_name} объявление ({count} шт.), размещенное {vendor_name}.
Ваша лицензия - {license}.

{notes}

+{email_footer}]]> + + + + Здравствуйте, {profile_name}.

+

{viewer_name} сделал предложение по вашему объявлению {ad_name}.

+{email_footer}]]>
+ + + + Здравствуйте, {offerer_name}.

+

Ваше предложение по {ad_name} объявлению было принято.

+{email_footer}]]>
+ + + + Здравствуйте, {offerer_name}.

+

Ваше предложение по {ad_name} объявлению было отклонено.

{email_footer}]]>
Все объявления в {1} ({2})]]> @@ -428,8 +498,20 @@ {1}, если у вас есть какие-либо вопросы или нужна помощь.]]> + + + + + + + + + + + +