当前位置: 首页>>代码示例>>PHP>>正文


PHP Notifier::newUserAccount方法代码示例

本文整理汇总了PHP中Notifier::newUserAccount方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifier::newUserAccount方法的具体用法?PHP Notifier::newUserAccount怎么用?PHP Notifier::newUserAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notifier的用法示例。


在下文中一共展示了Notifier::newUserAccount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_user_account

 /**
  * Create and attach a user account to the contact
  * 
  * @access public
  * @param void
  * @return null
  */
 function add_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->canAddUserAccount(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('dashboard', 'contacts');
     }
     // if
     if ($contact->hasUserAccount()) {
         flash_error(lang('contact already has user'));
         $this->redirectToUrl($contact->getCardUrl());
     }
     $user = new User();
     $company = $contact->getCompany();
     $user_data = array_var($_POST, 'user');
     if (!is_array($user_data)) {
         $user_data = array('email' => $contact->getEmail(), 'password_generator' => 'random', 'timezone' => $company->getTimezone());
         // array
     }
     // if
     $projects = $company->getProjects();
     $permissions = PermissionManager::getPermissionsText();
     tpl_assign('contact', $contact);
     tpl_assign('user', $user);
     tpl_assign('company', $company);
     tpl_assign('projects', $projects);
     tpl_assign('permissions', $permissions);
     tpl_assign('user_data', $user_data);
     if (is_array(array_var($_POST, 'user'))) {
         $user->setFromAttributes($user_data);
         try {
             // Generate random password
             if (array_var($user_data, 'password_generator') == 'random') {
                 $password = substr(sha1(uniqid(rand(), true)), rand(0, 25), 13);
                 // Validate user input
             } else {
                 $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
             }
             // if
             $user->setPassword($password);
             $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);
             $contact->setUserId($user->getId());
             $contact->save();
             ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_ADD);
             if (is_array($projects)) {
                 foreach ($projects as $project) {
                     if (array_var($user_data, 'project_permissions_' . $project->getId()) == 'checked') {
                         $relation = new ProjectUser();
                         $relation->setProjectId($project->getId());
                         $relation->setUserId($user->getId());
                         foreach ($permissions as $permission => $permission_text) {
                             $permission_value = array_var($user_data, 'project_permission_' . $project->getId() . '_' . $permission) == 'checked';
                             $setter = 'set' . Inflector::camelize($permission);
                             $relation->{$setter}($permission_value);
                         }
                         // foreach
                         $relation->save();
                     }
                     // if
                 }
                 // forech
             }
             // if
             DB::commit();
             // Send notification...
             try {
                 if (array_var($user_data, 'send_email_notification')) {
                     Notifier::newUserAccount($user, $password);
//.........这里部分代码省略.........
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:101,代码来源:ContactsController.class.php

示例2: create_user


//.........这里部分代码省略.........
			}
			
		}
		
	}
	if(!isset($_POST['sys_perm'])){
		$rol_permissions=SystemPermissions::getRolePermissions(array_var($user_data, 'type'));
		$_POST['sys_perm']=array();
		foreach($rol_permissions as $pr){
			$_POST['sys_perm'][$pr]=1;
		}
		
	}
	if(!isset($_POST['mod_perm'])){
		$tabs_permissions=TabPanelPermissions::getRoleModules(array_var($user_data, 'type'));
		$_POST['mod_perm']=array();
		foreach($tabs_permissions as $pr){
			$_POST['mod_perm'][$pr]=1;
		}
	}
        
    $password = '';
	if (array_var($user_data, 'password_generator') == 'specify') {
		$perform_password_validation = true;
		// Validate input
		$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
	} else {
		$user_data['password_generator'] = 'link';
		$perform_password_validation = false;
	}

	$contact->setPassword($password);   
	$contact->save();

	$user_password = new ContactPassword();
	$user_password->setContactId($contact->getId());
	$user_password->setPasswordDate(DateTimeValueLib::now());
	$user_password->setPassword(cp_encrypt($password, $user_password->getPasswordDate()->getTimestamp()));
	$user_password->password_temp = $password;
	$user_password->perform_validation = $perform_password_validation;
	$user_password->save();
        
	if (array_var($user_data, 'autodetect_time_zone', 1) == 1) {
		set_user_config_option('autodetect_time_zone', 1, $contact->getId());
	}
	
	/* create contact for this user*/

	ApplicationLogs::createLog($contact, ApplicationLogs::ACTION_ADD);

	// Set role permissions for active members
	$active_context = active_context();
	$sel_members = array();
	foreach ($active_context as $selection) {
		if ($selection instanceof Member) {
			$sel_members[] = $selection;
			$has_project_permissions = ContactMemberPermissions::instance()->count("permission_group_id = '".$contact->getPermissionGroupId()."' AND member_id = ".$selection->getId()) > 0;
			if (!$has_project_permissions) {
				RoleObjectTypePermissions::createDefaultUserPermissions($contact, $selection);
			}
		}
	}
	save_permissions($contact->getPermissionGroupId(), $contact->isGuest());
	
	Hook::fire('after_user_add', $contact, $null);
	
	// add user content object to associated members
	if (count($sel_members) > 0) {
		ObjectMembers::addObjectToMembers($contact->getId(), $sel_members);
		$contact->addToSharingTable();
	}
	
	// Send notification
	try {
		if (array_var($user_data, 'send_email_notification') && $contact->getEmailAddress()) {
                    
			if (array_var($user_data, 'password_generator', 'link') == 'link') {
				// Generate link password
				$user = Contacts::getByEmail(array_var($user_data, 'email'));
				$token = sha1(gen_id() . (defined('SEED') ? SEED : ''));
				$timestamp = time() + 60*60*24;
				set_user_config_option('reset_password', $token . ";" . $timestamp, $user->getId());
				Notifier::newUserAccountLinkPassword($contact, $password, $token);

			} else {
				Notifier::newUserAccount($contact, $password);
			}
			
		}
	} catch(Exception $e) {
		Logger::log($e->getTraceAsString());
	} // try
	return $contact;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:functions.php

