/** * Create a new personal slot if our form was submitted. * * @return void * @access private * @since 4/1/08 */ private function createNewSlotIfRequested() { $authN = Services::getService("AuthN"); $harmoni = Harmoni::instance(); // Creation of new personal slots. $harmoni->request->startNamespace('personal_slot'); if (RequestContext::value('slot_postfix') && PersonalSlot::hasPersonal()) { try { $newSlotname = PersonalSlot::getPersonalShortname($authN->getFirstUserId()) . "-" . RequestContext::value('slot_postfix'); // Replace delimiting marks with an underscore $newSlotname = preg_replace('/[\\s\\/=+.,()]+/i', '_', $newSlotname); // Remove anything left over (other than letters/numbers/-/_) $newSlotname = preg_replace('/[^a-z0-9_-]/i', '', $newSlotname); $slot = new PersonalSlot(strtolower($newSlotname)); $slot->addOwner($authN->getFirstUserId()); } catch (OperationFailedException $e) { $harmoni->request->endNamespace(); if ($e->getCode() == Slot::OWNER_EXISTS) { throw new OperationFailedException("Placeholder '" . strtolower($newSlotname) . "' already exists."); } else { throw $e; } } // Log this change. if (Services::serviceRunning("Logging")) { $loggingManager = Services::getService("Logging"); $log = $loggingManager->getLogForWriting("Segue"); $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified."); $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events."); $item = new AgentNodeEntryItem("Create Placeholder", "New placeholder created: '" . $slot->getShortname() . "'."); $log->appendLogWithTypes($item, $formatType, $priorityType); } } $harmoni->request->endNamespace(); }
/** * Answer the slot object * * @return object Slot * @access protected * @since 1/14/08 */ protected function getSlot() { $slotMgr = SlotManager::instance(); if (RequestContext::value('slot')) { $slot = $slotMgr->getSlotByShortname(RequestContext::value('slot')); } else { $authN = Services::getService("AuthN"); $shortname = PersonalSlot::getPersonalShortname($authN->getFirstUserId()); $slot = new PersonalSlot($shortname . "-" . $siteId); $slot->addOwner($authN->getFirstUserId()); } return $slot; }