function create($text, $persons, $groups) { $data['text'] = $text; $data['text_slashes'] = addslashes($text); $data['created'] = date('Y-m-d H:i:s'); $data['author_first_name'] = $_SESSION['first_name']; $data['author_last_name'] = $_SESSION['last_name']; foreach ($groups as $id => $name) { $group = new group($id); foreach ($group->members as $i => $member) { $persons[$member['member_id']] = $member; } } foreach ($persons as $id => $arr) { $person = new person(); $person->load($id); $persons[$id] = $person->data; } $this->to = $persons; $this->set_data($data); } function insert() { global $db; $query = 'messages (author, created, text) values ( "' . $_SESSION['userid'] . '", now(), "' . $this->data['text_slashes'] . '" )'; $db->insert($query); $message_id = $db->insert_id; $author = new person();