示例3: create_user


//.........这里部分代码省略.........
                $contact->setUserId($user->getId());
                if ($contact->isTrashed()) {
                    $contact->untrash();
                }
                $contact->save();
            }
        }
    }
    $contact = $user->getContact();
    if ($contact instanceof Contact) {
        // update contact data with data entered for this user
        $contact->setCompanyId($user->getCompanyId());
        if ($contact->getEmail() != $user->getEmail()) {
            // make user's email the contact's main email address
            if ($contact->getEmail2() == $user->getEmail()) {
                $contact->setEmail2($contact->getEmail());
            } else {
                if ($contact->getEmail3() == $user->getEmail()) {
                    $contact->setEmail3($contact->getEmail());
                } else {
                    if ($contact->getEmail2() == "") {
                        $contact->setEmail2($contact->getEmail());
                    } else {
                        $contact->setEmail3($contact->getEmail());
                    }
                }
            }
        }
        $contact->setEmail($user->getEmail());
        $contact->save();
    }
    if (!$user->isGuest()) {
        /* create personal project or assing the selected*/
        //if recived a personal project assing this
        //project as personal project for this user
        $new_project = null;
        $personalProjectId = array_var($user_data, 'personal_project', 0);
        $project = Projects::findById($personalProjectId);
        if (!$project instanceof Project) {
            $project = new Project();
            $wname = new_personal_project_name($user->getUsername());
            $project->setName($wname);
            $wdesc = Localization::instance()->lang(lang('personal workspace description'));
            if (!is_null($wdesc)) {
                $project->setDescription($wdesc);
            }
            $project->setCreatedById($user->getId());
            $project->save();
            //Save to set an ID number
            $project->setP1($project->getId());
            //Set ID number to the first project
            $project->save();
            $new_project = $project;
        }
        $user->setPersonalProjectId($project->getId());
        $project_user = new ProjectUser();
        $project_user->setProjectId($project->getId());
        $project_user->setUserId($user->getId());
        $project_user->setCreatedById($user->getId());
        $project_user->setAllPermissions(true);
        $project_user->save();
        /* end personal project */
    }
    $user->save();
    ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_ADD);
    //TODO - Make batch update of these permissions
    if ($permissionsString && $permissionsString != '') {
        $permissions = json_decode($permissionsString);
    } else {
        $permissions = null;
    }
    if (is_array($permissions) && (!logged_user() instanceof User || can_manage_security(logged_user()))) {
        foreach ($permissions as $perm) {
            if (ProjectUser::hasAnyPermissions($perm->pr, $perm->pc)) {
                if (!$personalProjectId || $personalProjectId != $perm->wsid) {
                    $relation = new ProjectUser();
                    $relation->setProjectId($perm->wsid);
                    $relation->setUserId($user->getId());
                    $relation->setCheckboxPermissions($perm->pc, $user->isGuest() ? false : true);
                    $relation->setRadioPermissions($perm->pr, $user->isGuest() ? false : true);
                    $relation->save();
                }
            }
        }
    }
    // if
    if ($new_project instanceof Project && logged_user() instanceof User && logged_user()->isProjectUser($new_project)) {
        evt_add("workspace added", array("id" => $new_project->getId(), "name" => $new_project->getName(), "color" => $new_project->getColor()));
    }
    // Send notification...
    try {
        if (array_var($user_data, 'send_email_notification')) {
            Notifier::newUserAccount($user, $password);
        }
        // if
    } catch (Exception $e) {
    }
    // try
    return $user;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:functions.php

