/** * Create useraccount on login for SSO/ntlm * * @return void */ public function auto_addaccount() { $account_lid = $GLOBALS['hook_values']['account_lid']; if (!$GLOBALS['phpgw']->accounts->exists($account_lid)) { $config = CreateObject('phpgwapi.config', 'frontend'); $config->read(); $autocreate_user = isset($config->config_data['autocreate_user']) && $config->config_data['autocreate_user'] ? $config->config_data['autocreate_user'] : 0; if ($autocreate_user) { $fellesdata_user = frontend_bofellesdata::get_instance()->get_user($account_lid); if ($fellesdata_user) { // Read default assign-to-group from config $default_group_id = isset($config->config_data['frontend_default_group']) && $config->config_data['frontend_default_group'] ? $config->config_data['frontend_default_group'] : 0; $group_lid = $GLOBALS['phpgw']->accounts->name2id($default_group_id); $group_lid = $group_lid ? $group_lid : 'frontend_delegates'; $password = '******' . mt_rand(100, mt_getrandmax()) . '&'; $account_id = frontend_bofrontend::create_delegate_account($account_lid, $fellesdata_user['firstname'], $fellesdata_user['lastname'], $password, $group_lid); if ($account_id) { $GLOBALS['phpgw']->redirect_link('/login.php', array()); } } } } }
public function add_delegate(int $account_id, $org_unit_id, $org_name) { $config = CreateObject('phpgwapi.config', 'rental'); $config->read(); $use_fellesdata = $config->config_data['use_fellesdata']; if (!$use_fellesdata) { return; } if (!isset($account_id) || $account_id == '') { //User is only registered in Fellesdata $username = phpgw::get_var('username'); $firstname = phpgw::get_var('firstname'); $lastname = phpgw::get_var('lastname'); // $password = '******'; $password = '******' . mt_rand(100, mt_getrandmax()) . '&'; $account_id = frontend_bofrontend::create_delegate_account($username, $firstname, $lastname, $password); if (isset($account_id) && !is_numeric($account_id)) { return false; } } return frontend_bofrontend::add_delegate($account_id, null, $org_unit_id, $org_name); }
public function add_delegate(int $account_id, $org_unit_id, $org_name) { $config = CreateObject('phpgwapi.config', 'rental'); $config->read(); $use_fellesdata = $config->config_data['use_fellesdata']; if (!isset($account_id) || $account_id == '' && $use_fellesdata) { //User is only registered in Fellesdata $username = phpgw::get_var('username'); $firstname = phpgw::get_var('firstname'); $lastname = phpgw::get_var('lastname'); $password = '******'; $account_id = frontend_bofrontend::create_delegate_account($username, $firstname, $lastname, $password); if (isset($account_id) && !is_numeric($account_id)) { return false; } } $success = frontend_bofrontend::add_delegate($account_id, null, $org_unit_id, $org_name); if ($success) { //Retrieve the usernames $user_account = $GLOBALS['phpgw']->accounts->get($account_id); $owner_account = $GLOBALS['phpgw']->accounts->get($GLOBALS['phpgw_info']['user']['account_id']); $user_name = $user_account->__get('lid'); $owner_name = $owner_account->__get('lid'); $org_name_string = $org_name; //If the usernames are set retrieve account data from Fellesdata if (isset($user_name) && $user_name != '' && $owner_name && $owner_name != '' && $use_fellesdata) { $fellesdata_user = frontend_bofellesdata::get_instance()->get_user($user_name); $fellesdata_owner = frontend_bofellesdata::get_instance()->get_user($owner_name); if ($fellesdata_user && $fellesdata_owner) { //Send email notification to delegate $email = $fellesdata_user['email']; if (isset($email) && $email != '') { $title = lang('email_add_delegate_title'); $message = lang('email_add_delegate_message', $fellesdata_user['firstname'], $fellesdata_user['lastname'], $fellesdata_owner['firstname'], $fellesdata_owner['lastname'], $org_name_string); frontend_bofrontend::send_system_message($email, $title, $message); return true; } } } } return false; }