LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another user');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to user list');
}
/**
* Returns the alias name of this account type.
*
* @return string alias name
*/
function getAlias() {
return _("Users");
}
/**
* Returns the description of this account type.
*
* @return string description
*/
function getDescription() {
return _("User accounts (e.g. Unix, Samba and Kolab)");
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "lamUserList";
}
/**
* Returns the default attribute list for this account type.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "#uid;#givenName;#sn;#uidNumber;#gidNumber";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array (
"uid" => _("User ID"),
"uidnumber" => _("UID number"),
"gidnumber" => _("GID number"),
"cn" => _("User name"),
"host" => _("Allowed hosts"),
"givenname" => _("First name"),
"sn" => _("Last name"),
"homedirectory" => _("Home directory"),
"loginshell" => _("Login shell"),
"mail" => _("Email"),
"gecos" => _("Description"),
"jpegphoto" => _('Photo'),
'shadowexpire' => _('Password expiration'),
'sambakickofftime' => _('Account expiration date')
);
}
/**
* Returns the the title text for the title bar on the new/edit page.
*
* @param accountContainer $container account container
* @return String title text
*/
public function getTitleBarTitle($container) {
// get attributes
$personalAttributes = null;
if ($container->getAccountModule('inetOrgPerson') != null) {
$personalAttributes = $container->getAccountModule('inetOrgPerson')->getAttributes();
}
$accountAttributes = null;
if ($container->getAccountModule('account') != null) {
$accountAttributes = $container->getAccountModule('account')->getAttributes();
}
$sambaAttributes = null;
if ($container->getAccountModule('sambaSamAccount') != null) {
$sambaAttributes = $container->getAccountModule('sambaSamAccount')->getAttributes();
}
$unixAttributes = null;
if ($container->getAccountModule('posixAccount') != null) {
$unixAttributes = $container->getAccountModule('posixAccount')->getAttributes();
}
// check if first and last name can be shown
if (($personalAttributes != null) && isset($personalAttributes['sn'][0]) && isset($personalAttributes['givenName'][0])) {
return htmlspecialchars($personalAttributes['givenName'][0] . ' ' . $personalAttributes['sn'][0]);
}
// check if a display name is set
if (($sambaAttributes != null) && isset($sambaAttributes['displayName'][0])) {
return htmlspecialchars($sambaAttributes['displayName'][0]);
}
// check if a common name is set
if (($personalAttributes != null) && isset($personalAttributes['cn'][0])) {
return htmlspecialchars($personalAttributes['cn'][0]);
}
if (($unixAttributes != null) && isset($unixAttributes['cn'][0])) {
return htmlspecialchars($unixAttributes['cn'][0]);
}
// check if a user name is set
if (($unixAttributes != null) && isset($unixAttributes['uid'][0])) {
return htmlspecialchars($unixAttributes['uid'][0]);
}
if (($personalAttributes != null) && isset($personalAttributes['uid'][0])) {
return htmlspecialchars($personalAttributes['uid'][0]);
}
if (($accountAttributes != null) && isset($accountAttributes['uid'][0])) {
return htmlspecialchars($accountAttributes['uid'][0]);
}
if ($container->isNewAccount) {
return _("New user");
}
// fall back to default
return parent::getTitleBarTitle($container);
}
/**
* Returns the the title text for the title bar on the new/edit page.
*
* @param accountContainer $container account container
* @return String title text
*/
public function getTitleBarSubtitle($container) {
$personalAttributes = null;
if ($container->getAccountModule('inetOrgPerson') != null) {
$personalAttributes = $container->getAccountModule('inetOrgPerson')->getAttributes();
}
if ($personalAttributes == null) {
return $this->buildAccountStatusIcon($container);
}
$subtitle = $this->buildAccountStatusIcon($container);
$spacer = ' ';
// check if an email address can be shown
if (isset($personalAttributes['mail'][0])) {
$subtitle .= '' . htmlspecialchars($personalAttributes['mail'][0]) . '' . $spacer;
}
// check if an telephone number can be shown
if (isset($personalAttributes['telephoneNumber'][0])) {
$subtitle .= _('Telephone number') . ' ' . htmlspecialchars($personalAttributes['telephoneNumber'][0]) . $spacer;
}
// check if an mobile number can be shown
if (isset($personalAttributes['mobile'][0])) {
$subtitle .= _('Mobile number') . ' ' . htmlspecialchars($personalAttributes['mobile'][0]);
}
if ($subtitle == '') {
return null;
}
return $subtitle;
}
/**
* Builds the HTML code for the icon that shows the account status (locked/unlocked).
*
* @param accountContainer $container account container
* @return String HTML code for icon
*/
private function buildAccountStatusIcon($container) {
// check if there are account parts that can be locked
$unixAvailable = ($container->getAccountModule('posixAccount') != null) && $container->getAccountModule('posixAccount')->isLockable();
$sambaAvailable = (($container->getAccountModule('sambaSamAccount') != null) && $container->getAccountModule('sambaSamAccount')->isExtensionEnabled());
$ppolicyAvailable = ($container->getAccountModule('ppolicyUser') != null);
if (!$unixAvailable && !$sambaAvailable && !$ppolicyAvailable) {
return '';
}
// get locking status
$unixLocked = false;
if ($unixAvailable && $container->getAccountModule('posixAccount')->isLocked()) {
$unixLocked = true;
}
$sambaLocked = false;
if ($sambaAvailable && $container->getAccountModule('sambaSamAccount')->isDeactivated()) {
$sambaLocked = true;
}
$ppolicyLocked = false;
if ($ppolicyAvailable && $container->getAccountModule('ppolicyUser')->isLocked()) {
$ppolicyLocked = true;
}
$partiallyLocked = $unixLocked || $sambaLocked || $ppolicyLocked;
$fullyLocked = ($unixAvailable || $sambaAvailable || $ppolicyAvailable)
&& (!$unixAvailable || $unixLocked)
&& (!$sambaAvailable || $sambaLocked)
&& (!$ppolicyAvailable || $ppolicyLocked);
// build tooltip
$icon = 'unlocked.png';
if ($fullyLocked) {
$icon = 'lock.png';
}
elseif ($partiallyLocked) {
$icon = 'partiallyLocked.png';
}
$statusTable = '
';
// Unix
if ($unixAvailable) {
$unixIcon = 'unlocked.png';
if ($unixLocked) {
$unixIcon = 'lock.png';
}
$statusTable .= '
' . _('Unix') . '
';
}
// Samba
if ($sambaAvailable) {
$sambaIcon = 'unlocked.png';
if ($sambaLocked) {
$sambaIcon = 'lock.png';
}
$statusTable .= '
' . _('Samba 3') . '
';
}
// PPolicy
if ($ppolicyAvailable) {
$ppolicyIcon = 'unlocked.png';
if ($ppolicyLocked) {
$ppolicyIcon = 'lock.png';
}
$statusTable .= '
' . _('Password policy') . '
';
}
$statusTable .= '
';
$tipContent = $statusTable;
$tipContent .= ' ';
$tipContent .= _('Please click to lock/unlock this account.');
$tooltip = "'" . $tipContent . "', TITLE, '" . _('Account status') . "'";
$dialogDiv = $this->buildAccountStatusDialogDiv($unixAvailable, $unixLocked, $sambaAvailable, $sambaLocked, $ppolicyAvailable, $ppolicyLocked);
$onClick = 'onclick="showConfirmationDialog(\'' . _('Change account status') . '\', \'' . _('Ok') . '\', \'' . _('Cancel') . '\', \'lam_accountStatusDialog\', \'inputForm\', \'lam_accountStatusResult\');"';
return $dialogDiv . ' ';
}
/**
* Builds the dialog to (un)lock parts of an account.
*
* @param boolean $unixAvailable Unix part is active
* @param boolean $unixLocked Unix part is locked
* @param boolean $sambaAvailable Samba part is active
* @param boolean $sambaLocked Samba part is locked
* @param boolean $ppolicyAvailable PPolicy part is active
* @param boolean $ppolicyLocked PPolicy part is locked
*/
private function buildAccountStatusDialogDiv($unixAvailable, $unixLocked, $sambaAvailable, $sambaLocked, $ppolicyAvailable, $ppolicyLocked) {
$partiallyLocked = $unixLocked || $sambaLocked || $ppolicyLocked;
$fullyLocked = ($unixAvailable || $sambaAvailable || $ppolicyAvailable)
&& (!$unixAvailable || $unixLocked)
&& (!$sambaAvailable || $sambaLocked)
&& (!$ppolicyAvailable || $ppolicyLocked);
$dialog = '