public function auth()
 {
     return false;
     require_once _base_ . '/lib/lib.preference.php';
     $preference = new UserPreferences(getLogUserId());
     $pl = Get::gReq('pl', DOTY_STRING);
     switch ($pl) {
         case "twitter":
             /*	include_once  $GLOBALS['social_config']['twitter_library_path'];
             				echo $GLOBALS['social_config']['twitter_consumer'];
             
             				$to = new TwitterOAuth($GLOBALS['social_config']['twitter_consumer'], $GLOBALS['social_config']['twitter_secret']);
             				$tok = $to->getRequestToken();
             
             				$request_link = $to->getAuthorizeURL($tok);
             
             				$_SESSION['twit_oauth_request_token']        = $token = $tok['oauth_token'];
             				$_SESSION['twit_oauth_request_token_secret'] = $tok['oauth_token_secret'];
             
             				header("Location: $request_link");
             				exit; */
             $user_pref = array();
             $user_pref['twitter_key'] = $preference->getPreference('social.twitter_key');
             $user_pref['twitter_secret'] = $preference->getPreference('social.twitter_secret');
             if (empty($user_pref['twitter_key'])) {
                 $twitter = new EpiTwitter($this->conf['twitter_key'], $this->conf['twitter_secret']);
                 $aUrl = $twitter->getAuthenticateUrl();
                 header("location: " . $aUrl);
                 exit;
             } else {
                 $twitter = new EpiTwitter($this->conf['twitter_key'], $this->conf['twitter_secret'], $user_pref['twitter_key'], $user_pref['twitter_secret']);
                 // debug:
                 $userInfo = $twitter->get_accountVerify_credentials();
                 echo "Logged in as: " . $userInfo->screen_name;
             }
             break;
         case "linkedin":
             $user_pref = array();
             $user_pref['linkedin_key'] = $preference->getPreference('social.linkedin_key');
             $user_pref['linkedin_secret'] = $preference->getPreference('social.linkedin_secret');
             if (empty($user_pref['linkedin_key'])) {
                 $linkedin = new EpiLinkedin($this->conf['linkedin_key'], $this->conf['linkedin_secret']);
                 $aUrl = $linkedin->getAuthenticateUrl();
                 header("location: " . $aUrl);
                 exit;
             } else {
                 die("mm");
                 $linkedin = new EpiLinkedin($this->conf['linkedin_key'], $this->conf['linkedin_secret'], $user_pref['linkedin_key'], $user_pref['linkedin_secret']);
                 // debug:
                 $userInfo = $linkedin->get_accountVerify_credentials();
                 echo "Logged in as: " . $userInfo->screen_name;
             }
             break;
     }
 }
