BAOBAB
co_us_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_us_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,
57  $in_longitude = NULL,
58  $in_latitude = NULL
59  ) {
60 
61  $this->_container = Array();
62 
63  parent::__construct($in_db_object, $in_db_result, $in_owner_id, $in_tags_array, $in_longitude, $in_latitude);
64  $this->class_description = "This is a 'Place Collection' Class for US Addresses.";
65  }
66 
67  /***********************/
73  public function load_from_db( $in_db_result
74  ) {
75  $ret = parent::load_from_db($in_db_result);
76 
77  $count = 0;
78  if (isset($this->context['children_ids']) && is_array($this->context['children_ids'])) {
79  $count = count($this->context['children_ids']);
80  }
81 
82  $this->class_description = "This is a 'Place Collection' Class for US Addresses.";
83  $this->instance_description = isset($this->name) && $this->name ? "$this->name ($this->_longitude, $this->_latitude - $count children objects)" : "($this->_longitude, $this->_latitude - $count children objects)";
84  }
85 
86  /***********************/
91  public function delete_from_db( $with_extreme_prejudice = false
92  ) {
93  if ($with_extreme_prejudice && $this->user_can_write()) {
94  // 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.
95  $user_items_to_delete = $this->children();
96 
97  foreach ($user_items_to_delete as $child) {
98  if ($child->user_can_write()) {
99  $child->delete_from_db();
100  }
101  }
102  }
103 
104  return parent::delete_from_db();
105  }
106 };