- function delid($_id, $write=true)
- {
- if (isset($this->overview[$_id])) {
- if (sizeof($this->overview[$_id]->parent)) {
- $this->overview[$this->overview[$_id]->parent]->children =
- array_diff($this->overview[$this->overview[$_id]->parent]->children, array($_id));
- if (sizeof($this->overview[$_id]->children)) {
- $this->overview[$this->overview[$_id]->parent]->children =
- array_merge($this->overview[$this->overview[$_id]->parent]->children, $this->overview[$_id]->children);
- foreach ($this->overview[$_id]->children as $c) {
- $this->overview[$c]->parent = $this->overview[$_id]->parent;
- $this->overview[$c]->parent_direct = false;
- }
- }
- $p = $this->overview[$_id]->parent;
- while ($p) {
- $this->overview[$p]->desc--;
- $p = $this->overview[$p]->parent;
+ $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)) {
+ $time = time();
+ foreach ($parent->children as $key=>&$child) {
+ if ($child === $overview) {
+ unset($parent->children[$key]);
+ break;