Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Reviews: добавить функцию вывода последних отзывов #321
Browse files Browse the repository at this point in the history
  • Loading branch information
devkont committed Apr 13, 2017
1 parent dd039d6 commit 19a4eed
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
60 changes: 59 additions & 1 deletion plugins/reviews/inc/reviews.functions.php
Expand Up @@ -230,4 +230,62 @@ function cot_reviews_list($userid, $area, $code='', $name='', $params='', $tail=
}
return '';
}
?>

/**
* Вывод последних отзывов
*
* @param int $count Количество отзывов
* @return string
*/
function cot_reviews_last($count = 0)
{
global $db_reviews, $db_users, $db, $L, $usr, $cfg;
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', 'reviews', 'RWA');
if ($usr['auth_read'])
{
$t1 = new XTemplate(cot_tplfile(array('reviews', 'last'), 'plug'));

require_once cot_langfile('reviews', 'plug');

if($count > 0) $limit = "LIMIT $count";

$sql = $db->query("SELECT * FROM $db_reviews as r
LEFT JOIN $db_users as u ON u.user_id=r.item_userid
ORDER BY item_date ASC $limit");

while ($item = $sql->fetch())
{
$t1->assign(cot_generate_usertags($item, 'REVIEW_ROW_OWNER_'));
$t1->assign(cot_generate_usertags($item['item_touserid'], 'REVIEW_ROW_TO_'));
$t1->assign(array(
'REVIEW_ROW_ID' => $item['item_id'],
'REVIEW_ROW_TEXT' => $item['item_text'],
'REVIEW_ROW_SCORE' => ($item['item_score'] > 0) ? '+' . $item['item_score'] : $item['item_score'],
'REVIEW_ROW_AREA' => $item['item_area'],
'REVIEW_ROW_CODE' => $item['item_code'],
'REVIEW_ROW_DATE' => $item['item_date'],
));

if($item['item_area'] == 'projects' && !empty($item['item_code']))
{
require_once cot_incfile('projects', 'module');
global $db_projects;

$prj = $db->query("SELECT * FROM $db_projects WHERE item_id=".$item['item_code'])->fetch();
$t1->assign(cot_generate_projecttags($prj, 'REVIEW_ROW_PRJ_'));
}

/* === Hook === */
foreach (cot_getextplugins('reviews.list.loop') as $pl)
{
include $pl;
}
/* ===== */

$t1->parse('MAIN.REVIEW_ROW');
}
$t1->parse('MAIN');
return $t1->text('MAIN');
}
return '';
}
4 changes: 2 additions & 2 deletions plugins/reviews/reviews.setup.php
Expand Up @@ -4,7 +4,7 @@
Code=reviews
Name=Reviews
Description=Отзывы о человеке
Version=2.2.2
Version=2.2.3
Date=24.11.2012
Author=CMSWorks Team
Copyright=Copyright © CMSWorks.ru, littledev.ru
Expand All @@ -29,7 +29,7 @@
* Reviews plugin
*
* @package reviews
* @version 2.2.2
* @version 2.2.3
* @author CMSWorks Team
* @copyright Copyright (c) CMSWorks.ru, littledev.ru
* @license BSD
Expand Down
19 changes: 19 additions & 0 deletions plugins/reviews/tpl/reviews.last.tpl
@@ -0,0 +1,19 @@
<!-- BEGIN: MAIN -->
<div class="reviews">
<!-- BEGIN: REVIEW_ROW -->
<div class="row">
<div class="span1">{REVIEW_ROW_OWNER_AVATAR}</div>
<div class="span8">
<div class="pull-right score">{REVIEW_ROW_SCORE}</div>
<div class="owner">{REVIEW_ROW_OWNER_NAME} &rarr; {REVIEW_ROW_TO_NAME}</div>
<!-- IF {REVIEW_ROW_AREA} == 'projects' -->
<p class="small">{PHP.L.reviews_reviewforproject}: <a href="{REVIEW_ROW_PRJ_URL}">{REVIEW_ROW_PRJ_SHORTTITLE}</a></p>
<!-- ENDIF -->
<p>{REVIEW_ROW_TEXT}</p>
<p class="small">{REVIEW_ROW_DATE|date('d.m.Y H:i', $this)}</p>
</div>
</div>
<hr/>
<!-- END: REVIEW_ROW -->
</div>
<!-- END: MAIN -->

0 comments on commit 19a4eed

Please sign in to comment.