Skip to content
This repository has been archived by the owner on Feb 28, 2018. It is now read-only.

Commit

Permalink
cursus dashboards removed
Browse files Browse the repository at this point in the history
See #370
  • Loading branch information
bfontaine committed Oct 19, 2014
1 parent 0d0773f commit cd6e5f4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 139 deletions.
13 changes: 0 additions & 13 deletions controllers/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,6 @@ function display_course_content() {
$js = 'editable-content';

$tpl_proposed = null;

if (user()->isAdmin()) {
$post_token = generate_post_token(user());
FormData::create($post_token)->store('proposed', $content);

$tpl_proposed = array(
'form' => array(
'action' => cursus_url($cursus).'/dash',
'post_token' => $post_token
)
);
}

}

if (is_connected() && user()->isModerator()) {
Expand Down
121 changes: 0 additions & 121 deletions controllers/cursus.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,127 +130,6 @@ function display_cursus() {
return tpl_render('cursus/base.html', $tpl_cursus);
}

function display_cursus_dashboard($has_msg=false, $msg_str='', $msg_type='') {
$name = params('name');
$cursus = CursusQuery::create()->findOneByShortName($name);

if ($cursus == null) { halt(NOT_FOUND); }

if (params('path')) {
// If this is a path, redirect to the main cursus dashboard
redirect_to(cursus_url($cursus).'/dash');
}

if (!is_connected() || !user()->isAdmin()) {
halt(HTTP_FORBIDDEN);
}

$has_msg &= ($msg_str && $msg_type);

$base_uri = Config::$root_uri.'cursus/'.strtoupper($cursus->getShortName()).'/';

$breadcrumbs = array(
array(
'href' => $base_uri,
'title' => $cursus->getName()
),
array(
'href' => url(),
'title' => 'Administration'
)
);

$contents = ContentQuery::create()
->limit(50)
->filterByCursus($cursus)
->orderById()
->findByValidated(0);

$tpl_contents = Array();

if ($contents){

foreach ( $contents as $c ){

$user = $c->getAuthor();
$course = $c->getCourse();

$tpl_c = array(
'title' => $c->getTitle(),
'href' => content_url($cursus, $course, $c),
'date' => tpl_date($c->getCreatedAt()),
'author' => array(
'href' => user_url($user),
'name' => $user->getPublicName()
)
);

$tpl_c['cursus'] = array( 'name' => $cursus->getShortName() );

if ($course) {
$tpl_c ['course'] = array(
'name' => $course->getShortName()
);
}

$tpl_contents []= $tpl_c;
}

}

return tpl_render('cursus/dashboard.html', array(
'page' => array(
'title' => $cursus->getName().' - Administration',
'breadcrumbs' => $breadcrumbs,
'contents' => $tpl_contents,
'message' => ($has_msg === true) ? $msg_str : null,
'message_type' => ($has_msg === true) ? $msg_type : null
)
));
}

function post_cursus_dashboard() {
$name = params('name');
$cursus = CursusQuery::create()->findOneByShortName($name);

if ($cursus == null) { halt(NOT_FOUND); }

if (!is_connected() || !user()->isAdmin()) {
halt(HTTP_FORBIDDEN);
}

$msg_str = null;

if (!has_post('t')) { halt(HTTP_BAD_REQUEST); }

$token = $_POST['t'];

$fd = FormData::create($token);

if ((!use_token($token, 'POST')) || (!$fd->exists())) {
halt(HTTP_FORBIDDEN, 'Le jeton d\'authentification est invalide ou a expiré.');
}

$content = $fd->get('proposed');

if ( !has_post('validate') && !has_post('delete') )
return display_cursus_dashboard(true,
'Erreur interne (nopost:validate,delete)', 'error');

if ( has_post('validate') ) {
$content->setValidated(1);
$content->save();
$msg_str = 'Le contenu a bien été validé.';
}

if ( has_post('delete') ){
$content->delete();
$msg_str = 'Le contenu a bien été supprimé.';
}

return display_cursus_dashboard(true, $msg_str, 'success');
}

function display_cursus_with_multiple_educational_paths($cursus, $msg_str, $msg_type, $base_uri, $breadcrumb) {

$paths = $cursus->getEducationalPaths();
Expand Down
5 changes: 0 additions & 5 deletions routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ function redirect_profile_init() { redirect_to('/profil/créer'); }
dispatch('/cursus/:name', 'display_cursus');
dispatch_post('/cursus/:name', 'display_cursus');

## cursus admin
dispatch('/cursus/:name/dash', 'display_cursus_dashboard');
dispatch_post('/cursus/:name/dash', 'post_cursus_dashboard');

## educational paths
dispatch('/cursus/:cursus/parcours/:path', 'display_educational_path');
dispatch('/cursus/:name/parcours/:path/dash', 'display_cursus_dashboard');

## cursus feeds
dispatch('/cursus/:name/flux.rss', 'display_cursus_rss_feed');
Expand Down

0 comments on commit cd6e5f4

Please sign in to comment.