Esempio n. 1
0
/**
 * unsubscribe all users of the class
 *
 * @author damien Garros <*****@*****.**>
 *
 * @param int $class_id course code from the class table
 *
 * @return boolean TRUE  if subscribtion succeed
 *         boolean FALSE otherwise.
 */
function class_remove_all_users($classId)
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_class_user = $tbl_mdb_names['rel_class_user'];
    $sql = "SELECT user_id\n            FROM `" . $tbl_class_user . "` AS `rel_c_u`\n                    WHERE `class_id`= " . (int) $classId;
    $userList = claro_sql_query_fetch_all($sql);
    foreach ($userList as $user) {
        $userId = $user['user_id'];
        user_remove_to_class($userId, $classId);
    }
    return true;
}
Esempio n. 2
0
$class_id = isset($_REQUEST['class_id']) ? (int) $_REQUEST['class_id'] : 0;
$search = isset($_REQUEST['search']) ? trim($_REQUEST['search']) : '';
// find info about the class
if (($classinfo = class_get_properties($class_id)) === false) {
    $class_id = 0;
}
$dialogBox = new DialogBox();
if (!empty($class_id)) {
    switch ($cmd) {
        case 'subscribe':
            if (user_add_to_class($user_id, $class_id)) {
                $dialogBox->success(get_lang('User has been sucessfully registered to the class'));
            }
            break;
        case 'unsubscribe':
            if (user_remove_to_class($user_id, $class_id)) {
                $dialogBox->success(get_lang('User has been sucessfully unregistered from the class'));
            }
            break;
    }
    //----------------------------------
    // Build query and find info in db
    //----------------------------------
    $sql = "SELECT *, U.`user_id`\n            FROM  `" . $tbl_user . "` AS U\n            LEFT JOIN `" . $tbl_class_user . "` AS CU\n                   ON  CU.`user_id` = U.`user_id`\n                  AND CU.`class_id` = " . (int) $class_id;
    if (!empty($search)) {
        $escapedSearchTerm = claro_sql_escape($search);
        $sql .= " WHERE (U.nom LIKE '%" . $escapedSearchTerm . "%'\n                  OR U.prenom LIKE '%" . $escapedSearchTerm . "%'\n                  OR U.email LIKE '%" . $escapedSearchTerm . "%'\n                  OR U.username LIKE '" . $escapedSearchTerm . "%'\n                  OR U.officialCode = '" . $escapedSearchTerm . "')";
    }
    // deal with REORDER
    // See SESSION variables used for reorder criteria :
    if (isset($_REQUEST['dir'])) {