public static function release_lock($UID, $entity_type, $user) { // add record to lock table in order to specify that the kbit is no longer locked // NOTE: it is recomended to implement the lock in separated class if (Lock::is_locked($UID, $entity_type) == false) { debugLog::log("<i>[Lock::release_lock]:</i> cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked"); return false; } if (Lock::is_locked_by_user($UID, $entity_type, $user) == false) { debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked by the same user"); return false; } $dbObj = new dbAPI(); // disable lock records $query = "UPDATE CONTENT_LOCK SET ENABLED = 0 WHERE LOCKED_UID = '" . $UID . "' AND ENTITY_TYPE = '" . $entity_type . "' AND LOCK_STATUS = 'LOCKED' AND ENABLED = 1 "; $results = $dbObj->run_query($dbObj->db_get_contentDB(), $query); if ($results == false) { debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because of database update error"); return false; } // add release record $query = "INSERT INTO CONTENT_LOCK (LOCKED_UID, ENTITY_TYPE, ENABLED, LOCK_STATUS, USER_ID, CREATION_DATE) VALUES (" . $UID . ", '" . $entity_type . "', 1, 'UNLOCKED', " . $user . ",'" . date("Y-m-d H:i:s") . "')"; return $dbObj->run_query($dbObj->db_get_contentDB(), $query) == true; }
/** * returns list of terms that are related to object * @param {array} $object_UID array of type array("column_name"=>'DELIVERY_BASE_ID', "value"=>5) * @param {string} $link_type The link type * @param {string} $tableName Table name of the relation which depends on object type, e.g. R_LD2T, R_LK2T. * @param {string} $lang The required language, if no language is selected all languages will be returned * @return {array:terms} array of terms */ public static function get_related_Kbits($Delivery_UID, $user) { $NEEDED = array(); $PROVIDED = array(); $OTHERS = array(); // get database name if (Lock::is_locked_by_user($Delivery_UID, 'DELIVERY_BASE', $user) == true) { $database_name = dbAPI::get_db_name('user'); } else { $database_name = dbAPI::get_db_name('content'); } $dbObj = new dbAPI(); // get all needed and provide Kbits (as relation objects) $query = "SELECT * FROM R_LD2K where ENABLED = 1 AND (DELIVERY_BASE_ID = " . $Delivery_UID . ")"; $results = $dbObj->db_select_query($database_name, $query); for ($i = 0; $i < count($results); $i++) { $curr_Kbit = Kbit::get_Kbit_details($results[$i]["KBIT_BASE_ID"], $user); if ($results[$i]["LINK_TYPE"] == 'NEEDED') { array_push($NEEDED, $curr_Kbit); } else { if ($results[$i]["LINK_TYPE"] == 'PROVIDED') { array_push($PROVIDED, $curr_Kbit); } else { array_push($OTHERS, $curr_Kbit); } } } $kbits = array("NEEDED" => $NEEDED, "PROVIDED" => $PROVIDED, "OTHERS" => $OTHERS); return $kbits; }
public static function remove_Kbit_from_delivery($Kbit_UID, $Delivery_UID, $link_type, $user) { if (Lock::is_locked_by_user($Delivery_UID, 'DELIVERY_BASE', $user) == false) { debugLog::log("<i>[delivery.php:remove_term_from_Delivery]</i> Delivery (" . $Delivery_UID . ") is not locked by the user (" . $user . ")"); return null; } $locking_user = Lock::get_locking_user($UID, 'KBIT_BASE'); if ($locking_user != null && $locking_user["UID"] != $user) { debugLog::log("<i>[delivery.php:add_Kbit_to_delivery]</i> Kbit(" . $Kbit_UID . ") is locked by other user(" . $locking_user["UID"] . ")"); return null; } return D2KRelation::remove_D2K_relation($Kbit_UID, $Delivery_UID, $link_type, 'user'); }
public static function remove_term_from_Kbit($Kbit_UID, $term_UID, $link_type, $user) { if (Lock::is_locked_by_user($Kbit_UID, 'KBIT_BASE', $user) == false) { debugLog::log("<i>[Kbits.php:remove_term_from_Kbit]</i> Kbit (" . $Kbit_UID . ") is not locked by the user (" . $user . ")"); return false; } O2TRelation::remove_O2T_relation(array("column_name" => 'KBIT_BASE_ID', "value" => $Kbit_UID), $term_UID, $link_type, 'R_LK2T', 'user'); return true; }