public function __construct($po_request, $ps_table = "")
 {
     $this->opo_request = $po_request;
     $this->ops_table = $ps_table;
     $this->opo_dm = Datamodel::load();
     $this->opa_errors = array();
     $this->ops_method = $this->opo_request->getRequestMethod();
     if (!in_array($this->ops_method, array("PUT", "DELETE", "GET", "POST", "OPTIONS"))) {
         $this->addError("Invalid HTTP request method");
     }
     $this->opn_id = $this->opo_request->getParameter("id", pString);
     // we allow for a string to support fetching by idno; typically it's a numeric id
     if ($vs_locale = $this->opo_request->getParameter('lang', pString)) {
         global $g_ui_locale, $g_ui_locale_id, $_;
         $g_ui_locale = $vs_locale;
         $t_locale = new ca_locales();
         if ($g_ui_locale_id = $t_locale->localeCodeToID($vs_locale)) {
             $g_ui_locale = $vs_locale;
             if (!initializeLocale($g_ui_locale)) {
                 die("Error loading locale " . $g_ui_locale);
             }
             $this->opo_request->reloadAppConfig();
         }
     }
     $vs_post_data = $this->opo_request->getRawPostData();
     if (strlen(trim($vs_post_data)) > 0) {
         $this->opa_post = json_decode($vs_post_data, true);
         if (!is_array($this->opa_post)) {
             $this->addError(_t("Data sent via POST doesn't seem to be in JSON format"));
         }
     } else {
         if ($vs_post_data = $this->opo_request->getParameter('source', pString)) {
             $this->opa_post = json_decode($vs_post_data, true);
             if (!is_array($this->opa_post)) {
                 $this->addError(_t("Data sent via 'source' parameter doesn't seem to be in JSON format"));
             }
         } else {
             $this->opa_post = array();
         }
     }
     $this->opa_valid_tables = array("ca_objects", "ca_object_lots", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_lists", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops", "ca_sets");
     if (strlen($ps_table) > 0) {
         if (!in_array($ps_table, $this->opa_valid_tables)) {
             $this->addError(_t("Table does not exist"));
         }
     }
 }
 public function DoLogin()
 {
     global $g_ui_locale;
     $vs_redirect_url = $this->request->getParameter('redirect', pString) ?: caNavUrl($this->request, null, null, null);
     if (!$this->request->doAuthentication(array('dont_redirect_to_login' => true, 'redirect' => $vs_redirect_url, 'noPublicUsers' => true, 'user_name' => $this->request->getParameter('username', pString), 'password' => $this->request->getParameter('password', pString)))) {
         $this->notification->addNotification(_t("Login was invalid"), __NOTIFICATION_TYPE_ERROR__);
         $this->view->setVar('notifications', $this->notification->getNotifications());
         if (isset($_COOKIE['CA_' . __CA_APP_NAME__ . '_ui_locale'])) {
             if (!initializeLocale($_COOKIE['CA_' . __CA_APP_NAME__ . '_ui_locale'])) {
                 die("Error loading locale " . $g_ui_locale);
             }
         }
         $this->render('login_html.php');
     } else {
         //
         // Reset locale globals
         //
         global $g_ui_locale_id, $g_ui_locale, $g_ui_units_pref, $_, $_locale;
         $g_ui_locale_id = $this->request->user->getPreferredUILocaleID();
         // get current UI locale as locale_id	 			(available as global)
         $g_ui_locale = $this->request->user->getPreferredUILocale();
         // get current UI locale as locale string 			(available as global)
         $g_ui_units_pref = $this->request->user->getPreference('units');
         // user's selected display units for measurements 	(available as global)
         if (!initializeLocale($g_ui_locale)) {
             die("Error loading locale " . $g_ui_locale);
         }
         MemoryCache::flush('translation');
         AppNavigation::clearMenuBarCache($this->request);
         // want to clear menu bar on login
         // Notify the user of the good news
         $this->notification->addNotification(_t("You are now logged in"), __NOTIFICATION_TYPE_INFO__);
         // Jump to redirect if set
         if ($vs_redirect_url) {
             $this->redirect($vs_redirect_url);
         }
         $this->render('welcome_html.php');
     }
 }
 public function Save()
 {
     $vs_view_name = 'preferences_html.php';
     $vs_action = $this->request->getParameter('action', pString);
     switch ($vs_action) {
         case 'EditCataloguingPrefs':
             $vs_group = 'cataloguing';
             $this->request->user->setPreference('cataloguing_locale', $this->request->getParameter('pref_cataloguing_locale', pString));
             $va_ui_prefs = array();
             foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                 foreach ($_REQUEST as $vs_k => $vs_v) {
                     if (preg_match("!pref_{$vs_pref}_([\\d]+)!", $vs_k, $va_matches)) {
                         $va_ui_prefs[$vs_pref][$va_matches[1]] = $vs_v;
                     } elseif (preg_match("!pref_{$vs_pref}__NONE_!", $vs_k)) {
                         $va_ui_prefs[$vs_pref]['_NONE_'] = $vs_v;
                     }
                 }
                 foreach ($va_ui_prefs as $vs_pref => $va_values) {
                     $this->request->user->setPreference($vs_pref, $va_values);
                 }
             }
             $vs_view_name = 'preferences_cataloguing_html.php';
             break;
         case 'EditBatchPrefs':
             $vs_group = 'batch';
             $va_ui_prefs = array();
             foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                 foreach ($_REQUEST as $vs_k => $vs_v) {
                     if (preg_match("!pref_{$vs_pref}!", $vs_k, $va_matches)) {
                         $this->request->user->setPreference($vs_pref, $vs_v);
                     }
                 }
             }
             $vs_view_name = 'preferences_batch_html.php';
             break;
         case 'EditQuickAddPrefs':
             $vs_group = 'quickadd';
             $va_ui_prefs = array();
             foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                 foreach ($_REQUEST as $vs_k => $vs_v) {
                     if (preg_match("!pref_{$vs_pref}_([\\d]+)!", $vs_k, $va_matches)) {
                         $va_ui_prefs[$vs_pref][$va_matches[1]] = $vs_v;
                     }
                 }
                 foreach ($va_ui_prefs as $vs_pref => $va_values) {
                     $this->request->user->setPreference($vs_pref, $va_values);
                 }
             }
             $vs_view_name = 'preferences_quickadd_html.php';
             break;
         case 'EditMediaPrefs':
             $vs_group = 'media';
             foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                 $this->request->user->setPreference($vs_pref, $this->request->getParameter('pref_' . $vs_pref, pString));
             }
             break;
         case 'EditUnitsPrefs':
             $vs_group = 'units';
             foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                 $this->request->user->setPreference($vs_pref, $this->request->getParameter('pref_' . $vs_pref, pString));
             }
             break;
         case 'EditProfilePrefs':
             $vs_group = 'profile';
             foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                 $this->request->user->setPreference($vs_pref, $this->request->getParameter('pref_' . $vs_pref, pString));
             }
             break;
         case 'EditDuplicationPrefs':
             $vs_group = 'duplication';
             foreach (array('ca_objects', 'ca_object_lots', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_loans', 'ca_movements', 'ca_lists', 'ca_list_items', 'ca_tours', 'ca_tour_stops', 'ca_sets', 'ca_bundle_displays') as $vs_table) {
                 foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                     if ($vs_pref == 'duplicate_relationships') {
                         $vs_val = $this->request->getParameter("pref_{$vs_table}_{$vs_pref}", pArray);
                     } else {
                         $vs_val = $this->request->getParameter("pref_{$vs_table}_{$vs_pref}", pString);
                     }
                     $this->request->user->setPreference("{$vs_table}_{$vs_pref}", $vs_val);
                 }
             }
             $vs_view_name = 'preferences_duplication_html.php';
             break;
         case 'EditUIPrefs':
         default:
             $vs_group = 'ui';
             $vs_action = 'EditUIPrefs';
             foreach ($this->request->user->getValidPreferences($vs_group) as $vs_pref) {
                 $this->request->user->setPreference($vs_pref, $vs_locale = $this->request->getParameter('pref_' . $vs_pref, pString));
                 if ($vs_pref == 'ui_locale' && $vs_locale) {
                     global $_, $g_ui_locale_id, $g_ui_locale, $_locale;
                     // set UI locale for this request (causes UI language to change immediately - and in time - for this request)
                     // if we didn't do this, you'd have to reload the page to see the locale change
                     $this->request->user->setPreference('ui_locale', $vs_locale);
                     $g_ui_locale_id = $this->request->user->getPreferredUILocaleID();
                     // get current UI locale as locale_id	 			(available as global)
                     $g_ui_locale = $this->request->user->getPreferredUILocale();
                     // get current UI locale as locale string 			(available as global)
                     if (!initializeLocale($g_ui_locale)) {
                         die("Error loading locale " . $g_ui_locale);
                     }
                     MemoryCache::flush('translation');
                     // reload menu bar
                     AppNavigation::clearMenuBarCache($this->request);
                 }
                 if ($vs_pref == 'ui_theme') {
                     // set the view path to use the new theme; if we didn't set this here you'd have to reload the page to
                     // see the theme change.
                     $this->view->setViewPath($this->request->getViewsDirectoryPath() . '/' . $this->request->getModulePath());
                 }
             }
             break;
     }
     $this->request->setAction($vs_action);
     $this->view->setVar('group', $vs_group);
     $this->notification->addNotification(_t("Saved preference settings"), __NOTIFICATION_TYPE_INFO__);
     $this->view->setVar('t_user', $this->request->user);
     $this->render($vs_view_name);
 }
