public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     if (isset($this->params["categoryIndex"]) && isset($this->params["value"])) {
         $data = array();
         $oldValue = $this->getEntryField($this->object, $this->categoryIndex, $this->entryIndex, $this->field);
         try {
             $this->setEntryField($this->object, $this->categoryIndex, $this->entryIndex, $this->field, $this->value);
         } catch (steam_exception $e) {
             $data["oldValue"] = $oldValue;
             $data["error"] = $e->get_message();
             $data["undo"] = false;
             $ajaxResponseObject->setStatus("ok");
             $ajaxResponseObject->setData($data);
             return $ajaxResponseObject;
         }
         $ajaxResponseObject->setStatus("ok");
         $newValue = $this->getEntryField($this->object, $this->categoryIndex, $this->entryIndex, $this->field);
         if ($newValue === $this->params["value"]) {
             $data["oldValue"] = $oldValue;
             $data["newValue"] = $newValue;
             $data["error"] = "none";
             $data["undo"] = true;
         } else {
             $data["oldValue"] = $oldValue;
             $data["error"] = "Data could not be saved.";
             $data["undo"] = false;
         }
         $ajaxResponseObject->setData($data);
     } else {
         $ajaxResponseObject->setStatus("error");
     }
     return $ajaxResponseObject;
 }
Exemplo n.º 2
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     $sanctions_result = array();
     $sanctions = $this->object->get_sanction();
     foreach ($sanctions as $id => $sanction) {
         if ($sanction | SANCTION_READ) {
             $sanctions_result[] = "read_{$id}";
         }
         if ($sanction | SANCTION_WRITE) {
             $sanctions_result[] = "write_{$id}";
         }
         if ($sanction | SANCTION_SANCTION) {
             $sanctions_result[] = "sanction_{$id}";
         }
     }
     $ajaxResponseObject->setStatus("ok");
     $ajaxResponseObject->setData(array("acquire" => $this->object->get_acquire(), "sanctions" => $sanctions_result));
     return $ajaxResponseObject;
 }
Exemplo n.º 3
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     $data = array();
     if (isset($this->params["attribute"]) && isset($this->params["value"])) {
         $oldValue = self::getAttributeValue($this->object, $this->params["attribute"]);
         try {
             self::setAttributeValue($this->object, $this->params["attribute"], $this->params["value"]);
         } catch (steam_exception $e) {
             $data["oldValue"] = $oldValue;
             $data["error"] = $e->get_message();
             $data["undo"] = false;
             $ajaxResponseObject->setStatus("ok");
             $ajaxResponseObject->setData($data);
             return $ajaxResponseObject;
         }
         $ajaxResponseObject->setStatus("ok");
         $newValue = self::getAttributeValue($this->object, $this->params["attribute"]);
         if ($newValue === $this->params["value"]) {
             $data["oldValue"] = $oldValue;
             $data["newValue"] = $newValue;
             $data["error"] = "none";
             $data["undo"] = true;
         } else {
             $data["oldValue"] = $oldValue;
             $data["error"] = "Data could not be saved.";
             $data["undo"] = false;
         }
         $ajaxResponseObject->setData($data);
     } else {
         if (isset($this->params["value"]) && !isset($this->params["attribute"]) && $this->object instanceof steam_document) {
             $oldValue = $this->object->get_content();
             try {
                 $this->object->set_content(cleanHTML($this->params["value"]));
             } catch (steam_exception $e) {
                 $data["oldValue"] = $oldValue;
                 $data["error"] = $e->get_message();
                 $data["undo"] = false;
                 $ajaxResponseObject->setStatus("ok");
                 $ajaxResponseObject->setData($data);
                 return $ajaxResponseObject;
             }
             $ajaxResponseObject->setStatus("ok");
             $newValue = $this->object->get_content();
             //if ($newValue === $this->params["value"]) {
             $data["oldValue"] = $oldValue;
             $data["newValue"] = $newValue;
             $data["error"] = "none";
             $data["undo"] = true;
             // 			 } else {
             // 			 	$data["oldValue"] = $oldValue;
             // 			 	$data["error"] = "Data could not be saved.";
             // 				$data["undo"] = false;
             // 			 }
             $ajaxResponseObject->setData($data);
         } else {
             if (isset($this->params["annotate"])) {
                 $newValue = $this->params["annotate"];
                 $oldValue = "";
                 try {
                     $annotation = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "Annotation", $newValue, "text/plain");
                     $this->object->add_annotation($annotation);
                     $data["oldValue"] = "";
                     $data["newValue"] = "";
                     $data["error"] = "none";
                     $data["undo"] = false;
                 } catch (steam_exception $e) {
                     $data["oldValue"] = "";
                     $data["error"] = $e->get_message();
                     $data["undo"] = false;
                 }
                 $ajaxResponseObject->setStatus("ok");
                 $ajaxResponseObject->setData($data);
                 return $ajaxResponseObject;
             } else {
                 $ajaxResponseObject->setStatus("error");
             }
         }
     }
     return $ajaxResponseObject;
 }