Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
AdminLanguageGridHandler.inc.php
1 <?php
2 
18 import('lib.pkp.controllers.grid.admin.languages.PKPAdminLanguageGridHandler');
19 
20 class AdminLanguageGridHandler extends PKPAdminLanguageGridHandler {
25  parent::PKPAdminLanguageGridHandler();
26  }
27 
32  function initialize($request) {
33  parent::initialize($request);
34  AppLocale::requireComponents(LOCALE_COMPONENT_APP_ADMIN);
35  }
36 
42  function _updateContextLocaleSettings($request) {
43  $site = $request->getSite();
44  $siteSupportedLocales = $site->getSupportedLocales();
45 
46  $pressDao = DAORegistry::getDAO('PressDAO');
47  $contexts = $pressDao->getAll()->toArray();
48  foreach ($contexts as $context) {
49  $primaryLocale = $context->getPrimaryLocale();
50  $supportedLocales = $context->getSetting('supportedLocales');
51 
52  if (isset($primaryLocale) && !in_array($primaryLocale, $siteSupportedLocales)) {
53  $context->setPrimaryLocale($site->getPrimaryLocale());
54  $this->updateContext($context);
55  }
56 
57  if (is_array($supportedLocales)) {
58  $supportedLocales = array_intersect($supportedLocales, $siteSupportedLocales);
59  $context->updateSetting('supportedLocales', $supportedLocales, 'object');
60  }
61  }
62  }
63 
70  function _canManage($request) {
71  $pressDao = DAORegistry::getDAO('PressDAO');
72  $presses = $pressDao->getAll();
73  $userRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
74  $press = $request->getPress();
75  return ($presses->getCount() == 1 && $press && in_array(ROLE_ID_MANAGER, $userRoles));
76  }
77 }
78 
79 ?>
static & getDAO($name, $dbconn=null)
static requireComponents()
Handle administrative language grid requests. If in single context (e.g. press) installation, this grid can also handle language management requests. See _canManage().
& getAuthorizedContextObject($assocType)