Exemplo n.º 1
0
<?php

$project_obj = CPM_Project::getInstance();
$projects = $project_obj->get_projects();
$total_projects = $projects['total_projects'];
$pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1;
$db_limit = intval(cpm_get_option('pagination'));
$limit = $db_limit ? $db_limit : 10;
$status_class = isset($_GET['status']) ? $_GET['status'] : 'active';
$count = cpm_project_count();
$can_create_project = cpm_manage_capability('project_create_role');
$class = $can_create_project ? '' : ' cpm-no-nav';
unset($projects['total_projects']);
?>

<h2><?php 
_e('Project Manager', 'cpm');
?>
</h2>

<div class="cpm-projects<?php 
echo $class;
?>
">

    <div class="cpm-project-filter">
        <ul class="list-inline order-statuses-filter">
            <li<?php 
echo $status_class == 'all' ? ' class="active"' : '';
?>
>
Exemplo n.º 2
0
 function archive()
 {
     if (!wp_verify_nonce($_POST['_nonce'], 'cpm_nonce')) {
         wp_send_json_error(__('Are you cheating?', 'cpm'));
     }
     if (isset($_POST['project_id'])) {
         $project_id = $_POST['project_id'];
     } else {
         wp_send_json_error(__('Project ID required', 'cpm'));
     }
     if ($_POST['type'] == 'archive') {
         update_post_meta($project_id, '_project_active', 'no');
     } else {
         update_post_meta($project_id, '_project_active', 'yes');
     }
     wp_cache_delete('cpm_count');
     wp_send_json_success(array('url' => cpm_url_projects(), 'count' => cpm_project_count()));
 }
Exemplo n.º 3
0
    /**
     * List all projects
     *
     * @since 1.0
     */
    function list_projects()
    {
        $project_obj = CPM_Project::getInstance();
        $projects = $project_obj->get_projects();
        $status_class = isset($_GET['status']) ? $_GET['status'] : 'active';
        if (function_exists('cpm_project_count')) {
            $count = cpm_project_count();
        }
        ?>

        <div class="icon32" id="icon-themes"><br></div>
        <h2><?php 
        _e('Project Manager', 'cpm');
        ?>
</h2>

        <?php 
        if (function_exists('cpm_project_filters')) {
            cpm_project_filters();
        }
        ?>

        <div class="cpm-projects">

            <?php 
        if (function_exists('cpm_project_filters')) {
            ?>
                <ul class="list-inline order-statuses-filter">
                    <li<?php 
            echo $status_class == 'all' ? ' class="active"' : '';
            ?>
>
                        <a href="<?php 
            echo cpm_url_all();
            ?>
"><?php 
            _e('All', 'cpm');
            ?>
</a>
                    </li>
                    <li<?php 
            echo $status_class == 'active' ? ' class="active"' : '';
            ?>
>
                        <a class="cpm-active" href="<?php 
            echo cpm_url_active();
            ?>
"><?php 
            printf(__('Active (%d)', 'cpm'), $count['active']);
            ?>
</a>
                    </li>
                    <li<?php 
            echo $status_class == 'archive' ? ' class="active"' : '';
            ?>
>
                        <a class="cpm-archive-head" href="<?php 
            echo cpm_url_archive();
            ?>
"><?php 
            printf(__('Completed (%d)', 'cpm'), $count['archive']);
            ?>
</a>
                    </li>
                </ul>
            <?php 
        }
        ?>

            <?php 
        if (cpm_manage_capability('project_create_role')) {
            ?>
                <nav class="cpm-new-project">
                    <a href="#" id="cpm-create-project"><span><?php 
            _e('New Project', 'cpm');
            ?>
</span></a>
                </nav>
            <?php 
        }
        ?>

            <?php 
        foreach ($projects as $project) {
            if (!$project_obj->has_permission($project)) {
                continue;
            }
            ?>
                <article class="cpm-project">
                    <?php 
            if (cpm_is_project_archived($project->ID)) {
                ?>
                        <div class="cpm-completed-wrap"><div class="ribbon-green"><?php 
                _e('Completed', 'cpm');
                ?>
</div></div>
                    <?php 
            }
            ?>

                    <a href="<?php 
            echo cpm_url_project_details($project->ID);
            ?>
">
                        <h5><?php 
            echo get_the_title($project->ID);
            ?>
</h5>

                        <div class="cpm-project-detail"><?php 
            echo cpm_excerpt($project->post_content, 55);
            ?>
</div>
                        <div class="cpm-project-meta">
                            <?php 
            echo cpm_project_summary($project->info);
            ?>
                        </div>

                        <footer class="cpm-project-people">
                            <div class="cpm-scroll">
                            <?php 
            if (count($project->users)) {
                foreach ($project->users as $id => $user_meta) {
                    echo get_avatar($id, 48, '', $user_meta['name']);
                }
            }
            ?>
                            </div>
                        </footer>
                    </a>

                    <?php 
            $progress = $project_obj->get_progress_by_tasks($project->ID);
            echo cpm_task_completeness($progress['total'], $progress['completed']);
            if (cpm_user_can_access($project->ID)) {
                cpm_project_actions($project->ID);
            }
            ?>


                </article>

            <?php 
        }
        ?>

        </div>

        <div id="cpm-project-dialog" title="<?php 
        _e('Start a new project', 'cpm');
        ?>
" style="display: none;">
            <?php 
        if ($project_obj->has_admin_rights()) {
            ?>
                <?php 
            cpm_project_form();
            ?>
            <?php 
        }
        ?>
        </div>

        <div id="cpm-create-user-wrap">
            <?php 
        if ($project_obj->has_admin_rights()) {
            ?>
                <?php 
            cpm_user_create_form();
            ?>
            <?php 
        }
        ?>
        </div>


        <script type="text/javascript">
            jQuery(function($) {
                $( "#cpm-project-dialog, #cpm-create-user-wrap" ).dialog({
                    autoOpen: false,
                    modal: true,
                    dialogClass: 'cpm-ui-dialog',
                    width: 485,
                    height: 425,
                    position:['middle', 100]
                });
            });

            jQuery(function($) {
                $( "#cpm-create-user-wrap" ).dialog({
                    autoOpen: false,
                    modal: true,
                    dialogClass: 'cpm-ui-dialog',
                    width: 400,
                    height: 353,
                    position:['middle', 100]
                });
            });
        </script>
        <?php 
    }