xref: /plugin/structpublish/helper/db.php (revision 677c897aab05e424810827fc196287ad07eb618d)
1<?php
2
3use dokuwiki\plugin\structpublish\meta\Assignments;
4
5class helper_plugin_structpublish_db extends helper_plugin_struct_db
6{
7    const ACTION_APPROVE = 'approve';
8    const ACTION_PUBLISH = 'publish';
9
10    /**
11     * Get list of all pages known to the plugin
12     * @return array
13     */
14    public function getPages($pid = null)
15    {
16        $sql = 'SELECT pid FROM data_structpublish';
17        if ($pid) {
18            $sql .= ' WHERE pid = ?';
19        }
20        $res = $this->sqlite->query($sql, $pid);
21        $list = $this->sqlite->res2arr($res);
22        $this->sqlite->res_close($res);
23        return $list;
24    }
25
26    /**
27     * Returns true if the current page is included in publishing workflows
28     *
29     * @return bool
30     */
31    public function isPublishable()
32    {
33        global $ID;
34
35        $sql = 'SELECT * FROM structpublish_assignments WHERE pid = ? AND assigned = 1';
36        $res = $this->sqlite->query($sql, $ID);
37        if ($res && $this->sqlite->res2count($res)) {
38            return true;
39        }
40        return false;
41    }
42}
43