示例#1
0
 /**
  * Activate User by id.
  *
  * @access public
  * @param string $userId [User's hash id]
  * @return bool
  */
 public function activate($userId)
 {
     $bind = array();
     $where = '';
     $status = false;
     try {
         if (!is_null($userId)) {
             $where = 'WHERE `hash_id` = ?';
             $bind[] = $userId;
         } else {
             //Log warning message
             Noobh_Log::warning(__CLASS__ . '::' . __FUNCTION__ . ' Missing Argument userid');
         }
         if (isset($where) && isset($bind)) {
             if (empty($this->_dbAdapter)) {
                 $this->_dbAdapter = new Noobh_DB_Adapter();
             }
             $sql = 'UPDATE us_user SET is_active = 1 ' . $where;
             $statement = $this->_dbAdapter->query($sql, $bind);
             //Log debug message
             Noobh_Log::debug(__CLASS__ . '::' . __FUNCTION__ . ' Completed executing Sql Query - ' . $sql);
             $status = true;
             //Log info
             Noobh_Log::info(__CLASS__ . '::' . __FUNCTION__ . ' Activated user with id : ' . $userId);
         }
     } catch (Exception $ex) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 920, $this->_errorList[920]);
         //Log fatal error
         Noobh_Log::fatal(__CLASS__ . '::' . __FUNCTION__ . '  User activate failed for id: ' . $userId . ' , Error code ' . $ex->getCode() . ' , Error Message ' . $ex->getMessage());
         throw new $ex();
     }
     return $status;
 }