user_level;
$role = @$current_user->roles[0];
switch ($role){
case 'administrator':
$role_level = 10;
break;
case 'editor':
$role_level = 7;
break;
case 'author':
$role_level = 2;
break;
case 'contributor':
$role_level = 1;
break;
default:
$role_level = 0;
}
if ($level > $role_level){
return $level;
} else {
return $role_level;
}
}
function xpress_is_contributor()
{
global $current_user;
xpress_get_current_user();
if (xpress_user_access_level() > 3)
return true;
else
return false;
}
function xpress_is_multiblog() {
global $xoops_config;
if (function_exists('is_multisite') && is_multisite()) return true;
return false;
}
function xpress_is_multiblog_root() {
global $blog_id;
if ( xpress_is_multiblog() && $blog_id == BLOG_ID_CURRENT_SITE){
return true;
} else {
return false;
}
}
function xpress_is_wp_version($operator='==',$comp_version){
global $xoops_config;
return version_compare($xoops_config->wp_version, $comp_version, $operator);
}
function xpress_is_theme_sidebar_disp(){
global $xpress_config;
if (is_wordpress_style()) return true;
return $xpress_config->is_theme_sidebar_disp;
}
function xpress_is_author_view_count(){
global $xpress_config;
return $xpress_config->is_author_view_count;
}
function xpress_is_multi_user(){
global $xpress_config;
return $xpress_config->is_multi_user;
}
function xpress_the_title($args = '')
{
$defaults = array(
'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
$output = '
' . "\n";
if ($echo)
echo $output;
else
return $output;
}
function xpress_selected_author($args ='' ) {
$defaults = array(
'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
$output = '';
$author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
if (!empty($_COOKIE[$author_cookie])){
$uid = intval($_COOKIE[$author_cookie]);
$user_info = get_userdata($uid);
$output = $user_info->display_name;
}
if ($echo)
echo $output;
else
return $output;
}
function xpress_selected_author_id($args ='' ) {
$defaults = array(
'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
$output = '';
$author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
if (!empty($_COOKIE[$author_cookie])){
$output = intval($_COOKIE[$author_cookie]);
} else {
$output = '';
}
if ($echo)
echo $output;
else
return $output;
}
function xpress_now_user_level($args ='' ) {
global $current_user;
$defaults = array(
'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
$output = xpress_user_access_level();
if ($echo)
echo $output;
else
return $output;
}
function xpress_credit($args ='')
{
global $wp_version , $xoops_config;
if ($xoops_config->is_wpmu) {
global $wpmu_version;
}
$defaults = array(
'echo' => 1,
'no_link' => 0
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
$xpress_version = $xoops_config->module_version;
$xpress_codename = $xoops_config->module_codename;
if ($no_link){
if ($xoops_config->is_wpmu) {
$output = 'XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename);
$output .= '(included WordPress MU ' . $wpmu_version. ')';
} else {
$output = 'XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename);
if (strstr($wp_version,'ME')){
$output .= '(included WordPress ' . $wp_version . ')';
} else {
$output .= '(included WordPress ' . $wp_version . ')';
}
}
} else {
if ($xoops_config->is_wpmu) {
$output = '(.*)<\/strong>(.*)';
if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){
$title = $match[1];
$content = $match[2];
}
if (empty($title)) $title = $trackback->comment_author;
$row_data = array(
'ID' => $trackback->comment_ID ,
'post_ID' => $trackback->comment_post_ID ,
'site_name' => $trackback->comment_author ,
'site_url' => $trackback->comment_author_url ,
'title' => $title ,
'content' => $content ,
'date' => $trackback->comment_timestamp ,
'date_gmt' => $trackback->comment_timestamp_gmt ,
'agent' => $trackback->comment_agent ,
'type' => $trackback->comment_type ,
'IP' => $trackback->comment_author_IP ,
);
array_push($ret,$row_data);
}
return $ret;
}
return false;
}
function xpress_get_calendar($args = '') {
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts , $xoops_config;
$defaults = array(
sun_color => '#DB0000',
sat_color => '#004D99',
initial => true
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
ob_start();
get_calendar(true);
$calendar = ob_get_contents();
ob_end_clean();
$calendar = preg_replace('//', ' | ', $calendar); //days align center
$calendar = preg_replace('/ | /', ' | ', $calendar); //today align center
$calendar = preg_replace('/' . $sun_match[2] . ''. $sun_match[3];
$calendar = str_replace($sun_head,$sun_head_after,$calendar);
}
if(preg_match('/'. $pattrn . '/' ,$sat_head,$sat_match)){
$sat_head_after = $sat_match[1] . '' . $sat_match[2] . ''. $sat_match[3];
$calendar = str_replace($sat_head,$sat_head_after,$calendar);
}
}
return $calendar;
}
function xpress_grobal_recent_posts($num = 10,$exclusion_blog = 0, $shown_for_each_blog = false)
{
global $wpdb, $wp_rewrite , $switched , $blog_id;
if (empty($date_format)) $date_format = get_settings('date_format');
if (empty($time_format)) $time_format = get_settings('time_format');
$exclusion = explode(',' , $exclusion_blog);
$first_blogid = $blog_id;
$num = (int)$num;
// $wp_query->in_the_loop = true; //for use the_tags() in multi lopp
$data_array = array();
if (xpress_is_multiblog()){
$blogs = get_blog_list(0,'all');
foreach ($blogs AS $blog) {
if (!in_array(0, $exclusion) && in_array($blog['blog_id'], $exclusion)) continue;
switch_to_blog($blog['blog_id']);
$wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.
if (empty($num)){
query_posts("post_status=publish");
} else {
query_posts("showposts=$num&post_status=publish");
}
if (have_posts()){
while(have_posts()){
$data = new stdClass();
the_post();
ob_start();
the_ID();
$data->post_id = ob_get_contents();
ob_end_clean();
$data->blog_id = $blog['blog_id'];
$data->blog_name = get_bloginfo('name');
$data->blog_url = get_bloginfo('url');
$data->blog_link = '' . $data->blog_name . '' ;
ob_start();
the_title();
$data->title = ob_get_contents();
ob_end_clean();
$data->post_permalink = get_blog_permalink($data->brog_id, $data->post_id);
$data->title_link = '' . $data->title . '' ;
ob_start();
the_author_posts_link();
$data->post_author = ob_get_contents();
ob_end_clean();
ob_start();
the_category(' • ');
$data->post_category = ob_get_contents();
ob_end_clean();
if (function_exists('the_tags')){
ob_start();
the_tags(__('Tags:', 'xpress') . ' ',' • ','');
$data->post_tags = ob_get_contents();
ob_end_clean();
} else {
$data->tags = '';
}
$data->the_content = xpress_the_content('echo=0');
ob_start();
the_content();
$data->the_full_content = ob_get_contents();
ob_end_clean();
ob_start();
the_modified_date($date_format);
$data->post_modified_date = ob_get_contents();
ob_end_clean();
ob_start();
the_modified_date($time_format);
$data->post_modified_time = ob_get_contents();
ob_end_clean();
$data->post_modified_date_time = $data->post_modified_date . ' ' . $data->post_modified_time;
ob_start();
the_time('U');
$data->post_unix_time = ob_get_contents();
ob_end_clean();
ob_start();
the_time($date_format);
$data->post_date = ob_get_contents();
ob_end_clean();
ob_start();
the_time($time_format);
$data->post_time = ob_get_contents();
ob_end_clean();
$data->post_date_time = $data->post_date . ' ' . $data->post_time;
ob_start();
comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
$data->comments_link = ob_get_contents();
ob_end_clean();
$data->post_views = xpress_post_views_count('post_id=' . $data->post_id . '&blogid=' . $data->brog_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
if (function_exists('the_qf_get_thumb_one')){
$data->post_thumbnail = the_qf_get_thumb_one("num=0&width=120&tag=1","",$data->the_full_content);
} else {
$data->post_thumbnail = get_the_post_thumbnail(null,'thumbnail');
}
$data->author_avatar =get_avatar(get_the_author_meta('ID'),$size = '32');
$data_array[] = $data;
} // end whilwe
} // end if
restore_current_blog();
// $wp_rewrite->init();
} // end foreach
// switch_to_blog($first_blogid);
$wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.
restore_current_blog();
}
if (!$shown_for_each_blog){
usort($data_array, "the_time_cmp");
if (!empty($num)){
$data_array = array_slice($data_array,0,$num);
}
}
return $data_array;
}
function the_time_cmp($a, $b)
{
return - strcasecmp($a->post_unix_time, $b->post_unix_time);
}
function xpress_get_blog_option($option_name,$b_id = 1)
{
global $wpdb;
$db_prefix = get_wp_prefix();
if (empty($b_id)) $b_id =1;
$blog_prefix = '';
if ($b_id >1) $blog_prefix = $b_id . '_';
$options_tb = $db_prefix . $blog_prefix .'options';
$sql = "SELECT option_value FROM $options_tb WHERE option_name = $option_name";
$ret_val = $wpdb->get_var($sql);
return $ret_val;
}
function xpress_create_new_blog_link($args ='' ) {
global $xoops_config;
global $current_user;
$defaults = array(
'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
extract( $r );
$result = xpress_create_new_blog();
if (!empty($result)){
$output = $result['link'];
} else {
$output = '';
}
if ($echo)
echo $output;
else
return $output;
}
function xpress_create_new_blog() {
global $xoops_config;
global $current_user;
$ret = array();
if (xpress_is_multiblog() && is_user_logged_in()){
$primary_blog_id = @$current_user->primary_blog;
if (!empty($primary_blog_id)) return $ret;
$active_signup = get_site_option( 'registration' );
if ( !$active_signup ) $active_signup = 'none';
switch ($active_signup){
case 'all':
case 'blog':
$ret['url'] = $xoops_config->module_url . '/wp-signup.php';
$ret['menu_url'] = 'wp-signup.php';
$ret['title'] = __('Create New Blog','xpressme');
$ret['link'] = '' . $ret['title'] . '';
break;
case 'user':
case 'none':
default:
}
}
return $ret;
}
function xpress_primary_blog_link() {
global $xoops_config;
global $current_user;
global $blog_id;
$ret = array();
if (xpress_is_multiblog() && is_user_logged_in()){
$blog_list = get_blog_list();
$root_path = get_blog_status(1,'path');
$primary_blog_id = @$current_user->primary_blog;
if(empty($primary_blog_id)) return $ret;
$primary_path = get_blog_status($primary_blog_id,'path');
$script = str_replace($root_path, "", $primary_path);
if ($primary_blog_id !== $blog_id){
$ret['url'] = get_blogaddress_by_id($primary_blog_id);
$ret['menu_url'] = $script;
$ret['title'] = __('Your Primary Blog','xpressme');
$ret['link'] = '' . $ret['title'] . '';
}
}
return $ret;
}
?> |