本文整理汇总了PHP中wppa_get_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wppa_get_user函数的具体用法?PHP wppa_get_user怎么用?PHP wppa_get_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wppa_get_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wppa_get_photo_count
function wppa_get_photo_count($id = '0', $use_treecounts = false)
{
global $wpdb;
if ($use_treecounts) {
$treecounts = wppa_treecount_a($id);
if (current_user_can('wppa_moderate')) {
$count = $treecounts['selfphotos'] + $treecounts['pendphotos'] + $treecounts['scheduledphotos'];
} else {
$count = $treecounts['selfphotos'];
}
} elseif (!$id) {
if (current_user_can('wppa_moderate')) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` ");
} else {
$count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS, "` WHERE ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR owner = %s )", wppa_get_user());
}
} else {
if (current_user_can('wppa_moderate')) {
$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM " . WPPA_PHOTOS . " WHERE album = %s", $id));
} else {
$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM " . WPPA_PHOTOS . " WHERE `album` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR owner = %s )", $id, wppa_get_user()));
}
wppa_dbg_q('Q-gpc');
}
// Substract private photos if not logged in and album given
if ($id && !is_user_logged_in()) {
$count -= $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` = 'private' ", $id));
}
return $count;
}
开发者ID:billadams,项目名称:forever-frame,代码行数:30,代码来源:wppa-statistics.php
示例2: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
global $wpdb;
require_once dirname(__FILE__) . '/wppa-links.php';
require_once dirname(__FILE__) . '/wppa-styles.php';
require_once dirname(__FILE__) . '/wppa-functions.php';
require_once dirname(__FILE__) . '/wppa-thumbnails.php';
require_once dirname(__FILE__) . '/wppa-boxes-html.php';
require_once dirname(__FILE__) . '/wppa-slideshow.php';
wppa_initialize_runtime();
wppa('in_widget', 'albnav');
wppa_bump_mocc();
extract($args);
$instance = wp_parse_args((array) $instance, array('title' => '', 'parent' => '0', 'skip' => 'yes'));
$widget_title = apply_filters('widget_title', $instance['title']);
$page = wppa_get_the_landing_page('album_navigator_widget_linkpage', __('Photo Albums', 'wp-photo-album-plus'));
$parent = $instance['parent'];
$skip = $instance['skip'];
$widget_content = "\n" . '<!-- WPPA+ Album Navigator Widget start -->';
$widget_content .= '<div style="width:100%; overflow:hidden; position:relative; left: -12px;" >';
if ($parent == 'all') {
$widget_content .= $this->do_album_navigator('0', $page, $skip, '');
$widget_content .= $this->do_album_navigator('-1', $page, $skip, '');
} elseif ($parent == 'owner') {
$widget_content .= $this->do_album_navigator('0', $page, $skip, '', " AND ( `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ) ");
$widget_content .= $this->do_album_navigator('-1', $page, $skip, '', " AND ( `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ) ");
} else {
$widget_content .= $this->do_album_navigator($parent, $page, $skip, '');
}
$widget_content .= '</div>';
$widget_content .= '<div style="clear:both"></div>';
$widget_content .= "\n" . '<!-- WPPA+ Album Navigator Widget end -->';
echo "\n" . $before_widget;
if (!empty($widget_title)) {
echo $before_title . $widget_title . $after_title;
}
echo $widget_content . $after_widget;
wppa('in_widget', false);
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:40,代码来源:wppa-album-navigator-widget.php
示例3: wppa_get_edit_search_photos
function wppa_get_edit_search_photos($limit = '', $count_only = false)
{
global $wpdb;
global $wppa_search_stats;
$doit = false;
// if ( wppa_user_is( 'administrator' ) ) $doit = true;
if (current_user_can('wppa_admin') && current_user_can('wppa_moderate')) {
$doit = true;
}
if (wppa_switch('upload_edit')) {
$doit = true;
}
if (!$doit) {
// Should never get here. Only when url is manipulted manually.
die('Security check failure #309');
}
$words = explode(',', wppa_sanitize_searchstring($_REQUEST['wppa-searchstring']));
$wppa_search_stats = array();
$first = true;
foreach ($words as $word) {
// Find lines in index db table
if (wppa_switch('wild_front')) {
$pidxs = $wpdb->get_results("SELECT `slug`, `photos` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '%" . $word . "%'", ARRAY_A);
} else {
$pidxs = $wpdb->get_results("SELECT `slug`, `photos` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '" . $word . "%'", ARRAY_A);
}
$photos = '';
foreach ($pidxs as $pi) {
$photos .= $pi['photos'] . ',';
}
if ($first) {
$photo_array = wppa_index_array_remove_dups(wppa_index_string_to_array(trim($photos, ',')));
$count = empty($photo_array) ? '0' : count($photo_array);
$list = implode(',', $photo_array);
if (!$list) {
$list = '0';
}
// if ( wppa_user_is( 'administrator' ) ) {
if (current_user_can('wppa_admin') && current_user_can('wppa_moderate')) {
$real_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") ");
if ($count != $real_count) {
update_option('wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus'));
// echo 'realcount mismatch:1';
// echo ' count='.$count.', realcount='.$real_count.'<br/>';
}
} else {
// Not admin, can edit own photos only
$real_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") AND `owner` = %s", wppa_get_user()));
}
$wppa_search_stats[] = array('word' => $word, 'count' => $real_count);
$first = false;
} else {
$temp_array = wppa_index_array_remove_dups(wppa_index_string_to_array(trim($photos, ',')));
$count = empty($temp_array) ? '0' : count($temp_array);
$list = implode(',', $temp_array);
// if ( wppa_user_is( 'administrator' ) ) {
if (current_user_can('wppa_admin') && current_user_can('wppa_moderate')) {
$real_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") ");
if ($count != $real_count) {
update_option('wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus'));
// echo 'realcount mismatch:2';
// echo ' count='.$count.', realcount='.$real_count.'<br/>';
}
} else {
// Not admin, can edit own photos only
$real_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") AND `owner` = %s", wppa_get_user()));
}
$wppa_search_stats[] = array('word' => $word, 'count' => $real_count);
$photo_array = array_intersect($photo_array, $temp_array);
}
}
if (!empty($photo_array)) {
$list = implode(',', $photo_array);
// if ( wppa_user_is( 'administrator' ) ) {
if (current_user_can('wppa_admin') && current_user_can('wppa_moderate')) {
$totcount = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") ");
} else {
// Not admin, can edit own photos only
$totcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") AND `owner` = %s", wppa_get_user()));
}
$wppa_search_stats[] = array('word' => __('Combined', 'wp-photo-album-plus'), 'count' => $totcount);
// if ( wppa_user_is( 'administrator' ) ) {
if (current_user_can('wppa_admin') && current_user_can('wppa_moderate')) {
$photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") " . wppa_get_photo_order('0', 'norandom') . $limit, ARRAY_A);
} else {
// Not admin, can edit own photos only
$photos = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` IN (" . $list . ") AND `owner` = %s" . wppa_get_photo_order('0', 'norandom') . $limit, wppa_get_user()), ARRAY_A);
}
} else {
$photos = false;
}
if ($count_only) {
if (is_array($photos)) {
return count($photos);
} else {
return '0';
}
} else {
return $photos;
}
//.........这里部分代码省略.........
开发者ID:msayagh,项目名称:Quercus-source-code-Maven,代码行数:101,代码来源:wppa-photo-admin-autosave.php
示例4: wppa_insert_photo
function wppa_insert_photo($file = '', $alb = '', $name = '', $desc = '', $porder = '0', $id = '0', $linkurl = '', $linktitle = '')
{
global $wpdb;
global $warning_given_small;
$album = wppa_cache_album($alb);
if (!wppa_allow_uploads($alb)) {
if (is_admin() && !wppa('ajax')) {
wppa_error_message(sprintf(__('Album %s is full', 'wp-photo-album-plus'), wppa_get_album_name($alb)));
} else {
wppa_alert(sprintf(__('Album %s is full', 'wp-photo-album-plus'), wppa_get_album_name($alb)));
}
return false;
}
if ($file != '' && $alb != '') {
// Get the name if not given
if ($name == '') {
$name = basename($file);
}
// Sanitize name
$filename = wppa_sanitize_file_name($name);
$name = wppa_sanitize_photo_name($name);
// If not dups allowed and its already here, quit
if (isset($_POST['wppa-nodups']) || wppa_switch('void_dups')) {
$exists = wppa_file_is_in_album($filename, $alb);
if ($exists) {
if (isset($_POST['del-after-p'])) {
unlink($file);
$msg = __('Photo %s already exists in album number %s. Removed from depot.', 'wp-photo-album-plus');
} else {
$msg = __('Photo %s already exists in album number %s.', 'wp-photo-album-plus');
}
wppa_warning_message(sprintf($msg, $name, $alb));
return false;
}
}
// Verify file exists
if (!wppa('is_remote') && !file_exists($file)) {
if (!is_dir(dirname($file))) {
wppa_error_message('Error: Directory ' . dirname($file) . ' does not exist.');
return false;
}
if (!is_writable(dirname($file))) {
wppa_error_message('Error: Directory ' . dirname($file) . ' is not writable.');
return false;
}
wppa_error_message('Error: File ' . $file . ' does not exist.');
return false;
}
// else {
// wppa_ok_message( 'Good: File '.$file.' exists.' );
// }
// Get and verify the size
$img_size = getimagesize($file);
if ($img_size) {
if (wppa_check_memory_limit('', $img_size['0'], $img_size['1']) === false) {
wppa_error_message(sprintf(__('ERROR: Attempt to upload a photo that is too large to process (%s).', 'wp-photo-album-plus'), $name) . wppa_check_memory_limit());
wppa('ajax_import_files_error', __('Too big', 'wp-photo-album-plus'));
return false;
}
if (!$warning_given_small && ($img_size['0'] < wppa_get_minisize() && $img_size['1'] < wppa_get_minisize())) {
wppa_warning_message(__('WARNING: You are uploading photos that are too small. Photos must be larger than the thumbnail size and larger than the coverphotosize.', 'wp-photo-album-plus'));
wppa('ajax_import_files_error', __('Too small', 'wp-photo-album-plus'));
$warning_given_small = true;
}
} else {
wppa_error_message(__('ERROR: Unable to retrieve image size of', 'wp-photo-album-plus') . ' ' . $name . ' ' . __('Are you sure it is a photo?', 'wp-photo-album-plus'));
wppa('ajax_import_files_error', __('No imagesize', 'wp-photo-album-plus'));
return false;
}
// Get ext based on mimetype, regardless of ext
switch ($img_size[2]) {
// mime type
case 1:
$ext = 'gif';
break;
case 2:
$ext = 'jpg';
break;
case 3:
$ext = 'png';
break;
default:
wppa_error_message(__('Unsupported mime type encountered:', 'wp-photo-album-plus') . ' ' . $img_size[2] . '.');
return false;
}
// Get an id if not yet there
if ($id == '0') {
$id = wppa_nextkey(WPPA_PHOTOS);
}
// Get opt deflt desc if empty
if ($desc == '' && wppa_switch('apply_newphoto_desc')) {
$desc = stripslashes(wppa_opt('newphoto_description'));
}
// Reset rating
$mrat = '0';
// Find ( new ) owner
$owner = wppa_get_user();
// Validate album
if (!is_numeric($alb) || $alb < '1') {
wppa_error_message(__('Album not known while trying to add a photo', 'wp-photo-album-plus'));
//.........这里部分代码省略.........
开发者ID:msayagh,项目名称:Quercus-source-code-Maven,代码行数:101,代码来源:wppa-admin-functions.php
示例5: wppa_album_select_a
//.........这里部分代码省略.........
break;
}
}
// Filter for must have content
if ($args['content']) {
foreach (array_keys($albums) as $albidx) {
if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) {
unset($albums[$albidx]);
}
}
}
// Add paths
if ($args['path']) {
$albums = wppa_add_paths($albums);
} else {
foreach (array_keys($albums) as $index) {
$albums[$index]['name'] = __(stripslashes($albums[$index]['name']));
}
}
// Sort
if ($args['sort']) {
$albums = wppa_array_sort($albums, 'name');
}
}
// Output
$result = '';
$selected = $args['selected'] == '0' ? ' selected="selected"' : '';
if ($args['addpleaseselect']) {
$result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . (is_admin() ? __('- select an album -', 'wppa') : __a('- select an album -')) . '</option>';
}
$selected = $args['selected'] == '0' ? ' selected="selected"' : '';
if ($args['addnone']) {
$result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- none ---', 'wppa') : __a('--- none ---')) . '</option>';
}
$selected = $args['selected'] == '0' ? ' selected="selected"' : '';
if ($args['addall']) {
$result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- all ---', 'wppa') : __a('--- all ---')) . '</option>';
}
$selected = $args['selected'] == '-2' ? ' selected="selected"' : '';
if ($args['addall']) {
$result .= '<option value="-2"' . $selected . ' >' . (is_admin() ? __('--- generic ---', 'wppa') : __a('--- generic ---')) . '</option>';
}
$selected = $args['selected'] == '0' ? ' selected="selected"' : '';
if ($args['addblank']) {
$result .= '<option value="0"' . $selected . ' >' . '</option>';
}
$selected = $args['selected'] == '-99' ? ' selected="selected"' : '';
if ($args['addmultiple']) {
$result .= '<option value="-99"' . $selected . ' >' . (is_admin() ? __('--- multiple see below ---', 'wppa') : __a('--- multiple see below ---')) . '</option>';
}
$selected = $args['selected'] == '0' ? ' selected="selected"' : '';
if ($args['addselbox']) {
$result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- a selection box ---', 'wppa') : __a('--- a selection box ---')) . '</option>';
}
if ($albums) {
foreach ($albums as $album) {
if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) {
$disabled = ' disabled="disabled"';
} else {
$disabled = '';
}
if ($args['selected'] == $album['id'] && !$disabled) {
$selected = ' selected="selected"';
} else {
$selected = '';
}
$ok = true;
// Assume this will be in the list
if ($args['checkaccess'] && !wppa_have_access($album['id'])) {
$ok = false;
}
if ($args['checkowner'] && wppa_switch('upload_owner_only')) {
// Need to check
if ($album['owner'] != wppa_get_user() && $album['owner'] != '--- public ---') {
// Not 'mine'
if (!wppa_user_is('administrator')) {
// No admin
$ok = false;
}
}
}
if ($selected && $args['addselected']) {
$ok = true;
}
if ($ok) {
if ($args['addnumbers']) {
$number = ' ( ' . $album['id'] . ' )';
} else {
$number = '';
}
$result .= '<option value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>';
}
}
}
$selected = $args['selected'] == '-1' ? ' selected="selected"' : '';
if ($args['addseparate']) {
$result .= '<option value="-1"' . $selected . '>' . (is_admin() ? __('--- separate ---', 'wppa') : __a('--- separate ---')) . '</option>';
}
return $result;
}
开发者ID:billadams,项目名称:forever-frame,代码行数:101,代码来源:wppa-common-functions.php
示例6: wppa_import_photos
function wppa_import_photos($delp = false, $dela = false, $delz = false, $delv = false, $delu = false, $delc = false, $delf = false)
{
global $wpdb;
global $warning_given;
global $wppa_supported_photo_extensions;
global $wppa_supported_video_extensions;
global $wppa_supported_audio_extensions;
$warning_given = false;
// Get this users current source directory setting
$user = wppa_get_user();
$source_type = get_option('wppa_import_source_type_' . $user, 'local');
if ($source_type == 'remote') {
wppa('is_remote', true);
}
$source = get_option('wppa_import_source_' . $user, WPPA_DEPOT_PATH);
$depot = WPPA_ABSPATH . $source;
// Filesystem
$depoturl = get_bloginfo('wpurl') . '/' . $source;
// url
// See what's in there
$files = wppa_get_import_files();
// First extract zips if our php version is ok
$idx = '0';
$zcount = 0;
if (PHP_VERSION_ID >= 50207) {
foreach ($files as $zipfile) {
if (isset($_POST['file-' . $idx])) {
$ext = strtolower(substr(strrchr($zipfile, "."), 1));
if ($ext == 'zip') {
$err = wppa_extract($zipfile, $delz);
if ($err == '0') {
$zcount++;
}
}
// if ext = zip
}
// if isset
$idx++;
}
// foreach
}
// Now see if albums must be created
$idx = '0';
$acount = 0;
foreach ($files as $album) {
if (isset($_POST['file-' . $idx])) {
$ext = strtolower(substr(strrchr($album, "."), 1));
if ($ext == 'amf') {
$name = '';
$desc = '';
$aord = '0';
$parent = '0';
$porder = '0';
$owner = '';
$handle = fopen($album, "r");
if ($handle) {
$buffer = fgets($handle, 4096);
while (!feof($handle)) {
$tag = substr($buffer, 0, 5);
$len = strlen($buffer) - 6;
// substract 5 for label and one for eol
$data = substr($buffer, 5, $len);
switch ($tag) {
case 'name=':
$name = $data;
break;
case 'desc=':
$desc = wppa_txt_to_nl($data);
break;
case 'aord=':
if (is_numeric($data)) {
$aord = $data;
}
break;
case 'prnt=':
if ($data == __('--- none ---', 'wp-photo-album-plus')) {
$parent = '0';
} elseif ($data == __('--- separate ---', 'wp-photo-album-plus')) {
$parent = '-1';
} else {
$prnt = wppa_get_album_id($data);
if ($prnt != '') {
$parent = $prnt;
} else {
$parent = '0';
wppa_warning_message(__('Unknown parent album:', 'wp-photo-album-plus') . ' ' . $data . ' ' . __('--- none --- used.', 'wp-photo-album-plus'));
}
}
break;
case 'pord=':
if (is_numeric($data)) {
$porder = $data;
}
break;
case 'ownr=':
$owner = $data;
break;
}
$buffer = fgets($handle, 4096);
}
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:wppa-import.php
示例7: wppa_backend_upload_mail
function wppa_backend_upload_mail($id, $alb, $name)
{
$owner = wppa_get_user();
if ($owner == 'admin') {
return;
}
// Admin does not send mails to himself
if (wppa_switch('upload_backend_notify')) {
$to = get_bloginfo('admin_email');
$subj = sprintf(__('New photo uploaded: %s', 'wp-photo-album-plus'), wppa_sanitize_file_name($name));
$cont['0'] = sprintf(__('User %1$s uploaded photo %2$s into album %3$s', 'wp-photo-album-plus'), $owner, $id, wppa_get_album_name($alb));
if (wppa_switch('upload_moderate') && !current_user_can('wppa_admin')) {
$cont['1'] = __('This upload requires moderation', 'wp-photo-album-plus');
$cont['2'] = '<a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Moderate manage photo', 'wp-photo-album-plus') . '</a>';
} else {
$cont['1'] = __('Details:', 'wp-photo-album-plus');
$cont['1'] .= ' <a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Manage photo', 'wp-photo-album-plus') . '</a>';
}
wppa_send_mail($to, $subj, $cont, $id);
}
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:21,代码来源:wppa-upload.php
示例8: wppa_get_session_id
function wppa_get_session_id()
{
global $wppa_api_version;
$id = md5($_SERVER['REMOTE_ADDR'] . wppa_get_user() . $_SERVER["HTTP_USER_AGENT"] . $wppa_api_version);
return $id;
}
开发者ID:billadams,项目名称:forever-frame,代码行数:6,代码来源:wppa-session.php
示例9: wppa_log
function wppa_log($type, $msg)
{
// Log debug messages only if WP_DEBUG is defined as true
if ($type == 'dbg') {
if (!defined('WP_DEBUG') || !WP_DEBUG) {
return;
}
}
@wppa_mktree(WPPA_CONTENT_PATH . '/wppa-depot/admin');
// Just in case...
$filename = WPPA_CONTENT_PATH . '/wppa-depot/admin/error.log';
if (is_file($filename)) {
$filesize = filesize($filename);
if ($filesize > 102400) {
// File > 100kB
$file = fopen($filename, 'rb');
if ($file) {
$buffer = @fread($file, $filesize);
$buffer = substr($buffer, $filesize - 90 * 1024);
// Take ending 90 kB
fclose($file);
$file = fopen($filename, 'wb');
@fwrite($file, $buffer);
@fclose($file);
}
}
}
if (!($file = fopen($filename, 'ab'))) {
return;
}
// Unable to open log file
@fwrite($file, $type . ': on:' . wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), time()) . ': ' . wppa_get_user() . ' ' . $msg . "\n");
// To prevent recursive error reporting, do not use wppa_switch!!!
//if ( wppa_switch( 'wppa_debug_trace_on' ) ) {
if (get_option('wppa_debug_trace_on') == 'yes') {
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = ob_get_contents();
ob_end_clean();
@fwrite($file, $trace . "\n");
}
@fclose($file);
}
开发者ID:billadams,项目名称:forever-frame,代码行数:43,代码来源:wppa-utils.php
示例10: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
global $wpdb;
require_once dirname(__FILE__) . '/wppa-links.php';
require_once dirname(__FILE__) . '/wppa-styles.php';
require_once dirname(__FILE__) . '/wppa-functions.php';
require_once dirname(__FILE__) . '/wppa-thumbnails.php';
require_once dirname(__FILE__) . '/wppa-boxes-html.php';
require_once dirname(__FILE__) . '/wppa-slideshow.php';
wppa_initialize_runtime();
wppa('in_widget', 'upldr');
wppa_bump_mocc();
extract($args);
$instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'name', 'ignore' => 'admin', 'parent' => ''));
$widget_title = apply_filters('widget_title', $instance['title']);
$page = in_array('album', wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_upldr_widget_linkpage', __('User uploaded photos', 'wp-photo-album-plus'));
$ignorelist = explode(',', $instance['ignore']);
$upldrcache = wppa_get_upldr_cache();
$needupdate = false;
$users = wppa_get_users();
$workarr = array();
$selalbs = str_replace('.', ',', wppa_expand_enum(wppa_alb_to_enum_children(wppa_expand_enum($instance['parent']))));
// Make the data we need
if ($users) {
foreach ($users as $user) {
if (!in_array($user['user_login'], $ignorelist)) {
$me = wppa_get_user();
if ($user['user_login'] != $me && isset($upldrcache[$this->get_widget_id()][$user['user_login']]['c'])) {
$photo_count = $upldrcache[$this->get_widget_id()][$user['user_login']]['c'];
} else {
if ($instance['parent']) {
$query = $wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND `album` IN (" . $selalbs . ") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me);
//);
} else {
$query = $wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me);
//);
}
$photo_count = $wpdb->get_var($query);
if ($user['user_login'] != $me) {
$upldrcache[$this->get_widget_id()][$user['user_login']]['c'] = $photo_count;
$needupdate = true;
}
}
if ($photo_count) {
if ($user['user_login'] != $me && isset($upldrcache[$this->get_widget_id()][$user['user_login']]['d'])) {
$last_dtm = $upldrcache[$this->get_widget_id()][$user['user_login']]['d'];
} else {
if ($instance['parent']) {
$last_dtm = $wpdb->get_var($wpdb->prepare("SELECT `timestamp` FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND `album` IN (" . $selalbs . ") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me));
} else {
$last_dtm = $wpdb->get_var($wpdb->prepare("SELECT `timestamp` FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me));
}
}
if ($user['user_login'] != $me) {
$upldrcache[$this->get_widget_id()][$user['user_login']]['d'] = $last_dtm;
$needupdate = true;
}
$workarr[] = array('login' => $user['user_login'], 'name' => $user['display_name'], 'count' => $photo_count, 'date' => $last_dtm);
}
}
}
} else {
$widget_content = __('There are too many registered users in the system for this widget', 'wp-photo-album-plus');
echo "\n" . $before_widget;
if (!empty($widget_title)) {
echo $before_title . $widget_title . $after_title;
}
echo $widget_content . $after_widget;
return;
}
if ($needupdate) {
update_option('wppa_upldr_cache', $upldrcache);
}
// Bring me to top
$myline = false;
if (is_user_logged_in()) {
$me = wppa_get_user();
foreach (array_keys($workarr) as $key) {
$user = $workarr[$key];
if ($user['login'] == $me) {
$myline = $workarr[$key];
unset($workarr[$key]);
}
}
}
// Sort workarray
$ord = $instance['sortby'] == 'name' ? SORT_ASC : SORT_DESC;
$workarr = wppa_array_sort($workarr, $instance['sortby'], $ord);
// Create widget content
$widget_content = "\n" . '<!-- WPPA+ Upldr Widget start -->';
$widget_content .= '<div class="wppa-upldr" style="max-height:180px; overflow:auto"><table><tbody>';
$albs = $instance['parent'] ? wppa_alb_to_enum_children(wppa_expand_enum($instance['parent'])) : '';
$a = $albs ? wppa_trim_wppa_('&wppa-album=' . $albs) : '';
if ($myline) {
$user = $myline;
$widget_content .= '<tr class="wppa-user" >
<td style="padding: 0 3px;" ><a href="' . wppa_get_upldr_link($user['login']) . $a . '" title="' . __('Photos uploaded by', 'wp-photo-album-plus') . ' ' . $user['name'] . '" ><b>' . $user['name'] . '</b></a></td>
<td style="padding: 0 3px;" ><b>' . $user['count'] . '</b></td>
<td style="padding: 0 3px;" ><b>' . wppa_get_time_since($user['date']) . '</b></td>
//.........这里部分代码省略.........
开发者ID:lchen01,项目名称:STEdwards,代码行数:101,代码来源:wppa-upldr-widget.php
示例11: wppa_maintenance_button
function wppa_maintenance_button($slug)
{
$label = __('Start!', 'wp-photo-album-plus');
$me = wppa_get_user();
$user = get_option($slug . '_user', $me);
if ($user && $user != $me) {
$label = __('Locked!', 'wp-photo-album-plus');
$locked = true;
} else {
$locked = false;
}
$result = '<input id="' . $slug . '_button" type="button" class="button-secundary" style="float:left; border-radius:3px; font-size: 11px; height: 18px; margin: 0 4px; padding: 0px;" value="' . $label . '"';
if (!$locked) {
$result .= ' onclick="if ( jQuery(\'#' . $slug . '_status\').html() != \'\' || confirm(\'Are you sure ?\') ) wppaMaintenanceProc(\'' . $slug . '\', false);" />';
} else {
$result .= ' onclick="alert(\'Is currently being executed by ' . $user . '.\')" />';
}
$result .= '<input id="' . $slug . '_continue" type="hidden" value="no" />';
return $result;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:20,代码来源:wppa-settings-autosave.php
示例12: wppa_get_coverphoto_ids
function wppa_get_coverphoto_ids($alb, $count)
{
global $wpdb;
if (!$alb) {
return false;
}
// no album, no coverphoto
// Find cover photo id
$id = wppa_get_album_item($alb, 'main_photo');
// main_photo is a positive integer ( photo id )?
if ($id > '0') {
// 1 coverphoto explicitly given
$photo = wppa_cache_photo($id);
if (!$photo) {
// Photo gone, set id to 0
$id = '0';
} elseif ($photo['album'] != $alb) {
// Photo moved to other album, set id to 0
$id = '0';
} else {
$temp['0'] = $photo;
// Found!
}
}
// main_photo is 0? Random
if ('0' == $id) {
if (current_user_can('wppa_moderate')) {
$temp = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s ORDER BY RAND( " . wppa_get_randseed('page') . " ) LIMIT %d", $alb, $count), ARRAY_A);
} else {
$temp = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY RAND( " . wppa_get_randseed('page') . " ) LIMIT %d", $alb, wppa_get_user(), $count), ARRAY_A);
}
}
// main_photo is -2? Last upload
if ('-2' == $id) {
if (current_user_can('wppa_moderate')) {
$temp = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s ORDER BY `timestamp` DESC LIMIT %d", $alb, $count), ARRAY_A);
} else {
$temp = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT %d", $alb, wppa_get_user(), $count), ARRAY_A);
}
}
// main_phtot is -1? Random featured
if ('-1' == $id) {
$temp = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` = 'featured' ORDER BY RAND( " . wppa_get_randseed('page') . " ) LIMIT %d", $alb, $count), ARRAY_A);
}
// Random from children
if ('-3' == $id) {
$allalb = wppa_expand_enum(wppa_alb_to_enum_children($alb));
$temp = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN ( " . str_replace('.', ',', $allalb) . " ) " . "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " . "ORDER BY RAND( " . wppa_get_randseed('page') . " ) LIMIT %d", wppa_get_user(), $count), ARRAY_A);
}
// Most recent from children
if ('-4' == $id) {
$allalb = wppa_expand_enum(wppa_alb_to_enum_children($alb));
$temp = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN ( " . str_replace('.', ',', $allalb) . " ) " . "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " . "ORDER BY `timestamp` DESC LIMIT %d", wppa_get_user(), $count), ARRAY_A);
}
// Report query
wppa_dbg_q('Q-gcovp');
// Add to 2nd level cache
wppa_cache_photo('add', $temp);
// Extract the ids only
$ids = array();
if (is_array($temp)) {
foreach ($temp as $item) {
$ids[] = $item['id'];
}
}
return $ids;
}
开发者ID:msayagh,项目名称:Quercus-source-code-Maven,代码行数:67,代码来源:wppa-album-covers.php
示例13: wppa_create_album_entry
function wppa_create_album_entry($args)
{
global $wpdb;
$args = wp_parse_args((array) $args, array('id' => '0', 'name' => __('New Album', 'wp-photo-album-plus'), 'description' => '', 'a_order' => '0', 'main_photo' => wppa_opt('main_photo'), 'a_parent' => wppa_opt('default_parent'), 'p_order_by' => '0', 'cover_linktype' => wppa_opt('default_album_linktype'), 'cover_linkpage' => '0', 'owner' => wppa_get_user(), 'timestamp' => time(), 'modified' => time(), 'upload_limit' => wppa_opt('upload_limit_count') . '/' . wppa_opt('upload_limit_time'), 'alt_thumbsize' => '0', 'default_tags' => '', 'cover_type' => '', 'suba_order_by' => '', 'views' => '0', 'cats' => '', 'scheduledtm' => ''));
if (!wppa_is_id_free(WPPA_ALBUMS, $args['id'])) {
$args['id'] = wppa_nextkey(WPPA_ALBUMS);
}
$query = $wpdb->prepare("INSERT INTO `" . WPPA_ALBUMS . "` ( \t`id`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`name`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`description`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`a_order`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`main_photo`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`a_parent`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`p_order_by`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`cover_linktype`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`cover_linkpage`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`owner`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`timestamp`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`modified`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`upload_limit`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`alt_thumbsize`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`default_tags`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`cover_type`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`suba_order_by`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`views`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`cats`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`scheduledtm`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s ,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", $args['id'], trim($args['name']), trim($args['description']), $args['a_order'], $args['main_photo'], $args['a_parent'], $args['p_order_by'], $args['cover_linktype'], $args['cover_linkpage'], $args['owner'], $args['timestamp'], $args['modified'], $args['upload_limit'], $args['alt_thumbsize'], $args['default_tags'], $args['cover_type'], $args['suba_order_by'], $args['views'], $args['cats'], $args['scheduledtm']);
$iret = $wpdb->query($query);
if ($iret) {
return $args['id'];
} else {
return false;
}
}
开发者ID:msayagh,项目名称:Quercus-source-code-Maven,代码行数:15,代码来源:wppa-wpdb-insert.php
示例14: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
global $wpdb;
global $wppa_opt;
require_once dirname(__FILE__) . '/wppa-links.php';
require_once dirname(__FILE__) . '/wppa-styles.php';
require_once dirname(__FILE__) . '/wppa-functions.php';
require_once dirname(__FILE__) . '/wppa-thumbnails.php';
require_once dirname(__FILE__) . '/wppa-boxes-html.php';
require_once dirname(__FILE__) . '/wppa-slideshow.php';
wppa_initialize_runtime();
extract($args);
wppa('in_widget', 'featen');
$instance = wp_parse_args((array) $instance, array('title' => '', 'album' => ''));
$widget_title = apply_filters('widget_title', $instance['title']);
$page = in_array(wppa_opt('featen_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('featen_widget_linkpage', __('Featured photos', 'wp-photo-album-plus'));
$max = wppa_opt('featen_count');
$album = $instance['album'];
$generic = $album == '-2';
// wppa( 'start_album', $album );
// if ( $generic ) {
// $album = '0';
// $max += '1000';
// }
switch ($album) {
// owner/public
case '-3':
$temp = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC", ARRAY_A);
if ($temp) {
$c = '0';
$thumbs = array();
while ($c < $max && $c < count($temp)) {
$alb = wppa_get_photo_item($temp[$c]['id'], 'album');
$own = wppa_get_album_item($alb, 'owner');
if ($own == '---public---' || $own == wppa_get_user()) {
$thumbs[] = $temp[$c];
}
$c++;
}
} else {
$thumbs = false;
}
break;
// generic
// generic
case '-2':
$temp = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC", ARRAY_A);
if ($temp) {
$c = '0';
$thumbs = array();
while ($c < $max && $c < count($temp)) {
$alb = wppa_get_photo_item($temp[$c]['id'], 'album');
if (!wppa_is_separate($alb)) {
$thumbs[] = $temp[$c];
}
$c++;
}
} else {
$thumbs = false;
}
break;
// all
// all
case '0':
$thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, ARRAY_A);
break;
// album spec
// album spec
default:
$thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status`= 'featured' AND `album` = %s ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, $album), ARRAY_A);
}
$widget_content = "\n" . '<!-- WPPA+ FeaTen Widget start -->';
$maxw = wppa_opt('featen_size');
$maxh = $maxw;
$lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
$maxh += $lineheight;
$count = '0';
if ($thumbs) {
foreach ($thumbs as $image) {
$thumb = $image;
if ($generic && wppa_is_separate($thumb['album'])) {
continue;
}
// Make the HTML for current picture
$widget_co
|
请发表评论