*/
public function setUsersConfig($user, $password, $firstUsage = false, $oldUser = null) {
$allUsers = $this->getAllUsers();
- $usersFile = Prado::getPathOfNamespace(self::USERS_FILE, '.users');
$password = $this->getCryptedPassword($password);
if($firstUsage === true) {
$allUsers[$user] = $password;
}
- $users = array();
- foreach ($allUsers as $user => $pwd) {
- $users[] = "$user:$pwd";
- }
-
- $usersToFile = implode("\n", $users);
- $old_umask = umask(0);
- umask(0077);
- $result = file_put_contents($usersFile, $usersToFile) !== false;
- umask($old_umask);
+ $result = $this->saveUserConfig($allUsers);
return $result;
}
return $allUsers;
}
+ public function saveUserConfig($allUsers) {
+ $users = array();
+ foreach ($allUsers as $user => $pwd) {
+ $users[] = "$user:$pwd";
+ }
+ $usersFile = Prado::getPathOfNamespace(self::USERS_FILE, '.users');
+ $usersToFile = implode("\n", $users);
+ $old_umask = umask(0);
+ umask(0077);
+ $result = file_put_contents($usersFile, $usersToFile) !== false;
+ umask($old_umask);
+ return $result;
+ }
+
+ public function removeUser($username) {
+ $result = false;
+ $allUsers = $this->getAllUsers();
+ if (array_key_exists($username, $allUsers)) {
+ unset($allUsers[$username]);
+ $result = $this->saveUserConfig($allUsers);
+ }
+ return $result;
+ }
+
/**
* Checking if users configuration file exists.
*
$result = file_put_contents($usersFile, '') !== false;
return $result;
}
+
+ public function switchToUser($http_protocol, $host, $port, $user, $password) {
+ $urlPrefix = $this->Application->getModule('friendly-url')->getUrlPrefix();
+ $location = sprintf("%s://%s:%s@%s:%d%s", $http_protocol, $user, $password, $host, $port, $urlPrefix);
+ header("Location: $location");
+ }
+
+ public function getRandomString() {
+ $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ $rand_string = str_shuffle($characters);
+ return $rand_string;
+ }
}
?>
}
}
}
+
+var Users = {
+ ids: {
+ create_user: {
+ add_user: 'add_user',
+ add_user_btn: 'add_user_btn',
+ newuser: 'newuser',
+ newpwd: 'newpwd'
+ },
+ change_pwd: {
+ rel_chpwd: 'chpwd',
+ rel_chpwd_btn: 'chpwd_btn'
+ }
+ },
+ init: function() {
+ this.setEvents();
+ },
+ setEvents: function() {
+ document.getElementById(this.ids.create_user.add_user_btn).addEventListener('click', function(e) {
+ $(this.ids.create_user.add_user).show();
+ $(this.ids.create_user.newuser).focus();
+ }.bind(this));
+ document.getElementById(this.ids.create_user.newuser).addEventListener('keypress', function(e) {
+ var target = e.target || e.srcElement;
+ if (e.keyCode == 13) {
+ target.parentNode.getElementsByTagName('A')[0].click();
+ }
+ return false;
+ }.bind(this));
+ document.getElementById(this.ids.create_user.newpwd).addEventListener('keypress', function(e) {
+ var target = e.target || e.srcElement;
+ if (e.keyCode == 13) {
+ $(target.nextElementSibling).click();
+ }
+ return false;
+ }.bind(this));
+ },
+ userValidator: function(user) {
+ user = user.replace(/\s/g, '');
+ var valid = user != '';
+ return valid;
+ },
+ pwdValidator: function(pwd) {
+ var valid = pwd.length > 4;
+ return valid;
+ },
+ addUser: function() {
+ var valid = true;
+ var user = document.getElementById(this.ids.create_user.newuser).value;
+ var pwd = document.getElementById(this.ids.create_user.newpwd).value;
+ if (this.userValidator(user) === false) {
+ alert(this.txt.enter_login);
+ valid = false;
+ }
+ if (this.pwdValidator(pwd) === false) {
+ alert(this.txt.invalid_pwd);
+ valid = false;
+ }
+ if (valid === true) {
+ $(this.ids.create_user.add_user).hide();
+ this.action_callback('newuser', user, pwd);
+ }
+ return valid;
+ },
+ rmUser: function(user) {
+ this.action_callback('rmuser', user);
+ },
+ showChangePwd: function(el) {
+ $$('a[rel=\'' + this.ids.change_pwd.rel_chpwd_btn + '\']').invoke('show');
+ $(el).hide();
+ $$('span[rel=\'' + this.ids.change_pwd.rel_chpwd + '\']').invoke('hide');
+ $(el.nextElementSibling).show();
+ $(el.nextElementSibling).select('input')[0].focus();
+ },
+ changePwd: function(el, user) {
+ var valid = true;
+ var pwd = el.previousElementSibling.value;
+
+ if (this.pwdValidator(pwd) === false) {
+ alert(this.txt.invalid_pwd);
+ valid = false;
+ }
+ if (valid === true) {
+ $(el.parentNode).hide();
+ $(el.parentNode.previousElementSibling).show();
+ this.action_callback('chpwd', user, pwd);
+ }
+ },
+ cancelAddUser: function(el) {
+ $(this.ids.create_user.add_user).hide();
+ },
+ cancelChangePwd: function(el) {
+ $(el.parentNode).hide();
+ $(el.parentNode.previousElementSibling).show();
+ }
+
+}
var PanelWindowClass = Class.create({
currentWindowId: null,
- windowIds: ['dashboard', 'container', 'graphs'],
+ windowIds: ['dashboard', 'container', 'graphs', 'users'],
onShow: null,
initialize: function() {
});
}
}
- for (var i = 0, j = 1; i < this.windowIds.length; i++, j++) {
+ for (var i = 0; i < this.windowIds.length; i++) {
hide_panel_by_id(this.windowIds[i]);
}
},
msgid "start time"
msgstr "start time"
+msgid "Users"
+msgstr "Users"
+
+msgid "User name"
+msgstr "User name"
+
+msgid "Role"
+msgstr "Role"
+
+msgid "Remove user"
+msgstr "Remove user"
+
+msgid "Logout"
+msgstr "Logout"
+
+msgid "Change password"
+msgstr "Change password"
+
+msgid "Administrator"
+msgstr "Administrator"
+
+msgid "Normal user"
+msgstr "Normal user"
+
+msgid "Add new user"
+msgstr "Add new user"
+
+msgid "Username:"
+msgstr "Username:"
+
+msgid "Please note that for each user (excluding administrator) there should exist separate Bconsole config file in form:"
+msgstr "Please note that for each user (excluding administrator) there should exist separate Bconsole config file in form:"
+
msgid "start time"
msgstr "czas rozpoczęcia"
+msgid "Users"
+msgstr "Użytkownicy"
+
+msgid "User name"
+msgstr "Nazwa użytkownika"
+
+msgid "Role"
+msgstr "Rola"
+
+msgid "Remove user"
+msgstr "Usuń użytkownika"
+
+msgid "Logout"
+msgstr "Wyloguj"
+
+msgid "Change password"
+msgstr "Zmień hasło"
+
+msgid "Administrator"
+msgstr "Administrator"
+
+msgid "Normal user"
+msgstr "Użytkownik"
+
+msgid "Add new user"
+msgstr "Dodaj nowego użytkownika"
+
+msgid "Username:"
+msgstr "Nazwa użytkownika:"
+
+msgid "Please note that for each user (excluding administrator) there should exist separate Bconsole config file in form:"
+msgstr "Uwaga! Dla każdego użytkownika (wyłączając administratora) powinien istnieć osobny plik konfiguracyjny Bconsole w postaci:"
+
$this->getModule('configuration')->setUsersConfig($cfgData['baculum']['login'], $cfgData['baculum']['password'], $this->firstRun, $previousUser);
// Automatic login after finish wizard.
$http_protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http';
- $urlPrefix = $this->Application->getModule('friendly-url')->getUrlPrefix();
- $location = sprintf("%s://%s:%s@%s:%d%s", $http_protocol, $cfgData['baculum']['login'], $cfgData['baculum']['password'], $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $urlPrefix);
- header("Location: $location");
+ $this->getModule('configuration')->switchToUser($http_protocol, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $cfgData['baculum']['login'], $cfgData['baculum']['password']);
exit();
} else { // standard version (user defined auth method)
$this->goToDefaultPage();
<%@ MasterClass="Application.Layouts.Main" Theme="Baculum-v1"%>
<com:TContent ID="Main">
<div id="top">
- <img id="logo" src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/logo.png" alt="Baculum" />
- <div id="directors"><com:TLabel ForControl="Director" Text="<%[ Director: ]%>" />
- <com:TActiveDropDownList ID="Director" OnTextChanged="director" />
- </div>
- <div id="panel_switcher">
- <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/dashboard.png" alt="" onclick="$('<%=$this->Dashboard->ClientID%>').click()" />
- <com:TActiveLinkButton ID="Dashboard" Text="<%[ Dashboard ]%>" Attributes.onclick="PanelWindow.show('dashboard'); return false;" />
- <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/workspace.png" alt="" onclick="$('<%=$this->Workspace->ClientID%>').click()"/>
- <com:TActiveLinkButton ID="Workspace" Text="<%[ Workspace ]%>" Attributes.onclick="PanelWindow.show('container'); return false;" />
- <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/graphs.png" alt="" onclick="$('<%=$this->Graphs->ClientID%>').click()" />
- <com:TActiveLinkButton ID="Graphs" Text="<%[ Graphs ]%>" Attributes.onclick="PanelWindow.show('graphs'); return false;" />
- </div>
+ <div id="topbar">
+ <div id="directors"><com:TLabel ForControl="Director" Text="<%[ Director: ]%>" />
+ <com:TActiveDropDownList ID="Director" OnTextChanged="director" />
+ </div>
+ <div id="panel_switcher">
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/dashboard.png" alt="" onclick="$('<%=$this->Dashboard->ClientID%>').click()" />
+ <com:TActiveLinkButton ID="Dashboard" Text="<%[ Dashboard ]%>" Attributes.onclick="PanelWindow.show('dashboard'); return false;" />
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/workspace.png" alt="" onclick="$('<%=$this->Workspace->ClientID%>').click()"/>
+ <com:TActiveLinkButton ID="Workspace" Text="<%[ Workspace ]%>" Attributes.onclick="PanelWindow.show('container'); return false;" />
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/graphs.png" alt="" onclick="$('<%=$this->Graphs->ClientID%>').click()" />
+ <com:TActiveLinkButton ID="Graphs" Text="<%[ Graphs ]%>" Attributes.onclick="PanelWindow.show('graphs'); return false;" />
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/users.png" alt="" onclick="$('<%=$this->Users->ClientID%>').click()" <%=$this->User->getIsAdmin() === false ? ' style="display: none;"' : ''%>/>
+ <com:TActiveLinkButton ID="Users" Text="<%[ Users ]%>" Attributes.onclick="PanelWindow.show('users'); return false;" />
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/logout.png" alt="" onclick="$('<%=$this->Logout->ClientID%>').click()" />
+ <com:TActiveLinkButton ID="Logout" Text="<%[ Logout ]%>" OnClick="logout" ClientSide.OnComplete="document.location.href = document.location.protocol + '//' + document.location.host;" />
+ </div>
<com:Application.Portlets.TrayBar ID="TrayBar" />
+ </div>
</div>
<div id="dashboard">
<div>
<p class="right bold italic"><%[ Tip: for getting zoom, please mark area on graph. ]%></p>
<p class="right bold italic"><%[ Tip 2: for back from zoom, please click somewhere on graph. ]%></p>
</div>
+ <div id="users" style="display: none">
+ <div>
+ <a href="javascript:void(0)" id="add_user_btn"><strong><%[ Add new user ]%></strong></a>
+ <div id="add_user" style="display: none">
+ <p><%[ Username: ]%><input id="newuser" type="text" /><%[ Password: ]%><input id="newpwd" type="password" />
+ <a href="javascript:void(0)" onclick="Users.addUser()">
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_ok.png" alt="<%[ Save ]%>" title="<%[ Save ]%>"/>
+ </a>
+ <a href="javascript:void(0)" onclick="Users.cancelAddUser()">
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_err.png" alt="<%[ Close ]%>" title="<%[ Close ]%>" />
+ </a></p>
+ </div>
+ <com:TActiveRepeater ID="UsersList">
+ <prop:HeaderTemplate>
+ <table id="users_list" class="window-section-detail-smallrow">
+ <tr>
+ <th><%[ User name ]%></th>
+ <th><%[ Role ]%></th>
+ <th><%[ Actions ]%></th>
+ </tr>
+ </prop:HeaderTemplate>
+ <prop:ItemTemplate>
+ <tr class="slide-window-element">
+ <td><%=$this->DataItem%></td>
+ <td><%=$this->User->getName() == $this->DataItem ? Prado::localize('Administrator') : Prado::localize('Normal user')%></td>
+ <td>
+ <a href="javascript:void(0)" <%=$this->User->getName() == $this->DataItem ? 'style="visibility: hidden"' : ''%> onclick="Users.rmUser('<%=$this->DataItem%>')"><img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/user-del.png"> <%[ Remove user ]%></a>
+ <a href="javascript:void(0)" onclick="Users.showChangePwd(this)" rel="chpwd_btn">
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/key.png" alt="" />
+ <%[ Change password ]%>
+ </a>
+ <span style="display: none;" rel="chpwd">
+ <input type="password" onkeypress="event.keyCode == 13 ? $(this.nextElementSibling).click(): '';" />
+ <a href="javascript:void(0)" onclick="Users.changePwd(this, '<%=$this->DataItem%>')">
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_ok.png" alt="<%[ Save ]%>" title="<%[ Save ]%>"/>
+ </a>
+ <a href="javascript:void(0)" onclick="Users.cancelChangePwd(this)">
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_err.png" alt="<%[ Close ]%>" title="<%[ Close ]%>" />
+ </a>
+ </span>
+ </td>
+ </tr>
+ </prop:ItemTemplate>
+ <prop:FooterTemplate>
+ </table>
+ </prop:FooterTemplate>
+ </com:TActiveRepeater>
+ <p><em><%[ Please note that for each user (excluding administrator) there should exist separate Bconsole config file in form: ]%> <strong><com:TLabel ID="BconsoleCustomPath" /></strong></em></p>
+ <com:TCallback ID="UserAction" OnCallback="userAction" />
+ <script type="text/javascript">
+ var send_user_action = function(action, param, value) {
+ if (!value) {
+ value = '';
+ }
+ var user_action_callback = <%=$this->UserAction->ActiveControl->Javascript%>;
+ user_action_callback.ActiveControl.CallbackParameter = [action, param, value].join(';');
+ user_action_callback.dispatch();
+ };
+ Users.txt = {
+ enter_login: '<%[ Please enter login. ]%>',
+ invalid_pwd: '<%[ Password must be longer than 4 chars. ]%>'
+ };
+ Users.action_callback = send_user_action;
+ Users.init();
+ </script>
+ </div>
+ </div>
<div id="console">
<a id="clear_bvfs_cache" href="javascript: void(0)"><com:TActiveImageButton ID="ClearBvfsCache" OnCallback="clearBvfsCache" Attributes.onclick="return (confirm('<%=Prado::localize('This action will clear bvfs cache that was created during preparing restore files. There is not recommended use this action during restore job working. Are you sure?')%>'));" ImageUrl="<%=$this->getPage()->getTheme()->getBaseUrl()%>/trash_icon.png" AlternateText="<%[ clear bvfs cache ]%>" /><com:TLabel ForControl="ClearBvfsCache"><%[ clear bvfs cache ]%></com:TLabel></a>
<a id="logging" href="javascript:void(0)"><com:TActiveCheckBox ID="Logging" OnCallback="setDebug" Attributes.onclick="return (this.checked === false || confirm('<%=Prado::localize('Debug files enable possibility to save most of actions executed on Baculum WebGUI. Debug functionality should be enabled if is happening shomething wrong with Baculum or something that looks like a bug. Logs can be useful for detecting a problems in Baculum working. After confirmation this message Baculum debug files will be continuously saving in /protected/Data/ directory. Are you sure?')%>'));" /><com:TLabel ForControl="Logging"><%[ Enable debug ]%></com:TLabel></a>
$appConfig = $this->getModule('configuration')->getApplicationConfig();
+ $this->Users->Visible = $this->User->getIsAdmin();
$this->SettingsWizardBtn->Visible = $this->User->getIsAdmin();
$this->PoolBtn->Visible = $this->User->getIsAdmin();
$this->VolumeBtn->Visible = $this->User->getIsAdmin();
$this->ClearBvfsCache->Visible = $this->User->getIsAdmin();
$this->Logging->Visible = $this->User->getIsAdmin();
+ $this->BconsoleCustomPath->Text = $appConfig['bconsole']['cfg_custom_path'];
if(!$this->IsPostBack && !$this->IsCallBack) {
$this->Logging->Checked = $this->getModule('logging')->isDebugOn();
$this->setJobsStates();
$this->setJobs();
$this->setClients();
+ $this->setUsers();
$this->setWindowOpen();
}
}
$this->Clients->dataBind();
}
+ public function setUsers() {
+ if($this->User->getIsAdmin() === true) {
+ $allUsers = $this->getModule('configuration')->getAllUsers();
+ $users = array_keys($allUsers);
+ sort($users);
+ $this->UsersList->dataSource = $users;
+ $this->UsersList->dataBind();
+ }
+ }
+
+ public function userAction($sender, $param) {
+ if($this->User->getIsAdmin() === true) {
+ list($action, $param, $value) = explode(';', $param->CallbackParameter, 3);
+ switch($action) {
+ case 'newuser':
+ case 'chpwd': {
+ $this->getmodule('configuration')->setusersconfig($param, $value);
+ $this->setUsers();
+ }
+ break;
+ case 'rmuser': {
+ if ($param != $this->User->getName()) {
+ $this->getModule('configuration')->removeUser($param);
+ $this->setUsers();
+ }
+ break;
+ }
+ }
+ }
+ }
+
public function setWindowOpen() {
if (isset($this->Request['open']) && in_array($this->Request['open'], $this->windowIds) && $this->Request['open'] != 'JobRun') {
$btn = $this->Request['open'] . 'Btn';
}
}
}
+
+ public function logout($sender, $param) {
+ $cfg = $this->getModule('configuration');
+ $http_protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http';
+ $fake_pwd = $cfg->getRandomString();
+ $cfg->switchToUser($http_protocol, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $this->User->getName(), $fake_pwd);
+ }
}
?>
float: left;
}
+#topbar {
+ background: transparent url('logo.png') no-repeat 10px center;
+ width: 100%;
+ height: 51px;
+}
+
#logo {
margin-left: 20px;
}
background-color: rgb(163, 180, 197);
}
-#graphs, #dashboard {
+#graphs, #dashboard, #users {
min-width: 954px;
max-width: 100%;
padding: 10px;
border-right: 1px solid black;
}
+#users input {
+ height: 9px;
+ margin: 0 4px;
+ font-size: 10px;
+}
+
#graphs span {
margin: 0 3px;
}
}
#jobs_to_view {
- width: 240px;
- margin: 0 2px 0 5px;
+ width: 240px;
+ margin: 0 2px 0 5px;
+}
+
+#users_list {
+ width: 720px;
+ font-size: 13px;
+}
+
+#users_list td {
+ font-style: normal;
+ padding: 3px 5px;
+}
+
+#users_list td:nth-of-type(1) {
+ font-weight: bold;
+}
+
+#users_list tr {
+ cursor: initial;
+}
+
+#users_list td:nth-of-type(1) {
+ width: 200px;
+}
+
+i#users_list td:nth-of-type(1) {
+ width: 120px;
+}
+
+#users_list td:nth-of-type(3) {
+ width: 400px;
+}
+
+#users_list img {
+ float: none;
}
/* Overwrite date picker classes */