Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • AuthSiteConfig
  • DeleteUnconfirmTask
  • ExtendPageMember
  • MemberActivation
  • ProfilePage
  • RegistrationPage
 1 <?php
 2 /**
 3  * Проверка входа для неактивированных пользователей
 4  *
 5  * @package auth
 6  * @author inxo, dvp
 7  */
 8 class MemberActivation extends DataObjectDecorator {
 9     
10     static $key_length = 20;
11     static $key_sub = 5;
12     static $key_pool = '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
13     
14     function extraStatics() {
15         return array(
16             'db' => array(
17                 'ActivationKey' => 'Varchar',
18             ),
19         );
20     }
21 
22     static function get_by_activation_key($key) {
23         $key = Convert::raw2sql($key);
24         return DataObject::get_one('Member', "\"Member\".\"ActivationKey\" = '{$key}'");
25     }
26 
27     static function ClearUnconfirmed() {
28         // Берем из конфига кол-во дней
29         $sc = SiteConfig::current_site_config();
30         $every = intval($sc->AuthActivationTTL);
31         if ($every > 0 && $unconfirmed = DataObject::get('Member', "Created < NOW() - INTERVAL $every DAY")) {
32             foreach ($unconfirmed as $item){
33                 if ($item->inGroup('unconfirm-site-members')) {
34                     $item->delete();
35                 }
36             }
37         }
38     }
39 
40     static function generate_key() {
41         $key = '';
42         for ($i = 0; $i < self::$key_length; $i++) {
43             $key .= substr(self::$key_pool, mt_rand(0, strlen(self::$key_pool) - 1), 1);
44             if (($i + 1) % self::$key_sub == 0 && ($i + 1) != self::$key_length)
45                 $key .= '-';
46         }
47         return $key;
48     }
49 
50     /*
51      * Проверка активации пользователя
52      */
53     function canLogIn(&$result){
54         foreach ($this->owner->Groups() as $group) {
55             if($group->Code == 'unconfirm-site-members'){
56                 $result->error(_t(
57                     'Member.NOTACTIVE',
58                     'Ваша учетная запись не активирована'
59                 ));
60             }
61         }
62         return $result;
63     }
64     
65     function updateCMSFields(&$fields) {
66         $fields->removeByName('ActivationKey');
67     }
68     
69     function updateMemberFormFields(&$fields) {
70         $fields->removeByName('ActivationKey');
71         $fields->removeByName('Locale');
72     }
73     
74     function onBeforeWrite() {
75         if (!$this->owner->IsInDB() && !$this->owner->ActivationKey)
76             $this->owner->ActivationKey = self::generate_key();
77     }
78     
79     function ProfileLink() {
80         return Director::absoluteURL(ProfilePage::find_link());
81     }
82     
83 }
84 
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0