/[LeafOK_CVS]/fenglin/bbs/section_setting.php
ViewVC logotype

Contents of /fenglin/bbs/section_setting.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Wed Apr 9 04:10:57 2025 UTC (11 months, 1 week ago) by sysadm
Branch: MAIN
Changes since 1.2: +31 -1 lines
Add section master operation

1 <?
2 require_once "../lib/db_open.inc.php";
3 require_once "./session_init.inc.php";
4 require_once "./theme.inc.php";
5
6 force_login();
7
8 $result_set = array(
9 "return" => array(
10 "code" => 0,
11 "message" => "",
12 "errorFields" => array(),
13 )
14 );
15
16 $sid = (isset($_GET["sid"]) ? intval($_GET["sid"]) : $BBS_default_sid);
17
18 if (!$_SESSION["BBS_priv"]->checkpriv($sid, S_POST | S_MAN_S))
19 {
20 $result_set["return"]["code"] = -1;
21 $result_set["return"]["message"] = "没有权限";
22
23 mysqli_close($db_conn);
24 exit(json_encode($result_set));
25 }
26
27 // Load section setting
28 $sql = "SELECT * FROM section_config WHERE SID = $sid AND enable";
29
30 $rs = mysqli_query($db_conn, $sql);
31 if ($rs == false)
32 {
33 $result_set["return"]["code"] = -2;
34 $result_set["return"]["message"] = "Query section data error: " . mysqli_error($db_conn);
35
36 mysqli_close($db_conn);
37 exit(json_encode($result_set));
38 }
39
40 if ($row = mysqli_fetch_array($rs))
41 {
42 $result_set["data"] = array(
43 "sid" => $sid,
44 "announcement" => $row["announcement"],
45 "comment" => $row["comment"],
46 "ex_update" => $row["ex_update"],
47 "section_hierachy" => array(),
48 "masters" => array(),
49 );
50 }
51 else
52 {
53 $result_set["return"]["code"] = -1;
54 $result_set["return"]["message"] = "Section data not exist";
55
56 mysqli_close($db_conn);
57 exit(json_encode($result_set));
58 }
59
60 mysqli_free_result($rs);
61
62 // Load section master
63 $sql = "SELECT section_master.UID, username, major, begin_dt, end_dt FROM section_master
64 INNER JOIN user_list ON section_master.UID = user_list.UID
65 WHERE SID = $sid AND section_master.enable AND (NOW() BETWEEN begin_dt AND end_dt)
66 ORDER BY major DESC, begin_dt ASC, end_dt ASC";
67
68 $rs = mysqli_query($db_conn, $sql);
69 if ($rs == false)
70 {
71 $result_set["return"]["code"] = -2;
72 $result_set["return"]["message"] = "Query section master error: " . mysqli_error($db_conn);
73
74 mysqli_close($db_conn);
75 exit(json_encode($result_set));
76 }
77
78 while ($row = mysqli_fetch_array($rs))
79 {
80 array_push($result_set["data"]["masters"], array(
81 "uid" => $row["UID"],
82 "username" => $row["username"],
83 "major" => $row["major"],
84 "begin_dt" => $row["begin_dt"],
85 "end_dt" => $row["end_dt"],
86 ));
87 }
88 mysqli_free_result($rs);
89
90 // Load section list
91 $sql = "SELECT SID, section_config.CID, section_config.title AS s_title, section_class.title AS c_title
92 FROM section_config INNER JOIN section_class ON section_config.CID = section_class.CID
93 WHERE section_class.enable AND section_config.enable
94 ORDER BY section_class.sort_order, section_config.sort_order";
95
96 $rs = mysqli_query($db_conn, $sql);
97 if ($rs == false)
98 {
99 $result_set["return"]["code"] = -2;
100 $result_set["return"]["message"] = "Query section error: " . mysqli_error($db_conn);
101
102 mysqli_close($db_conn);
103 exit(json_encode($result_set));
104 }
105
106 $last_cid = -1;
107 $last_c_title = "";
108 $section_list = array();
109 while ($row = mysqli_fetch_array($rs))
110 {
111 if ($row["CID"] != $last_cid)
112 {
113 if (count($section_list) > 0)
114 {
115 array_push($result_set["data"]["section_hierachy"], array(
116 "cid" => $last_cid,
117 "title" => $last_c_title,
118 "sections" => $section_list,
119 ));
120
121 $section_list = array();
122 }
123
124 $last_cid = $row["CID"];
125 $last_c_title = $row["c_title"];
126 }
127
128 if ($_SESSION["BBS_priv"]->checkpriv($row["SID"], S_POST | S_MAN_S))
129 {
130 array_push($section_list, array(
131 "sid" => $row["SID"],
132 "title" => $row["s_title"],
133 ));
134 }
135 }
136
137 if (count($section_list) > 0)
138 {
139 array_push($result_set["data"]["section_hierachy"], array(
140 "cid" => $last_cid,
141 "title" => $last_c_title,
142 "sections" => $section_list,
143 ));
144 }
145
146 mysqli_free_result($rs);
147
148 mysqli_close($db_conn);
149
150 // Output with theme view
151 $theme_view_file = get_theme_file("view/section_setting", $_SESSION["BBS_theme_name"]);
152 if ($theme_view_file == null)
153 {
154 exit(json_encode($result_set)); // Output data in Json
155 }
156 include $theme_view_file;
157 ?>

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1