Example #1
0
/**
 * Add a new class
 *
 * @param $className
 * @param $parentId
 *
 */
function class_create($className, $parentId)
{
    $tbl = claro_sql_get_main_tbl();
    $className = trim($className);
    $parentId = (int) $parentId;
    if ($parentId != 0) {
        $parent_class_properties = class_get_properties($parentId);
        $class_level = $parent_class_properties['class_level'] + 1;
    } else {
        $class_level = 1;
    }
    $sql = "INSERT INTO `" . $tbl['class'] . "`\n            SET `name`='" . claro_sql_escape($className) . "',\n                `class_level`='" . (int) $class_level . "'";
    if ($parentId != 0) {
        $sql .= ", `class_parent_id`= " . (int) $parentId;
    }
    return claro_sql_query($sql);
}
Example #2
0
 */
$tbl_mdb_names = claro_sql_get_main_tbl();
$tbl_cours = $tbl_mdb_names['course'];
$tbl_course_class = $tbl_mdb_names['rel_course_class'];
$tbl_class = $tbl_mdb_names['class'];
// Javascript confirm pop up declaration for header
JavascriptLanguage::getInstance()->addLangVar('Are you sure you want to unregister %name ?');
JavascriptLoader::getInstance()->load('admin');
//------------------------------------
// Execute COMMAND section
//------------------------------------
$cmd = isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : null;
$class_id = isset($_REQUEST['class_id']) ? (int) $_REQUEST['class_id'] : 0;
$course_id = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : null;
// find info about the class
if (($classinfo = class_get_properties($class_id)) === false) {
    $class_id = 0;
}
if (!empty($class_id)) {
    switch ($cmd) {
        case 'unsubscribe':
            unregister_class_to_course($class_id, $course_id);
            break;
        default:
            // No command
    }
    //find this class current content
    // TODO Factorise this statement
    $sql = "SELECT distinct (cc.`courseId`), c.`code`, c.`language`,\n            c.`intitule`, c.`titulaires`\n            FROM `" . $tbl_course_class . "` cc, `" . $tbl_cours . "` c\n            WHERE c.`code` = cc.`courseId`\n            AND cc.`classId` = '" . $class_id . "'";
    // deal with session variables for search criteria
    if (isset($_REQUEST['dir'])) {
            foreach ($resultLog['OK'] as $thisUser) {
                $dialogBox->success(get_lang('<i>%firstname %lastname</i> has been sucessfully registered to the course', array('%firstname' => $thisUser['firstname'], '%lastname' => $thisUser['lastname'])) . '<br />');
            }
        }
        if (isset($resultLog['KO']) && is_array($resultLog['KO'])) {
            foreach ($resultLog['KO'] as $thisUser) {
                $dialogBox->error(get_lang('<i>%firstname %lastname</i> has not been sucessfully registered to the course', array('%firstname' => $thisUser['firstname'], '%lastname' => $thisUser['lastname'])) . '<br />');
            }
        }
    } elseif ($cmd == 'exUnreg') {
        if (unregister_class_to_course($class_id, $course_id)) {
            $dialogBox->success(get_lang('Class has been unenroled'));
        }
    }
}
/**
 * PREPARE DISPLAY
 */
$classinfo = class_get_properties($class_id);
$cmdList[] = '<a class="claroCmd" href="index.php">' . get_lang('Back to administration page') . '</a>';
$cmdList[] = '<a class="claroCmd" href="' . 'admin_class_user.php?class_id=' . $classinfo['id'] . '">' . get_lang('Back to class members') . '</a>';
$cmdList[] = '<a class="claroCmd" href="' . get_path('clarolineRepositoryWeb') . 'auth/courses.php?cmd=rqReg&amp;fromAdmin=class' . '">' . get_lang('Register class for course') . '</a>';
/**
 * DISPLAY
 */
$out = '';
$out .= claro_html_tool_title(get_lang('Class registered') . ' : ' . $classinfo['name']);
$out .= $dialogBox->render();
$out .= '<p>' . claro_html_menu_horizontal($cmdList) . '</p>';
$claroline->display->body->appendContent($out);
echo $claroline->display->render();
Example #4
0
    }
    if ($fromAdmin == 'class') {
        if (isset($_REQUEST['class_id'])) {
            $classId = trim($_REQUEST['class_id']);
            $_SESSION['admin_user_class_id'] = $classId;
        } elseif (isset($_SESSION['admin_user_class_id'])) {
            $classId = $_SESSION['admin_user_class_id'];
        } else {
            $classId = '';
        }
        if (!empty($classId)) {
            $urlParamList['class_id'] = $classId;
        }
        // Breadcrumbs different if we come from admin tool for a CLASS
        $nameTools = get_lang('Enrol class');
        $classinfo = class_get_properties($_SESSION['admin_user_class_id']);
    }
}
/*---------------------------------------------------------------------
DB tables initialisation
Find info about user we are working with
---------------------------------------------------------------------*/
$userInfo = user_get_properties($userId);
if (!$userInfo) {
    $cmd = '';
    switch (claro_failure::get_last_failure()) {
        case 'user_not_found':
            $msg = get_lang('User not found');
            break;
        default:
            $msg = get_lang('User is not valid');
Example #5
0
     break;
     // Edit class properties with posted form
 // Edit class properties with posted form
 case 'exEdit':
     if (empty($form_data['class_name'])) {
         $dialogBox->warning(get_lang('You cannot give a blank name to a class'));
     } else {
         if (class_set_properties($form_data['class_id'], $form_data['class_name'])) {
             $dialogBox->success(get_lang('Name of the class has been changed'));
         }
     }
     break;
     // Show form to edit class properties (display form)
 // Show form to edit class properties (display form)
 case 'rqEdit':
     if (false !== ($thisClass = class_get_properties($form_data['class_id']))) {
         $dialogBox->form('<form action="' . $_SERVER['PHP_SELF'] . '" method="post" >' . "\n" . '<input type="hidden" name="cmd" value="exEdit" />' . "\n" . '<input type="hidden" name="class_id" value="' . $thisClass['id'] . '" />' . "\n" . '<table>' . "\n" . '<tr>' . "\n" . '<td>' . "\n" . get_lang('Name') . ' : ' . "\n" . '</td>' . "\n" . '<td>' . "\n" . '<input type="text" name="class_name" value="' . claro_htmlspecialchars($thisClass['name']) . '" />' . "\n" . '<input type="submit" value=" ' . get_lang('Ok') . ' " />' . "\n" . '</td>' . "\n" . '</tr>' . "\n" . '</table>' . "\n" . '</form>' . "\n ");
     } else {
         switch (claro_failure::get_last_failure()) {
             case 'class_not_found':
             default:
                 $dialogBox->error(get_lang('Error : Class not found'));
                 break;
         }
     }
     break;
     // Open a class in the tree
 // Open a class in the tree
 case 'exOpen':
     $_SESSION['admin_visible_class'][$form_data['class_id']] = 'open';
     break;