File manager - Edit - /home/missmand/public_html/learning/old/main/cooperation/index.php
Back
<?php /* For licensing terms, see /license.txt */ /** * Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action * @author Batiste Roger <batiste.roger@live.fr> * @package chamilo.cooperation */ assert_options(ASSERT_BAIL, true); // Make asserts stop code execution when failed (TODO - Remove) // Require subrole methods require_once '../inc/global.inc.php'; require_once(api_get_path(SYS_PATH) . 'main/subrole/subrole.php'); require_once(api_get_path(SYS_PATH) . 'main/couple/model.php'); require_once(api_get_path(SYS_PATH) . 'main/couple/action.php'); require_once(api_get_path(SYS_PATH) . 'main/couple/agenda.php'); require_once(api_get_path(SYS_PATH) . 'main/couple/tchat.php'); require_once(api_get_path(SYS_PATH) . 'main/couple/doc.php'); require_once(api_get_path(SYS_PATH) . 'main/couple/doc_system.php'); require_once(api_get_path(SYS_PATH) . 'main/couple/notification.php'); // current section unset($_SESSION['this_section']); //for hmtl editor repository // protect script api_block_anonymous_users(); $error_context = "cooperation/index.php"; $my_user_id = api_get_user_id(); $my_subrole = get_subrole($my_user_id); $is_admin = ($my_subrole == ADMIN); // Test notification click if (isset($_POST['item']) && $_POST['item'] == 'notification' && $_POST['action'] == 'delete') notification_delete($_POST['id']); // GET form content / creation, deletion... if (isset($_POST['type'])) { couple_create($_POST['type'], $_POST['hp_id'], $_POST['pa_id']); } elseif (isset($_POST['action']) && $_POST['action'] == 'delete' && UserManager::is_admin(api_get_user_id())) { couple_delete($_POST['couple_id'], $_POST['couple_type']); } if ($my_subrole == TUTOR) { if (isset($_GET['action']) && $_GET['action'] == 'select' && isset($_GET['id']) && isset($_GET['type'])) { $_SESSION['mm_couple_id'] = $_GET['id']; $_SESSION['mm_couple_type'] = $_GET['type']; } elseif (isset($_GET['action']) && $_GET['action'] == 'unset') { unset($_SESSION['mm_couple_id']); unset($_SESSION['mm_couple_type']); } if (!isset($_SESSION['mm_couple_id']) || !isset($_SESSION['mm_couple_type'])) { error_display("$error_context => $my_user_id"); $coops = couple_tutor_get_coops($my_user_id); $controller = new IndexManager("Test"); $tpl = $controller->tpl->get_template('layout/mm_tutor_coop_choice.tpl'); $controller->tpl->assign('coops', $coops); $controller->tpl->assign('part', 'cooperation'); $controller->tpl->assign('my_user_id', $my_user_id); $controller->tpl->assign('my_subrole', $my_subrole); $controller->tpl->assign('is_tutor', $my_subrole == TUTOR); $controller->tpl->display($tpl); exit; } $couple = couple_get_from_id($_SESSION['mm_couple_id'], $_SESSION['mm_couple_type']); $couple['hp_user_id'] = subrole_id_to_user_id($couple['hp_id'], HP); } else { $couple = couple_get_coop_partner(); $couple['hp_user_id'] = $couple['hp_id']; } if (!isset($couple) || empty($couple)) { // Display empty page $controller = new IndexManager("Coopération"); $tpl = $controller->tpl->get_template('layout/mm_coop_empty.tpl'); $controller->tpl->assign('my_user_id', $my_user_id); $controller->tpl->assign('my_subrole', $my_subrole); $controller->tpl->assign('part', 'cooperation'); $controller->tpl->display($tpl); exit; } // Tool actions if (isset($_GET['tool']) && $_GET['tool'] == 'action' && isset($_GET['action'])) { switch (trim($_GET['action'])) { case 'create' : action_create_form(); break; case 'update' : action_update_form($couple['couple_id'], $couple['type']); break; default : error_throw("Invalid action verb from url : '" . $_GET['action'] . "'", $error_context); } } elseif (isset($_GET['tool']) && $_GET['tool'] == 'agenda' && isset($_GET['action'])) { switch (trim($_GET['action'])) { case 'create' : agenda_create_form(); break; case 'update' : agenda_update_form($couple['couple_id'], $couple['type']); break; default : error_throw("Invalid agenda verb from url : '" . $_GET['agenda'] . "'", $error_context); } } elseif (isset($_GET['tool']) && $_GET['tool'] == 'tchat' && isset($_GET['action']) && $_GET['action'] == 'create') { tchat_create_form($couple); } // File uplaod if (isset($_FILES['file'])) { doc_create($couple['couple_id'], strtoupper($couple['type'])); } // Get info about tabs if (isset($_GET['tab'])) { $current_tab = intval($_GET['tab']); if (!is_int($current_tab) || $current_tab < 0 || $current_tab > 2) $current_tab = 0; } else { $current_tab = 0; } // Get couples or partner if ($is_admin) { // Display all couples // couple_get_all $couples = couple_get_all(); } else { // Display my couples $my_info = UserManager::get_user_info_by_id($my_user_id); $my_name = $my_info['firstname']; $pa_info = $couple['info']; $pa_name = $pa_info['firstname']; } $hp_info = UserManager::get_user_info_by_id($couple['hp_user_id']); $hp_name = ucfirst($hp_info['firstname'] . " " . $hp_info['lastname']); $su_name = ucfirst(subrole_id_to_user_fullname($couple['su_id'], STARTUP)); /* echo "'$hp_name' '$su_name'" . "<br/>"; echo "hp " . $couple['hp_id'] . "<br/>"; echo "su " . $couple['su_id'] . "<br/>"; echo "pa " . $couple['pa_id'] . "<br/>"; */ // Tabs for ($i=0; $i < 3; $i++) { $labels = array('Documents', 'Agenda', 'Actions'); $tabs[] = array("href" => "?tab=$i", "class" => ($current_tab == $i ? 'mm_tab_selected' : 'mm_tab'), "label" => $labels[$i]); } $controller = new IndexManager('Couples'); $controller->tpl->assign('is_admin', $is_admin); $controller->tpl->assign('part', 'cooperation'); $controller->tpl->assign('web_path', api_get_path(WEB_PATH)); $controller->tpl->assign('my_user_id', $my_user_id); $controller->tpl->assign('my_subrole', $my_subrole); if ($is_admin) { $controller->tpl->assign('couples', $couples); } else { $controller->tpl->assign('current_tab', $current_tab); $controller->tpl->assign('couple', $couple); $controller->tpl->assign('my_name', $my_name); $controller->tpl->assign('pa_name', $pa_name); $controller->tpl->assign('hp_name', $hp_name); $controller->tpl->assign('su_name', $su_name); $controller->tpl->assign('tabs', $tabs); } // Images $css_path = api_get_path(WEB_CSS_PATH); $images = array('img_create' => 'mm_new'); foreach ($images as $key => $value) { $controller->tpl->assign($key, $css_path . $value . '.png'); } // Set refresh time // {{refresh_time|default('4000')}} $controller->tpl->assign('refresh_time_tchat', 4 * 1000); $controller->tpl->assign('refresh_time_tools', 16 * 1000); // Call to formation's template $tpl = $controller->tpl->get_template('layout/mm_coop_main.tpl'); $controller->tpl->display($tpl);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings