當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataObject::canEdit方法代碼示例

本文整理匯總了PHP中DataObject::canEdit方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObject::canEdit方法的具體用法?PHP DataObject::canEdit怎麽用?PHP DataObject::canEdit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataObject的用法示例。


在下文中一共展示了DataObject::canEdit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: canDelete

 /**
  * standard SS method
  * @param Member $member
  * @return Boolean
  */
 public function canDelete($member = null)
 {
     if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
         return true;
     }
     return parent::canEdit($member);
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce,代碼行數:12,代碼來源:SearchReplacement.php

示例2: getColumnContent

 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->canEdit()) {
         return;
     }
     $data = new ArrayData(array('Link' => Controller::join_links(Director::baseURL(), '/admin/pages/edit/show/', $record->ID)));
     return $data->renderWith('GridFieldEditButton');
 }
開發者ID:helpfulrobot,項目名稱:micschk-silverstripe-gridfieldsitetreebuttons,代碼行數:15,代碼來源:GridFieldEditSiteTreeItemButton.php

示例3: getColumnContent

 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->canEdit()) {
         return;
     }
     $data = new ArrayData(array('Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')));
     return $data->renderWith('GridFieldEditButton');
 }
開發者ID:prostart,項目名稱:cobblestonepath,代碼行數:15,代碼來源:GridFieldEditButton.php

示例4: canEdit

 public function canEdit($member = null)
 {
     $this->beforeExtending(__FUNCTION__, function ($member = null) {
         if ($this->Parent && $this->Parent->canEdit($member)) {
             return true;
         }
     });
     return parent::canEdit($member);
 }
開發者ID:spekulatius,項目名稱:ss-social-feed,代碼行數:9,代碼來源:SocialFeed_Profile.php

示例5: getColumnContent

 /**
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->canEdit()) {
         return;
     }
     $history_controller = singleton('CMSPageHistoryController');
     $data = new ArrayData(array('Link' => Controller::join_links($history_controller->Link('show'), $record->ID)));
     return $data->renderWith('GridFieldPageHistoryButton');
 }
開發者ID:helpfulrobot,項目名稱:briceburg-silverstripe-pageholder,代碼行數:15,代碼來源:GridFieldPageHistoryButton.php

示例6: canEdit

 /**
  * Standard SS Method
  * @param Member $member
  * @var Boolean
  */
 public function canEdit($member = null)
 {
     if (!$member) {
         $member == Member::currentUser();
     }
     $shopAdminCode = EcommerceConfig::get("EcommerceRole", "admin_permission_code");
     if ($member && Permission::checkMember($member, $shopAdminCode)) {
         return true;
     }
     return parent::canEdit($member);
 }
開發者ID:nieku,項目名稱:silverstripe-ecommerce,代碼行數:16,代碼來源:EcommerceDBConfig.php

示例7: deleteinlinecomment

 public function deleteinlinecomment(array $data, Form $form, $request)
 {
     if (!$this->context->canEdit()) {
         return;
     }
     if (!isset($data['ID'])) {
         throw new Exception("Invalid comment ID");
     }
     $comment = DataObject::get_by_id('InlineComment', $data['ID']);
     $comment->delete();
     return singleton('ICUtils')->ajaxResponse("Deleted", true);
 }
開發者ID:nyeholt,項目名稱:silverstripe-inlinecomments,代碼行數:12,代碼來源:InlineCommentForm.php

