public function RecordRepresentationSelection() { $pn_item_id = $this->request->getParameter('item_id', pInteger); $pn_representation_id = $this->request->getParameter('representation_id', pInteger); $pn_selected = $this->request->getParameter('selected', pInteger); $va_errors = array(); $t_set_item = new ca_set_items($pn_item_id); $t_set = new ca_sets($t_set_item->get('set_id')); if (!$t_set->getPrimaryKey() || !$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) { // TODO: proper error reporting or redirect? return; } if (!$t_set_item->getPrimaryKey()) { $va_errors[] = _t("Invalid set item"); } if (!sizeof($va_errors)) { $t_set = new ca_sets($t_set_item->get('set_id')); if (!$t_set->getPrimaryKey()) { $va_errors[] = _t("Invalid set"); } if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) { $va_errors[] = _t("You do not have access to this set"); } if (!sizeof($va_errors)) { if ((bool) $pn_selected) { $t_set_item->addSelectedRepresentation($pn_representation_id); } else { $t_set_item->removeSelectedRepresentation($pn_representation_id); } $t_set_item->update(); $va_errors = $t_set_item->getErrors(); } } $this->view->setVar("errors", $va_errors); $this->view->setVar('representation_id', $pn_representation_id); $this->view->setVar('item_id', $pn_item_id); $this->render("ajax_select_representation_json.php"); }