Exemple #4
0
}
if (!($g_ui_locale = $g_request->session->getVar('lang'))) {
    $g_ui_locale = $va_ui_locales[0];
}
if (!in_array($g_ui_locale, $va_ui_locales)) {
    $g_ui_locale = $va_ui_locales[0];
}
$t_locale = new ca_locales();
$g_ui_locale_id = $t_locale->localeCodeToID($g_ui_locale);
// get current UI locale as locale_id	  (available as global)
$_ = array();
if (file_exists($vs_theme_specific_locale_path = $g_request->getThemeDirectoryPath() . '/locale/' . $g_ui_locale . '/messages.mo')) {
    $_[] = new Zend_Translate('gettext', $vs_theme_specific_locale_path, $g_ui_locale);
}
$_[] = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/' . $g_ui_locale . '/messages.mo', $g_ui_locale);
if (!initializeLocale($g_ui_locale)) {
    die("Error loading locale " . $g_ui_locale);
}
$g_request->reloadAppConfig();
// need to reload app config to reflect current locale
//
// PageFormat plug-in generates header/footer shell around page content
//
if (!$g_request->isAjax() && !$g_request->isDownload()) {
    require_once __CA_LIB_DIR__ . '/pawtucket/PageFormat.php';
    $app->registerPlugin(new PageFormat());
} else {
    require_once __CA_LIB_DIR__ . '/pawtucket/AjaxFooter.php';
    $app->registerPlugin(new AjaxFooter());
}
//
Exemple #5
0
 *
 */