示例8: checkPerm

 /**
  * Return true or false as to whether a given user can access an object
  * 
  * @param DataObject $node
  *			The object to check perms on
  * @param string $perm
  *			The permission to check against
  * @param Member $member 
  *			The member to check - if not set, the current user is used
  * 
  * @return type 
  */
 public function checkPerm(DataObject $node, $perm, $member = null)
 {
     // if the node doesn't use the extension, fall back to SS logic
     if (!$node->hasExtension('Restrictable')) {
         switch ($perm) {
             case 'View':
                 return $node->canView($member);
             case 'Write':
                 return $node->canEdit($member);
             default:
                 return $node->can($perm, $member);
         }
     }
     if (!$node) {
         return false;
     }
     if (!$member) {
         $member = singleton('SecurityContext')->getMember();
     }
     if (is_int($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     if (Permission::check('ADMIN', 'any', $member)) {
         return true;
     }
     $permCache = $this->getCache();
     /* @var $permCache Zend_Cache_Core */
     $key = $this->permCacheKey($node, $perm);
     $userGrants = null;
     if ($key) {
         $userGrants = $permCache->load($key);
         if (count($userGrants)) {
             $userGrants = $this->sanitiseCacheData($userGrants);
         }
     }
     if ($member && $userGrants && isset($userGrants[$perm][$member->ID])) {
         return $userGrants[$perm][$member->ID];
     }
     // okay, we need to build up all the info we have about the node for permissions
     $s = $this->realiseAllSources($node);
     if (!$userGrants) {
         $userGrants = array();
     }
     if (!isset($userGrants[$perm])) {
         $userGrants[$perm] = array();
     }
     $result = null;
     // if no member, just check public view
     $public = $this->checkPublicPerms($node, $perm);
     if ($public) {
         $result = true;
     }
     // can return immediately
     if (!$member) {
         return $result;
     }
     if (is_null($result)) {
         // see whether we're the owner, and if the perm we're checking is in that list
         if ($this->checkOwnerPerms($node, $perm, $member)) {
             $result = true;
         }
     }
     $accessAuthority = '';
     $directGrant = null;
     $can = false;
     if (is_null($result)) {
         $filter = array('ItemID' => $node->ID, 'ItemType' => $node->class);
         $existing = DataList::create('AccessAuthority')->filter($filter);
         // get all access authorities for this object
         $gids = isset($this->groups[$member->ID]) ? $this->groups[$member->ID] : null;
         if (!$gids) {
             $groups = $member ? $member->Groups() : array();
             $gids = array();
             if ($groups && $groups->Count()) {
                 $gids = $groups->map('ID', 'ID')->toArray();
             }
             $this->groups[$member->ID] = $gids;
         }
         $can = false;
         $directGrant = 'NONE';
         if ($existing && $existing->count()) {
             foreach ($existing as $access) {
                 // check if this mentions the perm in question
                 $perms = $access->Perms->getValues();
                 if ($perms) {
                     if (!in_array($perm, $perms)) {
                         continue;
                     }
//.........這裏部分代碼省略.........
開發者ID:nyeholt,項目名稱:silverstripe-restrictedobjects,代碼行數:101,代碼來源:PermissionService.php

示例9: canEdit

 /**
  * Shop Admins can edit
  * @return Boolean
  */
 function canEdit($member = null)
 {
     return true;
     if (!$member) {
         $member = Member::currentUser();
     }
     if ($member && $member->IsShopAdmin()) {
         return true;
     }
     return parent::canEdit($member);
 }
開發者ID:TouchtechLtd,項目名稱:silverstripe-ecommerce_product_variation,代碼行數:15,代碼來源:ProductVariation.php

示例10: canDelete

 /**
  * Standard SS method
  * @param Member $member
  * @return Boolean
  */
 public function canDelete($member = null)
 {
     //cant delete last status if there are orders with this status
     $nextOrderStepObject = $this->NextOrderStep();
     if ($nextOrderStepObject) {
         //do nothing
     } else {
         $orderCount = Order::get()->filter(array("StatusID" => intval($this->ID) - 0))->count();
         if ($orderCount) {
             return false;
         }
     }
     if ($this->isDefaultStatusOption()) {
         return false;
     }
     if (in_array($this->Code, self::get_codes_for_order_steps_to_include())) {
         return false;
     }
     if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
         return true;
     }
     return parent::canEdit($member);
 }
開發者ID:TouchtechLtd,項目名稱:silverstripe-ecommerce,代碼行數:28,代碼來源:OrderStep.php

示例11: canDelete

 /**
  * Standard SS method
  * @param Member $member
  * @return Boolean
  */
 function canDelete($member = null)
 {
     if (ShippingAddress::get()->filter(array("ShippingCountry" => $this->Code))->count()) {
         return false;
     }
     if (BillingAddress::get()->filter(array("Country" => $this->Code))->count()) {
         return false;
     }
     if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
         return true;
     }
     return parent::canEdit($member);
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce,代碼行數:18,代碼來源:EcommerceCountry.php

示例12: canEdit

 public function canEdit($member = null)
 {
     $this->beforeExtending(__METHOD__, function ($member) {
         if (!$this->checkIfHasGlobalMenuPermission($member)) {
             return false;
         }
     });
     return parent::canEdit($member);
 }
開發者ID:helpfulrobot,項目名稱:milkyway-multimedia-ss-linkable-menus,代碼行數:9,代碼來源:LinkableMenu.php

示例13: canEdit

 public function canEdit($member = null)
 {
     $first = $this->Pages()->first();
     return $first ? $first->canEdit() : parent::canEdit($member);
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-australia-silverstripe-question-answer,代碼行數:5,代碼來源:QuestionAnswerObject.php

示例14: canDelete

 /**
  * Standard SS method
  * @param Member $member
  * @return Boolean
  */
 function canDelete($member = null)
 {
     if (!$this->InUse && EcommerceCurrency::get()->Count() > 1) {
         if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
             return true;
         }
         return parent::canEdit($member);
     }
     return false;
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce,代碼行數:15,代碼來源:EcommerceCurrency.php

示例15: getColumnContent

 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if ($this->removeRelation) {
         if (!$record->canEdit()) {
             return;
         }
         $field = GridField_FormAction::create($gridField, 'UnlinkRelation' . $record->ID, _t('GridAction.UnlinkRelation', "Unlink"), "unlinkrelation", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-unlink')->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink"))->setAttribute('data-icon', 'chain--minus');
     } else {
         if (!$record->canDelete()) {
             return;
         }
         $field = GridField_FormAction::create($gridField, 'DeleteRecord' . $record->ID, _t('GridAction.Delete', "Delete"), "deleterecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-delete')->setAttribute('title', _t('GridAction.Delete', "Delete"))->setAttribute('data-icon', 'cross-circle')->setDescription(_t('GridAction.DELETE_DESCRIPTION', 'Delete'));
     }
     return $field->Field();
 }
開發者ID:congaaids,項目名稱:silverstripe-framework,代碼行數:22,代碼來源:GridFieldDeleteAction.php


注:本文中的DataObject::canEdit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。