public static function get_locking_user($UID, $entity_type) { $dbObj = new dbAPI(); $query = "SELECT usr.* FROM " . dbAPI::get_db_name('content') . ".CONTENT_LOCK AS lk INNER JOIN " . dbAPI::get_db_name('user') . ".USERS AS usr ON (usr.UID = lk.USER_ID) where lk.LOCKED_UID = '" . $UID . "' AND lk.ENTITY_TYPE = '" . $entity_type . "' AND lk.LOCK_STATUS = 'LOCKED' AND lk.ENABLED = 1 "; $results = $dbObj->db_select_query($dbObj->db_get_contentDB(), $query); if (count($results) > 0) { $usr = $results[0]; $usr["PASSWORD"] = '******'; return $usr; } return null; }
public static function get_terms_of_scope($scope_UID, $lang = '') { $terms = array(); // extract scope terms relations $dbObj = new dbAPI(); $query = "SELECT * FROM TERMS where ENABLED = 1 AND ( ID_SCOPE = " . $scope_UID . ")"; $terms_related = $dbObj->db_select_query($dbObj->db_get_contentDB(), $query); if ($terms_related == null) { return null; } // get terms details for ($i = 0; $i < count($terms_related); $i++) { $curr_term = term::get_term_by_UID_with_relations($terms_related[$i]["ID_TERM_STRING"], $lang); if ($curr_term != null) { array_push($terms, $curr_term); } } return $terms; }
/** * 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; }
/** * Returns the Delivery's base from user database * @param {int} $UID The UID of the requested Delivery * @return {DeliveryBase} the requested Delivery */ public static function get_edited_Delivery_by_UID($UID) { // returns the Delivery from user database $dbObj = new dbAPI(); $query = "SELECT * FROM DELIVERY_BASE where UID = '" . $UID . "' AND ENABLED = '1'"; $results = $dbObj->db_select_query($dbObj->db_get_usersDB(), $query); if (count($results) == 0) { return null; } return $results[0]; }
public static function validate_token($token) { $dbObj = new dbAPI(); $query = "SELECT * FROM users where TOKEN = '" . $token . "'"; $results = $dbObj->db_select_query($dbObj->db_get_usersDB(), $query); if (count($results) == 0) { return null; } $results[0]["PASSWORD"] = '******'; return $results[0]; }
public static function get_scopes_of_term($term_UID, $lang = '') { $scopes = array(); // extract scope terms relations $dbObj = new dbAPI(); $query = "SELECT * FROM TERMS where ENABLED = 1 AND ( ID_TERM_STRING = " . $term_UID . ")"; $scopes_related = $dbObj->db_select_query($dbObj->db_get_contentDB(), $query); if ($scopes_related == null) { return null; } // get scopes and meanings details for ($i = 0; $i < count($scopes_related); $i++) { $curr_scope = scope::get_scope_by_UID($scopes_related[$i]["ID_SCOPE"], $lang); $curr_meaning = term::get_term_meaning_by_UID($scopes_related[$i]["ID_TERM_MEAN"], $lang); if ($curr_scope != null) { array_push($scopes, array('scope' => $curr_scope, 'meaning' => $curr_meaning)); } } return $scopes; }