xref: /plugin/acknowledge/helper.php (revision cabb51d3f49ec86f5433a0e5df3c2db082d97d60)
14d6d17d0SAndreas Gohr<?php
24d6d17d0SAndreas Gohr/**
34d6d17d0SAndreas Gohr * DokuWiki Plugin acknowledge (Helper Component)
44d6d17d0SAndreas Gohr *
54d6d17d0SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
64d6d17d0SAndreas Gohr * @author  Andreas Gohr, Anna Dabrowska <dokuwiki@cosmocode.de>
74d6d17d0SAndreas Gohr */
84d6d17d0SAndreas Gohr
94d6d17d0SAndreas Gohr
104d6d17d0SAndreas Gohrclass helper_plugin_acknowledge extends DokuWiki_Plugin
114d6d17d0SAndreas Gohr{
124d6d17d0SAndreas Gohr
13*cabb51d3SAndreas Gohr    /**
14*cabb51d3SAndreas Gohr     * @return helper_plugin_sqlite|null
15*cabb51d3SAndreas Gohr     */
16*cabb51d3SAndreas Gohr    public function getDB()
17*cabb51d3SAndreas Gohr    {
18*cabb51d3SAndreas Gohr        /** @var \helper_plugin_sqlite $sqlite */
19*cabb51d3SAndreas Gohr        $sqlite = plugin_load('helper', 'sqlite');
20*cabb51d3SAndreas Gohr        if ($sqlite === null) {
21*cabb51d3SAndreas Gohr            msg($this->getLang('error sqlite plugin missing'), -1);
22*cabb51d3SAndreas Gohr            return null;
23*cabb51d3SAndreas Gohr        }
24*cabb51d3SAndreas Gohr        if (!$sqlite->init('acknowledgement', __DIR__ . '/db')) {
25*cabb51d3SAndreas Gohr            return null;
26*cabb51d3SAndreas Gohr        }
27*cabb51d3SAndreas Gohr
28*cabb51d3SAndreas Gohr        return $sqlite;
29*cabb51d3SAndreas Gohr    }
30*cabb51d3SAndreas Gohr
31*cabb51d3SAndreas Gohr    /**
32*cabb51d3SAndreas Gohr     * @param string $page Page ID
33*cabb51d3SAndreas Gohr     * @param string $assignees comma separated list of users and groups
34*cabb51d3SAndreas Gohr     */
35*cabb51d3SAndreas Gohr    public function setAssignees($page, $assignees)
36*cabb51d3SAndreas Gohr    {
37*cabb51d3SAndreas Gohr        $sqlite = $this->getDB();
38*cabb51d3SAndreas Gohr        if (!$sqlite) return;
39*cabb51d3SAndreas Gohr
40*cabb51d3SAndreas Gohr        $sql = "REPLACE INTO assignments ('page', 'assignee') VALUES (?,?)";
41*cabb51d3SAndreas Gohr        $sqlite->query($sql, $page, $assignees);
42*cabb51d3SAndreas Gohr    }
43*cabb51d3SAndreas Gohr
44*cabb51d3SAndreas Gohr
454d6d17d0SAndreas Gohr}
464d6d17d0SAndreas Gohr
47