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


PHP DataExtension类代码示例

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


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

示例1: requireDefaultRecords

 /**
  * @throws ValidationException
  * @throws null
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     /**
      * Add default site admin group if none with
      * permission code SITE_ADMIN exists
      *
      * @var Group $siteAdminGroup
      */
     $siteAdminGroups = DataObject::get('Group')->filter(array('Code' => 'site-administrators'));
     if (!$siteAdminGroups->count()) {
         $siteAdminGroup = Group::create();
         $siteAdminGroup->Code = 'site-administrators';
         $siteAdminGroup->Title = _t('BoilerplateGroupExtension.SiteAdminGroupTitle', 'Site Administrators');
         $siteAdminGroup->Sort = 0;
         $siteAdminGroup->write();
         /** Default CMS permissions */
         Permission::grant($siteAdminGroup->ID, 'CMS_ACCESS_LeftAndMain');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_VIEW_ALL');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_EDIT_ALL');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_REORGANISE');
         Permission::grant($siteAdminGroup->ID, 'VIEW_DRAFT_CONTENT');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_GRANT_ACCESS');
         Permission::grant($siteAdminGroup->ID, 'EDIT_SITECONFIG');
     }
 }
开发者ID:helpfulrobot,项目名称:ryanpotter-silverstripe-boilerplate,代码行数:30,代码来源:BoilerplateGroupExtension.php

示例2: onBeforeWrite

 function onBeforeWrite()
 {
     if (!$this->owner->ID && !$this->owner->SubsiteID && Subsite::currentSubsiteID()) {
         $this->owner->SubsiteID = Subsite::currentSubsiteID();
     }
     parent::onBeforeWrite();
 }
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:7,代码来源:SiteTreeSubsites.php

示例3: updateCMSFields

 public function updateCMSFields(\FieldList $fields)
 {
     if (!Permission::check('ADMIN')) {
         Requirements::css(HIDE_HISTORY_BASE . '/css/hide-history.css');
     }
     parent::updateCMSFields($fields);
 }
开发者ID:helpfulrobot,项目名称:zirak-hide-history,代码行数:7,代码来源:HideHistory.php

示例4: onBeforeWrite

 /**
  * Set VerificationString if not set
  * If not verified log out user and display message.
  */
 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->owner->VerificationString) {
         $this->owner->VerificationString = MD5(rand());
     }
     if (!$this->owner->Verified) {
         if (!$this->owner->VerificationEmailSent) {
             if (!self::$hasOnBeforeWrite) {
                 self::$hasOnBeforeWrite = true;
                 $this->owner->sendemail($this->owner, false);
             }
         }
         if (Member::currentUserID() && $this->owner->Email == Member::currentUser()->Email) {
             Security::logout(false);
             if (!is_null(Controller::redirectedTo())) {
                 $messageSet = array('default' => _t('EmailVerifiedMember.EMAILVERIFY', 'Please verify your email address by clicking on the link in the email before logging in.'));
             }
             Session::set("Security.Message.type", 'bad');
             Security::permissionFailure(Controller::curr(), $messageSet);
         } else {
             return;
         }
     } else {
         return;
     }
 }
开发者ID:helpfulrobot,项目名称:exadium-emailverifiedmember,代码行数:31,代码来源:EmailVerifiedMember.php

示例5: onAfterWrite

 public function onAfterWrite()
 {
     parent::onAfterWrite();
     $AvailableTypes = $this->AvailableSectionTypes();
     foreach ($AvailableTypes as $key => $value) {
         $ClassName = $AvailableTypes[$key]['classname'];
         if ($AvailableTypes[$key]['presets'] !== null) {
             foreach ($AvailableTypes[$key]['presets'] as $AdminTitle => $ShareStatus) {
                 $Section = $this->owner->Sections()->filter(array('ClassName' => $ClassName, 'UniqueConfigTitle' => $AdminTitle));
                 if ($Section->Count()) {
                     continue;
                 }
                 $ExistingSection = $ClassName::get()->filter(array('ClassName' => $ClassName, 'UniqueConfigTitle' => $AdminTitle))->first();
                 if ($ExistingSection && $ShareStatus == 'shared') {
                     $this->owner->Sections()->add($ExistingSection);
                 } else {
                     $newSection = $ClassName::create();
                     $newSection->UniqueConfigTitle = $AdminTitle;
                     $newSection->AdminTitle = $AdminTitle;
                     $newSection->Public = true;
                     $newSection->Write();
                     $this->owner->Sections()->add($newSection);
                 }
             }
         }
     }
 }
开发者ID:coreiho,项目名称:silverstripe-sections,代码行数:27,代码来源:SectionPageExtension.php

