Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PKPUserHandler.inc.php
1 <?php
2 
16 import('classes.handler.Handler');
17 
18 class PKPUserHandler extends Handler {
22  function PKPUserHandler() {
23  parent::Handler();
24  }
25 
30  function setLocale($args, $request) {
31  $setLocale = array_shift($args);
32 
33  $site = $request->getSite();
34  $context = $request->getContext();
35  if ($context != null) {
36  $contextSupportedLocales = (array) $context->getSupportedLocales();
37  }
38 
39  if (AppLocale::isLocaleValid($setLocale) && (!isset($contextSupportedLocales) || in_array($setLocale, $contextSupportedLocales)) && in_array($setLocale, $site->getSupportedLocales())) {
40  $session = $request->getSession();
41  $session->setSessionVar('currentLocale', $setLocale);
42  }
43 
44  if(isset($_SERVER['HTTP_REFERER'])) {
45  $request->redirectUrl($_SERVER['HTTP_REFERER']);
46  }
47 
48  $source = $request->getUserVar('source');
49  if (isset($source) && !empty($source)) {
50  $request->redirectUrl(
51  $request->getProtocol() . '://' . $request->getServerHost() . $source,
52  false
53  );
54  }
55 
56  $request->redirect(null, 'index');
57  }
58 
65  function getInterests($args, $request) {
66  // Get the input text used to filter on
67  $filter = $request->getUserVar('term');
68 
69  import('lib.pkp.classes.user.InterestManager');
70  $interestManager = new InterestManager();
71 
72  $interests = $interestManager->getAllInterests($filter);
73 
74  import('lib.pkp.classes.core.JSONMessage');
75  $json = new JSONMessage(true, $interests);
76  return $json->getString();
77  }
78 
85  function toggleHelp($args, $request) {
86 
87  $user = $request->getUser();
88  $user->setInlineHelp($user->getInlineHelp() ? 0 : 1);
89 
90  $userDao = DAORegistry::getDAO('UserDAO');
91  $userDao->updateObject($user);
92 
93  import('lib.pkp.classes.core.JSONMessage');
94  $json = new JSONMessage(true);
95  return $json->getString();
96  }
97 
103  function authorizationDenied($args, $request) {
104  if (!Validation::isLoggedIn()) {
106  }
107 
108  // Get message with sanity check (for XSS or phishing)
109  $authorizationMessage = $request->getUserVar('message');
110  if (!preg_match('/^[a-zA-Z0-9.]+$/', $authorizationMessage)) {
111  fatalError('Invalid locale key for auth message.');
112  }
113 
114  $this->setupTemplate($request);
115  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_USER);
116  $templateMgr = TemplateManager::getManager($request);
117  $templateMgr->assign('message', $authorizationMessage);
118  return $templateMgr->display('common/message.tpl');
119  }
120 }
121 
122 ?>
static & getDAO($name, $dbconn=null)
static requireComponents()
setupTemplate($request)
Class to represent a JSON (Javascript Object Notation) message.
static redirectLogin($message=null)
Handle requests for user functions.
Base request handler application class.
Definition: Handler.inc.php:20
toggleHelp($args, $request)
authorizationDenied($args, $request)
static isLocaleValid($locale)
Handle user interest functions.
setLocale($args, $request)
getInterests($args, $request)