public function queue_mails($args)
 {
     $cid = (int) $args['cid'];
     $tid = (int) $args['tid'];
     $pid = (int) $args['pid'];
     $type = $args['type'];
     if ($type == 'new_topic') {
         $subject = \CODOF\Util::get_opt('topic_notify_subject');
         $message = \CODOF\Util::get_opt('topic_notify_message');
     } else {
         $subject = \CODOF\Util::get_opt('post_notify_subject');
         $message = \CODOF\Util::get_opt('post_notify_message');
     }
     $mail = new \CODOF\Forum\Notification\Mail();
     $me = CODOF\User\User::get();
     $mails = array();
     $offset = 0;
     while ($data = $this->getData($cid, $tid, $pid, $offset)) {
         foreach ($data as $info) {
             //do not send email to the user making the post
             if ($me->id == $info['id'] || $info['mail'] == null) {
                 continue;
             }
             $user = array("id" => $me->id, "username" => $me->username);
             $post = array("omessage" => $info['omessage'], "imessage" => $info['imessage'], "url" => \CODOF\Forum\Forum::getPostURL($tid, $info['title'], $pid), "id" => $info['id'], "username" => $info['username'], "title" => $info['title'], "category" => $info['cat_name']);
             $mail->user = $user;
             $mail->post = $post;
             $mails[] = array("to_address" => $info['mail'], "mail_subject" => html_entity_decode($mail->replace_tokens($subject), ENT_NOQUOTES, "UTF-8"), "body" => html_entity_decode($mail->replace_tokens($message), ENT_QUOTES, "UTF-8"));
         }
         \DB::table(PREFIX . 'codo_mail_queue')->insert($mails);
         $offset += 400;
     }
 }
function smarty_function_print_post_url($option)
{
    if (isset($option['pid'])) {
        echo \CODOF\Forum\Forum::getPostURL($option['tid'], $option['title'], $option['pid']);
    } else {
        echo \CODOF\Forum\Forum::getPostURL($option['tid'], $option['title']);
    }
}