本文整理汇总了PHP中get_CommentCache函数的典型用法代码示例。如果您正苦于以下问题:PHP get_CommentCache函数的具体用法?PHP get_CommentCache怎么用?PHP get_CommentCache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_CommentCache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: skin_init
//.........这里部分代码省略.........
case 'arcdir':
$seo_page_type = 'Date archive directory';
if ($Blog->get_setting($disp . '_noindex')) {
// We prefer robots not to index these pages:
$robots_index = false;
}
break;
case 'catdir':
$seo_page_type = 'Category directory';
if ($Blog->get_setting($disp . '_noindex')) {
// We prefer robots not to index these pages:
$robots_index = false;
}
break;
case 'msgform':
global $disp;
// get expected message form type
$msg_type = param('msg_type', 'string', '');
// initialize
$recipient_User = NULL;
$Comment = NULL;
$allow_msgform = NULL;
// get possible params
$recipient_id = param('recipient_id', 'integer', 0, true);
$comment_id = param('comment_id', 'integer', 0, true);
$post_id = param('post_id', 'integer', 0, true);
$subject = param('subject', 'string', '');
// try to init recipient_User
if (!empty($recipient_id)) {
$UserCache =& get_UserCache();
$recipient_User =& $UserCache->get_by_ID($recipient_id);
} elseif (!empty($comment_id)) {
// comment id is set, try to get comment author user
$CommentCache =& get_CommentCache();
$Comment = $CommentCache->get_by_ID($comment_id, false);
if ($Comment = $CommentCache->get_by_ID($comment_id, false)) {
$recipient_User =& $Comment->get_author_User();
if (empty($recipient_User) && $Comment->allow_msgform && is_email($Comment->get_author_email())) {
// set allow message form to email because comment author (not registered) accepts email
$allow_msgform = 'email';
param('recipient_address', 'string', $Comment->get_author_email());
param('recipient_name', 'string', $Comment->get_author_name());
}
}
} else {
// Recipient was not defined, try set the blog owner as recipient
global $Blog;
if (empty($Blog)) {
// Blog is not set, this is an invalid request
debug_die('Invalid send message request!');
}
$recipient_User = $Blog->get_owner_User();
}
if ($recipient_User) {
// recipient User is set
// get_msgform_possibility returns NULL (false), only if there is no messaging option between current_User and recipient user
$allow_msgform = $recipient_User->get_msgform_possibility();
if ($msg_type == 'email' && $recipient_User->get_msgform_possibility(NULL, 'email') != 'email') {
// User doesn't want to receive email messages, Restrict if this was requested by wrong url:
$msg_type = '';
}
if ($allow_msgform == 'login') {
// user must login first to be able to send a message to this User
$disp = 'login';
param('action', 'string', 'req_login');
// override redirect to param
示例2: display_voting_form
// Display number of votes for current link type if it is enabled by blog skin
$voting_form_params['display_numbers'] = true;
}
}
}
display_voting_form($voting_form_params);
}
break;
case 'comment':
// Vote on comments
$comment_ID = (int) $vote_ID;
if (empty($comment_ID)) {
// No comment ID
break 2;
}
$CommentCache =& get_CommentCache();
$Comment = $CommentCache->get_by_ID($comment_ID, false);
if (!$Comment) {
// Incorrect comment ID
break 2;
}
if ($current_User->ID == $Comment->author_user_ID) {
// Do not allow users to vote on their own comments
break 2;
}
$comment_Item =& $Comment->get_Item();
$comment_Item->load_Blog();
if (!$comment_Item->Blog->get_setting('allow_rating_comment_helpfulness')) {
// If Users cannot vote
break 2;
}
示例3: cron_job_name
/**
* Get name of cron job
*
* @param string Job key
* @param string Job name
* @param string|array Job params
* @return string Default value of job name of Name from DB
*/
function cron_job_name($job_key, $job_name = '', $job_params = '')
{
if (empty($job_name)) {
// Get default name by key
$job_name = get_cron_jobs_config('name', $job_key);
}
$job_params = is_string($job_params) ? unserialize($job_params) : $job_params;
if (!empty($job_params)) {
// Prepare job name with the specified params
switch ($job_key) {
case 'send-post-notifications':
// Add item title to job name
if (!empty($job_params['item_ID'])) {
$ItemCache =& get_ItemCache();
if ($Item = $ItemCache->get_by_ID($job_params['item_ID'], false, false)) {
$job_name = sprintf($job_name, $Item->get('title'));
}
}
break;
case 'send-comment-notifications':
// Add item title of the comment to job name
if (!empty($job_params['comment_ID'])) {
$CommentCache =& get_CommentCache();
if ($Comment =& $CommentCache->get_by_ID($job_params['comment_ID'], false, false)) {
if ($Item = $Comment->get_Item()) {
$job_name = sprintf($job_name, $Item->get('title'));
}
}
}
break;
}
}
return $job_name;
}
示例4: echo_comment
/**
* Display a comment corresponding the given comment id
*
* @param int comment id
* @param string where to redirect after comment edit
* @param boolean true to set the new redirect param, false otherwise
*/
function echo_comment($comment_ID, $redirect_to = NULL, $save_context = false)
{
global $current_User, $localtimenow;
$CommentCache =& get_CommentCache();
/**
* @var Comment
*/
$Comment = $CommentCache->get_by_ID($comment_ID);
$Item =& $Comment->get_Item();
$Blog =& $Item->get_Blog();
$is_published = $Comment->get('status') == 'published';
$expiry_delay = $Item->get_setting('post_expiry_delay');
$is_expired = !empty($expiry_delay) && $localtimenow - mysql2timestamp($Comment->get('date')) > $expiry_delay;
echo '<div id="c' . $comment_ID . '" class="bComment bComment';
// check if comment is expired
if ($is_expired) {
// comment is expired
echo 'expired';
} else {
// comment is not expired
$Comment->status('raw');
}
echo '">';
if ($current_User->check_perm('comment!CURSTATUS', 'moderate', false, $Comment)) {
// User can moderate this comment
echo '<div class="bSmallHead">';
echo '<div>';
echo '<div class="bSmallHeadRight">';
$Comment->permanent_link(array('before' => '', 'text' => '#text#'));
echo '</div>';
echo '<span class="bDate">';
$Comment->date();
echo '</span>@<span class = "bTime">';
$Comment->time('H:i');
echo '</span>';
$Comment->author_email('', ' · Email: <span class="bEmail">', '</span>');
echo ' · <span class="bKarma">';
$Comment->spam_karma(T_('Spam Karma') . ': %s%', T_('No Spam Karma'));
echo '</span>';
echo '</div>';
echo '<div style="padding-top:3px">';
if ($is_expired) {
echo '<div class="bSmallHeadRight">';
echo '<span class="bExpired">' . T_('EXPIRED') . '</span>';
echo '</div>';
}
$Comment->author_ip('IP: <span class="bIP">', '</span> · ', true);
$Comment->ip_country('', ' · ');
$Comment->author_url_with_actions('', true, true);
echo '</div>';
echo '</div>';
echo '<div class="bCommentContent">';
$Comment->status('styled');
echo '<div class="bTitle">';
echo T_('In response to:') . ' <a href="?ctrl=items&blog=' . $Blog->ID . '&p=' . $Item->ID . '">' . $Item->dget('title') . '</a>';
echo '</div>';
echo '<div class="bCommentTitle">';
echo $Comment->get_title();
echo '</div>';
echo '<div class="bCommentText">';
$Comment->rating();
$Comment->avatar();
$Comment->content('htmlbody', 'true');
echo '</div>';
echo '</div>';
echo '<div class="CommentActionsArea">';
echo '<div class="floatleft">';
// Display edit button if current user has the rights:
$Comment->edit_link(' ', ' ', get_icon('edit'), '#', 'roundbutton', '&', $save_context, $redirect_to);
echo '<span class="roundbutton_group">';
// Display publish NOW button if current user has the rights:
$link_params = array('class' => 'roundbutton_text', 'save_context' => $save_context, 'ajax_button' => true, 'redirect_to' => $redirect_to);
$Comment->raise_link($link_params);
// Display deprecate button if current user has the rights:
$Comment->lower_link($link_params);
$next_status_in_row = $Comment->get_next_status(false);
if ($next_status_in_row && $next_status_in_row[0] != 'deprecated') {
// Display deprecate button if current user has the rights:
$Comment->deprecate_link('', '', get_icon('move_down_grey', 'imgtag', array('title' => '')), '#', 'roundbutton', '&', true, true);
}
// Display delete button if current user has the rights:
$Comment->delete_link('', '', '#', '#', 'roundbutton_text', false, '&', $save_context, true, '#', $redirect_to);
echo '</span>';
echo '</div>';
// Display Spam Voting system
$Comment->vote_spam('', '', '&', $save_context, true);
echo '<div class="clear"></div>';
echo '</div>';
} else {
// No permissions to moderate of this comment, just preview
echo '<div class="bSmallHead">';
echo '<div>';
echo '<div class="bSmallHeadRight">';
//.........这里部分代码省略.........
示例5: get_CommentCache
/**
* Get current Comment for an XML-RPC request.
*
* @param xmlrpcmsg XML-RPC Message
* @param integer idx of comment ID param
* @return Comment or NULL
*/
function &xmlrpcs_get_Comment($m, $id_param)
{
global $xmlrpcs_errcode, $xmlrpcs_errmsg, $xmlrpcerruser;
$id = $m->getParam($id_param);
$id = $id->scalarval();
/**
* @var CommentCache
*/
$CommentCache =& get_CommentCache();
/**
* @var Comment
*/
$edited_Comment =& $CommentCache->get_by_ID($id, false, false);
if (empty($edited_Comment)) {
// Comment not found
$xmlrpcs_errcode = $xmlrpcerruser + 9;
$xmlrpcs_errmsg = 'Requested comment (' . $id . ') does not exist.';
$r = NULL;
return $r;
}
logIO('Requested Comment: ' . $edited_Comment->ID . ' - ' . strmaxlen($edited_Comment->content, 30));
return $edited_Comment;
}
示例6: delete_comments
/**
* Delete comments of the user
*
* @return boolean True on success
*/
function delete_comments()
{
global $DB, $current_User;
// If user has a huge amount of the comments it will takes many time to delete all comments
set_max_execution_time(900);
$DB->begin();
// Get the comments of this user which current user can delete
$comments_IDs = $this->get_own_comments_IDs();
if (!count($comments_IDs)) {
// User has no comments
return false;
}
$CommentCache =& get_CommentCache();
$ItemCache =& get_ItemCache();
// If current user can moderate this user then it is allowed to delete all user data even if it wouldn't be allowed otherwise.
$current_user_can_moderate = $current_User->can_moderate_user($this->ID);
$result = false;
foreach ($comments_IDs as $comment_ID) {
$deleted_Comment =& $CommentCache->get_by_ID($comment_ID, false, false);
if ($deleted_Comment && ($current_user_can_moderate || $current_User->check_perm('comment!CURSTATUS', 'delete', false, $deleted_Comment))) {
// Current user has a permission to delete this comment
// Delete from DB
$result = $deleted_Comment->dbdelete(true, false);
if (!$result) {
break;
}
}
// Clear a cache to avoid a memory allocation error
$CommentCache->clear();
$ItemCache->clear();
}
if ($result) {
$DB->commit();
} else {
$DB->rollback();
}
return $result;
}
示例7: get_file_links
/**
* Get all links where file is used
*
* @param integer File ID
* @param array Params
* @return string The links to that posts, comments and users where the file is used
*/
function get_file_links($file_ID, $params = array())
{
global $DB, $current_User, $baseurl, $admin_url;
$params = array_merge(array('separator' => '<br />', 'post_prefix' => T_('Post') . ' - ', 'comment_prefix' => T_('Comment on') . ' - ', 'user_prefix' => T_('Profile picture') . ' - '), $params);
// Create result array
$attached_to = array();
// Get all links with posts and comments
$links_SQL = new SQL();
$links_SQL->SELECT('link_itm_ID, link_cmt_ID');
$links_SQL->FROM('T_links');
$links_SQL->WHERE('link_file_ID = ' . $DB->quote($file_ID));
$links = $DB->get_results($links_SQL->get());
if (!empty($links)) {
// File is linked with some posts or comments
$ItemCache =& get_ItemCache();
$CommentCache =& get_CommentCache();
foreach ($links as $link) {
if (!empty($link->link_itm_ID)) {
// File is linked to a post
if ($Item =& $ItemCache->get_by_ID($link->link_itm_ID, false)) {
$Blog = $Item->get_Blog();
if ($current_User->check_perm('item_post!CURSTATUS', 'view', false, $Item)) {
// Current user can edit the linked post
$attached_to[] = $params['post_prefix'] . '<a href="' . url_add_param($admin_url, 'ctrl=items&blog=' . $Blog->ID . '&p=' . $link->link_itm_ID) . '">' . $Item->get('title') . '</a>';
} else {
// No access to edit the linked post
$attached_to[] = $params['post_prefix'] . $Item->get('title');
}
}
}
if (!empty($link->link_cmt_ID)) {
// File is linked to a comment
if ($Comment =& $CommentCache->get_by_ID($link->link_cmt_ID, false)) {
$Item = $Comment->get_Item();
if ($current_User->check_perm('comment!CURSTATUS', 'moderate', false, $Comment)) {
// Current user can edit the linked Comment
$attached_to[] = $params['comment_prefix'] . '<a href="' . url_add_param($admin_url, 'ctrl=comments&action=edit&comment_ID=' . $link->link_cmt_ID) . '">' . $Item->get('title') . '</a>';
} else {
// No access to edit the linked Comment
$attached_to[] = $params['comment_prefix'] . $Item->get('title');
}
}
}
}
}
// Get all links with profile pictures
$profile_links_SQL = new SQL();
$profile_links_SQL->SELECT('user_ID, user_login');
$profile_links_SQL->FROM('T_users');
$profile_links_SQL->WHERE('user_avatar_file_ID = ' . $DB->quote($file_ID));
$profile_links = $DB->get_results($profile_links_SQL->get());
if (!empty($profile_links)) {
foreach ($profile_links as $link) {
if ($current_User->ID != $link->user_ID && !$current_User->check_perm('users', 'view')) {
// No permission to view other users in admin form
$attached_to[] = $params['user_prefix'] . '<a href="' . url_add_param($baseurl, 'disp=user&user_ID=' . $link->user_ID) . '">' . $link->user_login . '</a>';
} else {
// Build a link to display a user in admin form
$attached_to[] = $params['user_prefix'] . '<a href="?ctrl=user&user_tab=profile&user_ID=' . $link->user_ID . '">' . $link->user_login . '</a>';
}
}
}
return implode($params['separator'], $attached_to);
}
示例8: parse_anchor_links
/**
* Parse anchor links, Set absolute path for each link with relative anchor like <a href="#">
*
* @param string Content
* @return string Content
*/
function parse_anchor_links($content)
{
if (preg_match_all('/ href="#(c|p)([0-9]+)"/i', $content, $matches)) {
$CommentCache =& get_CommentCache();
$ItemCache =& get_ItemCache();
foreach ($matches[0] as $m => $full_match) {
$object_ID = $matches[2][$m];
$new_url = '';
switch ($matches[1][$m]) {
// Object type:
case 'p':
// Item
if ($Item =& $ItemCache->get_by_ID($object_ID, false, false)) {
// Replace anchor url with item permanent url
$new_url = $Item->get_permanent_url() . '#p' . $object_ID;
}
break;
case 'c':
// Comment
if ($Comment =& $CommentCache->get_by_ID($object_ID, false, false)) {
// Replace anchor url with comment permanent url
$new_url = $Comment->get_permanent_url();
}
break;
default:
// Incorrect object type, Skip this url
continue;
}
if (!empty($new_url)) {
// Replace relative anchor url with new absolute url
$content = str_replace($full_match, ' href="' . $new_url . '"', $content);
}
}
}
return $content;
}
示例9: search_result_block
function search_result_block($params = array())
{
global $Blog, $Session, $debug;
$search_keywords = param('s', 'string', '', true);
// Try to load existing search results from Session:
$search_params = $Session->get('search_params');
$search_result = $Session->get('search_result');
$search_result_loaded = false;
if (empty($search_params) || $search_params['search_keywords'] != $search_keywords || $search_params['search_blog'] != $Blog->ID || $search_result === NULL) {
// We need to perform a new search:
if ($debug) {
echo '<p class="text-muted">Starting a new search...</p>';
}
// Flush first part of the page before starting search, which can be long...
evo_flush();
$search_params = array('search_keywords' => $search_keywords, 'search_blog' => $Blog->ID);
// Perform new search:
$search_result = perform_scored_search($search_keywords);
// Save results into session:
$Session->set('search_params', $search_params);
$Session->set('search_result', $search_result);
$search_result_loaded = true;
} else {
// We found the desired saved search results in the Session:
if ($debug) {
// Display counts
echo '<div class="text-muted">';
echo '<p>We found the desired saved search results in the Session:</p>';
echo '<ul><li>' . sprintf('%d posts', $search_result[0]['nr_of_items']) . '</li>';
echo '<li>' . sprintf('%d comments', $search_result[0]['nr_of_comments']) . '</li>';
echo '<li>' . sprintf('%d chapters', $search_result[0]['nr_of_cats']) . '</li>';
echo '<li>' . sprintf('%d tags', $search_result[0]['nr_of_tags']) . '</li></ul>';
echo '</div>';
}
// Flush first part of the page before starting search, which can be long...
evo_flush();
}
// Make sure we are not missing any display params:
$params = array_merge(array('no_match_message' => '<p class="alert alert-info msg_nothing" style="margin: 2em 0">' . T_('Sorry, we could not find anything matching your request, please try to broaden your search.') . '<p>', 'title_suffix_post' => ' (' . T_('Post') . ')', 'title_suffix_comment' => ' (' . T_('Comment') . ')', 'title_suffix_category' => ' (' . T_('Category') . ')', 'title_suffix_tag' => ' (' . T_('Tag') . ')', 'block_start' => '', 'block_end' => '', 'pagination' => array(), 'use_editor' => false, 'author_format' => 'avatar_name', 'date_format' => locale_datefmt()), $params);
$search_result = $Session->get('search_result');
if (empty($search_result)) {
echo $params['no_match_message'];
return;
}
// Prepare pagination:
$result_count = count($search_result);
$result_per_page = $Blog->get_setting('search_per_page');
if ($result_count > $result_per_page) {
// We will have multiple search result pages:
$current_page = param('page', 'integer', 1);
$total_pages = ceil($result_count / $result_per_page);
if ($current_page > $total_pages) {
$current_page = $total_pages;
}
$page_params = array_merge(array('total' => $result_count, 'current_page' => $current_page, 'total_pages' => $total_pages, 'list_span' => 11), $params['pagination']);
search_page_links($page_params);
} else {
// Only one page of results:
$current_page = 1;
$total_pages = 1;
}
// Set current page indexes:
$from = ($current_page - 1) * $result_per_page;
$to = $current_page < $total_pages ? $from + $result_per_page : $result_count;
// Init caches
$ItemCache =& get_ItemCache();
$CommentCache =& get_CommentCache();
$ChapterCache =& get_ChapterCache();
if (!$search_result_loaded) {
// Search result objects are not loaded into memory yet, load them
// Group required object ids by type:
$required_ids = array();
for ($index = $from; $index < $to; $index++) {
$row = $search_result[$index];
if (isset($required_ids[$row['type']])) {
$required_ids[$row['type']][] = $row['ID'];
} else {
$required_ids[$row['type']] = array($row['ID']);
}
}
// Load each required object into the corresponding cache:
foreach ($required_ids as $type => $object_ids) {
switch ($type) {
case 'item':
$ItemCache->load_list($object_ids);
break;
case 'comment':
$CommentCache->load_list($object_ids);
break;
case 'category':
$ChapterCache->load_list($object_ids);
break;
// TODO: we'll probably load "tag" objects once we support tag-synonyms.
// TODO: we'll probably load "tag" objects once we support tag-synonyms.
default:
// Not handled search result type
break;
}
}
}
//.........这里部分代码省略.........
示例10: SQL
/**
* Get the latest Comment on this Item
*
* @param string the status of the latest comment
* @return Comment
*/
function &get_latest_Comment($status = NULL)
{
global $DB;
if (is_null($this->latest_Comment)) {
$SQL = new SQL('Get the latest Comment on the Item');
$SQL->SELECT('comment_ID');
$SQL->FROM('T_comments');
$SQL->WHERE('comment_item_ID = ' . $DB->quote($this->ID));
$SQL->WHERE_and('comment_type != "meta"');
$SQL->ORDER_BY('comment_date DESC');
$SQL->LIMIT('1');
if ($status != NULL) {
$SQL->WHERE_and('comment_status = ' . $DB->quote($status));
}
if ($comment_ID = $DB->get_var($SQL->get())) {
$CommentCache =& get_CommentCache();
$this->latest_Comment =& $CommentCache->get_by_ID($comment_ID);
}
}
return $this->latest_Comment;
}
示例11: get_file_links
/**
* Get all links where file is used
*
* @param integer File ID
* @param array Params
* @return string The links to that posts, comments and users where the file is used
*/
function get_file_links($file_ID, $params = array())
{
global $DB, $current_User, $baseurl, $admin_url;
$params = array_merge(array('separator' => '<br />', 'post_prefix' => T_('Post') . ' - ', 'comment_prefix' => T_('Comment on') . ' - ', 'user_prefix' => T_('Profile picture') . ' - ', 'current_link_ID' => 0, 'current_before' => '<b>', 'current_after' => '</b>'), $params);
// Create result array
$attached_to = array();
// Get all links with posts and comments
$links_SQL = new SQL();
$links_SQL->SELECT('link_ID, link_itm_ID, link_cmt_ID, link_usr_ID');
$links_SQL->FROM('T_links');
$links_SQL->WHERE('link_file_ID = ' . $DB->quote($file_ID));
$links = $DB->get_results($links_SQL->get());
if (!empty($links)) {
// File is linked with some posts or comments
$ItemCache =& get_ItemCache();
$CommentCache =& get_CommentCache();
$UserCache =& get_UserCache();
$LinkCache =& get_LinkCache();
foreach ($links as $link) {
$link_object_ID = 0;
$r = '';
if ($params['current_link_ID'] == $link->link_ID) {
$r .= $params['current_before'];
}
if (!empty($link->link_itm_ID)) {
// File is linked to a post
if ($Item =& $ItemCache->get_by_ID($link->link_itm_ID, false)) {
$Blog = $Item->get_Blog();
if ($current_User->check_perm('item_post!CURSTATUS', 'view', false, $Item)) {
// Current user can edit the linked post
$r .= $params['post_prefix'] . '<a href="' . url_add_param($admin_url, 'ctrl=items&blog=' . $Blog->ID . '&p=' . $link->link_itm_ID) . '">' . $Item->get('title') . '</a>';
} else {
// No access to edit the linked post
$r .= $params['post_prefix'] . $Item->get('title');
}
$link_object_ID = $link->link_itm_ID;
}
} elseif (!empty($link->link_cmt_ID)) {
// File is linked to a comment
if ($Comment =& $CommentCache->get_by_ID($link->link_cmt_ID, false)) {
$Item = $Comment->get_Item();
if ($current_User->check_perm('comment!CURSTATUS', 'moderate', false, $Comment)) {
// Current user can edit the linked Comment
$r .= $params['comment_prefix'] . '<a href="' . url_add_param($admin_url, 'ctrl=comments&action=edit&comment_ID=' . $link->link_cmt_ID) . '">' . $Item->get('title') . '</a>';
} else {
// No access to edit the linked Comment
$r .= $params['comment_prefix'] . $Item->get('title');
}
$link_object_ID = $link->link_cmt_ID;
}
} elseif (!empty($link->link_usr_ID)) {
// File is linked to user
if ($User =& $UserCache->get_by_ID($link->link_usr_ID, false)) {
if ($current_User->ID != $User->ID && !$current_User->check_perm('users', 'view')) {
// No permission to view other users in admin form
$r .= $params['user_prefix'] . '<a href="' . url_add_param($baseurl, 'disp=user&user_ID=' . $User->ID) . '">' . $User->login . '</a>';
} else {
// Build a link to display a user in admin form
$r .= $params['user_prefix'] . '<a href="?ctrl=user&user_tab=profile&user_ID=' . $User->ID . '">' . $User->login . '</a>';
}
$link_object_ID = $link->link_usr_ID;
}
}
if (!empty($link_object_ID)) {
// Action icon to unlink file from object
if (($edited_Link =& $LinkCache->get_by_ID($link->link_ID, false, false)) !== false && ($LinkOwner =& $edited_Link->get_LinkOwner()) !== false && $LinkOwner->check_perm('edit', false)) {
// Allow to unlink only if current user has an permission
$r .= ' ' . action_icon(T_('Delete this link!'), 'unlink', $admin_url . '?ctrl=links&link_ID=' . $link->link_ID . '&link_type=item&link_object_ID=' . $link->link_usr_ID . '&action=unlink&redirect_to=' . rawurlencode(regenerate_url('blog', '', '', '&')) . '&' . url_crumb('link'), NULL, NULL, NULL, array('onclick' => 'return confirm(\'' . TS_('Are you sure want to unlink this file?') . '\');'));
}
}
if ($params['current_link_ID'] == $link->link_ID) {
$r .= $params['current_after'];
}
if (!empty($r)) {
$attached_to[] = $r;
}
}
}
return implode($params['separator'], $attached_to);
}
示例12: comments_results_block
/**
* Display comments results table
*
* @param array Params
*/
function comments_results_block($params = array())
{
// Make sure we are not missing any param:
$params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_comment_', 'results_title' => T_('Comments posted by the user'), 'results_no_text' => T_('User has not posted any comment yet')), $params);
if (!is_logged_in()) {
// Only logged in users can access to this function
return;
}
global $current_User;
if (!$current_User->check_perm('users', 'edit')) {
// Check minimum permission:
return;
}
$edited_User = $params['edited_User'];
if (!$edited_User) {
// No defined User, probably the function is calling from AJAX request
$user_ID = param('user_ID', 'integer', 0);
if (empty($user_ID)) {
// Bad request, Exit here
return;
}
$UserCache =& get_UserCache();
if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) {
// Bad request, Exit here
return;
}
}
global $DB;
param('user_tab', 'string', '', true);
param('user_ID', 'integer', 0, true);
$SQL = new SQL();
$SQL->SELECT('*');
$SQL->FROM('T_comments');
$SQL->WHERE('comment_author_ID = ' . $DB->quote($edited_User->ID));
// Create result set:
$comments_Results = new Results($SQL->get(), $params['results_param_prefix'], 'D');
$comments_Results->Cache =& get_CommentCache();
$comments_Results->title = $params['results_title'];
$comments_Results->no_results_text = $params['results_no_text'];
// Get a count of the comments which current user can delete
$deleted_comments_count = count($edited_User->get_deleted_comments());
if ($comments_Results->total_rows > 0 && $deleted_comments_count) {
// Display action icon to delete all records if at least one record exists & current user can delete at least one comment posted by user
$comments_Results->global_icon(sprintf(T_('Delete all comments posted by %s'), $edited_User->login), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_comments&user_ID=' . $edited_User->ID . '&' . url_crumb('user'), ' ' . T_('Delete all'), 3, 4);
}
// Initialize Results object
comments_results($comments_Results, array('field_prefix' => 'comment_', 'display_kind' => false, 'display_additional_columns' => true, 'plugin_table_name' => 'activity', 'display_spam' => false));
if (is_ajax_content()) {
// init results param by template name
if (!isset($params['skin_type']) || !isset($params['skin_name'])) {
debug_die('Invalid ajax results request!');
}
$comments_Results->init_params_by_skin($params['skin_type'], $params['skin_name']);
}
$display_params = array('before' => '<div class="results" style="margin-top:25px" id="comments_result">');
$comments_Results->display($display_params);
if (!is_ajax_content()) {
// Create this hidden div to get a function name for AJAX request
echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>';
}
}
示例13: dbm_delete_orphan_comments
/**
* Find and delete orphan comments with no matching Item
*/
function dbm_delete_orphan_comments()
{
global $Messages, $DB;
// Get all comment with no matching Item
$comments_SQL = new SQL();
$comments_SQL->SELECT('comment_ID');
$comments_SQL->FROM('T_comments');
$comments_SQL->FROM_add('LEFT JOIN T_items__item ON comment_item_ID = post_ID');
$comments_SQL->WHERE('post_ID IS NULL');
$comments = $DB->get_col($comments_SQL->get());
$num_deleted = 0;
$CommentCache =& get_CommentCache();
foreach ($comments as $comment_ID) {
if (($broken_Comment =& $CommentCache->get_by_ID($comment_ID, false, false)) !== false) {
// Comment object is created
if ($broken_Comment->dbdelete(true)) {
// Comment is deleted successfully
$num_deleted++;
}
}
// Clear cache to save memory
$CommentCache->clear();
}
$Messages->add(sprintf(T_('%d comments have been deleted'), $num_deleted), 'success');
}
示例14: get_deleted_comments
/**
* Get the comments of this user which current user can delete
*
* @return array Comments
*/
function get_deleted_comments()
{
global $DB, $current_User;
// Get the comments of the user
$CommentCache =& get_CommentCache();
$CommentCache->ID_array = array();
$user_Comments = $CommentCache->load_where('comment_author_ID = ' . $DB->quote($this->ID));
$deleted_Comments = array();
foreach ($user_Comments as $user_Comment) {
if ($current_User->check_perm('comment!CURSTATUS', 'delete', false, $user_Comment)) {
// Current user has a permission to delete this comment
$deleted_Comments[] = $user_Comment;
}
}
return $deleted_Comments;
}
示例15: echo_comment
/**
* Display a comment corresponding the given comment id
*
* @param int comment id
* @param string where to redirect after comment edit
* @param boolean true to set the new redirect param, false otherwise
* @param integer Comment index in the current list
*/
function echo_comment($comment_ID, $redirect_to = NULL, $save_context = false, $comment_index = NULL)
{
global $current_User, $localtimenow;
$CommentCache =& get_CommentCache();
/**
* @var Comment
*/
$Comment = $CommentCache->get_by_ID($comment_ID);
$Item =& $Comment->get_Item();
$Blog =& $Item->get_Blog();
$is_published = $Comment->get('status') == 'published';
$expiry_delay = $Item->get_setting('comment_expiry_delay');
$is_expired = !empty($expiry_delay) && $localtimenow - mysql2timestamp($Comment->get('date')) > $expiry_delay;
echo '<a name="c' . $comment_ID . '"></a>';
echo '<div id="comment_' . $comment_ID . '" class="bComment bComment';
// check if comment is expired
if ($is_expired) {
// comment is expired
echo 'expired';
} elseif ($Comment->is_meta()) {
// meta comment
echo 'meta';
} else {
// comment is not expired and not meta
$Comment->status('raw');
}
echo '">';
if ($current_User->check_perm('comment!CURSTATUS', 'moderate', false, $Comment) || $Comment->is_meta() && $current_User->check_perm('meta_comment', 'view', false, $Item)) {
// User can moderate this comment OR Comment is meta and current user can view it
echo '<div class="bSmallHead">';
echo '<div>';
if ($Comment->is_meta()) {
// Display ID for each meta comment
echo '<span class="badge badge-info">' . $comment_index . '</span> ';
}
echo '<div class="bSmallHeadRight">';
$Comment->permanent_link(array('before' => '', 'text' => $Comment->is_meta() ? T_('Meta link') : '#text#'));
echo '</div>';
echo '<span class="bDate">';
$Comment->date();
echo '</span>@<span class = "bTime">';
$Comment->time('#short_time');
echo '</span>';
if ($Comment->is_meta()) {
// Display only author for meta comment
$Comment->author('', '', ' · ' . T_('Author') . ': ', '');
} else {
// Display the detailed info for standard comment
$Comment->author_email('', ' · Email: <span class="bEmail">', '</span>');
echo ' · <span class="bKarma">';
$Comment->spam_karma(T_('Spam Karma') . ': %s%', T_('No Spam Karma'));
echo '</span>';
echo '</div>';
echo '<div style="padding-top:3px">';
if ($is_expired) {
echo '<div class="bSmallHeadRight">';
echo '<span class="bExpired">' . T_('EXPIRED') . '</span>';
echo '</div>';
}
$Comment->author_ip('IP: <span class="bIP">', '</span> · ', true, true);
$Comment->ip_country('', ' · ');
$Comment->author_url_with_actions('', true, true);
}
echo '</div>';
echo '</div>';
echo '<div class="bCommentContent">';
$Comment->format_status(array('template' => '<div class="floatright"><span class="note status_$status$"><span>$status_title$</span></span></div>'));
if (!$Comment->is_meta()) {
// Don't display the titles for meta comments
echo '<div class="bCommentTitle">';
echo $Comment->get_title();
if (get_param('p') == '') {
// Don't display this title on a post view page
echo ' ' . T_('in response to') . ' <a href="?ctrl=items&blog=' . $Blog->ID . '&p=' . $Item->ID . '">' . $Item->dget('title') . '</a>';
}
echo '</div>';
}
echo '<div class="bCommentText">';
$Comment->rating();
$Comment->avatar('crop-top-80x80');
if ($current_User->check_perm('meta_comment', 'edit', false, $Comment)) {
// Put the comment content into this container to edit by ajax
echo '<div id="editable_comment_' . $Comment->ID . '" class="editable_comment_content">';
}
$Comment->content('htmlbody', 'true');
if ($current_User->check_perm('meta_comment', 'edit', false, $Comment)) {
// End of the container that is used to edit meta comment by ajax
echo '</div>';
}
echo '</div>';
echo '</div>';
echo '<div class="CommentActionsArea">';
//.........这里部分代码省略.........