示例4: send_notification

function send_notification($user_data, $contact_id)
{
    $contact = Contacts::findById($contact_id);
    //$contact->getId()
    $password = '';
    // Send notification
    try {
        if (array_var($user_data, 'send_email_notification') && $contact->getEmailAddress()) {
            if (array_var($user_data, 'password_generator', 'link') == 'link') {
                // Generate link password
                $user = Contacts::getByEmail(array_var($user_data, 'email'));
                $token = sha1(gen_id() . (defined('SEED') ? SEED : ''));
                $timestamp = time() + 60 * 60 * 24;
                set_user_config_option('reset_password', $token . ";" . $timestamp, $user->getId());
                Notifier::newUserAccountLinkPassword($contact, $password, $token);
            } else {
                $password = array_var($user_data, 'password');
                Notifier::newUserAccount($contact, $password);
            }
        }
    } catch (Exception $e) {
        Logger::log($e->getTraceAsString());
    }
    // try
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:25,代码来源:functions.php

示例5: add

 /**
  * Add user
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_user');
     $company = Companies::findById(get_id('company_id'));
     if (!$company instanceof Company) {
         flash_error(lang('company dnx'));
         $this->redirectTo('administration');
     }
     // if
     if (!User::canAdd(logged_user(), $company)) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $user = new User();
     $user_data = array_var($_POST, 'user');
     if (!is_array($user_data)) {
         $user_data = array('password_generator' => 'random', 'company_id' => $company->getId(), 'timezone' => $company->getTimezone());
         // array
     }
     // if
     $projects = $company->getProjects();
     $permissions = PermissionManager::getPermissionsText();
     tpl_assign('user', $user);
     tpl_assign('company', $company);
     tpl_assign('projects', $projects);
     tpl_assign('permissions', $permissions);
     tpl_assign('user_data', $user_data);
     if (is_array(array_var($_POST, 'user'))) {
         $user->setFromAttributes($user_data);
         $user->setCompanyId($company->getId());
         try {
             // Generate random password
             if (array_var($user_data, 'password_generator') == 'random') {
                 $password = substr(sha1(uniqid(rand(), true)), rand(0, 25), 13);
                 // Validate user input
             } else {
                 $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
             }
             // if
             $user->setPassword($password);
             if (config_option('check_email_unique', '1') == '1') {
                 if (!$user->validateUniquenessOf('email')) {
                     throw new Error(lang('email address is already used'));
                 }
             }
             DB::beginWork();
             $user->save();
             ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_ADD);
             if (is_array($projects)) {
                 foreach ($projects as $project) {
                     if (array_var($user_data, 'project_permissions_' . $project->getId()) == 'checked') {
                         $relation = new ProjectUser();
                         $relation->setProjectId($project->getId());
                         $relation->setUserId($user->getId());
                         foreach ($permissions as $permission => $permission_text) {
                             $permission_value = array_var($user_data, 'project_permission_' . $project->getId() . '_' . $permission) == 'checked';
                             $user->setProjectPermission($project, $permission, $permission_value);
                         }
                         // foreach
                         $relation->save();
                     }
                     // if
                 }
                 // foreach
             }
             // if
             DB::commit();
             // Send notification...
             try {
                 if (array_var($user_data, 'send_email_notification')) {
                     Notifier::newUserAccount($user, $password);
                 }
                 // if
             } catch (Exception $e) {
             }
             // try
             // Add task to Welcome project...
             try {
                 if (array_var($user_data, 'add welcome task')) {
                     $task_data = array('text' => lang('welcome task text', $user->getName(), get_url('account', 'edit')), 'due date' => DateTimeValueLib::now() + 7 * 24 * 60 * 60, 'assigned_to_company_id' => $user->getCompanyId(), 'assigned_to_user_id' => $user->getId());
                     $task_list = ProjectTaskLists::instance()->findById(2, true);
                     DB::beginWork();
                     $task = new ProjectTask();
                     $task->setFromAttributes($task_data);
//.........这里部分代码省略.........
开发者ID:469306621,项目名称:Languages,代码行数:101,代码来源:UserController.class.php

示例6: add_contact


//.........这里部分代码省略.........
             } else {
                 $contact->setAvatarFile('');
             }
             // if
             try {
                 DB::beginWork();
                 $contact->setFromAttributes($new_contact_data);
                 if (array_var($company_data, 'what') == 'existing') {
                     $company_id = $new_contact_data['company_id'];
                 } else {
                     $company = new Company();
                     $company->setName(array_var($company_data, 'name'));
                     $company->setTimezone(array_var($company_data, 'timezone'));
                     $company->setClientOfId(owner_company()->getId());
                     $company->save();
                     $company_id = $company->getId();
                 }
                 // if
                 $contact->setCompanyId($company_id);
                 // User account info
                 if (array_var($user_data, 'add_account') == "yes") {
                     $user = new User();
                     $user->setFromAttributes($user_data);
                     if (array_var($user_data, 'password_generator') == 'random') {
                         // Generate random password
                         $password = substr(sha1(uniqid(rand(), true)), rand(0, 25), 13);
                     } else {
                         // Validate user input
                         $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
                     }
                     // if
                     $user->setPassword($password);
                     $user->save();
                     $contact->setUserId($user->getId());
                 } else {
                     $contact->setUserId(0);
                 }
                 // if
                 $contact->save();
                 if (plugin_active('tags')) {
                     $contact->setTagsFromCSV(array_var($new_contact_data, 'tags'));
                 }
                 $contact->clearImValues();
                 foreach ($im_types as $im_type) {
                     $value = trim(array_var($new_contact_data, 'im_' . $im_type->getId()));
                     if ($value != '') {
                         $contact_im_value = new ContactImValue();
                         $contact_im_value->setContactId($contact->getId());
                         $contact_im_value->setImTypeId($im_type->getId());
                         $contact_im_value->setValue($value);
                         $contact_im_value->setIsDefault(array_var($new_contact_data, 'default_im') == $im_type->getId());
                         $contact_im_value->save();
                     }
                     // if
                 }
                 // foreach
                 ApplicationLogs::createLog($contact, null, ApplicationLogs::ACTION_ADD);
                 $page_attachment = new PageAttachment();
                 $page_attachment->setFromAttributes($new_contact_data);
                 $page_attachment->setRelObjectId($contact->getId());
                 $page_attachment->setRelObjectManager('Contacts');
                 $page_attachment->setProjectId(active_project()->getId());
                 $page_attachment->setPageName('people');
                 $page_attachment->save();
                 PageAttachments::reorder('people', active_project());
                 DB::commit();
                 // Send notification...
                 try {
                     if (array_var($user_data, 'add_account') == "yes" && array_var($user_data, 'send_email_notification')) {
                         Notifier::newUserAccount($user, $password);
                     }
                     // if
                 } catch (Exception $e) {
                 }
                 // try
                 flash_success(lang('success add contact', $contact->getDisplayName()));
                 if ($project_init) {
                     $this->redirectToUrl(active_project()->getAddContactUrl(array('project_init' => '1')));
                 } else {
                     $this->redirectToUrl(get_url('project', 'people'));
                 }
                 // if
             } catch (Exception $e) {
                 DB::rollback();
                 tpl_assign('error', $e);
             }
             // try
         }
         // if
     }
     // if
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:101,代码来源:ProjectController.class.php


注:本文中的Notifier::newUserAccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。