forked from nbuy/xoops-modules-eguide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.php
185 lines (157 loc) · 5.19 KB
/
event.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
// display events
// $Id: event.php,v 1.30 2010/06/27 04:12:30 nobu Exp $
include 'header.php';
$eid = param( 'eid' );
$exid = param( 'sub' );
$op = param( 'op', 'view' );
$myts =& MyTextSanitizer::getInstance();
$isadmin = false;
$uid = 0;
if ( is_object( $xoopsUser ) ) {
$isadmin = $xoopsUser->isAdmin( $xoopsModule->getVar( 'mid' ) );
$uid = $xoopsUser->getVar( 'uid' );
if ( ! $isadmin ) {
$result = $xoopsDB->query( 'SELECT uid FROM ' . EGTBL . " WHERE eid=$eid AND uid=$uid" );
if ( $xoopsDB->getRowsNum( $result ) > 0 ) {
$isadmin = true;
}
}
}
set_next_event();
$data = fetch_event( $eid, $exid, $isadmin );
if ( empty( $data ) ) {
redirect_header( EGUIDE_URL . '/index.php', 3, _NOPERM );
exit;
}
$_GET['cat'] = $data['topicid']; // for notification
$now = time();
$data['exid'] = $exid;
// sub
$extents = get_extents( $eid );
if ( $exid ) {
$data['extent'] = true;
} // show editdate link
else if ( count( $extents ) && $exid == 0 ) {
if ( count( $extents ) == 1 ) { // only one extent, chose that.
header( 'Location: ' . EGUIDE_URL . '/event.php?eid=' . $eid . '&sub=' . $extents[0]['exid'] );
exit;
}
$data['extent'] = true; // also show editdate link
$data['extents'] = $extents;
$data['exdate'] = $extents[0]['exdate'];
}
$data['isadmin'] = ( $isadmin || $data['uid'] == $uid );
if ( $op != "print" ) {
if ( ! $xoopsUser || $data['uid'] != $xoopsUser->uid() ) {
$xoopsDB->queryF( "UPDATE " . EGTBL . " SET counter=counter+1 WHERE eid=$eid" );
$data['counter'] ++;
}
$data['link'] = true;
}
// check pical exists
$module_handler =& xoops_gethandler( 'module' );
$module =& $module_handler->getByDirname( PICAL );
if ( is_object( $module ) && $module->getVar( 'isactive' ) == 1 ) {
$pidate = formatTimestamp( $data['edate'], 'Y-m-d' );
if ( empty( $_GET['caldate'] ) ) {
$_GET['caldate'] = $pidate;
}
$_POST['pical_jumpcaldate'] = true; // pical cache disable hack
}
include XOOPS_ROOT_PATH . '/header.php';
$xoopsOption['template_main'] = EGPREFIX . '_event.html';
assign_module_css();
edit_eventdata( $data );
$title = $data['date'] . " " . $data['title'];
set_eguide_breadcrumbs( $data['topicid'], array( $title => '' ) );
$xoopsTpl->assign( 'event', $data );
if ( isset( $pidate ) ) {
$xoopsTpl->assign( 'caldate', $pidate );
}
// page title
$xoopsTpl->assign( 'xoops_pagetitle', $xoopsModule->getVar( 'name' ) . " | " . $title );
if ( $data['closedate'] < $now ) {
if ( $data['reservation'] ) {
$xoopsTpl->assign( 'message', _MD_RESERV_CLOSE );
}
} elseif ( $data['reservation'] ) {
$reserved = false;
if ( is_object( $xoopsUser ) ) {
$result = $xoopsDB->query( "SELECT * FROM " . RVTBL . " WHERE eid=$eid AND exid=$exid AND uid=" . $xoopsUser->getVar( 'uid' ) );
$reserved = ( $xoopsDB->getRowsNum( $result ) > 0 );
}
if ( $data['strict'] && $data['persons'] <= $data['reserved'] ) {
$xoopsTpl->assign( 'message', _MD_RESERV_FULL );
} elseif ( ! is_object( $xoopsUser ) && $xoopsModuleConfig['member_only'] == ACCEPT_MEMBER ) {
$xoopsTpl->assign( 'message', _MD_RESERV_NEEDLOGIN );
} else {
$ok = true;
if ( $xoopsModuleConfig['use_plugins'] ) {
include_once 'plugins.php';
foreach ( $hooked_function['check'] as $func ) {
$ok = $func( $eid, $exid, $data['uid'] );
if ( ! $ok ) {
break;
}
}
}
if ( $reserved ) {
$xoopsTpl->assign( 'message', _MD_RESERVED );
} elseif ( $ok ) {
$xoopsTpl->assign( 'form', eventform( $data, 0 ) );
}
}
}
$xoopsTpl->assign( make_lists( $data ) );
if ( $op == "print" ) {
$xoopsOption['template_main'] = EGPREFIX . '_event_print.html';
$xoopsTpl->assign( 'lang_comefrom', sprintf( _MD_THISCOMESFROM, $xoopsConfig['sitename'] ) );
$xoopsTpl->display( 'db:' . EGPREFIX . '_event_print.html' );
exit;
}
if ( $xoopsModuleConfig['use_comment'] ) {
include XOOPS_ROOT_PATH . '/include/comment_view.php';
}
include XOOPS_ROOT_PATH . '/footer.php';
function make_lists( $data ) {
global $xoopsDB;
$eid = $data['eid'];
$exid = $data['exid'];
$myts =& MyTextSanitizer::getInstance();
if ( $data['reservation'] && ! empty( $data['reserved'] ) ) {
$show = array();
$item = array();
foreach ( explode( "\n", trim( $data['optfield'] ) ) as $n ) {
$a = explode( ",", preg_replace( '/[\n\r]/', "", $n ) );
$lab = preg_replace( '/[\*#]$/', "", array_shift( $a ) );
if ( preg_match( '/^!/', $lab ) ) {
$lab = preg_replace( '/^!\s*/', '', $lab );
$show[] = $lab;
}
$item[] = $lab;
}
$list = array();
if ( count( $show ) ) {
$result = $xoopsDB->query( 'SELECT * FROM ' . RVTBL . " WHERE eid=$eid AND exid=$exid AND status=" . _RVSTAT_RESERVED . ' ORDER BY rdate' );
$nc = 0;
while ( $rdata = $xoopsDB->fetchArray( $result ) ) {
$a = unserialize_text( $rdata['info'] );
if ( ! empty( $rdata['uid'] ) ) {
$uid = $rdata['uid'];
$uinfo = " (<a href='" . XOOPS_URL . "/userinfo.php?uid=$uid'>" . XoopsUser::getUnameFromId( $uid ) . "</a>)";
} else {
$uinfo = "";
}
$order = array();
foreach ( $show as $v ) {
$order[] = $myts->sanitizeForDisplay( $a[ $v ] ) . $uinfo;
$uinfo = "";
}
$list[ ++ $nc ] = $order;
}
}
return array( 'labels' => $show, 'list' => $list );
}
return array();
}