src/snac/server/ServerExecutor.php
/**
     * Reassign Constellation
     *
     * Reassigns the given constellation to a different user, setting it to be "locked editing" to that user, assuming the
     * administrator user has "Change Locks" permissions.
     *
     * @param string[] $input Input array from the Server object
     * @throws \snac\exceptions\SNACException
     * @return string[] The response to send to the client
     */
Reassign Constellation
Reassigns the given constellation to a different user, setting it to be "locked editing" to that user, assuming the
administrator user has "Change Locks" permissions.

@param string[] $input Input array from the Server object
@throws \snac\exceptions\SNACException
@return string[] The response to send to the client
Reassign Constellation Reassigns the given constellation to a different user setting it to be " locked editing " to that user assuming the administrator user has " Change Locks " permissions . @param string [] $input Input array from the Server object @throws \ snac \ exceptions \ SNACException @return string [] The response to send to the client
public function reassignConstellation(&$input) {
        $response = array();
        try {
            $this->logger->addDebug("Reassigning the constellation");
            if (isset($input["constellation"]) && isset($input["to_user"])) {
                $constellation = new \snac\data\Constellation($input["constellation"]);
                $toUser = new \snac\data\User($input["to_user"]);
                $logNote = "Constellation reassigned by " . $this->user->getUserName();
                $personalMessage = false;
                if (isset($input["message"]) && $input["message"] != "") {
                    $personalMessage = true;
                    $logNote = $input["message"];
                }
                $toUser = $this->uStore->readUser($toUser);
                if ($toUser === false) {
                    throw new \snac\exceptions\SNACInputException("Bad user information given.", 400);
                }
                $currentStatus = $this->cStore->readConstellationStatus($constellation->getID());
                $current = $this->cStore->readConstellation($constellation->getID(), null, DBUtil::$READ_NRD);
                if ($current->getVersion() == $constellation->getVersion() && $this->hasPermission("Change Locks")) {
                    $result = $this->cStore->writeConstellationStatus($this->user, $constellation->getID(), "change locks",
                            $logNote);
                    $result = $this->cStore->writeConstellationStatus($toUser, $constellation->getID(), "locked editing",
                            "Constellation reassigned by " . $this->user->getUserName());
                    if (isset($result) && $result !== false) {
                        $this->logger->addDebug("successfully reassigned constellation");
                        $constellation->setVersion($result);
                        $response["constellation"] = $constellation->toArray();
                        $response["result"] = "success";
                        if ($toUser != null) {
                            $newest = $this->cStore->readConstellation($constellation->getID(), null, DBUtil::$READ_MICRO_SUMMARY);
                            $message = new \snac\data\Message();
                            $message->setToUser($toUser);
                            $message->setFromUser($this->user);
                            $message->setSubject("Constellation Sent to You");
                            $msgBody = "<p>A constellation was reassigned to you for editing.</p>";
                            if ($personalMessage) {
                                $msgBody .= "<p>".$logNote."</p>";
                            }
                            $name = "Unknown";
                            $this->logger->addDebug("Sending message for reviewer", $newest->toArray());
                            $prefName = $newest->getPreferredNameEntry();
                            if ($prefName != null)
                                $name = $prefName->getOriginal();
                            $msgBody .= "<div class=\"list-group list-group-constellationlist\"><a href=\""
                                .\snac\Config::$WEBUI_URL.'/details/'.
                                $newest->getID()."/".$newest->getVersion()."?preview=1\"".
                                "class=\"constellation constellation-review list-group-item list-group-item-success\">$name</a></div>";
                            $message->setBody($msgBody);
                            $this->uStore->writeMessage($message);
                            $this->mailer->sendUserMessage($message);
                        }
                    } else {
                        $this->logger->addDebug("could not reassign the constellation");
                        $response["result"] = "failure";
                        $response["error"] = "writing status failed";
                    }
                } else {
                    $this->logger->addDebug("constellation versions didn't match or no permissions");
                    $response["result"] = "failure";
                    $response["error"] = "other changes have been made to this constellation";
                    $response["constellation"] = $constellation->toArray();
                }
            } else {
                $this->logger->addDebug("no constellation or user given");
                $response["result"] = "failure";
                $response["error"] = "no constellation or user given";
            }
        } catch (\Exception $e) {
            $this->logger->addError("unlocking constellation threw an exception");
            $response["result"] = "failure";
            throw $e;
        }
        return $response;
    }
