public function createUser($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        try {
            if(Member::get()->filter('Email', Convert::raw2sql($data->username))->count()>0) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.EMAIL_EXISTS', '_An account with that email already exists');
                
                return $response;
            }
            
            
            //Create and write member
            $member=new Member();
            $member->FirstName=(!empty($data->firstname) ? $data->firstname:$data->username);
            $member->Surname=(!empty($data->surname) ? $data->surname:null);
            $member->Email=$data->username;
            $member->Password=$data->Password;
            $member->UseHeartbeat=0;
            
            if(!$member->validate()) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.PASSWORD_NOT_VALID', '_Password is not valid');
                
                return $response;
            }
            
            $member->write();
            
            
            $response['status']='HELO';
            $response['message']="User added successfully";
        }catch (Exception $e) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
        }
        
        return $response;
    }
public function createUser($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        try {
            if(Member::get()->filter('Email', Convert::raw2sql($data->username))->count()>0) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.EMAIL_EXISTS', '_An account with that email already exists');
                
                return $response;
            }
            
            
            //Create and write member
            $member=new Member();
            $member->FirstName=(!empty($data->firstname) ? $data->firstname:$data->username);
            $member->Surname=(!empty($data->surname) ? $data->surname:null);
            $member->Email=$data->username;
            $member->Password=$data->Password;
            $member->UseHeartbeat=0;
            
            if(!$member->validate()) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.PASSWORD_NOT_VALID', '_Password is not valid');
                
                return $response;
            }
            
            $member->write();
            
            
            $response['status']='HELO';
            $response['message']="User added successfully";
        }catch (Exception $e) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
        }
        
        return $response;
    }
public function createUser ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; try { if ( Member :: get ( ) -> filter ( 'Email' , Convert :: raw2sql ( $ data -> username ) ) -> count ( ) > 0 ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.EMAIL_EXISTS' , '_An account with that email already exists' ) ; return $ response ; } //Create and write member $ member = new Member ( ) ; $ member -> FirstName = ( ! empty ( $ data -> firstname ) ? $ data -> firstname : $ data -> username ) ; $ member -> Surname = ( ! empty ( $ data -> surname ) ? $ data -> surname : null ) ; $ member -> Email = $ data -> username ; $ member -> Password = $ data -> Password ; $ member -> UseHeartbeat = 0 ; if ( ! $ member -> validate ( ) ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.PASSWORD_NOT_VALID' , '_Password is not valid' ) ; return $ response ; } $ member -> write ( ) ; $ response [ 'status' ] = 'HELO' ; $ response [ 'message' ] = "User added successfully" ; } catch ( Exception $ e ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.SERVER_ERROR' , '_Server error has occured, please try again later' ) ; } return $ response ; }
Creates a user in the database
@param {stdClass} $data Data passed from ActionScript
@return {array} Returns a standard response array
Creates a user in the database