Commit 1294c7cb by Cyrille37

comments

parent 56f2910c
......@@ -60,6 +60,9 @@ class CommunityProject
new ShortcodeController();
}
/**
* A student cannot edit other's projects.
*/
function redirect_if_not_author()
{
if ( isset( $_GET['post'] ) && $_GET['action'] === 'edit' && get_post( $_GET['post'] )->post_type === self::CPT_TYPE )
......@@ -146,6 +149,12 @@ class CommunityProject
}
}
/**
* Return all projects for no student user.
* Return only his/her projects for student user.
*
* @return WP_Post[]
*/
public static function get_projects()
{
if( UserRoleController::isStudent() )
......@@ -157,17 +166,17 @@ class CommunityProject
$author = null ;
return get_posts( array(
'author' => $author,
'numberposts' => 1000,
'category' => 0,
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
'meta_key' => '',
'meta_value' =>'',
'post_type' => ProjectCustomTypeCreator::CPT,
'suppress_filters' => true
'author' => $author,
'post_type' => ProjectCustomTypeCreator::CPT,
'numberposts' => 100,
'orderby' => 'date',
'order' => 'DESC',
//'category' => 0,
//'include' => array(),
//'exclude' => array(),
//'meta_key' => '',
//'meta_value' =>'',
//'suppress_filters' => true
));
}
......
......@@ -33,11 +33,10 @@ class DashboardWidget
public function display_widget()
{
$projects = CommunityProject::get_projects();
/*
/**
* @var WP_Post[] $projects Liste des projets, variable disponible dans le template.
*/
// Display whatever it is you want to show.
$projects = CommunityProject::get_projects();
ob_start();
include __DIR__.'/templates/dashboard.php';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment