BAOBAB
tco_owner.interface.php
Go to the documentation of this file.
1 <?php
2 /***************************************************************************************************************************/
26 defined( 'LGV_DBF_CATCHER' ) or die ( 'Cannot Execute Directly' ); // Makes sure that this file is in the correct context.
27 
28 require_once(CO_Config::db_classes_class_dir().'/co_ll_location.class.php');
29 
30 /***************************************************************************************************************************/
36 trait tCO_Owner {
37  var $my_owner_id = NULL;
38  protected $_cached_ids = NULL;
39 
40  /***********************/
46  public function adopt_child( $in_object_to_own
47  ) {
48  $ret = false;
49 
50  $my_owner_id = intval($this->my_owner_id) ? intval($this->my_owner_id) : $this->id();
51  if ($in_object_to_own->owner_id() != $my_owner_id) {
52  if ($in_object->user_can_write()) {
53  $ret = $in_object->set_owner_id($my_owner_id);
54  } else {
58  }
59  }
60 
61  return $ret;
62  }
63 
64  /***********************/
70  public function count() {
71  $children_ids = $this->children_ids();
72  $my_count = isset($children_ids) && is_array($children_ids) ? count($children_ids) : 0;
73 
74  return $my_count;
75  }
76 
77  /***********************/
81  public function children_ids() {
82  if (!((isset($this->_cached_ids) && is_array($this->_cached_ids) && count($this->_cached_ids)))) {
83  $my_owner_id = intval($this->my_owner_id) ? intval($this->my_owner_id) : $this->id();
84  $this->_cached_ids = $this->get_access_object()->generic_search(Array('owner' => $my_owner_id), false, 0, 0, false, false, true);
85  }
86 
87  return $this->_cached_ids;
88  }
89 
90  /***********************/
96  public function children() {
97  $children_ids = $this->children_ids();
98  return $this->get_access_object()->get_multiple_data_records_by_id($children_ids);
99  }
100 
101  /***********************/
112  public function generic_search( $in_search_parameters = NULL,
130  $page_size = 0,
131  $initial_page = 0,
132  $and_writeable = false,
133  $count_only = false,
134  $ids_only = false
135  ) {
136  $my_owner_id = intval($this->my_owner_id) ? intval($this->my_owner_id) : $this->id();
137  $in_search_parameters['owner'] = $my_owner_id;
138  return $this->get_access_object()->generic_search($in_search_parameters, false, $page_size, $initial_page, $and_writeable, $count_only, $ids_only);
139 
140  return $ret;
141  }
142 }
adopt_child( $in_object_to_own)
generic_search( $in_search_parameters=NULL, $page_size=0, $initial_page=0, $and_writeable=false, $count_only=false, $ids_only=false)
static $co_owner_error_code_user_not_authorized
Definition: common.inc.php:61
static $co_owner_error_desc_user_not_authorized
Definition: en.php:46
static $co_owner_error_name_user_not_authorized
These apply to the Owner classes.
Definition: en.php:45
This class provides a general error report, with file, method and error information.
Definition: error.class.php:32