<?php

$rootpath = __DIR__ . '/../';
require_once __DIR__ . '/../lib/common.inc.php';
db_disconnect();
$commentsArr = powerTrailBase::getPowerTrailComments();
$ptOwners = powerTrailBase::getPtOwners($_REQUEST['projectId']);
$paginateCount = powerTrailBase::commentsPaginateCount;
foreach ($ptOwners as $owner) {
    $ownersIdArray[] = $owner['user_id'];
}
$nextSearchStart = $_REQUEST['start'] + $_REQUEST['limit'];
$db = \lib\Database\DataBaseSingleton::Instance();
$q = 'SELECT count(*) AS `count` FROM  `PowerTrail_comments` WHERE  `PowerTrailId` =:1 AND `deleted` = 0 ';
$db->multiVariableQuery($q, $_REQUEST['projectId']);
$count = $db->dbResultFetch();
$count = $count['count'];
$query = 'SELECT * FROM  `PowerTrail_comments`, `user` WHERE  `PowerTrailId` =:variable1 AND `deleted` = 0 AND `PowerTrail_comments`.`userId` = `user`.`user_id` ORDER BY  `logDateTime` DESC LIMIT :variable2 , :variable3   ';
$params['variable1']['value'] = (int) $_REQUEST['projectId'];
$params['variable1']['data_type'] = 'integer';
$params['variable2']['value'] = (int) $_REQUEST['start'];
$params['variable2']['data_type'] = 'integer';
$params['variable3']['value'] = (int) $_REQUEST['limit'];
$params['variable3']['data_type'] = 'integer';
$db->paramQuery($query, $params);
// multiVariableQuery($query, $projectId, 0, 8);
$result = $db->dbResultFetchAll();
// print_r($result);
if (count($result) == 0) {
    echo '<p><br /><br />' . tr('pt118') . '</p><br /><br />';
    exit;
Пример #2
0
 public static function emailOwners($ptId, $commentType, $commentDateTime, $commentText, $action, $commentOwnerId = false, $delReason = '')
 {
     /*ugly, but we need this values from common.inc.php*/
     global $watchlistMailfrom, $usr, $absolute_server_URI, $site_name, $siteDateFormat, $siteDateTimeFormat;
     $siteDateFormat = 'Y-m-d';
     $siteDateTimeFormat = 'Y-m-d H:i';
     $owners = powerTrailBase::getPtOwners($ptId);
     $commentTypes = powerTrailBase::getPowerTrailComments();
     $ptDbRow = powerTrailBase::getPtDbRow($ptId);
     //remove images
     $commentText = preg_replace("/<img[^>]+\\>/i", "", $commentText);
     $headers = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=UTF-8 ' . "\r\n";
     $headers .= "From: {$site_name} <" . $watchlistMailfrom . ">\r\n";
     $headers .= "Reply-To: " . $watchlistMailfrom . "\r\n";
     $mailbody = read_file(dirname(__FILE__) . '/commentEmail.html');
     switch ($action) {
         case 'delComment':
             $subject = tr('pt131') . ' ' . $ptDbRow['name'];
             $mailbody = mb_ereg_replace('{commentAction}', tr('pt132'), $mailbody);
             $mailbody = mb_ereg_replace('{actionDesc}', tr('pt131'), $mailbody);
             $mailbody = mb_ereg_replace('{delReason}', $delReason, $mailbody);
             $mailbody = mb_ereg_replace('{pt153}', tr('pt153'), $mailbody);
             break;
         case 'newComment':
             $subject = tr('pt128') . ' ' . $ptDbRow['name'];
             $mailbody = mb_ereg_replace('{commentAction}', tr('pt127'), $mailbody);
             $mailbody = mb_ereg_replace('{actionDesc}', tr('pt128'), $mailbody);
             $mailbody = mb_ereg_replace('{delReason}', '', $mailbody);
             $mailbody = mb_ereg_replace('{pt153}', '', $mailbody);
             break;
         case 'editComment':
             $subject = tr('pt146') . ' ' . $ptDbRow['name'];
             $mailbody = mb_ereg_replace('{commentAction}', tr('pt147'), $mailbody);
             $mailbody = mb_ereg_replace('{actionDesc}', tr('pt146'), $mailbody);
             $mailbody = mb_ereg_replace('{delReason}', '', $mailbody);
             $mailbody = mb_ereg_replace('{pt153}', '', $mailbody);
             break;
     }
     if (!isset($usr['userid'])) {
         $usr['userid'] = -1;
     }
     if (!isset($usr['username'])) {
         $usr['username'] = '******';
     }
     $mailbody = mb_ereg_replace('{runwatch14}', tr('runwatch14'), $mailbody);
     $mailbody = mb_ereg_replace('{commentDateTime}', date($siteDateTimeFormat, strtotime($commentDateTime)), $mailbody);
     $mailbody = mb_ereg_replace('{userId}', $usr['userid'], $mailbody);
     $mailbody = mb_ereg_replace('{userName}', $usr['username'], $mailbody);
     $mailbody = mb_ereg_replace('{absolute_server_URI}', $absolute_server_URI, $mailbody);
     if (isset($commentTypes[$commentType]['translate'])) {
         $mailbody = mb_ereg_replace('{commentType}', tr($commentTypes[$commentType]['translate']), $mailbody);
     } else {
         $mailbody = mb_ereg_replace('{commentType}', '&nbsp', $mailbody);
     }
     $mailbody = mb_ereg_replace('{ptName}', $ptDbRow['name'], $mailbody);
     $mailbody = mb_ereg_replace('{ptId}', $ptId, $mailbody);
     $mailbody = mb_ereg_replace('{pt133}', tr('pt133'), $mailbody);
     $mailbody = mb_ereg_replace('{pt134}', tr('pt134'), $mailbody);
     $mailbody = mb_ereg_replace('{commentText}', htmlspecialchars_decode(stripslashes($commentText)), $mailbody);
     $mailbody = mb_ereg_replace('{addingCommentDateTime}', date($siteDateTimeFormat), $mailbody);
     $doNotSendEmailToCommentAuthor = false;
     foreach ($owners as $owner) {
         $to = $owner['email'];
         if ($owner['power_trail_email'] == 1) {
             mb_send_mail($to, $subject, $mailbody, $headers);
         }
         if ($commentOwnerId && $commentOwnerId == $owner["user_id"]) {
             $doNotSendEmailToCommentAuthor = true;
         }
     }
     if ($commentOwnerId && !$doNotSendEmailToCommentAuthor) {
         $userDetails = powerTrailBase::getUserDetails($commentOwnerId);
         if ($userDetails['power_trail_email']) {
             mb_send_mail($userDetails['email'], $subject, $mailbody, $headers);
         }
     }
     //for debug only
     //mb_send_mail('*****@*****.**', $subject, $mailbody, $headers);
 }
Пример #3
0
function displayPtCommentsSelector($htmlid, \lib\Objects\PowerTrail\PowerTrail $powerTrail, $selectedId = 0, $usr = null)
{
    $cachesFoundByUser = $powerTrail->getFoundCachsByUser($usr['userid']);
    $percetDemand = $powerTrail->getPerccentRequired();
    $ptId = $powerTrail->getId();
    if ($powerTrail->getCacheCount() != 0) {
        $percentUserFound = round(count($cachesFoundByUser) * 100 / $powerTrail->getCacheCount(), 2);
    } else {
        $percentUserFound = 0;
    }
    $commentsArr = powerTrailBase::getPowerTrailComments();
    $ptOwners = powerTrailBase::getPtOwners($ptId);
    $selector = '<select id="' . $htmlid . '" name="' . $htmlid . '">';
    foreach ($commentsArr as $id => $type) {
        if ($id == 2) {
            if ($percentUserFound < $percetDemand || powerTrailBase::checkUserConquestedPt($_SESSION['user_id'], $ptId) > 0) {
                continue;
            }
            $selected = 'selected="selected"';
        }
        if (!isset($ptOwners[$usr['userid']]) && ($id == 3 || $id == 4 || $id == 5)) {
            continue;
        }
        if (!isset($selected)) {
            $selected = '';
        }
        if ($selectedId == $id) {
            $selected = 'selected';
        }
        $selector .= '<option value="' . $id . '" ' . $selected . '>' . tr($type['translate']) . '</option>';
        unset($selected);
    }
    $selector .= '</select>';
    return $selector;
}