source: trunk/subscription.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 3.0 KB
Line 
1<?
2/***************************************************************************
3 * Dolphin Web Community Software
4 * -------------------
5 * begin : Mon Mar 23 2006
6 * copyright : (C) 2007 BoonEx Group
7 * website : http://www.boonex.com
8 *
9 *
10 *
11 ****************************************************************************/
12
13/***************************************************************************
14 *
15 * This is a free software; you can modify it under the terms of BoonEx
16 * Product License Agreement published on BoonEx site at http://www.boonex.com/downloads/license.pdf
17 * You may not however distribute it for free or/and a fee.
18 * This notice may not be removed from the source code. You may not also remove any other visible
19 * reference and links to BoonEx Group as provided in source code.
20 *
21 ***************************************************************************/
22
23require_once('inc/header.inc.php');
24require_once(BX_DIRECTORY_PATH_INC . 'utils.inc.php');
25require_once(BX_DIRECTORY_PATH_INC . 'design.inc.php');
26require_once(BX_DIRECTORY_PATH_INC . 'languages.inc.php');
27require_once(BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php');
28
29bx_import('BxDolSubscription');
30
31$oSubscription = new BxDolSubscription();
32
33$aResult = array();
34if(isset($_POST['direction'])) {
35 $sUnit = $_POST['unit'];
36 $sAction = $_POST['action'];
37 $iObjectId = (int)$_POST['object_id'];
38
39 switch($_POST['direction']) {
40 case 'subscribe':
41 if(isset($_POST['user_id']) && (int)$_POST['user_id'] != 0)
42 $aResult = $oSubscription->subscribeMember((int)$_POST['user_id'], $sUnit, $sAction, $iObjectId);
43 else if(isset($_POST['user_name']) && isset($_POST['user_email']))
44 $aResult = $oSubscription->subscribeVisitor($_POST['user_name'], $_POST['user_email'], $sUnit, $sAction, $iObjectId);
45 break;
46
47 case 'unsubscribe':
48 if(isset($_POST['user_id']) && (int)$_POST['user_id'] != 0)
49 $aResult = $oSubscription->unsubscribeMember((int)$_POST['user_id'], $sUnit, $sAction, $iObjectId);
50 else if(isset($_POST['user_name']) && isset($_POST['user_email']))
51 $aResult = $oSubscription->unsubscribeVisitor($_POST['user_name'], $_POST['user_email'], $sUnit, $sAction, $iObjectId);
52 break;
53 }
54
55 header('Content-Type:text/javascript');
56 $oJson = new Services_JSON();
57 echo $oJson->encode($aResult);
58}
59else if(isset($_GET['sid'])) {
60 $aResult = $oSubscription->unsubscribe(array('type' => 'sid', 'sid' => $_GET['sid']));
61 if(isset($_GET['js']) && (int)$_GET['js'] == 1) {
62 $oJson = new Services_JSON();
63 echo $oJson->encode($aResult);
64 exit;
65 }
66
67 $_page['name_index'] = 0;
68 $_page['header'] = $GLOBALS['site']['title'];
69 $_page['header_text'] = $GLOBALS['site']['title'];
70 $_page_cont[0]['page_main_code'] = MsgBox($aResult['message']);
71
72 PageCode();
73}
74?>
Note: See TracBrowser for help on using the repository browser.