Skip to content

Commit

Permalink
fix small things
Browse files Browse the repository at this point in the history
  • Loading branch information
Juinness committed Oct 5, 2021
1 parent 6d4ce5b commit 7d3951c
Show file tree
Hide file tree
Showing 18 changed files with 264 additions and 96 deletions.
30 changes: 22 additions & 8 deletions html/include/gosa.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,29 @@ function getNextInputElement(element) {
}
}

function changeState() {
for (var i = 0; i < arguments.length; i++) {
var element = $(arguments[i]);
if (element.hasAttribute('disabled')) {
element.removeAttribute('disabled');
function changeState(...args) {
args.forEach(element => {
var element = document.getElementById(element);
if (element.disabled) {
element.disabled = false;
if (element.tagName === 'SELECT') {
let dropdownOptions = {
dropdownOptions: {
'constrainWidth': true,
'coverTrigger': false,
'hover': false,
'alignment': 'right',
}
}
let selectInstances = M.FormSelect.init(element, dropdownOptions);
}
} else {
element.setAttribute('disabled', 'disabled');
element.disabled = true;
if (element.tagName === 'SELECT') {
let selectInstances = M.FormSelect.init(element);
}
}
}
});
}

function changeSelectState(triggerField, myField) {
Expand Down Expand Up @@ -185,7 +199,7 @@ function changeTripleSelectState(firstTriggerField, secondTriggerField, myField)
}
}

<!-- Second field must be non-checked -->
// Second field must be non-checked
function changeTripleSelectState_2nd_neg(firstTriggerField, secondTriggerField, myField) {
if (
document.getElementById(firstTriggerField).checked == true &&
Expand Down
12 changes: 11 additions & 1 deletion html/themes/default/js/eventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,14 @@ function language() {
weekdaysAbbrev: ['日', '一', '二', '三', '四', '五', '六'],
}
}
}
}

function enable_upload(val) {
console.log(val);
var upload_ssh_btn = document.getElementById('upload_sshpublickey');
if (val) {
upload_ssh_btn.disabled = false;
} else {
upload_ssh_btn.disabled = true;
}
}
2 changes: 1 addition & 1 deletion html/themes/default/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ if (input) {
pwButton.disabled = true;
}
}
}
}
57 changes: 28 additions & 29 deletions include/class_acl.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ class acl extends plugin
var $roleList = NULL;
var $aclMemberList = NULL;

var $theme;

