public static function add_relation_to_scope($parent_scope_UID, $child_scope_UID, $is_hier, $user) { // create relation between two terms if (refRelation::add_relation_to_object($parent_scope_UID, $child_scope_UID, $is_hier, $user, 'R_Ls2s') == null) { debugLog::log("parent scope (" . $parent_scope_UID . ") and child (" . $child_scope_UID . ") scope cannot be the same"); return null; } // return recently created relation return refRelation::get_objects_relation($parent_scope_UID, $child_scope_UID, 'R_Ls2s'); }
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} $database_name database name e.g. 'content', 'user' * @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_terms_of_object($object_UID, $database_name, $tableName, $lang = '') { // get database name $database_name = dbAPI::get_db_name($database_name); $dbObj = new dbAPI(); // get column name of object and its value (UID) to look for in table $object_column_name = $object_UID["column_name"]; $object_UID_value = $object_UID["value"]; if ($object_column_name == null || $object_column_name == '') { debugLog::log("<i>[relations.php:get_terms_of_object]</i> Column name was not specified."); return null; } // get all related terms to object $query = "SELECT * FROM " . $tableName . " where ENABLED = 1 AND (" . $object_column_name . " = " . $object_UID_value . ")"; $results = $dbObj->db_select_query($database_name, $query); // retrieve term's details from terms class into array $terms = array(); for ($i = 0; $i < count($results); $i++) { $curr_term = term::get_term_by_UID($results[$i]["TERM_ID"], $lang); // copy LINK_TYPE to term object $curr_term["LINK_TYPE"] = $results[$i]["LINK_TYPE"]; array_push($terms, $curr_term); } return $terms; }
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'); }
private static function create_new_token($username) { try { $token = users::generateRandomString(); $dbObj = new dbAPI(); $query = "UPDATE users SET TOKEN = '" . $token . "' where USERNAME = '******'"; $results = $dbObj->run_query($dbObj->db_get_usersDB(), $query); if ($results) { echo $results; return $token; } debugLog::debug_log("create token for user: "******" has failed"); return null; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } }
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; }
public static function po($object, $message) { debugLog::log('<b><u>' . $message . '</u></b>: ' . dbAPI::print_json_s($object, 0)); }
public static function Error($var) { self::getInstance()->trace[] = debugLog::Log(array('Parameters' => func_get_args()), 'ERROR', debug_backtrace()); }
public function disable_revision($database_name, $table_name, $whereSttmnt) { $query = "UPDATE " . $table_name . " SET ENABLED = 0 WHERE " . $whereSttmnt . " "; $results = $this->run_query($database_name, $query); if ($results) { // on success return true; } debugLog::debug_log("[disable_revision]: could not disbale rivision. [query]: <br>" . $query . "<hr>"); return false; }