src/snac/server/ServerExecutor.php
/**
     * List Constellations
     *
     * Lists the Constellations with a given status for any user.  If the requesting user needs permission
     * to actually get the list of constellations, this method also checks permissions.
     *
     * @param string[] $input Input array from the Server object
     * @throws \snac\exceptions\SNACPermissionException
     * @return string[] The response to send to the client
     */
List Constellations
Lists the Constellations with a given status for any user.  If the requesting user needs permission
to actually get the list of constellations, this method also checks permissions.

@param string[] $input Input array from the Server object
@throws \snac\exceptions\SNACPermissionException
@return string[] The response to send to the client
List Constellations Lists the Constellations with a given status for any user . If the requesting user needs permission to actually get the list of constellations this method also checks permissions . @param string [] $input Input array from the Server object @throws \ snac \ exceptions \ SNACPermissionException @return string [] The response to send to the client
public function listConstellations(&$input) {
        $status = "published";
        if (isset($input["status"]))
            $status = $input["status"];
        $hasPermission = false;
        switch ($status) {
            case "needs review":
                if ($this->hasPermission("Change Locks"))
                    $hasPermission = true;
                break;
            case "published":
                $hasPermission = true;
                break;
        }
        if (!$hasPermission) {
            throw new \snac\exceptions\SNACPermissionException("User does not have permission to list constellations with this status", 403);
        }
        $list = $this->cStore->listConstellationsWithStatusForAny($status);
        $response["results"] = array ();
        if ($list !== false) {
            foreach ($list as $constellation) {
                if ($constellation->getPreferredNameEntry() == null) {
                    $this->logger->addError("Constellation did not have name entry", $constellation->toArray());
                    continue;
                }
                $item = array (
                    "id" => $constellation->getID(),
                    "version" => $constellation->getVersion(),
                    "nameEntry" => ($constellation->getPreferredNameEntry() ? $constellation->getPreferredNameEntry()->getOriginal() : null)
                );
                $this->logger->addDebug("Listing (".$status.")", $item);
                array_push($response["results"], $item);
            }
        }
        usort($response["results"],
            function ($a, $b) {
                return $a['nameEntry'] <=> $b['nameEntry'];
            });
        return $response;
    }
public function listConstellations ( & $ input ) { $ status = " published " ; if ( isset ( $ input [ " status " ] ) ) $ status = $ input [ " status " ] ; $ hasPermission = false ; switch ( $ status ) { case " needs review " : if ( $ this -> hasPermission ( " Change Locks " ) ) $ hasPermission = true ; break ; case " published " : $ hasPermission = true ; break ; } if ( ! $ hasPermission ) { throw new \ snac \ exceptions \ SNACPermissionException ( " User does not have permission to list constellations with this status " , 403 ) ; } $ list = $ this -> cStore -> listConstellationsWithStatusForAny ( $ status ) ; $ response [ " results " ] = array ( ) ; if ( $ list !== false ) { foreach ( $ list as $ constellation ) { if ( $ constellation -> getPreferredNameEntry ( ) == null ) { $ this -> logger -> addError ( " Constellation did not have name entry " , $ constellation -> toArray ( ) ) ; continue ; } $ item = array ( " id " => $ constellation -> getID ( ) , " version " => $ constellation -> getVersion ( ) , " nameEntry " => ( $ constellation -> getPreferredNameEntry ( ) ? $ constellation -> getPreferredNameEntry ( ) -> getOriginal ( ) : null ) ) ; $ this -> logger -> addDebug ( " Listing ( " . $ status . " ) " , $ item ) ; array_push ( $ response [ " results " ] , $ item ) ; } } usort ( $ response [ " results " ] , function ( $ a , $ b ) { return $ a [ 'nameEntry' ] <=> $ b [ 'nameEntry' ] ; } ) ; return $ response ; }
List Constellations
 Lists the Constellations with a given status for any user.
List Constellations Lists the Constellations with a given status for any user .
//default is no permission //throw permission denied //TODO: may want to rewrite this as a list of Constellation objects // Error handling // Give the needs review back in alphabetical order