removed room support

This commit is contained in:
Paolo Asperti 2016-09-15 09:40:25 +02:00
parent 048e5a82da
commit 744ef03534
6 changed files with 2 additions and 176 deletions

View File

@ -147,7 +147,8 @@ rm -rf %{buildroot}
* Mon Jul 18 2016 Paolo Asperti <paolo@asperti.com> - 2.0.0-1
- PHP porting
- Added a basic UI
- Added room support
- TODO prima di release: controllare se /var/log/doraemon viene creata, controllare se il link ad httpd viene creato
* Tue Oct 27 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.1-2.ns6
- Packing corrections to rpm to fix upgrading issue

View File

@ -1,9 +0,0 @@
<?php
/* /usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon_Rooms.php */
$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';

View File

@ -1,9 +0,0 @@
<?php
/* /usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon_Rooms.php */
$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';

View File

@ -1,28 +0,0 @@
<?php
namespace NethServer\Module\Doraemon;
class Rooms extends \Nethgui\Controller\TableController
{
public function initialize()
{
$columns = array(
'Key',
'Actions',
);
$this
->setTableAdapter($this->getPlatform()->getTableAdapter('rooms', 'room'))
->setColumns($columns)
->addRowAction(new \NethServer\Module\Doraemon\Rooms\Modify('update'))
->addRowAction(new \NethServer\Module\Doraemon\Rooms\Modify('delete'))
->addTableAction(new \NethServer\Module\Doraemon\Rooms\Modify('create'))
->addTableAction(new \Nethgui\Controller\Table\Help('Help'))
;
parent::initialize();
}
}

View File

@ -1,89 +0,0 @@
<?php
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
{
public function initialize()
{
$parameterSchema = array(
// was: Validate::HOSTNAME_FQDN, but we need hostname
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),
);
$this->setSchema($parameterSchema);
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') {
$v = $this->createValidator()->platform('room-delete');
if ( ! $v->evaluate($this->parameters['name'])) {
$report->addValidationError($this, 'Key', $v);
}
}
parent::validate($report);
}
protected function onParametersSaved($parameters)
{
$actionName = $this->getIdentifier();
if ($actionName === 'update') {
$actionName = 'modify';
}
$this->getPlatform()->signalEvent(sprintf('room-%s &', $actionName));
}
public function prepareView(\Nethgui\View\ViewInterface $view)
{
parent::prepareView($view);
$templates = array(
'create' => 'NethServer\Template\Doraemon\Rooms',
'update' => 'NethServer\Template\Doraemon\Rooms',
'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;
}
}

View File

@ -1,40 +0,0 @@
<?php
/* @var $view \Nethgui\Renderer\Xhtml */
$view->requireFlag($view::INSET_FORM);
if ($view->getModule()->getIdentifier() == 'update') {
// disable updating of hostname
// the hostname is the key of the db item, if you change it, bad things happens
$keyFlags = $view::STATE_DISABLED;
$template = 'Update_Room_Header';
} else {
$keyFlags = 0;
$template = 'Create_Room_Header';
}
echo $view->header('doraemon')->setAttribute('template', $view->translate($template));
echo $view->panel()
->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);
});
});
");