require_once __CA_APP_DIR__ . '/helpers/errorHelpers.php';
require_once __CA_BASE_DIR__ . '/vendor/autoload.php';
// composer
require_once __CA_LIB_DIR__ . '/core/Utils/Debug.php';
require_once __CA_LIB_DIR__ . '/core/Zend/Translate.php';
require_once __CA_LIB_DIR__ . '/core/Zend/Cache.php';
require_once __CA_LIB_DIR__ . '/core/Zend/Registry.php';
require_once __CA_LIB_DIR__ . '/core/Cache/MemoryCache.php';
// is used in utilityHelpers
require_once __CA_APP_DIR__ . '/helpers/utilityHelpers.php';
require_once __CA_APP_DIR__ . '/helpers/initializeLocale.php';
if (isset($_COOKIE['CA_' . __CA_APP_NAME__ . '_ui_locale'])) {
    $g_ui_locale = $_COOKIE['CA_' . __CA_APP_NAME__ . '_ui_locale'];
    initializeLocale($g_ui_locale);
}
require_once __CA_APP_DIR__ . '/helpers/navigationHelpers.php';
require_once __CA_APP_DIR__ . '/helpers/mailHelpers.php';
require_once __CA_LIB_DIR__ . '/core/ApplicationMonitor.php';
require_once __CA_LIB_DIR__ . '/core/BaseModel.php';
require_once __CA_LIB_DIR__ . '/core/Controller/AppController.php';
require_once __CA_LIB_DIR__ . '/ca/MetaTagManager.php';
require_once __CA_LIB_DIR__ . '/ca/AssetLoadManager.php';
require_once __CA_LIB_DIR__ . '/ca/TooltipManager.php';
require_once __CA_LIB_DIR__ . '/ca/FooterManager.php';
require_once __CA_LIB_DIR__ . '/ca/AppNavigation.php';
require_once __CA_LIB_DIR__ . '/core/Controller/ActionController.php';
require_once __CA_MODELS_DIR__ . '/ca_acl.php';
require_once __CA_LIB_DIR__ . '/core/Cache/ExternalCache.php';
require_once __CA_LIB_DIR__ . '/core/Cache/CompositeCache.php';