本文整理汇总了PHP中QubitAcl::forwardUnauthorized方法的典型用法代码示例。如果您正苦于以下问题:PHP QubitAcl::forwardUnauthorized方法的具体用法?PHP QubitAcl::forwardUnauthorized怎么用?PHP QubitAcl::forwardUnauthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QubitAcl
的用法示例。
在下文中一共展示了QubitAcl::forwardUnauthorized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: 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'));
}
}
}
示例3: 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'));
}
}
示例4: 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'));
}
}
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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'));
}
}
示例9: 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);
}
示例10: execute
public function execute($request)
{
$this->form = new sfForm();
if (!$this->context->user->hasCredential('administrator')) {
QubitAcl::forwardUnauthorized();
}
$criteria = new Criteria();
$criteria->add(QubitSetting::NAME, 'plugins');
if (1 == count($query = QubitSetting::get($criteria))) {
$setting = $query[0];
$this->form->setDefault('enabled', unserialize($setting->__get('value', array('sourceCulture' => true))));
}
$configuration = ProjectConfiguration::getActive();
$pluginPaths = $configuration->getAllPluginPaths();
foreach (sfPluginAdminPluginConfiguration::$pluginNames as $name) {
unset($pluginPaths[$name]);
}
$this->plugins = array();
foreach ($pluginPaths as $name => $path) {
$className = $name . 'Configuration';
if (sfConfig::get('sf_plugins_dir') == substr($path, 0, strlen(sfConfig::get('sf_plugins_dir'))) && is_readable($classPath = $path . '/config/' . $className . '.class.php')) {
$this->installPluginAssets($name, $path);
require_once $classPath;
$class = new $className($configuration);
// Build a list of themes
if (isset($class::$summary) && 1 === preg_match('/theme/i', $class::$summary)) {
$this->plugins[$name] = $class;
}
}
}
if ($request->isMethod('post')) {
$this->form->setValidators(array('enabled' => new sfValidatorChoice(array('choices' => array_keys($this->plugins), 'empty_value' => array(), 'multiple' => true))));
$this->form->bind($request->getPostParameters());
if ($this->form->isValid()) {
if (1 != count($query)) {
$setting = new QubitSetting();
$setting->name = 'plugins';
}
$settings = unserialize($setting->__get('value', array('sourceCulture' => true)));
foreach (array_keys($this->plugins) as $item) {
if (in_array($item, (array) $this->form->getValue('enabled'))) {
$settings[] = $item;
} else {
if (false !== ($key = array_search($item, $settings))) {
unset($settings[$key]);
}
}
}
$setting->__set('value', serialize(array_unique($settings)));
$setting->save();
// Clear cache
$cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
$cacheClear->run();
$this->redirect(array('module' => 'sfPluginAdminPlugin', 'action' => 'themes'));
}
}
}
示例11: 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();
}
}
示例12: execute
public function execute($request)
{
$this->form = new sfForm();
$this->resource = $this->getRoute()->resource;
// Check user authorization
if ($this->resource->isProtected()) {
QubitAcl::forwardUnauthorized();
}
if ($request->isMethod('delete')) {
$this->resource->delete();
$this->redirect(array('module' => 'staticpage', 'action' => 'list'));
}
}
示例13: 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'));
}
}
示例14: execute
public function execute($request)
{
$this->resource = $this->getRoute()->resource;
// Check user authorization
if (!QubitAcl::check($this->resource->informationObject, 'update')) {
QubitAcl::forwardUnauthorized();
}
// Set the digital object's attributes
$this->resource->usageId = $request->usage_id;
$this->resource->mediaTypeId = $request->media_type_id;
// Save the digital object
$this->resource->save();
// Return to edit page
$this->redirect('digitalobject/edit?id=' . $this->resource->id);
}
示例15: execute
public function execute($request)
{
$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, 'read')) {
QubitAcl::forwardUnauthorized();
}
$criteria = new Criteria();
$criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
$criteria->addJoin(QubitRelation::SUBJECT_ID, QubitFunction::ID);
$this->functions = QubitFunction::get($criteria);
}