public function loadItems() { $user = new IEUser(); $ui = array('0' => _('Systémový uživatel')); foreach ($user->getAllFromMySQL(EaseShared::user()->getMyTable(), array('id', 'login'), null, 'login', 'id') as $UserInfo) { $ui[$UserInfo['id']] = $UserInfo['login']; } return $ui; }
<?php /** * Icinga Editor - přehled userů * * @package IcingaEditor * @subpackage WebUI * @author Vitex <*****@*****.**> * @copyright 2012 Vitex@hippy.cz (G) */ require_once 'includes/IEInit.php'; require_once 'classes/IEHost.php'; $oPage->onlyForLogged(); $oPage->addItem(new IEPageTop(_('Přehled uživatelů'))); $oPage->addPageColumns(); $user = new IEUser(); $users = $user->getColumnsFromMySQL(array('id', 'login'), null, 'login', $oUser->getmyKeyColumn()); if ($users) { $oPage->columnII->addItem(new EaseHtmlH4Tag(_('Uživatelé'))); $cntList = new EaseHtmlTableTag(null, array('class' => 'table')); $cid = 1; foreach ($users as $cId => $cInfo) { if (!$cId) { continue; } $lastRow = $cntList->addRowColumns(array($cid++, new IEUser((int) $cId), new EaseHtmlATag('userinfo.php?user_id=' . $cId, $cInfo['login'] . ' <i class="icon-edit"></i>'), new EaseHtmlATag('apply.php?force_user_id=' . $cId, _('Přegenerovat konfiguraci') . ' <i class="icon-repeat"></i>'))); } $oPage->columnII->addItem($cntList); } $oPage->columnIII->addItem(new EaseTWBLinkButton('createaccount.php', _('Založit uživatele') . ' ' . EaseTWBPart::GlyphIcon('edit'))); $oPage->addItem(new IEPageBottom());
$hostgroup = new IEHostgroup(); $contact = new IETimeperiod(); $command = new IECommand(); $service = new IEService(); $serviceGroup = new IEServicegroup(); $ownership = $oPage->getRequestValue('ownership'); if ($ownership) { $host->switchOwners($userID, $ownership); $hostgroup->switchOwners($userID, $ownership); $contact->switchOwners($userID, $ownership); $command->switchOwners($userID, $ownership); $service->switchOwners($userID, $ownership); $serviceGroup->switchOwners($userID, $ownership); $oPage->addStatusMessage(_('Vlastnictví byla předána')); } $user = new IEUser($userID); $oPage->addItem(new IEPageTop($user->getUserName())); if ($oPage->getRequestValue('delete') == 'true') { if ($user->delete()) { $oPage->redirect('users.php'); exit; } } $userInfoFrame = $oPage->columnI->addItem(new EaseTWBPanel($user->getUserLogin())); $userInfoFrame->addItem($user); $userInfoFrame->addItem(new EaseHtmlUlTag(array($user->getUserName(), new EaseHtmlATag('mailto:' . $user->getEmail(), $user->getEmail())))); $pocTimeperiods = $contact->getMyRecordsCount($userID); if ($pocTimeperiods) { $success = $oPage->columnIII->addItem(new EaseHtmlDivTag('Timeperiod', new EaseTWBLinkButton('timeperiods.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s časových period'), $pocTimeperiods)), array('class' => 'alert alert-success'))); } $pocHostu = $host->getMyRecordsCount($userID);
/** * Uživatel autentifikující se vůči twitteru * * @param arrat $Twitter id uživatele * @param string $TwitterName jméno uživatele */ public function __construct($Twitter = null) { parent::__construct(); if (!is_null($Twitter)) { $this->Twitter = $Twitter; $this->setmyKeyColumn('twitter_id'); $this->setMyKey($Twitter->id); if (!$this->loadFromMySQL()) { $this->restoreObjectIdentity(); $this->setDataValue($this->LoginColumn, $Twitter->screen_name); $this->setSettingValue('icon', $Twitter->profile_image_url); if ($this->saveToMySQL()) { $this->addStatusMessage(_(sprintf('Vytvořeno spojení s Twitterem', $Twitter->screen_name), 'success')); $this->loginSuccess(); } } else { $this->restoreObjectIdentity(); } $this->setObjectName(); } }
} } if (strlen($password) < 5) { $error = true; $oUser->addStatusMessage(_('heslo je příliš krátké'), 'warning'); } elseif ($password != $confirmation) { $error = true; $oUser->addStatusMessage(_('kontrola hesla nesouhlasí'), 'warning'); } $usedLogin = EaseShared::myDbLink()->QueryToValue('SELECT id FROM user WHERE login=\'' . $oPage->EaseAddSlashes($login) . '\''); if ($usedLogin) { $error = true; $oUser->addStatusMessage(sprintf(_('Zadané uživatelské jméno %s je již v databázi použito. Zvolte prosím jiné.'), $login), 'warning'); } if ($error == false) { $newOUser = new IEUser(); //TODO zde by se měly doplnit defaultní hodnoty z konfiguráku registry.php $newOUser->setData(array('email' => $emailAddress, 'parent' => (int) $customerParent, 'login' => $login, 'firstname' => $firstname, 'lastname' => $lastname)); $userID = $newOUser->insertToMySQL(); if (!is_null($userID)) { $newOUser->setMyKey($userID); $newOUser->passwordChange($password); if ($userID == 0) { $newOUser->setSettingValue('admin', TRUE); $oUser->addStatusMessage(_('Administrátirský účet byl vytvořen'), 'success'); $newOUser->saveToMySQL(); } else { $oUser->addStatusMessage(_('Uživatelský účet byl vytvořen'), 'success'); } system('sudo htpasswd -b /etc/icinga/htpasswd.users ' . $newOUser->getUserLogin() . ' ' . $password); $newOUser->loginSuccess();