src/snac/server/ServerExecutor.php
/**
     * Send Constellation For Review
     *
     * Lowers the lock on a constellation from editing to "needs review."  This essentially puts the
     * constellation into the list of constellations needing review.  The constellation must be given in the input.
     *
     * @param string[] $input Input array from the Server object
     * @throws \snac\exceptions\SNACException
     * @return string[] The response to send to the client
     */
Send Constellation For Review
Lowers the lock on a constellation from editing to "needs review."  This essentially puts the
constellation into the list of constellations needing review.  The constellation must be given in the input.

@param string[] $input Input array from the Server object
@throws \snac\exceptions\SNACException
@return string[] The response to send to the client
Send Constellation For Review Lowers the lock on a constellation from editing to " needs review . " This essentially puts the constellation into the list of constellations needing review . The constellation must be given in the input . @param string [] $input Input array from the Server object @throws \ snac \ exceptions \ SNACException @return string [] The response to send to the client
public function sendForReviewConstellation(&$input) {
        $response = array();
        try {
            $this->logger->addDebug("Marking the constellation as needs review");
            if (isset($input["constellation"])) {
                $constellation = new \snac\data\Constellation($input["constellation"]);
                $currentStatus = $this->cStore->readConstellationStatus($constellation->getID());
                $current = $this->cStore->readConstellation($constellation->getID(), null, DBUtil::$READ_NRD);
                $info = $this->cStore->readConstellationUserStatus($constellation->getID());
                $inList = false;
                if ($info != null && $this->user->getUserID() == $info["userid"] &&
                        ($info["status"] == "currently editing" || $info["status"] == "locked editing")) {
                    $inList = true;
                }
                if ($current->getVersion() == $constellation->getVersion() && $inList) {
                    $toUser = null;
                    if (isset($input["reviewer"])) {
                        $tmpUser = new \snac\data\User($input["reviewer"]);
                        $toUser = $this->uStore->readUser($tmpUser);
                        if ($toUser === false) {
                            throw new \snac\exceptions\SNACInputException("Tried to send constellation for review to unknown user", 400);
                        }
                        if (!$this->uStore->hasPrivilegeByLabel($toUser, "Change Locks")) {
                            throw new \snac\exceptions\SNACInputException("Tried to send constellation for review to non-reviewer", 400);
                        }
                    }
                    $logNote = "User sending Constellation for review";
                    $personalMessage = false;
                    if (isset($input["message"]) && $input["message"] != null && $input["message"] != "") {
                        $logNote = $input["message"];
                        $personalMessage = true;
                    }
                    $result = $this->cStore->writeConstellationStatus($this->user, $constellation->getID(), "needs review",
                            $logNote, $toUser);
                    if (isset($result) && $result !== false) {
                        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 for review");
                            $msgBody = "<p>Please review my constellation.</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);
                        }
                        $this->logger->addDebug("successfully sent constellation for review");
                        $constellation->setVersion($result);
                        $response["constellation"] = $constellation->toArray();
                        $response["result"] = "success";
                    } else {
                        $this->logger->addDebug("could not send the constellation for review");
                        $response["result"] = "failure";
                        $response["error"] = "writing status failed";
                    }
                } else {
                    $this->logger->addDebug("constellation versions didn't match or was not in users currently editing list");
                    $response["result"] = "failure";
                    $response["error"] = "other changes have been made to this constellation";
                    $response["constellation"] = $constellation->toArray();
                }
            } else {
                $this->logger->addDebug("no constellation given to send for review");
                $response["result"] = "failure";
                $response["error"] = "no constellation given";
            }
        } catch (\Exception $e) {
            $this->logger->addError("sending constellation for review threw an exception");
            $response["result"] = "failure";
            throw $e;
        }
        return $response;
    }
public function sendForReviewConstellation ( & $ input ) { $ response = array ( ) ; try { $ this -> logger -> addDebug ( " Marking the constellation as needs review " ) ; if ( isset ( $ input [ " constellation " ] ) ) { $ constellation = new \ snac \ data \ Constellation ( $ input [ " constellation " ] ) ; $ currentStatus = $ this -> cStore -> readConstellationStatus ( $ constellation -> getID ( ) ) ; $ current = $ this -> cStore -> readConstellation ( $ constellation -> getID ( ) , null , DBUtil :: $ READ_NRD ) ; $ info = $ this -> cStore -> readConstellationUserStatus ( $ constellation -> getID ( ) ) ; $ inList = false ; if ( $ info != null && $ this -> user -> getUserID ( ) == $ info [ " userid " ] && ( $ info [ " status " ] == " currently editing " || $ info [ " status " ] == " locked editing " ) ) { $ inList = true ; } if ( $ current -> getVersion ( ) == $ constellation -> getVersion ( ) && $ inList ) { $ toUser = null ; if ( isset ( $ input [ " reviewer " ] ) ) { $ tmpUser = new \ snac \ data \ User ( $ input [ " reviewer " ] ) ; $ toUser = $ this -> uStore -> readUser ( $ tmpUser ) ; if ( $ toUser === false ) { throw new \ snac \ exceptions \ SNACInputException ( " Tried to send constellation for review to unknown user " , 400 ) ; } if ( ! $ this -> uStore -> hasPrivilegeByLabel ( $ toUser , " Change Locks " ) ) { throw new \ snac \ exceptions \ SNACInputException ( " Tried to send constellation for review to non-reviewer " , 400 ) ; } } $ logNote = " User sending Constellation for review " ; $ personalMessage = false ; if ( isset ( $ input [ " message " ] ) && $ input [ " message " ] != null && $ input [ " message " ] != " " ) { $ logNote = $ input [ " message " ] ; $ personalMessage = true ; } $ result = $ this -> cStore -> writeConstellationStatus ( $ this -> user , $ constellation -> getID ( ) , " needs review " , $ logNote , $ toUser ) ; if ( isset ( $ result ) && $ result !== false ) { 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 for review " ) ; $ msgBody = " <p>Please review my constellation.</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 ) ; } $ this -> logger -> addDebug ( " successfully sent constellation for review " ) ; $ constellation -> setVersion ( $ result ) ; $ response [ " constellation " ] = $ constellation -> toArray ( ) ; $ response [ " result " ] = " success " ; } else { $ this -> logger -> addDebug ( " could not send the constellation for review " ) ; $ response [ " result " ] = " failure " ; $ response [ " error " ] = " writing status failed " ; } } else { $ this -> logger -> addDebug ( " constellation versions didn't match or was not in users currently editing list " ) ; $ response [ " result " ] = " failure " ; $ response [ " error " ] = " other changes have been made to this constellation " ; $ response [ " constellation " ] = $ constellation -> toArray ( ) ; } } else { $ this -> logger -> addDebug ( " no constellation given to send for review " ) ; $ response [ " result " ] = " failure " ; $ response [ " error " ] = " no constellation given " ; } } catch ( \ Exception $ e ) { $ this -> logger -> addError ( " sending constellation for review threw an exception " ) ; $ response [ " result " ] = " failure " ; throw $ e ; } return $ response ; }
Send Constellation For Review
 Lowers the lock on a constellation from editing to "needs review."
Send Constellation For Review Lowers the lock on a constellation from editing to " needs review . "
// Read the summary out of the database. if the version numbers match AND the constellation // is currently editing for the user, THEN send it for review it.  Else, send back a note to the client with a failure // Read the current summary // If this constellation is in the list of currently editing for the user, then send it for review // If the user doesn't exist, then don't allow the review to continue // Send a message and email to the user asked to review: // Send the message // Email the message, if needed