コード例 #1
0
function cp_wp_add_dashboard_widgets()
{
    //check if dashboard widget is enabled
    $options = cp_get_options();
    if (isset($options['dashboard_meta_box']) && $options['dashboard_meta_box'] == 'enabled') {
        wp_add_dashboard_widget('cp_wp_dashboard_widget', __('CollabPress - Recent Activity', 'collabpress'), 'cp_wp_dashboard_widget_function');
    }
}
コード例 #2
0
ファイル: dashboard.php プロジェクト: clarkewd/CollabPress
function cp_add_admin_menu_item()
{
    $cp_options = cp_get_options();
    $cp_user_role = isset($cp_options['user_role']) ? esc_attr($cp_options['user_role']) : 'manage_options';
    add_menu_page(__('CollabPress Dashboard', 'collabpress'), __('CollabPress', 'collabpress'), $cp_user_role, COLLABPRESS_DASHBOARD_PAGE, 'cp_admin_menu_page_load', COLLABPRESS_PLUGIN_URL . 'includes/images/collabpress-menu-icon.png');
    //load settings user role
    $cp_settings_user_role = isset($cp_options['settings_user_role']) ? esc_attr($cp_options['settings_user_role']) : 'manage_options';
    $cp_settings_page_hook = add_submenu_page(COLLABPRESS_DASHBOARD_PAGE, __('CollabPress Settings', 'collabpress'), __('Settings', 'collabpress'), $cp_settings_user_role, 'collabpress-settings', 'cp_settings_page');
}
コード例 #3
0
ファイル: update.php プロジェクト: clarkewd/CollabPress
/**
 * Update scripts for specific versions
 *
 * @since 1.3
 */
function cp_update()
{
    global $wpdb;
    $installed_version = get_option('CP_VERSION');
    if ($installed_version != COLLABPRESS_VERSION) {
        // 1.3 specific upgrades
        if (version_compare($installed_version, '1.3-dev', '<')) {
            $tablename = $wpdb->prefix . 'cp_project_users';
            // Add project_users table
            $sql = "CREATE TABLE {$tablename} (\n\t\t\t\tproject_member_id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t\tproject_id bigint(20) NOT NULL,\n\t\t\t\tuser_id bigint(20) NOT NULL,\n\t\t\t\tUNIQUE KEY project_member_id (project_member_id)\n\t\t\t);";
            require_once ABSPATH . 'wp-admin/includes/upgrade.php';
            dbDelta($sql);
            // Move old user relationships into new user table
            $projects = get_posts(array('post_type' => 'cp-projects', 'posts_per_page' => -1));
            foreach ($projects as $project) {
                $users = get_post_meta($project->ID, '_cp-project-users', true);
                foreach ($users as $user_id) {
                    cp_add_user_to_project($project->ID, $user_id);
                }
            }
        }
        // 1.4 specific upgrades
        if (version_compare($installed_version, '1.4-dev', '<')) {
            // Change task due date storage format from m/d/yy to mysql formatted date
            $tasks = get_posts(array('post_type' => 'cp-tasks', 'posts_per_page' => -1));
            foreach ($tasks as $task) {
                $due_date = cp_get_task_due_date_mysql($task->ID);
                $unix_timestamp = strtotime($due_date);
                $formatted_date = gmdate('Y-m-d H:i:s', $unix_timestamp);
                cp_update_task(array('ID' => $task->ID, 'task_due_date' => $formatted_date));
            }
            // 1.4 introduces the date format option, which we need to add
            // a default to in the cp_options.
            $cp_options = cp_get_options();
            if (empty($cp_options['date_format'])) {
                $cp_options['date_format'] = 'F j, Y';
                update_option('cp_options', $cp_options);
            }
        }
        update_option('CP_VERSION', COLLABPRESS_VERSION);
    }
}
コード例 #4
0
ファイル: settings.php プロジェクト: clarkewd/CollabPress
		<h2><?php 
    _e('CollabPress Settings', 'collabpress');
    ?>
