Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions codebase/Dhtmlx/Connector/Data/DataItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ public function set_value($name,$value){
id of element
*/
public function get_id(){
$return = false;
$id = $this->config->id["name"];
if (array_key_exists($id,$this->data))
return $this->data[$id];
return false;
if ((is_array($this->data) && array_key_exists($id,$this->data)) ||
(is_object($this->data) && property_exists($this->data,'attributes') && isset($this->data[$id]))
){
$return = $this->data[$id];
}
return $return;
}
/*! change id of element

Expand Down
28 changes: 22 additions & 6 deletions codebase/Dhtmlx/Connector/DataStorage/PHPLaravelDBDataWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,39 @@ protected function getErrorMessage() {
}

public function insert($data, $source) {
$className = get_class($source->get_source());
$obj = new $className();
$obj = null;
if(method_exists($source->get_source(), 'getModel')){
$obj = $source->get_source()->getModel()->newInstance();
} else {
$className = get_class($source->get_source());
$obj = new $className();
}

$this->fill_model($obj, $data)->save();

$fieldPrimaryKey = $this->config->id["db_name"];
$data->success($obj->$fieldPrimaryKey);
}

public function delete($data, $source) {
$className = get_class($source->get_source());
$className::destroy($data->get_id());
if(method_exists($source->get_source(), 'getModel')){
$source->get_source()->getModel()->find($data->get_id())->delete();
} else {
$className = get_class($source->get_source());
$className::destroy($data->get_id());
}
$data->success();
}

public function update($data, $source) {
$className = get_class($source->get_source());
$obj = $className::find($data->get_id());
$obj = null;
if(method_exists($source->get_source(), 'getModel')){
$obj = $source->get_source()->getModel()->find($data->get_id());
} else {
$className = get_class($source->get_source());
$obj = $className::find($data->get_id());
}

$this->fill_model($obj, $data)->save();
$data->success();
}
Expand Down
9 changes: 6 additions & 3 deletions codebase/Dhtmlx/Connector/GanttConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ function delete_related_links($action){
$links = $this->options["links"];
$value = $this->sql->escape($action->get_new_id());
$table = $links->get_request()->get_source();

$this->sql->query("DELETE FROM $table WHERE source = '$value'");
$this->sql->query("DELETE FROM $table WHERE target = '$value'");
if(method_exists($table, 'getModel') && method_exists($table->getModel(), 'getTable')){
$table->where('source', '=', $value)->orWhere('target', '=', $value)->delete();
} else {
$this->sql->query("DELETE FROM $table WHERE source = $value");
$this->sql->query("DELETE FROM $table WHERE target = $value");
}
}
}

Expand Down