62 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
63 $this->Link =
get_package(
'link' ,
'last' , __FILE__ );
64 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
65 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
66 $this->UserAlgorithms =
get_package(
'user::user_algorithms' ,
'last' , __FILE__ );
116 $MasterId = $this->Security->get( $MasterId ,
'integer' );
117 $MasterType = $this->Security->get( $MasterType ,
'command' );
119 $Links = $this->Link->get_links( $MasterId ,
false , $MasterType , $ObjectType );
120 if( isset( $Links[ 0 ] ) )
124 if( $Access ===
false )
130 return( $Access->select_list( implode(
',' , $ids ) ) );
133 catch( Exception $e )
173 $MasterId = $this->Security->get( $MasterId ,
'integer' );
174 $MasterType = $this->Security->get( $MasterType ,
'command' );
178 return( isset( $ids[ 0 ] ) && $ids[ 0 ] );
180 catch( Exception $e )
228 $ObjectId = $this->Security->get( $ObjectId ,
'integer' );
229 $MasterType = $this->Security->get( $MasterType ,
'command' );
232 $Links = $this->Link->get_links(
false , $ObjectId , $MasterType , $ObjectType );
234 if( isset( $Links[ 0 ] ) )
239 if( $Access ===
false )
245 return( $Access->select_list( implode(
',' , $ids ) ) );
248 catch( Exception $e )
288 $ObjectId = $this->Security->get( $ObjectId ,
'integer' );
289 $MasterType = $this->Security->get( $MasterType ,
'command' );
293 return( isset( $ids[ 0 ] ) && $ids[ 0 ] );
295 catch( Exception $e )
331 $MasterType = $this->Security->get( $MasterType ,
'command' );
333 if( $MasterId ===
false && $MasterType ==
'user' )
335 $MasterId = $this->UserAlgorithms->get_id();
338 $MasterId = $this->Security->get( $MasterId ,
'integer' );
340 return( array( $MasterId , $MasterType ) );
342 catch( Exception $e )
395 $JoiningTableName , $FieldName2 , $Fields =
'*' )
399 if( isset( $Records[ 0 ] ) )
401 $LinkType = $this->LinkDictionary->get_link_type( $Object1Type , $Object2Type );
402 $Ids =
implode_ex(
',' , $Records , $FieldName1 );
403 $Fields =
"$Fields , umx_link.object1_id AS _record_original_id";
404 $Tables =
"$JoiningTableName , umx_link";
405 $JoinConditions =
"umx_link.type $LinkType AND umx_link.object1_id IN ( $Ids ) AND
406 umx_link.object2_id = $JoiningTableName".
".$FieldName2";
407 return( $this->Database->select( $Fields , $Tables , $JoinConditions ) );
414 catch( Exception $e )
463 $ExtendingFields , $Condition =
'1 = 1' )
467 if( isset( $Records[ 0 ] ) )
469 $Values = implode(
' , ' , array_unique(
get_field_ex( $Records , $FieldName1 ) ) );
470 $SubRecords = $this->Database->select(
471 "$FieldName2 AS _joining_field , $ExtendingFields" ,
"$JoiningTableName" ,
472 "$FieldName2 IN ( $Values ) AND ( $Condition )"
474 return( $SubRecords );
479 catch( Exception $e )
535 function join_data( &$Records , $Object1Type , $Object2Type , $FieldName1 ,
536 $FieldName2 , $JoiningTableName , $JoinName , $Fields =
'*' )
540 $SubRecords = $this->
get_sub_records( $Object1Type , $Object2Type , $Records , $FieldName1 ,
541 $JoiningTableName , $FieldName2 );
543 foreach( $Records as $k1 => $v1 )
545 set_field( $Records[ $k1 ] , $JoinName , array() );
546 foreach( $SubRecords as $k2 => $v2 )
557 catch( Exception $e )
610 $FieldName2 , $JoiningTableName , $JoinName , $Fields =
'*' , $Condition =
'1 = 1' )
615 $Records , $FieldName1 , $FieldName2 , $JoiningTableName , $Fields , $Condition
617 foreach( $Records as $k1 => $v1 )
619 foreach( $SubRecords as $k2 => $v2 )
623 if(
get_field( $Records[ $k1 ] , $JoinName ,
false ) !==
false )
625 throw(
new Exception(
"The field \"$JoinName\" was already set" ) );
633 catch( Exception $e )
686 $FieldName2 , $JoiningTableName , $JoinName , $Fields =
'*' , $Condition =
'1 = 1' )
691 $Records , $FieldName1 , $FieldName2 , $JoiningTableName , $Fields , $Condition
694 foreach( $Records as $k1 => $v1 )
696 set_field( $Records[ $k1 ] , $JoinName , array() );
697 foreach( $SubRecords as $k2 => $v2 )
708 catch( Exception $e )
756 function extend_records( &$Records , $FieldName1 , $FieldName2 , $JoiningTableName ,
757 $ExtendingFields , $Condition =
'1 = 1' )
762 $Records , $FieldName1 , $FieldName2 , $JoiningTableName ,
763 implode(
' , ' , $ExtendingFields ) , $Condition
766 foreach( $Records as $k1 => $v1 )
768 foreach( $SubRecords as $k2 => $v2 )
779 catch( Exception $e )