function discuss($ID) { global $comments_disabled_after; $preview = ps('preview'); extract(safe_row("Annotate,AnnotateInvite,unix_timestamp(Posted) as uPosted", "textpattern", "ID='{$ID}'")); $darr = !$preview ? fetchComments($ID) : array(psas(array('name', 'email', 'web', 'message', 'parentid', 'remember'))); $out = n . '<h3 style="margin-top:2em" id="comment">' . $AnnotateInvite . '</h3>' . n; if ($darr) { $out .= '<ol>' . n; $out .= formatComments($darr); $out .= n . '</ol>'; } $wasAnnotated = !$Annotate ? getCount('txp_discuss', "parentid={$ID}") : ''; if (!$Annotate) { $out .= graf(gTxt("comments_closed")); } else { if ($comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $timesince = time() - $uPosted; if ($lifespan > $timesince) { $out .= commentForm($ID); } else { $out .= graf(gTxt("comments_closed")); } } else { $out .= commentForm($ID); } } return $out; }
function comments($atts) { global $thisarticle, $prefs, $comment_preview, $pretext; extract($prefs); extract(lAtts(array('id' => @$pretext['id'], 'form' => 'comments', 'wraptag' => $comments_are_ol ? 'ol' : '', 'break' => $comments_are_ol ? 'li' : 'div', 'class' => __FUNCTION__, 'breakclass' => ''), $atts)); if (is_array($thisarticle)) { extract($thisarticle); } if (@$thisid) { $id = $thisid; } $Form = fetch_form($form); if (!empty($comment_preview)) { $preview = psas(array('name', 'email', 'web', 'message', 'parentid', 'remember')); $preview['time'] = time(); $preview['discussid'] = 0; $preview['message'] = markup_comment($preview['message']); $GLOBALS['thiscomment'] = $preview; $comments[] = parse($Form) . n; unset($GLOBALS['thiscomment']); $out = doWrap($comments, $wraptag, $break, $class, $breakclass); } else { $rs = safe_rows_start("*, unix_timestamp(posted) as time", "txp_discuss", "parentid='{$id}' and visible='1' order by posted asc"); $out = ''; if ($rs) { $comments = array(); while ($vars = nextRow($rs)) { $GLOBALS['thiscomment'] = $vars; $comments[] = parse($Form) . n; unset($GLOBALS['thiscomment']); } $out .= doWrap($comments, $wraptag, $break, $class, $breakclass); } } return $out; }
function sed_comments($atts) { global $thisarticle, $prefs, $comment_preview, $pretext; extract($prefs); extract(lAtts(array('id' => @$pretext['id'], 'form' => 'comments', 'wraptag' => $comments_are_ol ? 'ol' : '', 'break' => $comments_are_ol ? 'li' : 'div', 'class' => __FUNCTION__, 'breakclass' => '', 'sort' => 'posted ASC'), $atts)); assert_article(); if (is_array($thisarticle)) { extract($thisarticle); } if (@$thisid) { $id = $thisid; } # # Extract the sed article overrides... # Access the custom field that houses the vars and explode the string on ';' boundaries. # $sed_vars = _sed_cp_get_sed_vars(@$thisarticle['sed per-article vars']); $sed_vars = lAtts(array('sed_delay' => '0', 'sed_ttl' => '', 'sed_on_cull' => 'hide', 'sed_ttl_grace' => ''), $sed_vars); extract($sed_vars); if (!empty($comment_preview)) { $preview = psas(array('name', 'email', 'web', 'message', 'parentid', 'remember')); $preview['time'] = time(); $preview['discussid'] = 0; $preview['message'] = markup_comment($preview['message']); $GLOBALS['thiscomment'] = $preview; $comments[] = parse_form($form) . n; unset($GLOBALS['thiscomment']); $out = doWrap($comments, $wraptag, $break, $class, $breakclass); } else { $rs = safe_rows_start("*, unix_timestamp(posted) as time", "txp_discuss", 'parentid=' . intval($id) . ' and visible=' . VISIBLE . ' order by ' . doSlash($sort)); $out = ''; if ($rs) { $comments = array(); $culled_comments = array(); while ($vars = nextRow($rs)) { $culled = false; $show = true; $extra = ''; $now = time(); $remaining = ''; # # If the comment is in a deleting page then check if it is to be culled... # if (!empty($sed_ttl)) { $do_cull_check = true; # # Are we in any grace period??? # if (!empty($sed_ttl_grace) && 0 != $sed_ttl_grace) { $do_cull_check = _sed_cp_if_outside_period($thisarticle['posted'], $sed_ttl_grace, $vars['time'], $remaining); } # # If not then do the cull checking... # if ($do_cull_check) { $culled = _sed_cp_if_outside_period($vars['time'], $sed_ttl, $now, $remaining); } # # Display how long to go before culling. # if ($do_cull_check && !$culled) { $vars['message'] .= "<br/><br/><strong>[MARKED FOR DELETION IN {$remaining}.]</strong>"; } } if ($culled) { $extra .= ' culled'; $culled_comments[] = $vars; $vars['time'] = $now; $vars['message'] .= "<br/><br/><strong>[DELETED.]</strong>"; } else { # # See if the comment is in its "hidden" period. # This is to try and discourage spam-robots that immediately see if their posts appear live. # if (!empty($sed_delay) && $sed_delay > '0') { $show = _sed_cp_if_outside_period($vars['time'], $sed_delay, $now, $remaining); } # # Still hidden so show a place-holder comment instead. # if (!$show) { $extra .= ' delay_queue'; $vars['name'] = "[DELAYED]"; $vars['time'] = $now; $vars['message'] = "A comment has been recorded and is in the delay queue."; $vars['message'] .= "<br/><br/><strong>[REVEALED IN {$remaining}.]</strong>"; } } # # Save the additional css class markup for this comment in the vars before parsing the comment form. # $vars['sed_class_extra'] = $extra; $GLOBALS['thiscomment'] = $vars; $comments[] = parse_form($form) . n; unset($GLOBALS['thiscomment']); } $out .= doWrap($comments, $wraptag, $break, $class, $breakclass); # # Process the culled list... # if (!empty($culled_comments)) { foreach ($culled_comments as $comment) { if ('delete' == $sed_on_cull) { _sed_cp_delete_comment($comment); } else { _sed_cp_update_comment($comment, $sed_on_cull); } } update_comments_count($id); } } } return $out; }
function comments_preview($atts, $thing = '', $me = '') { global $thisarticle, $has_comments_preview; if (!ps('preview')) { return; } extract(lAtts(array('id' => @$pretext['id'], 'form' => 'comments', 'wraptag' => '', 'class' => __FUNCTION__), $atts)); assert_article(); if (is_array($thisarticle)) { extract($thisarticle); } if (@$thisid) { $id = $thisid; } $Form = fetch_form($form); $preview = psas(array('name', 'email', 'web', 'message', 'parentid', 'remember')); $preview['time'] = time(); $preview['discussid'] = 0; if ($preview['message'] == '') { $in = getComment(); $preview['message'] = $in['message']; } $preview['message'] = markup_comment($preview['message']); $GLOBALS['thiscomment'] = $preview; $comments = parse($Form) . n; unset($GLOBALS['thiscomment']); $out = doTag($comments, $wraptag, $class); # set a flag, to tell the comments_form tag that it doesn't have to show a preview $has_comments_preview = true; return $out; }
function comments_preview($atts, $thing = '', $me = '') { global $thisarticle; if (!ps('preview')) { return; } extract(lAtts(array('id' => @$pretext['id'], 'form' => 'comments', 'bc' => false, 'wraptag' => '', 'class' => __FUNCTION__), $atts)); //FIXME for crockery. This emulates the old hardcoded preview behaviour. if ($bc) { if (@$GLOBALS['pretext']['secondpass'] == false) { return $me; } if (@$GLOBALS['pretext']['comments_preview_shown']) { return ''; } else { return '<a id="cpreview"></a>' . discuss($id); } } $GLOBALS['pretext']['comments_preview_shown'] = true; if (is_array($thisarticle)) { extract($thisarticle); } if (@$thisid) { $id = $thisid; } $Form = fetch_form($form); $preview = psas(array('name', 'email', 'web', 'message', 'parentid', 'remember')); $preview['time'] = time(); $preview['discussid'] = 0; $preview['message'] = markup_comment($preview['message']); $GLOBALS['thiscomment'] = $preview; $comments = parse($Form) . n; unset($GLOBALS['thiscomment']); $out = doTag($comments, $wraptag, $class); return $out; }