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; }