本文整理汇总了PHP中QubitAcl类的典型用法代码示例。如果您正苦于以下问题:PHP QubitAcl类的具体用法?PHP QubitAcl怎么用?PHP QubitAcl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QubitAcl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($request)
{
$this->form = new sfForm();
$this->resource = $this->getRoute()->resource;
// Check that this isn't the root
if (!isset($this->resource->parent)) {
$this->forward404();
}
// Check user authorization
if (!QubitAcl::check($this->resource, 'delete')) {
QubitAcl::forwardUnauthorized();
}
if ($request->isMethod('delete')) {
$parent = $this->resource->parent;
foreach ($this->resource->descendants->andSelf()->orderBy('rgt') as $item) {
// Delete related digitalObjects
foreach ($item->digitalObjects as $digitalObject) {
$digitalObject->informationObjectId = null;
$digitalObject->delete();
}
$item->delete();
}
if (isset($parent->parent)) {
$this->redirect(array($parent, 'module' => 'informationobject'));
}
$this->redirect(array('module' => 'informationobject', 'action' => 'browse'));
}
}
示例2: execute
public function execute($request)
{
$this->resource = $this->getRoute()->resource;
if (!$this->resource instanceof QubitTerm) {
$this->forward404();
}
// Check that this isn't the root
if (!isset($this->resource->parent)) {
$this->forward404();
}
if (1 > strlen($title = $this->resource->__toString())) {
$title = $this->context->i18n->__('Untitled');
}
$this->response->setTitle("{$title} - {$this->response->getTitle()}");
if (QubitAcl::check($this->resource, 'update')) {
$validatorSchema = new sfValidatorSchema();
$values = array();
$validatorSchema->name = new sfValidatorCallback(array('callback' => array($this, 'checkForRepeatedNames')));
$values['name'] = $this->resource->getName(array('cultureFallback' => true));
try {
$validatorSchema->clean($values);
} catch (sfValidatorErrorSchema $e) {
$this->errorSchema = $e;
}
}
QubitTreeView::addAssets($this->response);
}
示例3: earlyExecute
public function earlyExecute()
{
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
$this->resource = new QubitAccession();
if (isset($this->getRoute()->resource)) {
$this->resource = $this->getRoute()->resource;
// Check user authorization
if (!QubitAcl::check($this->resource, 'update')) {
QubitAcl::forwardUnauthorized();
}
} else {
// Check user authorization
if (!QubitAcl::check($this->resource, 'create')) {
QubitAcl::forwardUnauthorized();
}
}
$title = $this->context->i18n->__('Add new accession record');
if (isset($this->getRoute()->resource)) {
if (1 > strlen($title = $this->resource->__toString())) {
$title = $this->context->i18n->__('Untitled');
}
$title = $this->context->i18n->__('Edit %1%', array('%1%' => $title));
}
$this->response->setTitle("{$title} - {$this->response->getTitle()}");
$this->relatedDonorComponent = new AccessionRelatedDonorComponent($this->context, 'accession', 'relatedDonor');
$this->relatedDonorComponent->resource = $this->resource;
$this->relatedDonorComponent->execute($this->request);
$this->rightEditComponent = new RightEditComponent($this->context, 'right', 'edit');
$this->rightEditComponent->resource = $this->resource;
$this->rightEditComponent->execute($this->request);
}
示例4: execute
public function execute($request)
{
$criteria = new Criteria();
$criteria = QubitTaxonomy::addEditableTaxonomyCriteria($criteria);
$criteria->addJoin(QubitTaxonomy::ID, QubitTaxonomyI18n::ID);
$criteria->add(QubitTaxonomyI18n::CULTURE, $this->context->user->getCulture());
// Narrow results by query
if (0 < strlen($request->query)) {
$criteria->add(QubitTaxonomyI18n::NAME, "{$request->query}%", Criteria::LIKE);
}
// Limit results by ACL
$criterion = QubitAcl::getFilterCriterion($criteria, QubitTaxonomy::getById(QubitTaxonomy::ROOT_ID), 'createTerm');
if (isset($criterion) && true !== $criterion) {
$criteria->addAnd($criterion);
} else {
if (false === $criterion) {
// If access denied to all taxonomies, then return nothing
return sfView::NONE;
}
}
// Sort by name
$criteria->addAscendingOrderByColumn(QubitTaxonomyI18n::NAME);
// Show first 10 results
$criteria->setLimit(10);
$this->taxonomies = QubitTaxonomy::get($criteria);
}
示例5: execute
public function execute($request)
{
parent::execute($request);
$this->isdiah = new sfEhriIsdiahPlugin($this->resource);
if (1 > strlen($title = $this->resource)) {
$title = $this->context->i18n->__('Untitled');
}
$this->response->setTitle("{$title} - {$this->response->getTitle()}");
if (QubitAcl::check($this->resource, 'update')) {
$validatorSchema = new sfValidatorSchema();
$valuess = array();
$validatorSchema->authorizedFormOfName = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Authorized form of name%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.1.2">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>'))));
$values['authorizedFormOfName'] = $this->resource->getAuthorizedFormOfName(array('culltureFallback' => true));
$validatorSchema->identifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Identifier%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.1.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>'))));
$values['identifier'] = $this->resource->identifier;
$validatorSchema->primaryContact = new sfValidatorAnd(array(new QubitValidatorCountable(), new sfValidatorOr(array(new sfValidatorSchema(array('city' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('countryCode' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('postalCode' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('region' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('streetAddress' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true))), array('required' => true), array('invalid' => $this->context->i18n->__('%1%Contact information%2% - You %3%must%4% at least include one of the following location or address fields: city, country, postal code, region or street address.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.2.1">', '%2%' => '</a>', '%3%' => '<a href="<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>'))))), array('required' => true), array('required' => $this->context->i18n->__('%1%Contact information%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.2.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>'))));
if (null !== $this->resource->getPrimaryContact()) {
$values['primaryContact']['city'] = $this->resource->getPrimaryContact()->getCity(array('culltureFallback' => true));
$values['primaryContact']['countryCode'] = $this->resource->getPrimaryContact()->countryCode;
$values['primaryContact']['postalCode'] = $this->resource->getPrimaryContact()->postalCode;
$values['primaryContact']['region'] = $this->resource->getPrimaryContact()->getRegion(array('culltureFallback' => true));
$values['primaryContact']['streetAddress'] = $this->resource->getPrimaryContact()->streetAddress;
}
try {
$validatorSchema->clean($values);
} catch (sfValidatorErrorSchema $e) {
$this->errorSchema = $e;
}
}
}
示例6: execute
public function execute($request)
{
parent::execute($request);
$this->isaar = new sfIsaarPlugin($this->resource);
if (1 > strlen($title = $this->resource->__toString())) {
$title = $this->context->i18n->__('Untitled');
}
$this->response->setTitle("{$title} - {$this->response->getTitle()}");
if (QubitAcl::check($this->resource, 'update')) {
$validatorSchema = new sfValidatorSchema();
$values = array();
$validatorSchema->authorizedFormOfName = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Authorized form of name%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.1.2">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>'))));
$values['authorizedFormOfName'] = $this->resource->getAuthorizedFormOfName(array('cultureFallback' => true));
$validatorSchema->datesOfExistence = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Dates of existence%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.2.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>'))));
$values['datesOfExistence'] = $this->resource->getDatesOfExistence(array('cultureFallback' => true));
$validatorSchema->descriptionIdentifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Description identifier%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.4.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>'))));
$values['descriptionIdentifier'] = $this->resource->descriptionIdentifier;
$validatorSchema->entityType = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Type of entity%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.1.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>'))));
$values['entityType'] = $this->resource->entityType;
try {
$validatorSchema->clean($values);
} catch (sfValidatorErrorSchema $e) {
$this->errorSchema = $e;
}
}
}
示例7: execute
public function execute($request)
{
if (!$this->context->user->hasCredential(array('contributor', 'editor', 'administrator'), false)) {
QubitAcl::forwardUnauthorized();
}
if (!isset($request->limit)) {
$request->limit = sfConfig::get('app_hits_per_page');
}
$criteria = new Criteria();
switch ($request->sort) {
case 'nameDown':
$criteria->addDescendingOrderByColumn('identifier');
break;
case 'nameUp':
$criteria->addAscendingOrderByColumn('identifier');
break;
case 'updatedDown':
$criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
break;
case 'updatedUp':
$criteria->addAscendingOrderByColumn(QubitObject::UPDATED_AT);
break;
default:
if (!$this->getUser()->isAuthenticated()) {
$criteria->addAscendingOrderByColumn('authorized_form_of_name');
} else {
$criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
}
}
// Page results
$this->pager = new QubitPager('QubitAccession');
$this->pager->setCriteria($criteria);
$this->pager->setMaxPerPage($request->limit);
$this->pager->setPage($request->page);
}
示例8: execute
public function execute($request)
{
parent::execute($request);
$this->dc = new sfDcPlugin($this->resource);
if (1 > strlen($title = $this->resource)) {
$title = $this->context->i18n->__('Untitled');
}
$this->response->setTitle("{$title} - {$this->response->getTitle()}");
if (QubitAcl::check($this->resource, 'update')) {
$validatorSchema = new sfValidatorSchema();
$values = array();
$validatorSchema->identifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Identifier%2% - This is a mandatory element.', array('%1%' => '<a href="http://dublincore.org/documents/dcmi-terms/#elements-identifier">', '%2%' => '</a>'))));
$values['identifier'] = $this->resource->identifier;
$validatorSchema->title = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Title%2% - This is a mandatory element.', array('%1%' => '<a href="http://dublincore.org/documents/dcmi-terms/#elements-title">', '%2%' => '</a>'))));
$values['title'] = $this->resource->getTitle(array('cultureFallback' => true));
$validatorSchema->repository = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Relation%2% (%3%isLocatedAt%4%) - This is a mandatory element for this resource or one its higher descriptive levels (if part of a collection hierarchy).', array('%1%' => '<a href="http://dublincore.org/documents/dcmi-terms/#elements-relation">', '%2%' => '</a>', '%3%' => '<a href="http://dublincore.org/groups/collections/collection-application-profile/#colcldisLocatedAt">', '%4%' => '</a>'))));
foreach ($this->resource->ancestors->andSelf() as $item) {
$values['repository'] = $item->repository;
if (isset($values['repository'])) {
break;
}
}
try {
$validatorSchema->clean($values);
} catch (sfValidatorErrorSchema $e) {
$this->errorSchema = $e;
}
}
}
示例9: earlyExecute
protected function earlyExecute()
{
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
$this->resource = new QubitDonor();
if (isset($this->getRoute()->resource)) {
$this->resource = $this->getRoute()->resource;
// Check user authorization
if (!QubitAcl::check($this->resource, 'update')) {
QubitAcl::forwardUnauthorized();
}
// Add optimistic lock
$this->form->setDefault('serialNumber', $this->resource->serialNumber);
$this->form->setValidator('serialNumber', new sfValidatorInteger());
$this->form->setWidget('serialNumber', new sfWidgetFormInputHidden());
} else {
// Check user authorization
if (!QubitAcl::check($this->resource, 'create')) {
QubitAcl::forwardUnauthorized();
}
}
$title = $this->context->i18n->__('Add new donor');
if (isset($this->getRoute()->resource)) {
if (1 > strlen($title = $this->resource->__toString())) {
$title = $this->context->i18n->__('Untitled');
}
$title = $this->context->i18n->__('Edit %1%', array('%1%' => $title));
}
$this->response->setTitle("{$title} - {$this->response->getTitle()}");
$this->contactInformationEditComponent = new ContactInformationEditComponent($this->context, 'contactinformation', 'editContactInformation');
$this->contactInformationEditComponent->resource = $this->resource;
$this->contactInformationEditComponent->execute($this->request);
}
示例10: execute
public function execute($request)
{
if (!$this->getUser()->isAuthenticated()) {
QubitAcl::forwardUnauthorized();
}
if (!isset($request->limit)) {
$request->limit = sfConfig::get('app_hits_per_page');
}
$criteria = new Criteria();
// Do source culture fallback
$criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitPhysicalObject');
switch ($request->sort) {
case 'nameDown':
$criteria->addDescendingOrderByColumn('name');
break;
case 'locationDown':
$criteria->addDescendingOrderByColumn('location');
break;
case 'locationUp':
$criteria->addAscendingOrderByColumn('location');
break;
case 'nameUp':
default:
$request->sort = 'nameUp';
$criteria->addAscendingOrderByColumn('name');
}
// Page results
$this->pager = new QubitPager('QubitPhysicalObject');
$this->pager->setCriteria($criteria);
$this->pager->setMaxPerPage($request->limit);
$this->pager->setPage($request->page);
}
示例11: execute
public function execute($request)
{
$this->resource = $request->getAttribute('sf_route')->resource;
$criteria = new Criteria();
$criteria->add(QubitEvent::ACTOR_ID, $this->resource->id);
$criteria->addJoin(QubitEvent::INFORMATION_OBJECT_ID, QubitInformationObject::ID);
$criteria->addAscendingOrderByColumn(QubitEvent::TYPE_ID);
// Sort info objects alphabetically (w/ fallback)
$criteria->addAscendingOrderByColumn('title');
$criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitInformationObject');
// Filter draft descriptions
$criteria = QubitAcl::addFilterDraftsCriteria($criteria);
$this->relatedInfoObjects = array();
foreach (QubitEvent::get($criteria) as $item) {
$this->relatedInfoObjects[$item->type->getRole()][] = $item->informationObject;
}
// Get "subject of" information objects (name access point)
$criteria = new Criteria();
$criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
$criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID);
$this->subjectInfoObjects = array();
foreach (QubitRelation::get($criteria) as $item) {
$this->subjectInfoObjects[] = $item->subject;
}
}
示例12: earlyExecute
protected function earlyExecute()
{
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
$this->resource = new QubitActor();
// Make root actor the parent of new actors
$this->resource->parentId = QubitActor::ROOT_ID;
if (isset($this->getRoute()->resource)) {
$this->resource = $this->getRoute()->resource;
// Check that this isn't the root
if (!isset($this->resource->parent)) {
$this->forward404();
}
// Check user authorization
if (!QubitAcl::check($this->resource, 'update')) {
QubitAcl::forwardUnauthorized();
}
// Add optimistic lock
$this->form->setDefault('serialNumber', $this->resource->serialNumber);
$this->form->setValidator('serialNumber', new sfValidatorInteger());
$this->form->setWidget('serialNumber', new sfWidgetFormInputHidden());
} else {
// Check user authorization against Actor ROOT
if (!QubitAcl::check(QubitActor::getById(QubitActor::ROOT_ID), 'create')) {
QubitAcl::forwardUnauthorized();
}
}
$this->form->setDefault('next', $this->request->getReferer());
$this->form->setValidator('next', new sfValidatorString());
$this->form->setWidget('next', new sfWidgetFormInputHidden());
}
示例13: execute
public function execute($request)
{
$this->form = new sfForm();
$this->resource = $this->getRoute()->resource;
// Check that this isn't the root
if (!isset($this->resource->parent)) {
$this->forward404();
}
// Don't delete protected terms
if ($this->resource->isProtected()) {
$this->forward('admin', 'termPermission');
}
// Check user authorization
if (!QubitAcl::check($this->resource, 'delete')) {
QubitAcl::forwardUnauthorized();
}
if ($request->isMethod('delete')) {
foreach ($this->resource->descendants->andSelf()->orderBy('rgt') as $item) {
if (QubitAcl::check($item, 'delete')) {
$item->delete();
}
}
if (isset($this->resource->taxonomy)) {
$this->redirect(array($this->resource->taxonomy, 'module' => 'taxonomy'));
}
$this->redirect(array('module' => 'taxonomy', 'action' => 'list'));
}
}
示例14: execute
public function execute($request)
{
if (!isset($request->limit)) {
$request->limit = sfConfig::get('app_hits_per_page');
}
$this->resource = $this->getRoute()->resource;
// Check that this isn't the root
if (!isset($this->resource->parent)) {
$this->forward404();
}
$query = QubitSearch::getInstance()->addTerm($this->resource->id, 'parentId');
if (isset($request->query)) {
$query = $request->query;
}
$query = QubitAcl::searchFilterByRepository($query, 'read');
$query = QubitAcl::searchFilterDrafts($query);
$this->pager = new QubitArrayPager();
$this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query);
$this->pager->setMaxPerPage($request->limit);
$this->pager->setPage($request->page);
$ids = array();
foreach ($this->pager->getResults() as $hit) {
$ids[] = $hit->getDocument()->id;
}
$criteria = new Criteria();
$criteria->add(QubitInformationObject::ID, $ids, Criteria::IN);
$this->informationObjects = QubitInformationObject::get($criteria);
}
示例15: execute
public function execute($request)
{
if (!isset($request->limit)) {
$request->limit = sfConfig::get('app_hits_per_page');
}
if (isset($request->subquery)) {
try {
// Parse query string
$query = QubitSearch::getInstance()->parse($request->subquery);
} catch (Exception $e) {
$this->error = $e->getMessage();
return;
}
} else {
$this->redirect(array('module' => 'actor', 'action' => 'browse'));
}
$query->addSubquery(QubitSearch::getInstance()->addTerm('QubitActor', 'className'), true);
$query = QubitAcl::searchFilterByResource($query, QubitActor::getById(QubitActor::ROOT_ID));
$this->pager = new QubitArrayPager();
try {
$this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query);
} catch (Exception $e) {
$this->error = $e->getMessage();
return;
}
$this->pager->setMaxPerPage($request->limit);
$this->pager->setPage($request->page);
$ids = array();
foreach ($this->pager->getResults() as $hit) {
$ids[] = $hit->getDocument()->id;
}
$criteria = new Criteria();
$criteria->add(QubitActor::ID, $ids, Criteria::IN);
$this->actors = QubitActor::get($criteria);
}