/[LeafOK_CVS]/lbbs/utils/lib/section_list.inc.php
ViewVC logotype

Annotation of /lbbs/utils/lib/section_list.inc.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Mon May 19 01:50:56 2025 UTC (9 months, 4 weeks ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Add script for generating menu config with section class/list

1 sysadm 1.1 <?php
2     function load_section_list(array & $result, callable $filter, callable $udf_value_gen, mysqli $db_conn, array $filter_param = array()) : bool
3     {
4     $sql = "SELECT SID, section_config.CID, section_config.sname, section_config.title AS s_title,
5     section_config.comment, section_class.cname, section_class.title AS c_title,
6     section_config.recommend, section_config.read_user_level, section_config.write_user_level
7     FROM section_config INNER JOIN section_class ON section_config.CID = section_class.CID
8     WHERE section_class.enable AND section_config.enable
9     ORDER BY section_class.sort_order, section_config.sort_order";
10    
11     $rs = mysqli_query($db_conn, $sql);
12     if ($rs == false)
13     {
14     return false;
15     }
16    
17     $last_cid = -1;
18     $last_c_name = "";
19     $last_c_title = "";
20     $section_list = array();
21     while ($row = mysqli_fetch_array($rs))
22     {
23     if ($row["CID"] != $last_cid)
24     {
25     if (count($section_list) > 0)
26     {
27     array_push($result, array(
28     "cid" => $last_cid,
29     "name" => $last_c_name,
30     "title" => $last_c_title,
31     "sections" => $section_list,
32     ));
33    
34     $section_list = array();
35     }
36    
37     $last_cid = $row["CID"];
38     $last_c_name = $row["cname"];
39     $last_c_title = $row["c_title"];
40     }
41    
42     if (call_user_func($filter, $row, $filter_param))
43     {
44     array_push($section_list, array(
45     "sid" => $row["SID"],
46     "name" => $row["sname"],
47     "title" => $row["s_title"],
48     "comment" => $row["comment"],
49     "read_user_level" => $row["read_user_level"],
50     "write_user_level" => $row["write_user_level"],
51     "udf_values" => call_user_func($udf_value_gen, $row, $filter_param),
52     ));
53     }
54     }
55    
56     if (count($section_list) > 0)
57     {
58     array_push($result, array(
59     "cid" => $last_cid,
60     "name" => $last_c_name,
61     "title" => $last_c_title,
62     "sections" => $section_list,
63     ));
64     }
65    
66     mysqli_free_result($rs);
67    
68     return true;
69     }

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