本文整理汇总了PHP中Notifier::updatedUserAccount方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifier::updatedUserAccount方法的具体用法?PHP Notifier::updatedUserAccount怎么用?PHP Notifier::updatedUserAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifier
的用法示例。
在下文中一共展示了Notifier::updatedUserAccount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_user_account
/**
* Edit the contact's user account
*
* @access public
* @param void
* @return null
*/
function edit_user_account()
{
$this->setTemplate('add_user_to_contact');
$contact = Contacts::findById(get_id());
if (!$contact instanceof Contact) {
flash_error(lang('contact dnx'));
$this->redirectTo('dashboard', 'contacts');
}
// if
if (!$contact->canEditUserAccount(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectTo('dashboard', 'contacts');
}
// if
if (!$contact->hasUserAccount()) {
flash_error(lang('user dnx'));
$this->redirectToUrl($contact->getCompany()->getViewUrl());
}
$user = $contact->getUserAccount();
$company = $contact->getCompany();
$user_data = array_var($_POST, 'user');
if (!is_array($user_data)) {
$user_data = array('username' => $user->getUsername(), 'email' => $user->getEmail(), 'timezone' => $user->getTimezone(), 'locale' => $user->getLocale(), 'is_admin' => $user->isAdministrator(), 'auto_assign' => $user->getAutoAssign(), 'use_LDAP' => $user->getUseLDAP(), 'can_manage_projects' => $user->canManageProjects() ? '1' : '0');
// array
}
// if
tpl_assign('contact', $contact);
tpl_assign('user', $user);
tpl_assign('company', $company);
tpl_assign('user_data', $user_data);
if (is_array(array_var($_POST, 'user'))) {
$user->setFromAttributes($user_data);
try {
$password = '';
// Generate random password
if (array_var($user_data, 'password_generator') == 'random') {
$password = substr(sha1(uniqid(rand(), true)), rand(0, 25), 13);
$user->setPassword($password);
// Validate user input
} else {
if (array_var($user_data, 'password_generator') == 'specify') {
$password = array_var($user_data, 'password');
if (trim($password) == '') {
throw new Error(lang('password value required'));
}
// if
if ($password != array_var($user_data, 'password_a')) {
throw new Error(lang('passwords dont match'));
}
// if
$user->setPassword($password);
}
}
// if
$granted = 0;
if (logged_user()->isAdministrator()) {
$user->setIsAdmin(array_var($user_data, 'is_admin'));
$user->setAutoAssign(array_var($user_data, 'auto_assign'));
$granted = trim(array_var($user_data, 'can_manage_projects')) == '1' ? 1 : 0;
} else {
$user->setIsAdmin(0);
$user->setAutoAssign(0);
}
DB::beginWork();
$user->save();
$user->setPermission(PermissionManager::CAN_MANAGE_PROJECTS, $granted);
ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_EDIT);
DB::commit();
// Send notification...
try {
if (array_var($user_data, 'send_email_notification')) {
Notifier::updatedUserAccount($user, $password);
}
// if
} catch (Exception $e) {
}
// try
flash_success(lang('success edit user', $user->getDisplayName()));
$this->redirectToUrl($company->getViewUrl());
// Translate to profile page
} catch (Exception $e) {
DB::rollback();
tpl_assign('error', $e);
}
// try
}
// if
}