BAOBAB
co_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 require_once(CO_Config::db_class_dir().'/co_main_db_record.class.php');
29 CO_Config::require_extension_class('tco_collection.interface.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
47  ) {
48 
49  $this->_container = Array();
50 
51  parent::__construct($in_db_object, $in_db_result, $in_owner_id, $in_tags_array);
52  $this->class_description = "This is a 'Generic Collection' Class.";
53  }
54 
55  /***********************/
61  public function load_from_db( $in_db_result
62  ) {
63  $ret = parent::load_from_db($in_db_result);
64 
65  if ($ret) {
66  $count = 0;
67  if (isset($this->context['children_ids']) && is_array($this->context['children_ids'])) {
68  $count = count($this->context['children_ids']);
69  }
70 
71  $this->class_description = "This is a 'Generic Collection' Class.";
72  $this->instance_description = isset($this->name) && $this->name ? "$this->name" : "Generic Collection Object";
73  }
74 
75  return $ret;
76  }
77 
78  /***********************/
83  public function delete_from_db( $with_extreme_prejudice = false
84  ) {
85  if ($with_extreme_prejudice && $this->user_can_write()) {
86  // 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.
87  $user_items_to_delete = $this->children();
88 
89  foreach ($user_items_to_delete as $child) {
90  if ($child->user_can_write()) {
91  $child->delete_from_db();
92  }
93  }
94  }
95 
96  return parent::delete_from_db();
97  }
98 };