Example #1
0
 /**
  * Generate a new activation code
  *
  * @param array $userInfo
  * @return boolean|string
  */
 public function generateActivationCode(array $userInfo)
 {
     try {
         $this->adapter->getDriver()->getConnection()->beginTransaction();
         $activationCode = $this->generateRandString();
         $update = $this->update()->table('user_list')->set(['activation_code' => $activationCode, 'date_edited' => date('Y-m-d')])->where(['user_id' => $userInfo['user_id']]);
         $statement = $this->prepareStatementForSqlObject($update);
         $statement->execute();
         // clear a cache
         $this->removeUserCache($userInfo['user_id']);
         $this->adapter->getDriver()->getConnection()->commit();
     } catch (Exception $e) {
         $this->adapter->getDriver()->getConnection()->rollback();
         ApplicationErrorLogger::log($e);
         return $e->getMessage();
     }
     // fire the user password reset request event
     UserEvent::fireUserPasswordResetRequestEvent($userInfo['user_id'], $userInfo, $activationCode);
     return true;
 }