Beispiel #1
0
function adminManager_assign_tree($adminidst)
{
    checkPerm('view');
    if ($adminidst == 0) {
        return;
    }
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.userselector.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.adminmanager.php';
    $directory = new UserSelector();
    $lang =& DoceboLanguage::createInstance('adminrules', 'framework');
    $aclManager = new DoceboACLManager();
    $adminManager = new AdminManager();
    if (isset($_POST['okselector'])) {
        $arr_selected = $directory->getSelection($_POST);
        $arr_unselected = $directory->getUnselected();
        foreach ($arr_unselected as $idstTree) {
            $adminManager->removeAdminTree($idstTree, $adminidst);
        }
        foreach ($arr_selected as $idstTree) {
            $adminManager->addAdminTree($idstTree, $adminidst);
        }
        Util::jump_to('index.php?modname=admin_manager&op=view');
    } elseif (isset($_POST['cancelselector'])) {
        Util::jump_to('index.php?modname=admin_manager&op=view');
    } else {
        if (!isset($_GET['stayon'])) {
            $directory->resetSelection($adminManager->getAdminTree($adminidst));
        }
        $admin_info = $aclManager->getUser($adminidst, false);
        $directory->show_user_selector = FALSE;
        $directory->show_group_selector = TRUE;
        $directory->show_orgchart_selector = TRUE;
        $directory->show_orgchart_simple_selector = TRUE;
        $directory->multi_choice = TRUE;
        $directory->loadSelector('index.php?modname=admin_manager&amp;op=assign_tree&amp;adminidst=' . $adminidst . '&amp;stayon=1', $lang->def('_ASSIGN_USERS'), '<span class="text_bold">' . substr($admin_info[ACL_INFO_USERID], 1) . '</span>', TRUE);
    }
}
 function org_createUser($treeid = FALSE)
 {
     checkPerm('createuser_org_chart', false, 'directory', 'framework');
     require_once _base_ . '/lib/lib.form.php';
     $title_page = array($this->lang->def('_USERS'), $this->lang->def('_NEW_USER'));
     $control_view = 1;
     $data = new GroupDataRetriever($GLOBALS['dbConn'], $GLOBALS['prefix_fw']);
     $rend = new Table(Get::sett('visuItem'));
     $lv = new GroupListView('', $data, $rend, 'groupdirectory');
     $group_count = $lv->getTotalRows();
     $query_org_chart = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_fw'] . "_org_chart_tree";
     list($number_of_folder) = sql_fetch_row(sql_query($query_org_chart));
     if ($number_of_folder == 0 && $group_count == 0) {
         $control_view = 0;
     }
     $GLOBALS['page']->add(getTitleArea($title_page, 'directory_people') . '<div class="std_block">');
     if ($control_view && (Get::sett('use_org_chart') == '1' || $GLOBALS['use_groups'] == '1')) {
         if (isset($_POST['okselector'])) {
             // go to user creation with folders selected
             require_once dirname(__FILE__) . '/../modules/org_chart/tree.org_chart.php';
             $repoDb = new TreeDb_OrgDb($GLOBALS['prefix_fw'] . '_org_chart_tree');
             $arr_selection = $this->getSelection($_POST);
             if (count($arr_selection) > 0) {
                 $arr_selection = array_merge($arr_selection, $repoDb->getDescendantsSTFromST($arr_selection));
             }
             $arr_selection = array_merge($arr_selection, $this->aclManager->getArrGroupST(array('/oc_0', '/ocd_0')));
             $this->editPerson(FALSE, $arr_selection);
         } elseif (isset($_POST['cancelselector'])) {
             Util::jump_to('index.php?modname=directory&op=org_chart');
         } else {
             if (!isset($_GET['stayon'])) {
                 if ($treeid === FALSE && isset($_GET['treeid'])) {
                     $treeid = (int) $_GET['treeid'];
                 }
                 if ($treeid != 0) {
                     require_once dirname(__FILE__) . '/../modules/org_chart/tree.org_chart.php';
                     $repoDb = new TreeDb_OrgDb($GLOBALS['prefix_fw'] . '_org_chart_tree');
                     $idst = $repoDb->getGroupST($treeid);
                     $this->resetSelection(array($idst));
                 } else {
                     $this->resetSelection(array());
                 }
             }
             $this->show_user_selector = FALSE;
             if ($group_count == 0) {
                 $this->show_group_selector = FALSE;
             } else {
                 $this->show_group_selector = TRUE;
             }
             if (Get::sett('use_org_chart') == '1' && $number_of_folder != 0) {
                 $this->show_orgchart_selector = TRUE;
                 $this->show_orgchart_simple_selector = TRUE;
             } else {
                 $this->show_orgchart_selector = FALSE;
             }
             if (Docebo::user()->getUserLevelId() === '/framework/level/admin') {
                 require_once $GLOBALS['where_framework'] . '/lib/lib.adminmanager.php';
                 $adminManager = new AdminManager();
                 $this->setGroupFilter('group', $adminManager->getAdminTree(getLogUserId()));
             }
             $this->loadSelector('index.php?modname=directory&amp;op=org_createuser&amp;stayon=1', $this->lang->def('_NEW_USER'), $this->lang->def('_NEW_USERDESCR'), TRUE);
         }
     } else {
         $this->editPerson(FALSE, array());
     }
     $GLOBALS['page']->add('</div>');
 }
 public function setUnsubscribeRequest($id_user, $id_course, $id_edition = FALSE, $id_date = FALSE)
 {
     if ($id_user <= 0 || $id_course <= 0) {
         return FALSE;
     }
     $cmodel = new CourseAlms();
     $cinfo = $cmodel->getCourseModDetails($id_course);
     switch ((int) $cinfo['auto_unsubscribe']) {
         case 0:
             return FALSE;
             break;
         case 1:
         case 2:
             if ($cinfo['unsubscribe_date_limit'] != "" && $cinfo['unsubscribe_date_limit'] != "0000-00-00 00:00:00") {
                 if ($cinfo['unsubscribe_date_limit'] < date("Y-m-d H:i:s")) {
                     return FALSE;
                 }
             }
             break;
     }
     if ($id_date > 0) {
         $query = "UPDATE %lms_course_date_user SET requesting_unsubscribe = 1, requesting_unsubscribe_date = NOW() " . " WHERE id_user = "******" AND id_date = " . (int) $id_date;
     } else {
         if ($id_edition > 0) {
             $query = "UPDATE %lms_course_editions_user SET requesting_unsubscribe = 1, requesting_unsubscribe_date = NOW() " . " WHERE id_user = "******" AND id_edition = " . (int) $id_edition;
         } else {
             $query = "UPDATE %lms_courseuser SET requesting_unsubscribe = 1, requesting_unsubscribe_date = NOW() " . " WHERE idUser = "******" AND idCourse = " . (int) $id_course;
         }
     }
     $res = $this->db->query($query);
     // check and send message for unsibscription moderated
     if ($res && (int) $cinfo['auto_unsubscribe'] == 1) {
         //moderated self unsubscribe
         $userinfo = $this->acl_man->getUser($id_user);
         $array_subst = array('[url]' => Get::sett('url'), '[course]' => $cinfo['name'], '[firstname]' => $userinfo[ACL_INFO_FIRSTNAME], '[lastname]' => $userinfo[ACL_INFO_LASTNAME], '[userid]' => $this->acl_man->relativeId($userinfo[ACL_INFO_USERID]));
         // message to user that is waiting
         require_once _base_ . '/lib/lib.eventmanager.php';
         $msg_composer = new EventMessageComposer('subscribe', 'lms');
         $msg_composer->setSubjectLangText('email', '_NEW_USER_UNSUBS_WAITING_SUBJECT', false);
         $msg_composer->setBodyLangText('email', '_NEW_USER_UNSUBS_WAITING_TEXT', $array_subst);
         $msg_composer->setSubjectLangText('sms', '_NEW_USER_UNSUBS_WAITING_SUBJECT_SMS', false);
         $msg_composer->setBodyLangText('sms', '_NEW_USER_UNSUBS_WAITING_TEXT_SMS', $array_subst);
         $acl =& Docebo::user()->getAcl();
         $acl_man =& $this->acl_man;
         $recipients = array();
         $idst_group_god_admin = $acl->getGroupST(ADMIN_GROUP_GODADMIN);
         $recipients = $acl_man->getGroupMembers($idst_group_god_admin);
         $idst_group_admin = $acl->getGroupST(ADMIN_GROUP_ADMIN);
         $idst_admin = $acl_man->getGroupMembers($idst_group_admin);
         require_once _adm_ . '/lib/lib.adminmanager.php';
         foreach ($idst_admin as $id_user) {
             $adminManager = new AdminManager();
             $acl_manager =& $acl_man;
             $idst_associated = $adminManager->getAdminTree($id_user);
             $array_user =& $acl_manager->getAllUsersFromIdst($idst_associated);
             $array_user = array_unique($array_user);
             $array_user[] = $array_user[0];
             unset($array_user[0]);
             $control_user = array_search(getLogUserId(), $array_user);
             $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'course'" . " AND id_entry = '" . $id_course . "'";
             list($control_course) = mysql_fetch_row(mysql_query($query));
             $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'coursepath'" . " AND id_entry IN" . " (" . " SELECT id_path" . " FROM " . Get::cfg('prefix_lms') . "_coursepath_courses" . " WHERE id_item = '" . $id_course . "'" . " )";
             list($control_coursepath) = mysql_fetch_row(mysql_query($query));
             $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'catalogue'" . " AND id_entry IN" . " (" . " SELECT idCatalogue" . " FROM " . Get::cfg('prefix_lms') . "_catalogue_entry" . " WHERE idEntry = '" . $id_course . "'" . " )";
             list($control_catalogue) = mysql_fetch_row(mysql_query($query));
             if ($control_user && ($control_course || $control_coursepath || $control_catalogue)) {
                 $recipients[] = $id_user;
             }
         }
         $recipients = array_unique($recipients);
         createNewAlert('UserCourseRemovedModerate', 'unsubscribe', 'insert', '1', 'User unsubscribed with moderation', $recipients, $msg_composer);
     }
     return $res ? TRUE : FALSE;
 }
