Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 public static function get_Kbit_details($UID, $user)
 {
     if (Lock::is_locked_by_user($UID, 'KBIT_BASE', $user)) {
         $kbit = Kbit::get_edited_kbit_by_UID($UID);
     } else {
         $kbit = Kbit::get_kbit_by_UID($UID);
     }
     // get locking user
     $locking_user = Lock::get_locking_user($UID, 'KBIT_BASE');
     if ($locking_user != null) {
         $kbit["LOCKING_USER"] = $locking_user;
     }
     return $kbit;
 }