_DB = $databaseConnectionObject; $this->_User = $userObj; } /** * Validate if given action is a valid tool and if the user has access * * @param string $identifier * @return array */ public function validate(string $identifier): array { $ret = array(); $queryStr = "SELECT `name`,`description`,`action` FROM `".DB_PREFIX."_tool` WHERE ".$this->_User->getSQLRightsString()." AND `action` = '".$this->_DB->real_escape_string($identifier)."'"; if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr)); try { $query = $this->_DB->query($queryStr); if ($query !== false && $query->num_rows > 0) { $ret = $query->fetch_assoc(); } } catch (Exception $e) { Summoner::cleanForLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage()); if(QUERY_DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." mysql query: ".$queryStr); } return $ret; } /** * Default creation info based on current user * * @return array */ public function getDefaultCreationInfo(): array { return array( 'id' => $this->_User->param('id'), 'group' => $this->_User->param('baseGroupId'), 'rights' => 'rwxrwxr--' ); } }