/** * @Secure(roles={"ROLE_CA"}) */ public function listAction(Account $account = null, $type = null, Agency $agency = null, User $user = null) { $params = $this->get('enigmatic_crm.service.list')->parseRequest($this->get('request')->request->all()); if ($type) { $params['search']['type_type'] = $type; } if ($agency) { $params['search']['agency'] = $agency; } if ($user) { $params['search']['user'] = $user; } if ($this->get('security.authorization_checker')->isGranted('ROLE_RCA') && !$this->get('security.authorization_checker')->isGranted('ROLE_RS')) { $params['search']['agency'] = $this->get('enigmatic_crm.manager.user')->getCurrent() ? $this->get('enigmatic_crm.manager.user')->getCurrent()->getAgency() : null; } elseif ($this->get('security.authorization_checker')->isGranted('ROLE_CA') && !$this->get('security.authorization_checker')->isGranted('ROLE_RS')) { $params['search']['agency'] = $this->get('enigmatic_crm.manager.user')->getCurrent() ? $this->get('enigmatic_crm.manager.user')->getCurrent()->getAgency() : null; $params['search']['activity_account_owner'] = $this->get('enigmatic_crm.manager.user')->getCurrent(); } if ($account) { $params['search']['account'] = $account->getId(); } $activities = $this->get('enigmatic_crm.manager.activity')->getList($params['page'], $params['limit'], $params); $params['entity'] = 'Activity'; $params['total'] = $activities->count(); return $this->get('enigmatic.render')->render($this->renderView('EnigmaticCRMBundle:Activity:list.html.twig', array('activities' => $activities, 'params' => $params, 'account' => $account, 'calendar' => true))); }
public function checkLinkDuplicate(Account $account, $md5) { if ($md5 == md5($account->getName() . $account->getCity()->getId())) { return true; } else { return false; } }
/** * @param Account $account * @param bool $flush * @return Account */ public function save(Account $account, $flush = true) { $account->setDateUpdated(new \DateTime()); $this->em->persist($account); if ($flush) { $this->em->flush(); } return $account; }
public function grantAccount(Account $account) { $grant = false; if ($this->authorizationChecker->isGranted('ROLE_RS')) { $grant = true; } elseif ($this->authorizationChecker->isGranted('ROLE_RCA')) { $agency = $this->userManager->getCurrent()->getAgency(); foreach ($account->getAgencies() as $account_agency) { if ($account_agency->getAgency() == $agency) { $grant = true; break; } } } elseif ($this->authorizationChecker->isGranted('ROLE_CA')) { foreach ($account->getOwners() as $account_owner) { if ($account_owner->getUser() == $this->userManager->getCurrent() && !$account_owner->getEnd()) { $grant = true; break; } } } return $grant; }