function __construct(&$config, $parent, $dn= NULL)
{
/* Include config object */
plugin::__construct($config, $dn);

$this->theme = getThemeName();

/* Load ACL's */
$this->gosaAclEntry= array();
if (isset($this->attrs['gosaAclEntry'])){
Expand Down Expand Up @@ -333,9 +337,6 @@ class acl extends plugin
$tmp= session::global_get('plist');
$plist= $tmp->info;

// store theme name
$theme = getThemeName();

/* Handle posts */
if (isset($_POST['new_acl'])){
$this->dialogState= 'create';
Expand Down Expand Up @@ -563,7 +564,7 @@ class acl extends plugin
$this->recipients['G:*'] = _("All users");

$key = "G:*";
switch ($theme) {
switch ($this->theme) {
case 'classic':
$vData = array("data" => array(image("plugins/groups/images/select_group.png")));
break;
Expand All @@ -586,7 +587,7 @@ class acl extends plugin
/* If dialog is confirmed */
if((isset($_POST['userGroupSelect_save']) || isset($_POST['ok-save'])) &&
$this->dialog instanceof userGroupSelect) {
switch ($theme) {
switch ($this->theme) {
case 'classic':
$groupIcon = image("plugins/groups/images/select_group.png");
$userIcon = image("plugins/users/images/select_user.png");
Expand Down Expand Up @@ -695,7 +696,7 @@ class acl extends plugin

/* Set summary... */
if ($summary == ""){
switch ($theme) {
switch ($this->theme) {
case 'classic':
$summary = '<i>'._("No ACL settings for this category!").'</i>';
break;
Expand All @@ -711,7 +712,7 @@ class acl extends plugin

$actions ="";
if($this->acl_is_readable("")){
switch ($theme) {
switch ($this->theme) {
case 'classic':
$actions .= image('images/lists/edit.png', 'cat_edit_'.$section, msgPool::editButton(_("category ACL")));
break;
Expand All @@ -722,7 +723,7 @@ class acl extends plugin
}
}
if($this->acl_is_removeable() && preg_match("/;".$section."(;|\/)/", $usedList)){
switch ($theme) {
switch ($this->theme) {
case 'classic':
$actions .= image('images/lists/trash.png', 'cat_del_'.$section, msgPool::delButton(_("category ACL")));
break;
Expand Down Expand Up @@ -885,7 +886,7 @@ class acl extends plugin
$style = "style='width:100px;'";

if($this->acl_is_writeable("")){
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= "<button type='button' ".$style." name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" >Toggle C</button>";
$display .= "<button type='button' ".$style." name='toggle_all_move' onClick=\"acl_toggle_all('_0_m$');\" >Toggle M</button>";
Expand Down Expand Up @@ -1015,7 +1016,7 @@ class acl extends plugin
(preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) ||
(preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) {

switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .="<table summary='{$name}' style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>
<tr>
Expand All @@ -1040,7 +1041,7 @@ class acl extends plugin
break;
}
} else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= " <table summary='{$name}' style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>
<tr>
Expand Down Expand Up @@ -1069,7 +1070,7 @@ class acl extends plugin
break;
}
} else {
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= " <table summary='{$name}' style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>
<tr>
Expand Down Expand Up @@ -1102,7 +1103,7 @@ class acl extends plugin
$more_options= $this->mkchkbx($key."_0_r", _("read"), preg_match('/r/', $overall_acl));
$more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl));

switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= " <tr>
<td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>
Expand Down Expand Up @@ -1134,7 +1135,7 @@ class acl extends plugin
if(session::global_get('js')) {
if(isset($_SERVER['HTTP_USER_AGENT']) &&
(preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) {
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= " <tr id='tr_$tname' style='vertical-align:top;height:0px;'>
<td colspan=".$cols.">
Expand All @@ -1147,7 +1148,7 @@ class acl extends plugin
break;
}
} else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= " <tr id='tr_$tname' style='vertical-align:top;height:0px;'>
<td colspan=".$cols.">
Expand All @@ -1172,7 +1173,7 @@ class acl extends plugin

/* Open table row */
if ($cnt == 1){
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= '<tr>';
break;
Expand All @@ -1183,7 +1184,7 @@ class acl extends plugin
}

/* Close table row */
switch ($theme) {
switch ($this->theme) {
case 'classic':
if ($cnt == $cols){
$cnt= 1;
Expand All @@ -1205,7 +1206,7 @@ class acl extends plugin
$state= $currentAcl[$attr];
}

switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= " <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100/$cols)."%'>
<b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."
Expand Down Expand Up @@ -1236,7 +1237,7 @@ class acl extends plugin
(preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) ||
(preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT'])) ||
(preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT']))) {
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= " </table>
</div>
Expand All @@ -1250,7 +1251,7 @@ class acl extends plugin
}
}
}
switch ($theme) {
switch ($this->theme) {
case 'classic':
$display .= "</table><br/>";
break;
Expand All @@ -1269,7 +1270,7 @@ class acl extends plugin
$state= $state?"checked":"";
if($this->acl_is_writeable("")){
$tname= preg_replace("/[^a-z0-9]/i","_",$name);
switch ($theme) {
switch ($this->theme) {
case 'classic':
return "<input id='acl_$tname' type='checkbox' name='acl_$name' $state>
<label for='acl_$tname'>$text</label>";
Expand All @@ -1280,7 +1281,7 @@ class acl extends plugin
</label>";
}
}else{
switch ($theme) {
switch ($this->theme) {
case 'classic':
return "<input type='checkbox' disabled name='dummy_".microtime(1)."' $state>$text";
default:
Expand All @@ -1301,7 +1302,7 @@ class acl extends plugin
$tname= preg_replace("/[^a-z0-9]/i","_",$name);

if($this->acl_is_writeable("")){
switch ($theme) {
switch ($this->theme) {
case 'classic':
return "<input id='acl_".$tname."_r' type='checkbox' name='acl_${name}_r' $rstate>
<label for='acl_".$tname."_r'>"._("read")."</label>
Expand All @@ -1318,7 +1319,7 @@ class acl extends plugin
</label>" ;
}
}else{
switch ($theme) {
switch ($this->theme) {
case 'classic':
return "<input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read")."
<input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write");
Expand Down Expand Up @@ -1519,8 +1520,6 @@ class acl extends plugin

function loadAclEntry($new= FALSE)
{
$theme = getThemeName();

/* New entry gets presets... */
if ($new){
$this->aclType= 'base';
Expand Down Expand Up @@ -1548,7 +1547,7 @@ class acl extends plugin
if($key == "G:*") {
$name = _("All users");
$desc = _("Pseudo-group for all users.");
switch ($theme) {
switch ($this->theme) {
case 'classic':
$icon = image("plugins/groups/images/select_group.png");
break;
Expand All @@ -1562,7 +1561,7 @@ class acl extends plugin
else if($key[0] == 'U') { // is user?
$name = $match[3][0];
$desc = $match[1][0];
switch ($theme) {
switch ($this->theme) {
case 'classic':
$icon = image("plugins/users/images/select_user.png");
break;
Expand All @@ -1575,7 +1574,7 @@ class acl extends plugin
else { // or group?
$name = $match[1][0];
$desc = $match[3][0];
switch ($theme) {
switch ($this->theme) {
case 'classic':
$icon = image("plugins/groups/images/select_group.png");
break;
Expand Down
26 changes: 14 additions & 12 deletions include/class_management.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class management
public $plHeadline = "unconfigured";

// The currently used object(s) (e.g. in edit, removal)
public $dn = ""; // this is public due to some compatibility problems with class plugin..
protected $dns = array();
public $dn = ""; // this is public due to some compatibility problems with class plugin..
protected $dns = array();

// The last used object(s).
protected $last_dn = "";
Expand All @@ -44,13 +44,13 @@ class management
protected $storagePoints = array();

// The tab definitions to use for the current object.
protected $tabClass = ""; // e.g. usertabs
protected $tabType = ""; // e.g. USERTABS
protected $aclPlugin = ""; // e.g. generic
protected $aclCategory = ""; // e.g. users
protected $objectName = ""; // e.g. users
protected $tabClass = ""; // e.g. usertabs
protected $tabType = ""; // e.g. USERTABS
protected $aclPlugin = ""; // e.g. generic
protected $aclCategory = ""; // e.g. users
protected $objectName = ""; // e.g. users

// The opened object.
// The opened object.
protected $tabObject = null;
protected $dialogObject = null;

Expand Down Expand Up @@ -205,7 +205,7 @@ class management

// Display tab object.
if ($this->tabObject instanceof tabs || $this->tabObject instanceof multi_plug) {
# $this->tabObject->save_object();
# $this->tabObject->save_object();
$display = $this->tabObject->execute();
$display.= $this->_getTabFooter();
return($this->getHeader().$display);
Expand Down Expand Up @@ -273,7 +273,6 @@ class management
}
}


/*! \brief Generates the footer which is used whenever a tab object is
* displayed.
*/
Expand All @@ -299,9 +298,13 @@ class management
return("");
}

if ($theme == "default") {
$acl_mode = preg_match("/^[r]$/", $this->ui->get_category_permissions($this->ui->dn,"users"));
}

// In case an of locked entry, we may have opened a read-only tab.
$str = "";
if (isset($this->tabObject->read_only) && $this->tabObject->read_only == true) {
if (isset($this->tabObject->read_only) && $this->tabObject->read_only == true || $acl_mode) {
switch ($theme) {
case 'classic':
$str .= "<p style=\"text-align:right\">
Expand Down Expand Up @@ -344,7 +347,6 @@ class management
return($str);
}


/*! \brief Initiates the removal for the given entries
* and displays a confirmation dialog.
*
Expand Down
Loading

0 comments on commit 7d3951c

Please sign in to comment.