Beispiel #1
0
 /**
  * @Route("/check/groupname/{platformid}/{organizationid}/{name}", name="_check_groupname", 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})",
  *   "name": ".+"
  * })
  * @Method({"GET","HEAD"})
  */
 public function checkgroupnameAction(Request $request, $platformid, $organizationid, $name)
 {
     $platformPeer = new PlatformPeer();
     $platform_repository = $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);
     $base_dn = sprintf('ou=Groups,%s', $organization->getDn());
     $groupPeer = new GroupPeer($base_dn);
     $groups = $groupPeer->getLdapManager()->getRepository('group')->getGroupByName($name);
     $response = new JsonResponse();
     $response->setData(array('data' => count($groups)));
     return $response;
 }
Beispiel #2
0
 /**
  * @Route("/group/{platformid}/{organizationid}/{groupid}/sendas", name="_group_sendas", 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})",
  *     "groupid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})"
  * })
  */
 public function sendasAction(Request $request, $platformid, $organizationid, $groupid)
 {
     $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);
     $groupPeer = new GroupPeer($organization->getDn());
     $group_repository = $groupPeer->getLdapManager()->getRepository('group');
     $groupLdap = $group_repository->getGroupByUUID($groupid);
     $domainPeer = new DomainPeer($organization->getDn());
     $domain_repository = $domainPeer->getLdapManager()->getRepository('domain');
     $tranformer = new ZacaciaTransformer();
     $group = $tranformer->transGroup($groupLdap, $platform, $organization);
     $form = $this->createForm(GroupType::class, $group, array('domain_choices' => $domain_repository->getAllDomainsAsChoice()));
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $groupLdap->setSn($group->getSn());
             $groupLdap->setGivenName($group->getGivenName());
             $groupLdap->setMail(sprintf('%s@%s', $group->getEmail(), $group->getDomain()));
             $groupLdap->setZarafaHidden($group->getZarafaHidden());
             $groupLdap->setZarafaAccount($group->getZarafaAccount());
             $groupLdap->setZacaciastatus($group->getZacaciastatus());
             $groupPeer->updateGroup($groupLdap);
             return $this->redirectToRoute('_group', array('platformid' => $platform->getEntryUUID(), 'organizationid' => $organization->getEntryUUID()));
         } catch (LdapConnectionException $e) {
             echo "Failed to update group!" . PHP_EOL;
             echo $e->getMessage() . PHP_EOL;
         }
     }
     return $this->render('ZacaciaBundle:Group:edit.html.twig', array('platform' => $platform, 'organization' => $organization, 'group' => $group, 'form' => $form->createView()));
 }