/**
  * Process the activation key from the activation email
  * 
  * @param $actkey The activation key 
  * 
  * @return bool TRUE if the signup process completes successfully, false if activation key is invalid or save fails
  */
 function activateAccount($actkey, $checkkey = true)
 {
     # validate the activation key
     if ($this->getActivationKey() != $actkey && $checkkey) {
         // debugMessage('failed');
         # Log to audit trail when an invalid activation key is used to activate account
         $audit_values = array("executedby" => $this->getID(), "transactiontype" => USER_SIGNUP, "success" => "N");
         $audit_values["transactiondetails"] = "Invalid Activation Code specified for User(" . $this->getID() . ") (" . $this->getEmail() . "). ";
         // $this->notify(new sfEvent($this, USER_SIGNUP, $audit_values));
         $this->getErrorStack()->add("user.activationkey", $this->translate->_("profile_invalid_actkey_error"));
         return false;
     }
     # set active to true and blank out activation key
     $this->setStatus(1);
     $this->setActivationKey("");
     $startdate = DEFAULT_DATETIME;
     $this->setActivationDate($startdate);
     if ($this->isCompanyAdmin()) {
         $expirydate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($startdate)) . " +" . getTrialDays() . " days "));
         $this->getCompany()->setStartDate($startdate);
         $this->getCompany()->setEndDate($expirydate);
         $this->getCompany()->setStatus(1);
     }
     # save
     try {
         $this->save();
         # Add to audittrail that a new user has been activated.
         $audit_values = array("executedby" => $this->getID(), "transactiontype" => USER_SIGNUP, "success" => "Y");
         $audit_values["transactiondetails"] = $this->getID() . " (" . $this->getEmail() . ") has completed the sign up process";
         // $this->notify(new sfEvent($this, USER_SIGNUP, $audit_values));
         return true;
     } catch (Exception $e) {
         $this->getErrorStack()->add("user.activation", $this->translate->_("profile_activation_error"));
         $this->logger->err("Error activating User " . $this->getEmail() . " " . $e->getMessage());
         // debugMessage($e->getMessage());
         # log to audit trail when an error occurs in updating payee details on user account
         $audit_values = array("executedby" => $this->getID(), "transactiontype" => USER_SIGNUP, "success" => "N");
         $audit_values["transactiondetails"] = "An error occured in activating account for User(" . $this->getID() . ") (" . $this->getEmail() . "): " . $e->getMessage();
         // $this->notify(new sfEvent($this, USER_SIGNUP, $audit_values));
         return false;
     }
 }
Beispiel #2
0
 function afterUpdate()
 {
     $session = SessionWrapper::getInstance();
     # check if user is being invited during update
     if (!isEmptyString($this->getDefaultUserID()) && isEmptyString($this->getDefaultUser()->getCompanyID())) {
         $this->getDefaultUser()->setCompanyID($this->getID());
         $startdate = DEFAULT_DATETIME;
         $expirydate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($startdate)) . " +" . getTrialDays() . " days "));
         if (isEmptyString($this->getStartDate()) && $this->getID() != DEFAULT_COMPANYID) {
             $this->setStartDate($startdate);
         }
         if (isEmptyString($this->getEndDate()) && $this->getID() != DEFAULT_COMPANYID) {
             $this->setEndDate($expirydate);
         }
         $this->save();
     }
     // invite via email
     if ($this->getIsBeinginvited() == 1) {
         $this->getDefaultUser()->inviteViaEmail();
     }
     if ($this->getID() == DEFAULT_ID) {
         $config_collection = new Doctrine_Collection(Doctrine_Core::getTable("AppConfig"));
         $appconfig = new AppConfig();
         $appconfig->populate(61);
         $appconfig->setOptionValue($this->getAppName());
         $config_collection->add($appconfig);
         $appconfig = new AppConfig();
         $appconfig->populate(62);
         $appconfig->setOptionValue($this->getName());
         $config_collection->add($appconfig);
         if ($config_collection->count() > 0) {
             $config_collection->save();
         }
     }
     return true;
 }