Completed
Branch master (d598f1)
by Michael
02:16
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright   {@link http://xoops.org/ XOOPS Project}
14
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team,
18
 * @author      GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/)
19
 */
20
21
require_once __DIR__ . '/../../mainfile.php';
22
require_once XOOPS_ROOT_PATH . '/class/template.php';
23
24
error_reporting(0);
25
$xoopsLogger->activated = false;
26
27
// for "Duplicatable"
28
$moduleDirName = basename(__DIR__);
29
if (!preg_match('/^(\D+)(\d*)$/', $moduleDirName, $regs)) {
30
    echo('invalid dirname: ' . htmlspecialchars($moduleDirName));
31
}
32
$mydirnumber = $regs[2] === '' ? '' : (int)$regs[2];
33
34
$conn = $GLOBALS['xoopsDB']->conn;
35
36
// setting physical & virtual paths
37
$mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName";
38
$mod_url  = XOOPS_URL . "/modules/$moduleDirName";
39
40
// ���饹������ɤ߹���
41
if (!class_exists('APCal_xoops')) {
42
    require_once "$mod_path/class/APCal.php";
43
    require_once "$mod_path/class/APCal_xoops.php";
44
}
45
46
// creating an instance of APCal
47
$cal = new APCal_xoops('', $xoopsConfig['language'], true);
48
49
// setting properties of APCal
50
$cal->conn = $conn;
51
include "$mod_path/include/read_configs.php";
52
$cal->base_url    = $mod_url;
53
$cal->base_path   = $mod_path;
54
$cal->images_url  = "$mod_url/assets/images/$skin_folder";
55
$cal->images_path = "$mod_path/assets/images/$skin_folder";
56
57
// Include our module's language file
58
if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/language/' . $xoopsConfig['language'] . '/main.php')) {
59
    require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/language/' . $xoopsConfig['language'] . '/main.php';
60
    require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
