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


PHP Contact::getPermissionGroupId方法代码示例

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


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

示例1: createDefaultUserPermissionsAllDimension

 static function createDefaultUserPermissionsAllDimension(Contact $user, $dimension_id, $remove_previous = true)
 {
     $role_id = $user->getUserType();
     $permission_group_id = $user->getPermissionGroupId();
     $dimension = Dimensions::getDimensionById($dimension_id);
     if (!$dimension instanceof Dimension || !$dimension->getDefinesPermissions()) {
         return;
     }
     try {
         $shtab_permissions = array();
         $new_permissions = array();
         $role_permissions = self::findAll(array('conditions' => "role_id = '{$role_id}'"));
         $members = Members::findAll(array('conditions' => 'dimension_id = ' . $dimension_id));
         foreach ($members as $member) {
             $member_id = $member->getId();
             if ($remove_previous) {
                 ContactMemberPermissions::delete("permission_group_id = {$permission_group_id} AND member_id = {$member_id}");
             }
             foreach ($role_permissions as $role_perm) {
                 if ($member->canContainObject($role_perm->getObjectTypeId())) {
                     $cmp = new ContactMemberPermission();
                     $cmp->setPermissionGroupId($permission_group_id);
                     $cmp->setMemberId($member_id);
                     $cmp->setObjectTypeId($role_perm->getObjectTypeId());
                     $cmp->setCanDelete($role_perm->getCanDelete());
                     $cmp->setCanWrite($role_perm->getCanWrite());
                     $cmp->save();
                     $new_permissions[] = $cmp;
                     $perm = new stdClass();
                     $perm->m = $member_id;
                     $perm->r = 1;
                     $perm->w = $role_perm->getCanWrite();
                     $perm->d = $role_perm->getCanDelete();
                     $perm->o = $role_perm->getObjectTypeId();
                     $shtab_permissions[] = $perm;
                 }
             }
         }
         if (count($shtab_permissions)) {
             $cdp = ContactDimensionPermissions::instance()->findOne(array('conditions' => "permission_group_id = '{$permission_group_id}' AND dimension_id = {$dimension_id}"));
             if (!$cdp instanceof ContactDimensionPermission) {
                 $cdp = new ContactDimensionPermission();
                 $cdp->setPermissionGroupId($permission_group_id);
                 $cdp->setContactDimensionId($dimension_id);
                 $cdp->setPermissionType('check');
                 $cdp->save();
             } else {
                 if ($cdp->getPermissionType() == 'deny all') {
                     $cdp->setPermissionType('check');
                     $cdp->save();
                 }
             }
             $stCtrl = new SharingTableController();
             $stCtrl->afterPermissionChanged($permission_group_id, $shtab_permissions);
         }
         return $new_permissions;
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:60,代码来源:RoleObjectTypePermissions.class.php

示例2: 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

示例3: core_dim_create_member_associations

/**
 * 
 * Instantiates dimension asociations for the contact member in feng_persons and the members where the contact belongs to.
 * @param $contact The contact
 * @param $contact_member Member of the contact
 * @param $all_members Members where the object belongs
 */
function core_dim_create_member_associations(Contact $contact, $contact_member, $all_members, $reload_dim = true) {
	
	$creator = logged_user();
	if (!$creator instanceof Contact) {
		$oc = Contacts::instance()->getOwnerCompany();
		if ($oc instanceof Contact) {
			$creator = $oc->getCreatedBy();
		}
	}
	if (!$creator instanceof Contact) {
		return array();
	}
	
	$affected_dimensions = array();
	if ($contact->isUser()) {
		$del_sub_query = "SELECT member_id FROM ".TABLE_PREFIX."contact_member_permissions WHERE permission_group_id='".$contact->getPermissionGroupId()."'";
	} else {
		$del_sub_query = "SELECT member_id FROM ".TABLE_PREFIX."object_members WHERE object_id='".$contact->getId()."'";
	}
	
	// one way
	$associations = DimensionMemberAssociations::getAssociatations ( $contact_member->getDimensionId(), $contact_member->getObjectTypeId() );
	foreach ( $associations as $a ) {
		foreach ( $all_members as $m ) {
			if ($m->getDimensionId() == $a->getAssociatedDimensionMemberAssociationId() && $m->getObjectTypeId() == $a->getAssociatedObjectType()) {
				
				$mpm = MemberPropertyMembers::findOne(array('conditions' => array('association_id = ? AND member_id = ? AND property_member_id = ?', $a->getId(), $contact_member->getId(), $m->getId())));
				if (!$mpm instanceof MemberPropertyMember) {
					$sql = "INSERT INTO " . TABLE_PREFIX . "member_property_members (association_id, member_id, property_member_id, is_active, created_on, created_by_id)
						VALUES (" . $a->getId() . "," . $contact_member->getId() . "," . $m->getId() . ", 1, NOW()," . $creator->getId() . ") ";
					DB::execute( $sql );
					$affected_dimensions[$m->getDimensionId()] = $m->getDimensionId();
				}
			}
		}
		MemberPropertyMembers::instance()->delete('association_id = '.$a->getId().' AND member_id = '.$contact_member->getId() . " AND property_member_id NOT IN ($del_sub_query)");
	}
	
	// reverse way
	$associations = DimensionMemberAssociations::findAll(array("conditions" => array("`associated_dimension_id` = ? AND `associated_object_type_id` = ?", $contact_member->getDimensionId(), $contact_member->getObjectTypeId())));
	foreach ( $associations as $a ) {
		foreach ( $all_members as $m ) {
			if ($m->getDimensionId() == $a->getDimensionId() && $m->getObjectTypeId() == $a->getObjectTypeId()) {
				
				$mpm = MemberPropertyMembers::findOne(array('conditions' => array('association_id = ? AND property_member_id = ? AND member_id = ?', $a->getId(), $contact_member->getId(), $m->getId())));
				if (!$mpm instanceof MemberPropertyMember) {
					$sql = "INSERT INTO " . TABLE_PREFIX . "member_property_members (association_id, property_member_id, member_id, is_active, created_on, created_by_id)
						VALUES (" . $a->getId() . "," . $contact_member->getId() . "," . $m->getId() . ", 1, NOW()," . $creator->getId() . ") ";
					DB::execute( $sql );
					$affected_dimensions[$m->getDimensionId()] = $m->getDimensionId();
				}
			}
		}
		MemberPropertyMembers::instance()->delete('association_id = '.$a->getId().' AND property_member_id = '.$contact_member->getId() . " AND member_id NOT IN ($del_sub_query)");
	}
	
	// reload affected dimensions
	if ($reload_dim) {
		foreach ($affected_dimensions as $dim_id) {
			evt_add("reload dimension tree", array('dim_id' => $dim_id, 'node' => null));
		}
	}
	
	return $affected_dimensions;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:72,代码来源:core_dimensions_hooks.php

示例4: grantAllPermissions

 /**
  * Enter description here ...
  * @param Contact $contact
  * @param array of ObjectType $types
  * @param array of int  $members
  */
 function grantAllPermissions(Contact $contact, $members)
 {
     if ($contact->getUserType() > 0 && count($members)) {
         $userType = $contact->getUserTypeName();
         $permissions = array();
         // TO fill sharing table
         $gid = $contact->getPermissionGroupId();
         foreach ($members as $member_id) {
             //new
             $member = Members::findById($member_id);
             $dimension = $member->getDimension();
             $types = array();
             $member_types = DimensionObjectTypeContents::getContentObjectTypeIds($dimension->getId(), $member->getObjectTypeId());
             if (count($member_types)) {
                 switch ($userType) {
                     case 'Super Administrator':
                     case 'Administrator':
                     case 'Manager':
                     case 'Executive':
                         $types = $member_types;
                         break;
                     case 'Collaborator Customer':
                     case 'Non-Exec Director':
                         foreach (ObjectTypes::findAll(array("conditions" => " name NOT IN ('mail') ")) as $type) {
                             //TODO This sucks
                             $types[] = $type->getId();
                         }
                         break;
                     case 'Internal Collaborator':
                     case 'External Collaborator':
                         foreach (ObjectTypes::findAll(array("conditions" => " name NOT IN ('mail','contact', 'report') ")) as $type) {
                             //TODO This sucks
                             $types[] = $type->getId();
                         }
                         break;
                     case 'Guest Customer':
                         foreach (ObjectTypes::findAll(array("conditions" => " name IN ('message', 'weblink', 'event', 'file') ")) as $type) {
                             //TODO This sucks
                             $types[] = $type->getId();
                         }
                         break;
                     case 'Guest':
                         foreach (ObjectTypes::findAll(array("conditions" => " name IN ('message', 'weblink', 'event') ")) as $type) {
                             //TODO This sucks
                             $types[] = $type->getId();
                         }
                         break;
                 }
             }
             foreach ($types as $type_id) {
                 if (!ContactMemberPermissions::instance()->findOne(array("conditions" => "permission_group_id = {$gid}\tAND \n\t\t\t\t\t\t\tmember_id = {$member_id} AND \n\t\t\t\t\t\t\tobject_type_id = {$type_id}"))) {
                     $cmp = new ContactMemberPermission();
                     $cmp->setPermissionGroupId($gid);
                     $cmp->setMemberId($member_id);
                     $cmp->setObjectTypeId($type_id);
                     if ($userType != "Guest" && $userType != "Guest Customer") {
                         $cmp->setCanWrite(1);
                         $cmp->setCanDelete(1);
                     } else {
                         $cmp->setCanWrite(0);
                         $cmp->setCanDelete(0);
                     }
                     $cmp->save();
                     $perm = new stdClass();
                     $perm->m = $member_id;
                     $perm->r = 1;
                     $perm->w = 1;
                     $perm->d = 1;
                     $perm->o = $type_id;
                     $permissions[] = $perm;
                 }
             }
         }
         if (count($permissions)) {
             $stCtrl = new SharingTableController();
             $stCtrl->afterPermissionChanged($contact->getPermissionGroupId(), $permissions);
         }
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:85,代码来源:ContactMemberPermissions.class.php

示例5: cut_max_user_permissions

 private function cut_max_user_permissions(Contact $user)
 {
     $admin_pg = PermissionGroups::findOne(array('conditions' => "`name`='Super Administrator'"));
     $all_roles_max_permissions = RoleObjectTypePermissions::getAllRoleObjectTypePermissionsInfo();
     $admin_perms = $all_roles_max_permissions[$admin_pg->getId()];
     $all_object_types = array();
     foreach ($admin_perms as &$aperm) {
         $all_object_types[] = $aperm['object_type_id'];
     }
     $max_permissions = array_var($all_roles_max_permissions, $user->getUserType());
     $pg_id = $user->getPermissionGroupId();
     foreach ($all_object_types as $ot) {
         if (!$ot) {
             continue;
         }
         $max = array_var($max_permissions, $ot);
         if (!$max) {
             // cannot read -> delete in contact_member_permissions
             $sql = "DELETE FROM " . TABLE_PREFIX . "contact_member_permissions WHERE permission_group_id={$pg_id} AND object_type_id={$ot}";
             DB::execute($sql);
         } else {
             // cut can_delete and can_write using max permissions
             $can_d = $max['can_delete'] ? "1" : "0";
             $can_w = $max['can_write'] ? "1" : "0";
             $sql = "UPDATE " . TABLE_PREFIX . "contact_member_permissions\r\n\t\t\t\tSET can_delete=(can_delete AND {$can_d}), can_write=(can_write AND {$can_w})\r\n\t\t\t\tWHERE permission_group_id={$pg_id} AND object_type_id={$ot}";
             DB::execute($sql);
         }
     }
     // rebuild sharing table for permission group $pg_id
     $cmp_rows = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "contact_member_permissions WHERE permission_group_id={$pg_id}");
     $permissions_array = array();
     foreach ($cmp_rows as $row) {
         $p = new stdClass();
         $p->m = array_var($row, 'member_id');
         $p->o = array_var($row, 'object_type_id');
         $p->d = array_var($row, 'can_delete');
         $p->w = array_var($row, 'can_write');
         $p->r = 1;
         $permissions[] = $p;
     }
     $sharing_table_controller = new SharingTableController();
     $sharing_table_controller->after_permission_changed($pg_id, $permissions_array);
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:43,代码来源:ContactController.class.php

示例6: 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

示例7: 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

示例8: create_user


//.........这里部分代码省略.........
        }
        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'])) {
            $sp->setColumnValue('can_see_assigned_to_other_tasks', array_var($user_data, 'can_see_assigned_to_other_tasks'));
        }
        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();
        $permissions_sent = array_var($_POST, 'manual_permissions_setted') == 1;
        // give permissions for user if user type defined in "give_member_permissions_to_new_users" config option
        $allowed_user_type_ids = config_option('give_member_permissions_to_new_users');
        if ($contact->isAdministrator() || !$permissions_sent && in_array($contact->getUserType(), $allowed_user_type_ids)) {
            ini_set('memory_limit', '512M');
            $permissions = array();
            $default_permissions = RoleObjectTypePermissions::instance()->findAll(array('conditions' => 'role_id = ' . $contact->getUserType()));
            $dimensions = Dimensions::findAll();
            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('check');
                    $cdp->save();
                    // contact member permisssion entries
                    $members = DB::executeAll('SELECT * FROM ' . TABLE_PREFIX . 'members WHERE dimension_id=' . $dimension->getId());
                    foreach ($members as $member) {
                        foreach ($default_permissions as $p) {
                            // Add persmissions to sharing table
                            $perm = new stdClass();
                            $perm->m = $member['id'];
                            $perm->r = 1;
                            $perm->w = $p->getCanWrite();
                            $perm->d = $p->getCanDelete();
                            $perm->o = $p->getObjectTypeId();
                            $permissions[] = $perm;
                        }
                    }
                }
            }
            $_POST['permissions'] = json_encode($permissions);
        } else {
            if ($permissions_sent) {
                $_POST['permissions'] = $permissionsString;
            } else {
                $_POST['permissions'] = "";
            }
        }
        if (config_option('let_users_create_objects_in_root') && ($contact->isAdminGroup() || $contact->isExecutive() || $contact->isManager())) {
开发者ID:abhinay100,项目名称:feng_app,代码行数:67,代码来源:functions.php


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