1<?php 2 3use dokuwiki\plugin\structpublish\meta\Assignments; 4 5class helper_plugin_structpublish_db extends helper_plugin_struct_db 6{ 7 8 /** 9 * Get list of all pages known to the plugin 10 * @return array 11 */ 12 public function getPages($pid = null) 13 { 14 $sql = 'SELECT pid FROM data_structpublish'; 15 if ($pid) { 16 $sql .= ' WHERE pid = ?'; 17 } 18 $res = $this->sqlite->query($sql, $pid); 19 $list = $this->sqlite->res2arr($res); 20 $this->sqlite->res_close($res); 21 return $list; 22 } 23 24 /** 25 * Returns true if the current page is included in publishing workflows 26 * 27 * @return bool 28 */ 29 public function isPublishable() 30 { 31 global $ID; 32 33 $sql = 'SELECT * FROM structpublish_assignments WHERE pid = ? AND assigned = 1'; 34 $res = $this->sqlite->query($sql, $ID); 35 if ($res && $this->sqlite->res2count($res)) { 36 return true; 37 } 38 return false; 39 } 40 41 /** 42 * Check if the current user has the given roles on the current page 43 * 44 * @param string $pid The page ID to check access for 45 * @param string[] $roles Roles needed. Empty for any role 46 * @return bool 47 */ 48 public function checkAccess($pid, $roles = []) 49 { 50 return action_plugin_structpublish_sqlitefunction::userHasRole($pid, '', [], $roles); 51 } 52 53} 54