function verify_new_user($var)
{
    if (!is_user_logged_in()) {
        return $var;
    }
    $errors = new WP_Error();
    $errors = $var['errors'];
    // get pricing plan level for the current blog
    $blogid = get_current_blog_id();
    $princing_plan = get_blog_option($blogid, 'product_id');
    // get pricing plan level for the current blog
    //$princing_plan = get_option('pricing_plan');
    //get number of users for this blog
    //$users = get_users_of_blog();
    //$nusers = count($users);
    $nusers = 0;
    global $blog_id;
    switch_to_blog($blog_id);
    $adminemail = get_bloginfo('admin_email');
    $admin = get_user_by_email($adminemail);
    restore_current_blog();
    $user_blogs = get_blogs_of_user($admin->ID);
    foreach ($user_blogs as $blog) {
        $bid = $blog->userblog_id;
        if ($bid == 1) {
            continue;
        }
        // does not count
        $email = get_blog_option($bid, 'admin_email');
        if ($email != $adminemail) {
            continue;
        }
        //eh apenas membro
        $u = get_users_of_blog($bid);
        $nusers = $nusers + count($u);
    }
    $pname = get_plan_name($princing_plan);
    switch ($pname) {
        case 'Cáucaso':
            if ($nusers == 30) {
                //$errors->add('pricing_plan', __('You have reached the maximum number of users. To add a new user pelase upgrade your plan.','delibera'));
                $errors->add('pricing_plan', __('Atingiu o número máximo de usuários permitido. Para adicionar mais usuários por favor actualize o seu plano.', 'delibera'));
            }
            break;
        case 'Miscenas':
            if ($nusers == 120) {
                //	$errors->add('pricing_plan', __('You have reached the maximum number of users. To add a new user pelase upgrade your plan.','delibera'));
                $errors->add('pricing_plan', __('Atingiu o número máximo de usuários permitido. Para adicionar mais usuários por favor actualize o seu plano.', 'delibera'));
            }
            break;
        case 'Creta':
            if ($nusers == 300) {
                //	$errors->add('pricing_plan', __('You have reached the maximum number of users. To add a new user pelase upgrade your plan.','delibera'));
                $errors->add('pricing_plan', __('Atingiu o número máximo de usuários permitido. Para adicionar mais usuários por favor actualize o seu plano.', 'delibera'));
            }
            break;
    }
    $var['errors'] = $errors;
    return $var;
}
Ejemplo n.º 2
0
function p2_get_at_name_map()
{
    global $wpdb;
    static $name_map = array();
    if ($name_map) {
        // since $names is static, the stuff below will only get run once per page load.
        return $name_map;
    }
    $users = get_users_of_blog();
    // get display names (can take out if you only want to handle nicenames)
    foreach ($users as $user) {
        $name_map["@{$user->user_login}"]['id'] = $user->ID;
        $users_to_array[] = $user->ID;
    }
    // get nicenames (can take out if you only want to handle display names)
    $user_ids = join(',', array_map('intval', $users_to_array));
    foreach ($wpdb->get_results("SELECT ID, display_name, user_nicename from {$wpdb->users} WHERE ID IN({$user_ids})") as $user) {
        $name_map["@{$user->display_name}"]['id'] = $user->ID;
        $name_map["@{$user->user_nicename}"]['id'] = $user->ID;
    }
    foreach ($name_map as $name => $values) {
        $username = get_userdata($values['id'])->user_login;
        $name_map[$name]['replacement'] = '<a href="' . esc_url('/mentions/' . $username) . '/">' . esc_html($name) . '</a>';
    }
    // remove any empty name just in case
    unset($name_map['@']);
    return $name_map;
}
function pp_generate_sidebars()
{
    register_sidebar(array('name' => 'All - Top', 'id' => 'pp-sidebar-top', 'before_widget' => '<li id="%1$s" class="widget pp-sidebar-top %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
    register_sidebar(array('name' => 'Home', 'id' => 'pp-home-sidebar', 'before_widget' => '<li id="%1$s" class="widget pp-home-sidebar %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
    register_sidebar(array('name' => 'Single post page', 'id' => 'pp-single-sidebar', 'before_widget' => '<li id="%1$s" class="widget pp-single-sidebar %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
    register_sidebar(array('name' => 'Project (default)', 'id' => 'pp-project-sidebar-default', 'before_widget' => '<li id="%1$s" class="widget pp-project-sidebar pp-project-sidebar-all %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
    $options = pp_get_options();
    if ($options['project_sidebars'] && ($projects = pp_get_projects())) {
        foreach ($projects as $project) {
            register_sidebar(array('name' => 'Project - ' . $project->name, 'id' => 'pp-project-sidebar-' . $project->cat_ID, 'before_widget' => '<li id="%1$s" class="widget pp-project-sidebar pp-project-sidebar-' . $project->cat_ID . ' %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
        }
    }
    register_sidebar(array('name' => 'Author (default)', 'id' => 'pp-author-sidebar-default', 'before_widget' => '<li id="%1$s" class="widget pp-author-sidebar pp-author-sidebar-all %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
    // Todo: cache the author array
    $authors = array();
    if ($options['author_sidebars'] && ($users = get_users_of_blog())) {
        foreach ($users as $user) {
            $user_object = new WP_User($user->user_id);
            if (!$user_object->has_cap('publish_posts')) {
                continue;
            }
            $authors[] = $user;
        }
    }
    foreach ($authors as $author) {
        register_sidebar(array('name' => 'Author - ' . $author->display_name, 'id' => 'pp-author-sidebar-' . $author->user_id, 'before_widget' => '<li id="%1$s" class="widget pp-author-sidebar pp-author-sidebar-' . $author->user_id . ' %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
    }
    register_sidebar(array('name' => 'All - Bottom', 'id' => 'pp-sidebar-bottom', 'before_widget' => '<li id="%1$s" class="widget pp-sidebar-bottom %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
}
Ejemplo n.º 4
0
 function setUp()
 {
     parent::setUp();
     // keep track of users we create
     $this->_flush_roles();
     $this->orig_users = get_users_of_blog();
 }
Ejemplo n.º 5
0
 /**
  * Generates array of users indexed by user ID, and
  * an array of user_nicenames, indexed by user ID.
  *
  * @compat < 3.1: Use $wpdb and get_users of blog.
  */
 function load_users()
 {
     global $wpdb;
     // < 3.1
     // Cache the user information.
     if (!empty($this->users)) {
         return $this->users;
     }
     if (function_exists('get_users')) {
         // >= 3.1
         $users = get_users();
         foreach ($users as $user) {
             $this->users[$user->ID] = $user;
             $this->names[$user->ID] = $user->user_nicename;
         }
     } else {
         //  < 3.1
         $users = get_users_of_blog();
         $user_ids = '';
         foreach ($users as $user) {
             $this->users[$user->ID] = $user;
             $user_ids .= $user->ID;
         }
         foreach ($wpdb->get_results("SELECT ID, user_nicename from {$wpdb->users} WHERE ID IN({$user_ids})") as $user) {
             $this->users[$user->ID]->user_nicename = $user->user_nicename;
             $this->names[$user->ID] = $user->user_nicename;
         }
     }
     return $this->users;
 }
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => '', 'user_id' => 0));
        ?>
        <p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        esc_attr_e($instance['title']);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('user_id');
        ?>
"><?php 
        _e('User:'******'user_id');
        ?>
" id="<?php 
        echo $this->get_field_id('user_id');
        ?>
" class="widefat">
				<option value="-1"<?php 
        selected($instance['user_id'], -1);
        ?>
><?php 
        _e('Select a User');
        ?>
</option>
<?php 
        $users = get_users_of_blog();
        foreach ($users as $user) {
            echo '
				<option value="' . $user->ID . '"' . selected($instance['user_id'], $user->ID) . '>' . esc_html($user->display_name) . '</option>';
        }
        ?>
			</select>
		</p>
<?php 
    }
Ejemplo n.º 7
0
function get_users_of_blog_by_rol($blog_id, $rol)
{
    $users = get_users_of_blog($blog_id);
    $result = array();
    foreach ($users as $user) {
        switch_to_blog($blog_id);
        $user_o = new WP_User($user->user_id);
        if ($user_o->has_cap($rol) && strcmp($user->user_nicename, "admin") != 0) {
            array_push($result, $user);
        }
        restore_current_blog();
    }
    return $result;
}
Ejemplo n.º 8
0
 function format_author_value(&$value)
 {
     if (is_array($value)) {
         $users = get_users_of_blog();
         $all = true;
         foreach ($users as $user) {
             if (!in_array($user->user_id, $value)) {
                 $all = false;
                 break;
             }
         }
         if ($all) {
             $value = '';
         }
     }
 }
Ejemplo n.º 9
0
    function users_form($n)
    {
        global $wpdb, $testing;
        $users = get_users_of_blog($wpdb->blogid);
        ?>
<select name="userselect[<?php 
        echo $n;
        ?>
]">
	<option value="#NONE#"><?php 
        _e('- Select -');
        ?>
</option>
	<?php 
        foreach ($users as $user) {
            echo '<option value="' . $user->user_login . '">' . $user->user_login . '</option>';
        }
        ?>
	</select>
	<?php 
    }
Ejemplo n.º 10
0
function q_generate_quser_pages()
{
    $errormessage = "All Users: ";
    $qusers = get_users_of_blog();
    foreach ($qusers as $quser) {
        $userpost = array('post_title' => $quser->display_name, 'post_content' => $quser->user_description, 'post_status' => 'publish', 'post_author' => $quser->ID, 'post_date' => $quser->registered, 'post_type' => 'quser');
        $postid = wp_insert_post($userpost);
        if (!$postid) {
            $errormessage .= __("error with user", 'qna-forum') . " " . $quser->ID;
        } else {
            update_user_meta($quser->ID, 'q_profilepage_id', $postid);
        }
    }
    //create default page with author -1 so that we can display a homepage or login page
    $default_post = array('post_title' => 'My Account', 'post_content' => 'Default User', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'quser');
    $default_id = wp_insert_post($default_post);
    if (!$default_id) {
        $errormessage .= __("error creating default page", 'qna-forum');
    } else {
        update_option('q_quser_default_pageid', $default_id);
    }
    return $erromessage;
}
Ejemplo n.º 11
0
    function users_form($n, $author)
    {
        if ($this->allow_create_users()) {
            printf('<label>' . __('Create user %1$s or map to existing'), ' <input type="text" value="' . esc_attr($author) . '" name="' . 'user_create[' . intval($n) . ']' . '" maxlength="30" /></label> <br />');
        } else {
            echo __('Map to existing') . '<br />';
        }
        // keep track of $n => $author name
        echo '<input type="hidden" name="author_in[' . intval($n) . ']" value="' . esc_attr($author) . '" />';
        $users = get_users_of_blog();
        ?>
<select name="user_select[<?php 
        echo $n;
        ?>
]">
	<option value="0"><?php 
        _e('- Select -');
        ?>
</option>
	<?php 
        foreach ($users as $user) {
            echo '<option value="' . $user->user_id . '">' . $user->user_login . '</option>';
        }
        ?>
	</select>
	<?php 
    }
Ejemplo n.º 12
0
function confirm_delete_users($users)
{
    global $current_user;
    if (!is_array($users)) {
        return false;
    }
    screen_icon();
    ?>
	<h2><?php 
    esc_html_e('Users');
    ?>
</h2>
	<p><?php 
    _e('Transfer or delete posts and links before deleting users.');
    ?>
</p>
	<form action="ms-edit.php?action=dodelete" method="post">
	<input type="hidden" name="dodelete" />
    <?php 
    wp_nonce_field('ms-users-delete');
    $site_admins = get_super_admins();
    $admin_out = "<option value='{$current_user->ID}'>{$current_user->user_login}</option>";
    foreach ($allusers = (array) $_POST['allusers'] as $key => $val) {
        if ($val != '' && $val != '0') {
            $delete_user = new WP_User($val);
            if (in_array($delete_user->user_login, $site_admins)) {
                wp_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network admnistrator.'), $delete_user->user_login));
            }
            echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
            $blogs = get_blogs_of_user($val, true);
            if (!empty($blogs)) {
                ?>
				<br /><fieldset><p><legend><?php 
                printf(__("What should be done with posts and links owned by <em>%s</em>?"), $delete_user->user_login);
                ?>
</legend></p>
				<?php 
                foreach ((array) $blogs as $key => $details) {
                    $blog_users = get_users_of_blog($details->userblog_id);
                    if (is_array($blog_users) && !empty($blog_users)) {
                        $user_site = "<a href='" . esc_url(get_home_url($details->userblog_id)) . "'>{$details->blogname}</a>";
                        $user_dropdown = "<select name='blog[{$val}][{$key}]'>";
                        $user_list = '';
                        foreach ($blog_users as $user) {
                            if ($user->user_id != $val && !in_array($user->user_id, $allusers)) {
                                $user_list .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
                            }
                        }
                        if ('' == $user_list) {
                            $user_list = $admin_out;
                        }
                        $user_dropdown .= $user_list;
                        $user_dropdown .= "</select>\n";
                        ?>
						<ul style="list-style:none;">
							<li><?php 
                        printf(__('Site: %s'), $user_site);
                        ?>
</li>
							<li><label><input type="radio" id="delete_option0" name="delete[<?php 
                        echo $details->userblog_id . '][' . $delete_user->ID;
                        ?>
]" value="delete" checked="checked" />
							<?php 
                        _e('Delete all posts and links.');
                        ?>
</label></li>
							<li><label><input type="radio" id="delete_option1" name="delete[<?php 
                        echo $details->userblog_id . '][' . $delete_user->ID;
                        ?>
]" value="reassign" />
							<?php 
                        echo __('Attribute all posts and links to:') . '</label>' . $user_dropdown;
                        ?>
</li>
						</ul>
						<?php 
                    }
                }
                echo "</fieldset>";
            }
        }
    }
    ?>
	<p class="submit"><input type="submit" class="button-secondary delete" value="<?php 
    esc_attr_e('Confirm Deletion');
    ?>
" /></p>
	</form>
    <?php 
    return true;
}
 /**
  * Returns all blog usernames (in form [user_login => display_name (user_login)] )
  *
  * @return array $usernames
  **/
 function getBlogUsernames()
 {
     $return = array();
     $users = get_users_of_blog();
     foreach ($users as $user) {
         if ($user->display_name == $user->user_login) {
             $return[$user->user_login] = "{$user->display_name}";
         } else {
             $return[$user->user_login] = "{$user->display_name} ({$user->user_login})";
         }
     }
     return $return;
 }
Ejemplo n.º 14
0
function xtec_delblogs_page()
{
    if (isset($_POST['inactivity_days'])) {
        $inactivity_days = $_POST['inactivity_days'];
    } else {
        $inactivity_days = get_site_option('xtec_maintenance_inactivity_days', 90);
    }
    if (isset($_POST['posts_pages'])) {
        $posts_pages = $_POST['posts_pages'];
    } else {
        $posts_pages = get_site_option('xtec_maintenance_posts_pages', 2);
    }
    if (get_site_option('xtec_maintenance_never_upload_file', 1) == 1) {
        $never_upload_file = true;
    } else {
        $never_upload_file = false;
    }
    if (isset($_POST['never_upload_file'])) {
        $never_upload_file = true;
    } else {
        if (isset($_POST['submit']) || isset($_POST['set_as_default']) || isset($_POST['touch'])) {
            $never_upload_file = false;
        }
    }
    ?>
	
	<div class="wrap">
	
	<h2>Eliminació de blocs</h2>
	
	<?php 
    global $wpdb;
    if (isset($_POST['delete'])) {
        if (!isset($_POST['idblogs'])) {
            ?>
<div class="error below-h2"><p>No has seleccionat cap bloc.</p></div><?php 
        } else {
            $idblogs = $_POST['idblogs'];
            foreach ($idblogs as $idblog) {
                $blogname = get_blog_option($idblog, 'blogname');
                $path = $wpdb->get_var("SELECT `path` FROM `{$wpdb->blogs}` WHERE `blog_id`='{$idblog}'");
                $del_date = date("Y-m-d H:i:s");
                $sql = "INSERT INTO `wp_delblocs` SET `site_id` = '{$idblog}', `site_path` = '" . $path . "', `blogname` = '" . $blogname . "', `del_date` = '{$del_date}', `status` = '2';";
                $wpdb->get_results($sql);
                $users = get_users_of_blog($idblog);
                foreach ($users as $user) {
                    $sql = "INSERT INTO `wp_delblocs_users` SET `blog_id` = '{$idblog}', `user_id` = '" . $user->user_id . "', `user_login` = '" . $user->user_login . "', `display_name` = '" . $user->display_name . "', `user_email` = '" . $user->user_email . "', `meta_value` = '" . $user->meta_value . "';";
                    $wpdb->get_results($sql);
                }
                // drops data of the blog when deleted
                wpmu_delete_blog($idblog, true);
                echo "El bloc {$blogname} amb ID {$idblog} s'ha eliminat correctament.<br />";
            }
        }
        echo "<p><a href=\"?page=xtec-delblogs\">Torna al formulari d'eliminació de blocs</a></p>";
    } else {
        if (isset($_POST['touch'])) {
            if (!isset($_POST['idblogs'])) {
                ?>
<div class="error below-h2"><p>No has seleccionat cap bloc.</p></div><?php 
            } else {
                $idblogs = $_POST['idblogs'];
                foreach ($idblogs as $idblog) {
                    $blogname = get_blog_option($idblog, 'blogname');
                    $wpdb->update($wpdb->blogs, array('last_updated' => current_time('mysql', true)), array('blog_id' => $idblog));
                    refresh_blog_details($wpdb->blogid);
                    echo "La data de la darrera actualització del bloc <strong>{$blogname}</strong> amb ID <strong>{$idblog}</strong> ha estat actualitzada a la data actual.<br>";
                }
            }
            echo "<p><a href=\"?page=xtec-delblogs\">Torna al formulari d'eliminació de blocs</a></p>";
        } else {
            if (isset($_POST['set_as_default'])) {
                update_site_option('xtec_maintenance_inactivity_days', $_POST['inactivity_days']);
                update_site_option('xtec_maintenance_posts_pages', $_POST['posts_pages']);
                $value = isset($_POST['never_upload_file']) ? 1 : 0;
                update_site_option('xtec_maintenance_never_upload_file', $value);
            }
            ?>
		
		<form action="?page=xtec-delblogs" method="post">
			<table class="form-table">
				<tbody>
					<tr valign="top">
						<th scope="row">
							<label for="inactivity_days">Dies d'inactivitat</label>
						</th>
						<td>
							<input id="inactivity_days" class="small-text" type="text" value="<?php 
            echo $inactivity_days;
            ?>
" name="inactivity_days"/>
						</td>
					</tr>
					<tr valign="top">
						<th scope="row">
							<label for="posts_pages">Articles i pàgines</label>
						</th>
						<td>
							<input id="posts_pages" class="small-text" type="text" value="<?php 
            echo $posts_pages;
            ?>
" name="posts_pages"/>
						</td>
					</tr>
					<tr valign="top">
						<th scope="row">
							<label for="never_upload_file">Mai s'ha pujat cap fitxer</label>
						</th>
						<td>
							<?php 
            if ($never_upload_file) {
                ?>
								<input type="checkbox" checked="checked" value=1 name="never_upload_file"/>
							<?php 
            } else {
                ?>
								<input type="checkbox" value=1 name="never_upload_file"/>
							<?php 
            }
            ?>
						</td>
					</tr>
				</tbody>
			</table>

			<h3>Es llisten tots els blocs que compleixen les següents restriccions:</h3>

			<div  style="background-color: rgb(255, 251, 204); border-color:#E6DB55; border-style: solid;border-width:1px; padding: 0.6em;-moz-border-radius:3px">
				<?php 
            if ($inactivity_days == 1) {
                ?>
 - Fa almenys <strong><?php 
                echo $inactivity_days;
                ?>
</strong> dia que no s'actualitzen.<br>
				<?php 
            } else {
                if ($inactivity_days != 0) {
                    ?>
 - Fa almenys <strong><?php 
                    echo $inactivity_days;
                    ?>
</strong> dies que no s'actualitzen.<br>
				<?php 
                }
            }
            ?>
				<?php 
            if ($posts_pages == 1) {
                ?>
 - Tenen com a molt <strong><?php 
                echo $posts_pages;
                ?>
</strong> article o pàgina.<br>
				<?php 
            } else {
                if ($posts_pages != 0) {
                    ?>
 - Tenen com a molt <strong><?php 
                    echo $posts_pages;
                    ?>
</strong> articles o pàgines.<br>
				<?php 
                } else {
                    if ($posts_pages == 0) {
                        ?>
 - No tenen <strong>cap</strong> article ni <strong>cap</strong> pàgina.<br>
				<?php 
                    }
                }
            }
            ?>
				<?php 
            if ($never_upload_file) {
                ?>
 - <strong>Mai</strong> s'hi ha pujat cap fitxer.<br>
				<?php 
            } else {
                ?>
 - S'hi ha pujat <strong>alguna vegada</strong> algun fitxer.<br>
				<?php 
            }
            ?>
			</div>
			
			<div class="tablenav">
				<div class="alignleft">
						<input class="button-secondary" type="submit" value="Refresca la llista" name="submit"/>
						<input class="button-secondary" type="submit" value="Elimina els blocs seleccionats" name="delete"/>
						<input class="button-secondary" type="submit" value="Actualitza la data dels blocs seleccionats" name="touch"/>
						<input class="button-secondary" type="submit" value="Desa els valors actuals com a predeterminats" name="set_as_default"/>
						<br class="clear" />				
				</div>
			</div>
			<br class="clear" />
			
			<?php 
            $blogname_columns = constant("VHOST") == 'yes' ? __('Domain') : __('Path');
            ?>
						
			<table cellspacing="3" cellpadding="3" width="100%" class="widefat">
				<thead>
					<tr>
						<th class="check-column" scope="col"><input type="checkbox"/></th>
						<th scope="col"><?php 
            echo __('ID');
            ?>
</th>
						<th scope="col"><?php 
            echo $blogname_columns;
            ?>
</th>
						<th scope="col">Dies des de la darrera actualització</th>
						<th scope="col">Articles i pàgines</th>
						<th scope="col">S'han pujat fitxers algun cop?</th>
					</tr>
				</thead>
				<tbody id="the-list">
					<?php 
            // Inactivity check
            $date_limit = date("Y-m-d H:i:s", mktime() - $inactivity_days * 86400);
            $blogs = $wpdb->get_results("SELECT `blog_id`, `path`, `registered`, UNIX_TIMESTAMP(`last_updated`) as last_updated FROM {$wpdb->blogs} WHERE last_updated<'{$date_limit}' AND deleted=0 AND blog_id!=1", ARRAY_A);
            foreach ($blogs as $blog) {
                $blog_id = $blog["blog_id"];
                $path = $blog["path"];
                $registered = $blog["registered"];
                $last_updated = $blog["last_updated"];
                $posts_pages_check = false;
                $upload_check = false;
                $now = mktime();
                $elapsed_days = (int) (($now - $last_updated) / 86400);
                // Posts and Pages check
                $posts_table = $wpdb->get_results("SELECT post_type FROM `wp_" . $blog_id . "_posts`", ARRAY_A);
                $posts = 0;
                $pages = 0;
                foreach ($posts_table as $post_row) {
                    if ($post_row['post_type'] == 'post') {
                        $posts++;
                    } else {
                        if ($post_row['post_type'] == 'page') {
                            $pages++;
                        }
                    }
                }
                if ($posts + $pages <= $posts_pages) {
                    $posts_pages_check = true;
                }
                // Upload check
                if (!file_exists(ABSPATH . "wp-content/blogs.dir/{$blog_id}")) {
                    if ($never_upload_file) {
                        $upload_check = true;
                    }
                } else {
                    if (!$never_upload_file) {
                        $upload_check = true;
                    }
                }
                // Check the rules
                if ($posts_pages_check && $upload_check) {
                    $path = $wpdb->get_var("SELECT `path` FROM `{$wpdb->blogs}` WHERE `blog_id`='{$blog_id}'");
                    ?>
							<tr class="alternate">
								<th class="check-column" scope="row">
									<input type="checkbox" value="<?php 
                    echo $blog_id;
                    ?>
" name="idblogs[]" id="blog_<?php 
                    echo $blog_id;
                    ?>
"/>
								</th>
								
								<th scope="row"><?php 
                    echo $blog_id;
                    ?>
</th>
								<td valign="top">
									<a rel="permalink" href="<?php 
                    echo $path;
                    ?>
"><?php 
                    echo $path;
                    ?>
</a>
								</td>
								<td valign="top">
									<?php 
                    echo '<strong>' . $elapsed_days . '</strong>';
                    ?>
								</td>
								<td valign="top">
									<?php 
                    echo '<strong>' . ($posts + $pages) . '</strong>' . ' (' . $posts . '+' . $pages . ')';
                    ?>
								</td>
								<td valign="top">
									<strong><?php 
                    if ($never_upload_file) {
                        ?>
NO<?php 
                    } else {
                        ?>
SI<?php 
                    }
                    ?>
</strong>
								</td>
							</tr>
							<?php 
                }
            }
            ?>
				</tbody>
			</table>
		</form>		
		<?php 
        }
    }
    ?>
	</div>
	<?php 
}
Ejemplo n.º 15
0
         } else {
             $domain = $current_site->domain;
             $path = trailingslashit($current_site->path . $dashboard_blog);
         }
         $wpdb->hide_errors();
         $dashboard_blog_id = wpmu_create_blog($domain, $path, __('My Dashboard'), $current_user->id, array('public' => 0), $current_site->id);
         $wpdb->show_errors();
     } else {
         $dashboard_blog_id = $blog_details->blog_id;
     }
 }
 if (is_wp_error($dashboard_blog_id)) {
     wp_die(__('Problem creating dashboard blog: ') . $dashboard_blog_id->get_error_message());
 }
 if ($_POST['dashboard_blog_orig'] != $_POST['dashboard_blog']) {
     $users = get_users_of_blog(get_site_option('dashboard_blog'));
     $move_users = array();
     foreach ((array) $users as $user) {
         if (array_pop(array_keys(unserialize($user->meta_value))) == 'subscriber') {
             $move_users[] = $user->user_id;
         }
     }
     if (false == empty($move_users)) {
         foreach ((array) $move_users as $user_id) {
             remove_user_from_blog($user_id, get_site_option('dashboard_blog'));
             add_user_to_blog($dashboard_blog_id, $user_id, get_site_option('default_user_role', 'subscriber'));
             update_user_meta($user_id, 'primary_blog', $dashboard_blog_id);
         }
     }
 }
 update_site_option('dashboard_blog', $dashboard_blog_id);
function tweetimport_display_account_add_edit_form($mode="add", $account_details=NULL)
{
  echo '<h3>' . ($mode=='add'?'Add':'Update') . ' Twitter Feed</h3>';
  echo '<div class="form-wrap">';
  echo '<form name="twitter-account-form" id="twitter-account-form" method="post">';
  echo '<input type="hidden" name="tweetimport_action" value="' . ($mode=="add"?'add':'update') .'">';

  echo '<fieldset class="tweetimport">';
  echo '<legend class="tweetimport">Feed Info</legend>';
  if ($mode == 'add')
  {
    echo '<div class="form-field form-required">';
    echo '<label for="account_type">Twitter Feed Type</label>';
    echo '<select name="account_type" id="account_type">';
    if (!isset ($account_details['account_type'])) $account_details['account_type'] = 0;
    echo '<option value="0" ' . ($account_details['account_type']==0?'selected="selected"':'') . '>User Public Timeline</option>';
    echo '<option value="1" ' . ($account_details['account_type']==1?'selected="selected"':'') . '>Favorites</option>';
    echo '<option value="2" ' . ($account_details['account_type']==2?'selected="selected"':'') . '>List</option>';
    echo '</select>';
    echo '<p>Define the feed source type and identifiers. For a normal user feed, please select User Public Timeline. Favorites allows importing the tweets favorited by a user. A List feed will import the tweets that appear on a list as shown on the list page.</p>';
    echo '</div>';

    echo '<div class="form-field form-required">';
    echo '<label for="account_name">Twitter Feed User Name or List</label>';
    echo '<input name="account_name" id="account_name" type="text" value="' . $account_details['twitter_name'] . '" size="40" aria-required="true" />';
    echo '<p>For a User Public Timeline or a Favorites feed, please enter the twitter user name only. For a List feed, please input the user/list-name as it appears on the list page on twitter.</p>';
    echo '</div>';
  }
  else
  {
    echo '<div class="form-field form-required">';
    echo 'Updating Account information for<br />Twitter Feed Type: <strong>';
    if ($account_details['account_type'] == 0) echo 'User Public Timeline';
    elseif ($account_details['account_type'] == 1) echo 'Favorites';
    elseif ($account_details['account_type'] == 2) echo 'List';
    echo '</strong><br />Twitter Feed User Name or List: <strong>' . $account_details['twitter_name'] . '</strong>';
    echo '<p>Twitter feed information cannot be changed after creation. If for any reason you would like to change the feed user name or list, please deactivate or delete the account and create a new one. Please note that deleting an account does not delete the posts created through this account.</p>';
    echo '</div>';
  }

  echo '</fieldset>';
 
  echo '<br /><br />';
  echo '<fieldset class="tweetimport">';
  echo '<legend class="tweetimport">Import Options</legend>';

  echo '<div class="form-field form-required">';
  echo '<label for="tweet_author">Assign Author for tweets</label>';
  echo '<select name="tweet_author" id="tweet_author" >';

  $blog_authors = get_users_of_blog();
  foreach ($blog_authors as $blog_author)
  {
    $blog_author_info = get_userdata($blog_author->user_id);
    if (!isset ($account_details['author'])) $account_details['author'] = 1;
    if ($blog_author->user_id == $account_details['author']) {$selected = 'selected="selected"';} else {$selected = '';}
    echo '<option value="' . $blog_author->user_id . '" ' . $selected . '>' . $blog_author_info->user_login . '</option>';
  }
  echo '</select>';
  echo '<p>Assign an author to your imported tweets.</p>';
  echo '</div>';

  echo '<div class="form-field form-required">';
  echo '<label for="tweet_category">Category for imported tweets</label>';
  echo '<select name="tweet_category" id="tweet_category" >';

  $categories = get_categories ('hide_empty=0');
  foreach ($categories as $category)
  {
    !empty($category->term_id) ? $cat_id = $category->term_id : $cat_id = $category->cat_ID;
    !empty($category->name) ? $cat_name = $category->name : $cat_name = $category->cat_name;
    if (!isset ($account_details['category'])) $account_details['category'] = 1;
    if ($cat_id == $account_details['category']) {$selected = 'selected="selected"';} else {$selected = '';}
    echo '<option value="' . $cat_id . '" ' . $selected . '>' . $cat_name . '</option>';
  }
  echo '</select>';
  echo '<p>Import this account tweets to the selected category.</p>';
  echo '</div>';

  echo '<div class="form-field">';
  echo '<label for="account_tags">Tag Tweets</label>';
  echo '<input name="account_tags" id="account_tags" type="text" value="'. $account_details['add_tag'] .'" size="40" />';
  echo '<p>You can add multiple tags. Make sure to separate tags with a comma (,)</p>';
  echo '</div>';

  echo '<div class="form-field form-required">';
  echo '<label for="names_clickable">Make Twitter names clickable</label>';
  echo '<select name="names_clickable" id="names_clickable">';
  if (!isset ($account_details['names_clickable'])) $account_details['names_clickable'] = 0;
  echo '<option value="0" ' . ($account_details['names_clickable']!=1?'selected="selected"':'') . '>No</option>';
  echo '<option value="1" ' . ($account_details['names_clickable']==1?'selected="selected"':'') . '>Yes</option>';
  echo '</select>';
  echo '<p>Would you like Tweet Import to try identify Twitter user names in tweets and make them clickable leading to their Twitter pages?</p>';
  echo '</div>';

  echo '<div class="form-field form-required">';
  echo '<label for="account_hashtags">#hashtags</label>';
  echo '<select name="account_hashtags" id="account_hashtags">';
  if (!isset ($account_details['hash_tag'])) $account_details['hash_tag'] = 0;
  echo '<option value="0" ' . ($account_details['hash_tag']!=1?'selected="selected"':'') . '>No</option>';
  echo '<option value="1" ' . ($account_details['hash_tag']==1?'selected="selected"':'') . '>Yes</option>';
  echo '</select>';
  echo '<p>For the imported tweets, would you like to have #hashtags added as tags to the created wordpress posts?</p>';
  echo '</div>';

  echo '<div class="form-field form-required">';
  echo '<label for="hashtags_clickable">Make #hashtags clickable</label>';
  echo '<select name="hashtags_clickable" id="hashtags_clickable">';
  if (!isset ($account_details['hashtags_clickable'])) $account_details['hashtags_clickable'] = 0;
  echo '<option value="0" ' . ($account_details['hashtags_clickable']!=1?'selected="selected"':'') . '>No</option>';
  echo '<option value="1" ' . ($account_details['hashtags_clickable']==1?'selected="selected"':'') . '>Yes</option>';
  echo '</select>';
  echo '&nbsp;&nbsp;&nbsp;<select name="hashtags_clickable_twitter" id="hashtags_clickable_twitter">';
  if (!isset ($account_details['hashtags_clickable_twitter'])) $account_details['hashtags_clickable_twitter'] = 0;
  echo '<option value="0" ' . ($account_details['hashtags_clickable_twitter']!=1?'selected="selected"':'') . '>Locally</option>';
  echo '<option value="1" ' . ($account_details['hashtags_clickable_twitter']==1?'selected="selected"':'') . '>to twitter</option>';
  echo '</select>';
  echo '<p>Would you like Tweet Import to make #hashtags clickable? If so, would you like the link to point to the tag page locally, or the search page on twitter?</p>';
  echo '</div>';

  echo '<div class="form-field form-required">';
  echo '<label for="account_hashtags">Remove Prefixed @name</label>';
  echo '<select name="strip_name" id="strip_name">';
  if (!isset ($account_details['strip_name'])) $account_details['hash_tag'] = 0;
  echo '<option value="0" ' . ($account_details['strip_name']!=1?'selected="selected"':'') . '>No</option>';
  echo '<option value="1" ' . ($account_details['strip_name']==1?'selected="selected"':'') . '>Yes</option>';
  echo '</select>';
  echo '<p>By default Twitter includes the @name of the Twitter user at the beginning of the tweet as [ @name: ]. Would you like Tweet Import to remove this name from the beginning of the imported tweets?</p>';
  echo '</div>';

  echo '</fieldset>';

  echo '<p class="submit">';
  echo '<input type="submit" class="button" name="submit" value="' . ($mode == 'add' ? 'Add Account' : 'Update Account') .'" />';
  echo '</p>';
  echo '</form>';
  echo '</div> <!-- end form-wrap -->';
}
Ejemplo n.º 17
0
        ?>
<h2><?php 
        echo wp_specialchars($title);
        if (isset($_GET['s']) && $_GET['s']) {
            printf('<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', wp_specialchars(get_search_query()));
        }
        ?>
</h2>

<div class="filter">
<form id="list-filter" action="" method="get">
<ul class="subsubsub">
<?php 
        $role_links = array();
        $avail_roles = array();
        $users_of_blog = get_users_of_blog();
        $total_users = count($users_of_blog);
        foreach ((array) $users_of_blog as $b_user) {
            $b_roles = unserialize($b_user->meta_value);
            foreach ((array) $b_roles as $b_role => $val) {
                if (!isset($avail_roles[$b_role])) {
                    $avail_roles[$b_role] = 0;
                }
                $avail_roles[$b_role]++;
            }
        }
        unset($users_of_blog);
        $current_role = false;
        $class = empty($role) ? ' class="current"' : '';
        $role_links[] = "<li><a href='users.php'{$class}>" . sprintf(__ngettext('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users), number_format_i18n($total_users)) . '</a>';
        foreach ($wp_roles->get_names() as $this_role => $name) {
Ejemplo n.º 18
0
/**
 * populate network settings
 *
 * @since 3.0.0
 *
 * @param int $network_id id of network to populate
 * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful,
 * 	so the error code must be checked) or failure.
 */
function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
	global $wpdb, $current_site, $wp_db_version, $wp_rewrite;

	$errors = new WP_Error();
	if ( '' == $domain )
		$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
	if ( '' == $site_name )
		$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );

	// check for network collision
	if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
		$errors->add( 'siteid_exists', __( 'The network already exists.' ) );

	$site_user = get_user_by_email( $email );
	if ( ! is_email( $email ) )
		$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );

	if ( $errors->get_error_code() )
		return $errors;

	// set up site tables
	$template = get_option( 'template' );
	$stylesheet = get_option( 'stylesheet' );
	$allowed_themes = array( $stylesheet => true );
	if ( $template != $stylesheet )
		$allowed_themes[ $template ] = true;
	if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template )
		$allowed_themes[ WP_DEFAULT_THEME ] = true;

	if ( 1 == $network_id ) {
		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
		$network_id = $wpdb->insert_id;
	} else {
		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
	}

	if ( !is_multisite() ) {
		$site_admins = array( $site_user->user_login );
		$users = get_users_of_blog();
		if ( $users ) {
			foreach ( $users as $user ) {
				if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
					$site_admins[] = $user->user_login;
			}
		}
	} else {
		$site_admins = get_site_option( 'site_admins' );
	}

	$welcome_email = __( 'Dear User,

Your new SITE_NAME site has been successfully set up at:
BLOG_URL

You can log in to the administrator account with the following information:
Username: USERNAME
Password: PASSWORD
Login Here: BLOG_URLwp-login.php

We hope you enjoy your new site.
Thanks!

--The Team @ SITE_NAME' );

	$sitemeta = array(
		'site_name' => $site_name,
		'admin_email' => $site_user->user_email,
		'admin_user_id' => $site_user->ID,
		'registration' => 'none',
		'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',
		'blog_upload_space' => 10,
		'fileupload_maxk' => 1500,
		'site_admins' => $site_admins,
		'allowedthemes' => $allowed_themes,
		'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
		'wpmu_upgrade_site' => $wp_db_version,
		'welcome_email' => $welcome_email,
		'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
		'siteurl' => get_option( 'siteurl' ) . '/',
		'add_new_users' => '0',
		'upload_space_check_disabled' => '0',
		'subdomain_install' => intval( $subdomain_install ),
		'global_terms_enabled' => global_terms_enabled() ? '1' : '0'
	);
	if ( !intval( $subdomain_install ) )
		$sitemeta['illegal_names'][] = 'blog';

	$insert = '';
	foreach ( $sitemeta as $meta_key => $meta_value ) {
		$meta_key = $wpdb->escape( $meta_key );
		if ( is_array( $meta_value ) )
			$meta_value = serialize( $meta_value );
		$meta_value = $wpdb->escape( $meta_value );
		if ( !empty( $insert ) )
			$insert .= ', ';
		$insert .= "( $network_id, '$meta_key', '$meta_value')";
	}
	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );

	$current_site->domain = $domain;
	$current_site->path = $path;
	$current_site->site_name = ucfirst( $domain );

	if ( !is_multisite() ) {
		$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
		$blog_id = $wpdb->insert_id;
		update_user_meta( $site_user->ID, 'source_domain', $domain );
		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
		if ( !$upload_path = get_option( 'upload_path' ) ) {
			$upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
			update_option( 'upload_path', $upload_path );
		}
		update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
	}

	if ( $subdomain_install )
		update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
	else
		update_option( 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');

	$wp_rewrite->flush_rules();

	if ( $subdomain_install ) {
		$vhost_ok = false;
		$errstr = '';
		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
		$page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
		if ( is_wp_error( $page ) )
			$errstr = $page->get_error_message();
		elseif ( 200 == $page['response']['code'] )
				$vhost_ok = true;

		if ( ! $vhost_ok ) {
			$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';
			$msg .= '<p>' . sprintf( __( 'The installer attempted to contact a random hostname (<code>%1$s</code>) on your domain.' ), $hostname );
			if ( ! empty ( $errstr ) )
				$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
			$msg .= '</p>';
			$msg .= '<p>' . __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a <code>*</code> hostname record pointing at your web server in your DNS configuration tool.' ) . '</p>';
			$msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>';
			return new WP_Error( 'no_wildcard_dns', $msg );
		}
	}

	return true;
}
Ejemplo n.º 19
0
								<td valign="top">
								<?php 
                            if ($blog['registered'] == '0000-00-00 00:00:00') {
                                echo '&#x2014;';
                            } else {
                                echo mysql2date(__($date), $blog['registered']);
                            }
                            ?>
								</td>
						<?php 
                            break;
                        case 'users':
                            ?>
								<td valign="top">
									<?php 
                            $blogusers = get_users_of_blog($blog['blog_id']);
                            if (is_array($blogusers)) {
                                $blogusers_warning = '';
                                if (count($blogusers) > 5) {
                                    $blogusers = array_slice($blogusers, 0, 5);
                                    $blogusers_warning = __('Only showing first 5 users.') . ' <a href="' . esc_url(get_admin_url($blog['blog_id'], 'users.php')) . '">' . __('More') . '</a>';
                                }
                                foreach ($blogusers as $key => $val) {
                                    echo '<a href="' . esc_url(admin_url('user-edit.php?user_id=' . $val->user_id)) . '">' . esc_html($val->user_login) . '</a> ';
                                    if ('list' != $mode) {
                                        echo '(' . $val->user_email . ')';
                                    }
                                    echo '<br />';
                                }
                                if ($blogusers_warning != '') {
                                    echo '<strong>' . $blogusers_warning . '</strong><br />';
Ejemplo n.º 20
0
    /**
     * @access private
     * @since 2.0
     * @return void
     */
    function _options_page()
    {
        global $wpdb, $wp_roles, $wp_version;
        $the_role = $this->get_option('role');
        $widgets = $this->get_option('widgets');
        $allowed = $banned = array();
        foreach (get_users_of_blog() as $blog_user) {
            if ($this->banned_execute($blog_user->ID)) {
                $banned[] = $blog_user->user_login;
            } else {
                if ($this->can_execute($blog_user->ID) || $widgets && ($blog_user =& new WP_User($blog_user->ID)) && $blog_user->has_cap('edit_theme_options')) {
                    $allowed[] = $blog_user->user_login;
                }
            }
        }
        sort($allowed);
        sort($banned);
        $this->_comment_tag(true);
        ?>
	<div id="<?php 
        $this->slug(true, true);
        ?>
" class="wrap">
		<h2><?php 
        $this->_plugin_data('Name', true, true);
        ?>
</h2>
		<form method="post" action="">
			<fieldset class="options">
				<table class="editform">
					<tr>
						<th scope="row"><?php 
        _e('Author:', $this->slug());
        ?>
</th>
						<td><a href="<?php 
        $this->_plugin_data('authoruri', true, true);
        ?>
" target="_blank"><?php 
        $this->_plugin_data('author', true, true);
        ?>
</a> | <a href="<?php 
        $this->_plugin_data('otherplugins', true, true);
        ?>
" target="_blank"><?php 
        printf(__('Other plugins by %1$s', $this->slug()), $this->_plugin_data('author', true));
        ?>
</a> | <a href="<?php 
        $this->_plugin_data('uri', true, true);
        ?>
" target="_blank"><?php 
        _e('Documentation', $this->slug());
        ?>
</a> | <a href="<?php 
        $this->_plugin_data('donate', true, true);
        ?>
"><?php 
        _e('Donate', $this->slug());
        ?>
</a></td>
					</tr>
					<tr>
						<th scope="row"><?php 
        _e('Credit:', $this->slug());
        ?>
</th>
						<td><?php 
        printf(__('Inspired by %1$s by %2$s.', $this->slug()), '<a href="http://priyadi.net/archives/2005/03/02/wordpress-php-exec-plugin/" target="_blank">PHP Exec</a>', '<a href="http://priyadi.net/" target="_blank">Priyadi Iman Nurcahyo</a>');
        ?>
</td>
					</tr>
					<tr>
						<th scope="row"><?php 
        _e('Version:', $this->slug());
        ?>
</th>
<?php 
        if (version_compare($wp_version, '2.9.0', '>=')) {
            ?>
						<td class="<?php 
            if ($this->latest_version()) {
                echo 'green';
            } else {
                echo 'red';
            }
            ?>
"><span class="dashed" title="<?php 
            if ($this->latest_version()) {
                _e('Latest version', $this->slug());
            } else {
                _e('Newer version avalible', $this->slug());
            }
            ?>
"><?php 
            $this->version(true, true);
            ?>
</span></td>
<?php 
        } else {
            ?>
						<td><span class="dashed"><?php 
            $this->version(true, true);
            ?>
</span></td>
<?php 
        }
        ?>
					</tr>
					<tr><td>&nbsp;</td></tr>
					<tr>
						<th scope="row"><?php 
        _e('Role:', $this->slug());
        ?>
</th>
						<td>
							<label>
								<select name="<?php 
        $this->slug(true, true);
        ?>
-role">
<?php 
        foreach ($wp_roles->get_names() as $role => $name) {
            echo "\t\t\t\t\t\t\t\t\t<!--<option value=\"{$role}\"" . selected($the_role, $role, false) . ">{$name}</option>-->\n";
        }
        for ($i = 10; $i > 0; $i--) {
            echo "\t\t\t\t\t\t\t\t\t<option value=\"level_{$i}\"" . selected($the_role, "level_{$i}", false) . '>' . sprintf(__('Level %1$d', $this->slug()), $i) . "</option>\n";
        }
        ?>
								</select>
								<?php 
        _e('The required <a href="http://codex.wordpress.org/Roles_and_Capabilities#User_Levels" target="_blank">User Level</a> to execute PHP in posts &amp; pages and hook onto actions and filters.', $this->slug());
        ?>
 
							</label>
						</td>
					</tr>
					<tr>
						<th scope="row"><?php 
        _e('Actions &amp; Filters:', $this->slug());
        ?>
</th>
						<td>
							<p>
								<label>
									<input name="<?php 
        $this->slug(true, true);
        ?>
-hooks" type="checkbox"<?php 
        checked($this->get_option('hooks'));
        ?>
 />
									<?php 
        _e('Allow hooking onto <a href="http://codex.wordpress.org/Plugin_API" target="_blank">actions and filters</a> using &quot;Custom Fields&quot;. Only works on posts and pages.', $this->slug());
        ?>
 
								</label>
							</p>
							<blockquote cite="http://codex.wordpress.org/Plugin_API">
								<p><?php 
        _e('Actions: Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API.', $this->slug());
        ?>
</p>
							</blockquote>
							<p>action_<em>action_name</em> and action_<em>priority</em>_<em>action_name</em></p>
							<blockquote cite="http://codex.wordpress.org/Plugin_API">
								<p><?php 
        _e('Filters: Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.', $this->slug());
        ?>
</p>
							</blockquote>
							<p>filter_<em>filter_name</em> and filter_<em>priority</em>_<em>filter_name</em></p>
						</td>
					</tr>
					<tr>
						<th scope="row"><?php 
        _e('Widgets:', $this->slug());
        ?>
</th>
						<td>
							<label>
								<input name="<?php 
        $this->slug(true, true);
        ?>
-widgets" type="checkbox"<?php 
        checked($widgets);
        ?>
 />
								<?php 
        _e('Execute PHP in text widgets. Anyone who can add widgets can execute PHP if this option is selected.', $this->slug());
        ?>
 
							</label>
						</td>
					</tr>
					<tr><td>&nbsp;</td></tr>
					<tr>
						<th><?php 
        _e('Allowed Users:', $this->slug());
        ?>
</th>
						<td class="green"><?php 
        echo implode(', ', $allowed);
        ?>
</td>
					</tr>
					<tr>
						<th><?php 
        _e('Banned Users:', $this->slug());
        ?>
</th>
						<td class="red">
							<p style="margin:0;"><?php 
        echo implode(', ', $banned);
        ?>
</p>
							<p style="margin:0;"><em class="dashed red" title="<?php 
        _e('Will be added to a future release.', $this->slug());
        ?>
"><?php 
        _e('Not yet supported.', $this->slug());
        ?>
</em></p>
						</td>
					</tr>
<?php 
        do_action("{$this->slug('hook')}-options-page");
        ?>
					<tr><td>&nbsp;</td></tr>
					<tr>
						<th><input type="submit" class="button-primary" name="<?php 
        $this->slug(true, true);
        ?>
-submit" value="<?php 
        _e('Save', $this->slug());
        ?>
" /></th>
						<td><input type="submit" class="button-primary" name="<?php 
        $this->slug(true, true);
        ?>
-reset" value="<?php 
        _e('Reset', $this->slug());
        ?>
" onclick="return confirm('<?php 
        _e('WARNING: This will reset ALL options, are you sure want to continue?', $this->slug());
        ?>
');" /></td>
					</tr>
					<tr><td>&nbsp;</td></tr>
					<tr>
						<th></th>
						<td><?php 
        printf(__('Please support us by <a href="http://twitter.com/?status=I+just+installed+%2$s+WordPress+plugin+%3$s+%%23wordpress" target="_blank">tweeting about this plugin</a>, <a href="%1$s" target="_blank">writing a post about this plugin</a> or <a href="%4$s">donating</a>.', $this->slug()), admin_url('post-new.php'), urlencode($this->_plugin_data('name')), urlencode($this->_plugin_data('shortlink')), $this->_plugin_data('donate', true));
        ?>
</td>
					</tr>
				</table>
			</fieldset>
			<?php 
        wp_nonce_field("{$this->file}_{$this->slug()}_{$this->version()}");
        ?>
		</form>
	</div>
<?php 
        $this->_comment_tag(false);
    }
Ejemplo n.º 21
0
 private function check_author($author)
 {
     if (is_null($author)) {
         return true;
     }
     $authors = get_users_of_blog();
     if (empty($authors) || is_wp_error($authors)) {
         WP_CLI::warning(sprintf("Could not find any authors in this blog"));
         return false;
     }
     $hit = false;
     foreach ($authors as $user) {
         if ($hit) {
             break;
         }
         if ((int) $author == $user->ID || $author == $user->user_login) {
             $hit = $user->ID;
         }
     }
     if (false === $hit) {
         $authors_nice = array();
         foreach ($authors as $_author) {
             $authors_nice[] = sprintf('%s (%s)', $_author->user_login, $_author->display_name);
         }
         WP_CLI::warning(sprintf('Could not find a matching author for %s. The following authors exist: %s', $author, implode(", ", $authors_nice)));
         return false;
     }
     $this->export_args['author'] = $hit;
     return true;
 }
/**
 * List all the authors of the blog, with several options available.
 *
 * <ul>
 * <li>optioncount (boolean) (false): Show the count in parenthesis next to the
 * author's name.</li>
 * <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is
 * installed bydefault.</li>
 * <li>show_fullname (boolean) (false): Show their full names.</li>
 * <li>hide_empty (boolean) (true): Don't show authors without any posts.</li>
 * <li>feed (string) (''): If isn't empty, show links to author's feeds.</li>
 * <li>feed_image (string) (''): If isn't empty, use this image to link to
 * feeds.</li>
 * <li>echo (boolean) (true): Set to false to return the output, instead of
 * echoing.</li>
 * <li>style (string) ('list'): Whether to display list of authors in list form
 * or as a string.</li>
 * <li>html (bool) (true): Whether to list the items in html for or plaintext.
 * </li>
 * </ul>
 *
 * @link http://codex.wordpress.org/Template_Tags/wp_list_authors
 * @since 1.2.0
 * @param array $args The argument array.
 * @return null|string The output, if echo is set to false.
 */
function wp_list_authors($args = '')
{
    global $wpdb;
    $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'style' => 'list', 'html' => true);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $return = '';
    /** @todo Move select to get_authors(). */
    $users = get_users_of_blog();
    $author_ids = array();
    foreach ((array) $users as $user) {
        $author_ids[] = $user->user_id;
    }
    if (count($author_ids) > 0) {
        $author_ids = implode(',', $author_ids);
        $authors = $wpdb->get_results("SELECT ID, user_nicename from {$wpdb->users} WHERE ID IN({$author_ids}) " . ($exclude_admin ? "AND user_login <> 'admin' " : '') . "ORDER BY display_name");
    } else {
        $authors = array();
    }
    $author_count = array();
    foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM {$wpdb->posts} WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " GROUP BY post_author") as $row) {
        $author_count[$row->post_author] = $row->count;
    }
    foreach ((array) $authors as $author) {
        $link = '';
        $author = get_userdata($author->ID);
        $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
        $name = $author->display_name;
        if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
            $name = "{$author->first_name} {$author->last_name}";
        }
        if (!$html) {
            if ($posts == 0) {
                if (!$hide_empty) {
                    $return .= $name . ', ';
                }
            } else {
                $return .= $name . ', ';
            }
            // No need to go further to process HTML.
            continue;
        }
        if (!($posts == 0 && $hide_empty) && 'list' == $style) {
            $return .= '<li>';
        }
        if ($posts == 0) {
            if (!$hide_empty) {
                $link = $name;
            }
        } else {
            $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__("Posts by %s"), $author->display_name)) . '">' . $name . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_author_feed_link($author->ID) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . esc_attr($feed) . '"';
                    $alt = ' alt="' . esc_attr($feed) . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"" . esc_url($feed_image) . "\" style=\"border: none;\"{$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if ($optioncount) {
                $link .= ' (' . $posts . ')';
            }
        }
        if (!($posts == 0 && $hide_empty) && 'list' == $style) {
            $return .= $link . '</li>';
        } else {
            if (!$hide_empty) {
                $return .= $link . ', ';
            }
        }
    }
    $return = trim($return, ', ');
    if (!$echo) {
        return $return;
    }
    echo $return;
}
Ejemplo n.º 23
0
function simple_local_avatars_uninstall()
{
    $simple_local_avatars = new Simple_Local_Avatars();
    $users = get_users_of_blog();
    foreach ($users as $user) {
        $simple_local_avatars->avatar_delete($user->user_id);
    }
    delete_option('simple_local_avatars_caps');
}
 function admin_emails($id = '')
 {
     $users = get_users_of_blog($id);
     $recipients = array();
     foreach ($users as $user) {
         $user_id = isset($user->user_id) ? $user->user_id : $user->ID;
         $dude = new WP_User($user_id);
         if ($dude->has_cap('administrator')) {
             if ($dude->user_email) {
                 $recipients[] = $dude->user_email;
             }
         }
     }
     return $recipients;
 }
Ejemplo n.º 25
0
function WP_members_list_list()
{
    global $wp_roles, $getWP, $tern_wp_msg, $tern_wp_members_defaults, $current_user, $notice;
    get_currentuserinfo();
    $o = $getWP->getOption('tern_wp_members', $tern_wp_members_defaults);
    $wps = new WP_User_Search($_GET['query'], $_GET['userspage'], $_GET['role']);
    $paging_text = paginate_links(array('total' => ceil($wps->total_users_for_query / $wps->users_per_page), 'current' => $wps->page, 'base' => 'admin.php?page=members-list-edit-members-list&%_%', 'format' => 'userspage=%#%', 'add_args' => $args));
    if ($paging_text) {
        $paging_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($wps->page - 1) * $wps->users_per_page + 1), number_format_i18n(min($wps->page * $wps->users_per_page, $wps->total_users_for_query)), number_format_i18n($wps->total_users_for_query), $paging_text);
    }
    ?>
	<div class="wrap">
		<div id="icon-users" class="icon32"><br /></div>
		<h2>Members List</h2>
		<?php 
    if (!empty($notice)) {
        ?>
<div id="notice" class="error"><p><?php 
        echo $notice;
        ?>
</p></div><?php 
    }
    ?>
		<p>Here you are able to select which of your members you'd like to show or hide in your members list. By default all members are showm.</p>
		<?php 
    if (!empty($tern_wp_msg)) {
        echo '<div id="message" class="updated fade"><p>' . $tern_wp_msg . '</p></div>';
    }
    ?>
		<div class="filter">
			<form id="list-filter" action="" method="get">
				<ul class="subsubsub">
					<?php 
    $l = array();
    $a = array();
    $u = get_users_of_blog();
    $t = count($u);
    foreach ((array) $u as $c) {
        $d = unserialize($c->meta_value);
        foreach ((array) $d as $e => $v) {
            if (!isset($a[$e])) {
                $a[$e] = 0;
            }
            $a[$e]++;
        }
    }
    unset($u);
    $current_role = false;
    $class = empty($role) ? ' class="current"' : '';
    $l[] = "<li><a href='admin.php?page=members-list-edit-members-list'{$class}>" . sprintf(__ngettext('All<span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $t), number_format_i18n($t)) . '</a>';
    foreach ($wp_roles->get_names() as $s => $name) {
        if (!isset($a[$s])) {
            continue;
        }
        $class = '';
        if ($s == $role) {
            $current_role = $role;
            $class = ' class="current"';
        }
        $name = translate_with_context($name);
        $name = sprintf(_c('%1$s <span class="count">(%2$s)</span>|user role with count'), $name, $a[$s]);
        $l[] = "<li><a href='admin.php?page=members-list-edit-members-list&role={$s}'{$class}>{$name}</a>";
    }
    echo implode(" |</li>\n", $l) . '</li>';
    unset($l);
    ?>
				</ul>
			</form>
		</div>
		<form class="search-form" action="" method="get">
			<p class="search-box">
				<label class="hidden" for="user-search-input">Search Users:</label>
				<input type="text" class="search-input" id="user-search-input" name="query" value="" />
				<input type="hidden" id="page" name="page" value="<?php 
    echo $_REQUEST['page'];
    ?>
" />
				<input type="submit" value="Search Users" class="button" />
			</p>
		</form>
		<form id="posts-filter" action="" method="get">
			<div class="tablenav">
				<?php 
    if ($wps->results_are_paged()) {
        ?>
					<div class="tablenav-pages"><?php 
        echo $paging_text;
        ?>
</div>
				<?php 
    }
    ?>
				<div class="alignleft actions">
					<select name="action">
						<option value="" selected="selected">Bulk Actions</option>
						<option value="show">Show</option>
						<option value="hide">Hide</option>
					</select>
					<input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" />
				</div>
				<br class="clear" />
			</div>
			<table class="widefat fixed" cellspacing="0">
				<thead>
				<tr class="thead">
					<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
					<th scope="col" id="username" class="manage-column column-username" style="">Username</th>
					<th scope="col" id="name" class="manage-column column-name" style="">Name</th>
					<th scope="col" id="email" class="manage-column column-email" style="">E-mail</th>
					<th scope="col" id="role" class="manage-column column-role" style="">Role</th>
					<th scope="col" id="displayed" class="manage-column column-displayed" style="">Displayed</th>
				</tr>
				</thead>
				<tfoot>
				<tr class="thead">
					<th scope="col"  class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
					<th scope="col"  class="manage-column column-username" style="">Username</th>
					<th scope="col"  class="manage-column column-name" style="">Name</th>
					<th scope="col"  class="manage-column column-email" style="">E-mail</th>
					<th scope="col"  class="manage-column column-role" style="">Role</th>
					<th scope="col" id="displayed" class="manage-column column-displayed" style="">Displayed</th>
				</tr>
				</tfoot>
				<tbody id="users" class="list:user user-list">
<?php 
    //
    $c = 0;
    //foreach($m as $u) {
    foreach ($wps->get_results() as $u) {
        $u = new WP_User($u);
        $r = $u->roles;
        $r = array_shift($r);
        if (!empty($_REQUEST['role']) and $_REQUEST['role'] != $r) {
            continue;
        }
        $d = is_float($c / 2) ? '' : ' class="alternate"';
        $nu = $current_user;
        $e = $u->ID == $nu->ID ? 'profile.php' : 'user-edit.php?user_id=' . $u->ID . '&#038;wp_http_referer=' . wp_get_referer();
        ?>
		<tr id='user-<?php 
        echo $u->ID;
        ?>
'<?php 
        echo $d;
        ?>
>
			<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_<?php 
        echo $u->ID;
        ?>
' class='administrator' value='<?php 
        echo $u->ID;
        ?>
' /></th>
			<td class="username column-username">
				<?php 
        echo get_avatar($u->ID, 32);
        ?>
				<strong>
					<a href="<?php 
        echo $e;
        ?>
"><?php 
        echo $u->user_nicename;
        ?>
</a>
				</strong><br />
				<div class="row-actions">
					<span class='edit'><a href="admin.php?page=members-list-edit-members-list&users%5B%5D=<?php 
        echo $u->ID;
        ?>
&action=show&_wpnonce=<?php 
        echo wp_create_nonce('tern_wp_members_nonce');
        ?>
">Show</a> | </span>
					<span class='edit'><a href="admin.php?page=members-list-edit-members-list&users%5B%5D=<?php 
        echo $u->ID;
        ?>
&action=hide&_wpnonce=<?php 
        echo wp_create_nonce('tern_wp_members_nonce');
        ?>
">Hide</a></span>
				</div>
			</td>
			<td class="name column-name"><?php 
        echo $u->first_name . ' ' . $u->last_name;
        ?>
</td>
			<td class="email column-email"><a href='mailto:<?php 
        echo $u->user_email;
        ?>
' title='e-mail: <?php 
        echo $u->user_email;
        ?>
'><?php 
        echo $u->user_email;
        ?>
</a></td>
			<td class="role column-role"><?php 
        echo $r;
        ?>
</td>
			<td class="role column-displayed"><?php 
        if (!empty($o['hidden']) and in_array($u->ID, $o['hidden'])) {
            echo 'no';
        } else {
            echo 'yes';
        }
        ?>
</td>
		</tr>
<?php 
        $c++;
    }
    ?>
				</tbody>
			</table>
			<div class="tablenav">
				<div class="alignleft actions">
					<select name="action2">
						<option value="" selected="selected">Bulk Actions</option>
						<option value="show">Show</option>
						<option value="hide">Hide</option>
					</select>
					<input type="hidden" id="page" name="page" value="members-list-edit-members-list" />
					<input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php 
    echo wp_create_nonce('tern_wp_members_nonce');
    ?>
" />
					<input type="submit" value="Apply" name="doaction2" id="doaction2" class="button-secondary action" />
				</div>
				<br class="clear" />
			</div>
		</form>
	</div>
<?php 
}
Ejemplo n.º 26
0
function confirm_delete_users($users)
{
    if (!is_array($users)) {
        return false;
    }
    echo '<p>' . __('Transfer posts before deleting users:') . '</p>';
    echo '<form action="wpmu-edit.php?action=allusers" method="post">';
    echo '<input type="hidden" name="alluser_transfer_delete" />';
    wp_nonce_field('allusers');
    foreach ((array) $_POST['allusers'] as $key => $val) {
        if ($val != '' && $val != '0' && $val != '1') {
            echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
            $blogs = get_blogs_of_user($val, true);
            if (!empty($blogs)) {
                foreach ((array) $blogs as $key => $details) {
                    $blog_users = get_users_of_blog($details->userblog_id);
                    if (is_array($blog_users) && !empty($blog_users)) {
                        echo "<p><a href='http://{$details->domain}{$details->path}'>{$details->blogname}</a> ";
                        echo "<select name='blog[{$val}][{$key}]'>";
                        $out = '';
                        foreach ($blog_users as $user) {
                            if ($user->user_id != $val) {
                                $out .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
                            }
                        }
                        if ($out == '') {
                            $out = "<option value='1'>admin</option>";
                        }
                        echo $out;
                        echo "</select>\n";
                    }
                }
            }
        }
    }
    echo "<br /><input type='submit' value='" . __('Delete user and transfer posts') . "' />";
    echo "</form>";
    return true;
}
Ejemplo n.º 27
0
/**
 * Get lists of users from database
 *
 * @return array
 */
function wpuf_list_users()
{
    if (function_exists('get_users')) {
        $users = get_users();
    } else {
        ////wp 3.1 fallback
        $users = get_users_of_blog();
    }
    $list = array();
    if ($users) {
        foreach ($users as $user) {
            $list[$user->ID] = $user->display_name;
        }
    }
    return $list;
}
Ejemplo n.º 28
0
 function get_user_options($current)
 {
     global $importer_users;
     if (!isset($importer_users)) {
         $importer_users = (array) get_users_of_blog();
     }
     foreach ($importer_users as $user) {
         $sel = $user->user_id == $current ? " selected='selected'" : '';
         $options .= "<option value='{$user->user_id}'{$sel}>{$user->display_name}</option>";
     }
     return $options;
 }
Ejemplo n.º 29
0
 /**
  * WordPress XML-RPC API
  * wp_getAuthors
  */
 function wp_getAuthors($args)
 {
     $this->escape($args);
     $blog_id = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     if (!$this->login_pass_ok($username, $password)) {
         return $this->error;
     }
     set_current_user(0, $username);
     if (!current_user_can("edit_posts")) {
         return new IXR_Error(401, __("Sorry, you can not edit posts on this blog."));
     }
     do_action('xmlrpc_call', 'wp.getAuthors');
     $authors = array();
     foreach ((array) get_users_of_blog() as $row) {
         $authors[] = array("user_id" => $row->user_id, "user_login" => $row->user_login, "display_name" => $row->display_name);
     }
     return $authors;
 }
Ejemplo n.º 30
0
	/**
	 * WordPress XML-RPC API
	 * wp_getAuthors
	 */
	function wp_getAuthors($args) {
		global $wpdb;

		$this->escape($args);

		$blog_id	= (int) $args[0];
		$username	= $args[1];
		$password	= $args[2];

		if(!$this->login_pass_ok($username, $password)) {
			return($this->error);
		}

		return(get_users_of_blog());
	}