Subversion Repositories c2i-annu

Rev

Rev 42 | Rev 44 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/* -----------------
/ C2ildapadm Controller
/------------------*/


require_once('include/auth.inc.php');
require_once('include/c2ildapadm.inc.php');
require_once('include/admins.inc.php');
require_once('include/admin.inc.php');
require_once('include/sadmin.inc.php');
require_once('include/schools.inc.php');
require_once('include/pupil.inc.php');

global $c2i_ldap;
global $smarty;
global $current_year;



$ldap_res=ldap_connection();

$user=$_SESSION['user'];


switch ($user->type) {
  case 'sadmin':  
    if ($user->rne=='-1') {
      sadmin_init_menu();
    }
    else {
      admin_init_menu();
    }
    break;
 case 'admin' :
     admin_init_menu();
     break;
 case 'pupil' :
     pupil_init_menu();
     break;
}

$smarty->assign('user_type',$user->type);
$smarty->assign('user_rne',$user->rne);

$action=$_POST['action'];
$page=$_POST['page'];


switch ($page) {
 case 'accueil' :
   break;
   
   /*
      Gestion des administrateurs locaux
   */


 case 'logout' :
     session_unset();
     session_destroy();
     header("Location: https://disconnect:true@c2i1.ac-grenoble.fr/c2i-annu/logout/logout.html");
     break;

 case 'admins' :
   if ($user->type !='sadmin') {
     $action='unauthorized';
   }
   switch ($action) {
   case 'list_admins' :
       sadmin_list_admins();
       break;
   case 'create_admin':
       sadmin_create_admin();
       break;
   case 'edit' :
       sadmin_modify_admin($_POST['uid']);
       break;
   case 'reset_admin_pwd':
       sadmin_reset_admin_pwd($_POST['uid']);
       break;
   case 'reset_all_admins_pwd':
       sadmin_reset_all_admins_pwd();
       break;
   case 'process' :
       sadmin_admin_process();
       break;
   case 'delete' :
       sadmin_delete_admin($_POST['uid']);    
       break;
   case 'confirm_delete' :
       sadmin_confirm_delete_admin($_POST['uid']);
       break;
   case 'import_admins' :
       sadmin_admins_import();
       break;
   case 'export_final_note':
       sadmin_export_naissance();
       break;
   case 'process_import' :
       sadmin_admins_process_import();
       break;
   case 'process_import_create' :
       sadmin_admins_process_import_create();
   case 'unauthorized' :
       c2ildapadm_unauthorized();
       break;
   default :
       c2ildapadm_unauthorized();
       break;
   }
   break;

   /*
    Gestion  des élèves.
   */


 case 'pupils' :
     if ($user->type !='sadmin') {
         $action='unauthorized';
     }
     switch ($action)  {
     case 'recover_pupil_from_ine' :
         $smarty->assign('header_title',"R&eacute;cup&eacute;rer depuis l'INE");
         sadmin_recover_pupil_from_ine();
         break;
     case 'recover_pupil_from_ine_confirm':
         $smarty->assign('header_title',"Confirmation du choix.");
         sadmin_recover_pupil_from_ine_confirm($_POST);
         break;
     case 'recover_pupil_from_ine_process':
         sadmin_recover_pupil_from_ine_process($_POST);
         $smarty->assign('header_title',"R&eacute;cup&eacute;rer depuis l'INE");
         sadmin_recover_pupil_from_ine();
         break;
     case 'unauthorized' :
         c2ildapadm_unauthorized();
         break;
     default:
         sadmin_welcome();
         break;
     }
     break;

  /*
      Gestion des établissements
   */


 case 'schools' :
   if ($user->type !='sadmin') {
     $action='unauthorized';
   }
   switch ($action) {
   case 'welcome_schools' :
     sadmin_welcome_schools();
     break;
   case 'list_schools' :
     sadmin_list_schools();
     break;
   case 'create_school':
     sadmin_create_school();
     break;
   case 'edit' :    
     sadmin_modify_school($_POST['rne']);
     break;
   case 'confirm_delete' :
     sadmin_confirm_delete_school($_POST['rne']);
     break;
   case 'delete' :
     sadmin_delete_school($_POST['rne']);    
     break;
   case 'process' :
     $school=new school($_POST);
     $school->insert_into_ldap();
     sadmin_list_schools();
     break;
   case 'import_schools' :
     sadmin_import_schools();
     break;

   case 'process_import' :
     sadmin_schools_process_import();
     break;
   case 'control_school' :
       $_SESSION['user']->rne=$_POST['rne'];
       $smarty->assign('user_rne',$user->rne);
       admin_init_menu();
       admin_view_school();
       break;
   case 'unauthorized' :
       c2ildapadm_unauthorized();
       break;
   default :
       sadmin_welcome_schools();
       break;
   }
   break;

   /*
    *
    *  Gestion de la configuration
    *
    */


 case 'config' :
   if ($user->type !='sadmin' ) {
     $action='unauthorized';
   }
   switch ($action) {
   case 'parameters':
       sadmin_config_parameters();
       break;
   case 'config_modify' :
       sadmin_config_modify($_POST);
       break;
   case 'ldap_clean' :
       ldap_clean();
       sadmin_welcome();
       break;
   case 'ldap_synchronize' :
       sadmin_ldap_synchronize();
       break;
   case 'process_ldap_synchronize' :
       sadmin_process_ldap_synchronize();
       break;
   case 'ldap_recover_lost_ine' :
       sadmin_ldap_recover_lost_ine();
       break;
   case 'confirm_ldap_recover_lost_ine' :
       sadmin_confirm_ldap_recover_lost_ine();
       break;
   case 'process_ldap_recover_lost_ine' :
       sadmin_process_ldap_recover_lost_ine();
       break;
   default :
     c2ildapadm_unauthorized();
     break;
   }
   break;

   /*
    *  Gestion de l'annuaire
    */


 case 'ldap' :
     if ($user->type !='sadmin') {
         $action='unauthorized';
     }
     
     switch ($action) {
     case 'ldap_export_csv' :
         sadmin_ldap_export_csv();
         break;
     default :
         c2ildapadm_unauthorized();
         break;
     }
     break;

   /*
      Pages des admins locaux
   */


 case 'admin':
   if ($user->type !='sadmin' && $user->type!='admin') {
     $action='unauthorized';
   }
   switch ($action) {
   case 'view_profile' :
     admin_view_profile();
     break;
   case 'view_school' :
     admin_view_school();
     break;
   case 'list_sections' :
     admin_list_sections();
     break;
   case 'create_section' :
     admin_create_section($_POST['section']);
     admin_list_sections();
     break;
   case 'confirm_delete_section' :
     admin_confirm_delete_section($_POST['section']);
     break;
   case 'delete_section' :
     admin_delete_section($_POST['section']);
     admin_list_sections();
     break;
   case 'list_pupils' :
     admin_list_pupils($_POST['section']);
     break;
   case 'reset_pupil_pwd' :
     admin_reset_pupil_password($_POST['uid']);
     break;
   case 'reset_all_pupils_pwd' :
     admin_reset_all_pupils_password($_POST['section']);
     break;
   case 'export_pwd_CSV' :
       admin_export_password_CSV();
       break;
   case 'confirm_delete_pupil' :
     admin_confirm_delete_pupil($_POST['uid']);
     break;
   case 'delete_pupil' :
     admin_delete_pupil($_POST['uid']);
     break;
   case 'import_pupils':
     admin_import_pupils();
     break;
   case 'import_sconet_pupils':
     admin_import_sconet_pupils();
     break;
   case 'edit_pupil' :
     admin_edit_pupil($_POST['uid']);
     break;
   case 'process_import' :
     admin_process_pupils_import();
     break;
   case 'process_sconet_import':
     admin_process_sconet_import();
     break;
   case 'process_sconet_import_create' :
     admin_process_sconet_import_create();
     break;
   case 'note_pupils' :
     admin_list_pupils_note($_POST['section']);
     break;
   case 'process_note_pupils' :
     admin_process_pupils_note($_POST['note'],$_POST['section']);
    break;
   case 'export_pupils_note' :
     admin_export_pupils_note($_POST['section']);
    break;    
   case 'import_pupils_note' :      
       admin_import_pupils_note($_FILES,$_POST['section'],$_SESSION['user']->rne);
       break;
   case 'exportCSV' :
       admin_exportCSV($_SESSION['user']->rne);
       break;
   case 'process_import_create' :
       admin_process_pupils_import_create();
       break;
   case 'sadmin_return' :
       if ($user->type == 'sadmin') {
           sadmin_return();
           $smarty->assign('user_rne','-1');
           sadmin_init_menu();
           sadmin_list_schools();
       } else {
           c2ildapadm_unauthorized();
       }
       break;
   default :
       admin_view_profile();
       break;
   }
   break;
   

 case 'pupil' :
     switch ($action) {
     case 'infos':
         pupil_infos();
         break;
     case 'validation':
         pupil_validation();
         break;
     case 'process_validation':
         pupil_process_validation();
         break;
     }
     break;


 default :
     sadmin_welcome();
     break;
 }
?>