public function _multiple_update() { if (!$this->user->canModify('common/resource_library')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true)); } $object_name = $this->request->get['object_name']; $object_id = $this->request->get['object_id']; $result = false; $rm = new AResourceManager(); if ($this->request->post['sort_order']) { $result = $rm->updateSortOrder($this->request->post['sort_order'], $object_name, $object_id); } // $this->request->post['map'] must be an array of resource ids if ($this->request->post['map']) { $result = $rm->mapResources($this->request->post['map'], $object_name, $object_id); } // $this->request->post['unmap'] must be an array of resource ids if ($this->request->post['unmap']) { $result = $rm->unmapResources($this->request->post['unmap'], $object_name, $object_id); } // $this->request->post['delete'] must be an array of resource ids if ($this->request->post['delete']) { $result = $rm->deleteResources($this->request->post['delete'], $object_name, $object_id); if ($result === false) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $rm->error, 'reset_value' => true)); } } $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($result)); }
public function update_sort_order() { if (!$this->user->canModify('common/resource_library')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true)); } $rm = new AResourceManager(); $rm->updateSortOrder($this->request->post['sort_order'], $this->request->get['object_name'], $this->request->get['object_id']); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode(true)); }