/**
  * Creates and returns a captcha object from a row
  * @param $row array
  * @return Captcha object
  */
 function &_returnCaptchaFromRow($row)
 {
     $captcha = new Captcha();
     $captcha->setId($row['captcha_id']);
     $captcha->setSessionId($row['session_id']);
     $captcha->setValue($row['value']);
     $captcha->setDateCreated($this->datetimeFromDB($row['date_created']));
     HookRegistry::call('CaptchaDAO::_returnCaptchaFromRow', array(&$captcha, &$row));
     return $captcha;
 }
 /**
  * Create a CAPTCHA object.
  * @param $length int The length, in characters, of the CAPTCHA test to create
  * @return object Captcha
  */
 function &createCaptcha($length = 6)
 {
     $captchaDao =& DAORegistry::getDAO('CaptchaDAO');
     $session =& Request::getSession();
     if ($session && $this->isEnabled()) {
         $captcha = new Captcha();
         $captcha->setSessionId($session->getId());
         $captcha->setValue(Validation::generatePassword($length));
         $captchaDao->insertCaptcha($captcha);
     } else {
         $captcha = null;
     }
     return $captcha;
 }