</h2>
			<?php 
    // User Notice
    $sent_data = $_POST ? $_POST : $_GET;
    cp_user_notice($sent_data);
    ?>
			<form method="post" action="options.php">

			<?php 
    settings_fields('cp_options_group');
    ?>
			<?php 
    $options = cp_get_options();
    ?>

			<?php 
    //clear activity log
    if (isset($_POST['cp_clear_activity']) && $_POST['cp_clear_activity'] == 'Delete Log') {
        //delete all activity log posts
        $tasks_args = array('post_type' => 'cp-meta-data', 'showposts' => '-1');
        $activity_query = new WP_Query($tasks_args);
        // WP_Query();
        if ($activity_query->have_posts()) {
            while ($activity_query->have_posts()) {
                $activity_query->the_post();
                //delete the activity
                wp_delete_post(get_the_ID(), true);
            }
コード例 #5
0
ファイル: cp-bp-groups.php プロジェクト: clarkewd/CollabPress
 /**
  * Constructor
  *
  * @package CollabPress
  * @subpackage CP BP
  * @since 1.2
  */
 function __construct()
 {
     global $bp;
     $this->cp_settings = cp_get_options();
     // Set up a group id. This will differ depending on when the class is being instantiated
     if (bp_get_current_group_id()) {
         $this->maybe_group_id = bp_get_current_group_id();
     } else {
         if (!empty($bp->groups->new_group_id)) {
             $this->maybe_group_id = $bp->groups->new_group_id;
         } else {
             $this->maybe_group_id = false;
         }
     }
     // Grab the group settings for use throughout
     $this->group_settings = groups_get_groupmeta($this->maybe_group_id, 'collabpress');
     if (empty($this->group_settings)) {
         $this->group_settings = array();
     }
     // Should we enable the group tab?
     if (!empty($this->group_settings)) {
         $this->enable_nav_item = isset($this->group_settings['group_enable']) && 'enabled' == $this->group_settings['group_enable'];
     } else {
         // Should the group tab be enabled by default? Mostly for backpat and groups
         // created before CP was installed.
         $this->enable_nav_item = apply_filters('bp_cp_group_enable_default', true);
     }
     // Abstract some of the sitewide settings
     $this->admins_can_disable = 'allow' == $this->cp_settings['bp']['groups_admins_can_disable'];
     $this->admins_can_customize = 'allow' == $this->cp_settings['bp']['groups_admins_can_customize'];
     // Set up name and slug
     if ($this->admins_can_customize) {
         // Admins are allowed to customize this data
         // Fall back on sitewide settings if none have been provided
         $this->name = !empty($this->group_settings['tab_name']) ? $this->group_settings['tab_name'] : $this->cp_settings['bp']['groups_default_tab_name'];
         $this->slug = !empty($this->group_settings['tab_slug']) ? $this->group_settings['tab_slug'] : $this->cp_settings['bp']['groups_default_tab_slug'];
     } else {
         // Use the sitewide settings
         $this->name = $this->cp_settings['bp']['groups_default_tab_name'];
         $this->slug = $this->cp_settings['bp']['groups_default_tab_slug'];
     }
     // Put the CP slug in the main global for later access when building URLs
     cp_bp()->item_cp_slug = $this->slug;
     // We only need to show in the admin if admins can customize
     if ($this->admins_can_customize || $this->admins_can_disable) {
         $this->enable_create_step = true;
         $this->enable_edit_item = true;
         $this->create_step_position = 35;
     }
     $this->nav_item_position = 31;
     // Allow users to edit/delete items based on group settings
     add_filter('cp_settings_user_role', array(&$this, 'has_cap_edit'), 10, 2);
     add_filter('map_meta_cap', array(&$this, 'map_meta_cap'), 10, 4);
     if (bp_is_group()) {
         // Set up the group's CP link
         $this->cp_link = bp_get_group_permalink(groups_get_current_group()) . $this->slug;
         // Don't do this work unless we're on a CP page
         if (bp_is_current_action($this->slug)) {
             // Tell CollabPress we're on a CP page
             add_filter('is_collabpress_page', '__return_true');
             // Set up the current item
             $this->set_current_item();
             // Based on the current item, set the current view
             $this->set_current_view();
             // A less-than-ideal way to let the main CPBP class know we're done
             do_action('cp_bp_setup_item');
             // Legacy permalink redirection
             add_filter('bp_get_canonical_url', array($this, 'filter_canonical_url'), 10, 2);
             // Setup $cp global
             add_action('cp_global_setup', array($this, 'setup_cp_global'));
         }
         // Get the settings for create and edit/delete roles
         $this->create_role = isset($this->group_settings['create_role']) ? $this->group_settings['create_role'] : 'group-members';
         $this->edit_delete_role = isset($this->group_settings['edit_delete_role']) ? $this->group_settings['edit_delete_role'] : 'admins-mods-owners';
         // Enable the calendar tab if necessary
         $this->calendar_enable = !isset($this->group_settings['calendar_enable']) || 'enabled' == $this->group_settings['calendar_enable'];
         if ($this->calendar_enable) {
             $this->calendar_nav_setup();
         }
         // Ensure that the proper users show up on the user list dropdown
         add_filter('cp_task_user_list_html', array(&$this, 'user_list_html'), 10, 2);
     }
     // Automatically provision group members to each group project
     add_filter('cp_check_project_permissions', array(&$this, 'project_perms'), 10, 4);
     // Filter the tax query for project loops
     add_filter('cp_bp_projects_tax_query', array(&$this, 'projects_tax_query'));
     // Load the styles
     add_action('wp_print_styles', array(&$this, 'enqueue_styles'));
     $this->enqueue_scripts();
     add_action('cp_project_added', array($this, 'add_tax_data_for_new_projects'));
 }
コード例 #6
0
ファイル: cp-bp.php プロジェクト: clarkewd/CollabPress
    /**
     * Render the BP-specific settings options
     *
     * @package CollabPress
     * @subpackage CP BP
     * @since 1.2
     */
    function render_settings()
    {
        // Only show to super admins
        if (!is_super_admin()) {
            return;
        }
        $options = cp_get_options();
        ?>

		<tr>
			<td colspan="2"><h3><?php 
        _e('BuddyPress', 'collabpress');
        ?>
</h3><hr /></td>
		</tr>

		<?php 
        if (bp_is_active('groups')) {
            ?>
			<tr>
				<th scope="row"><label for="cp_options[bp][groups_enabled]"><?php 
            _e('Groups tab', 'collabpress');
            ?>
</label></th>

				<td>
					<select name="cp_options[bp][groups_enabled]">
						<option value="disabled" <?php 
            selected($options['bp']['groups_enabled'], 'disabled');
            ?>
><?php 
            _e('Disabled', 'collabpress');
            ?>
</option>
						<option value="enabled" <?php 
            selected($options['bp']['groups_enabled'], 'enabled');
            ?>
><?php 
            _e('Enabled', 'collabpress');
            ?>
</option>
					</select>
				</td>
			</tr>

			<tr>
				<th scope="row"><label for="cp_options[bp][groups_admins_can_disable]"><?php 
            _e('Allow group admins to disable tab', 'collabpress');
            ?>
</label></th>

				<td>
					<select name="cp_options[bp][groups_admins_can_disable]">
						<option value="allow" <?php 
            selected($options['bp']['groups_admins_can_disable'], 'alow');
            ?>
><?php 
            _e('Allow', 'collabpress');
            ?>
</option>
						<option value="disallow" <?php 
            selected($options['bp']['groups_admins_can_disable'], 'disallow');
            ?>
><?php 
            _e("Don't allow", 'collabpress');
            ?>
</option>
					</select>
				</td>
			</tr>

			<tr>
				<th scope="row"><label for="cp_options[bp][groups_admins_can_customize]"><?php 
            _e('Allow group admins to customize tab name and slug', 'collabpress');
            ?>
</label></th>

				<td>
					<select name="cp_options[bp][groups_admins_can_customize]">
						<option value="allow" <?php 
            selected($options['bp']['groups_admins_can_customize'], 'allow');
            ?>
><?php 
            _e('Allow', 'collabpress');
            ?>
</option>
						<option value="disallow" <?php 
            selected($options['bp']['groups_admins_can_customize'], 'disallow');
            ?>
><?php 
            _e("Don't allow", 'collabpress');
            ?>
</option>
					</select>
				</td>
			</tr>

			<tr>
				<th scope="row"><label for="cp_options[bp][groups_default_tab_name]"><?php 
            _e('Default group tab name', 'collabpress');
            ?>
</label></th>

				<td>
					<input type="text" name="cp_options[bp][groups_default_tab_name]" id="groups-default-tab-name" value="<?php 
            echo esc_html($options['bp']['groups_default_tab_name']);
            ?>
" />
				</td>
			</tr>

			<tr>
				<th scope="row"><label for="cp_options[bp][groups_default_tab_slug]"><?php 
            _e('Default group tab slug', 'collabpress');
            ?>
</label></th>

				<td>
					<input type="text" name="cp_options[bp][groups_default_tab_slug]" id="groups-default-tab-slug" value="<?php 
            echo esc_html($options['bp']['groups_default_tab_slug']);
            ?>
" />
				</td>
			</tr>
		<?php 
        }
        ?>

		<?php 
    }
コード例 #7
0
function cp_recent_activity($data = NULL)
{
    // Get Current User
    global $current_user;
    get_currentuserinfo();
    // Get Activities
    $paged = isset($_GET['paged']) ? esc_html($_GET['paged']) : 1;
    // Load plugin options
    $cp_options = cp_get_options();
    // Check number of recent items to display
    $cp_num_recent = isset($cp_options['num_recent_activity']) ? absint($cp_options['num_recent_activity']) : 4;
    $activities_args = array('post_type' => 'cp-meta-data', 'showposts' => $cp_num_recent, 'paged' => $paged);
    $activities_query = new WP_Query($activities_args);
    echo '<div class="cp-activity-list">';
    // WP_Query();
    if ($activities_query->have_posts()) {
        $activityCount = 1;
        while ($activities_query->have_posts()) {
            $activities_query->the_post();
            global $post;
            if ($activityCount % 2 == 0) {
                $row = " even";
            } else {
                $row = " odd";
            }
            // Avatar
            $activityUser = get_post_meta($post->ID, '_cp-activity-author', true);
            $activityUser = get_userdata($activityUser);
            $activityAction = get_post_meta($post->ID, '_cp-activity-action', true);
            $activityType = get_post_meta($post->ID, '_cp-activity-type', true);
            $activityID = get_post_meta($post->ID, '_cp-activity-ID', true);
            if ($activityUser) {
                ?>

		    <div class="cp-activity-row <?php 
                echo $row;
                ?>
">
			    <a class="cp-activity-author" title="<?php 
                $activityUser->display_name;
                ?>
" href="<?php 
                echo COLLABPRESS_DASHBOARD;
                ?>
&user=<?php 
                echo $activityUser->ID;
                ?>
"><?php 
                echo get_avatar($activityUser->ID, 32);
                ?>
</a>
			    <div class="cp-activity-wrap">
			    <p class="cp-activity-description"><?php 
                echo $activityUser->display_name . ' ' . $activityAction . ' ' . __('a', 'collabpress') . ' ' . $activityType;
                ?>
: <a href="<?php 
                echo cp_get_url($activityID, $activityType);
                ?>
"><?php 
                echo get_the_title($activityID);
                ?>
</a></p>
			    </div>
		    </div>

		    <?php 
            }
            $activityCount++;
        }
        wp_reset_query();
    } else {
        echo '<p>' . __('No Activities...', 'collabpress') . '</p>';
    }
    // Pagination
    if ($activities_query->max_num_pages > 1) {
        echo '<p class="cp_pagination">';
        for ($i = 1; $i <= $activities_query->max_num_pages; $i++) {
            echo '<a href="' . COLLABPRESS_DASHBOARD . '&paged=' . $i . '" ' . ($paged == $i ? 'class="active"' : '') . '>' . $i . '</a> ';
        }
        echo '</p>';
    }
    ?>

	<style type="text/css">
		.cp-activity-list {
		    position: relative;
		}
		.cp-activity-row {
		    margin: 0;
		    overflow: hidden;
		    padding: 2px 10px;
		}
		.cp-activity-list .even {
		    background-color: #FFFFE0;
		}
		.cp-activity-list .cp-activity-author {
		    float: left;
		    margin: 5px 0;
		}
		.cp-activity-list .cp-activity-wrap {
		    margin: 6px 0;
		    overflow: hidden;
		    word-wrap: break-word;
		}
		.cp-activity-list p {
		    font-size: 11px;
		    margin: 6px 6px 8px;
		}
	</style>

	<?php 
    echo '</div>';
}