src/snac/server/ServerExecutor.php
/**
     * Update the Controlled Vocabulary
     *
     * Calls saveUser to save the user information to the database.  Then returns the user object.
     *
     * @param string[]|null $input The input from the client
     * @return string[] The response to send to the client
     */
Update the Controlled Vocabulary
Calls saveUser to save the user information to the database.  Then returns the user object.

@param string[]|null $input The input from the client
@return string[] The response to send to the client
Update the Controlled Vocabulary Calls saveUser to save the user information to the database . Then returns the user object . @param string [] |null $input The input from the client @return string [] The response to send to the client
public function updateVocabulary(&$input) {
        $response = array();
        $success = false;
        $term = null;
        if (isset($input["type"]) && $input["type"] == "geo_term") {
            $term = new \snac\data\GeoTerm($input["term"]);
        } else {
            $term = new \snac\data\Term($input["term"]);
        }
        if ($term->getID() == null || $term->getID() == "") {
            $writtenTerm = null;
            if (isset($input["type"]) && $input["type"] == "geo_term") {
                $writtenTerm = $this->cStore->writeGeoTerm($term);
            } else {
                $writtenTerm = $this->cStore->writeVocabularyTerm($term);
            }
            if ($writtenTerm) {
                $success = true;
                $response["term"] = $writtenTerm->toArray();
            } else {
                $response["error"] = "Term could not be written";
            }
        } else {
            $current = null;
            if (isset($input["type"]) && $input["type"] == "geo_term") {
                $current = $this->cStore->buildGeoTerm($term->getID());
            } else {
                $current = $this->cStore->populateTerm($term->getID());
            }
            if ($current->getType() == $term->getType() && $term->getTerm() != null && $term->getTerm() != "") {
                throw new \snac\exceptions\SNACPermissionException("Currently the system is not allowing updating terms.", 403);
            }
            $response["error"] = "The term to update was not found in the database.";
        }
        if ($success === true) {
            $response["result"] = "success";
        } else {
            $response["result"] = "failure";
        }
        return $response;
    }
public function updateVocabulary ( & $ input ) { $ response = array ( ) ; $ success = false ; $ term = null ; if ( isset ( $ input [ " type " ] ) && $ input [ " type " ] == " geo_term " ) { $ term = new \ snac \ data \ GeoTerm ( $ input [ " term " ] ) ; } else { $ term = new \ snac \ data \ Term ( $ input [ " term " ] ) ; } if ( $ term -> getID ( ) == null || $ term -> getID ( ) == " " ) { $ writtenTerm = null ; if ( isset ( $ input [ " type " ] ) && $ input [ " type " ] == " geo_term " ) { $ writtenTerm = $ this -> cStore -> writeGeoTerm ( $ term ) ; } else { $ writtenTerm = $ this -> cStore -> writeVocabularyTerm ( $ term ) ; } if ( $ writtenTerm ) { $ success = true ; $ response [ " term " ] = $ writtenTerm -> toArray ( ) ; } else { $ response [ " error " ] = " Term could not be written " ; } } else { $ current = null ; if ( isset ( $ input [ " type " ] ) && $ input [ " type " ] == " geo_term " ) { $ current = $ this -> cStore -> buildGeoTerm ( $ term -> getID ( ) ) ; } else { $ current = $ this -> cStore -> populateTerm ( $ term -> getID ( ) ) ; } if ( $ current -> getType ( ) == $ term -> getType ( ) && $ term -> getTerm ( ) != null && $ term -> getTerm ( ) != " " ) { throw new \ snac \ exceptions \ SNACPermissionException ( " Currently the system is not allowing updating terms. " , 403 ) ; } $ response [ " error " ] = " The term to update was not found in the database. " ; } if ( $ success === true ) { $ response [ " result " ] = " success " ; } else { $ response [ " result " ] = " failure " ; } return $ response ; }
Update the Controlled Vocabulary
 Calls saveUser to save the user information to the database.
Update the Controlled Vocabulary Calls saveUser to save the user information to the database .
// We are doing an insert // Get the one out of the database // The term didn't change type and does not have an empty term field, so update