/** * Counts ExObject stored for the object * * @param CMbObject $object The object to count the ExObjects for * * @return CExObject[][] The list, with ExClass IDs as key and counts as value */ static function loadExObjectsFor(CMbObject $object) { $group_id = CGroups::loadCurrent()->_id; $where = array("group_id = '{$group_id}' OR group_id IS NULL"); $ex_class = new CExClass(); $ex_class_ids = $ex_class->loadIds($where, "name"); $ds = $ex_class->_spec->ds; $where = array("object_class" => $ds->prepare("= %", $object->_class), "object_id" => $ds->prepare("= %", $object->_id)); $ex_objects = array(); foreach ($ex_class_ids as $_ex_class_id) { $_ex_object = new CExObject($_ex_class_id); if ($_ex_object->countList($where) == 0) { continue; } $_list = $_ex_object->loadList($where); if (count($_list) > 0) { foreach ($_list as $_ex_object) { $_ex_object->_ex_class_id = $_ex_class_id; $_ex_object->load(); } $ex_objects[$_ex_class_id] = $_list; } } return $ex_objects; }