Exemplo n.º 1
0
 /**
  * Get business units ids for current user for current access level
  *
  * @return array
  *  value -> business unit id
  */
 protected function getBusinessUnitIds()
 {
     if (AccessLevel::SYSTEM_LEVEL == $this->accessLevel) {
         return $this->businessUnitManager->getBusinessUnitIds();
     } elseif (AccessLevel::LOCAL_LEVEL == $this->accessLevel) {
         return $this->treeProvider->getTree()->getUserBusinessUnitIds($this->currentUser->getId(), $this->getOrganizationContextId());
     } elseif (AccessLevel::DEEP_LEVEL === $this->accessLevel) {
         return $this->treeProvider->getTree()->getUserSubordinateBusinessUnitIds($this->currentUser->getId(), $this->getOrganizationContextId());
     } elseif (AccessLevel::GLOBAL_LEVEL === $this->accessLevel) {
         return $this->businessUnitManager->getBusinessUnitIds($this->getOrganizationContextId());
     }
     return [];
 }
Exemplo n.º 2
0
 public function getBusinessUnitIds()
 {
     $this->buRepo->expects($this->once())->method('getBusinessUnitIds');
     $this->businessUnitManager->getBusinessUnitIds();
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', 'text', array('label' => 'oro.organization.businessunit.name.label', 'required' => true))->add('businessUnit', 'oro_business_unit_tree_select', ['label' => 'oro.organization.businessunit.parent.label', 'empty_value' => 'oro.business_unit.form.none_business_user', 'property_path' => 'owner', 'required' => false, 'choices' => $this->getBusinessUnitChoices($this->businessUnitManager->getBusinessUnitsTree(null, $this->securityFacade->getOrganizationId())), 'business_unit_ids' => $this->businessUnitManager->getBusinessUnitIds(null, $this->securityFacade->getOrganizationId())])->add('phone', 'text', array('label' => 'oro.organization.businessunit.phone.label', 'required' => false))->add('website', 'text', array('label' => 'oro.organization.businessunit.website.label', 'required' => false))->add('email', 'text', array('label' => 'oro.organization.businessunit.email.label', 'required' => false))->add('fax', 'text', array('label' => 'oro.organization.businessunit.fax.label', 'required' => false))->add('appendUsers', 'oro_entity_identifier', array('class' => 'OroUserBundle:User', 'required' => false, 'mapped' => false, 'multiple' => true))->add('removeUsers', 'oro_entity_identifier', array('class' => 'OroUserBundle:User', 'required' => false, 'mapped' => false, 'multiple' => true));
     $builder->addEventListener(FormEvents::PRE_SET_DATA, [$this, 'onPreSetData']);
 }