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