if (!Auth::ACL('edit-' . $Table) && !Auth::ACL('edit-' . $Table . '-' . $Field) && !Auth::ACL('su')) { echo '1'; die; } $m = new RowLock($database); $locks = $m->Select(array('I' => $ID, 'T' => $Table)); if (isset($getpost['S'])) { // checking status only if (!false_or_null($locks) && count($locks) > 0) { echo '1'; die; } echo '0'; die; } if (!false_or_null($locks) && count($locks) > 0) { foreach ($locks as $lock) { $m->Delete(array('ID' => $lock['ID'])); } echo '0'; die; } $m->Insert(array('T' => $Table, 'I' => $ID)); Modified(array("D" => array($Table => array("F" => 'Edit Lock', "I" => $ID)))); echo '1'; die; } } echo '-1'; die; // Give a false positive
$getpost = getpost(); if (isset($getpost['I']) && isset($getpost['V']) && isset($getpost['T']) && isset($getpost['F'])) { $ID = $getpost['I']; $Table = $getpost['T']; $Field = $getpost['F']; $Value = $getpost['V']; if (!Auth::ACL('edit-' . $Table) && !Auth::ACL('edit-' . $Table . '-' . $Field) && !Auth::ACL('su')) { echo '{"result":"readonly"}'; die; } if (LockCheck($Table, $ID) === TRUE) { echo '{"result":"locked"}'; die; } if (AutoLockCheck($Table, $ID) === TRUE) { echo '{"result":"locked"}'; die; } // Update the db, but only when a valid model is provided if (class_exists($Table) && matches(get_parent_class($Table), 'Model')) { global $database; $model = new $Table($database); $model->Update(array($Field => $Value), array('ID' => $ID)); Modified(array("D" => array($Table => array("F" => $Field, "I" => $ID)))); echo '{"result":"success"}'; //var_dump($getpost); exit; } } } echo '{"result":"error"}';