Пример #1
0
 function sent_notification(MM_Message_Model $model)
 {
     //send message
     $setting = new MM_Setting_Model();
     $setting->load();
     $link = add_query_arg('message_id', $model->id, get_permalink(mmg()->setting()->inbox_page));
     $data = array('SITE_NAME' => get_bloginfo('name'), 'FROM_NAME' => $model->get_name($model->send_from), 'POST_LINK' => $link, 'FROM_MESSAGE' => $model->content);
     $data = apply_filters('message_notification_params', $data, $this);
     $subject = stripslashes($setting->noti_subject);
     $content = stripslashes($setting->noti_content);
     foreach ($data as $key => $val) {
         $subject = str_replace($key, $val, $subject);
         $content = str_replace($key, $val, $content);
     }
     $sendto = get_userdata($model->send_to);
     $from = get_userdata($model->send_from);
     //prepare atachments
     $attachments = array();
     if ($model->attachment) {
         $ids = explode(',', $model->attachment);
         $ids = array_filter($ids);
         foreach ($ids as $id) {
             if (filter_var($id, FILTER_VALIDATE_INT)) {
                 $upload = IG_Uploader_Model::model()->find($id);
                 if (is_object($upload) && $upload->file) {
                     $attachments[] = get_attached_file($upload->file);
                 }
             }
         }
     }
     $headers = array('From: ' . $model->get_name($model->send_from) . ' <' . $from->user_email . '>', 'Content-Type: text/html; charset=UTF-8');
     wp_mail($sendto->user_email, $subject, $content, $headers, $attachments);
 }
Пример #2
0
 function index_new_message(MM_Message_Model $model)
 {
     $key = "mm_notification";
     delete_user_meta($model->send_to, $key);
     $cache = array();
     $cache['status'] = 1;
     //clean up messages
     $cache['messages'] = array();
     $unreads = MM_Conversation_Model::get_unread($model->send_to);
     $message = array('id' => $model->id, 'from' => $model->get_name($model->send_from), 'subject' => $model->subject, 'text' => mmg()->trim_text($model->content, 100));
     $cache['messages'][] = $message;
     $cache['count'] = count($unreads);
     add_user_meta($model->send_to, $key, $cache);
 }