deleteSetting() public static method

Delete a setting.
public static deleteSetting ( integer $id, string $name ) : integer
$id integer Profile id.
$name string Setting name.
return integer
Example #1
0
 /**
  * Execute the extra.
  */
 public function execute()
 {
     // get activation key
     $key = $this->URL->getParameter(0);
     // load template
     $this->loadTemplate();
     // do we have an activation key?
     if (isset($key)) {
         // get profile id
         $profileId = FrontendProfilesModel::getIdBySetting('activation_key', $key);
         // have id?
         if ($profileId != null) {
             // update status
             FrontendProfilesModel::update($profileId, array('status' => 'active'));
             // delete activation key
             FrontendProfilesModel::deleteSetting($profileId, 'activation_key');
             // login profile
             FrontendProfilesAuthentication::login($profileId);
             // trigger event
             FrontendModel::triggerEvent('Profiles', 'after_activate', array('id' => $profileId));
             // show success message
             $this->tpl->assign('activationSuccess', true);
         } else {
             // failure
             $this->redirect(FrontendNavigation::getURL(404));
         }
     } else {
         $this->redirect(FrontendNavigation::getURL(404));
     }
 }
Example #2
0
 /**
  * Validate the form.
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get fields
         $txtPassword = $this->frm->getField('password');
         // field is filled in?
         $txtPassword->isFilled(FL::getError('PasswordIsRequired'));
         // valid
         if ($this->frm->isCorrect()) {
             // get profile id
             $profileId = FrontendProfilesModel::getIdBySetting('forgot_password_key', $this->URL->getParameter(0));
             // remove key (we can only update the password once with this key)
             FrontendProfilesModel::deleteSetting($profileId, 'forgot_password_key');
             // update password
             FrontendProfilesAuthentication::updatePassword($profileId, $txtPassword->getValue());
             // login (check again because we might have logged in in the meanwhile)
             if (!FrontendProfilesAuthentication::isLoggedIn()) {
                 FrontendProfilesAuthentication::login($profileId);
             }
             // trigger event
             FrontendModel::triggerEvent('Profiles', 'after_reset_password', array('id' => $profileId));
             // redirect
             $this->redirect(FrontendNavigation::getURLForBlock('Profiles', 'ResetPassword') . '/' . $this->URL->getParameter(0) . '?sent=true');
         } else {
             $this->tpl->assign('forgotPasswordHasError', true);
         }
     }
 }