/** * Verify email address * @param string $code * @return boolean */ public function verifyEmailAddress($code) { try { $verificationCode = $this->getDataOption('email_verification_code', null); if (!is_null($code) && $code == $verificationCode) { $oldEmails = $this->getDataOption('email_old'); if (is_array($oldEmails)) { $i = 0; foreach ($oldEmails as $e) { if ($e['new'] == $this->email()) { $e['verify'] = zbase_date_now(); $e['verify_ip'] = zbase_ip(); $oldEmails[$i] = $e; } $i++; } } if (!empty($oldEmails)) { $this->setDataOption('email_old', $oldEmails); } $this->unsetDataOption('email_verification_code'); $this->email_verified = 1; $this->email_verified_at = zbase_date_now(); $this->log('user::verifyEmailAddress'); $this->save(); zbase_alert('info', _zt('Your email address <strong>%email%<strong> is now verified.', ['%email%' => $this->email()])); zbase_session_flash('user_verifyEmailAddress', true); return true; } } catch (\Zbase\Exceptions\RuntimeException $e) { zbase_exception_throw($e); } return false; }
/** * Validate widget */ public function validateWidget($action) { if ($this->_urlHasRequest) { if (empty($this->_entity)) { return zbase_abort(404); } if ($this->isAdmin() && $this->_entity instanceof \Zbase\Entity\Laravel\Node\Nested) { $children = $this->_entity->getImmediateDescendants(); if ($children->count()) { return zbase_abort(404); } } } $this->setAction($action); $this->prepare(); if (zbase_request_method() == 'post') { $currentTab = zbase_request_input('tab', false); if (!empty($currentTab)) { zbase_session_flash('sessiontab', $currentTab); } if ($this->isDeleting()) { return; } $validationRules = $this->getValidationRules(); if (!empty($validationRules)) { $v = \Validator::make(zbase_request_inputs(), $validationRules, $this->getValidationMessages()); if ($v->fails()) { zbase_session_flash('posted', true); $this->setHasError($v->errors()->getMessages()); $messageBag = $v->getMessageBag(); zbase_alert(\Zbase\Zbase::ALERT_ERROR, $messageBag, ['formvalidation' => true]); return $v; } $inputs = zbase_request_inputs(); foreach ($inputs as $k => $v) { $e = $this->element($k); if ($e instanceof \Zbase\Ui\Form\ElementInterface) { $e->setValue($v); } } } } }
/** * Flash a message for the form input. * Usable if you want to check if there are error on an input * * @param string $key * @param string $msg * @param string $type error|succes|danger|info */ function zbase_form_message_flash($key, $msg, $type = 'error') { zbase_session_flash('_form_' . $type . '_' . $key, $msg); }