コード例 #1
0
 /**
  * Copies the promotion to a new one
  * @param   integer     Promotion ID
  * @param   integer     Career ID, in case we want to change it
  * @param   boolean     Whether or not to copy the sessions inside
  * @return  integer     New promotion ID on success, false on failure
  */
 public function copy($id, $career_id = null, $copy_sessions = false)
 {
     $pid = false;
     $promotion = $this->get($id);
     if (!empty($promotion)) {
         $new = array();
         foreach ($promotion as $key => $val) {
             switch ($key) {
                 case 'id':
                 case 'updated_at':
                     break;
                 case 'name':
                     $val .= ' ' . get_lang('CopyLabelSuffix');
                     $new[$key] = $val;
                     break;
                 case 'created_at':
                     $val = api_get_utc_datetime();
                     $new[$key] = $val;
                     break;
                 case 'career_id':
                     if (!empty($career_id)) {
                         $val = (int) $career_id;
                     }
                     $new[$key] = $val;
                 default:
                     $new[$key] = $val;
                     break;
             }
         }
         if ($copy_sessions) {
             /**
              * When copying a session we do:
              * 1. Copy a new session from the source
              * 2. Copy all courses from the session (no user data, no user list)
              * 3. Create the promotion
              */
             $session_list = SessionManager::get_all_sessions_by_promotion($id);
             if (!empty($session_list)) {
                 $pid = $this->save($new);
                 if (!empty($pid)) {
                     $new_session_list = array();
                     foreach ($session_list as $item) {
                         $sid = SessionManager::copy_session($item['id'], true, false, false, true);
                         $new_session_list[] = $sid;
                     }
                     if (!empty($new_session_list)) {
                         SessionManager::suscribe_sessions_to_promotion($pid, $new_session_list);
                     }
                 }
             }
         } else {
             $pid = $this->save($new);
         }
     }
     return $pid;
 }
コード例 #2
0
ファイル: session_list.php プロジェクト: ragebat/chamilo-lms
$this_section = SECTION_PLATFORM_ADMIN;
SessionManager::protect_session_edit();
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = api_get_js('json-js/json2.js');
$htmlHeadXtra[] = api_get_js('date/date.js');
$htmlHeadXtra = api_get_datetime_picker_js($htmlHeadXtra);
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null;
$list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple';
if ($action == 'delete') {
    SessionManager::delete_session($idChecked);
    header('Location: ' . api_get_path(WEB_CODE_PATH) . 'session/session_list.php');
    exit;
} elseif ($action == 'copy') {
    SessionManager::copy_session($idChecked, true, false);
    header('Location: ' . api_get_path(WEB_CODE_PATH) . 'session/session_list.php');
    exit;
}
$interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('Sessions'));
$tool_name = get_lang('SessionList');
Display::display_header($tool_name);
$error_message = '';
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
    $error_message = Security::remove_XSS($_GET['message']);
}
if (!empty($error_message)) {
    Display::display_normal_message($error_message, false);
}
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_sessions&list_type=' . $list_type;
コード例 #3
0
ファイル: session_list.php プロジェクト: ragebat/chamilo-lms
 * List sessions in an efficient and usable way
 * @package chamilo.admin
 */
$cidReset = true;
//require_once '../inc/global.inc.php';
api_protect_admin_script(true);
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null;
if ($action == 'delete') {
    SessionManager::delete_session($idChecked);
    header('Location: session_list.php');
    exit;
} elseif ($action == 'copy') {
    SessionManager::copy_session($idChecked);
    header('Location: session_list.php');
    exit;
}
$interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('PlatformAdmin'));
$tool_name = get_lang('SessionList');
Display::display_header($tool_name);
$error_message = '';
// Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php.
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
    $error_message = Security::remove_XSS($_GET['message']);
}
if (!empty($error_message)) {
    Display::display_normal_message($error_message, false);
}
$sessionFilter = new FormValidator('course_filter', 'get', '', '', array('class' => 'form-search'), false);