public function cleanoldrecoverAction()
 {
     $maxAge = 48 * 60 * 60;
     $recover = Ml_Model_Recover::getInstance();
     $deleted = $recover->gc($maxAge);
     echo "Number of rows with age > " . $maxAge . " (seconds) deleted in recover: " . $deleted . "\n";
 }
 public function passwordAction()
 {
     $request = $this->getRequest();
     $auth = Zend_Auth::getInstance();
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $people = Ml_Model_People::getInstance();
     $credential = Ml_Model_Credential::getInstance();
     $recover = Ml_Model_Recover::getInstance();
     $params = $request->getParams();
     $this->view->request = $request;
     if ($auth->hasIdentity()) {
         if (isset($params['confirm_uid'])) {
             $this->_redirect($router->assemble(array(), "logout") . "?please", array("exit"));
         }
         $form = $credential->newPasswordForm();
         $uid = $auth->getIdentity();
         $registry->set("changeUserProperPassword", true);
         $signedUserInfo = $registry->get("signedUserInfo");
     } else {
         if (isset($params['confirm_uid']) && isset($params['security_code'])) {
             $recoverInfo = $recover->getAuthorization($params["confirm_uid"], $params["security_code"]);
             if (!$recoverInfo) {
                 return $this->_forward("unavailable");
             }
             $form = $credential->newPasswordForm($params["confirm_uid"], $params["security_code"]);
             $uid = $recoverInfo['uid'];
         } else {
             return $this->_forward("redirect", "login");
         }
     }
     if ($auth->hasIdentity()) {
         $this->view->userInfoDataForPasswordChange = $signedUserInfo;
     } else {
         $userInfo = $people->getById($request->getParam("confirm_uid"));
         $this->view->userInfoDataForPasswordChange = $userInfo;
     }
     if ($request->isPost()) {
         $credentialInfo = $credential->getByUid($uid);
         if (!$credentialInfo) {
             $this->_redirect($router->assemble(array(), "index"), array("exit"));
         }
         $registry->set('credentialInfoDataForPasswordChange', $credentialInfo);
         if ($form->isValid($request->getPost())) {
             $password = $form->getValue("password");
             if (isset($recoverInfo)) {
                 $recover->closeCase($uid);
             }
             $credential->setCredential($uid, $password);
             $this->view->passwordReset = true;
         }
     }
     if (!isset($this->view->passwordReset)) {
         $this->view->passwordForm = $form;
     }
 }