Beispiel #4
0
function subscribedel()
{
    checkPerm('subscribe', false, 'course');
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    $id_course = importVar('id_course', true, 0);
    $course_to_save = Man_Course::saveCourseStatus();
    $edition_id = getCourseEditionId();
    $out =& $GLOBALS['page'];
    $lang =& DoceboLanguage::CreateInstance('subscribe', 'lms');
    $acl_man =& Docebo::user()->getAclManager();
    $levels = CourseLevel::getLevels();
    $user_alredy_subscribed = getSubscribed($id_course, false, false, true, $edition_id);
    $user_levels = getSubscribedLevel($id_course, false, false, $edition_id);
    require_once $GLOBALS['where_framework'] . '/lib/lib.adminmanager.php';
    $adminManager = new AdminManager();
    $acl_manager = new DoceboACLManager();
    $idst_associated = $adminManager->getAdminTree(getLogUserId());
    $array_user_associated =& $acl_manager->getAllUsersFromIdst($idst_associated);
    $user_level = Docebo::user()->getUserLevelId();
    if ($user_level != ADMIN_GROUP_GODADMIN) {
        $user_alredy_subscribed = array_intersect($user_alredy_subscribed, $array_user_associated);
    }
    $user_selected_info =& $acl_man->getUsers($user_alredy_subscribed);
    $GLOBALS['page']->add(getTitleArea($lang->def('_SUBSCRIBE'), 'subscribe') . '<div class="std_block">' . Form::openForm('levelselection', 'index.php?modname=subscribe&amp;op=subscriberemove') . Form::getHidden('id_course', 'id_course', $id_course) . Form::getHidden('edition_id', 'edition_id', $edition_id), 'content');
    $tb = new Table(0, $lang->def('_CAPTION_SELECT_LEVELS'), $lang->def('_SUMMARY_SELECT_LEVEL'));
    $type_h = array('', '', '', 'image');
    $content_h = array($lang->def('_USERNAME'), $lang->def('_FULLNAME'), $lang->def('_LEVEL'), '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . '">');
    $tb->addHead($content_h, $type_h);
    $num_user_sel = 0;
    if (is_array($user_selected_info)) {
        reset($user_selected_info);
        while (list($id_user, $user_info) = each($user_selected_info)) {
            // if the user isn't alredy subscribed to the course
            $content = array(substr($user_info[ACL_INFO_USERID], 1), $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME], $levels[$user_levels[$id_user]], $content[] = Form::getInputCheckbox('user_to_remove' . $id_user, 'user_to_remove[' . $id_user . ']', $id_user, false, '') . '<label class="access-only" for="user_to_remove' . $id_user . '">' . $user_info[ACL_INFO_USERID] . '</label>');
            $tb->addBody($content);
        }
        $GLOBALS['page']->add($tb->getTable(), 'content');
    }
    $GLOBALS['page']->add(Form::openButtonSpace() . '<br />' . Form::getButton('subscribe', 'subscribe', $lang->def('_DEL')) . Form::getButton('cancelselector', 'cancelselector', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm(), 'content');
    $GLOBALS['page']->add('</div>', 'content');
}
 public function subscribeToCourse()
 {
     $id_course = Get::req('id_course', DOTY_INT, 0);
     $id_date = Get::req('id_date', DOTY_INT, 0);
     $id_edition = Get::req('id_edition', DOTY_INT, 0);
     $id_user = Docebo::user()->getIdSt();
     $docebo_course = new DoceboCourse($id_course);
     require_once _lms_ . '/admin/models/SubscriptionAlms.php';
     $model = new SubscriptionAlms($id_course, $id_edition, $id_date);
     $course_info = $model->getCourseInfoForSubscription();
     $userinfo = $this->acl_man->getUser($id_user);
     $level_idst =& $docebo_course->getCourseLevel($id_course);
     if (count($level_idst) == 0 || $level_idst[1] == '') {
         $level_idst =& $docebo_course->createCourseLevel($id_course);
     }
     $waiting = 0;
     if ($course_info['subscribe_method'] != 2) {
         $waiting = 1;
     }
     $userlevel_subscrip = $this->get_userlevel_subscription($id_user);
     //UG
     //UG		$this->acl_man->addToGroup($level_idst[3], $id_user);
     $this->acl_man->addToGroup($level_idst[$userlevel_subscrip], $id_user);
     //UG
     //UG		if($model->subscribeUser($id_user, 3, $waiting))
     if ($model->subscribeUser($id_user, $userlevel_subscrip, $waiting)) {
         $res['success'] = true;
         $res['new_status_code'] = '';
         if ($id_edition != 0 || $id_date != 0) {
             $must_change_status = $this->model->controlSubscriptionRemaining($id_course);
             $res['new_status'] = '';
             if (!$must_change_status) {
                 $res['new_status'] = '<p class="cannot_subscribe">' . Lang::t('_NO_EDITIONS', 'catalogue') . '</p>';
             }
         } else {
             if ($waiting == 1) {
                 $res['new_status'] = '<p class="cannot_subscribe">' . Lang::t('_WAITING', 'catalogue') . '</p>';
                 $res['new_status_code'] = 'waiting';
             } else {
                 $res['new_status'] = '<p class="subscribed">' . Lang::t('_USER_STATUS_ENTER', 'catalogue') . '</p>';
                 $res['new_status_code'] = 'subscribed';
             }
         }
         $array_subst = array('[url]' => Get::sett('url'), '[course]' => $course_info['name'], '[firstname]' => $userinfo[ACL_INFO_FIRSTNAME], '[lastname]' => $userinfo[ACL_INFO_LASTNAME]);
         // message to user that is waiting
         require_once _base_ . '/lib/lib.eventmanager.php';
         $msg_composer = new EventMessageComposer('subscribe', 'lms');
         $msg_composer->setSubjectLangText('email', '_NEW_USER_SUBS_WAITING_SUBJECT', false);
         $msg_composer->setBodyLangText('email', '_NEW_USER_SUBS_WAITING_TEXT', $array_subst);
         $msg_composer->setSubjectLangText('sms', '_NEW_USER_SUBS_WAITING_SUBJECT_SMS', false);
         $msg_composer->setBodyLangText('sms', '_NEW_USER_SUBS_WAITING_TEXT_SMS', $array_subst);
         $acl =& Docebo::user()->getAcl();
         $acl_man =& $this->acl_man;
         $recipients = array();
         $idst_group_god_admin = $acl->getGroupST(ADMIN_GROUP_GODADMIN);
         $recipients = $acl_man->getGroupMembers($idst_group_god_admin);
         $idst_group_admin = $acl->getGroupST(ADMIN_GROUP_ADMIN);
         $idst_admin = $acl_man->getGroupMembers($idst_group_admin);
         require_once _adm_ . '/lib/lib.adminmanager.php';
         foreach ($idst_admin as $id_user) {
             $adminManager = new AdminManager();
             $acl_manager =& $acl_man;
             $idst_associated = $adminManager->getAdminTree($id_user);
             $array_user =& $acl_manager->getAllUsersFromIdst($idst_associated);
             $array_user = array_unique($array_user);
             $array_user[] = $array_user[0];
             unset($array_user[0]);
             $control_user = array_search(getLogUserId(), $array_user);
             $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'course'" . " AND id_entry = '" . $id_course . "'";
             list($control_course) = mysql_fetch_row(mysql_query($query));
             /*if($control)
             		$recipients[] = $id_user;*/
             $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'coursepath'" . " AND id_entry IN" . " (" . " SELECT id_path" . " FROM " . Get::cfg('prefix_lms') . "_coursepath_courses" . " WHERE id_item = '" . $id_course . "'" . " )";
             list($control_coursepath) = mysql_fetch_row(mysql_query($query));
             /*if($control)
             		$recipients[] = $id_user;*/
             $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'catalogue'" . " AND id_entry IN" . " (" . " SELECT idCatalogue" . " FROM " . Get::cfg('prefix_lms') . "_catalogue_entry" . " WHERE idEntry = '" . $id_course . "'" . " )";
             list($control_catalogue) = mysql_fetch_row(mysql_query($query));
             if ($control_user && ($control_course || $control_coursepath || $control_catalogue)) {
                 $recipients[] = $id_user;
             }
         }
         $recipients = array_unique($recipients);
         createNewAlert('UserCourseInsertModerate', 'subscribe', 'insert', '1', 'User subscribed with moderation', $recipients, $msg_composer);
         $res['message'] = UIFeedback::info(Lang::t('_SUBSCRIPTION_CORRECT', 'catalogue'), true);
     } else {
         $this->acl_man->removeFromGroup($level_idst[3], $id_user);
         $res['success'] = false;
         $res['message'] = UIFeedback::error(Lang::t('_SUBSCRIPTION_ERROR', 'catalogue'), true);
     }
     echo $this->json->encode($res);
 }