\n";
$retval .= "\n";
return $retval;
} // end self::get()
/**
* Creates the contents for a row in the list of routines
*
* @param array $routine An array of routine data
* @param string $rowclass Additional class
*
* @return string HTML code of a row for the list of routines
*/
public static function getRoutineRow(array $routine, $rowclass = '')
{
global $url_query, $url_params, $db, $titles;
$sql_drop = sprintf(
'DROP %s IF EXISTS %s',
$routine['type'],
Util::backquote($routine['name'])
);
$type_link = "item_type={$routine['type']}";
$retval = "
\n";
// this is for our purpose to decide whether to
// show the edit link or not, so we need the DEFINER for the routine
$where = "ROUTINE_SCHEMA " . Util::getCollateForIS() . "="
. "'" . $GLOBALS['dbi']->escapeString($db) . "' "
. "AND SPECIFIC_NAME='" . $GLOBALS['dbi']->escapeString($routine['name']) . "'"
. "AND ROUTINE_TYPE='" . $GLOBALS['dbi']->escapeString($routine['type']) . "'";
$query = "SELECT `DEFINER` FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
$routine_definer = $GLOBALS['dbi']->fetchValue($query);
$curr_user = $GLOBALS['dbi']->getCurrentUser();
// Since editing a procedure involved dropping and recreating, check also for
// CREATE ROUTINE privilege to avoid lost procedures.
if ((Util::currentUserHasPrivilege('CREATE ROUTINE', $db)
&& $curr_user == $routine_definer)
|| $GLOBALS['dbi']->isSuperuser()
) {
$retval .= ' ' . $titles['Edit'] . "\n";
} else {
$retval .= " {$titles['NoEdit']}\n";
}
$retval .= "
\n";
$retval .= "
\n";
// There is a problem with Util::currentUserHasPrivilege():
// it does not detect all kinds of privileges, for example
// a direct privilege on a specific routine. So, at this point,
// we show the Execute link, hoping that the user has the correct rights.
// Also, information_schema might be hiding the ROUTINE_DEFINITION
// but a routine with no input parameters can be nonetheless executed.
// Check if the routine has any input parameters. If it does,
// we will show a dialog to get values for these parameters,
// otherwise we can execute it directly.
$definition = $GLOBALS['dbi']->getDefinition(
$db, $routine['type'], $routine['name']
);
if ($definition !== false) {
$parser = new Parser($definition);
/**
* @var CreateStatement $stmt
*/
$stmt = $parser->statements[0];
$params = Routine::getParameters($stmt);
if (Util::currentUserHasPrivilege('EXECUTE', $db)) {
$execute_action = 'execute_routine';
for ($i = 0; $i < $params['num']; $i++) {
if ($routine['type'] == 'PROCEDURE'
&& $params['dir'][$i] == 'OUT'
) {
continue;
}
$execute_action = 'execute_dialog';
break;
}
$query_part = $execute_action . '=1&item_name='
. urlencode($routine['name']) . '&' . $type_link;
$retval .= ' ' . $titles['Execute'] . "\n";
} else {
$retval .= " {$titles['NoExecute']}\n";
}
}
$retval .= "
\n";
return $retval;
} // end self::getRoutineRow()
/**
* Creates the contents for a row in the list of triggers
*
* @param array $trigger An array of routine data
* @param string $rowclass Additional class
*
* @return string HTML code of a cell for the list of triggers
*/
public static function getTriggerRow(array $trigger, $rowclass = '')
{
global $url_query, $url_params, $db, $table, $titles;
$retval = "
\n";
return $retval;
} // end self::getTriggerRow()
/**
* Creates the contents for a row in the list of events
*
* @param array $event An array of routine data
* @param string $rowclass Additional class
*
* @return string HTML code of a cell for the list of events
*/
public static function getEventRow(array $event, $rowclass = '')
{
global $url_query, $url_params, $db, $titles;
$sql_drop = sprintf(
'DROP EVENT IF EXISTS %s',
Util::backquote($event['name'])
);
$retval = "