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"));
         }
     }
 }