Exemple #1
0
 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;
 }
Exemple #2
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;
 }
Exemple #3
0
 public static function disable_all_Delivery_info($UID, $destination = 'user')
 {
     $dbObj = new dbAPI();
     $destination = dbAPI::get_db_name($destination);
     // disable old records
     $dbObj->disable_revision('', $destination . ".DELIVERY_BASE ", ' UID = ' . $UID . ' ');
     // disable old front record
     $links_tables_names = array('DELIVERY_FRONT');
     for ($i = 0; $i < count($links_tables_names); $i++) {
         // disable old links records
         $dbObj->disable_revision('', $destination . "." . $links_tables_names[$i] . " ", ' UID = ' . $UID . ' ');
     }
     // loop over links and copy records from content to user
     $links_tables_names = Delivery::get_relations_tables_names();
     for ($i = 0; $i < count($links_tables_names); $i++) {
         // prepare where statement
         if ($links_tables_names[$i] == 'R_LD2D') {
             $where_sttmnt = ' (PARENT_ID = ' . $UID . ' OR CHILD_ID = ' . $UID . ') ';
         } else {
             $where_sttmnt = ' (DELIVERY_BASE_ID = ' . $UID . ') ';
         }
         // disable old links records
         $dbObj->disable_revision('', $destination . "." . $links_tables_names[$i] . " ", $where_sttmnt);
     }
     return true;
 }
Exemple #4
0
 public function get_latest_Rivision_ID($database_name, $table_name, $whereSttmnt = '')
 {
     $database_name = dbAPI::get_db_name($database_name);
     if ($whereSttmnt != '') {
         $whereSttmnt = ' WHERE ((' . $whereSttmnt . '))';
     }
     $query = 'SELECT MAX(REVISION) AS max_Riv FROM ' . $table_name . $whereSttmnt;
     $results = $this->db_select_query($database_name, $query);
     if (count($results) == 0) {
         return null;
     }
     return $results[0]["max_Riv"];
 }