示例#1
0
 /**
  * Relate object to object of the same type
  * @param {int} $parent_UID parent/first object UID
  * @param {int} $child_UID  child/second object UID
  * @param {bool} $is_hier    true if relation is parent/child false otherwise
  * @param {int} $user       the user id that is performing the operation
  * @param {string} $tableName  table name of the relation, e.g. R_LT2T, R_LS2S..
  * @return {refRelation} the relation that was just created
  */
 public static function add_relation_to_object($parent_UID, $child_UID, $is_hier, $user, $tableName, $database_name = 'content')
 {
     $database_name = dbAPI::get_db_name($database_name);
     if ($parent_UID == $child_UID) {
         debugLog::log("<i>[relations.php:add_relation_to_object]</i> parent " . $tableName . " (" . $parent_UID . ") and child (" . $child_UID . ") " . $tableName . " cannot be the same");
         return null;
     }
     // disable old relation
     refRelation::remove_relation($parent_UID, $child_UID, $tableName, $database_name);
     // get latest revision number
     $dbObj = new dbAPI();
     // where statement
     $where_sttmnt = " (PARENT_ID = " . $parent_UID . " AND CHILD_ID = " . $child_UID . ") OR (CHILD_ID = " . $parent_UID . " AND PARENT_ID = " . $child_UID . ")";
     $old_rel = $dbObj->get_latest_Rivision_ID($database_name, $tableName, $where_sttmnt);
     if ($old_rel == null) {
         $old_rel = 0;
     }
     // add new relation
     $query = "INSERT INTO " . $tableName . " (REVISION, HIER, PARENT_ID, CHILD_ID, ENABLED, USER_ID, CREATION_DATE) VALUES (" . ($old_rel + 1) . ", " . $is_hier . ", " . $parent_UID . ", " . $child_UID . ", 1, " . $user . ",'" . date("Y-m-d H:i:s") . "')";
     $dbObj->run_query($database_name, $query);
     // return recently created relation
     return refRelation::get_objects_relation($parent_UID, $child_UID, $tableName, $database_name);
 }
示例#2
0
 public static function get_D2D_relations($Delivery_UID, $user)
 {
     return refRelation::get_relations_of_object($Delivery_UID, 'R_LD2D', 'Delivery::get_Delivery_details', $user);
 }
示例#3
0
 public static function get_relations_of_term($term_UID, $lang = '')
 {
     return refRelation::get_relations_of_object($term_UID, 'R_Lt2t', 'term::get_term_by_UID', $lang);
 }
示例#4
0
 public static function get_K2K_relations($Kbit_UID, $user)
 {
     return refRelation::get_relations_of_object($Kbit_UID, 'R_LK2K', 'Kbit::get_Kbit_details', $user);
 }
示例#5
0
 public static function get_relations_of_scope($scope_UID)
 {
     return refRelation::get_relations_of_object($scope_UID, 'R_Ls2s', 'scope::get_scope_by_UID');
 }