function alterTokensPlace() { $postParams = $this->postParams; $numberChanged = 0; $tokenID = false; if (isset($postParams["tokenID"])) { $tokenID = $postParams["tokenID"]; } $scope = "this"; if (isset($postParams["scope"])) { $scope = $postParams["scope"]; } $note = false; if (isset($postParams["note"])) { $note = $postParams["note"]; } $placeURI = "error"; if (isset($postParams["placeURI"])) { if (strstr($postParams["placeURI"], "http://")) { $placeURI = $postParams["placeURI"]; } elseif (strlen($postParams["placeURI"]) <= 1) { $placeURI = false; } } if ($placeURI != "error" && $tokenID != false) { $alterTokenIDs = array(); $alterTokenIDs[] = $tokenID; $this->nextTokenID = false; $this->newPlaceURI = false; if ($scope == "all-c") { $tokensObj = new Tokens(); $relatedTokens = $tokensObj->getTokenIDsByCommonPlace($tokenID); if (is_array($relatedTokens)) { $this->nextTokenID = $relatedTokens[0]; //the first of other related tokens! :) $this->newPlaceURI = $placeURI; } } elseif ($scope == "all") { $tokensObj = new Tokens(); $relatedTokens = $tokensObj->getTokenIDsByCommonPlace($tokenID); if (is_array($relatedTokens)) { foreach ($relatedTokens as $alterID) { $alterTokenIDs[] = $alterID; //add to the array of tokenIDs to alter } } } else { //do nothing } //iterate through and make all the changes! foreach ($alterTokenIDs as $alterID) { $ok = $this->alterTokenPlace($alterID, $placeURI, $note); if ($ok) { $numberChanged++; } } } return $numberChanged; }