Viewing File: /usr/local/cpanel/base/frontend/jupiter/sql/userrights_include.html.tt
[% IF !CPANEL.feature('mysql') %]
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span>
<div class="alert-message">
<strong class="alert-title">[% locale.maketext('Error:') %]</strong>
<span class="alert-body">
[% locale.maketext("You do not have the feature “[_1]”.", 'mysql') %]
</span>
</div>
</div>
[% ELSE %]
[%
#Accepts these variables:
# full_username - falls back to RAW_FORM.user
# full_dbname - falls back to RAW_FORM.db
IF !full_username.size;
full_username = RAW_FORM.user;
END;
IF !full_dbname.size;
full_dbname = RAW_FORM.db;
END;
USE Api2;
SET userprivs_list = execute(
'Mysql',
'get_privileges_on_database',
{
user => full_username,
database => full_dbname,
}
);
SET userprivs = userprivs_list.data.size() ? array_to_hash(userprivs_list.data()) : {};
SET all_privs = userprivs.exists('ALL PRIVILEGES');
SET privs = Api2.exec( 'MysqlFE', 'getmysqlprivileges' );
SET errors = [];
errors = errors.merge(userprivs_list.errors);
errors.push(CPANEL.CPERROR.mysqlfe) IF CPANEL.CPERROR.mysqlfe;
IF errors.size();
FOREACH message IN errors.unique %]
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span>
<div class="alert-message">
<strong class="alert-title">[% locale.maketext('Error:') %]</strong>
<span class="alert-body">
[% message.html() %]
</span>
</div>
</div>
[% END %]
[% ELSE %]
<table class="nonsortable table table-striped" id="privs_table">
<thead>
<tr>
<th colspan="2" class="info-heading">
<div class="checkbox">
<label>
<input type="checkbox" name="ALL" id="ALL" value="ALL" [% all_privs ? 'checked="checked"' : '' %] />
[% locale.maketext("ALL PRIVILEGES") %]
</label>
</div>
</th>
</tr>
</thead>
<tbody>
[% FOR cur_priv = privs -%]
[% SET priv_no_spaces = cur_priv.replace(' ','') -%]
[% SET tdclass = (loop.index % 4 < 2) ? 'info-odd' : 'info-even' -%]
[% IF !(loop.index % 2) -%]
<tr>
[% END -%]
<td class="[% tdclass %]">
<div class="checkbox">
<label>
<input type="checkbox"
id="chk[% priv_no_spaces %]"
name="privileges" [% ( all_privs || userprivs.exists(cur_priv) ) ? 'checked="checked"' : '' %]
value="[% cur_priv %]"
class="user_right" />
[% cur_priv %]
</label>
</div>
</td>
[% IF (loop.index % 2) -%]
</tr>
[% END -%]
[% END -%]
[% IF privs.size % 2 -%]
<td> </td>
[% END -%]
</tbody>
</table>
<div class="form-group">
<input type="submit" value="[% locale.maketext("Make Changes") %]" class="btn btn-primary" id="submit" />
<button type="reset" value="[% locale.maketext("Reset") %]" class="btn btn-secondary">[% locale.maketext('Reset') %]</button>
</div>
[% END %]
<script type="text/javascript">
var USER_RIGHTS;
/**
* [checkallprivs description]
* @return {[type]} [description]
*/
var checkallprivs = function() {
var all_checked = DOM.get("ALL").checked;
USER_RIGHTS.forEach( function(i) {
i.checked = all_checked;
} );
};
/**
* [checkprivs description]
* @return {[type]} [description]
*/
var checkprivs = function() {
DOM.get("ALL").checked = USER_RIGHTS.every( function(i) {
return i.checked;
} );
};
/**
* [init_user_rights description]
* @return {[type]} [description]
*/
var init_user_rights = function() {
EVENT.on("ALL", "click", checkallprivs);
USER_RIGHTS = DOM.getElementsByClassName("user_right", "input", "privs_table")
EVENT.on(USER_RIGHTS, "click", checkprivs);
};
EVENT.onDOMReady(init_user_rights);
</script>
[% END %]
Back to Directory
File Manager