protected function getColor(Activity $activity = null, $replanned = false, $type = ActivityType::CALL) { if ($activity->getUser() == $this->userManager->getCurrent()) { if ($replanned) { if ($type == ActivityType::CALL) { return '#A9B7C0'; } else { return '#BBCBA3'; } } else { if ($type == ActivityType::CALL) { return '#3B90AC'; } else { return '#2E8B57'; } } } else { if ($this->authorizationChecker->isGranted('ROLE_RS')) { if ($replanned) { return '#CCCCCC'; } else { return $this->parseIdColor($activity->getAccount()->getId()); } } elseif ($this->authorizationChecker->isGranted('ROLE_RCA')) { if ($replanned) { return '#CCCCCC'; } else { return $this->parseIdColor($activity->getUser()->getId()); } } elseif ($this->authorizationChecker->isGranted('ROLE_CA')) { if ($replanned) { if ($type == ActivityType::CALL) { return '#C0B997'; } else { return '#C0B997'; } } else { if ($type == ActivityType::CALL) { return '#C0B35D'; } else { return '#C0B35D'; } } } } return '#C0B35D'; }
public function grantActivity(Activity $activity, $action = 'view') { $grant = false; if ($this->authorizationChecker->isGranted('ROLE_RS')) { $grant = true; } elseif ($this->authorizationChecker->isGranted('ROLE_RCA') || $this->authorizationChecker->isGranted('ROLE_CA')) { $agency = $this->userManager->getCurrent()->getAgency(); foreach ($activity->getUser()->getAgencies() as $histoAgence) { if ($agency == $histoAgence->getAgency()) { if ($histoAgence->getDateCreated() <= $activity->getDateCreated()) { if ($histoAgence->getEnd()) { if ($histoAgence->getEnd()->getDateEnd() > $activity->getDateCreated()) { $grant = true; } } else { $grant = true; } } } } } if ($this->authorizationChecker->isGranted('ROLE_CA') && !$this->authorizationChecker->isGranted('ROLE_RCA')) { if ($grant) { $grant = false; if ($action == 'view') { foreach ($activity->getAccount()->getOwners() as $account_owner) { if ($account_owner->getUser() == $this->userManager->getCurrent() && !$account_owner->getEnd()) { $grant = true; break; } } } else { if ($activity->getUser() == $this->userManager->getCurrent()) { $grant = true; } } } } return $grant; }
/** * Constructor */ public function __construct(Account $account = null, Activity $activity = null, User $user = null, ActivityType $type = null) { $this->account = $account; $this->user = $user; $this->type = $type; $this->dateStart = new \DateTime(); $this->dateCreated = new \DateTime(); $this->dateUpdated = new \DateTime(); if ($activity) { $this->account = $activity->getAccount(); $this->user = $activity->getUser(); $this->setReplannedBy($activity); $this->type = $activity->getType(); $this->comment = $activity->getComment(); $this->dateStart = $activity->getDateStart(); } }