Exemple #2
0
     } else {
         Util::jump_to('index.php?access_fail=3');
     }
     break;
 case "linkedin_login":
     $social = new Social();
     $social->includeLinkedinLib();
     require_once _base_ . '/lib/lib.preference.php';
     $preference = new UserPreferences(getLogUserId());
     $conf = $social->getConfig();
     $user_pref = array();
     if (Docebo::user()->isAnonymous()) {
         $user_pref['linkedin_key'] = '';
         $user_pref['linkedin_secret'] = '';
     } else {
         $user_pref['linkedin_key'] = $preference->getPreference('social.linkedin_key');
         $user_pref['linkedin_secret'] = $preference->getPreference('social.linkedin_secret');
     }
     $already_auth = $social->checkLinkedinAuth($conf['linkedin_key'], $conf['linkedin_secret'], $user_pref['linkedin_key'], $user_pref['linkedin_secret']);
     $sign_in = false;
     if ($already_auth) {
         $sign_in = true;
     } else {
         if (!isset($_GET['back'])) {
             $social->linkedinRequestToken($conf['linkedin_key'], $conf['linkedin_secret']);
             die;
             // don't remove this ;)
         } else {
             // linkedin callback
             $sign_in = $social->linkedinAccess($conf['linkedin_key'], $conf['linkedin_secret']);
         }
 /**
  * retrive the access list setted by the user
  */
 function getFieldAccessList($id_user)
 {
     if (isset($this->_field_access_list[$id_user])) {
         return $this->_field_access_list[$id_user];
     } else {
         // load from database the saved access list for the user
         $preference = new UserPreferences($id_user);
         $this->_field_access_list[$id_user] = unserialize(stripslashes($preference->getPreference('user_rules.field_policy')));
     }
     // add default value to list if needed
     if (!isset($this->_field_access_list[$id_user]['email'])) {
         $this->_field_access_list[$id_user]['email'] = PFL_POLICY_NOONE;
     }
     if (!isset($this->_field_access_list[$id_user]['online_satus'])) {
         $this->_field_access_list[$id_user]['online_satus'] = PFL_POLICY_TEACHER_AND_FRIENDS;
     }
     if (!isset($this->_field_access_list[$id_user]['message_recipients'])) {
         $this->_field_access_list[$id_user]['message_recipients'] = PFL_POLICY_TEACHER_AND_FRIENDS;
     }
     return $this->_field_access_list[$id_user];
 }
 public function multiplesubscription()
 {
     if (!$this->permissions['subscribe_course']) {
         $this->render('invalid', array('message' => $this->_getErrorMessage('no permission'), 'back_url' => 'index.php?r=' . $this->link_course . '/show'));
         return;
     } else {
         if (!$this->checkAdminLimit()) {
             $this->render('invalid', array('message' => Lang::t('_SUBSCRIBE_LIMIT_REACHED', 'subscribe'), 'back_url' => 'index.php?r=' . $this->link_course . '/show'));
             return;
         }
     }
     require_once _base_ . '/lib/lib.form.php';
     require_once _base_ . '/lib/lib.userselector.php';
     require_once _lms_ . '/lib/lib.course.php';
     $course_selector = new Selector_Course();
     //$user_selector = new Module__Directory();
     $user_selector = new UserSelector();
     //Step info
     $step = Get::req('step', DOTY_INT, 1);
     $model = new SubscriptionAlms();
     if (isset($_POST['okselector']) || isset($_POST['next'])) {
         $step++;
     }
     if (isset($_POST['back'])) {
         $step--;
     }
     if (isset($_POST['undo']) || isset($_POST['cancelselector'])) {
         $step = 0;
     }
     switch ($step) {
         case '0':
             Util::jump_to('index.php?r=' . $this->link_course . '/show');
             break;
         case '1':
             if (isset($_POST['back'])) {
                 $course_selector->parseForState($_POST);
                 $course_selection = urlencode(serialize($course_selector->getSelection()));
                 $user_selector->addFormInfo(Form::getHidden('course_selection', 'course_selection', $course_selection));
             }
             $user_selector->show_user_selector = TRUE;
             $user_selector->show_group_selector = TRUE;
             $user_selector->show_orgchart_selector = TRUE;
             $user_selector->show_orgchart_simple_selector = TRUE;
             if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
                 require_once _base_ . '/lib/lib.preference.php';
                 $adminManager = new AdminPreference();
                 $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
                 $admin_users = $this->acl_man->getAllUsersFromIdst($admin_tree);
                 $user_selector->setUserFilter('user', $admin_users);
                 $user_selector->setUserFilter('group', $admin_tree);
             }
             if (isset($_GET['load'])) {
                 $user_selector->resetSelection(array());
             }
             if (isset($_POST['user_selection'])) {
                 $user_selector->resetSelection(unserialize(urldecode($_POST['user_selection'])));
             }
             $user_selector->setUserFilter('exclude', array($this->acl_man->getAnonymousId()));
             $this->render('multiple_subscription_1', array('model' => $model, 'user_selector' => $user_selector));
             break;
         case '2':
             $id_cat = Get::req('id_cat', DOTY_INT, 0);
             if (isset($_POST['okselector'])) {
                 $_selection = $user_selector->getSelection($_POST);
                 $acl_man = Docebo::user()->getAclManager();
                 $user_selected = $acl_man->getAllUsersFromSelection($_selection);
                 //$acl_man->getAllUsersFromIdst($_selection);
                 //$user_selected = $user_selector->getSelection($_POST);
                 if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
                     require_once _base_ . '/lib/lib.preference.php';
                     $adminManager = new AdminPreference();
                     $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
                     $admin_users = $this->acl_man->getAllUsersFromIdst($admin_tree);
                     $user_selected = array_intersect($user_selected, $admin_users);
                     if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
                         $to_subscribe = count($user_selected);
                         $admin_pref = new AdminPreference();
                         $pref = $admin_pref->getAdminRules(Docebo::user()->getIdSt());
                         if ($pref['admin_rules.limit_course_subscribe'] == 'on') {
                             $user_pref = new UserPreferences(Docebo::user()->getIdSt());
                             $subscribed_count = $user_pref->getPreference('user_subscribed_count');
                             if ($subscribed_count + $to_subscribe > $pref['admin_rules.max_course_subscribe']) {
                                 $this->render('invalid', array('message' => Lang::t('_SUBSCRIBE_LIMIT_REACHED', 'subscribe'), 'back_url' => 'index.php?r=' . $this->link_course . '/show'));
                                 return;
                             }
                         }
                     }
                 }
                 if (count($user_selected) == 0) {
                     Util::jump_to('index.php?r=' . $this->link . '/multiplesubscription');
                 }
                 $model->setUserData(urlencode(serialize($user_selected)));
             }
             $course_selector->parseForState($_POST);
             if (isset($_POST['course_selection'])) {
                 $course_selector->resetSelection(unserialize(urldecode($_POST['course_selection'])));
             } elseif (isset($_POST['okselector'])) {
                 $course_selector->resetSelection(array());
             }
             $user_selection = isset($_POST['user_selection']) ? $_POST['user_selection'] : $model->getUserData();
             $this->render('multiple_subscription_2', array('model' => $model, 'id_cat' => $id_cat, 'course_selector' => $course_selector, 'user_selection' => $user_selection));
             break;
         case '3':
             $user_selection = $_POST['user_selection'];
             if (isset($_POST['course_selection'])) {
                 $course_selection = $_POST['course_selection'];
             } else {
                 $course_selector->parseForState($_POST);
                 $course_selection = urlencode(serialize($course_selector->getSelection()));
             }
             $control = $model->controlCoursesWithEdition($course_selector->getSelection());
             if ($control && !isset($_POST['edition_selected'])) {
                 $this->render('multiple_subscription_2_2', array('model' => $model, 'course_selection' => $course_selection, 'user_selection' => $user_selection, 'courses' => $course_selector->getSelection()));
             } else {
                 $courses = unserialize(urldecode($course_selection));
                 $edition_selected = array();
                 foreach ($courses as $id_course) {
                     if (isset($_POST['edition_' . $id_course])) {
                         $edition_selected[$id_course] = (int) $_POST['edition_' . $id_course];
                     }
                 }
                 $model->loadSelectedUser(unserialize(urldecode($user_selection)));
                 $this->render('multiple_subscription_3', array('model' => $model, 'course_selection' => $course_selection, 'user_selection' => $user_selection, 'edition_selected' => urlencode(serialize($edition_selected))));
             }
             break;
         case '4':
             //Start case 4
             require_once _lms_ . '/lib/lib.course.php';
             if (isset($_POST['undo'])) {
                 Util::jump_to('index.php?r=' . $this->link . '/show&id_course=' . $id_course . '&id_edition=' . $id_edition . '&id_date=' . $id_date);
             }
             $user_selection = $_POST['user_selection'];
             $course_selection = $_POST['course_selection'];
             $edition_selected = $_POST['edition_selected'];
             $user_selected = unserialize(urldecode($user_selection));
             $course_selected = unserialize(urldecode($course_selection));
             $edition_selected = unserialize(urldecode($edition_selected));
             if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
                 $limited_subscribe = Docebo::user()->preference->getAdminPreference('admin_rules.limit_course_subscribe');
                 $max_subscribe = Docebo::user()->preference->getAdminPreference('admin_rules.max_course_subscribe');
                 $direct_subscribe = Docebo::user()->preference->getAdminPreference('admin_rules.direct_course_subscribe');
                 if ($limited_subscribe == 'on') {
                     $limited_subscribe = true;
                 } else {
                     $limited_subscribe = false;
                 }
                 if ($direct_subscribe == 'on') {
                     $direct_subscribe = true;
                 } else {
                     $direct_subscribe = false;
                 }
             } else {
                 $limited_subscribe = false;
                 $max_subscribe = 0;
                 $direct_subscribe = true;
             }
             $just_subscribed_count = 0;
             foreach ($course_selected as $id_course) {
                 $course_man = new Man_Course();
                 $course_info = $course_man->getCourseInfo($id_course);
                 if ($course_info['course_type'] !== 'classroom' && $course_info['course_edition'] == 0) {
                     $model = new SubscriptionAlms($id_course);
                     $course_info = $model->getCourseInfoForSubscription();
                     $can_subscribe = true;
                     $max_num_subscribe = $course_info['max_num_subscribe'];
                     $subscribe_method = $course_info['subscribe_method'];
                     if ($can_subscribe) {
                         require_once _lms_ . '/lib/lib.course.php';
                         $docebo_course = new DoceboCourse($id_course);
                         $level_idst =& $docebo_course->getCourseLevel($id_course);
                         if (count($level_idst) == 0 || $level_idst[1] == '') {
                             $level_idst =& $docebo_course->createCourseLevel($id_course);
                         }
                         $waiting = 0;
                         $user_subscribed = array();
                         $user_waiting = array();
                         if (!$direct_subscribe) {
                             $waiting = 1;
                         }
                         while (list($id_user, $lv_sel) = each($_POST['user_level_sel'])) {
                             if (!$limited_subscribe || $max_subscribe) {
                                 if ($lv_sel != 0) {
                                     //$this->acl_man->addToGroup($level_idst[$lv_sel], $id_user);
                                     $this->_addToCourseGroup($level_idst[$lv_sel], $id_user);
                                     if ($model->subscribeUser($id_user, $lv_sel, $waiting)) {
                                         $max_subscribe--;
                                         $just_subscribed_count++;
                                     } else {
                                         $this->acl_man->removeFromGroup($level_idst[$lv_sel], $id_user);
                                     }
                                 }
                             }
                         }
                         //End While
                         reset($_POST['user_level_sel']);
                     }
                 } elseif (isset($edition_selected[$id_course])) {
                     if ($course_info['course_type'] === 'classroom') {
                         $model_t = new SubscriptionAlms($id_course, false, $edition_selected[$id_course]);
                         $course_info = $model_t->getCourseInfoForSubscription();
                         $can_subscribe = true;
                         $max_num_subscribe = $course_info['max_num_subscribe'];
                         $subscribe_method = $course_info['subscribe_method'];
                         if ($can_subscribe) {
                             require_once _lms_ . '/lib/lib.course.php';
                             $docebo_course = new DoceboCourse($id_course);
                             $level_idst =& $docebo_course->getCourseLevel($id_course);
                             if (count($level_idst) == 0 || $level_idst[1] == '') {
                                 $level_idst =& $docebo_course->createCourseLevel($id_course);
                             }
                             $waiting = 0;
                             $user_subscribed = array();
                             $user_waiting = array();
                             if (!$direct_subscribe) {
                                 $waiting = 1;
                             }
                             while (list($id_user, $lv_sel) = each($_POST['user_level_sel'])) {
                                 if (!$limited_subscribe || $max_subscribe) {
                                     if ($lv_sel != 0) {
                                         //$this->acl_man->addToGroup($level_idst[$lv_sel], $id_user);
                                         $this->_addToCourseGroup($level_idst[$lv_sel], $id_user);
                                         if ($model_t->subscribeUser($id_user, $lv_sel, $waiting)) {
                                             $max_subscribe--;
                                             $just_subscribed_count++;
                                         } else {
                                             $this->acl_man->removeFromGroup($level_idst[$lv_sel], $id_user);
                                         }
                                     }
                                 }
                             }
                             //End While
                             reset($_POST['user_level_sel']);
                         }
                     } else {
                         $model_t = new SubscriptionAlms($id_course, $edition_selected[$id_course], false);
                         $course_info = $model_t->getCourseInfoForSubscription();
                         $can_subscribe = true;
                         $max_num_subscribe = $course_info['max_num_subscribe'];
                         $subscribe_method = $course_info['subscribe_method'];
                         if ($can_subscribe) {
                             require_once _lms_ . '/lib/lib.course.php';
                             $docebo_course = new DoceboCourse($id_course);
                             $level_idst =& $docebo_course->getCourseLevel($id_course);
                             if (count($level_idst) == 0 || $level_idst[1] == '') {
                                 $level_idst =& $docebo_course->createCourseLevel($id_course);
                             }
                             $waiting = 0;
                             $user_subscribed = array();
                             $user_waiting = array();
                             if (!$direct_subscribe) {
                                 $waiting = 1;
                             }
                             while (list($id_user, $lv_sel) = each($_POST['user_level_sel'])) {
                                 if (!$limited_subscribe || $max_subscribe) {
                                     if ($lv_sel != 0) {
                                         //$this->acl_man->addToGroup($level_idst[$lv_sel], $id_user);
                                         $this->_addToCourseGroup($level_idst[$lv_sel], $id_user);
                                         if ($model_t->subscribeUser($id_user, $lv_sel, $waiting)) {
                                             $max_subscribe--;
                                             $just_subscribed_count++;
                                         } else {
                                             $this->acl_man->removeFromGroup($level_idst[$lv_sel], $id_user);
                                         }
                                     }
                                 }
                             }
                             //End While
                             reset($_POST['user_level_sel']);
                         }
                     }
                 }
             }
             // Save limit preference for admin
             if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
                 $admin_pref = new AdminPreference();
                 $pref = $admin_pref->getAdminRules(Docebo::user()->getIdSt());
                 if ($pref['admin_rules.limit_course_subscribe'] == 'on') {
                     $user_pref = new UserPreferences(Docebo::user()->getIdSt());
                     $subscribed_count = $user_pref->getPreference('user_subscribed_count');
                     $user_pref->setPreference('user_subscribed_count', $subscribed_count + $just_subscribed_count);
                 }
             }
             Util::jump_to('index.php?r=' . $this->link_course . '/show&res=_operation_successful');
             //End case 4
             break;
     }
 }
 function createuser_action()
 {
     //check permissions
     if (!$this->permissions['add_user']) {
         $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission'));
         echo $this->echoResult($output);
         return;
     }
     $userid = Get::req('username', DOTY_STRING, '');
     $password = Get::Req('password', DOTY_STRING, '');
     $password_confirm = Get::req('password_confirm', DOTY_STRING, '');
     $output = array();
     if ($userid == '') {
         $output['success'] = false;
         $output['message'] = Lang::t('_ERR_INVALID_USER', 'register');
         echo $this->echoResult($output);
         return;
     }
     if ($password != $password_confirm) {
         $output['success'] = false;
         $output['message'] = Lang::t('_ERR_PASSWORD_NO_MATCH', 'register');
         echo $this->echoResult($output);
         return;
     }
     $userdata = new stdClass();
     $userdata->userid = trim($userid);
     $userdata->firstname = trim(Get::req('firstname', DOTY_STRING, ''));
     $userdata->lastname = trim(Get::req('lastname', DOTY_STRING, ''));
     $userdata->email = trim(Get::req('email', DOTY_STRING, ''));
     $userdata->password = $password;
     $userdata->force_change = trim(Get::Req('force_changepwd', DOTY_INT, 0));
     /* $userdata->facebook_id = Get::pReq('facebook_id', DOTY_STRING, '');
     		$userdata->twitter_id = Get::pReq('twitter_id', DOTY_STRING, '');
     		$userdata->linkedin_id = Get::pReq('linkedin_id', DOTY_STRING, '');
     		$userdata->google_id = Get::pReq('google_id', DOTY_STRING, ''); */
     if (Docebo::user()->user_level == ADMIN_GROUP_GODADMIN) {
         $userdata->level = Get::req('level', DOTY_STRING, ADMIN_GROUP_USER);
     } else {
         $userdata->level = ADMIN_GROUP_USER;
     }
     if (!$this->model->checkUserid($userdata->userid)) {
         $output['success'] = false;
         $output['message'] = Lang::t('_USERID_DUPLICATE', 'organization_chart');
         echo $this->echoResult($output);
         return;
     }
     if (!$this->_canUseLevel($userdata->level)) {
         $output['success'] = false;
         $output['message'] = Lang::t('_OPERATION_FAILURE', 'standard');
         echo $this->echoResult($output);
         return;
     }
     if (Get::sett('pass_change_first_login', 'off') == 'on') {
         $userdata->force_change = 1;
     }
     $userdata->preferences =& $_POST;
     $folders = Get::req('sel', DOTY_MIXED, false);
     $idst = $this->model->createUser($userdata, $folders);
     if (is_numeric($idst) && $idst > 0) {
         $output['success'] = true;
         $output['idst'] = $idst;
         $output['total_users'] = $this->model->getUsersCount();
         $output['message'] = Lang::t('_OPERATION_SUCCESSFUL', 'standard') . ': ' . $userid;
         // Send alert:
         require_once _base_ . '/lib/lib.eventmanager.php';
         $acl_man = Docebo::user()->getAclManager();
         $array_subst = array('[url]' => Get::sett('url'), '[userid]' => $userid, '[password]' => $password);
         $e_msg = new EventMessageComposer();
         $e_msg->setSubjectLangText('email', '_REGISTERED_USER_SBJ', false);
         $e_msg->setBodyLangText('email', '_REGISTERED_USER_TEXT', $array_subst);
         $e_msg->setBodyLangText('sms', '_REGISTERED_USER_TEXT_SMS', $array_subst);
         $recipients = array($idst);
         if (!empty($recipients)) {
             createNewAlert('UserNew', 'directory', 'edit', '1', 'New user created', $recipients, $e_msg);
             ob_clean();
         }
         // Increment the counter for users created by this admin:
         if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
             $admin_pref = new AdminPreference();
             $pref = $admin_pref->getAdminRules(Docebo::user()->getIdSt());
             if ($pref['admin_rules.limit_user_insert'] == 'on') {
                 $user_pref = new UserPreferences(Docebo::user()->getIdSt());
                 $user_created_count = (int) $user_pref->getPreference('user_created_count');
                 $user_created_count++;
                 $user_pref->setPreference('user_created_count', $user_created_count);
                 if ($user_created_count >= $pref['admin_rules.max_user_insert']) {
                     $output['force_page_refresh'] = true;
                     $output['message'] = Lang::t('_USER_CREATED_MAX_REACHED', 'admin_directory');
                 }
             }
         }
     } else {
         $output['success'] = false;
         $output['message'] = Lang::t('_OPERATION_FAILURE', 'standard');
     }
     $this->echoResult($output);
 }