10 define(
'CH_WSB_SBS_TYPE_VISITOR', 0);
11 define(
'CH_WSB_SBS_TYPE_MEMBER', 1);
61 $this->_bDataAdded =
false;
62 $this->_sJsObject =
'oChWsbSubscription';
63 $this->_sActionUrl =
$GLOBALS[
'site'][
'url'] .
'subscription.php';
64 $this->_sVisitorPopup =
'sbs_visitor_popup';
69 if(!isset(
$GLOBALS[
'chWsbClasses'][
'ChWsbSubscription']))
72 return $GLOBALS[
'chWsbClasses'][
'ChWsbSubscription'];
80 $aSubscriptions = $this->_oDb->getSubscriptionsByUser((
int)$aUserInfo[
'ID']);
81 if(
empty($aSubscriptions))
85 if((
int)$aUserInfo[
'EmailNotify'] == 0)
86 $sContent .=
MsgBox(
_t(
'_sbs_wrn_email_notify_disabled', CH_WSB_URL_ROOT .
'pedit.php?ID=' . (
int)$aUserInfo[
'ID']));
89 'form_attrs' => array(
90 'id' =>
'sbs-subscriptions-form',
91 'name' =>
'sbs-subscriptions-form',
94 'enctype' =>
'multipart/form-data'
102 foreach($aSubscriptions
as $aSubscription) {
103 $oFunction =
function($arg1, $arg2, $arg3)
use ($aSubscription) {
104 return eval($aSubscription[
'params']);
107 $aParams = $oFunction($aSubscription[
'unit'], $aSubscription[
'action'], $aSubscription[
'object_id']);
108 if(isset($aParams[
'skip']) && $aParams[
'skip'] ===
true)
111 if($sUnit != $aSubscription[
'unit']) {
113 $aForm[
'inputs'][$sUnit .
'_end'] = array(
114 'type' =>
'block_end'
116 $aForm[
'inputs'][$aSubscription[
'unit'] .
'_begin'] = array(
117 'type' =>
'block_header',
118 'caption' =>
_t(
'_sbs_txt_title_' . $aSubscription[
'unit']),
119 'collapsable' =>
true,
120 'collapsed' => $bCollapsed
123 $sUnit = $aSubscription[
'unit'];
127 $sName =
'sbs-subscription_' . $aSubscription[
'entry_id'];
131 'content' =>
$oSysTemplate->parseHtmlByContent($sTmplRow, array(
132 'js_object' => $this->_sJsObject,
133 'obj_link' => $aParams[
'template'][
'ViewLink'],
134 'obj_title' => $aParams[
'template'][
'Subscription'],
141 $aForm[
'inputs'][$sUnit .
'_end'] = array(
142 'type' =>
'block_end'
149 $GLOBALS[
'oTopMenu']->setCurrentProfileID((
int)$aUserInfo[
'ID']);
161 if(!$this->_bDataAdded) {
165 'form_attrs' => array(
167 'name' =>
'sbs_form',
168 'action' => $this->_sActionUrl,
170 'enctype' =>
'multipart/form-data',
171 'onSubmit' =>
'javascript: return ' . $this->_sJsObject .
'.send(this);'
175 'direction' => array (
177 'name' =>
'direction',
190 'object_id' => array (
192 'name' =>
'object_id',
195 'user_name' => array (
197 'name' =>
'user_name',
198 'caption' =>
_t(
'_sys_txt_sbs_name'),
204 'user_email' => array (
206 'name' =>
'user_email',
207 'caption' =>
_t(
'_sys_txt_sbs_email'),
213 'sbs_controls' => array (
214 'type' =>
'input_set',
217 'name' =>
'sbs_subscribe',
218 'value' =>
_t(
'_sys_btn_sbs_subscribe'),
220 'onClick' =>
'javascript:$("#' . $this->_sVisitorPopup .
' [name=\'direction\']").val(\'subscribe\')',
225 'name' =>
'sbs_unsubscribe',
226 'value' =>
_t(
'_sys_btn_sbs_unsubscribe'),
228 'onClick' =>
'javascript:$("#' . $this->_sVisitorPopup .
' [name=\'direction\']").val(\'unsubscribe\')',
237 'content' =>
$oForm->getCode()
240 $this->_bDataAdded =
true;
244 $sCssJs .=
$oSysTemplate->addCss(array(
'subscription.css',
'subscription_phone.css'), $bDynamic);
245 $sCssJs .=
$oSysTemplate->addJs(array(
'ChWsbSubscription.js'), $bDynamic);
246 return ($bDynamic ? $sCssJs :
'') .
$sContent;
250 if($this->_oDb->isSubscribed(array(
'user_id' => $iUserId,
'unit' => $sUnit,
'action' =>
$sAction,
'object_id' => $iObjectId)))
252 'title' =>
_t(
'_sys_btn_sbs_unsubscribe'),
253 'script' => $this->_sJsObject .
".unsubscribe(" . $iUserId .
", '" . $sUnit .
"', '" .
$sAction .
"', " . $iObjectId .
")"
257 'title' =>
_t(
'_sys_btn_sbs_subscribe'),
258 'script' => $this->_sJsObject .
".subscribe(" . $iUserId .
", '" . $sUnit .
"', '" .
$sAction .
"', " . $iObjectId .
")"
285 switch($aParams[
'type']) {
287 $aRequest = array(
'sid' => $aParams[
'sid']);
290 $aRequest = array(
'unit' => $aParams[
'unit'],
'object_id' => $aParams[
'object_id']);
295 'user_id' => $aParams[
'id']
301 'user_id' => $aParams[
'id']
305 return $this->_oDb->deleteSubscription($aRequest);
309 return $this->_oDb->sendDelivery(array(
312 'object_id' => $iObjectId
317 return $this->_oDb->getSubscribersCount($iType);
321 return $this->_oDb->getSubscribers($iType, $iStart, $iCount);
326 $sMethodName = $sDirection .
'Subscription';
327 return $this->_oDb->$sMethodName(array(
329 'user_id' => $iUserId,
332 'object_id' => $iObjectId
337 $sMethodName = $sDirection .
'Subscription';
338 return $this->_oDb->$sMethodName(array(
340 'user_name' => $sUserName,
341 'user_email' => $sUserEmail,
344 'object_id' => $iObjectId
353 sActionUrl:
'<?=$this->_sActionUrl; ?>',
354 sObjName:
'<?=$this->_sJsObject; ?>',
355 sVisitorPopup:
'<?=$this->_sVisitorPopup; ?>'
366 if(is_int($mixedIds))
367 $aIds = array($mixedIds);
368 else if(is_string($mixedIds))
369 $aIds = explode(
",", $mixedIds);
370 else if(is_array($mixedIds))
373 return !
empty($aIds) ? $this->_sActionUrl .
'?sid=' . urlencode(base64_encode(implode(
",", $aIds))) :
'';