public function reassignConstellation ( & $ input ) { $ response = array ( ) ; try { $ this -> logger -> addDebug ( " Reassigning the constellation " ) ; if ( isset ( $ input [ " constellation " ] ) && isset ( $ input [ " to_user " ] ) ) { $ constellation = new \ snac \ data \ Constellation ( $ input [ " constellation " ] ) ; $ toUser = new \ snac \ data \ User ( $ input [ " to_user " ] ) ; $ logNote = " Constellation reassigned by  " . $ this -> user -> getUserName ( ) ; $ personalMessage = false ; if ( isset ( $ input [ " message " ] ) && $ input [ " message " ] != " " ) { $ personalMessage = true ; $ logNote = $ input [ " message " ] ; } $ toUser = $ this -> uStore -> readUser ( $ toUser ) ; if ( $ toUser === false ) { throw new \ snac \ exceptions \ SNACInputException ( " Bad user information given. " , 400 ) ; } $ currentStatus = $ this -> cStore -> readConstellationStatus ( $ constellation -> getID ( ) ) ; $ current = $ this -> cStore -> readConstellation ( $ constellation -> getID ( ) , null , DBUtil :: $ READ_NRD ) ; if ( $ current -> getVersion ( ) == $ constellation -> getVersion ( ) && $ this -> hasPermission ( " Change Locks " ) ) { $ result = $ this -> cStore -> writeConstellationStatus ( $ this -> user , $ constellation -> getID ( ) , " change locks " , $ logNote ) ; $ result = $ this -> cStore -> writeConstellationStatus ( $ toUser , $ constellation -> getID ( ) , " locked editing " , " Constellation reassigned by  " . $ this -> user -> getUserName ( ) ) ; if ( isset ( $ result ) && $ result !== false ) { $ this -> logger -> addDebug ( " successfully reassigned constellation " ) ; $ constellation -> setVersion ( $ result ) ; $ response [ " constellation " ] = $ constellation -> toArray ( ) ; $ response [ " result " ] = " success " ; if ( $ toUser != null ) { $ newest = $ this -> cStore -> readConstellation ( $ constellation -> getID ( ) , null , DBUtil :: $ READ_MICRO_SUMMARY ) ; $ message = new \ snac \ data \ Message ( ) ; $ message -> setToUser ( $ toUser ) ; $ message -> setFromUser ( $ this -> user ) ; $ message -> setSubject ( " Constellation Sent to You " ) ; $ msgBody = " <p>A constellation was reassigned to you for editing.</p> " ; if ( $ personalMessage ) { $ msgBody .= " <p> " . $ logNote . " </p> " ; } $ name = " Unknown " ; $ this -> logger -> addDebug ( " Sending message for reviewer " , $ newest -> toArray ( ) ) ; $ prefName = $ newest -> getPreferredNameEntry ( ) ; if ( $ prefName != null ) $ name = $ prefName -> getOriginal ( ) ; $ msgBody .= " <div class= \" list-group list-group-constellationlist \" ><a href= \" " . \ snac \ Config :: $ WEBUI_URL . '/details/' . $ newest -> getID ( ) . " / " . $ newest -> getVersion ( ) . " ?preview=1 \" " . " class= \" constellation constellation-review list-group-item list-group-item-success \" > $ name </a></div> " ; $ message -> setBody ( $ msgBody ) ; $ this -> uStore -> writeMessage ( $ message ) ; $ this -> mailer -> sendUserMessage ( $ message ) ; } } else { $ this -> logger -> addDebug ( " could not reassign the constellation " ) ; $ response [ " result " ] = " failure " ; $ response [ " error " ] = " writing status failed " ; } } else { $ this -> logger -> addDebug ( " constellation versions didn't match or no permissions " ) ; $ response [ " result " ] = " failure " ; $ response [ " error " ] = " other changes have been made to this constellation " ; $ response [ " constellation " ] = $ constellation -> toArray ( ) ; } } else { $ this -> logger -> addDebug ( " no constellation or user given " ) ; $ response [ " result " ] = " failure " ; $ response [ " error " ] = " no constellation or user given " ; } } catch ( \ Exception $ e ) { $ this -> logger -> addError ( " unlocking constellation threw an exception " ) ; $ response [ " result " ] = " failure " ; throw $ e ; } return $ response ; }
Reassign Constellation
 Reassigns the given constellation to a different user, setting it to be "locked editing" to that user, assuming the
 administrator user has "Change Locks" permissions.
Reassign Constellation Reassigns the given constellation to a different user setting it to be " locked editing " to that user assuming the administrator user has " Change Locks " permissions .
// Get the full User object // Read the summary out of the database. if the version numbers match AND the constellation // is currently editing for the user, THEN unlock it.  Else, send back a note to the client with a failure // Read the current summary // If the admin user has the current version AND permission to change locks // Send a message and email to the user asked to review: // Send the message // Email the message, if needed