Exemplo n.º 1
0
 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();
Exemplo n.º 2
0
 function mail($verbose = 0)
 {
     $timestamp = strtotime('+1 day');
     $this->date = date('Y-m-d', $timestamp);
     if (!$this->load_schedule()) {
         return false;
     }
     global $db;
     $select = "CONCAT(first_name,' ',last_name) as name, mail\r\n                   FROM person\r\n                   WHERE opt&32=32";
     $db->select($select);
     $recipients = $db->data;
     $mail = new mail();
     $subject_v['date'] = local_date($this->date);
     $subject = new tmpl('mail_subject.txt', $subject_v);
     $mail->set_subject($subject->fdata);
     $mail->data_main = $this->text;
     $output = '';
     foreach ($recipients as $i => $person) {
         $name = $person['name'];
         $mail->sendto($person['mail'], $name);
         if ($mail->sent) {
             $output .= '_';
         } else {
             $output .= 'X';
         }
     }
     if ($verbose) {
         echo $output;
     }
     return $output;
 }