application/controllers/api/User.php
//delete relations (not user for now)
delete relations (not user for now)
delete relations ( not user for now )
function index_delete($user_id) {
        $user_id  = $this->uri->segment(3, NULL); 
        $resource = $this->uri->segment(4, NULL); /clubs or /friends
        $elem_id  = $this->uri->segment(5, NULL); /clubs or /friends /id 
        $command  = $this->uri->segment(6, NULL); /clubs or /friends /delete (just to confirm)
        if ($user_id == NULL || !is_numeric($user_id)) {
            $this->response(NULL, REST_Controller::HTTP_BAD_REQUEST);
        } else {
            if ($resource == 'clubs' && $command = 'delete') {
                $club_id = $elem_id;
                $result = $this->user_model->removeClub($user_id,$club_id); 
            } elseif ($resource == 'friends' && $command = 'delete') {
                $friend_user_id = $elem_id;
                $result = $this->user_model->removeFriend($user_id,$friend_user_id); 
            } else {
                $this->response(NULL, REST_Controller::HTTP_BAD_REQUEST);
            }
        }
        if($result === FALSE)        {
            $this->response(array('status' => 'failed'), REST_Controller::HTTP_OK);
        } else {
            $this->response(array('status' => 'success'), REST_Controller::HTTP_OK);
        }
    }
function index_delete ( $ user_id ) { $ user_id = $ this -> uri -> segment ( 3 , NULL ) ; $ resource = $ this -> uri -> segment ( 4 , NULL ) ; $ elem_id = $ this -> uri -> segment ( 5 , NULL ) ; $ command = $ this -> uri -> segment ( 6 , NULL ) ; if ( $ user_id == NULL || ! is_numeric ( $ user_id ) ) { $ this -> response ( NULL , REST_Controller :: HTTP_BAD_REQUEST ) ; } else { if ( $ resource == 'clubs' && $ command = 'delete' ) { $ club_id = $ elem_id ; $ result = $ this -> user_model -> removeClub ( $ user_id , $ club_id ) ; } elseif ( $ resource == 'friends' && $ command = 'delete' ) { $ friend_user_id = $ elem_id ; $ result = $ this -> user_model -> removeFriend ( $ user_id , $ friend_user_id ) ; } else { $ this -> response ( NULL , REST_Controller :: HTTP_BAD_REQUEST ) ; } } if ( $ result === FALSE ) { $ this -> response ( array ( 'status' => 'failed' ) , REST_Controller :: HTTP_OK ) ; } else { $ this -> response ( array ( 'status' => 'success' ) , REST_Controller :: HTTP_OK ) ; } }
delete relations (not user for now)
delete relations ( not user for now )
// BASE_URL/api/user/id // BASE_URL/api/user/id/clubs or /friends // BASE_URL/api/user/id/clubs or /friends /id  // BASE_URL/api/user/id/clubs or /friends /delete (just to confirm) //if id is null, its a new user //otherwise include resource accordingly //$this->response($result, REST_Controller::HTTP_OK);