61
} else {
62
    require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/language/english/main.php';
63
    require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/language/english/modinfo.php';
64
}
65
66
$myts = MyTextSanitizer::getInstance();
67
68
if ($_GET['op'] == 'exportxls') {
69
    header("Content-type: application/vnd-ms-excel; charset=' . _CHARSET");
70
    // Defines the name of the export file "codelution-export.xls"
71
    header("Content-Disposition: attachment; filename=download.xls");
72
} else {
73
    header('Content-Type:text/html; charset=' . _CHARSET);
74
}
75
$tpl = new XoopsTpl();
76
$tpl->xoops_setTemplateDir(XOOPS_ROOT_PATH . '/themes');
77
$tpl->xoops_setCaching(2);
78
$tpl->xoops_setCacheTime(0);
79
80
$tpl->assign('for_print', true);
81
82
$tpl->assign('charset', _CHARSET);
83
$tpl->assign('sitename', $xoopsConfig['sitename']);
84
$tpl->assign('site_url', XOOPS_URL);
85
86
$tpl->assign('lang_comesfrom', sprintf(_MB_APCAL_COMESFROM, $xoopsConfig['sitename']));
87
88
// �ڡ���ɽ����Ϣ�ν���ʬ��
89
if (!empty($_GET['event_id'])) {
90
    $tpl->assign('contents', $cal->get_schedule_view_html(true));
91
} else {
92
    switch ($_GET['smode']) {
93
        case 'ro_list':
94
            $tpl->assign('for_event_list', false);
95
            if (!empty($_REQUEST['eventid'])) {
96
                $eventid   = \Xmf\Request::getInt('eventid');
97
                $summary   = \Xmf\Request::getString('summary', '');
98
                $date      = \Xmf\Request::getInt('date');
99
                $location  = \Xmf\Request::getString('location', '');
100
                $classname = '';
101
102
                $title = $summary . ' (' . $date . ' ' . $location . ')';
103
                $query = 'SELECT '
104
                    . $GLOBALS['xoopsDB']->prefix('users')
105
                    . '.uname, '
106
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
107
                    . '.* FROM '
108
                    . $GLOBALS['xoopsDB']->prefix('users')
109
                    . ' INNER JOIN '
110
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
111
                    . ' ON '
112
                    . $GLOBALS['xoopsDB']->prefix('users')
113
                    . '.uid = '
114
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
115
                    . '.rom_submitter WHERE ((('
116
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
117
                    . ".rom_eventid)=$eventid)) ORDER BY "
118
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
119
                    . '.rom_date_created';
120
121
                $res      = $GLOBALS['xoopsDB']->query($query);
122
                $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
123
124
                if ($num_rows == 0) {
125
                    $ret = _APCAL_RO_NOMEMBERS;
126
                } else {
127
                    $ret .= "<h3>$title</h3>
128
                        <table class='ro_table-'>
129
                            <tr>
130
                                <th width='100px' class='listeheader'>" . _APCAL_RO_UNAME . "</th>
131
                                <th width='100px' class='listeheader'>" . _APCAL_RO_FIRSTNAME . "</th>
132
                                <th width='100px' class='listeheader'>" . _APCAL_RO_LASTNAME . "</th>
133
                                <th class='listeheader'>" . _APCAL_RO_EMAIL . '</th>';
134
                                if ($cal->ro_extrainfo1 !== '') {
135
                                    $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo1 . '</th>';
136
                                }
137
                                if ($cal->ro_extrainfo2 !== '') {
138
                                    $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo2 . '</th>';
139
                                }
140
                                if ($cal->ro_extrainfo3 !== '') {
141
                                    $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo3 . '</th>';
142
                                }
143
                                if ($cal->ro_extrainfo4 !== '') {
144
                                    $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo4 . '</th>';
145
                                }
146
                                if ($cal->ro_extrainfo5 !== '') {
147
                                    $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo5 . '</th>';
148
                                }
149
                                $ret .= "<th class='listeheader'>" . _APCAL_RO_STATUS . "</th>";
150
                    $ret .= '</tr>';
151
                    $line = 0;
152
                    while ($member = $GLOBALS['xoopsDB']->fetchObject($res)) {
153
                        $rom_id = $member->rom_id;
154
                        $uname = $member->uname;
155
                        $firstname = $member->rom_firstname;
156
                        $lastname = $member->rom_lastname;
157
                        $email = $member->rom_email;
158
                        $extrainfo1 = $member->rom_extrainfo1;
159
                        $extrainfo2 = $member->rom_extrainfo2;
160
                        $extrainfo3 = $member->rom_extrainfo3;
161
                        $extrainfo4 = $member->rom_extrainfo4;
162
                        $extrainfo5 = $member->rom_extrainfo5;
163
                        $status = (int)$member->rom_status;
164 View Code Duplication
                        if ($line == 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
165
                            $classname = 'odd';
166
                            $line = 1;
167
                        } else {
168
                            $classname = 'even';
169
                            $line = 0;
170
                        }
171
                        $ret .= "<tr>
172
                    <td class='$classname'>$uname</td>
173
                    <td class='$classname'>$firstname</td>
174
                    <td class='$classname'>$lastname</td>
175
                    <td class='$classname'>$email</td>";
176
                        if ($cal->ro_extrainfo1 !== '') {
177
                            $ret .= "<td class='$classname'>$extrainfo1</td>";
178
                        }
179
                        if ($cal->ro_extrainfo2 !== '') {
180
                            $ret .= "<td class='$classname'>$extrainfo2</td>";
181
                        }
182
                        if ($cal->ro_extrainfo3 !== '') {
183
                            $ret .= "<td class='$classname'>$extrainfo3</td>";
184
                        }
185
                        if ($cal->ro_extrainfo4 !== '') {
186
                            $ret .= "<td class='$classname'>$extrainfo4</td>";
187
                        }
188
                        if ($cal->ro_extrainfo5 !== '') {
189
                            $ret .= "<td class='$classname'>$extrainfo5</td>";
190
                        }
191
                        $ret .= "<td class='$classname' style='text-align:center'>";
192
                        $unique_id = uniqid(mt_rand());
193
                        $ret .= "<div style='display:inline;'>";
194
                        if ($status == 1) {
195
                            $ret .= _APCAL_RO_STATUS_PENDING;
196
                        } else if ($status == 2) {
197
                            $ret .= _APCAL_RO_STATUS_LIST;
198
                        } else {
199
                            $ret .= _APCAL_RO_STATUS_OK;
200
                        }
201
                        $ret .= "</div>";
202
                        $ret .= '</td></tr>';
203
                    }
204
                    $ret .= "</table>\n<br>";
205
                }
206
            }
207
208
            $tpl->assign('contents', $ret);
209
            break;
210
        case 'Yearly':
211
            $tpl->assign('for_event_list', false);
212
            $tpl->assign('contents', $cal->get_yearly('', '', true));
213
            break;
214
        case 'Weekly':
215
            $tpl->assign('for_event_list', false);
216
            $tpl->assign('contents', $cal->get_weekly('', '', true));
217
            break;
218
        case 'Daily':
219
            $tpl->assign('for_event_list', false);
220
            $tpl->assign('contents', $cal->get_daily('', '', true));
221
            break;
222
        case 'List':
223
            $tpl->assign('for_event_list', true);
224
            $cal->assign_event_list($tpl);
225
            break;
226
        case 'Monthly':
227
        default:
228
            $tpl->assign('for_event_list', false);
229
            $tpl->assign('contents', $cal->get_monthly('', '', true));
230
            break;
231
    }
232
}
233
234
echo '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/modules/apcal/assets/css/apcal.css" />';
235
$tpl->display('db:apcal_print.tpl');
236