BAOBAB
co_place_collection.class.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 CO_Config::require_extension_class('tco_collection.interface.php');
29 CO_Config::require_extension_class('co_place.class.php');
30 
31 /***************************************************************************************************************************/
36  use tCO_Collection; // These are the built-in collection methods.
37 
38  /***********************************************************************************************************************/
39  /***********************/
43  public function __construct( $in_db_object = NULL,
44  $in_db_result = NULL,
45  $in_owner_id = NULL,
46  $in_tags_array = NULL,
58  $in_longitude = NULL,
59  $in_latitude = NULL
60  ) {
61 
62  $this->_container = Array();
63 
64  parent::__construct($in_db_object, $in_db_result, $in_owner_id, $in_tags_array, $in_longitude, $in_latitude);
65  $this->class_description = "This is a 'Place Collection' Class for Addresses.";
66 
67  $count = 0;
68  if (isset($this->context['children_ids']) && is_array($this->context['children_ids'])) {
69  $count = count($this->context['children_ids']);
70  }
71 
72  $this->instance_description = isset($this->name) && $this->name ? "$this->name ($this->_longitude, $this->_latitude - $count children objects)" : "($this->_longitude, $this->_latitude - $count children objects)";
73  }
74 
75  /***********************/
81  public function load_from_db( $in_db_result
82  ) {
83  $ret = parent::load_from_db($in_db_result);
84 
85  $count = 0;
86  if (isset($this->context['children_ids']) && is_array($this->context['children_ids'])) {
87  $count = count($this->context['children_ids']);
88  }
89 
90  $this->class_description = "This is a 'Place Collection' Class for Addresses.";
91  $this->instance_description = isset($this->name) && $this->name ? "$this->name ($this->_longitude, $this->_latitude - $count children objects)" : "($this->_longitude, $this->_latitude - $count children objects)";
92  }
93 
94  /***********************/
99  public function delete_from_db( $with_extreme_prejudice = false
100  ) {
101  if ($with_extreme_prejudice && $this->user_can_write()) {
102  // We don't error-check this on purpose, as it's a given that there might be issues, here. This is a "due dilligence" thing.
103  $user_items_to_delete = $this->children();
104 
105  foreach ($user_items_to_delete as $child) {
106  if ($child->user_can_write()) {
107  $child->delete_from_db();
108  }
109  }
110  }
111 
112  return parent::delete_from_db();
113  }
114 };