#$paginationHtml .= "pages at all: $numPages <br>"; #echo "pagelink:".$tmpl["pagelink"]; for ($page = 0; $page < $numPages; $page++) { #echo "page $page <br>"; $pageParams = array("link" => tkMakeURL("page=" . ($page + 1), $confStripQueryVars), "title" => $page + 1, "special" => $curPage == $page ? " currentPage" : ""); $paginationLinksHtml .= tkMakeHtml($tmpl["pagelink"], $pageParams); } $params = array("pagelink" => $paginationLinksHtml); $paginationHtml = tkMakeHtml($tmpl["pagination"], $params); /*$nextO = $offset + $tkThreadsPerPage; $prevO = $offset - $tkThreadsPerPage; $pageParams = Array( "nextOffset"=>tkMakeURL( "offset=".( $nextO <= $thread->numTotalElements ? $nextO : $thread->numTotalElements ), $confStripQueryVars ), "lastOffset"=>tkMakeURL( "offset=".( $prevO < 0 ? 0 : $prevO ), $confStripQueryVars ) ); if( $offset + $tkThreadsPerPage < $thread->numTotalElements ) $forwardHtml = tkMakeHtml( $tmpl["forwardlink"], $pageParams ); if( $offset > 0 ) $newerHtml = tkMakeHtml( $tmpl["newerlink"], $pageParams );*/ // Form the body $params = array("list" => $listHtml, "title" => $ln_overview, "newCount" => $countHtml, "message" => $msgHtml, "currentFilter" => $filterHtml, "filterchoice" => $tmplFilterChoice, "newlinkcon" => $linkHtml, "pagination" => $paginationHtml, "mailhint" => $mailHtml); $html = tkMakeHtml($tmpl["body"], $params); echo $html; } // remote } } } } } } } #$curdir = chdir( $$bckdir );
function sendNotify($cause, $type) { global $tmpl, $tkConfBotMail, $tkConfSysName, $ln_eNotify_titles, $tkUser; // Get all users who need to be identified $users = array(); // First option - all users who subscribed to the current thread /*if( $type == "_subscribers" )#$this->checkFrontidExistance( $type ) ) { // Get the ids of the users who described to this thread $sql = " SELECT id, userid, email_last_notify FROM ".PRFX."threads_marks WHERE threadid='".$this->dataRaw["id"]."' AND email_notification LIKE '%".$cause."%' ;"; $res = $this->query( $sql ); while( $row = $this->assoc( $res ) ) { // don't spam the users if( time() > $row["email_last_notify"] + 60 * 60 * 24 * 7 ) // maximum is: once a week $users[] = $row["userid"]; } } // Second Option - all users, who want to be notified when there is a new thread else if( $type == "_new" ) { global $confEmailNotifyUsers; $users = $confEmailNotifyUsers; }*/ // add the Global Subscription Users #$users = Array(); // We are just notifying users who want it. $users = globGetUsers(); #foreach ( $globUser as $userid ) #{ # if( !in_array( $userid, $users ) ) # $users[] = $userid; #} // Give the users for debug reasons #var_dump( $users ); /*foreach( $users as $userid ) { echo "-------------<br />"; $user = tkCbGetUserById( $userid ); echo $user["name"]; echo " -".$user["email"]."-<br />"; } exit;*/ // Now it's time to notify the users foreach ($users as $userid) { // get the details for each user $user = tkCbGetUserById($userid); // check the users mail if (!validateMail($user["email"])) { tkLog("bad mail for user \"" . $user["name"] . "\": " . $user["email"]); continue; } // Is the user even allowed to view this thread? if (tkCheckTags("viewAll", $userid) || tkCheckTags("viewOwn", $userid) && $this->dataRaw["author"] == $userid) { $access = true; } else { continue; } // only send the mail, if the user checked the rhead since last mail // (meaning, if the email_last_notify column in threads_marks != 0, then no mail) $marks = $this->getMarks($user["id"]); if ($marks["email_last_notify"] > 0) { continue; } #marker3 // send a notification mail switch ($cause) { case "onComment": $eTmpl = $tmpl["email:newComment"]; #$content = $this->posts["create"]->handleField( "text", $this->posts["create"]->dataRaw["text"] ); $content = $this->posts["create"]->dataRaw["text"]; $author = $this->posts["create"]->handleField("author", $this->posts["create"]->dataRaw["author"]); break; case "onStatusChange": $eTmpl = $tmpl["email:statusChange"]; break; case "onNew": $eTmpl = $tmpl["email:newThread"]; $content = $this->posts["create"]->dataRaw["text"]; $author = $this->handleField("author", $this->dataRaw["author"]); break; default: tkSendError("System Error: unkown notify status"); break; } $htmlContent = $this->posts["create"]->handleField("text", $content); $lastCheckOnThread = $this->getLastCheck($tkUser["id"], $dataRaw["id"]); $unreadPosts = 0; $allPosts = 0; // First unread post foreach ($this->posts as $post) { if ($post->dataRaw["build"] > $lastCheckOnThread) { if (!isset($firstUnreadPost)) { $firstUnreadPost = $post->dataRaw["id"]; } $unreadPosts++; } $allPosts++; } $subjval = $this->handleField("subject", $this->dataRaw["subject"]); $subject = $ln_eNotify_titles[$cause] . ': \'' . $subjval . '\''; global $tkConfPath; // No Br in Mails #$text = $content; #$text = str_replace( "\n", "<br />", $text ); #$text = stripslashes( $text ); #$content = $text; $params = array("username" => $user["name"], "author" => $author, "subject" => $subjval, "status" => $this->dataRaw["status"], "content" => $htmlContent, "link" => $tkConfPath . "index.php?id=" . $this->dataRaw["frontid"] . "&p=" . $firstUnreadPost . "#comment" . $firstUnreadPost, "frontid" => $this->dataRaw["frontid"]); #$message = $tkConfNotMailTmpl; $message = tkMakeHtml($eTmpl, $params); /*$headers = 'From: KG-Ticket-Notify <'.$tkConfBotMail . ">\r\n" . 'Reply-To: KG-Ticket-Notify <'.$tkConfBotMail . ">\r\n" . "MIME-Version: 1.0" . "\r\n"; "Content-type: text/html; charset=ISO-8859-1" ; "\n\n" ; $trans_table = array ( 'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue' ); $subject = str_replace( array_keys( $trans_table), $trans_table, $subject );*/ // don't notify the user himself if ($user["id"] != $tkUser["id"]) { // Send the notification mail #die( $htmlContent ); mailLog($user["email"], $user["name"], $subject, $message, $headers); #echo $user["name"]; #$x = mail( $to, $subject, $message, $headers ); #sendMail( $subject, $message, $user["email"], $user["name"], "Dies ist eine HTML-Email...man kann sie nur mit einem HTML-Email-View ansehen..." ); #die( "stop" ); #echo "sendmail"; /*echo "<pre>"."Send Mail To: $to; Subject: $subject; Message: $message"."</pre>";*/ #exit; } // prevent spam ( also at creation of ticket ) $sql = "\n UPDATE \n " . PRFX . "threads_marks\n SET\n email_last_notify='" . time() . "'\n WHERE\n threadid='" . $this->dataRaw["id"] . "' AND\n userid='" . $user["id"] . "'\n ;"; $this->query($sql); } // Send all Mails in the background #> /dev/null & system("php includes/sendmails.php > includes/maillog &", $ret); // attention, works only with Linux! #echo $ret; #die("stop"); return 0; #exit; }