/** * @param OptionsResolver $resolver */ public function configureOptions(OptionsResolver $resolver) { $journal = $this->journalService->getSelectedJournal(false); if (!$journal instanceof Journal) { return; } $resolver->setDefaults(array('choices' => $journal->getLocaleCodeBag())); }
/** * @param OptionsResolver $resolver */ public function configureOptions(OptionsResolver $resolver) { $journal = $this->journalService->getSelectedJournal(false); if (!$journal instanceof Journal) { return; } $journalLocaleBag = $journal->getLocaleCodeBag(); if (!in_array($journal->getMandatoryLang()->getCode(), $journalLocaleBag)) { $journalLocaleBag[] = $journal->getMandatoryLang()->getCode(); } $resolver->setDefaults(array('locales' => $journalLocaleBag, 'default_locale' => $journal->getMandatoryLang()->getCode(), 'required_locales' => [$journal->getMandatoryLang()->getCode()])); }
/** * Check if user is selected journal publisher manager * * @return bool */ public function isGrantedForPublisher() { $token = $this->tokenStorage->getToken(); if ($token && method_exists($token, 'getUser')) { /** @var User $user */ $user = $token->getUser(); } else { return false; } $selectedJournal = $this->journalService->getSelectedJournal(); if ($selectedJournal) { $publisher = $selectedJournal->getPublisher(); } else { $publisherId = $this->requestStack->getCurrentRequest()->attributes->get('publisherId'); if (!$publisherId) { return false; } $publisher = $this->em->getRepository('OjsJournalBundle:Publisher')->find($publisherId); } if ($user->isAdmin()) { return true; } foreach ($publisher->getPublisherManagers() as $manager) { if ($manager->getUser()->getId() == $user->getId()) { return true; } } return false; }
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) { $mappings = $targetEntity->getAssociationMappings(); if (!array_key_exists('journal', $mappings) || $mappings['journal']['targetEntity'] !== 'Ojs\\JournalBundle\\Entity\\Journal') { return ''; } try { $selectedJournal = $this->journalService->getSelectedJournal(); } catch (\Exception $e) { return ''; } if (!$selectedJournal) { return ''; } $journalJoinColumn = $mappings['journal']['joinColumns'][0]['name']; $addCondSql = $targetTableAlias . '.' . $journalJoinColumn . ' = ' . $selectedJournal->getId(); return $addCondSql; }
/** * {@inheritdoc} */ public function getSecurityIdentities(Token\TokenInterface $token) { $sids = array(); // add user security identity if (!$token instanceof Token\AnonymousToken) { try { $sids[] = UserSecurityIdentity::fromToken($token); } catch (\InvalidArgumentException $invalid) { // ignore, user has no user security identity } } // add all reachable roles foreach ($this->roleHierarchy->getReachableRoles($token->getRoles()) as $role) { $sids[] = new RoleSecurityIdentity($role); } // add journal roles $user = $token->getUser(); try { $selectedJournal = $this->journalService->getSelectedJournal(); } catch (\Exception $e) { $selectedJournal = false; } if ($user instanceof User && $selectedJournal instanceof Journal) { foreach ($user->getJournalRoles($selectedJournal) as $journalRoles) { $sids[] = new JournalRoleSecurityIdentity($journalRoles[0], $journalRoles[1]); } } // add built-in special roles if ($this->authenticationTrustResolver->isFullFledged($token)) { $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_FULLY); $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED); $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY); } elseif ($this->authenticationTrustResolver->isRememberMe($token)) { $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED); $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY); } elseif ($this->authenticationTrustResolver->isAnonymous($token)) { $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY); } return $sids; }
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) { $mappings = $targetEntity->getAssociationMappings(); if (!array_key_exists('journal', $mappings) || $mappings['journal']['targetEntity'] !== 'Ojs\\JournalBundle\\Entity\\Journal') { return ''; } //return if journal filter disabled globally for current entity if (isset($GLOBALS[$targetEntity->getName() . '#journalFilter']) && $GLOBALS[$targetEntity->getName() . '#journalFilter'] == false) { return ''; } try { $selectedJournal = $this->journalService->getSelectedJournal(); } catch (\Exception $e) { return ''; } if (!$selectedJournal) { return ''; } $journalJoinColumn = $mappings['journal']['joinColumns'][0]['name']; $addCondSql = $targetTableAlias . '.' . $journalJoinColumn . ' = ' . $selectedJournal->getId(); return $addCondSql; }
/** * @param OptionsResolver $resolver */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array('remote_route' => 'search_journal_users', 'remote_params' => array('journalId' => $this->journalService->getSelectedJournal()->getId()), 'multiple' => true, 'class' => 'OjsUserBundle:User')); }
/** * * @param Article $article * @return string */ public function generateUrl(Article $article) { $journalUrl = $this->journalService->generateUrl($article->getJournal()); return $journalUrl . '/' . $article->getSlug(); }