public function cleanoldemailchangeAction() { $maxAge = 48 * 60 * 60; $emailChange = Ml_Model_EmailChange::getInstance(); $deleted = $emailChange->gc($maxAge); echo "Number of rows with age > " . $maxAge . " (seconds) deleted in EmailChange: " . $deleted . "\n"; }
public function confirmAction() { $auth = Zend_Auth::getInstance(); $router = Zend_Controller_Front::getInstance()->getRouter(); $request = $this->getRequest(); $people = Ml_Model_People::getInstance(); $emailChange = Ml_Model_EmailChange::getInstance(); $confirmUid = $request->getParam("confirm_uid"); $securityCode = $request->getParam("security_code"); $changeInfo = $emailChange->get($confirmUid, $securityCode); if (!$changeInfo) { $this->_redirect("/email/unconfirmed", array("exit")); } if ($auth->hasIdentity() && $changeInfo['uid'] != $auth->getIdentity()) { $this->_redirect($router->assemble(array(), "logout") . "?please", array("exit")); } $confirm = $emailChange->setChange($confirmUid, $changeInfo['email']); if ($confirm) { $this->_redirect($this->view->StaticUrl("/email/confirmed"), array("exit")); } else { throw new Exception("Couldn't confirm new e-mail."); } }
public function indexAction() { $request = $this->getRequest(); $registry = Zend_Registry::getInstance(); $router = Zend_Controller_Front::getInstance()->getRouter(); $config = $registry->get("config"); $people = Ml_Model_People::getInstance(); $profile = Ml_Model_Profile::getInstance(); $form = Ml_Model_Account::settingsForm(); $signedUserInfo = $registry->get("signedUserInfo"); $profileInfo = $profile->getById($signedUserInfo['id']); //only data that can be changed can be here $listOfData = array("name" => $signedUserInfo['name'], "email" => $signedUserInfo['email'], "private_email" => $signedUserInfo['private_email'], "about" => $profileInfo['about'], "website" => $profileInfo['website'], "location" => $profileInfo['location']); $form->setDefaults($listOfData); if ($request->isPost()) { $form->isValid($request->getPost()); $errors = $form->getErrors(); $changeData = array(); $rec = $form->getValues(); //update foreach ($listOfData as $key => $value) { if (empty($errors[$key]) && $rec[$key] != $value) { $changeData[$key] = $rec[$key]; } } if (!empty($changeData)) { $changeDataLessEmail = $changeData; if (isset($changeData['email'])) { unset($changeDataLessEmail['email']); } if (!empty($changeDataLessEmail)) { //just a small state protection if (isset($changeDataLessEmail['private_email'])) { $changeDataLessEmail['private_email'] = 1; } $profileFields = array("website", "location", "about"); $changeProfileData = array(); foreach ($profileFields as $field) { if (isset($changeDataLessEmail[$field])) { $changeProfileData[$field] = $changeDataLessEmail[$field]; unset($changeDataLessEmail[$field]); } } if (!empty($changeDataLessEmail)) { $people->update($signedUserInfo['id'], $changeDataLessEmail); } if (!empty($changeProfileData)) { if (isset($changeProfileData['about'])) { $purifier = Ml_Model_HtmlPurifier::getInstance(); $changeProfileData['about_filtered'] = $purifier->purify($changeProfileData['about']); } $profile->update($signedUserInfo['id'], $changeProfileData); } $signedUserInfo = array_merge($signedUserInfo, $changeDataLessEmail); $registry->set("signedUserInfo", $signedUserInfo); } if (isset($changeData['about']) && sizeof($changeData) == 1) { $redirectToProfile = true; } } if (isset($changeData['email'])) { $emailChange = Ml_Model_EmailChange::getInstance(); $securitycode = $emailChange->newChange($signedUserInfo['id'], $changeData['email'], $signedUserInfo['name']); $mail = new Zend_Mail(); $this->view->securitycode = $securitycode; $mail->setBodyText($this->view->render("account/emailChange.phtml"))->setFrom($config['robotEmail']['addr'], $config['robotEmail']['name'])->addTo($changeData['email'], $signedUserInfo['name'])->setSubject('Changing your ' . $config['applicationname'] . ' email')->send(); $this->view->changeEmail = true; } else { if (isset($redirectToProfile)) { $this->_redirect($router->assemble(array("username" => $signedUserInfo['alias']), "profile") . "?about_check=true", array("exit")); } } } $this->view->accountForm = $form; }