11 $a = $aModuleOverwright ? $aModuleOverwright :
$aModule;
12 if (!$a || $a[
'uri'] !=
'store') {
14 $a = $oMain->_aModule;
23 define(
'CH_STORE_PHOTOS_CAT',
'Store');
24 define(
'CH_STORE_PHOTOS_TAG',
'store');
26 define(
'CH_STORE_VIDEOS_CAT',
'Store');
27 define(
'CH_STORE_VIDEOS_TAG',
'store');
29 define(
'CH_STORE_FILES_CAT',
'Store');
30 define(
'CH_STORE_FILES_TAG',
'store');
128 $this->_sFilterName =
'ch_store_filter';
129 $this->_sPrefix =
'ch_store';
136 $GLOBALS[
'oChStoreModule'] = &$this;
141 parent::_actionHome(
_t(
'_ch_store_page_title_home'));
146 parent::_actionVideos($sUri,
_t(
'_ch_store_page_title_videos'));
151 parent::_actionPhotos($sUri,
_t(
'_ch_store_page_title_photos'));
156 parent::_actionComments($sUri,
_t(
'_ch_store_page_title_comments'));
161 parent::_actionView($sUri,
_t(
'_ch_store_msg_pending_approval'));
166 parent::_actionBroadcast($iEntryId,
_t(
'_ch_store_page_title_broadcast'),
167 _t(
'_ch_store_msg_broadcast_no_recipients'),
_t(
'_ch_store_msg_broadcast_message_sent'));
172 parent::_actionCalendar($iYear, $iMonth,
_t(
'_ch_store_page_title_calendar'));
177 parent::_actionSearch($sKeyword, $sCategory,
_t(
'_ch_store_page_title_search'));
182 parent::_actionAdd(
_t(
'_ch_store_page_title_add'));
187 $this->_oTemplate->addCss(
'form_field_product_files_choice.css');
188 parent::_actionEdit($iEntryId,
_t(
'_ch_store_page_title_edit'));
193 parent::_actionDelete($iEntryId,
_t(
'_ch_store_msg_product_was_deleted'));
198 parent::_actionMarkFeatured($iEntryId,
_t(
'_ch_store_msg_added_to_featured'),
199 _t(
'_ch_store_msg_removed_from_featured'));
204 parent::_actionSharePopup($iEntryId,
_t(
'_ch_store_cpation_share_product'));
209 parent::_actionTags(
_t(
'_ch_store_page_title_tags'));
214 parent::_actionCategories(
_t(
'_ch_store_page_title_categories'));
219 header(
'Content-type:text/html;charset=utf-8');
221 $aFileInfo = $this->_oDb->getFileInfoByFileId((
int)
$iFileId);
223 echo
_t(
'_sys_request_page_not_found_cpt');
227 if (!$this->_iProfileId || $aFileInfo[
'author_id'] != $this->_iProfileId) {
228 echo
_t(
'_Access denied');
232 if (
false === ($iHidden = $this->_oDb->toggleProductFileVisibility($aFileInfo[
'id']))) {
233 echo
_t(
'_Error Occured');
237 echo $iHidden ?
_t(
'_ch_store_product_file_hidden') :
_t(
'_ch_store_product_file_visible');
243 $aFileInfo = $this->_oDb->getFileInfoByFileId((
int)
$iFileId);
246 $this->_oTemplate->displayPageNotFound();
251 $this->_oTemplate->displayAccessDenied();
255 parent::_actionDownload($aFileInfo,
'media_id');
262 if (!$this->_oDb->isAnyPublicContent()) {
268 $o->sUrlStart = CH_WSB_URL_ROOT .
'?';
270 $sDefaultHomepageTab = $this->_oDb->getParam(
'ch_store_homepage_default_tab');
272 $sBrowseMode = $sDefaultHomepageTab;
273 switch (
$_GET[
'ch_store_filter']) {
279 case $sDefaultHomepageTab:
280 $sBrowseMode =
$_GET[
'ch_store_filter'];
284 return $o->ajaxBrowse(
286 $this->_oDb->getParam(
'ch_store_perpage_homepage'),
288 _t(
'_ch_store_tab_featured') => array(
289 'href' => CH_WSB_URL_ROOT .
'?ch_store_filter=featured',
290 'active' =>
'featured' == $sBrowseMode,
293 _t(
'_ch_store_tab_recent') => array(
294 'href' => CH_WSB_URL_ROOT .
'?ch_store_filter=recent',
295 'active' =>
'recent' == $sBrowseMode,
298 _t(
'_ch_store_tab_top') => array(
299 'href' => CH_WSB_URL_ROOT .
'?ch_store_filter=top',
300 'active' =>
'top' == $sBrowseMode,
303 _t(
'_ch_store_tab_popular') => array(
304 'href' => CH_WSB_URL_ROOT .
'?ch_store_filter=popular',
305 'active' =>
'popular' == $sBrowseMode,
308 _t(
'_ch_store_tab_free') => array(
309 'href' => CH_WSB_URL_ROOT .
'?ch_store_filter=free',
310 'active' =>
'free' == $sBrowseMode,
324 return $o->ajaxBrowse(
326 $this->_oDb->getParam(
'ch_store_perpage_profile'),
336 parent::_serviceGetMemberMenuItem(
_t(
'_ch_store'),
_t(
'_ch_store'),
'shopping-cart');
345 return parent::_serviceGetMemberMenuItem(
_t(
'_ch_store_products_single'),
_t(
'_ch_store_products_single'),
346 'shopping-cart',
false,
'&ch_store_filter=add_product');
352 'icon' =>
'shopping-cart',
353 'txt_object' =>
'_ch_store_wall_object',
354 'txt_added_new_single' =>
'_ch_store_wall_added_new',
355 'txt_added_new_title_single' =>
'_ch_store_wall_added_new_title',
356 'txt_added_new_plural' =>
'_ch_store_wall_added_new_items',
357 'txt_added_new_title_plural' =>
'_ch_store_wall_added_new_title_items',
358 'txt_privacy_view_event' =>
'view_product',
359 'obj_privacy' => $this->_oPrivacyProduct,
361 'owner' =>
'author_id',
366 return parent::_serviceGetWallPost($aEvent, $aParams);
372 'txt_privacy_view_event' =>
'view_product',
373 'obj_privacy' => $this->_oPrivacyProduct
376 return parent::_serviceGetWallAddComment($aEvent, $aParams);
385 'txt_privacy_view_event' =>
'view_product',
386 'obj_privacy' => $this->_oPrivacyProduct
389 return parent::_serviceGetWallPostComment($aEvent, $aParams);
395 'txt_privacy_view_event' =>
'view_product',
396 'obj_privacy' => $this->_oPrivacyProduct,
397 'templates' => array(
398 'grouped' =>
'wall_outline_grouped'
402 return parent::_serviceGetWallPostOutline($aEvent,
'shopping-cart', $aParams);
407 return parent::_serviceGetSpyPost(
$sAction, $iObjectId, $iSenderId, $aExtraParams, array(
408 'add' =>
'_ch_store_spy_post',
409 'change' =>
'_ch_store_spy_post_change',
410 'rate' =>
'_ch_store_spy_rate',
411 'commentPost' =>
'_ch_store_spy_comment',
417 $aOld = parent::serviceGetSpyData();
419 'handlers' => array(),
422 foreach ($aOld[
'handlers']
as $a) {
423 if (
'join' == $a[
'alert_action']) {
426 $aNew[
'handlers'][] = $a;
428 foreach ($aOld[
'alerts']
as $a) {
429 if (
'join' == $a[
'action']) {
432 $aNew[
'alerts'][] = $a;
441 'change' =>
_t(
'_ch_store_sbs_change'),
442 'commentPost' =>
_t(
'_ch_store_sbs_comment'),
443 'rate' =>
_t(
'_ch_store_sbs_rate'),
446 return parent::_serviceGetSubscriptionParams(
$sAction, $iEntryId, $a);
451 $iVendorId = (int)$iVendorId;
452 if ($iVendorId < 0) {
456 $aItems = $this->_oDb->getFilesByAuthor($iVendorId);
459 foreach ($aItems
as $aItem) {
460 $aFile =
ChWsbService::call(
'files',
'get_file_array', array($aItem[
'media_id']),
'Search');
461 if (!$aFile[
'date']) {
465 'id' => $aItem[
'id'],
466 'title' => $aItem[
'title'] .
' - ' . $aFile[
'title'] .
' / ' . $aItem[
'price'],
467 'description' => $aItem[
'title'] .
' - ' . $aFile[
'title'],
468 'url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aItem[
'uri'],
469 'price' => $aItem[
'price'],
483 if (!$iItemId || !$iClientId) {
487 $aItem = $this->_oDb->getFileInfoByFileId($iItemId);
488 $aFile =
ChWsbService::call(
'files',
'get_file_array', array($aItem[
'media_id']),
'Search');
489 if (!$aFile[
'date']) {
494 'id' => $aItem[
'id'],
495 'title' => $aItem[
'title'] .
' - ' . $aFile[
'title'],
496 'description' => $aItem[
'title'] .
' - ' . $aFile[
'title'],
497 'url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aItem[
'uri'],
498 'price' => $aItem[
'price'],
504 $aItem = $this->_oDb->getFileInfoByFileId($iItemId);
505 $aFile =
ChWsbService::call(
'files',
'get_file_array', array($aItem[
'media_id']),
'Search');
506 if (!$aFile[
'date']) {
510 if (!$this->_oDb->registerCustomer($iClientId, $iItemId, $sOrderId, $iItemCount,
time())) {
515 'id' => $aItem[
'id'],
516 'title' => $aItem[
'title'] .
' - ' . $aFile[
'title'],
517 'description' => $aItem[
'title'] .
' - ' . $aFile[
'title'],
518 'url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aItem[
'uri'],
519 'price' => $aItem[
'price'],
525 return $this->_oDb->unregisterCustomer($iClientId, $iItemId, $sOrderId);
533 $this->_oDb->removeCustomersFromAllEntries(
$iProfileId);
541 $this->_oTemplate->displayAccessDenied();
546 $this->_oTemplate->pageStart();
549 'pending_approval' => array(
550 'title' =>
_t(
'_ch_store_menu_admin_pending_approval'),
551 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/pending_approval',
553 'name' =>
'actionAdministrationManage',
554 'params' => array(
false,
'administration/pending_approval')
557 'admin_entries' => array(
558 'title' =>
_t(
'_ch_store_menu_admin_entries'),
559 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/admin_entries',
561 'name' =>
'actionAdministrationManage',
562 'params' => array(
true,
'administration/admin_entries')
566 'title' =>
_t(
'_ch_store_menu_admin_add_entry'),
567 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/create',
568 '_func' => array(
'name' =>
'actionAdministrationCreateEntry',
'params' => array()),
571 'title' =>
_t(
'_ch_store_menu_admin_settings'),
572 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/settings',
573 '_func' => array(
'name' =>
'actionAdministrationSettings',
'params' => array()),
578 $sUrl =
'pending_approval';
585 echo $this->_oTemplate->adminBlock(
$sContent,
_t(
'_ch_store_page_title_administration'),
$aMenu);
586 $this->_oTemplate->addCssAdmin(array(
594 $this->_oTemplate->pageCodeAdmin(
_t(
'_ch_store_page_title_administration'));
599 return parent::_actionAdministrationSettings(
'Store');
604 return parent::_actionAdministrationManage($isAdminEntries,
'_ch_store_admin_delete',
605 '_ch_store_admin_activate',
$sUrl);
619 return ($this->
isAdmin() || $aDataEntry[
'author_id'] == $iIdProfile);
625 if ($this->
isAdmin() || $aDataEntry[
'author_id'] == $this->_iProfileId) {
631 $aCheck =
checkAction($this->_iProfileId, CH_STORE_VIEW_PRODUCT, $isPerformAction);
637 return $this->_oPrivacyProduct->check(
'view_product', $aDataEntry[
'id'], $this->_iProfileId);
646 $aCheck =
checkAction($this->_iProfileId, CH_STORE_BROWSE, $isPerformAction);
657 $aCheck =
checkAction($this->_iProfileId, CH_STORE_SEARCH, $isPerformAction);
667 if (!
$GLOBALS[
'logged'][
'member']) {
671 $aCheck =
checkAction($this->_iProfileId, CH_STORE_ADD_PRODUCT, $isPerformAction);
679 if ($this->
isAdmin() || (
$GLOBALS[
'logged'][
'member'] && $aDataEntry[
'author_id'] == $this->_iProfileId &&
isProfileActive($this->_iProfileId))) {
685 $aCheck =
checkAction($this->_iProfileId, CH_STORE_EDIT_ANY_PRODUCT, $isPerformAction);
696 $aCheck =
checkAction($this->_iProfileId, CH_STORE_MARK_AS_FEATURED, $isPerformAction);
703 if ($this->
isAdmin() || (
$GLOBALS[
'logged'][
'member'] && $aDataEntry[
'author_id'] == $this->_iProfileId &&
isProfileActive($this->_iProfileId))) {
707 $aCheck =
checkAction($this->_iProfileId, CH_STORE_BROADCAST_MESSAGE, $isPerformAction);
714 if ($this->
isAdmin() || (
$GLOBALS[
'logged'][
'member'] && $aDataEntry[
'author_id'] == $this->_iProfileId &&
isProfileActive($this->_iProfileId))) {
718 $aCheck =
checkAction($this->_iProfileId, CH_STORE_DELETE_ANY_PRODUCT, $isPerformAction);
725 if ($aDataEntry[
'status'] !=
'pending') {
732 $aCheck =
checkAction($this->_iProfileId, CH_STORE_APPROVE_PRODUCT, $isPerformAction);
748 if (!$this->_iProfileId || 0 == $aItem[
'price']) {
752 return $this->
isAdmin() || $this->_oPrivacyFile->check(
'purchase', $aItem[
'id'], $this->_iProfileId);
761 return $this->
isAdmin() || (
$GLOBALS[
'logged'][
'member'] && $aDataEntry[
'author_id'] == $this->_iProfileId &&
isProfileActive($this->_iProfileId)) || $this->_oPrivacyProduct->check(
'post_in_forum',
771 return $this->
isAdmin() || (
$GLOBALS[
'logged'][
'member'] && $aDataEntry[
'author_id'] == $this->_iProfileId &&
isProfileActive($this->_iProfileId)) || $this->_oPrivacyProduct->check(
'view_forum',
780 if (0 == $aItem[
'price'] && $this->_oPrivacyFile->check(
'purchase', $aItem[
'id'], $this->_iProfileId)) {
783 if ($this->_oDb->isPurchasedItem($this->_iProfileId, $aItem[
'id'])) {
805 if (!
$GLOBALS[
'logged'][
'member'] || $aEvent[
'author_id'] != $this->_iProfileId) {
809 $aCheck =
checkAction($this->_iProfileId, CH_STORE_PRODUCT_COMMENTS_DELETE_AND_EDIT, $isPerformAction);
816 if($aItem[
'price_range'] ==
'Free')
819 return $this->_oDb->isCustomer($this->_iProfileId, $aItem[
'id']);
825 'store view product',
829 'store edit any product',
830 'store delete any product',
831 'store mark as featured',
832 'store approve product',
833 'store broadcast message'
841 if (
'm' == $mixedId[0]) {
842 require_once(CH_DIRECTORY_PATH_INC .
'membership_levels.inc.php');
845 return $a && isset($a[
'Name']) ? $a[
'Name'] :
'undefined';
849 $a = $oPrivacyQuery->getGroupsBy(array(
'type' =>
'id',
'id' => $mixedId));
851 return $a && (int)$a[
'owner_id'] == 0 ?
_t(
'_ps_group_' . $a[
'id'] .
'_title') : $a[
'title'];
857 parent::_browseMy(
$aProfile,
_t(
'_ch_store_page_title_my_store'));
863 if (
'Free' == $aData[
'price_range']) {
864 $sPrice =
_t(
'_ch_store_free_product');
866 $sPrice = str_replace(
'.00',
'', sprintf($aData[
'price_range'],
getParam(
'pmt_default_currency_sign'),
867 getParam(
'pmt_default_currency_sign')));
875 return $this->_oTemplate->parseHtmlByName(
'wall_outline_extra_info', array(