当前位置: 首页>>代码示例>>PHP>>正文


PHP DataObject::canCreate方法代码示例

本文整理汇总了PHP中DataObject::canCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::canCreate方法的具体用法?PHP DataObject::canCreate怎么用?PHP DataObject::canCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataObject的用法示例。


在下文中一共展示了DataObject::canCreate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: canView

 /**
  * standard SS method
  * @param Member | NULL
  * @return Boolean
  */
 public function canView($member = null)
 {
     if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
         return true;
     }
     return parent::canCreate($member);
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-tax,代码行数:12,代码来源:GSTTaxModifierOptions.php

示例2: canCreate

 /**
  * Prevent creation of non-specific Blocks 
  * @see DataObject::canCreate()
  */
 public function canCreate($member = null)
 {
     if ($this->ClassName == 'Block') {
         return false;
     }
     return parent::canCreate($member);
 }
开发者ID:VisionaerAG,项目名称:page-blocks,代码行数:11,代码来源:Block.php

示例3: canCreate

 public function canCreate($member = null)
 {
     $this->beforeExtending(__FUNCTION__, function ($member = null) {
         if (get_class($this) == 'SocialFeed_Profile') {
             return false;
         }
         if ($this->Parent && $this->Parent->canCreate($member)) {
             return true;
         }
     });
     return parent::canCreate($member);
 }
开发者ID:spekulatius,项目名称:ss-social-feed,代码行数:12,代码来源:SocialFeed_Profile.php

