diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc
index d27045db6de1115392671ada830b8673a581bcf1..c4ca4e77bf5001b6a47bf22452925c4d623f4b39 100644 (file)
var $got_uid = "";
var $edit_uid = "";
var $got_uid = "";
var $edit_uid = "";
+ var $pwd_change_queue = array();
+ var $force_hash_type = array();
+
// Tab definition
protected $tabClass = "usertabs";
protected $tabType = "USERTABS";
// Tab definition
protected $tabClass = "usertabs";
protected $tabType = "USERTABS";
protected $aclPlugin = "user";
protected $objectName = "user";
protected $aclPlugin = "user";
protected $objectName = "user";
+ protected $releaseSelector = NULL;
+
function __construct($config,$ui)
{
$this->config = $config;
$this->ui = $ui;
function __construct($config,$ui)
{
$this->config = $config;
$this->ui = $ui;
-
+
+ $this->storagePoints = array(get_ou("userRDN"));
+
// Build filter
// Build filter
- $filter = new filter(get_template_path("user-filter.xml", true));
- $filter->setObjectStorage("ou=people,");
+ if (session::global_is_set(get_class($this)."_filter")){
+ $filter= session::global_get(get_class($this)."_filter");
+ } else {
+ $filter = new filter(get_template_path("user-filter.xml", true));
+ $filter->setObjectStorage($this->storagePoints);
+ }
$this->setFilter($filter);
// Build headpage
$headpage = new listing(get_template_path("user-list.xml", true));
$headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
$headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
$this->setFilter($filter);
// Build headpage
$headpage = new listing(get_template_path("user-list.xml", true));
$headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
$headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
+ $headpage->registerElementFilter("filterProperties", "userManagement::filterProperties");
$headpage->setFilter($filter);
// Add copy&paste and snapshot handler.
$headpage->setFilter($filter);
// Add copy&paste and snapshot handler.
parent::__construct($config, $ui, "users", $headpage);
parent::__construct($config, $ui, "users", $headpage);
- $this->registerAction("new", "newEntry");
- $this->registerAction("edit", "editEntry");
- $this->registerAction("apply", "applyChanges");
- $this->registerAction("save", "saveChanges");
- $this->registerAction("cancel", "cancelEdit");
- $this->registerAction("remove", "removeEntryRequested");
- $this->registerAction("removeConfirmed", "removeEntryConfirmed");
-
- $this->registerAction("copy", "copyPasteHandler");
- $this->registerAction("cut", "copyPasteHandler");
- $this->registerAction("paste", "copyPasteHandler");
-
// Register special user actions
$this->registerAction("lock", "lockEntry");
$this->registerAction("lockUsers", "lockUsers");
// Register special user actions
$this->registerAction("lock", "lockEntry");
$this->registerAction("lockUsers", "lockUsers");
$this->registerAction("templatize", "templatizeUsers");
$this->registerAction("templatizeContinue", "templatizeContinue");
$this->registerAction("templatize", "templatizeUsers");
$this->registerAction("templatizeContinue", "templatizeContinue");
+ $this->registerAction("password", "changePassword");
+ $this->registerAction("passwordQueue", "handlePasswordQueue");
+ $this->registerAction("passwordCancel", "closeDialogs");
+
$this->registerAction("sendMessage", "sendMessage");
$this->registerAction("saveEventDialog", "saveEventDialog");
$this->registerAction("abortEventDialog", "closeDialogs");
$this->registerAction("sendMessage", "sendMessage");
$this->registerAction("saveEventDialog", "saveEventDialog");
$this->registerAction("abortEventDialog", "closeDialogs");
+
+ // Register shortcut icon actions
+ $this->registerAction("edit_user","editEntry");
+ $this->registerAction("edit_posixAccount","editEntry");
+ $this->registerAction("edit_mailAccount","editEntry");
+ $this->registerAction("edit_sambaAccount","editEntry");
+ $this->registerAction("edit_netatalk","editEntry");
+ $this->registerAction("edit_environment","editEntry");
+ $this->registerAction("edit_gofaxAccount","editEntry");
+ $this->registerAction("edit_phoneAccount","editEntry");
+
+
+ $rel = array("a" => "/");
+ $rel['b,a'] = "test";
+ $rel['c,a'] = "test/f";
+
+ $this->releaseSelector = new releaseSelector($rel, "a");
+ }
+
+
+ function renderList()
+ {
+ $smarty = get_smarty();
+ $smarty->assign("RELEASE", $this->releaseSelector->render());
+ return(management::renderList());
}
}
+
// Inject user actions
function detectPostActions()
{
// Inject user actions
function detectPostActions()
{
if(isset($_POST['templatize_continue'])) $action['action'] = "templatizeContinue";
if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
if(isset($_POST['templatize_continue'])) $action['action'] = "templatizeContinue";
if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
+ if(isset($_POST['password_cancel'])){
+ $action['action'] = "passwordCancel";
+ }elseif((count($this->pwd_change_queue) || isset($_POST['password_finish']))){
+ $action['action'] = "passwordQueue";
+ }
return($action);
}
return($action);
}
+ function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+ {
+ $str = management::editEntry($action,$target);
+ if($str) return($str);
+
+ if(preg_match("/^edit_/",$action)){
+ $tab = preg_replace("/^edit_/","",$action);
+ if(isset($this->tabObject->by_object[$tab])){
+ $this->tabObject->current = $tab;
+ }else{
+ trigger_error("Unknown tab: ".$tab);
+ }
+ }
+ }
+
+
+ function closeDialogs()
+ {
+ management::closeDialogs();
+ $this->pwd_change_queue = array();
+ }
+
+
/*! \brief Sends a message to a set of users using gosa-si events.
*/
function sendMessage($action="",$target=array(),$all=array())
/*! \brief Sends a message to a set of users using gosa-si events.
*/
function sendMessage($action="",$target=array(),$all=array())
}
}
+ /*! \brief Queues a set of users for password changes
+ */
+ function changePassword($action="",$target=array(),$all=array())
+ {
+ $this->dn ="";
+ $this->pwd_change_queue = $target;
+
+ // Check permisions
+ $disallowed = array();
+ foreach($this->pwd_change_queue as $key => $dn){
+ if(!preg_match("/w/",$this->ui->get_permissions($dn,$this->aclCategory."/password"))){
+ unset($this->pwd_change_queue[$key]);
+ $disallowed[] = $dn;
+ }
+ }
+ if(count($disallowed)){
+ msg_dialog::display(_("Permission"),msgPool::permModify($disallowed),INFO_DIALOG);
+ }
+
+ // Now display change dialog.
+ return($this->handlePasswordQueue());
+ }
+
+
+ function handlePasswordQueue()
+ {
+ $smarty = get_smarty();
+
+ // Get next entry from queue.
+ if(empty($this->dn) && count($this->pwd_change_queue)){
+ $this->dn = array_pop($this->pwd_change_queue);
+ set_object_info($this->dn);
+ return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
+ }
+
+ // Check permissions
+ $dn = $this->dn;
+ $acl = $this->ui->get_permissions($dn, "users/password");
+ $cacl= $this->ui->get_permissions($dn, "users/user");
+ if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){
+ $message= array();
+ if ($_POST['new_password'] != $_POST['repeated_password']){
+ $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
+ } else {
+ if ($_POST['new_password'] == ""){
+ $message[] = msgPool::required(_("New password"));
+ }
+ }
+
+ // Display errors
+ if (count($message) != 0){
+ msg_dialog::displayChecks($message);
+ return($smarty->fetch(get_template_path('password.tpl', TRUE)));
+ }
+
+ // Change cassword
+ if(isset($this->force_hash_type[$this->dn])){
+ if(!change_password ($this->dn, $_POST['new_password'],0,$this->force_hash_type[$this->dn])){
+ return($smarty->fetch(get_template_path('password.tpl', TRUE)));
+ }
+ }else{
+ if(!change_password ($this->dn, $_POST['new_password'])){
+ return($smarty->fetch(get_template_path('password.tpl', TRUE)));
+ }
+ }
+ if ($this->config->get_cfg_value("passwordHook") != ""){
+ exec($this->config->get_cfg_value("passwordHook")." ".$username." ".$_POST['new_password'], $resarr);
+ }
+ new log("modify","users/".get_class($this),$this->dn,array(),"Password has been changed");
+ $this->dn ="";
+
+ } else {
+ msg_dialog::display(_("Password change"),
+ _("You have no permission to change this users password!"),
+ WARNING_DIALOG);
+ }
+
+ // Cleanup
+ if(!count($this->pwd_change_queue)){
+ $this->remove_lock();
+ $this->closeDialogs();
+ }else{
+ return($this->handlePasswordQueue());
+ }
+ }
+
+
+ /*! \brief Save user modifications.
+ * Whenever we save a 'new' user, request a password change for him.
+ */
+ function saveChanges()
+ {
+ $str = management::saveChanges();
+
+ if(!empty($str)) return($str);
+
+ if($this->last_tabObject instanceOf multi_plug){
+ foreach($this->last_tabObject->a_handles as $user){
+ if($user->password_change_needed()){
+ $this->force_hash_type[$user->dn] = $user->by_object['user']->pw_storage;
+ $this->pwd_change_queue[] = $user->dn;
+ }
+ }
+ return($this->handlePasswordQueue());
+ }
+
+ if(isset($this->last_tabObject->by_object['user']) && $this->last_tabObject->by_object['user']->password_change_needed()){
+ $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
+ $this->pwd_change_queue[] = $this->last_tabObject->dn;
+ return($this->handlePasswordQueue());
+ }
+ }
+
+ function cancelEdit()
+ {
+ $str = management::cancelEdit();
+ if(!empty($str)) return($str);
+
+ if(isset($this->last_tabObject->by_object['user']) &&
+ $this->last_tabObject->by_object['user']->dn != "new" &&
+ $this->last_tabObject->by_object['user']->password_change_needed()){
+ $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
+ $this->pwd_change_queue[] = $this->last_tabObject->dn;
+ return($this->handlePasswordQueue());
+ }
+ }
+
+
/*! \brief Intiates user creation.
* If we've user templates, then the user will be asked to use to use one.
* -> See 'templateContinue' for further handling.
/*! \brief Intiates user creation.
* If we've user templates, then the user will be asked to use to use one.
* -> See 'templateContinue' for further handling.
function newUserFromTemplate($action="",$target=array(),$all=array())
{
// Call parent method, it knows whats to do, locking and so on ...
function newUserFromTemplate($action="",$target=array(),$all=array())
{
// Call parent method, it knows whats to do, locking and so on ...
- management::newEntry($action,$target,$all);
+ $str = management::newEntry($action,$target,$all);
+ if(!empty($str)) return($str);
// Reset uid selection.
$this->got_uid= "";
// Reset uid selection.
$this->got_uid= "";
* if he wants to use one.
* -> See 'templateContinue' for further handling.
*/
* if he wants to use one.
* -> See 'templateContinue' for further handling.
*/
- function newEntry($action="",$target=array(),$all=array())
+ function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
{
// Call parent method, it manages everything, locking, object creation...
{
// Call parent method, it manages everything, locking, object creation...
- management::newEntry($action,$target,$all);
+ $str = management::newEntry($action,$target,$all);
+ if(!empty($str)) return($str);
// If we've at least one template, then ask the user if he wants to use one?
$templates = array();
// If we've at least one template, then ask the user if he wants to use one?
$templates = array();
$templates = array_merge($templates,$this->get_templates());
// Display template selection
$templates = array_merge($templates,$this->get_templates());
// Display template selection
- if (count($templates)){
+ if (count($templates) > 1){
$smarty = get_smarty();
// Set default variables, normally empty.
$smarty = get_smarty();
// Set default variables, normally empty.
// Adapt template values.
$template_dn = $_POST['template'];
$this->tabObject->adapt_from_template($template_dn, array("uid","cn","givenName","sn"));
// Adapt template values.
$template_dn = $_POST['template'];
$this->tabObject->adapt_from_template($template_dn, array("uid","cn","givenName","sn"));
- $template_base = preg_replace("/^[^,]+,".preg_quote(get_people_ou(), '/')."/", '', $template_dn);
+ $template_base = preg_replace("/^[^,]+,".preg_quote(get_people_ou(), '/i')."/", '', $template_dn);
$this->tabObject->by_object['user']->base= $template_base;
// The user Tab object is already instantiated, so just go back and let the
$this->tabObject->by_object['user']->base= $template_base;
// The user Tab object is already instantiated, so just go back and let the
// Check entry locking
foreach($target as $dn){
if (($user= get_lock($dn)) != ""){
// Check entry locking
foreach($target as $dn){
if (($user= get_lock($dn)) != ""){
+ $this->dn = $dn;
return(gen_locked_message ($user, $dn));
}
$this->dns[] = $dn;
return(gen_locked_message ($user, $dn));
}
$this->dns[] = $dn;
*/
function lockUsers($action,$target,$all)
{
*/
function lockUsers($action,$target,$all)
{
+ if(!count($target)) return;
if($action == "lockUsers"){
$this->lockEntry($action,$target, $all, "lock");
}else{
if($action == "lockUsers"){
$this->lockEntry($action,$target, $all, "lock");
}else{
}
}
+ function copyPasteHandler($action="",$target=array(),$all=array(),
+ $altTabClass ="", $altTabType = "", $altAclCategory="",$altAclPlugin="")
+ {
+ if ($this->config->boolValueIsTrue("main", "copyPaste")){
+ $this->cpHandler->lastdn = "";
+ $str = management::copyPasteHandler($action,$target,$all);
+ if($this->cpHandler->lastdn != "" && isset($_POST['passwordTodo']) && $_POST['passwordTodo'] == "new"){
+ $this->pwd_change_queue[] = $this->cpHandler->lastdn;
+ return($this->handlePasswordQueue());
+ }
+ return($str);
+ }
+
+ return "";
+ }
+
+
static function filterLockImage($userPassword)
{
$image= "images/empty.png";
static function filterLockImage($userPassword)
{
$image= "images/empty.png";
}
return $label;
}
}
return $label;
}
+
+
+ static function filterProperties($row, $classes)
+ {
+ $result= "";
+ $map= array( "gosaAccount" => array( "image" => "plugins/users/images/select_user.png",
+ "plugin" => "user",
+ "alt" => _("Generic"),
+ "title" => _("Edit generic properties")),
+ "posixAccount" => array("image" => "images/penguin.png",
+ "plugin" => "posixAccount",
+ "alt" => _("POSIX"),
+ "title" => _("Edit POSIX properties")),
+ "gosaMailAccount" => array("image" => "images/mailto.png",
+ "alt" => _("Mail"),
+ "plugin" => "mailAccount",
+ "title" => _("Edit mail properties")),
+ "sambaSamAccount" => array("image" => "plugins/systems/images/select_winstation.png",
+ "plugin" => "sambaAccount",
+ "alt" => _("Samba"),
+ "title" => _("Edit samba properties")),
+ "apple-user" => array("image" => "plugins/netatalk/images/select_netatalk.png",
+ "plugin" => "netatalk",
+ "alt" => _("Netatalk"),
+ "title" => _("Edit netatalk properties")),
+ "gotoEnvironment" => array("image" => "plugins/users/images/small_environment.png",
+ "plugin" => "environment",
+ "alt" => _("Environment"),
+ "title" => _("Edit environment properties")),
+ "goFaxAccount" => array("image" => "plugins/users/images/fax_small.png",
+ "plugin" => "gofaxAccount",
+ "alt" => _("FAX"),
+ "title" => _("Edit FAX properties")),
+ "goFonAccount" => array("image" => "plugins/gofon/images/select_phone.png",
+ "plugin" => "phoneAccount",
+ "alt" => _("Phone"),
+ "title" => _("Edit phone properties")));
+
+ // Walk thru map
+ foreach ($map as $oc => $properties) {
+ if (in_array_ics($oc, $classes)) {
+ $result.= image($properties['image'], "listing_edit_".$properties['plugin']."_$row", $properties['title']);
+ } else {
+ $result.= image('images/empty.png');
+ }
+ }
+ return $result;
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>