/** * This class implements the Singleton pattern. There is only ever * one instance of the this class and it is accessed only via the * ClassName::instance() method. * * @return object * @access public * @since 5/26/05 * @static */ public static function instance() { if (!isset(self::$instance)) { self::$instance = new UserData(); } return self::$instance; }
/** * Answer the head JS * * @return string * @access public * @since 1/13/09 * @static */ public static function getHeadJs() { ob_start(); print "\n\n\t\t<script type='text/javascript' src='" . POLYPHONY_PATH . "/javascript/UserData.js'></script>"; print "\n\t\t<script type='text/javascript'>\n\t\t// <![CDATA[\n\t\t\n\t\t\tvar userData = UserData.instance();\n"; $userData = UserData::instance(); foreach ($userData->getPreferenceKeys() as $key) { print "\n\t\t\tuserData.prefs['{$key}'] = '" . addslashes($userData->getPreference($key)) . "';"; } print "\n\t\t// ]]>\n\t\t</script>\n"; return ob_get_clean(); }
/** * Execute * * @return void * @access public * @since 09/23/08 */ public function execute() { try { $this->start(); $userData = UserData::instance(); $userData->setPreference(RequestContext::value('key'), RequestContext::value('val')); print "\n\t<preference key=\"" . RequestContext::value('key') . '">'; print $userData->getPreference(RequestContext::value('key')); print '</preference>'; $this->end(); } catch (Exception $e) { HarmoniErrorHandler::logException($e); $this->error($e->getMessage(), get_class($e)); } }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); ob_start(); $userPrefs = UserData::instance(); // $userPrefs->setPreference('test_pref2', 'goodbye world'); print "\n<input type='button' value='" . _("Clear Session-Values") . "'/>"; // print "\n<input type='button' value='"._("Delete All Values")."'/>"; print "\n<table border='1'>"; print "\n\t<thead>"; print "\n\t\t<tr>"; print "\n\t\t\t<th>" . "</th>"; print "\n\t\t\t<th>" . _('Key') . "</th>"; print "\n\t\t\t<th>" . _('Value') . "</th>"; print "\n\t\t\t<th>" . "</th>"; print "\n\t\t\t<th>" . _('Session-Value') . "</th>"; print "\n\t\t\t<th>" . _('Stored-Value') . "</th>"; print "\n\t\t</tr>"; print "\n\t</thead>"; print "\n\t<tbody>"; foreach ($userPrefs->getPreferenceKeys() as $key) { print "\n\t\t<tr>"; print "\n\t\t\t<td><input type='button' name='" . RequestContext::name('delete') . "' value='" . _("Delete") . "'/></td>"; print "\n\t\t\t<td class='user_pref_key'>" . $key . "</td>"; print "\n\t\t\t<td class='user_pref_val'><input type='text' name='" . RequestContext::name('pref_val') . "' value=\"" . $userPrefs->getPreference($key) . "\"/></td>"; print "\n\t\t\t<td><input type='button' name='" . RequestContext::name('save') . "' value='" . _("Save Changes") . "'/></td>"; print "\n\t\t\t<td class='user_pref_sess_val'>" . $userPrefs->getPreferenceSessionValue($key) . "</td>"; print "\n\t\t\t<td class='user_pref_stored_val'>" . $userPrefs->getPreferencePersistantValue($key) . "</td>"; print "\n\t\t</tr>"; } print "\n\t\t<tr>"; print "\n\t\t\t<td></td>"; print "\n\t\t\t<td><input type='text' name='" . RequestContext::name('pref_key') . "'/></td>"; print "\n\t\t\t<td><input type='text' name='" . RequestContext::name('pref_val') . "'/></td>"; print "\n\t\t\t<td><input type='button' name='" . RequestContext::name('new') . "' value='" . _("Create New Preference") . "'/></td>"; print "\n\t\t\t<td></td>"; print "\n\t\t\t<td></td>"; print "\n\t\t</tr>"; print "\n\t</tbody>"; print "\n</table>"; $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); textdomain($defaultTextDomain); }
/** * Set the UI module * * @param string $module * @return void * @access public * @since 7/27/07 */ function setUiModule($module) { $allowed = array('ui1', 'ui2'); if (in_array($module, $allowed)) { UserData::instance()->setPreference('segue_ui_module', $module); } }
$authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); // Administration Functions $type = new Type("Authorization", "edu.middlebury.harmoni", "Group Administration", "Functions for administering groups."); $id = $idManager->getId("edu.middlebury.authorization.create_group"); $function = $authZManager->createFunction($id, "Create Groups", "Add Groups to the system.", $type, $qualifierHierarchyId); $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); $id = $idManager->getId("edu.middlebury.authorization.delete_group"); $function = $authZManager->createFunction($id, "Delete Groups", "Remove Groups from the system.", $type, $qualifierHierarchyId); $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); $id = $idManager->getId("edu.middlebury.authorization.modify_group_membership"); $function = $authZManager->createFunction($id, "Modify Group Membership", "Modify Group membership.", $type, $qualifierHierarchyId); $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); /********************************************************* * Add a site for the administrator user to use for testing * new installations. *********************************************************/ $slotMgr = SlotManager::instance(); $testSlot = $slotMgr->getSlotByShortname('jadministrator-test_site'); $testSlot->addOwner($adminAgent->getId()); $testSlot->setLocationCategory('community'); $slotMgr->convertSlotToType($testSlot, Slot::personal); // Set the 'personal' folder as the last visited so that admins logging into // a new install will see their personal test site. UserData::instance()->setPreference('segue_portal_last_folder', 'personal'); // print "\n<br> ...done"; $_SESSION['table_setup_complete'] = TRUE; unset($_SESSION['installation_underway']); // $dbHandler->commitTransaction($dbID); RequestContext::locationHeader($_SERVER['REQUEST_URI']); } }
/** * Answer the current Folder id * * @return string * @access private * @since 4/1/08 */ private function getCurrentFolderId() { if (!isset($this->currentFolderId)) { if (RequestContext::value('folder')) { try { $portalMgr = PortalManager::instance(); $folder = $portalMgr->getFolder(RequestContext::value('folder')); $this->currentFolderId = $folder->getIdString(); } catch (UnknownIdException $e) { $this->currentFolderId = 'recent_access'; } } else { if (UserData::instance()->getPreference('segue_portal_last_folder')) { $harmoni = Harmoni::instance(); $this->currentFolderId = UserData::instance()->getPreference('segue_portal_last_folder'); if (!strlen(RequestContext::value('starting_number')) && UserData::instance()->getPreference('segue_portal_starting_number')) { $harmoni->request->setRequestParam('starting_number', UserData::instance()->getPreference('segue_portal_starting_number')); } try { $portalMgr = PortalManager::instance(); $folder = $portalMgr->getFolder($this->currentFolderId); $this->currentFolderId = $folder->getIdString(); } catch (UnknownIdException $e) { $this->currentFolderId = 'personal'; $harmoni->request->setRequestParam('starting_number', '0'); } } else { $this->currentFolderId = 'recent_access'; } } } UserData::instance()->setPreference('segue_portal_last_folder', $this->currentFolderId); UserData::instance()->setPreference('segue_portal_starting_number', strval(intval(RequestContext::value('starting_number')))); return $this->currentFolderId; }
/** * Update from environmental ($_REQUEST) data. * Plugin writers should override this method with their own functionality * as needed. * * @param array $request * @return void * @access public * @since 1/12/06 */ function update($request) { if ($this->getFieldValue('edit')) { $this->editing = true; } if ($this->getFieldValue('submit_pressed')) { $this->setContent($this->tokenizeLocalUrls($this->cleanHTML($this->unapplyTextTemplates($this->getFieldValue('content'))))); $this->setRawDescription(intval($this->getFieldValue('abstractLength'))); $this->logEvent('Modify Content', 'TextBlock content updated'); if ($this->getFieldValue('comment') && $this->getFieldValue('comment') != $this->getCommentText()) { $this->markVersion($this->getFieldValue('comment')); } else { $this->markVersion(); } } else { if ($this->getFieldValue('editor')) { $this->textEditor = $this->getFieldValue('editor'); UserData::instance()->setPreference('segue_text_editor', $this->textEditor); $this->editing = true; $this->workingContent = $this->cleanHTML($this->getFieldValue('content')); $this->workingAbstractLength = intval($this->getFieldValue('abstractLength')); } } }