示例6: onBeforeWrite

 function onBeforeWrite()
 {
     if ($this->owner->Status == 'Paid' && $this->owner->StockHasBeenCalculated == 0) {
         $this->owner->StockHasBeenCalculated = 1;
         if ($orderItems = $this->owner->Items()) {
             foreach ($orderItems as $orderItem) {
                 if ($buyable = $orderItem->Buyable()) {
                     if ($buyable->UnlimitedStock == 0) {
                         $oldNum = $buyable->Stock;
                         $newNum = $oldNum - $orderItem->Quantity;
                         $buyable->Stock = $newNum;
                         $buyable->write();
                     }
                 }
             }
         }
     }
     if ($this->owner->Status == 'AdminCancelled' && $this->owner->StockHasBeenCalculated == 1 || $this->owner->Status == 'MemberCancelled' && $this->owner->StockHasBeenCalculated == 1) {
         if ($orderItems = $this->owner->Items()) {
             foreach ($orderItems as $orderItem) {
                 if ($buyable = $orderItem->Buyable()) {
                     $oldNum = $buyable->Stock;
                     $newNum = $oldNum + $orderItem->Quantity;
                     $buyable->Stock = $newNum;
                     $buyable->write();
                 }
             }
         }
     }
     parent::onBeforeWrite();
 }
开发者ID:nimeso,项目名称:shop-stock-control,代码行数:31,代码来源:OrderStockDecoator.php

示例7: onAfterWrite

 /**
  * Override to avoid Dup groups titles and slugs
  */
 function onAfterWrite()
 {
     parent::onAfterWrite();
     $exits_group = false;
     $suffix = 1;
     //get original values
     $original_code = $this->owner->Code;
     $original_title = $this->owner->Title;
     //iterate until we get an unique slug and title
     while (!$exits_group) {
         $new_code = $this->owner->Code;
         $new_title = $this->owner->Title;
         $id = $this->owner->ID;
         //check if group already exists...
         $count = DB::query(" SELECT COUNT(*) FROM \"Group\" WHERE Code ='{$new_code}' AND ID <> {$id}")->value();
         if ($count) {
             //if exists , rename it
             $this->owner->Code = $original_code . '-' . $suffix;
             $this->owner->Title = $original_title . ' ' . $suffix;
         } else {
             DB::query("UPDATE \"Group\" SET Code= '{$new_code}', Title = '{$new_title}' WHERE ID = {$id} ");
             $exits_group = true;
         }
         ++$suffix;
     }
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:29,代码来源:GroupDecorator.php

示例8: onBeforeWrite

 /**
  * Write the Color field to get the dominant color if not set
  */
 public function onBeforeWrite()
 {
     if ($this->owner->getField('Color') === null) {
         $this->owner->Color = $this->dominantColor();
     }
     parent::onBeforeWrite();
 }
开发者ID:jacobbuck,项目名称:silverstripe-colorfulimage,代码行数:10,代码来源:ColorfulImageExtension.php

示例9: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Add default author group if no other group exists
     $frontend_group = Group::get()->filter("Code", "users-frontend");
     if (!$frontend_group->exists()) {
         $frontend_group = new Group();
         $frontend_group->Code = 'users-frontend';
         $frontend_group->Title = "Frontend Users";
         $frontend_group->Sort = 1;
         $frontend_group->write();
         Permission::grant($frontend_group->ID, 'USERS_MANAGE_ACCOUNT');
         DB::alteration_message('Front end users group created', 'created');
     }
     // Add a verified users group (only used if we turn on
     // verification)
     $verify_group = Group::get()->filter("Code", "users-verified");
     if (!$verify_group->exists()) {
         $verify_group = new Group();
         $verify_group->Code = 'users-verified';
         $verify_group->Title = "Verified Users";
         $verify_group->Sort = 1;
         $verify_group->write();
         Permission::grant($verify_group->ID, 'USERS_VERIFIED');
         DB::alteration_message('Verified users group created', 'created');
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-users,代码行数:27,代码来源:Ext_Users_Group.php

示例10: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->owner->Locale) {
         $this->owner->Locale = Translatable::get_current_locale();
     }
 }
开发者ID:webtorque7,项目名称:inpage-modules,代码行数:7,代码来源:ContentModuleLanguageExtension.php

