2015-07-02 14:13:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Forms;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
2015-07-31 17:02:52 +02:00
|
|
|
use Icinga\Authentication\Auth;
|
2015-07-02 14:13:42 +02:00
|
|
|
|
|
|
|
class DirectorDatalistForm extends DirectorObjectForm
|
|
|
|
{
|
|
|
|
public function setup()
|
|
|
|
{
|
|
|
|
$this->addElement('text', 'list_name', array(
|
2015-07-31 17:13:07 +02:00
|
|
|
'label' => $this->translate('List name'),
|
|
|
|
'required' => true,
|
2015-07-02 14:13:42 +02:00
|
|
|
));
|
2015-07-03 14:00:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function onSuccess()
|
|
|
|
{
|
2015-07-31 17:19:17 +02:00
|
|
|
$this->object()->owner = self::username();
|
2015-07-03 14:00:40 +02:00
|
|
|
parent::onSuccess();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static function username()
|
|
|
|
{
|
|
|
|
$auth = Auth::getInstance();
|
|
|
|
if ($auth->isAuthenticated()) {
|
|
|
|
return $auth->getUser()->getUsername();
|
|
|
|
} else {
|
|
|
|
return '<unknown>';
|
|
|
|
}
|
2015-07-02 14:13:42 +02:00
|
|
|
}
|
|
|
|
}
|