function check_for_subscribed_members()
 {
     global $awc_tables;
     $email_adds = array();
     // this can be set in a HOOK to false to create your own user-email list
     if ($this->email_lookup) {
         $rDB = wfGetDB(DB_SLAVE);
         $wiki_user = $rDB->tableName('user');
         if ($this->forum_or_thread == 'thread') {
             $sql = "SELECT wu.user_email, t.wtcht_mem_id FROM {$awc_tables['awc_f_watchthreads']} t\n                        JOIN {$wiki_user} wu\n                            ON t.wtcht_mem_id=wu.user_id\n                        WHERE t.wtcht_thread_id={$this->tID} AND t.wtcht_sent=0 AND t.wtcht_todo= 'email'";
         } else {
             $sql = "SELECT wu.user_email, f.wtchf_mem_id FROM {$awc_tables['awc_f_watchforums']} f\n                        JOIN {$wiki_user} wu\n                            ON f.wtchf_mem_id=wu.user_id\n                        WHERE f.wtchf_forum_id={$this->fID} AND f.wtchf_sent=0";
         }
         $res = $rDB->query($sql);
         while ($r = $rDB->fetchObject($res)) {
             if ($this->forum_or_thread == 'thread') {
                 if ($this->cur_memID != $r->wtcht_mem_id) {
                     // "safe" check
                     if ($r->user_email != '') {
                         $email_adds[] = $r->user_email;
                     }
                 }
             } else {
                 if ($this->cur_memID != $r->wtchf_mem_id) {
                     // "safe" check
                     if ($r->user_email != '') {
                         $email_adds[] = $r->user_email;
                     }
                 }
             }
         }
     }
     wfRunHooks('awcsforum_subscribe_get_email_address', array(&$email_adds, &$this));
     // 2.5.5
     if (!empty($email_adds)) {
         require_once awc_dir . 'send_mail.php';
         if ($this->forum_or_thread == "thread") {
             $send_title = get_awcsforum_word('word_email_newreplieswaitingtitle') . ' ' . $this->title;
             $send_body = get_awcsforum_word('word_email_newreplieswaiting');
             $send_body .= " \n" . $this->title;
             $send_body .= " \n\n <a href='" . awc_url . "st/id" . $this->tID . "'>" . awc_url . "st/id" . $this->tID . "</a><br /><br />";
             if ($this->cf_send_post_body_in_email == '1') {
                 $send_body .= " \n" . awcsforum_mailer::check_msg_len($this->post, $this->post_text_limit);
             }
         } else {
             $send_title = get_awcsforum_word('word_email_newreplieswaitingtitle_forum') . ' ' . $this->title;
             $send_body = get_awcsforum_word('word_email_newreplieswaiting_forum');
             $send_body .= " \n" . $this->title;
             $send_body .= " \n\n <a href='" . awc_url . "sf/id" . $this->fID . "'>" . awc_url . "sf/id" . $this->fID . "</a><br /><br />";
             if ($this->cf_send_thread_body_in_email == '1') {
                 $send_body .= " \n" . awcsforum_mailer::check_msg_len($this->post, $this->thread_text_limit);
             }
         }
         $html = true;
         if ($this->send_email_html == '0') {
             $html = false;
         }
         awcsforum_mailer::send_mail($email_adds, $send_title, $send_body, $html);
         if ($this->forum_or_thread == 'thread') {
             $this->wDB->update('awc_f_watchthreads', array('wtcht_sent' => '1'), array('wtcht_thread_id' => $this->tID, 'wtcht_sent' => '0'), '');
         } else {
             $this->wDB->update('awc_f_watchforums', array('wtchf_sent' => '1'), array('wtchf_forum_id' => $this->fID, 'wtchf_sent' => '0'), '');
         }
     }
     if ($this->subscribe != 'no' and $this->forum_or_thread != "thread") {
         self::subscribe_to_thread();
         self::update_mem_thread();
     }
 }
