$sTableID = "t_learning_group_admin";
$oSort = new CAdminSorting($sTableID, "ID", "desc");
// sort initializing
$lAdmin = new CAdminList($sTableID, $oSort);
// list initializing
$filter = new CAdminFilter($sTableID . "_filter", array(GetMessage('LEARNING_ADMIN_GROUPS_TITLE'), 'ID', GetMessage('LEARNING_ADMIN_GROUPS_ACTIVE'), GetMessage('LEARNING_ADMIN_GROUPS_CODE'), GetMessage('LEARNING_ADMIN_GROUPS_COURSE_TITLE'), GetMessage('LEARNING_ADMIN_GROUPS_COURSE_LESSON_ID'), GetMessage('LEARNING_ADMIN_GROUPS_SORT'), GetMessage('LEARNING_ADMIN_GROUPS_ACTIVE_FROM'), GetMessage('LEARNING_ADMIN_GROUPS_ACTIVE_TO')));
$arFilterFields = array("filter_title", "filter_id", "filter_active", "filter_code", "filter_course_title", "filter_course_lesson_id", "filter_sort", "filter_active_from_from", "filter_active_from_to", "filter_active_to_from", "filter_active_to_to");
$lAdmin->InitFilter($arFilterFields);
// filter initializing
$arFilter = array('ID' => $filter_id, 'ACTIVE' => $filter_active, 'TITLE' => $filter_title, 'CODE' => $filter_code, 'SORT' => $filter_sort, '>=ACTIVE_FROM' => $filter_active_from_from, '<=ACTIVE_FROM' => $filter_active_from_to, '>=ACTIVE_TO' => $filter_active_to_from, '<=ACTIVE_TO' => $filter_active_to_to, 'COURSE_TITLE' => $filter_course_title, 'COURSE_LESSON_ID' => $filter_course_lesson_id);
if ($lAdmin->EditAction()) {
    foreach ($FIELDS as $ID => $arFields) {
        if (!$lAdmin->IsUpdated($ID)) {
            continue;
        }
        if (!CLearningGroup::update((int) $ID, $arFields)) {
            if ($e = $APPLICATION->GetException()) {
                $lAdmin->AddUpdateError(GetMessage("SAVE_ERROR") . $ID . ": " . $e->GetString(), $ID);
            }
        }
    }
}
// group and single actions processing
if ($arID = $lAdmin->GroupAction()) {
    if ($_REQUEST['action_target'] == 'selected') {
        $rsData = CLearningGroup::GetList(array($by => $order), $arFilter);
        while ($arRes = $rsData->Fetch()) {
            $arID[] = $arRes['ID'];
        }
    }
    foreach ($arID as $ID) {
 if ($USER_FIELD_MANAGER->getRights('LEARNING_LGROUPS') >= 'W') {
     $USER_FIELD_MANAGER->EditFormAddFields('LEARNING_LGROUPS', $arFields);
 }
 $res = false;
 $oAccess = CLearnAccess::GetInstance($USER->GetID());
 $isAccessible = $oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_MANAGE_RIGHTS);
 $DB->StartTransaction();
 if ($isAccessible) {
     $tr = new CLearningGroup();
     if ($ID == 0) {
         $res = $tr->add($arFields);
         if ($res > 0) {
             $ID = (int) $res;
         }
     } else {
         $res = $tr->update($ID, $arFields);
     }
     if ($res) {
         foreach ($arAddedMembers as $memberId) {
             CLearningGroupMember::add(array('USER_ID' => $memberId, 'LEARNING_GROUP_ID' => $ID));
         }
         foreach ($arRemovedMembers as $memberId) {
             CLearningGroupMember::delete($memberId, $ID);
         }
     }
 }
 if (!$res) {
     $DB->Rollback();
     if ($e = $APPLICATION->GetException()) {
         $message = new CAdminMessage(GetMessage("LEARNING_ERROR"), $e);
     } elseif (!$isAccessible) {