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 /** 44 * Check if the current user has the given roles on the current page 45 * 46 * @param string $pid The page ID to check access for 47 * @param string[] $roles Roles needed. Empty for any role 48 * @return bool 49 */ 50 public function checkAccess($pid, $roles = []) 51 { 52 return action_plugin_structpublish_sqlitefunction::userHasRole($pid, '', [], $roles); 53 } 54 55} 56