Example #1
0
/**
 * Generates comments display for a given item
 *
 * @param string $link_area Target URL area for cot_url()
 * @param string $link_params Target URL params for cot_url()
 * @param string $ext_name Module or plugin code
 * @param string $code Item identifier
 * @param string $cat Item category code (optional)
 * @param array $row Database row entry (optional)
 * @return string Rendered HTML output for comments
 * @see cot_comments_count()
 * @global CotDB $db
 */
function cot_comments_link($link_area, $link_params, $ext_name, $code, $cat = '', $row = array())
{
    global $cfg, $db, $R, $L, $db_com;
    if (!cot_comments_enabled($ext_name, $cat, $code)) {
        return '';
    }
    $res = cot_rc('comments_link', array('url' => cot_url($link_area, $link_params, '#comments'), 'count' => $cfg['plugin']['comments']['countcomments'] ? cot_comments_count($ext_name, $code, $row) : ''));
    return $res;
}
Example #2
0
$id = (int) cot_import('id', 'G', 'INT');
$item = cot_import('item', 'G', 'TXT');
$cat = cot_import('cat', 'G', 'TXT');
$area = cot_import('area', 'G', 'ALP');
$out['subtitle'] = $L['comments_comments'];
// Get area/item/cat by id
if ($id > 0) {
    $res = $db->query("SELECT com_code, com_area FROM {$db_com} WHERE com_id = {$id}");
    if ($res->rowCount() == 1) {
        $row = $res->fetch();
        $area = $row['com_area'];
        $item = $row['com_code'];
    }
}
// Check if comments are enabled for specific category/item
cot_block(!empty($area) && !empty($item) && cot_comments_enabled($area, $cat, $item));
$cot_com_back = cot_import('cb', 'P', 'TXT');
if (!empty($cot_com_back)) {
    $cot_com_back = unserialize(base64_decode($cot_com_back));
} else {
    $cot_com_back = $_SESSION['cot_com_back'][$area][$cat][$item];
}
$url_area = $cot_com_back[0];
$url_params = $cot_com_back[1];
cot_block(!empty($url_area));
// Try to fetch $force_admin from session
if (isset($_SESSION['cot_comments_force_admin'][$area][$item]) && $_SESSION['cot_comments_force_admin'][$area][$item] && $usr['auth_read'] && $usr['auth_write']) {
    $usr['isadmin'] = true;
}
if ($m == 'edit' && $id > 0) {
    if ($a == 'update' && $id > 0) {