示例11: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->owner->ScheduledTitle) {
         $this->owner->ScheduledTitle = $this->owner->Title;
     }
     if ($this->owner->FirstGeneration) {
         $changed = $this->owner->getChangedFields();
         $changed = false || isset($changed['FirstGeneration']) || isset($changed['RegenerateEvery']) || isset($changed['RegenerateFree']);
         if ($changed && $this->owner->ScheduledJobID) {
             if ($this->owner->ScheduledJob()->ID) {
                 $this->owner->ScheduledJob()->delete();
             }
             $this->owner->ScheduledJobID = 0;
         }
         if (!$this->owner->ScheduledJobID) {
             $job = new ScheduledReportJob($this->owner);
             $time = date('Y-m-d H:i:s');
             if ($this->owner->FirstGeneration) {
                 $time = date('Y-m-d H:i:s', strtotime($this->owner->FirstGeneration));
             }
             $this->owner->ScheduledJobID = singleton('QueuedJobService')->queueJob($job, $time);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:maldicore-advancedreports,代码行数:25,代码来源:ScheduledReportExtension.php

示例12: onBeforeWrite

 /**
  * Set URLSegment to be unique on write
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $defaults = $this->owner->config()->defaults;
     $URLSegment = $this->owner->URLSegment;
     // If there is no URLSegment set, generate one from Title
     if ((!$URLSegment || $URLSegment == $defaults['URLSegment']) && $this->owner->Title != $defaults['Title']) {
         $URLSegment = $this->generateURLSegment($this->owner->Title);
     } else {
         if ($this->owner->isChanged('URLSegment')) {
             // Make sure the URLSegment is valid for use in a URL
             $segment = preg_replace('/[^A-Za-z0-9]+/', '-', $this->owner->URLSegment);
             $segment = preg_replace('/-+/', '-', $segment);
             // If after sanitising there is no URLSegment, give it a reasonable default
             if (!$segment) {
                 $segment = $this->fallbackUrl();
             }
             $URLSegment = $segment;
         }
     }
     // Ensure that this object has a non-conflicting URLSegment value.
     $count = 2;
     $ID = $this->owner->ID;
     while ($this->lookForExistingURLSegment($URLSegment, $ID)) {
         $URLSegment = preg_replace('/-[0-9]+$/', null, $URLSegment) . '-' . $count;
         $count++;
     }
     $this->owner->URLSegment = $URLSegment;
 }
开发者ID:helpfulrobot,项目名称:ntb-silverstripe-rest-api,代码行数:32,代码来源:SlugableExtension.php

示例13: updateCMSFields

 /**
  * Remove the administrators group from the possible parent group
  * 
  * @todo this check should be done in core code, since the dropdown can be simply 
  *				crafted for injecting administrators group ID
  * @param \FieldList $fields
  */
 public function updateCMSFields(\FieldList $fields)
 {
     parent::updateCMSFields($fields);
     /* @var $parentID DropdownField */
     $parentID = $fields->fieldByName('Root.Members.ParentID');
     $parentID->setDisabledItems(array(DataObject::get_one('Group', "Code='administrators'")->ID));
 }
开发者ID:helpfulrobot,项目名称:zirak-member-user-management,代码行数:14,代码来源:ZkMemberGroup.php

示例14: setOwner

 public function setOwner($owner, $ownerBaseClass = null)
 {
     if (!$this->hasSetRelationForHidingFromFieldLists) {
         static::$connected_relations[] = get_class($owner);
     }
     return parent::setOwner($owner, $ownerBaseClass);
 }
开发者ID:spekulatius,项目名称:ss-social-feed,代码行数:7,代码来源:HasProfiles.php

示例15: onBeforeWrite

 /**
  *	Update the tagging to reflect the change, allowing searchable content.
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     // Determine whether consolidated tags are found in the existing relationships.
     $types = array();
     foreach (singleton('FusionService')->getFusionTagTypes() as $type => $field) {
         $types[$type] = $type;
     }
     $types = array_intersect($this->owner->many_many(), $types);
     if (empty($types)) {
         // There are no consolidated tags found, therefore update the tagging based on the fusion tags.
         $tagging = array();
         foreach ($this->owner->FusionTags() as $tag) {
             $tagging[] = $tag->Title;
         }
     } else {
         // Empty the fusion tags to begin.
         $this->owner->FusionTags()->removeAll();
         // There are consolidated tags found, therefore update the tagging based on these.
         $tagging = array();
         foreach ($types as $relationship => $type) {
             foreach ($this->owner->{$relationship}() as $tag) {
                 // Update both the fusion tags and tagging.
                 $fusion = $tag->FusionTag();
                 $this->owner->FusionTags()->add($fusion);
                 $tagging[] = $fusion->Title;
             }
         }
     }
     $this->owner->Tagging = implode(' ', $tagging);
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-fusion,代码行数:34,代码来源:TaggingExtension.php


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