Beispiel #1
0
 /**
  * @Route("/user/{platformid}/{organizationid}/new", name="_user_new", requirements={
  *    "platformid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  *    "organizationid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  * })
  */
 public function newAction(Request $request, $platformid, $organizationid)
 {
     $platform_repository = (new PlatformPeer())->getLdapManager()->getRepository('platform');
     $platform = $platform_repository->getPlatformByUUID($platformid);
     $organizationPeer = new OrganizationPeer($platform->getDn());
     $organization_repository = $organizationPeer->getLdapManager()->getRepository('organization');
     $organization = $organization_repository->getOrganizationByUUID($organizationid);
     $domainPeer = new DomainPeer($organization->getDn());
     $domain_repository = $domainPeer->getLdapManager()->getRepository('domain');
     $user = new User();
     $user->setZacaciastatus("enable");
     $user->setPlatformId($platform->getEntryUUID());
     $user->setOrganizationId($organization->getEntryUUID());
     $form = $this->createForm(UserType::class, $user, array('domain_choices' => $domain_repository->getAllDomainsAsChoice()));
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $userPeer = new UserPeer($organization->getDn());
             $user->setCn($user->getDisplayname());
             $user->setEmail(sprintf('%s@%s', $user->getEmail(), $user->getDomain()));
             $userPeer->createUser($user);
             return $this->redirectToRoute('_user', array('platformid' => $platform->getEntryUUID(), 'organizationid' => $organization->getEntryUUID()));
         } catch (LdapConnectionException $e) {
             echo "Failed to add server!" . PHP_EOL;
             echo $e->getMessage() . PHP_EOL;
         }
     }
     return $this->render('ZacaciaBundle:User:new.html.twig', array('platform' => $platform, 'organization' => $organization, 'form' => $form->createView()));
 }
 public function transUser($ldapObject, $platform, $organization)
 {
     $user = new User();
     $user->setUserId($ldapObject->getEntryUUID());
     $user->setPlatformId($platform->getEntryUUID());
     $user->setOrganizationId($organization->getEntryUUID());
     $user->setCn($ldapObject->getCn());
     $user->setZacaciaStatus($ldapObject->getZacaciaStatus());
     $user->setCn($ldapObject->getCn());
     $user->setDn($ldapObject->getDn());
     $user->setDisplayName($ldapObject->getDisplayName());
     $user->setMail($ldapObject->getMail());
     $user->setSn($ldapObject->getSn());
     $user->setGivenName($ldapObject->getGivenName());
     $user->setUid($ldapObject->getUid());
     $user->setEmail($this::getEmailUserPart($ldapObject->getMail()));
     $user->setDomain($this::getEmailDomainPart($ldapObject->getMail()));
     $user->setZarafaAccount($ldapObject->getZarafaAccount());
     $user->setZarafaHidden($ldapObject->getZarafaHidden());
     $user->setZarafaQuotaOverride($ldapObject->getZarafaQuotaOverride());
     if ($user->getZarafaQuotaOverride()) {
         $user->setZarafaQuotaSoft($ldapObject->getZarafaQuotaSoft());
         $user->setZarafaQuotaWarn($ldapObject->getZarafaQuotaWarn());
         $user->setZarafaQuotaHard($ldapObject->getZarafaQuotaHard());
     } else {
         $user->setZarafaQuotaSoft(0);
         $user->setZarafaQuotaWarn(0);
         $user->setZarafaQuotaHard(0);
     }
     #$user->set($ldapObject->get());
     return $user;
 }