/** * Get the HTML snippet for routine specific privileges * * @param string $username username for database connection * @param string $hostname hostname for database connection * @param string $db the database * @param string $routine the routine * @param string $url_dbname url encoded db name * * @return string $html_output */ function PMA_getHtmlForRoutineSpecificPrivilges($username, $hostname, $db, $routine, $url_dbname) { $header = PMA_getHtmlHeaderForUserProperties(false, $url_dbname, $db, $username, $hostname, $routine); $sql = "SELECT `Proc_priv`" . " FROM `mysql`.`procs_priv`" . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "'" . " AND `Db` = '" . PMA_Util::sqlAddSlashes(PMA_Util::unescapeMysqlWildcards($db)) . "'" . " AND `Routine_name` LIKE '" . PMA_Util::sqlAddSlashes($routine) . "';"; $res = $GLOBALS['dbi']->fetchValue($sql); $privs = array('Alter_routine_priv' => 'N', 'Execute_priv' => 'N', 'Grant_priv' => 'N'); foreach (explode(',', $res) as $priv) { if ($priv == 'Alter Routine') { $privs['Alter_routine_priv'] = 'Y'; } else { $privs[$priv . '_priv'] = 'Y'; } } $routineArray = array(PMA_getTriggerPrivilegeTable()); $privTableNames = array(__('Routine')); $privCheckboxes = PMA_getHtmlForGlobalPrivTableWithCheckboxes($routineArray, $privTableNames, $privs); $data = array('username' => $username, 'hostname' => $hostname, 'database' => $db, 'routine' => $routine, 'grantCount' => count($privs), 'privCheckboxes' => $privCheckboxes, 'header' => $header); $html_output = PMA\Template::get('privileges/edit_routine_privileges')->render($data); return $html_output; }
/** * Get the HTML snippet for routine specific privileges * * @param string $username username for database connection * @param string $hostname hostname for database connection * @param string $db the database * @param string $routine the routine * @param string $url_dbname url encoded db name * * @return string $html_output */ function PMA_getHtmlForRoutineSpecificPrivilges($username, $hostname, $db, $routine, $url_dbname) { $header = PMA_getHtmlHeaderForUserProperties(false, $url_dbname, $db, $username, $hostname, $routine, 'routine'); $sql = "SELECT `Proc_priv`" . " FROM `mysql`.`procs_priv`" . " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'" . " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "'" . " AND `Db` = '" . $GLOBALS['dbi']->escapeString(Util::unescapeMysqlWildcards($db)) . "'" . " AND `Routine_name` LIKE '" . $GLOBALS['dbi']->escapeString($routine) . "';"; $res = $GLOBALS['dbi']->fetchValue($sql); $privs = PMA_parseProcPriv($res); $routineArray = array(PMA_getTriggerPrivilegeTable()); $privTableNames = array(__('Routine')); $privCheckboxes = PMA_getHtmlForGlobalPrivTableWithCheckboxes($routineArray, $privTableNames, $privs); $data = array('username' => $username, 'hostname' => $hostname, 'database' => $db, 'routine' => $routine, 'grantCount' => count($privs), 'privCheckboxes' => $privCheckboxes, 'header' => $header); $html_output = Template::get('privileges/edit_routine_privileges')->render($data); return $html_output; }