示例4: ItemEditForm

 /**
  * Builds an item edit form.  The arguments to getCMSFields() are the popupController and
  * popupFormName, however this is an experimental API and may change.
  * 
  * @todo In the future, we will probably need to come up with a tigher object representing a partially
  * complete controller with gaps for extra functionality.  This, for example, would be a better way
  * of letting Security/login put its log-in form inside a UI specified elsewhere.
  * 
  * @return Form 
  */
 public function ItemEditForm()
 {
     $list = $this->gridField->getList();
     if (empty($this->record)) {
         $controller = $this->getToplevelController();
         $noActionURL = $controller->removeAction($_REQUEST['url']);
         $controller->getResponse()->removeHeader('Location');
         //clear the existing redirect
         return $controller->redirect($noActionURL, 302);
     }
     $canView = $this->record->canView();
     $canEdit = $this->record->canEdit();
     $canDelete = $this->record->canDelete();
     $canCreate = $this->record->canCreate();
     if (!$canView) {
         $controller = $this->getToplevelController();
         // TODO More friendly error
         return $controller->httpError(403);
     }
     $actions = new FieldList();
     if ($this->record->ID !== 0) {
         if ($canEdit) {
             $actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Save', 'Save'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
         }
         if ($canDelete) {
             $actions->push(FormAction::create('doDelete', _t('GridFieldDetailForm.Delete', 'Delete'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive action-delete'));
         }
     } else {
         // adding new record
         //Change the Save label to 'Create'
         $actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Create', 'Create'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'add'));
         // Add a Cancel link which is a button-like link and link back to one level up.
         $curmbs = $this->Breadcrumbs();
         if ($curmbs && $curmbs->count() >= 2) {
             $one_level_up = $curmbs->offsetGet($curmbs->count() - 2);
             $text = sprintf("<a class=\"%s\" href=\"%s\">%s</a>", "crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all", $one_level_up->Link, _t('GridFieldDetailForm.CancelBtn', 'Cancel'));
             $actions->push(new LiteralField('cancelbutton', $text));
         }
     }
     $fields = $this->component->getFields();
     if (!$fields) {
         $fields = $this->record->getCMSFields();
     }
     // If we are creating a new record in a has-many list, then
     // pre-populate the record's foreign key. Also disable the form field as
     // it has no effect.
     if ($list instanceof HasManyList) {
         $key = $list->getForeignKey();
         $id = $list->getForeignID();
         if (!$this->record->isInDB()) {
             $this->record->{$key} = $id;
         }
         if ($field = $fields->dataFieldByName($key)) {
             $fields->makeFieldReadonly($field);
         }
     }
     // Caution: API violation. Form expects a Controller, but we are giving it a RequestHandler instead.
     // Thanks to this however, we are able to nest GridFields, and also access the initial Controller by
     // dereferencing GridFieldDetailForm_ItemRequest->getController() multiple times. See getToplevelController
     // below.
     $form = new Form($this, 'ItemEditForm', $fields, $actions, $this->component->getValidator());
     $form->loadDataFrom($this->record, $this->record->ID == 0 ? Form::MERGE_IGNORE_FALSEISH : Form::MERGE_DEFAULT);
     if ($this->record->ID && !$canEdit) {
         // Restrict editing of existing records
         $form->makeReadonly();
         // Hack to re-enable delete button if user can delete
         if ($canDelete) {
             $form->Actions()->fieldByName('action_doDelete')->setReadonly(false);
         }
     } elseif (!$this->record->ID && !$canCreate) {
         // Restrict creation of new records
         $form->makeReadonly();
     }
     // Load many_many extraData for record.
     // Fields with the correct 'ManyMany' namespace need to be added manually through getCMSFields().
     if ($list instanceof ManyManyList) {
         $extraData = $list->getExtraData('', $this->record->ID);
         $form->loadDataFrom(array('ManyMany' => $extraData));
     }
     // TODO Coupling with CMS
     $toplevelController = $this->getToplevelController();
     if ($toplevelController && $toplevelController instanceof LeftAndMain) {
         // Always show with base template (full width, no other panels),
         // regardless of overloaded CMS controller templates.
         // TODO Allow customization, e.g. to display an edit form alongside a search form from the CMS controller
         $form->setTemplate('LeftAndMain_EditForm');
         $form->addExtraClass('cms-content cms-edit-form center');
         $form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
         if ($form->Fields()->hasTabset()) {
             $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
//.........这里部分代码省略.........
开发者ID:8secs,项目名称:cocina,代码行数:101,代码来源:GridFieldDetailForm.php

示例5: canDelete

 /**
  * @param null $member
  * @return bool
  */
 public function canDelete($member = null)
 {
     $parent = parent::canCreate($member);
     $manage = Permission::check('TEAM_MANAGE', 'any', $member);
     return $parent || $manage;
 }
开发者ID:helpfulrobot,项目名称:wernerkrauss-silverstripe-team,代码行数:10,代码来源:TeamMember.php

示例6: canCreate

 /**
  * @param Member $member
  *
  * @return bool
  */
 public function canCreate($member = null)
 {
     if (!$member) {
         $member = Member::currentUser();
     }
     if (!$member) {
         return false;
     }
     if (Permission::checkMember($member, 'ADMIN')) {
         return true;
     }
     // This calls canCreate on extensions.
     return parent::canCreate($member);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-deploynaut,代码行数:19,代码来源:DNProject.php

示例7: canCreate

 public function canCreate($member = null)
 {
     $method = __FUNCTION__;
     $this->beforeExtending(__FUNCTION__, function ($member) use($method) {
         if (!$this->checkIfHasGlobalMenuPermission($member)) {
             return false;
         }
         if (singleton('SiteTree')->{$method}($member)) {
             return true;
         }
     });
     return parent::canCreate($member);
 }
开发者ID:milkyway-multimedia,项目名称:ss-linkable-menus,代码行数:13,代码来源:LinkableMenu.php

示例8: canEdit

 /**
  * Standard SS method
  * @param Member $member
  * @return Boolean
  */
 function canEdit($member = null)
 {
     if ($this->Status == "Pending" || $this->Status == "Incomplete") {
         if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
             return true;
         }
         return parent::canCreate($member);
     }
     return false;
 }
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce,代码行数:15,代码来源:EcommercePayment.php

示例9: canCreate

 public function canCreate($member = null)
 {
     $this->beforeExtending(__METHOD__, function ($member) {
         if (!$this->checkIfHasGlobalMenuPermission($member)) {
             return false;
         }
     });
     return parent::canCreate($member);
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-linkable-menus,代码行数:9,代码来源:LinkableMenu.php

示例10: getColumnContent

 /**
  * Returns the columns content for the given GridField, record and column 
  * name.
  *
  * @param GridField  $gridField  GridField to get content for
  * @param DataObject $record     Record to get content for
  * @param string     $columnName Column name to get content for
  * 
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     $content = '';
     if ($record->canCreate()) {
         $field = GridField_FormAction::create($gridField, 'DuplicateRecord' . $record->ID, false, "duplicaterecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-duplicate')->setAttribute('title', _t('GridAction.Duplicate', "Duplicate"))->setAttribute('data-icon', 'addpage')->setDescription(_t('GridAction.DUPLICATE_DESCRIPTION', 'Duplicate'));
         $content = $field->Field();
     }
     return $content;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:19,代码来源:SilvercartGridFieldDuplicateAction.php

示例11: canCreate

 public function canCreate($member = null)
 {
     return $this->stat('can_create') === false ? false : parent::canCreate($member);
 }
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-flexiform,代码行数:4,代码来源:FlexiFormField.php

示例12: ItemEditForm

 /**
  * Builds an item edit form.  The arguments to getCMSFields() are the popupController and
  * popupFormName, however this is an experimental API and may change.
  *
  * @todo In the future, we will probably need to come up with a tigher object representing a partially
  * complete controller with gaps for extra functionality.  This, for example, would be a better way
  * of letting Security/login put its log-in form inside a UI specified elsewhere.
  *
  * @return Form
  */
 public function ItemEditForm()
 {
     $list = $this->gridField->getList();
     if (empty($this->record)) {
         $controller = $this->getToplevelController();
         $url = $controller->getRequest()->getURL();
         $noActionURL = $controller->removeAction($url);
         $controller->getResponse()->removeHeader('Location');
         //clear the existing redirect
         return $controller->redirect($noActionURL, 302);
     }
     $canView = $this->record->canView();
     $canEdit = $this->record->canEdit();
     $canDelete = $this->record->canDelete();
     $canCreate = $this->record->canCreate();
     if (!$canView) {
         $controller = $this->getToplevelController();
         // TODO More friendly error
         return $controller->httpError(403);
     }
     // Build actions
     $actions = $this->getFormActions();
     // If we are creating a new record in a has-many list, then
     // pre-populate the record's foreign key.
     if ($list instanceof HasManyList && !$this->record->isInDB()) {
         $key = $list->getForeignKey();
         $id = $list->getForeignID();
         $this->record->{$key} = $id;
     }
     $fields = $this->component->getFields();
     if (!$fields) {
         $fields = $this->record->getCMSFields();
     }
     // If we are creating a new record in a has-many list, then
     // Disable the form field as it has no effect.
     if ($list instanceof HasManyList) {
         $key = $list->getForeignKey();
         if ($field = $fields->dataFieldByName($key)) {
             $fields->makeFieldReadonly($field);
         }
     }
     // Caution: API violation. Form expects a Controller, but we are giving it a RequestHandler instead.
     // Thanks to this however, we are able to nest GridFields, and also access the initial Controller by
     // dereferencing GridFieldDetailForm_ItemRequest->getController() multiple times. See getToplevelController
     // below.
     $form = new Form($this, 'ItemEditForm', $fields, $actions, $this->component->getValidator());
     $form->loadDataFrom($this->record, $this->record->ID == 0 ? Form::MERGE_IGNORE_FALSEISH : Form::MERGE_DEFAULT);
     if ($this->record->ID && !$canEdit) {
         // Restrict editing of existing records
         $form->makeReadonly();
         // Hack to re-enable delete button if user can delete
         if ($canDelete) {
             $form->Actions()->fieldByName('action_doDelete')->setReadonly(false);
         }
     } elseif (!$this->record->ID && !$canCreate) {
         // Restrict creation of new records
         $form->makeReadonly();
     }
     // Load many_many extraData for record.
     // Fields with the correct 'ManyMany' namespace need to be added manually through getCMSFields().
     if ($list instanceof ManyManyList) {
         $extraData = $list->getExtraData('', $this->record->ID);
         $form->loadDataFrom(array('ManyMany' => $extraData));
     }
     // TODO Coupling with CMS
     $toplevelController = $this->getToplevelController();
     if ($toplevelController && $toplevelController instanceof LeftAndMain) {
         // Always show with base template (full width, no other panels),
         // regardless of overloaded CMS controller templates.
         // TODO Allow customization, e.g. to display an edit form alongside a search form from the CMS controller
         $form->setTemplate('LeftAndMain_EditForm');
         $form->addExtraClass('cms-content cms-edit-form center');
         $form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
         if ($form->Fields()->hasTabset()) {
             $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
             $form->addExtraClass('cms-tabset');
         }
         $form->Backlink = $this->getBackLink();
     }
     $cb = $this->component->getItemEditFormCallback();
     if ($cb) {
         $cb($form, $this);
     }
     $this->extend("updateItemEditForm", $form);
     return $form;
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:96,代码来源:GridFieldDetailForm.php


注:本文中的DataObject::canCreate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。