本文整理汇总了PHP中QubitAcl::check方法的典型用法代码示例。如果您正苦于以下问题:PHP QubitAcl::check方法的具体用法?PHP QubitAcl::check怎么用?PHP QubitAcl::check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QubitAcl
的用法示例。
在下文中一共展示了QubitAcl::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($request)
{
$this->resource = $this->getRoute()->resource;
// Check user authorization
if (!QubitAcl::check($this->resource, 'read')) {
QubitAcl::forwardToSecureAction();
}
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->date = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Acquisition date - This is a mandatory element.')));
$values['date'] = $this->resource->date;
$validatorSchema->sourceOfAcquisition = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Source of acquisition - This is a mandatory element.')));
$values['sourceOfAcquisition'] = $this->resource->getSourceOfAcquisition(array('culltureFallback' => true));
$validatorSchema->locationInformation = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Location information - This is a mandatory element.')));
$values['locationInformation'] = $this->resource->getLocationInformation(array('culltureFallback' => true));
try {
$validatorSchema->clean($values);
} catch (sfValidatorErrorSchema $e) {
$this->errorSchema = $e;
}
}
}
示例2: 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;
}
}
}
示例3: execute
public function execute($request)
{
$this->form = new sfForm();
$this->resource = $this->getRoute()->resource;
// Get related information object by first grabbing top-level digital
// object
$parent = $this->resource->parent;
if (isset($parent)) {
$this->informationObject = $parent->informationObject;
} else {
$this->informationObject = $this->resource->informationObject;
if (!isset($this->informationObject)) {
$this->forward404();
}
}
// Check user authorization
if (!QubitAcl::check($this->informationObject, 'delete')) {
QubitAcl::forwardUnauthorized();
}
if ($request->isMethod('delete')) {
// Delete the digital object record from the database
$this->resource->delete();
// Redirect to edit page for parent Info Object
if (isset($parent)) {
$this->redirect(array($parent, 'module' => 'digitalobject', 'action' => 'edit'));
} else {
$this->redirect(array($this->informationObject, 'module' => 'informationobject'));
}
}
}
示例4: 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;
}
}
}
示例5: 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());
}
示例6: 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'));
}
}
示例7: 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);
}
示例8: execute
public function execute($request)
{
$this->form = new sfForm();
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
$this->resource = $this->getRoute()->resource;
// Check that object exists and that it is not the root
if (!isset($this->resource) || !isset($this->resource->parent)) {
$this->forward404();
}
// Check if already exists a digital object
if (null !== ($digitalObject = $this->resource->getDigitalObject())) {
$this->redirect(array($digitalObject, 'module' => 'digitalobject', 'action' => 'edit'));
}
// Check user authorization
if (!QubitAcl::check($this->resource, 'update')) {
QubitAcl::forwardUnauthorized();
}
// Check repository file upload limit
$repo = $this->resource->getRepository(array('inherit' => true));
if (null !== $repo && $repo->uploadLimit != -1 && $repo->getDiskUsage(array('units' => 'G')) >= floatval($repo->uploadLimit)) {
$this->redirect(array($repo, 'module' => 'repository', 'action' => 'uploadLimitExceeded'));
}
// Add form fields
$this->addFields($request);
// Process form
if ($request->isMethod('post')) {
$this->form->bind($request->getPostParameters(), $request->getFiles());
if ($this->form->isValid()) {
$this->processForm();
$this->resource->save();
$this->redirect(array($this->resource, 'module' => 'informationobject'));
}
}
}
示例9: 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'));
}
}
示例10: 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);
}
示例11: 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);
}
示例12: 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;
}
}
}
示例13: execute
public function execute($request)
{
if (null === ($this->resource = $this->getRoute()->resource)) {
return $this->generateResponse(404, 'error/ErrorBadRequest', array('summary' => $this->context->i18n->__('Not found')));
}
$this->user = $request->getAttribute('user');
if ($request->isMethod('post')) {
if (QubitAcl::check(QubitInformationObject::getRoot(), 'create')) {
return $this->generateResponse(403, 'error/ErrorBadRequest', array('summary' => $this->context->i18n->__('Forbidden')));
}
$this->packageFormat = $request->getHttpHeader('X-Packaging');
$this->packageContentType = $request->getContentType();
// Check if the packaging format is supported
if (!in_array($this->packageFormat, qtSwordPluginConfiguration::$packaging)) {
return $this->generateResponse(415, 'error/ErrorContent', array('summary' => $this->context->i18n->__('The supplied format is not supported by this server')));
}
// Check if the content type is supported
if (!in_array($this->packageContentType, qtSwordPluginConfiguration::$mediaRanges)) {
return $this->generateResponse(415, 'error/ErrorContent', array('summary' => $this->context->i18n->__('The supplied content type is not supported by this server')));
}
// Save the file temporary
$filename = qtSwordPlugin::saveRequestContent();
// Package name
if (null !== $request->getHttpHeader('Content-Disposition')) {
$this->packageName = substr($request->getHttpHeader('Content-Disposition'), 9);
}
// TODO see [RFC2183]
$this->packageName = $filename;
// Calculated MD5 check does not match the value provided by the client
if (md5(file_get_contents($filename)) != $request->getHttpHeader('Content-MD5')) {
return $this->generateResponse(412, 'error/ErrorChecksumMismatchSuccess', array('summary' => $this->context->i18n->__('Checksum sent does not match the calculated checksum')));
}
try {
$extractor = qtPackageExtractorFactory::build($this->packageFormat, array('filename' => $filename, 'name' => $this->packageName, 'format' => $this->packageFormat, 'resource' => $this->resource, 'type' => $this->packageContentType));
} catch (Exception $e) {
return $this->generateResponse(415, 'error/ErrorContent', array('summary' => $e->getMessage()));
}
// Open package and XML document
$extractor->extract();
// Parse and create objects
$extractor->process();
$this->informationObject = $extractor->informationObject;
// Remove temporary files
$extractor->clean();
return $this->generateResponse(201, 'deposit', array('headers' => array('Location' => $this->context->routing->generate(null, array($this->informationObject, 'module' => 'informationobject')))));
} else {
if ($request->isMethod('put') || $request->isMethod('delete')) {
return $this->generateResponse(501, 'error/ErrorNotImplemented', array('summary' => $this->context->i18n->__('Not implemented')));
} else {
return $this->generateResponse(400, 'error/ErrorBadRequest', array('summary' => $this->context->i18n->__('Bad request')));
}
}
}
示例14: earlyExecute
protected function earlyExecute()
{
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
$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();
}
}
示例15: execute
public function execute($request)
{
$this->form = new sfForm();
$this->resource = $this->getRoute()->resource;
// Check user authorization
if (!QubitAcl::check($this->resource, 'delete')) {
QubitAcl::forwardUnauthorized();
}
if ($request->isMethod('delete')) {
$accession = $this->resource->accession;
$this->resource->delete();
$this->redirect(array($accession, 'module' => 'accession'));
}
}