- if (isset($this->overview[$_id])) {
- $overview =& $this->overview[$_id];
- if (!$overview->isread) {
- $this->markAsRead($_id);
- }
- if ($overview->parent) {
- $p = $overview->parent;
- $parent =& $this->overview[$p];
- $parent->children = array_diff($parent->children, array($_id));
- if (sizeof($overview->children)) {
- $parent->children = array_merge($parent->children, $overview->children);
- foreach ($overview->children as $c) {
- $this->overview[$c]->parent = $p;
- $this->overview[$c]->parent_direct = false;
- }
- }
- while (isset($p)) {
- $this->overview[$p]->desc--;
- $p = $this->overview[$p]->parent;
- }
- } elseif ($overview->children) {
- foreach ($overview->children as $c) {
- $this->overview[$c]->parent = null;
+ if (!isset($this->overview[$_id])) {
+ return;
+ }
+
+ $overview =& $this->overview[$_id];
+ // Be sure it is not counted as unread
+ if (!$overview->isread) {
+ $this->markAsRead($_id);
+ }
+
+ $parent =& $overview->parent;
+
+ // Remove from the message tree
+ if (!is_null($parent)) {
+ foreach ($parent->children as $key=>&$child) {
+ if ($child === $overview) {
+ unset($parent->children[$key]);
+ break;