Beispiel #2
0
 function sendpm($to_name, $title, $msg, $save_sent = false, $sendto_names = null)
 {
     global $wgUser, $wgOut, $wgPasswordSender, $IP, $awc_tables, $awcs_forum_config;
     // awcsforum_funcs::get_page_lang(array('lang_txt_mem'));
     /* 
     
     if ( !file_exists($IP . '/includes/AutoLoader.php')){
         require($IP . "/includes/UserMailer.php");
     }
     */
     $sender_name = $wgUser->mName;
     $sender_id = $wgUser->mId;
     $send_msg_text = false;
     if (isset($awcs_forum_config->cf_send_pm_body_in_email) and $awcs_forum_config->cf_send_pm_body_in_email == '1') {
         $send_msg_text = true;
     }
     $user_get = array();
     $user_get[] = 'm_id';
     $dbw = wfGetDB(DB_MASTER);
     $date_seperated = $dbw->timestamp();
     $pm_count = null;
     $to_address = array();
     /* set up email stuff here so its not included in the loop */
     $send_title = get_awcsforum_word('mem_pm_email_newpmawaiting') . ' ' . $title;
     $send_body = get_awcsforum_word('mem_pm_email_newpmawaitingbody');
     $send_body .= " \n" . $sender_name;
     $send_body .= " \n\n <a href='" . awcsforum_funcs::awcforum_url('member_options/pminbox') . "'>" . awcsforum_funcs::awcforum_url('member_options/pminbox') . "</a> \n\r\n\r";
     require_once awc_dir . 'send_mail.php';
     $html = true;
     if ($awcs_forum_config->cf_send_email_html == '0') {
         $html = false;
     }
     foreach ($to_name as $id => $send_to_info) {
         $pm_count++;
         if ($pm_count == 1) {
             #$bs = $dbw->nextSequenceValue( 'awc_f_pms_pm_id_seq' );
             $dbw->insert('awc_f_pms', array('pm_title' => $title, 'pm_text' => $msg));
             $pm_id = awcsforum_funcs::lastID($dbw, 'awc_f_pms', 'pm_id');
         }
         $dbw->insert('awc_f_pms_info', array('pmi_pmid' => $pm_id, 'pmi_sender' => $sender_name, 'pmi_sender_id' => $sender_id, 'pmi_receipt_id' => $send_to_info['id'], 'pmi_receipt' => $sendto_names, 'pmi_send_date' => $date_seperated));
         # $mem = GetMemInfo($id, $user_get);
         # if(isset($mem['name'])){
         # awc_pdie($wgUser->mId);
         if ($send_to_info['forum_username'] != 'no_name' or $send_to_info['id'] == $wgUser->mId) {
             $dbw->query("UPDATE {$awc_tables['awc_f_mems']} \n                                    SET m_pmtotal = m_pmtotal + 1,\n                                    m_pmunread = m_pmunread + 1, \n                                    m_pminbox = m_pminbox + 1,\n                                    m_pmpop = '1'\n                                    WHERE m_id =" . $send_to_info['id']);
         } else {
             $dbw->insert('awc_f_mems', array('m_id' => $send_to_info['id'], 'm_idname' => $send_to_info['name'], 'm_pmtotal' => '1', 'm_pmunread' => '1', 'm_pminbox' => '1', 'm_pmpop' => '1'));
         }
         /* @changeVer 2.5.8 */
         if (isset($send_to_info['email']) && !empty($send_to_info['email']) && $send_to_info['email'] != 'no_email') {
             $to_address[] = new MailAddress($send_to_info['email']);
             if ($send_to_info['pass_pm_text'] == '1' and $send_msg_text) {
                 $send_body .= "\n\r\n\r" . awcsforum_mailer::check_msg_len($msg, 0);
             }
             awcsforum_mailer::send_mail($to_address, $send_title, $send_body, $html);
         }
     }
     if ($save_sent) {
         $dbw->insert('awc_f_pms_info', array('pmi_pmid' => $pm_id, 'pmi_sender' => $sender_name, 'pmi_sender_id' => $sender_id, 'pmi_receipt_id' => $sender_id, 'pmi_receipt' => $sendto_names, 'pmi_send_date' => $date_seperated, 'pmi_folder_id' => '1', 'pmi_read_date' => $date_seperated, 'pmi_read' => '1'));
         $mem = GetMemInfo($id, $user_get);
         if (isset($mem['name'])) {
             $dbw->query("UPDATE {$awc_tables['awc_f_mems']} \n                                    SET m_pmtotal = m_pmtotal + 1,\n                                    m_pmsent = m_pmsent + 1\n                                    WHERE m_id =" . $sender_id);
         } else {
             $dbw->insert('awc_f_mems', array('m_id' => $sender_id, 'm_idname' => $wgUser->mName, 'm_pmtotal' => '1', 'm_pmsent' => '1'));
         }
     }
     $wgOut->redirect(awc_url . 'member_options/pminbox');
 }