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


PHP Contact::setCompanyId方法代码示例

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


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

示例1: trim

	/**
	 * @author Ignacio Vazquez <elpepe.uy at gmail dot com>
	 * Handle quick add submit
	 */
	function quick_add() {
		if (array_var($_GET, 'current') == 'overview-panel') {
			ajx_current("reload");	
		}else {
			ajx_current("empty");
		}
		
		//---------- REQUEST PARAMS -------------- 
		//		$_POST = Array (
		//			[member] => Array (
		//				[name] => pepe 333
		//				[dimension_id] => 1
		//				[parent_member_id] => 0
		//				[dimension_id] => 19
		//			)
		//			[contact] => Array (
		//				[email] => slkdjflksjdflksdf@kldsjflkdf.com
		//				[user] => Array (
		//					[create-user]=>on
		//					[type] => 25
		//					[first_name] =>  
		// 					[surname] => 						
		//		)
		//----------------------------------------
		
		// Init variables

		$max_users = config_option('max_users');
		if ($max_users && (Contacts::count() >= $max_users)) {
			flash_error(lang('maximum number of users reached error'));
			ajx_current("empty");
			return;
		}

		if (!can_manage_security(logged_user())) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		
		$email = trim(array_var(array_var($_POST, 'contact'),'email')) ;
		$member = array_var($_POST, 'member');
		$name = array_var($member, 'name');
		$firstName = trim(array_var(array_var($_POST, 'contact'),'first_name'));
		$surname = trim(array_var(array_var($_POST, 'contact'),'surname'));
		$parentMemberId = array_var($member, 'parent_member_id');
		$objectType = ObjectTypes::findById(array_var($member, 'object_type_id'))->getName(); // 'person', 'company'
		$dimensionId =  array_var($member, 'dimension_id'); 		
		$company = array_var(array_var(array_var($_POST, 'contact'),'user'),'company_id');
                
		// Create new instance of Contact and set the basic fields
		$contact = new Contact();
		$contact->setObjectName($name);
		if ($firstName) {
			$contact->setFirstName($firstName);
		}else{
			$contact->setFirstName($name);	
		}
		
		if ($surname) {
			$contact->setSurname($surname);
		}
		
		$contact->setCompanyId($company);
		$contact->setIsCompany($objectType == "company");
		if ($parentMemberId){
			if ( $companyId = Members::findById($parentMemberId)->getObjectId()) {
				$contact->setCompanyId($companyId);
			}
		}
		
		
		// Save Contact
		try {
			DB::beginWork();
			$contact->save();
			if ($email && is_valid_email($email)) {
				if (!Contacts::validateUniqueEmail($email)) {
					DB::rollback();
					flash_error(lang("email address must be unique"));
					return false;
				}else{
					if (!array_var (array_var(array_var($_POST, 'contact'),'user'), 'create-user')) {
						$contact->addEmail($email, 'personal', true);
					}
					flash_success(lang("success add contact", $contact->getObjectName()));
				}
			}
			
			// User settings
			$user = array_var(array_var($_POST, 'contact'),'user');
			$user['username'] = str_replace(" ","",strtolower($name)) ;
			$this->createUserFromContactForm($user, $contact->getId(), $email);
			
			// Reload contact again due to 'createUserFromContactForm' changes
			Hook::fire("after_contact_quick_add", Contacts::instance()->findById($contact->getId()), $ret);
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:ContactController.class.php

示例2: die

 /**
  * Finish the installation - create owner company and administrator
  *
  * @param void
  * @return null
  */
 function complete_installation()
 {
     if (Companies::getOwnerCompany() instanceof Company) {
         die('Owner company already exists');
         // Somebody is trying to access this method even if the user already exists
     }
     // if
     $this->setLayout('complete_install');
     $form_data = array_var($_POST, 'form');
     tpl_assign('form_data', $form_data);
     if (array_var($form_data, 'submitted') == 'submitted') {
         try {
             $admin_password = trim(array_var($form_data, 'admin_password'));
             $admin_password_a = trim(array_var($form_data, 'admin_password_a'));
             if (trim($admin_password) == '') {
                 throw new Error(lang('password value required'));
             }
             // if
             if ($admin_password != $admin_password_a) {
                 throw new Error(lang('passwords dont match'));
             }
             // if
             DB::beginWork();
             Users::delete();
             // clear users table
             Companies::delete();
             // clear companies table
             // Create the administrator user
             $administrator = new User();
             $administrator->setId(1);
             $administrator->setUsername(array_var($form_data, 'admin_username'));
             $administrator->setEmail(array_var($form_data, 'admin_email'));
             $administrator->setPassword($admin_password);
             $administrator->setIsAdmin(true);
             $administrator->setAutoAssign(true);
             $administrator->save();
             // Create the contact for administrator
             $administrator_contact = new Contact();
             $administrator_contact->setId(1);
             $administrator_contact->setCompanyId(1);
             $administrator_contact->setEmail(array_var($form_data, 'admin_email'));
             $administrator_contact->setUserId($administrator->getId());
             $administrator_contact->setDisplayName($administrator->getUsername());
             $administrator_contact->save();
             // Create a company
             $company = new Company();
             $company->setId(1);
             $company->setClientOfId(0);
             $company->setName(array_var($form_data, 'company_name'));
             $company->setCreatedById(1);
             $company->save();
             DB::commit();
             $this->redirectTo('access', 'login');
         } catch (Exception $e) {
             tpl_assign('error', $e);
             DB::rollback();
         }
         // try
     }
     // if
 }
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:67,代码来源:AccessController.class.php

示例3: die

 /**
  * Finish the installation - create owner company and administrator
  *
  * @param void
  * @return null
  */
 function complete_installation()
 {
     if (Contacts::getOwnerCompany() instanceof Contact) {
         die('Owner company already exists');
         // Somebody is trying to access this method even if the user already exists
     }
     // if
     $form_data = array_var($_POST, 'form');
     tpl_assign('form_data', $form_data);
     if (array_var($form_data, 'submited') == 'submited') {
         try {
             $admin_password = trim(array_var($form_data, 'admin_password'));
             $admin_password_a = trim(array_var($form_data, 'admin_password_a'));
             if (trim($admin_password) == '') {
                 throw new Error(lang('password value required'));
             }
             // if
             if ($admin_password != $admin_password_a) {
                 throw new Error(lang('passwords dont match'));
             }
             // if
             DB::beginWork();
             Contacts::delete();
             // clear users table
             // Create a company
             $company = new Contact();
             $company->setFirstName(array_var($form_data, 'company_name'));
             $company->setObjectName();
             $company->setIsCompany(true);
             $company->save();
             // Init default colors
             set_config_option('brand_colors_head_back', "424242");
             set_config_option('brand_colors_tabs_back', "e7e7e7");
             set_config_option('brand_colors_head_font', "FFFFFF");
             set_config_option('brand_colors_tabs_font', "333333");
             // Create the administrator user
             $administrator = new Contact();
             $pergroup = PermissionGroups::findOne(array('conditions' => "`name`='Super Administrator'"));
             $administrator->setUserType($pergroup->getId());
             $administrator->setCompanyId($company->getId());
             $administrator->setUsername(array_var($form_data, 'admin_username'));
             $administrator->setPassword($admin_password);
             $administrator->setFirstname(array_var($form_data, 'admin_username'));
             $administrator->setObjectName();
             $administrator->save();
             $user_password = new ContactPassword();
             $user_password->setContactId($administrator->getId());
             $user_password->password_temp = $admin_password;
             $user_password->setPasswordDate(DateTimeValueLib::now());
             $user_password->setPassword(cp_encrypt($admin_password, $user_password->getPasswordDate()->getTimestamp()));
             $user_password->save();
             //Add email after save because is needed.
             $administrator->addEmail(array_var($form_data, 'admin_email'), 'personal', true);
             //permissions
             $permission_group = new PermissionGroup();
             $permission_group->setName('Account Owner');
             $permission_group->setContactId($administrator->getId());
             $permission_group->setIsContext(false);
             $permission_group->setType("permission_groups");
             $permission_group->save();
             $administrator->setPermissionGroupId($permission_group->getId());
             $administrator->save();
             $company->setCreatedById($administrator->getId());
             $company->setUpdatedById($administrator->getId());
             $company->save();
             $contact_pg = new ContactPermissionGroup();
             $contact_pg->setContactId($administrator->getId());
             $contact_pg->setPermissionGroupId($permission_group->getId());
             $contact_pg->save();
             // tab panel permissions
             $panels = TabPanels::getEnabled();
             foreach ($panels as $panel) {
                 $tpp = new TabPanelPermission();
                 $tpp->setPermissionGroupId($administrator->getPermissionGroupId());
                 $tpp->setTabPanelId($panel->getId());
                 $tpp->save();
             }
             // dimension permissions
             $dimensions = Dimensions::findAll();
             foreach ($dimensions as $dimension) {
                 if ($dimension->getDefinesPermissions()) {
                     $cdp = ContactDimensionPermissions::findOne(array("conditions" => "`permission_group_id` = " . $administrator->getPermissionGroupId() . " AND `dimension_id` = " . $dimension->getId()));
                     if (!$cdp instanceof ContactDimensionPermission) {
                         $cdp = new ContactDimensionPermission();
                         $cdp->setPermissionGroupId($administrator->getPermissionGroupId());
                         $cdp->setContactDimensionId($dimension->getId());
                     }
                     $cdp->setPermissionType('allow all');
                     $cdp->save();
                     // contact member permisssion entries
                     $members = $dimension->getAllMembers();
                     foreach ($members as $member) {
                         $ots = DimensionObjectTypeContents::getContentObjectTypeIds($dimension->getId(), $member->getObjectTypeId());
                         $ots[] = $member->getObjectId();
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:AccessController.class.php

示例4: create_user

function create_user($user_data, $permissionsString) {
    
	// try to find contact by some properties 
	$contact_id = array_var($user_data, "contact_id") ;
	$contact =  Contacts::instance()->findById($contact_id) ; 
	
	if (!is_valid_email(array_var($user_data, 'email'))) {
		throw new Exception(lang("email value is required"));
	}

	if (!$contact instanceof Contact) {
		// Create a new user
		$contact = new Contact();
		$contact->setUsername(array_var($user_data, 'username'));
		$contact->setDisplayName(array_var($user_data, 'display_name'));
		$contact->setCompanyId(array_var($user_data, 'company_id'));
		$contact->setUserType(array_var($user_data, 'type'));
		$contact->setTimezone(array_var($user_data, 'timezone'));
		$contact->setFirstname($contact->getObjectName() != "" ? $contact->getObjectName() : $contact->getUsername());
		$contact->setObjectName();
	} else {
		// Create user from contact
		$contact->setUserType(array_var($user_data, 'type'));
		if (array_var($user_data, 'company_id')) {
			$contact->setCompanyId(array_var($user_data, 'company_id'));
		}	
		$contact->setUsername(array_var($user_data, 'username'));
		$contact->setTimezone(array_var($user_data, 'timezone'));
	}
	$contact->save();
	if (is_valid_email(array_var($user_data, 'email'))) {
		$contact->addEmail(array_var($user_data, 'email'), 'personal', true);
	}
	
	
	//permissions
	$permission_group = new PermissionGroup();
	$permission_group->setName('User '.$contact->getId().' Personal');
	$permission_group->setContactId($contact->getId());
	$permission_group->setIsContext(false);
	$permission_group->setType("permission_groups");
	$permission_group->save();
	$contact->setPermissionGroupId($permission_group->getId());
	
	$contact_pg = new ContactPermissionGroup();
	$contact_pg->setContactId($contact->getId());
	$contact_pg->setPermissionGroupId($permission_group->getId());
	$contact_pg->save();

	if ( can_manage_security(logged_user()) ) {
		
		$sp = new SystemPermission();
		$rol_permissions=SystemPermissions::getRolePermissions(array_var($user_data, 'type'));
		foreach($rol_permissions as $pr){
			$sp->setPermission($pr);
		}
		$sp->setPermissionGroupId($permission_group->getId());

		$sp->setCanManageSecurity(array_var($user_data, 'can_manage_security'));
		$sp->setCanManageConfiguration(array_var($user_data, 'can_manage_configuration'));
		$sp->setCanManageTemplates(array_var($user_data, 'can_manage_templates'));
		$sp->setCanManageTime(array_var($user_data, 'can_manage_time'));
		$sp->setCanAddMailAccounts(array_var($user_data, 'can_add_mail_accounts'));
		$sp->setCanManageDimensions(array_var($user_data, 'can_manage_dimensions'));
		$sp->setCanManageDimensionMembers(array_var($user_data, 'can_manage_dimension_members'));
		$sp->setCanManageTasks(array_var($user_data, 'can_manage_tasks'));
		$sp->setCanTasksAssignee(array_var($user_data, 'can_task_assignee'));
		$sp->setCanManageBilling(array_var($user_data, 'can_manage_billing'));
		$sp->setCanViewBilling(array_var($user_data, 'can_view_billing'));
		
		Hook::fire('add_user_permissions', $sp, $other_permissions);
		if (!is_null($other_permissions) && is_array($other_permissions)) {
			foreach ($other_permissions as $k => $v) {
				$sp->setColumnValue($k, array_var($user_data, $k));
			}
		}
		$sp->save();
		
		if ($contact->isAdminGroup()) {
			// allow all un all dimensions if new user is admin
			$dimensions = Dimensions::findAll();
			$permissions = array();
			foreach ($dimensions as $dimension) {
				if ($dimension->getDefinesPermissions()) {
					$cdp = ContactDimensionPermissions::findOne(array("conditions" => "`permission_group_id` = ".$contact->getPermissionGroupId()." AND `dimension_id` = ".$dimension->getId()));
					if (!$cdp instanceof ContactDimensionPermission) {
						$cdp = new ContactDimensionPermission();
						$cdp->setPermissionGroupId($contact->getPermissionGroupId());
						$cdp->setContactDimensionId($dimension->getId());
					}
					$cdp->setPermissionType('allow all');
					$cdp->save();
					
					// contact member permisssion entries
					$members = $dimension->getAllMembers();
					foreach ($members as $member) {
						
						$ots = DimensionObjectTypeContents::getContentObjectTypeIds($dimension->getId(), $member->getObjectTypeId());
						$ots[]=$member->getObjectId();
						foreach ($ots as $ot) {
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:functions.php

示例5: trim

	/**
	 * Finish the installation - create owner company and administrator
	 *
	 * @param void
	 * @return null
	 */
	function complete_installation() {
		
		if(Contacts::getOwnerCompany() instanceof Contact) {
			die('Owner company already exists'); // Somebody is trying to access this method even if the user already exists
		} // if

		$form_data = array_var($_POST, 'form');
		tpl_assign('form_data', $form_data);

		if(array_var($form_data, 'submited') == 'submited') {
			try {
				$admin_password = trim(array_var($form_data, 'admin_password'));
				$admin_password_a = trim(array_var($form_data, 'admin_password_a'));

				if(trim($admin_password) == '') {
					throw new Error(lang('password value required'));
				} // if

				if($admin_password <> $admin_password_a) {
					throw new Error(lang('passwords dont match'));
				} // if

				DB::beginWork();

				Contacts::delete(); // clear users table

				// Create a company
				$company = new Contact();
				$company->setFirstName(array_var($form_data, 'company_name'));
				$company->setObjectName();
				$company->setIsCompany(true);
				$company->save();
				
				// Init default colors
				set_config_option('brand_colors_head_back', "000000");
				set_config_option('brand_colors_tabs_back', "14780e");
				set_config_option('brand_colors_head_font', "ffffff");
				set_config_option('brand_colors_tabs_font', "ffffff");

				// Create the administrator user
				$administrator = new Contact();
				$pergroup = PermissionGroups::findOne(array('conditions'=>"`name`='Super Administrator'"));
				$administrator->setUserType($pergroup->getId());
				$administrator->setCompanyId($company->getId());
				$administrator->setUsername(array_var($form_data, 'admin_username'));
				
				
				$administrator->setPassword($admin_password);
				$administrator->setFirstname(array_var($form_data, 'admin_username'));
				$administrator->setObjectName();
				$administrator->save();
				
				$user_password = new ContactPassword();
				$user_password->setContactId($administrator->getId());
				$user_password->password_temp = $admin_password;
				$user_password->setPasswordDate(DateTimeValueLib::now());
				$user_password->setPassword(cp_encrypt($admin_password, $user_password->getPasswordDate()->getTimestamp()));
				$user_password->save();
				
				//Add email after save because is needed. 
				$administrator->addEmail(array_var($form_data, 'admin_email'), 'personal', true);
				
				//permissions
				$permission_group = new PermissionGroup();
				$permission_group->setName('Account Owner');
				$permission_group->setContactId($administrator->getId());
				$permission_group->setIsContext(false);
				$permission_group->setType("permission_groups");
				$permission_group->save();
				
				$administrator->setPermissionGroupId($permission_group->getId());
				$administrator->save();
				
				$company->setCreatedById($administrator->getId());
				$company->setUpdatedById($administrator->getId());
				$company->save();
				
				$contact_pg = new ContactPermissionGroup();
				$contact_pg->setContactId($administrator->getId());
				$contact_pg->setPermissionGroupId($permission_group->getId());
				$contact_pg->save();
				
				// tab panel permissions
				$panels = TabPanels::getEnabled();
				foreach ($panels as $panel) {
					$tpp = new TabPanelPermission();
					$tpp->setPermissionGroupId($administrator->getPermissionGroupId());
					$tpp->setTabPanelId($panel->getId());
					$tpp->save();
				}
				
				// dimension permissions
				$dimensions = Dimensions::findAll();
				foreach ($dimensions as $dimension) {
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:AccessController.class.php

示例6: create_user

function create_user($user_data, $permissionsString)
{
    $user = new User();
    $user->setUsername(array_var($user_data, 'username'));
    $user->setDisplayName(array_var($user_data, 'display_name'));
    $user->setEmail(array_var($user_data, 'email'));
    $user->setCompanyId(array_var($user_data, 'company_id'));
    $user->setType(array_var($user_data, 'type'));
    $user->setTimezone(array_var($user_data, 'timezone'));
    if (!logged_user() instanceof User || can_manage_security(logged_user())) {
        $user->setCanEditCompanyData(array_var($user_data, 'can_edit_company_data'));
        $user->setCanManageSecurity(array_var($user_data, 'can_manage_security'));
        $user->setCanManageWorkspaces(array_var($user_data, 'can_manage_workspaces'));
        $user->setCanManageConfiguration(array_var($user_data, 'can_manage_configuration'));
        $user->setCanManageContacts(array_var($user_data, 'can_manage_contacts'));
        $user->setCanManageTemplates(array_var($user_data, 'can_manage_templates'));
        $user->setCanManageReports(array_var($user_data, 'can_manage_reports'));
        $user->setCanManageTime(array_var($user_data, 'can_manage_time'));
        $user->setCanAddMailAccounts(array_var($user_data, 'can_add_mail_accounts'));
        $other_permissions = array();
        Hook::fire('add_user_permissions', $user, $other_permissions);
        foreach ($other_permissions as $k => $v) {
            $user->setColumnValue($k, array_var($user_data, $k));
        }
    }
    if (array_var($user_data, 'password_generator', 'random') == 'random') {
        // Generate random password
        $password = UserPasswords::generateRandomPassword();
    } else {
        // 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
    }
    // if
    $user->setPassword($password);
    $user->save();
    $user_password = new UserPassword();
    $user_password->setUserId($user->getId());
    $user_password->setPasswordDate(DateTimeValueLib::now());
    $user_password->setPassword(cp_encrypt($password, $user_password->getPasswordDate()->getTimestamp()));
    $user_password->password_temp = $password;
    $user_password->save();
    if (array_var($user_data, 'autodetect_time_zone', 1) == 1) {
        set_user_config_option('autodetect_time_zone', 1, $user->getId());
    }
    if ($user->getType() == 'admin') {
        if ($user->getCompanyId() != owner_company()->getId() || logged_user() instanceof User && !can_manage_security(logged_user())) {
            // external users can't be admins or logged user has no rights to create admins => set as Normal
            $user->setType('normal');
        } else {
            $user->setAsAdministrator(true);
        }
    }
    /* create contact for this user*/
    if (array_var($user_data, 'create_contact', 1)) {
        // if contact with same email exists take it, else create new
        $contact = Contacts::getByEmail($user->getEmail(), true);
        if (!$contact instanceof Contact) {
            $contact = new Contact();
            $contact->setEmail($user->getEmail());
        } else {
            if ($contact->isTrashed()) {
                $contact->untrash();
            }
        }
        $contact->setFirstname($user->getDisplayName());
        $contact->setUserId($user->getId());
        $contact->setTimezone($user->getTimezone());
        $contact->setCompanyId($user->getCompanyId());
        $contact->save();
    } else {
        $contact_id = array_var($user_data, 'contact_id');
        $contact = Contacts::findById($contact_id);
        if ($contact instanceof Contact) {
            // user created from a contact
            $contact->setUserId($user->getId());
            $contact->save();
        } else {
            // if contact with same email exists use it as user's contact, without changing it
            $contact = Contacts::getByEmail($user->getEmail(), true);
            if ($contact instanceof Contact) {
                $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());
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:functions.php

示例7: create_user

function create_user($user_data, $permissionsString, $rp_permissions_data = array(), $save_permissions = true)
{
    // try to find contact by some properties
    $contact_id = array_var($user_data, "contact_id");
    $contact = Contacts::instance()->findById($contact_id);
    if (!is_valid_email(array_var($user_data, 'email'))) {
        throw new Exception(lang("email value is required"));
    }
    if (!$contact instanceof Contact) {
        // Create a new user
        $contact = new Contact();
        $contact->setUsername(array_var($user_data, 'username'));
        $contact->setDisplayName(array_var($user_data, 'display_name'));
        $contact->setCompanyId(array_var($user_data, 'company_id'));
        $contact->setUserType(array_var($user_data, 'type'));
        $contact->setTimezone(array_var($user_data, 'timezone'));
        $contact->setFirstname($contact->getObjectName() != "" ? $contact->getObjectName() : $contact->getUsername());
        $contact->setObjectName();
        $user_from_contact = false;
    } else {
        // Create user from contact
        $contact->setUserType(array_var($user_data, 'type'));
        if (array_var($user_data, 'company_id')) {
            $contact->setCompanyId(array_var($user_data, 'company_id'));
        }
        $contact->setUsername(array_var($user_data, 'username'));
        $contact->setTimezone(array_var($user_data, 'timezone'));
        $user_from_contact = true;
    }
    $contact->save();
    if (is_valid_email(array_var($user_data, 'email'))) {
        $user = Contacts::getByEmail(array_var($user_data, 'email'));
        if (!$user) {
            $contact->addEmail(array_var($user_data, 'email'), 'personal', true);
        }
    }
    //permissions
    $additional_name = "";
    $tmp_pg = PermissionGroups::findOne(array('conditions' => "`name`='User " . $contact->getId() . " Personal'"));
    if ($tmp_pg instanceof PermissionGroup) {
        $additional_name = "_" . gen_id();
    }
    $permission_group = new PermissionGroup();
    $permission_group->setName('User ' . $contact->getId() . $additional_name . ' Personal');
    $permission_group->setContactId($contact->getId());
    $permission_group->setIsContext(false);
    $permission_group->setType("permission_groups");
    $permission_group->save();
    $contact->setPermissionGroupId($permission_group->getId());
    $null = null;
    Hook::fire('on_create_user_perm_group', $permission_group, $null);
    $contact_pg = new ContactPermissionGroup();
    $contact_pg->setContactId($contact->getId());
    $contact_pg->setPermissionGroupId($permission_group->getId());
    $contact_pg->save();
    if (can_manage_security(logged_user())) {
        $sp = new SystemPermission();
        if (!$user_from_contact) {
            $rol_permissions = SystemPermissions::getRolePermissions(array_var($user_data, 'type'));
            if (is_array($rol_permissions)) {
                foreach ($rol_permissions as $pr) {
                    $sp->setPermission($pr);
                }
            }
        }
        $sp->setPermissionGroupId($permission_group->getId());
        if (isset($user_data['can_manage_security'])) {
            $sp->setCanManageSecurity(array_var($user_data, 'can_manage_security'));
        }
        if (isset($user_data['can_manage_configuration'])) {
            $sp->setCanManageConfiguration(array_var($user_data, 'can_manage_configuration'));
        }
        if (isset($user_data['can_manage_templates'])) {
            $sp->setCanManageTemplates(array_var($user_data, 'can_manage_templates'));
        }
        if (isset($user_data['can_manage_time'])) {
            $sp->setCanManageTime(array_var($user_data, 'can_manage_time'));
        }
        if (isset($user_data['can_add_mail_accounts'])) {
            $sp->setCanAddMailAccounts(array_var($user_data, 'can_add_mail_accounts'));
        }
        if (isset($user_data['can_manage_dimensions'])) {
            $sp->setCanManageDimensions(array_var($user_data, 'can_manage_dimensions'));
        }
        if (isset($user_data['can_manage_dimension_members'])) {
            $sp->setCanManageDimensionMembers(array_var($user_data, 'can_manage_dimension_members'));
        }
        if (isset($user_data['can_manage_tasks'])) {
            $sp->setCanManageTasks(array_var($user_data, 'can_manage_tasks'));
        }
        if (isset($user_data['can_task_assignee'])) {
            $sp->setCanTasksAssignee(array_var($user_data, 'can_task_assignee'));
        }
        if (isset($user_data['can_manage_billing'])) {
            $sp->setCanManageBilling(array_var($user_data, 'can_manage_billing'));
        }
        if (isset($user_data['can_view_billing'])) {
            $sp->setCanViewBilling(array_var($user_data, 'can_view_billing'));
        }
        if (isset($user_data['can_see_assigned_to_other_tasks'])) {
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:functions.php

示例8: array

 /**
  * Create a contact with the data of a user
  *
  */
 function create_contact_from_user()
 {
     ajx_current("empty");
     $user = Users::findById(get_id());
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         return;
     }
     // if
     if (!logged_user()->canSeeUser($user)) {
         flash_error(lang('no access permissions'));
         return;
     }
     // if
     if ($user->getContact()) {
         if ($contact->isTrashed()) {
             try {
                 DB::beginWork();
                 $contact->untrash();
                 DB::commit();
                 $this->redirectTo('contact', 'card', array('id' => $contact->getId()));
             } catch (Exception $e) {
                 DB::rollback();
                 flash_error(lang('error add contact from user') . " " . $e->getMessage());
             }
         } else {
             flash_error(lang('user has contact'));
             return;
         }
     }
     try {
         DB::beginWork();
         $contact = new Contact();
         $contact->setFirstname($user->getDisplayName());
         $contact->setUserId($user->getId());
         $contact->setEmail($user->getEmail());
         $contact->setTimezone($user->getTimezone());
         $contact->setCompanyId($user->getCompanyId());
         $contact->save();
         DB::commit();
         $this->redirectTo('contact', 'card', array('id' => $contact->getId()));
     } catch (Exception $exx) {
         DB::rollback();
         flash_error(lang('error add contact from user') . " " . $exx->getMessage());
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:50,代码来源:UserController.class.php


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