diff --git a/doraemon.spec b/doraemon.spec index 1d903d4..bf4793f 100644 --- a/doraemon.spec +++ b/doraemon.spec @@ -137,6 +137,8 @@ rm -rf %{buildroot} %files -f %{name}-%{version}-%{release}-filelist %defattr(0644,root,root,755) %doc README.md LICENSE.txt +%attr(0644,srvmgr,srvmgr) %ghost %{_localstatedir}/log/doraemon/access_log +%attr(0644,srvmgr,srvmgr) %ghost %{_localstatedir}/log/doraemon/error_log %changelog diff --git a/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon.php b/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon.php index 9af5b40..9c70ab3 100644 --- a/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon.php +++ b/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon.php @@ -3,7 +3,6 @@ /* /usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon.php */ $L['Doraemon_Title'] = 'Doraemon'; -$L['Key_label'] = 'Hostname'; $L['hostname_label'] = 'Hostname'; $L['MacAddress_label'] = 'MAC Address'; $L['shutdown_label'] = 'Shutdown'; diff --git a/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Hosts.php b/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Hosts.php index fb935d2..b5c5108 100644 --- a/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Hosts.php +++ b/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Hosts.php @@ -6,3 +6,4 @@ $L['Hosts_Title'] = 'Hosts'; $L['Create_Host_Header'] = 'Create a new host'; $L['Update_Host_Header'] = 'Update host "${0}"'; $L['Role_label'] = 'Role'; +$L['Key_label'] = 'Hostname'; diff --git a/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Rooms.php b/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Rooms.php index 4ff50e0..bc616fc 100644 --- a/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Rooms.php +++ b/root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Rooms.php @@ -6,3 +6,4 @@ $L['Rooms_Title'] = 'Rooms'; $L['Create_Room_Header'] = 'Create a new room'; $L['Update_Room_Header'] = 'Update room "${0}"'; $L['Name_label'] = 'Name'; +$L['Key_label'] = 'Room'; diff --git a/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon.php b/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon.php index 9d23878..812bcea 100644 --- a/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon.php +++ b/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon.php @@ -3,7 +3,6 @@ /* /usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon.php */ $L['Doraemon_Title'] = 'Doraemon'; -$L['Key_label'] = 'Hostname'; $L['hostname_label'] = 'Hostname'; $L['MacAddress_label'] = 'MAC Address'; $L['shutdown_label'] = 'Spegni'; diff --git a/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Hosts.php b/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Hosts.php index 2609f3e..a0ac122 100644 --- a/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Hosts.php +++ b/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Hosts.php @@ -6,3 +6,4 @@ $L['Hosts_Title'] = 'Hosts'; $L['Create_Host_Header'] = 'Crea un nuovo host'; $L['Update_Host_Header'] = 'Modifica il nome host "${0}"'; $L['Role_label'] = 'Ruolo'; +$L['Key_label'] = 'Hostname'; diff --git a/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Rooms.php b/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Rooms.php index 4f63a0c..91a6440 100644 --- a/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Rooms.php +++ b/root/usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Rooms.php @@ -6,3 +6,4 @@ $L['Rooms_Title'] = 'Stanze'; $L['Create_Room_Header'] = 'Crea una nuova stanza'; $L['Update_Room_Header'] = 'Modifica il nome stanza "${0}"'; $L['Name_label'] = 'Nome'; +$L['Key_label'] = 'Stanza'; diff --git a/root/usr/share/nethesis/NethServer/Module/Doraemon/Rooms/Modify.php b/root/usr/share/nethesis/NethServer/Module/Doraemon/Rooms/Modify.php index 122b7d7..6ee5e48 100644 --- a/root/usr/share/nethesis/NethServer/Module/Doraemon/Rooms/Modify.php +++ b/root/usr/share/nethesis/NethServer/Module/Doraemon/Rooms/Modify.php @@ -3,6 +3,7 @@ namespace NethServer\Module\Doraemon\Rooms; use Nethgui\System\PlatformInterface as Validate; +use Nethgui\Controller\Table\Modify as Table; class Modify extends \Nethgui\Controller\Table\Modify @@ -12,7 +13,10 @@ class Modify extends \Nethgui\Controller\Table\Modify { $parameterSchema = array( // was: Validate::HOSTNAME_FQDN, but we need hostname - array('Name', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::KEY), + array('Name', Validate::ANYTHING, Table::KEY), + array('AclRead', Validate::USERNAME_COLLECTION, Table::FIELD, 'AclRead', ','), // ACL + array('AclWrite', Validate::USERNAME_COLLECTION, Table::FIELD, 'AclWrite', ','), // ACL + // array('MacAddress', Validate::MACADDRESS, \Nethgui\Controller\Table\Modify::FIELD), // array('Role', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), // array('Role', Validate::ROLES_COLLECTION ??? TODO!!!, \Nethgui\Controller\Table\Modify::FIELD), @@ -21,6 +25,16 @@ class Modify extends \Nethgui\Controller\Table\Modify parent::initialize(); } + public function bind(\Nethgui\Controller\RequestInterface $request) + { + parent::bind($request); + if($request->isMutation()) { + // save the old values for later usage: + $this->originalAclRead = $this->getPlatform()->getDatabase('accounts')->getProp($this->parameters['ibay'], 'AclRead'); + $this->originalAclWrite = $this->getPlatform()->getDatabase('accounts')->getProp($this->parameters['ibay'], 'AclWrite'); + } + } + public function validate(\Nethgui\Controller\ValidationReportInterface $report) { if ($this->getIdentifier() === 'delete') { @@ -50,6 +64,26 @@ class Modify extends \Nethgui\Controller\Table\Modify 'delete' => 'Nethgui\Template\Table\Delete', ); $view->setTemplate($templates[$this->getIdentifier()]); + + + $owners = array(array('locals', $view->translate('locals_group_label'))); + $subjects = array(array('locals', $view->translate('locals_group_label'))); + + foreach ($this->getPlatform()->getDatabase('accounts')->getAll('group') as $keyName => $props) { + $entry = array($keyName, sprintf("%s (%s)", isset($props['Description']) ? $props['Description'] : $keyName, $keyName)); + $owners[] = $entry; + $subjects[] = $entry; + } + + $view['OwningGroupDatasource'] = $owners; + + foreach ($this->getPlatform()->getDatabase('accounts')->getAll('user') as $keyName => $props) { + $entry = array($keyName, sprintf("%s (%s)", trim($props['FirstName'] . ' ' . $props['LastName']), $keyName)); + $subjects[] = $entry; + } + + $view['AclSubjects'] = $subjects; + } } diff --git a/root/usr/share/nethesis/NethServer/Template/Doraemon/Rooms.php b/root/usr/share/nethesis/NethServer/Template/Doraemon/Rooms.php index 48ca637..723c7ef 100644 --- a/root/usr/share/nethesis/NethServer/Template/Doraemon/Rooms.php +++ b/root/usr/share/nethesis/NethServer/Template/Doraemon/Rooms.php @@ -1,5 +1,7 @@ requireFlag($view::INSET_FORM); if ($view->getModule()->getIdentifier() == 'update') { // disable updating of hostname @@ -11,11 +13,28 @@ if ($view->getModule()->getIdentifier() == 'update') { $template = 'Create_Room_Header'; } -echo $view->header('hostname')->setAttribute('template', $T($template)); +echo $view->header('doraemon')->setAttribute('template', $view->translate($template)); echo $view->panel() - ->insert($view->textInput('Name')) -// ->insert($view->textInput('Name', $keyFlags)) -; + ->insert($view->textInput('ibay', $keyFlags)) + ->insert($view->textInput('Description')) + ->insert($view->selector('OwningGroup', $view::SELECTOR_DROPDOWN)) + ->insert($view->checkBox('GroupAccess', 'rw')->setAttribute('uncheckedValue', 'r')) + ->insert($view->checkBox('OtherAccess', 'r')->setAttribute('uncheckedValue', '')) + ->insert($view->objectPicker() + ->setAttribute('objects', 'AclSubjects') + ->setAttribute('objectLabel', 1) + ->insert($view->checkBox('AclRead', FALSE, $view::STATE_CHECKED)) + ->insert($view->checkBox('AclWrite', FALSE)) +); echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_CANCEL | $view::BUTTON_HELP); + +$actionId = $view->getUniqueId(); +$view->includeJavascript(" +jQuery(function($){ + $('#${actionId}').on('nethguishow', function () { + $(this).find('.Tabs').tabs('select', 0); + }); +}); +");