本文整理汇总了PHP中qa_time_to_string函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_time_to_string函数的具体用法?PHP qa_time_to_string怎么用?PHP qa_time_to_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_time_to_string函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: messagelist
public function messagelist()
{
$offset = (int) qa_get('offset');
$offset = isset($offset) ? $offset * 15 : 0;
require_once QA_INCLUDE_DIR . 'qa-db-users.php';
// Get Events
$message_events = array('u_message', 'u_wall_post');
$events = "'" . implode("','", $message_events) . "'";
$userid = qa_get_logged_in_userid();
$eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT id, UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params, `read` FROM ^ra_userevent WHERE effecteduserid=# AND `read` = 0 AND event IN (' . $events . ') ORDER BY id DESC LIMIT 15 OFFSET #', $userid, $offset));
if (count($eventslist) > 0) {
$event = array();
$userids = array();
foreach ($eventslist as $event) {
$userids[$event['userid']] = $event['userid'];
$userids[$event['effecteduserid']] = $event['effecteduserid'];
}
if (QA_FINAL_EXTERNAL_USERS) {
$handles = qa_get_public_from_userids($userids);
} else {
$handles = qa_db_user_get_userid_handles($userids);
}
// get event's: time, type, parameters
// get post id of questions
foreach ($eventslist as $event) {
$title = '';
$link = '';
$handle = $handles[$event['userid']];
$reciever_handle = $handles[$event['effecteduserid']];
$reciever_link = qa_path('user/' . $reciever_handle);
$datetime = $event['datetime'];
$event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
$event['params'] = json_decode($event['params'], true);
$message = substr($event['params']['message'], 0, 30) . '..';
$id = ' data-id="' . $event['id'] . '"';
$read = $event['read'] ? ' read' : ' unread';
$url_param = array('ra_notification' => $event['id']);
$user_link = qa_path_html('user/' . $handle, $url_param);
switch ($event['event']) {
case 'u_message':
// related question to an answer
echo '<div class="event-content clearfix' . $read . '"' . $id . '>
<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
<div class="event-right">
<a href="' . qa_path_html('message/' . $handle, $url_param, QW_BASE_URL) . '">
<div class="head">
<strong class="user">' . $handle . '</strong>
<span class="what">' . qa_lang_html('dude/sent_you_a_private_message') . '</span>
<span class="message">' . $message . '</span>
</div>
<div class="footer">
<span class="event-icon icon-email"></span>
<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
</div>
</a>
</div>
</div>';
break;
case 'u_wall_post':
// user's question had been answered
$url = qa_path_html('user/' . $reciever_handle . '/wall', $url_param, QW_BASE_URL);
echo '<div class="event-content clearfix' . $read . '"' . $id . '>
<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
<div class="event-right">
<a href="' . $url . '">
<div class="head">
<strong class="user">' . $handle . '</strong>
<span class="what">' . qa_lang_html('dude/posted_on_your_wall') . '</span>
<span class="message">' . $message . '</span>
</div>
<div class="footer">
<span class="event-icon icon-pin"></span>
<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
</div>
</a>
</div>
</div>';
break;
}
}
} else {
echo '<div class="no-more-activity">' . qa_lang_html('dude/no_more_messages') . '</div>';
}
die;
}
示例2: array
}
}
if (count($showpermits)) {
$qa_content['form_profile']['fields']['permits'] = array('type' => 'static', 'label' => qa_lang_html('profile/extra_privileges'), 'value' => qa_html(implode("\n", $showpermits), true), 'rows' => count($showpermits));
}
// Show email address only if we're an administrator
if ($loginlevel >= QA_USER_LEVEL_ADMIN && !qa_user_permit_error()) {
$doconfirms = qa_opt('confirm_user_emails') && $useraccount['level'] < QA_USER_LEVEL_EXPERT;
$isconfirmed = $useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED ? true : false;
$qa_content['form_profile']['fields']['email'] = array('type' => $userediting ? 'text' : 'static', 'label' => qa_lang_html('users/email_label'), 'tags' => 'NAME="email"', 'value' => qa_html(isset($inemail) ? $inemail : $useraccount['email']), 'error' => qa_html(@$errors['email']), 'note' => ($doconfirms ? qa_lang_html($isconfirmed ? 'users/email_confirmed' : 'users/email_not_confirmed') . ' ' : '') . qa_lang_html('users/only_shown_admins'));
}
// Show IP addresses and times for last login or write - only if we're a moderator or higher
if ($loginlevel >= QA_USER_LEVEL_MODERATOR && !qa_user_permit_error()) {
$qa_content['form_profile']['fields']['lastlogin'] = array('type' => 'static', 'label' => qa_lang_html('users/last_login_label'), 'value' => strtr(qa_lang_html('users/x_ago_from_y'), array('^1' => qa_time_to_string(qa_opt('db_time') - $useraccount['loggedin']), '^2' => qa_ip_anchor_html($useraccount['loginip']))), 'note' => qa_lang_html('users/only_shown_moderators'));
if (isset($useraccount['written'])) {
$qa_content['form_profile']['fields']['lastwrite'] = array('type' => 'static', 'label' => qa_lang_html('users/last_write_label'), 'value' => strtr(qa_lang_html('users/x_ago_from_y'), array('^1' => qa_time_to_string(qa_opt('db_time') - $useraccount['written']), '^2' => qa_ip_anchor_html($useraccount['writeip']))), 'note' => qa_lang_html('users/only_shown_moderators'));
} else {
unset($qa_content['form_profile']['fields']['lastwrite']);
}
}
// Show other profile fields
$fieldsediting = $fieldseditable && $userediting;
foreach ($userfields as $userfield) {
if ($userfield['flags'] & QA_FIELD_FLAGS_LINK_URL && !$fieldsediting) {
$valuehtml = qa_url_to_html_link(@$userprofile[$userfield['title']], qa_opt('links_in_new_window'));
} else {
$value = @$inprofile[$userfield['fieldid']];
if (!isset($value)) {
$value = @$userprofile[$userfield['title']];
}
$valuehtml = qa_html($value, $userfield['flags'] & QA_FIELD_FLAGS_MULTI_LINE && !$fieldsediting ? true : false);
示例3: qa_db_user_set_password
if (empty($errors)) {
qa_db_user_set_password($userid, $innewpassword1);
qa_db_user_set($userid, 'sessioncode', '');
// stop old 'Remember me' style logins from still working
qa_set_logged_in_user($userid, $useraccount['handle'], false, $useraccount['sessionsource']);
// reinstate this specific session
qa_report_event('u_password', $userid, $useraccount['handle'], qa_cookie_get());
qa_redirect('account', array('state' => 'password-changed'));
}
}
}
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('profile/my_account_title');
$qa_content['error'] = @$errors['page'];
$qa_content['form_profile'] = array('tags' => 'enctype="multipart/form-data" method="post" action="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('duration' => array('type' => 'static', 'label' => qa_lang_html('users/member_for'), 'value' => qa_time_to_string(qa_opt('db_time') - $useraccount['created'])), 'type' => array('type' => 'static', 'label' => qa_lang_html('users/member_type'), 'value' => qa_html(qa_user_level_string($useraccount['level'])), 'note' => $isblocked ? qa_lang_html('users/user_blocked') : null), 'handle' => array('label' => qa_lang_html('users/handle_label'), 'tags' => 'name="handle"', 'value' => qa_html(isset($inhandle) ? $inhandle : $useraccount['handle']), 'error' => qa_html(@$errors['handle']), 'type' => $changehandle && !$isblocked ? 'text' : 'static'), 'email' => array('label' => qa_lang_html('users/email_label'), 'tags' => 'name="email"', 'value' => qa_html(isset($inemail) ? $inemail : $useraccount['email']), 'error' => isset($errors['email']) ? qa_html($errors['email']) : ($doconfirms && !$isconfirmed ? qa_insert_login_links(qa_lang_html('users/email_please_confirm')) : null), 'type' => $isblocked ? 'static' : 'text'), 'messages' => array('label' => qa_lang_html('users/private_messages'), 'tags' => 'name="messages"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES), 'note' => qa_lang_html('users/private_messages_explanation')), 'wall' => array('label' => qa_lang_html('users/wall_posts'), 'tags' => 'name="wall"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_WALL_POSTS), 'note' => qa_lang_html('users/wall_posts_explanation')), 'mailings' => array('label' => qa_lang_html('users/mass_mailings'), 'tags' => 'name="mailings"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MAILINGS), 'note' => qa_lang_html('users/mass_mailings_explanation')), 'avatar' => null), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('users/save_profile'))), 'hidden' => array('dosaveprofile' => '1', 'code' => qa_get_form_security_code('account')));
if (qa_get_state() == 'profile-saved') {
$qa_content['form_profile']['ok'] = qa_lang_html('users/profile_saved');
}
if (!qa_opt('allow_private_messages')) {
unset($qa_content['form_profile']['fields']['messages']);
}
if (!qa_opt('allow_user_walls')) {
unset($qa_content['form_profile']['fields']['wall']);
}
if (!qa_opt('mailing_enabled')) {
unset($qa_content['form_profile']['fields']['mailings']);
}
if ($isblocked) {
unset($qa_content['form_profile']['buttons']['save']);
$qa_content['error'] = qa_lang_html('users/no_permission');
示例4: qa_lang
$errors['newpassword2'] = qa_lang('users/password_mismatch');
}
if (empty($errors)) {
qa_db_user_set_password($userid, $innewpassword1);
qa_db_user_set($userid, 'sessioncode', '');
// stop old 'Remember me' style logins from still working
qa_set_logged_in_user($userid, $useraccount['handle'], false, $useraccount['sessionsource']);
// reinstate this specific session
qa_report_event('u_password', $userid, $useraccount['handle'], qa_cookie_get());
qa_redirect('account', array('state' => 'password-changed'));
}
}
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('profile/my_account_title');
$qa_content['form_profile'] = array('tags' => 'ENCTYPE="multipart/form-data" METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('duration' => array('type' => 'static', 'label' => qa_lang_html('users/member_for'), 'value' => qa_time_to_string(qa_opt('db_time') - $useraccount['created'])), 'type' => array('type' => 'static', 'label' => qa_lang_html('users/member_type'), 'value' => qa_html(qa_user_level_string($useraccount['level']))), 'handle' => array('label' => qa_lang_html('users/handle_label'), 'tags' => 'NAME="handle"', 'value' => qa_html(isset($inhandle) ? $inhandle : $useraccount['handle']), 'error' => qa_html(@$errors['handle']), 'type' => $changehandle ? 'text' : 'static'), 'email' => array('label' => qa_lang_html('users/email_label'), 'tags' => 'NAME="email"', 'value' => qa_html(isset($inemail) ? $inemail : $useraccount['email']), 'error' => isset($errors['email']) ? qa_html($errors['email']) : ($doconfirms && !$isconfirmed ? qa_insert_login_links(qa_lang_html('users/email_please_confirm')) : null)), 'messages' => array('label' => qa_lang_html('users/private_messages'), 'tags' => 'NAME="messages"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES), 'note' => qa_lang_html('users/private_messages_explanation')), 'mailings' => array('label' => qa_lang_html('users/mass_mailings'), 'tags' => 'NAME="mailings"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MAILINGS), 'note' => qa_lang_html('users/mass_mailings_explanation')), 'avatar' => null), 'buttons' => array('save' => array('label' => qa_lang_html('users/save_profile'))), 'hidden' => array('dosaveprofile' => '1'));
if (qa_get_state() == 'profile-saved') {
$qa_content['form_profile']['ok'] = qa_lang_html('users/profile_saved');
}
if (!qa_opt('allow_private_messages')) {
unset($qa_content['form_profile']['fields']['messages']);
}
if (!qa_opt('mailing_enabled')) {
unset($qa_content['form_profile']['fields']['mailings']);
}
// Avatar upload stuff
if (qa_opt('avatar_allow_gravatar') || qa_opt('avatar_allow_upload')) {
$avataroptions = array();
if (qa_opt('avatar_default_show') && strlen(qa_opt('avatar_default_blobid'))) {
$avataroptions[''] = '<SPAN STYLE="margin:2px 0; display:inline-block;">' . qa_get_avatar_blob_html(qa_opt('avatar_default_blobid'), qa_opt('avatar_default_width'), qa_opt('avatar_default_height'), 32) . '</SPAN> ' . qa_lang_html('users/avatar_default');
} else {
示例5: qa_when_to_html
function qa_when_to_html($timestamp, $fulldatedays)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$interval = qa_opt('db_time') - $timestamp;
if ($interval < 0 || isset($fulldatedays) && $interval > 86400 * $fulldatedays) {
// full style date
$stampyear = date('Y', $timestamp);
$thisyear = date('Y', qa_opt('db_time'));
return array('data' => qa_html(strtr(qa_lang($stampyear == $thisyear ? 'main/date_format_this_year' : 'main/date_format_other_years'), array('^day' => date(qa_lang('main/date_day_min_digits') == 2 ? 'd' : 'j', $timestamp), '^month' => qa_lang('main/date_month_' . date('n', $timestamp)), '^year' => date(qa_lang('main/date_year_digits') == 2 ? 'y' : 'Y', $timestamp)))));
} else {
// ago-style date
return qa_lang_html_sub_split('main/x_ago', qa_html(qa_time_to_string($interval)));
}
}
示例6: qa_lang_html
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// Check to see if any were approved or blocked here
$pageerror = qa_admin_check_clicks();
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/approve_users_title');
$qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['message_list'] = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('admin/click'))), 'messages' => array());
if (count($users)) {
foreach ($users as $user) {
$message = array();
$message['tags'] = 'id="p' . qa_html($user['userid']) . '"';
// use p prefix for qa_admin_click() in qa-admin.js
$message['content'] = qa_lang_html('users/registered_label') . ' ' . strtr(qa_lang_html('users/x_ago_from_y'), array('^1' => qa_time_to_string(qa_opt('db_time') - $user['created']), '^2' => qa_ip_anchor_html($user['createip']))) . '<br/>';
$htmlemail = qa_html($user['email']);
$message['content'] .= qa_lang_html('users/email_label') . ' <a href="mailto:' . $htmlemail . '">' . $htmlemail . '</a>';
if (qa_opt('confirm_user_emails')) {
$message['content'] .= '<small> - ' . qa_lang_html($user['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED ? 'users/email_confirmed' : 'users/email_not_confirmed') . '</small>';
}
foreach ($userfields as $userfield) {
if (strlen(@$user['profile'][$userfield['title']])) {
$message['content'] .= '<br/>' . qa_html($userfield['content'] . ': ' . $user['profile'][$userfield['title']]);
}
}
$message['meta_order'] = qa_lang_html('main/meta_order');
$message['who']['data'] = qa_get_one_user_html($user['handle']);
$message['form'] = array('style' => 'light', 'buttons' => array('approve' => array('tags' => 'name="admin_' . $user['userid'] . '_userapprove" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/approve_button'), 'popup' => qa_lang_html('admin/approve_user_popup')), 'block' => array('tags' => 'name="admin_' . $user['userid'] . '_userblock" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('admin/block_button'), 'popup' => qa_lang_html('admin/block_user_popup'))));
$qa_content['message_list']['messages'][] = $message;
}
示例7: qa_content_prepare
}
}
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('misc/private_message_title');
$qa_content['error'] = @$page_error;
$qa_content['form_message'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $messagesent ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'NAME="message" ID="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 8, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('tags' => 'onClick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1'));
$qa_content['focusid'] = 'message';
if ($messagesent) {
$qa_content['form_message']['ok'] = qa_lang_html('misc/message_sent');
unset($qa_content['form_message']['fields']['message']['note']);
unset($qa_content['form_message']['buttons']);
}
// If relevant, show recent message history
if (qa_opt('show_message_history')) {
$recent = array_merge($torecent, $fromrecent);
qa_sort_by($recent, 'created');
$showmessages = array_slice(array_reverse($recent, true), 0, QA_DB_RETRIEVE_MESSAGES);
if (count($showmessages)) {
$qa_content['form_recent'] = array('title' => qa_lang_html_sub('misc/message_recent_history', qa_html($toaccount['handle'])), 'style' => 'tall', 'fields' => array());
foreach ($showmessages as $message) {
$qa_content['form_recent']['fields'][] = array('label' => qa_lang_html_sub($message['touserid'] == $toaccount['userid'] ? 'misc/message_sent_x_ago' : 'misc/message_received_x_ago', qa_html(qa_time_to_string(qa_opt('db_time') - $message['created']))), 'type' => 'static', 'value' => qa_viewer_html($message['content'], $message['format']));
}
}
}
$qa_content['raw']['account'] = $toaccount;
// for plugin layers to access
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
示例8: qw_activitylist
function qw_activitylist($limit)
{
$offset = (int) qa_get('start');
// get points for each activity
require_once QA_INCLUDE_DIR . 'qa-db-points.php';
require_once QA_INCLUDE_DIR . 'qa-db-users.php';
$optionnames = qa_db_points_option_names();
$options = qa_get_options($optionnames);
$multi = (int) $options['points_multiple'];
$upvote = '';
$downvote = '';
if (@$options['points_per_q_voted_up']) {
$upvote = '_up';
$downvote = '_down';
}
$event_point['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
$event_point['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
$event_point['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
$event_point['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
$event_point['a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
$event_point['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
$event_point['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
$event_point['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
$event_point['in_a_select'] = (int) $options['points_a_selected'] * $multi;
$event_point['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
$event_point['q_post'] = (int) $options['points_post_q'] * $multi;
$event_point['a_post'] = (int) $options['points_post_a'] * $multi;
$event_point['a_select'] = (int) $options['points_select_a'] * $multi;
$event_point['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
$event_point['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
$event_point['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
$event_point['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
// Get Events
$userid = qa_get_logged_in_userid();
$eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT id, UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params, `read` FROM ^ra_userevent WHERE effecteduserid=# AND event NOT IN ("u_wall_post", "u_message") ORDER BY datetime DESC LIMIT # OFFSET #', $userid, $limit, $offset));
if (count($eventslist) > 0) {
$event = array();
$output = '';
$i = 0;
//
$userids = array();
foreach ($eventslist as $event) {
$userids[$event['userid']] = $event['userid'];
$userids[$event['effecteduserid']] = $event['effecteduserid'];
}
if (QA_FINAL_EXTERNAL_USERS) {
$handles = qa_get_public_from_userids($userids);
} else {
$handles = qa_db_user_get_userid_handles($userids);
}
// get event's: time, type, parameters
// get post id of questions
foreach ($eventslist as $event) {
$title = '';
$link = '';
$vote_status = '';
$handle = isset($handles[$event['userid']]) ? $handles[$event['userid']] : qa_lang('main/anonymous');
$datetime = $event['datetime'];
$event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
$event['params'] = json_decode($event['params'], true);
$id = ' data-id="' . $event['id'] . '"';
$read = $event['read'] ? ' read' : ' unread';
$mark_as_read = !$event['read'] ? '<span class="icon icon-tick"></span>' : '';
$url_param = array('ra_notification' => $event['id']);
$user_link = qa_path_html('user/' . $handle, $url_param, QW_BASE_URL);
switch ($event['event']) {
case 'related':
// related question to an answer
$url = qa_path_html(qa_q_request($event['postid'], $event['params']['title']), $url_param, QW_BASE_URL, null, null);
echo '<div class="event-content clearfix' . $read . '' . $read . '"' . $id . '>
<div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div>
<div class="event-right">
<a href="' . $url . '">
<div class="head">
<strong class="user">' . $handle . '</strong>
<span class="what">' . qa_lang_html('dude/asked_question_related_to_your') . '</span>
<strong class="where">' . qa_lang_html('dude/answer') . '</strong>
</div>
<div class="footer">
<span class="event-icon icon-link"></span>
<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
</div>
</a>
</div>
</div>';
break;
case 'a_post':
// user's question had been answered
$anchor = qa_anchor('A', $event['postid']);
$url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
$title = qw_truncate($event['params']['qtitle'], 60);
echo '<div class="event-content clearfix' . $read . '"' . $id . '>
<div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div>
<div class="event-right">
<a href="' . $url . '">
<div class="head">
<strong class="user">' . $handle . '</strong>
<span class="what">' . qa_lang_html('dude/answered_your') . '</span>
<strong class="where">' . qa_lang_html('dude/question') . '</strong>
</div>
//.........这里部分代码省略.........
示例9: qa_other_to_q_html_fields
function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options)
{
$fields = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options);
switch ($question['obasetype']) {
case 'Q':
$fields['what'] = @$question['oedited'] ? qa_lang_html('main/edited') : null;
break;
case 'A':
$fields['what'] = @$question['oedited'] ? qa_lang_html('main/answer_edited') : qa_lang_html('main/answered');
break;
case 'C':
$fields['what'] = @$question['oedited'] ? qa_lang_html('main/comment_edited') : qa_lang_html('main/commented');
break;
}
if ($question['obasetype'] != 'Q') {
$fields['what_url'] = $fields['url'] . '#' . qa_html(urlencode(qa_anchor($question['obasetype'], $question['opostid'])));
}
if (@$options['whenview']) {
$fields['when'] = qa_lang_html_sub_split('main/x_ago', qa_html(qa_time_to_string(qa_opt('db_time') - $question['otime'])));
}
if (@$options['whoview']) {
$isbyuser = qa_post_is_by_user(array('userid' => $question['ouserid'], 'cookieid' => $question['ocookieid']), $userid, $cookieid);
$fields['who'] = qa_who_to_html($isbyuser, $question['ouserid'], $usershtml, @$options['ipview'] ? $question['oip'] : null, false);
if (isset($question['opoints'])) {
if (@$options['pointsview']) {
$fields['who']['points'] = $question['opoints'] == 1 ? qa_lang_html_sub_split('main/1_point', '1', '1') : qa_lang_html_sub_split('main/x_points', qa_html(number_format($question['opoints'])));
}
if (isset($options['pointstitle'])) {
$fields['who']['title'] = qa_get_points_title_html($question['opoints'], $options['pointstitle']);
}
}
if (isset($question['olevel'])) {
$fields['who']['level'] = qa_html(qa_user_level_string($question['olevel']));
}
}
unset($fields['flags']);
if (@$options['flagsview'] && @$post['oflagcount']) {
$fields['flags'] = $post['oflagcount'] == 1 ? qa_lang_html_sub_split('main/1_flag', '1', '1') : qa_lang_html_sub_split('main/x_flags', $post['oflagcount']);
}
unset($fields['avatar']);
if (!QA_FINAL_EXTERNAL_USERS && @$options['avatarsize'] > 0) {
$fields['avatar'] = qa_get_user_avatar_html($question['oflags'], $question['oemail'], $question['ohandle'], $question['oavatarblobid'], $question['oavatarwidth'], $question['oavatarheight'], $options['avatarsize']);
}
return $fields;
}
示例10: messagelist
function messagelist()
{
require_once QA_INCLUDE_DIR . 'qa-db-users.php';
// Get Events
$message_events = array('u_message', 'u_wall_post');
$events = "'" . implode("','", $message_events) . "'";
$userid = qa_get_logged_in_userid();
$eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE effecteduserid=# AND
DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime AND
event IN (' . $events . ')
ORDER BY datetime DESC' . (qa_opt('qat_activity_number') ? ' LIMIT ' . (int) qa_opt('qat_activity_number') : ''), $userid, qa_opt('qat_activity_age')));
$event = array();
$output = '';
//
$userids = array();
foreach ($eventslist as $event) {
$userids[$event['userid']] = $event['userid'];
$userids[$event['effecteduserid']] = $event['effecteduserid'];
}
$handles = qa_db_user_get_userid_handles($userids);
// get event's: time, type, parameters
// get post id of questions
foreach ($eventslist as $event) {
$title = '';
$link = '';
$handle = $handles[$event['userid']];
$user_link = qa_path('user/' . $handle);
$reciever_handle = $handles[$event['effecteduserid']];
$reciever_link = qa_path('user/' . $reciever_handle);
$datetime = $event['datetime'];
$event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
$event['params'] = json_decode($event['params'], true);
$message = substr($event['params']['message'], 0, 20);
$output .= '<li>';
switch ($event['event']) {
case 'u_message':
// related question to an answer
$url = qa_path_html(qa_path('message/' . $handle));
$output .= '<div class="event-icon pull-left icon-chat"></div>
<div class="event-content">
<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
<span class="what">left you a message</span>
</p>
<a class="title" href="' . $url . '">' . $message . '</a>
<span class="date"> ' . $event['date'] . '</span>
</div>';
break;
case 'u_wall_post':
// user's question had been answered
$url = qa_path_html(qa_path('user/' . $reciever_handle . '/wall'));
$output .= '<div class="event-icon pull-left icon-chat"></div>
<div class="event-content">
<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
<span class="what">posted a message on your wall</span>
</p>
<a class="title" href="' . $url . '">' . $message . '</a>
<span class="date"> ' . $event['date'] . '</span>
</div>';
break;
}
}
$output .= '</li>';
return $output;
}
示例11: user_activity_form
//.........这里部分代码省略.........
if (!qa_opt('badge_active') || !function_exists('qa_get_badge_type')) {
continue;
}
if ($post != null) {
if (strpos($post['type'], 'Q') !== 0) {
$anchor = qa_anchor(strpos($post['type'], 'A') === 0 ? 'A' : 'C', $params['postid']);
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT parentid,type,BINARY title as title,postid FROM ^posts WHERE postid=#', $post['parentid']), true);
if ($parent['type'] == 'A') {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT BINARY title as title,postid FROM ^posts WHERE postid=#', $parent['parentid']), true);
}
$activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
$link = '<a href="' . $activity_url . '">' . $parent['title'] . '</a>';
} else {
$activity_url = qa_path_html(qa_q_request($params['postid'], $post['title']), null, qa_opt('site_url'), null, null);
$link = '<a href="' . $activity_url . '">' . $post['title'] . '</a>';
}
}
} else {
if ($post != null && strpos($event['event'], 'q_') !== 0 && strpos($event['event'], 'in_q_') !== 0) {
// comment or answer
if (!isset($params['parentid'])) {
$params['parentid'] = $post['parentid'];
}
$parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $params['parentid']));
if ($parent['type'] == 'A') {
$parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $parent['parentid']));
}
$anchor = qa_anchor(strpos($event['event'], 'a_') === 0 || strpos($event['event'], 'in_a_') === 0 ? 'A' : 'C', $params['postid']);
$activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
$link = '<a href="' . $activity_url . '">' . $parent['title'] . '</a>';
} else {
if ($post != null) {
// question
if (!isset($params['title'])) {
$params['title'] = $posts[$params['postid']]['title'];
}
if ($params['title'] !== null) {
$activity_url = qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url'));
$link = '<a href="' . $activity_url . '">' . $params['title'] . '</a>';
}
}
}
}
}
$time = $event['datetime'];
if (qa_opt('user_act_list_shading')) {
$days = (qa_opt('db_time') - $time) / 60 / 60 / 24;
$col = round($days / qa_opt('user_act_list_age') * 255 / 2);
$bkg = 255 - round($days / qa_opt('user_act_list_age') * 255 / 8);
$bkg = dechex($bkg);
$col = dechex($col);
if (strlen($col) == 1) {
$col = '0' . $col;
}
if (strlen($bkg) == 1) {
$bkg = '0' . $bkg;
}
$col = '#' . $col . $col . $col;
$bkg = '#' . $bkg . $bkg . $bkg;
}
$whenhtml = qa_html(qa_time_to_string(qa_opt('db_time') - $time));
$when = qa_lang_html_sub('main/x_ago', $whenhtml);
$when = str_replace(' ', '<br/>', $when);
$when = preg_replace('/([0-9]+)/', '<span class="qa-history-item-date-no">$1</span>', $when);
if (strpos($type, '_vote_nil') == 4) {
if ($params['oldvote'] == '1') {
// unvoting an upvote
$points = @$option_events[str_replace('_vote_nil', '_unvote_up', $type)];
} else {
// unvoting a downvote
$points = @$option_events[str_replace('_vote_nil', '_unvote_down', $type)];
}
} else {
$points = @$option_events[$type];
}
$string = qa_opt('user_act_list_' . $type);
if ($type == 'badge_awarded') {
$slug = $params['badge_slug'];
$typea = qa_get_badge_type_by_slug($slug);
if (!$typea) {
continue;
}
$types = $typea['slug'];
$typed = $typea['name'];
$badge_name = qa_badge_name($slug);
if (!qa_opt('badge_' . $slug . '_name')) {
qa_opt('badge_' . $slug . '_name', $badge_name);
}
$var = qa_opt('badge_' . $slug . '_var');
$name = qa_opt('badge_' . $slug . '_name');
$desc = qa_badge_desc_replace($slug, $var, false);
$string = str_replace('^badge', '<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '</span>', $string);
}
$fields[] = array('type' => 'static', 'label' => '<div class="qa-history-item-date' . ($time >= $last_visit && strpos($type, 'in_') === 0 ? ' qa-history-item-date-new' : '') . '"' . (qa_opt('user_act_list_shading') ? ' style="color:' . $col . ';background-color:' . $bkg . '"' : '') . '>' . $when . '</div>', 'value' => '<table class="qa-history-item-table"><tr><td class="qa-history-item-type-cell"><div class="qa-history-item-type qa-history-item-' . $type . '">' . $string . '</div></td><td class="qa-history-item-title-cell"><div class="qa-history-item-title">' . $link . '</div></td class="qa-history-item-points-cell"><td align="right">' . ($points ? '<div class="qa-history-item-points qa-history-item-points-' . ($points < 0 ? 'neg">' : 'pos">+') . $points . '</div>' : ' ') . '</td></tr></table>');
}
if (empty($fields)) {
return;
}
return array('style' => 'wide', 'title' => qa_opt('user_act_list_title'), 'fields' => $fields);
}
示例12: process_request
//.........这里部分代码省略.........
}
if ($params['title'] !== null) {
$qTitle = qa_db_read_one_value(qa_db_query_sub("SELECT title FROM `^posts` WHERE `postid` = " . $params['postid'] . " LIMIT 1"), true);
if (!isset($qTitle)) {
$qTitle = '';
}
$activity_url = qa_path_absolute(qa_q_request($params['postid'], $qTitle), null, null);
$linkTitle = $qTitle;
$link = '<a target="_blank" href="' . $activity_url . '">' . $qTitle . '</a>';
}
}
}
// event name
$eventName = '';
$itemIcon = '';
if ($type == 'in_c_question' || $type == 'in_c_answer' || $type == 'in_c_comment') {
// added in_c_comment
$eventName = qa_lang('q2apro_onsitenotifications_lang/in_comment');
$itemIcon = '<div class="nicon ncomment"></div>';
} else {
if ($type == 'in_q_vote_up' || $type == 'in_a_vote_up') {
$eventName = qa_lang('q2apro_onsitenotifications_lang/in_upvote');
$itemIcon = '<div class="nicon nvoteup"></div>';
} else {
if ($type == 'in_q_vote_down' || $type == 'in_a_vote_down') {
$eventName = qa_lang('q2apro_onsitenotifications_lang/in_downvote');
$itemIcon = '<div class="nicon nvotedown"></div>';
} else {
if ($type == 'in_a_question') {
$eventName = qa_lang('q2apro_onsitenotifications_lang/in_answer');
$itemIcon = '<div class="nicon nanswer"></div>';
} else {
if ($type == 'in_a_select') {
$eventName = qa_lang('q2apro_onsitenotifications_lang/in_bestanswer');
$itemIcon = '<div class="nicon nbestanswer"></div>';
} else {
// ignore other events such as in_c_flag
continue;
}
}
}
}
}
}
}
// end a_post, c_post, q_vote_up, a_vote_up, q_vote_down, a_vote_down
$eventtime = $event['datetime'];
$whenhtml = qa_html(qa_time_to_string(qa_opt('db_time') - $eventtime));
$when = qa_lang_html_sub('main/x_ago', $whenhtml);
// extra CSS for highlighting new events
$cssNewEv = '';
if ($eventtime > $last_visit) {
$cssNewEv = '-new';
}
// if post has been deleted there is no link, dont output
if ($activity_url == '') {
continue;
} else {
$notifyBoxEvents .= '<div class="itemBox' . $cssNewEv . '">
' . $itemIcon . '
<div class="nfyItemLine">
<p class="nfyWhat">' . $eventName . '
<a ' . ($type == 'u_message' || $type == 'u_wall_post' ? 'title="' . $event['message'] . '" ' : '') . 'href="' . $activity_url . '"' . (qa_opt('q2apro_onsitenotifications_newwindow') ? ' target="_blank"' : '') . '>' . $linkTitle . '</a>
</p>
<p class="nfyTime">' . $when . '</p>
</div>
</div>';
}
}
// END FOREACH
$notifyBoxEvents .= '</div>
</div>
<div class="nfyFooter">
<a href="http://www.q2apro.com/">by q2apro.com</a>
</div>
</div>
';
header('Access-Control-Allow-Origin: ' . qa_path(null));
echo $notifyBoxEvents;
// update database entry so that all user notifications are seen as read
qa_db_query_sub('INSERT INTO ^usermeta (user_id,meta_key,meta_value) VALUES(#,$,NOW()) ON DUPLICATE KEY UPDATE meta_value=NOW()', $userid, 'visited_profile');
exit;
} else {
echo 'Unexpected problem detected! No userid, no transfer string.';
exit;
}
}
/* start */
$qa_content = qa_content_prepare();
$qa_content['title'] = '';
// page title
// return if not admin!
if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
$qa_content['error'] = '<p>Access denied</p>';
return $qa_content;
} else {
$qa_content['custom'] = '<p>Hi Admin, it actually makes no sense to call the Ajax URL directly.</p>';
}
return $qa_content;
}
开发者ID:Kasparohub,项目名称:q2apro-on-site-notifications,代码行数:101,代码来源:q2apro-onsitenotifications-page.php