コード例 #1
0
ファイル: Registration.php プロジェクト: ktrzos/plethora
 /**
  * Activate user account.
  *
  * @access     public
  * @return     View
  * @since      1.0.0
  * @version    1.1.0, 2015-02-12
  */
 public function actionActivation()
 {
     // if user is logged, redirect to main page
     if (UserModel::isLogged()) {
         Route::factory('home')->redirectTo();
     }
     // set page title
     $this->setTitle(__('Activate your new account'));
     // get code from URL
     $sCode = Router::getParam('code');
     $bActivated = FALSE;
     // get activation code from DB
     $oResult = DB::query("SELECT c FROM \\Model\\User\\ActivationCode c WHERE c.code = :code")->param('code', $sCode)->single();
     /* @var $oResult ActivationCodeModel */
     // activate user
     if ($oResult instanceof ActivationCodeModel) {
         // Set user as activated
         $bActivated = TRUE;
         $oUser = $oResult->getUser();
         $oUser->setActivation(TRUE);
         DB::flush();
         // Remove activation code from DB
         DB::remove($oResult);
         DB::flush();
     }
     // view
     return View::factory("user/frontend/register/activation")->bind('bActivated', $bActivated);
 }
コード例 #2
0
ファイル: ModelCore.php プロジェクト: ktrzos/plethora
 /**
  * Remove all data of this Model from database.
  *
  * @access   public
  * @return   boolean
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function remove()
 {
     if (static::hasLocales()) {
         foreach ($this->getLocales('all') as $oLocale) {
             /* @var $oLocale ModelCore\Locales */
             foreach ($oLocale->getConfig()->getFields() as $sFieldName => $oField) {
                 /* @var $oField Form\Field */
                 $oField->whenRemovingEntity($this, $oLocale->{$sFieldName});
             }
             DB::remove($oLocale);
         }
     }
     foreach ($this->getConfig()->getFields() as $sFieldName => $oField) {
         /* @var $oField Form\Field */
         $oField->whenRemovingEntity($this, $this->{$sFieldName});
     }
     DB::remove($this);
     return TRUE;
 }