function publicAdminManager_list()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.table.php';
    $lang =& DoceboLanguage::createInstance('adminrules', 'framework');
    $lang =& DoceboLanguage::createInstance('public_admin_manager', 'framework');
    $aclManager = new DoceboACLManager();
    // get users to show --------------------------------------------------
    $admin_group_idst = $aclManager->getGroupST(ADMIN_GROUP_PUBLICADMIN);
    $arr_admin_idst = $aclManager->getGroupUMembers($admin_group_idst);
    $arr_admin_id = array_flip($aclManager->getArrUserST($arr_admin_idst));
    $pm =& PlatformManager::createInstance();
    $lms_is_active = $pm->isLoaded("lms");
    /*$cms_is_active = $pm->isLoaded("cms");*/
    // print table --------------------------------------------------------
    $table = new Table(Get::sett('visuItem'), $lang->def('_PUBLIC_ADMIN_USER'), $lang->def('_PUBLIC_ADMIN_USER'));
    $table->initNavBar('ini', 'link');
    $table->setLink('index.php?modname=public_admin_manager&op=view&ini=');
    $ini = $table->getSelectedElement();
    $GLOBALS['page']->add(getTitleArea($lang->def('_ADMIN_MANAGMENT'), 'admin_managmer', $lang->def('_ADMIN_MANAGMENT')) . '<div class="std_block">', 'content');
    $contentH = array($lang->def('_USERNAME'), '<img src="' . getPathImage() . 'admin_manager/man_pref.gif" alt="' . $lang->def('_ADMIN_PREFERENCES_TITLE', 'adminrules') . '" ' . 'title="' . $lang->def('_ADMIN_PREFERENCES_TITLE', 'adminrules') . '" />', '<img src="' . getPathImage() . 'admin_manager/man_menu.gif" alt="' . $lang->def('_ASSIGN_USERS', 'adminrules') . '" ' . 'title="' . $lang->def('_ASSIGN_USERS', 'adminrules') . '" />', '<img src="' . getPathImage() . 'directory/tree.gif" alt="' . $lang->def('_ASSIGN_USERS', 'adminrules') . '" ' . 'title="' . $lang->def('_ASSIGN_USERS', 'adminrules') . '" />');
    $typeH = array('', 'image', 'image', 'image');
    if ($lms_is_active) {
        $contentH[] = '<img src="' . getPathImage() . 'admin_manager/man_course.gif" alt="' . $lang->def('_ASSIGN_USERS', 'adminrules') . '" ' . 'title="' . $lang->def('_ASSIGN_USERS', 'adminrules') . '" />';
        $typeH[] = 'image';
    }
    $table->setColsStyle($typeH);
    $table->addHead($contentH);
    $maxItem = count($arr_admin_id) < $ini + Get::sett('visuItem') ? count($arr_admin_id) : $ini + Get::sett('visuItem');
    for ($index = $ini; $index < $maxItem; $index++) {
        $admin_userid = substr($arr_admin_id[$arr_admin_idst[$index]], 1);
        $rowContent = array($admin_userid);
        // Edit preferences
        $rowContent[] = '<a href="index.php?modname=public_admin_manager&amp;op=edit_preferences&amp;adminidst=' . $arr_admin_idst[$index] . '"
						 title="' . $lang->def('_ADMIN_PREFERENCES_TITLE', 'adminrules') . ' : ' . $admin_userid . '">' . '<img src="' . getPathImage() . 'admin_manager/man_pref.gif"' . ' alt="' . $lang->def('_ADMIN_PREFERENCES_TITLE', 'adminrules') . ' : ' . $admin_userid . '" /></a>';
        // Edit menu
        $rowContent[] = '<a href="index.php?modname=public_admin_manager&amp;op=edit_menu&amp;adminidst=' . $arr_admin_idst[$index] . '"
						 title="' . $lang->def('_ASSIGN_USERS', 'adminrules') . ' : ' . $admin_userid . '">' . '<img src="' . getPathImage() . 'admin_manager/man_menu.gif"' . ' alt="' . $lang->def('_ASSIGN_USERS', 'adminrules') . ' : ' . $admin_userid . '" /></a>';
        // Edit user
        $rowContent[] = '<a href="index.php?modname=public_admin_manager&amp;op=assign_tree&amp;adminidst=' . $arr_admin_idst[$index] . '"
		 					title="' . $lang->def('_ASSIGN_USERS', 'adminrules') . ' : ' . $admin_userid . '">' . '<img src="' . getPathImage() . 'directory/tree.gif" ' . 'alt="' . $lang->def('_ASSIGN_USERS', 'adminrules') . ' : ' . $admin_userid . '" /></a>';
        // Edit course
        if ($lms_is_active) {
            $rowContent[] = '<a href="index.php?modname=public_admin_manager&amp;op=edit_course&amp;adminidst=' . $arr_admin_idst[$index] . '&amp;load=1"
								 title="' . $lang->def('_ASSIGN_USERS', 'adminrules') . ' : ' . $admin_userid . '">' . '<img src="' . getPathImage() . 'admin_manager/man_course.gif"' . ' alt="' . $lang->def('_ASSIGN_USERS', 'adminrules') . ' : ' . $admin_userid . '" /></a>';
        }
        $table->addBody($rowContent);
    }
    $GLOBALS['page']->add($table->getTable() . $table->getNavBar($ini, count($arr_admin_id)), 'content');
    $GLOBALS['page']->add('</div>', 'content');
}
Exemple #2
0
function canAccessCmsMedia()
{
    require_once _base_ . '/lib/lib.platform.php';
    $pl =& PlatformManager::createInstance();
    if (!$pl->isLoaded('cms')) {
        return false;
    }
    $level_id = Docebo::user()->getUserLevelId();
    if (Docebo::user()->isAnonymous()) {
        return false;
    }
    if ($GLOBALS["htmledit_image_godadmin"] && $level_id == ADMIN_GROUP_GODADMIN || $GLOBALS["htmledit_image_admin"] && $level_id == ADMIN_GROUP_ADMIN || $GLOBALS["htmledit_image_user"] && $level_id == ADMIN_GROUP_USER) {
        if ($GLOBALS["where_cms"] === false || $GLOBALS["where_cms_relative"] === false) {
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}
Exemple #3
0
 function _saveSuiteManager()
 {
     require_once _base_ . '/lib/lib.platform.php';
     $plat_man =& PlatformManager::createInstance();
     $all_platform = $plat_man->getPlatformsInfo();
     $re = true;
     reset($all_platform);
     while (list($code, $info) = each($all_platform)) {
         if ($info['hidden_in_config'] != 'true') {
             $code = $info['platform'];
             if (isset($_POST['activate_platform'][$code])) {
                 $re &= $plat_man->activatePlatform($code);
                 $code_list_home[$code] = $info['name'];
             } elseif ($info['mandatory'] == 'false') {
                 $re &= $plat_man->deactivatePlatform($code);
             }
         }
     }
     if (isset($code_list_home[$_POST['platform_in_home']])) {
         $re &= $plat_man->putInHome($_POST['platform_in_home']);
     }
     return $re;
 }
Exemple #4
0
<?php

defined("IN_FORMA") or die('Direct access is forbidden.');
/* ======================================================================== \
|   FORMA - The E-Learning Suite                                            |
|                                                                           |
|   Copyright (c) 2013 (Forma)                                              |
|   http://www.formalms.org                                                 |
|   License  http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt           |
|                                                                           |
|   from docebo 4.0.5 CE 2008-2012 (c) docebo                               |
|   License http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt            |
\ ======================================================================== */
if (Docebo::user()->isLoggedIn()) {
    $lang =& DoceboLanguage::createInstance('menu', 'framework');
    $p_man =& PlatformManager::createInstance();
    $platforms = $p_man->getPlatformList();
    cout('<li><a href="#main_menu">' . $lang->def('_BLIND_MAIN_MENU') . '</a></li>', 'blind_navigation');
    cout('<div id="main_menu_container" class="layout_menu_over yuimenubar yuimenubarnav">', 'menu_over');
    cout('<div class="bd"><ul class="first-of-type">', 'menu_over');
    foreach ($platforms as $p_code => $p_name) {
        $menu_man =& $p_man->getPlatofmMenuInstance($p_code);
        if ($menu_man !== false) {
            $main_voice = $menu_man->getLevelOne();
            if (!empty($main_voice)) {
                cout('<li class="yuimenuitem">' . '<a class="yuimenuitemlabel" href="#submenu_' . $p_code . '">' . '<span class="admmenu_' . $p_code . '">' . $lang->def('_FIRST_LINE_' . $p_code) . '</span>' . '</a>' . '<div id="submenu_' . $p_code . '" class="yuimenu"><div class="bd"><ul>', 'menu_over');
                foreach ($main_voice as $id_m => $v_main) {
                    $under_voice = $menu_man->getLevelTwo($id_m);
                    if (!isset($v_main['collapse']) || $v_main['collapse'] === false) {
                        cout('<li class="yuimenuitem">' . '<a class="yuimenuitemlabel" href="#submenu_' . $p_code . '_' . $id_m . '">' . $v_main['name'] . '</a>', 'menu_over');
                        if (!empty($under_voice)) {
function adminManager_edit_menu()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.tab.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.adminmanager.php';
    $lang =& DoceboLanguage::createInstance('adminrules', 'framework');
    $aclManager =& Docebo::user()->getAclManager();
    $adminidst = importVar('adminidst', true, 0);
    $out =& $GLOBALS['page'];
    $admin_manager = new AdminManager();
    // perform other platforms login operation
    require_once _base_ . '/lib/lib.platform.php';
    $pm =& PlatformManager::createInstance();
    //prefetching tab-------------------------------------------
    $tabs = new TabView('admin_menu_tab_editing', 'index.php?modname=admin_manager&amp;op=edit_menu&amp;adminidst=' . $adminidst);
    $plat = $pm->getPlatformList();
    $active_tab = importVar('tab', false, 'framework');
    foreach ($plat as $code => $descr) {
        if (isset($_POST['tabelem_' . $code . '_status'])) {
            $active_tab = $code;
        }
        $tab = new TabElemDefault($code, $lang->def('_MENU_MANAGE_' . strtoupper($code)), getPathImage() . 'main_zone/' . $code . '.gif');
        $tabs->addTab($tab);
    }
    $admin_menu =& $pm->getPlatformAdminMenuInstance($active_tab);
    $all_admin_permission =& $admin_manager->getAdminPermission($adminidst);
    // save if is it required
    if (isset($_POST['save_permission'])) {
        $re = $admin_menu->savePreferences($_POST, $adminidst, $all_admin_permission);
        $all_admin_permission =& $admin_manager->getAdminPermission($adminidst);
    }
    $tabs->setActiveTab($active_tab);
    $out->setWorkingZone('content');
    $out->add(getTitleArea($lang->def('_ADMIN_MANAGMENT'), 'admin_managmer', $lang->def('_ADMIN_MANAGMENT')) . '<div class="std_block">' . $tabs->printTabView_Begin() . Form::openForm('admin_menu_editing', '') . Form::getHidden('adminidst', 'adminidst', $adminidst) . Form::getHidden('tab', 'tab', $active_tab) . ($admin_menu !== false ? $admin_menu->getPermissionUi($all_admin_permission, 'admin_menu_editing', 'admin_menu_editing') : '') . Form::openButtonSpace() . Form::getButton('save_permission', 'save_permission', $lang->def('_SAVE')) . Form::getButton('undo_pref', 'undo_pref', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm() . $tabs->printTabView_End() . '</div>');
}
     if (!Docebo::user()->isAnonymous() && isset($_SESSION['idCourse'])) {
         TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], '', '');
     }
     //i need to save the language of the user in order to use it again after logout
     $language = Lang::get();
     if (!Docebo::user()->isAnonymous()) {
         TrackUser::logoutSessionCourseTrack();
         $_SESSION = array();
         session_destroy();
         // load standard language module and put it global
         $glang =& DoceboLanguage::createInstance('standard', 'framework');
         // Recreate Anonymous user
         $GLOBALS['current_user'] =& DoceboUser::createDoceboUserFromSession('public_area');
         $GLOBALS['logout'] = true;
         require_once _base_ . '/lib/lib.platform.php';
         $pm =& PlatformManager::createInstance();
         $pm->doCommonOperations("logout");
     }
     $GLOBALS['op'] = 'login';
     $GLOBALS['modname'] = 'login';
     $query = 'logout=1&special=changelang&new_lang=' . $language;
     if (isset($_GET['msg']) && !empty($_GET['msg'])) {
         $query = 'msg=' . (int) $_GET['msg'];
     }
     Util::jump_to('../index.php?' . $query);
     break;
 case "aula":
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     if (!logIntoCourse($_GET['idCourse'], true)) {
         $_SESSION['current_main_menu'] = '1';
         $_SESSION['sel_module_id'] = '1';
Exemple #7
0
 /**
  * @return string with the default region_id in system
  */
 function getDefaultRegion()
 {
     require_once _base_ . '/lib/lib.platform.php';
     $plt_man =& PlatformManager::createInstance();
     $def_lang = $plt_man->getLanguageForPlatform();
     if ($this->default_region == NULL || $this->default_region == "") {
         $qtxt = "SELECT region_id FROM " . $this->_getListTable() . " WHERE lang_code='" . $def_lang . "'";
         $q = $this->_executeQuery($qtxt);
         if ($q && mysql_num_rows($q) > 0) {
             $row = mysql_fetch_array($q);
             $this->default_region = $row["region_id"];
         } else {
             $this->default_region = 'english';
         }
     }
     return $this->default_region;
 }
 /**
  * @param    string $language the language to use as filter
  * @param    array $array_idst the  optional security token of the users to be
  *                                    used as an additional filter
  *
  * @return    array    with user idst of the found entries
  */
 function getUsersIdstByLanguage($language, $array_idst = FALSE)
 {
     require_once _base_ . '/lib/lib.platform.php';
     $plat_man =& PlatformManager::createInstance();
     if ($language == $plat_man->getLanguageForPlatform()) {
         $get_null = TRUE;
     } else {
         $get_null = FALSE;
     }
     $lang_idst_arr = $this->getUsersBySetting("ui.language", $language, $get_null, $array_idst);
     return $lang_idst_arr;
 }
 function org_waitingUser()
 {
     checkPerm('approve_waiting_user', false, 'directory', 'framework');
     require_once _base_ . '/lib/lib.form.php';
     require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
     require_once _base_ . '/lib/lib.table.php';
     require_once _base_ . '/lib/lib.usermanager.php';
     if (isset($_POST['ok_waiting'])) {
         $user_man = new UserManager();
         // Remove refused users
         $refused = array();
         $aopproved = array();
         if (isset($_POST['waiting_user_refuse'])) {
             while (list($idst) = each($_POST['waiting_user_refuse'])) {
                 $this->aclManager->deleteTempUser($idst, false, false, true);
             }
             $refused[] = $idst;
         }
         // Subscribed accepted users
         if (isset($_POST['waiting_user_accept'])) {
             $idst_usergroup = $this->aclManager->getGroup(false, ADMIN_GROUP_USER);
             $idst_usergroup = $idst_usergroup[ACL_INFO_IDST];
             $idst_oc = $this->aclManager->getGroup(false, '/oc_0');
             $idst_oc = $idst_oc[ACL_INFO_IDST];
             $idst_ocd = $this->aclManager->getGroup(false, '/ocd_0');
             $idst_ocd = $idst_ocd[ACL_INFO_IDST];
             $request = $this->aclManager->getTempUsers(false, true);
             while (list($idst) = each($_POST['waiting_user_accept'])) {
                 if ($this->aclManager->registerUser(addslashes($request[$idst]['userid']), addslashes($request[$idst]['firstname']), addslashes($request[$idst]['lastname']), $request[$idst]['pass'], addslashes($request[$idst]['email']), '', '', true, $idst)) {
                     $approved[] = $idst;
                     $this->aclManager->addToGroup($idst_usergroup, $idst);
                     $this->aclManager->addToGroup($idst_oc, $idst);
                     $this->aclManager->addToGroup($idst_ocd, $idst);
                     if ($request[$idst]['create_by_admin'] != 0) {
                         $pref = new UserPreferences($request[$idst]['create_by_admin']);
                         if ($pref->getAdminPreference('admin_rules.limit_user_insert') == 'on') {
                             $max_insert = $pref->getAdminPreference('admin_rules.max_user_insert');
                             $pref->setPreference('admin_rules.max_user_insert', $max_insert - 1);
                         }
                     }
                     $this->aclManager->deleteTempUser($idst, false, false, false);
                 }
             }
         }
         require_once _base_ . '/lib/lib.platform.php';
         require_once _base_ . '/lib/lib.eventmanager.php';
         // send the alert
         /*
         			if(!empty($refused)) {
         
         				$array_subst = array('[url]' => Get::sett('url'));
         
         				$msg_composer = new EventMessageComposer('admin_directory', 'framework');
         
         				$msg_composer->setSubjectLangText('email', '_REFUSED_USER_SBJ', false);
         				$msg_composer->setBodyLangText('email', '_REFUSED_USER_TEXT', $array_subst);
         
         				$msg_composer->setBodyLangText('sms', '_REFUSED_USER_TEXT_SMS', $array_subst);
         
         				createNewAlert(	'UserApproved', 'directory', 'edit', '1', 'Users refused',
         							$refused, $msg_composer );
         			}*/
         if (!empty($approved)) {
             $pl_man =& PlatformManager::createInstance();
             $array_subst = array('[url]' => Get::sett('url', ''));
             $msg_composer2 = new EventMessageComposer('admin_directory', 'framework');
             $msg_composer2->setSubjectLangText('email', '_APPROVED_USER_SBJ', false);
             $msg_composer2->setBodyLangText('email', '_APPROVED_USER_TEXT', $array_subst);
             $msg_composer2->setBodyLangText('sms', '_APPROVED_USER_TEXT_SMS', $array_subst);
             createNewAlert('UserApproved', 'directory', 'edit', '1', 'Users approved', $approved, $msg_composer2, true);
         }
         Util::jump_to('index.php?modname=directory&op=org_chart');
     } elseif (isset($_POST['cancel_waiting'])) {
         Util::jump_to('index.php?modname=directory&op=org_chart');
     } else {
         $tb = new Table(0, $this->lang->def('_WAITING_USERS'), $this->lang->def('_WAITING_USER_SUMMARY'));
         $type_h = array('', '', '', 'image', 'image');
         $cont_h = array($this->lang->def('_USERNAME'), $this->lang->def('_DIRECTORY_FULLNAME'), $this->lang->def('_BY'), '<img src="' . getPathImage('framework') . 'directory/wuser_accept.gif" alt="' . $this->lang->def('_ACCEPT') . '" ' . 'title="' . $this->lang->def('_ACCEPT_USER') . '" />', '<img src="' . getPathImage('framework') . 'directory/wuser_refuse.gif" alt="' . $this->lang->def('_REFUSE_USER') . '" ' . 'title="' . $this->lang->def('_REFUSE_USER_TITLE') . '" />');
         $tb->setColsStyle($type_h);
         $tb->addHead($cont_h);
         $temp_users = $this->aclManager->getTempUsers(false, true);
         if ($temp_users !== false) {
             $idst_admins = array();
             while (list($idst, $info) = each($temp_users)) {
                 if ($info['create_by_admin'] != 0) {
                     $idst_admins[] = $info['create_by_admin'];
                 }
             }
             $admins = $this->aclManager->getUsers($idst_admins);
             reset($temp_users);
             while (list($idst, $info) = each($temp_users)) {
                 if ($info['create_by_admin'] != 0) {
                     $creator = $admins[$info['create_by_admin']][ACL_INFO_LASTNAME] . ' ' . $admins[$info['create_by_admin']][ACL_INFO_FIRSTNAME];
                     if ($creator == '') {
                         $creator = $this->aclManager->relativeId($admins[$info['create_by_admin']][ACL_INFO_USERID]);
                     }
                 } else {
                     $creator = $this->lang->def('_DIRECOTRY_SELFREGISTERED');
                 }
                 $more = isset($_GET['id_user']) && $_GET['id_user'] == $idst ? '<a href="index.php?modname=directory&amp;op=org_waitinguser"><img src="' . getPathImage() . 'standard/less.gif"></a> ' : '<a href="index.php?modname=directory&amp;op=org_waitinguser&amp;id_user='******'"><img src="' . getPathImage() . 'standard/more.gif"></a> ';
                 $cont = array($more . $this->aclManager->relativeId($info['userid']), $info['lastname'] . ' ' . $info['firstname'], $creator, Form::getInputCheckbox('waiting_user_accept_' . $idst, 'waiting_user_accept[' . $idst . ']', $idst, false, '') . Form::getLabel('waiting_user_accept_' . $idst, $this->lang->def('_ACCEPT'), 'access-only'), Form::getInputCheckbox('waiting_user_refuse_' . $idst, 'waiting_user_refuse[' . $idst . ']', $idst, false, '') . Form::getLabel('waiting_user_refuse_' . $idst, $this->lang->def('_REFUSE_USER'), 'access-only'));
                 $tb->addBody($cont);
                 if (isset($_GET['id_user']) && $idst == $_GET['id_user']) {
                     $field = new FieldList();
                     $tb->addBodyExpanded($field->playFieldsForUser($idst, false, true), 'user_specific_info');
                 }
             }
         }
         $GLOBALS['page']->add(getTitleArea($this->lang->def('_WAITING_USERS'), 'directory') . '<div class="std_block">' . Form::openForm('waiting_user', 'index.php?modname=directory&amp;op=org_waitinguser') . $tb->getTable() . Form::openButtonSpace() . Form::getButton('ok_waiting', 'ok_waiting', $this->lang->def('_SAVE')) . Form::getButton('cancel_waiting', 'cancel_waiting', $this->lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content');
     }
 }
Exemple #10
0
 function getShowOnPlatformFieldset($show_on_platform = FALSE)
 {
     $res = "";
     if ($this->canSelectPlatform()) {
         if ($show_on_platform === FALSE) {
             $show_on_platform = $this->getShowOnPlatformDefaultArr();
         }
         $plt_man =& PlatformManager::createInstance();
         $plt_list = $plt_man->getPlatformList(true);
         $res .= Form::getOpenFieldset(Lang::t('_SHOW_ON_PLATFORM', 'field'));
         $res .= Form::getHidden('show_on_platform_framework', 'show_on_platform[framework]', 1);
         while (list($code, $name) = each($plt_list)) {
             $sel = isset($show_on_platform[$code]) ? TRUE : FALSE;
             $res .= Form::getCheckbox($name, 'show_on_platform_' . $code, 'show_on_platform[' . $code . ']', 1, $sel);
         }
         $res .= Form::getCloseFieldset();
     } else {
         $res .= Form::getHidden('show_on_platform_framework', 'show_on_platform[framework]', 1);
         foreach ($this->getShowOnPlatformDefaultArr() as $code) {
             $res .= Form::getHidden('show_on_platform_' . $code, 'show_on_platform[' . $code . ']', 1);
         }
     }
     return $res;
 }
 public function menu()
 {
     require_once _base_ . '/lib/lib.platform.php';
     if (isset($_POST['back'])) {
         Util::jump_to('index.php?r=adm/adminrules/show');
     }
     $idst = Get::req('idst', DOTY_INT, 0);
     $active_tab = Get::req('active_tab', DOTY_MIXED, 'framework');
     $pm =& PlatformManager::createInstance();
     $platform_list = $pm->getPlatformList();
     if (isset($platform_list['scs'])) {
         unset($platform_list['scs']);
     }
     if (isset($platform_list['ecom'])) {
         unset($platform_list['ecom']);
     }
     $result_message = "";
     if (isset($_POST['save'])) {
         $adm_perm = array();
         if (isset($_POST['adm_perm'])) {
             $adm_perm = array_keys($_POST['adm_perm']);
         }
         $res = $this->model->saveAdminPerm($idst, $adm_perm);
         $result_message = $res ? UIFeedback::info(Lang::t('_OPERATION_SUCCESSFUL', 'standard')) : UIFeedback::error(Lang::t('_OPERATION_FAILURE', 'standard'));
         Util::jump_to('index.php?r=adm/adminrules/show&res=' . ($res ? 'ok' : 'err'));
     }
     $this->render('menu', array('idst' => $idst, 'platform_list' => $platform_list, 'active_tab' => $active_tab, 'model' => $this->model, 'save_res' => $result_message));
 }
 public function multimodTask()
 {
     if (!$this->permissions['mod_user']) {
         $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission'));
         echo $this->json->encode($output);
         return;
     }
     $title = Lang::t('_MOD', 'admin_directory');
     $users_count = Get::req('users_count', DOTY_INT, 0);
     if ($users_count <= 0) {
         $output = array('success' => true, 'header' => $title, 'body' => Lang::t('_EMPTY_SELECTION', 'admin_directory'));
         echo $this->json->encode($output);
         return;
     }
     $acl_man = Docebo::user()->getAclManager();
     $level = ADMIN_GROUP_USER;
     $arr_levels = $acl_man->getAdminLevels();
     //index = idst; value = groupid;
     $levels = array();
     foreach ($arr_levels as $groupid_level => $idst_level) {
         $levels[$groupid_level] = Lang::t('_DIRECTORY_' . $groupid_level, 'admin_directory');
     }
     $info = array('firstname' => '', 'lastname' => '', 'email' => '', 'level' => '', 'facebook_id' => '', 'twitter_id' => '', 'linkedin_id' => '', 'google_id' => '');
     $language = getDefaultLanguage();
     $languages = Docebo::langManager()->getAllLanguages();
     require_once _base_ . '/lib/lib.platform.php';
     $pman =& PlatformManager::createInstance();
     // = new PlatformManager();
     $platforms = $pman->getPlatformList();
     require_once _adm_ . '/lib/lib.field.php';
     $fman = new FieldList();
     $field_list = $fman->getFlatAllFields(array_keys($platforms));
     $fields_to_exclude = $fman->getFieldsByType('upload');
     $preference = new UserPreferences(0);
     $modify_mask = $preference->getModifyMask('ui.', true, true);
     $fields_mask = $fman->playFieldsForUser(-1, false, false, true, false, true);
     //build edit mask
     $this->render('multimod', array('users_count' => $users_count, 'title' => $title, 'levels' => $levels, 'modify_mask' => $modify_mask, 'fields_mask' => $fields_mask, 'fields_to_exclude' => is_array($fields_to_exclude) ? $fields_to_exclude : array(), 'info' => $info, 'json' => $this->json));
 }
Exemple #13
0
 function getLangStat()
 {
     require_once _base_ . '/lib/lib.platform.php';
     $pl_man =& PlatformManager::createInstance();
     $platform_list = array_keys($pl_man->getActivePlatformList());
     $stats = array();
     $lang_stat = "" . " SELECT COUNT(*)" . " FROM " . $this->_getTableText() . " " . " WHERE 0 ";
     foreach ($platform_list as $plat) {
         $lang_stat .= " OR text_platform = '" . $plat . "' ";
     }
     list($stats['tot_lang']) = sql_fetch_row(sql_query($lang_stat));
     $lang_stat = "" . "SELECT lang_code, COUNT(*) " . "FROM " . $this->_getTableTranslation() . " " . "WHERE translation_text <> '' " . "GROUP BY lang_code";
     $re_stat = sql_query($lang_stat);
     while (list($lc, $tot) = sql_fetch_row($re_stat)) {
         $stats[$lc] = $tot;
     }
     return $stats;
 }
 function extendedParsing($arrayState, $arrayExpand, $arrayCompress)
 {
     if (isset($arrayState['editpersonsave'])) {
         $idst = $_POST['idst'];
         $userid = $_POST['userid'];
         $firstname = $_POST['firstname'];
         $lastname = $_POST['lastname'];
         $pass = $_POST['pass'];
         $userlevel = $_POST['userlevel'];
         $olduserlevel = $_POST['olduserlevel'];
         if ($pass === '') {
             $pass = FALSE;
         }
         $email = $_POST['email'];
         if ($idst !== '') {
             //-extra field-----------------------------------------------
             require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
             $fields = new FieldList();
             //$re_filled = $fields->isFilledFieldsForUser($idst);
             if ($userid != '') {
                 $info = $this->aclManager->getUser($idst, false);
                 $this->aclManager->updateUser($idst, $userid, $firstname, $lastname, $pass, $email, FALSE, FALSE);
                 //-extra field-----------------------------------------------
                 $fields->storeFieldsForUser($idst);
                 //-----------------------------------------------------------
                 // remove from old group level
                 $this->aclManager->removeFromGroup($olduserlevel, $idst);
                 // add to group level
                 $this->aclManager->addToGroup($userlevel, $idst);
                 if ($this->aclManager->absoluteId($userid) != $info[ACL_INFO_USERID] || $this->aclManager->encrypt($pass) != $info[ACL_INFO_PASS]) {
                     require_once _base_ . '/lib/lib.eventmanager.php';
                     $pl_man = PlatformManager::createInstance();
                     $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass);
                     // message to user that is odified
                     $msg_composer = new EventMessageComposer();
                     $msg_composer->setSubjectLangText('email', '_MODIFIED_USER_SBJ', false);
                     $msg_composer->setBodyLangText('email', '_MODIFIED_USER_TEXT', $array_subst);
                     if ($pass != '') {
                         $msg_composer->setBodyLangText('email', '_PASSWORD_CHANGED', array('[password]' => $pass));
                     }
                     $msg_composer->setBodyLangText('sms', '_MODIFIED_USER_TEXT_SMS', $array_subst);
                     if ($pass != '') {
                         $msg_composer->setBodyLangText('sms', '_PASSWORD_CHANGED_SMS', array('[password]' => $pass));
                     }
                     createNewAlert('UserMod', 'directory', 'edit', '1', 'User ' . $userid . ' was modified', array($userid), $msg_composer);
                 }
                 $GLOBALS['page']->add(getResultUi($this->lang->def('_OPERATION_SUCCESSFUL')));
             } else {
                 $this->op = 'reedit_person';
                 //$GLOBALS['page']->add( getErrorUi( implode(',', $re_filled) ), 'content');
             }
         } else {
             if (isset($_POST['arr_idst_groups'])) {
                 $arr_idst_groups = unserialize(urldecode($_POST['arr_idst_groups']));
                 $acl =& Docebo::user()->getACL();
                 $arr_idst_all = $acl->getArrSTGroupsST($arr_idst_groups);
             } else {
                 $arr_idst_groups = FALSE;
                 $arr_idst_all = FALSE;
             }
             //-verify that userid is not already used
             if ($this->aclManager->getUserST($userid) !== FALSE) {
                 $GLOBALS['page']->add(getErrorUi($this->lang->def('_USERID_DUPLICATE')));
                 $_POST['userid'] = '';
                 $this->op = 'reedit_person';
             } else {
                 //-verify mandatory extra field--------------------------------
                 require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
                 $fields = new FieldList();
                 //$re_filled = $fields->isFilledFieldsForUser(0, $arr_idst_all);
                 if ($arr_idst_groups != FALSE && $userid != '') {
                     $idst = false;
                     if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
                         $limit_insert = Docebo::user()->preference->getAdminPreference('admin_rules.limit_user_insert');
                         $max_insert = Docebo::user()->preference->getAdminPreference('admin_rules.max_user_insert');
                         $direct_insert = Docebo::user()->preference->getAdminPreference('admin_rules.direct_user_insert');
                         if ($limit_insert == 'off' || $limit_insert == 'on' && $max_insert > 0) {
                             if ($direct_insert == 'on') {
                                 Docebo::user()->preference->setPreference('admin_rules.max_user_insert', $max_insert - 1);
                                 $idst = $this->aclManager->registerUser($userid, $firstname, $lastname, $pass, $email, '', '');
                                 require_once _base_ . '/lib/lib.preference.php';
                                 $preference = new UserPreferences($idst);
                                 $preference->savePreferences($_POST, 'ui.');
                                 require_once _base_ . "/lib/lib.eventmanager.php";
                                 $pl_man =& PlatformManager::createInstance();
                                 $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass);
                                 // message to user that is inserted
                                 $msg_composer = new EventMessageComposer();
                                 $msg_composer->setSubjectLangText('email', '_REGISTERED_USER_SBJ', false);
                                 $msg_composer->setBodyLangText('email', '_REGISTERED_USER_TEXT', $array_subst);
                                 $msg_composer->setBodyLangText('sms', '_REGISTERED_USER_TEXT_SMS', $array_subst);
                                 createNewAlert('UserNew', 'directory', 'edit', '1', 'User ' . $userid . ' created', array($userid), $msg_composer);
                                 $GLOBALS['page']->add(getResultUi($this->lang->def('_INSERTED_NEW_USER')));
                             } else {
                                 $acl = Docebo::user()->getAcl();
                                 $idst = $this->aclManager->registerTempUser($userid, $firstname, $lastname, $pass, $email, 0, getLogUserId());
                                 require_once _base_ . "/lib/lib.eventmanager.php";
                                 $pl_man =& PlatformManager::createInstance();
                                 $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass);
                                 // message to user that is waiting
                                 $msg_composer = new EventMessageComposer();
                                 $msg_composer->setSubjectLangText('email', '_WAITING_USER_SBJ', false);
                                 $msg_composer->setBodyLangText('email', '_WAITING_USER_TEXT', $array_subst);
                                 $msg_composer->setBodyLangText('sms', '_WAITING_USER_TEXT_SMS', $array_subst);
                                 // send message to the user subscribed
                                 createNewAlert('UserNew', 'directory', 'edit', '1', 'User ' . $userid . ' was modified', array($userid), $msg_composer);
                                 // set as recipients all who can approve a waiting user
                                 $msg_c_approve = new EventMessageComposer();
                                 $msg_c_approve->setSubjectLangText('email', '_TO_APPROVE_USER_SBJ', false);
                                 $msg_c_approve->setBodyLangText('email', '_TO_APPROVE_USER_TEXT', array('[url]' => Get::sett('url')));
                                 $msg_c_approve->setBodyLangText('sms', '_TO_APPROVE_USER_TEXT_SMS', array('[url]' => Get::sett('url')));
                                 $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user');
                                 $recipients = $this->aclManager->getAllRoleMembers($idst_approve);
                                 createNewAlert('UserNewModerated', 'directory', 'edit', '1', 'User ' . $userid . ' to moderate', $recipients, $msg_c_approve);
                                 $GLOBALS['page']->add(getResultUi($this->lang->def('_INSERTED_WAIT_FOR_ADMIN')));
                             }
                         }
                     } else {
                         $idst = $this->aclManager->registerUser($userid, $firstname, $lastname, $pass, $email, '', '');
                         require_once _base_ . '/lib/lib.preference.php';
                         $preference = new UserPreferences($idst);
                         $preference->savePreferences($_POST, 'ui.');
                         require_once _base_ . "/lib/lib.eventmanager.php";
                         $pl_man =& PlatformManager::createInstance();
                         $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass);
                         // message to user that is inserted
                         $msg_composer = new EventMessageComposer();
                         $msg_composer->setSubjectLangText('email', '_REGISTERED_USER_SBJ', false);
                         $msg_composer->setBodyLangText('email', '_REGISTERED_USER_TEXT', $array_subst);
                         $msg_composer->setBodyLangText('sms', '_REGISTERED_USER_TEXT_SMS', $array_subst);
                         createNewAlert('UserNew', 'directory', 'edit', '1', 'User ' . $userid . ' created', array($idst), $msg_composer);
                     }
                     if ($idst !== false) {
                         foreach ($arr_idst_groups as $idst_group) {
                             $this->aclManager->addToGroup($idst_group, $idst);
                         }
                         // add to group level
                         $this->aclManager->addToGroup($userlevel, $idst);
                         //-save extra field------------------------------------------
                         $fields->storeFieldsForUser($idst, $arr_idst_all);
                         //-----------------------------------------------------------
                     }
                 } else {
                     $this->op = 'reedit_person';
                     //$GLOBALS['page']->add(getErrorUi(implode('<br/>', $re_filled)), 'content');
                 }
             }
         }
     } elseif (isset($arrayState['deleteperson'])) {
         $idst = $_POST['idst'];
         if ($idst !== '') {
             require_once _base_ . "/lib/lib.eventmanager.php";
             $u_info = $this->aclManager->getUser($idst, false);
             $userid = $u_info[ACL_INFO_USERID];
             $pl_man =& PlatformManager::createInstance();
             $acl_man =& Docebo::user()->getAclManager();
             $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $acl_man->relativeId($userid));
             // message to user that is inserted
             $msg_composer = new EventMessageComposer();
             $msg_composer->setSubjectLangText('email', '_DELETED_USER_SBJ', false);
             $msg_composer->setBodyLangText('email', '_DELETED_USER_TEXT', $array_subst);
             $msg_composer->setBodyLangText('sms', '_DELETED_USER_TEXT_SMS', $array_subst);
             /*
             				createNewAlert(	'UserDel', 'directory', 'edit', '1', 'User '.$userid.' deleted',
             							array($idst), $msg_composer );*/
             $event =& DoceboEventManager::newEvent('UserDel', 'directory', 'edit', '1', 'User ' . addslashes($userid) . ' deleted');
             $event->setProperty('recipientid', implode(',', array($idst)));
             $event->setProperty('subject', $msg_composer->getSubject('email', getLanguage()));
             $event->setProperty('body', $msg_composer->getBody('email', getLanguage()));
             $msg_composer->prepare_serialize();
             $event->setProperty('MessageComposer', addslashes(rawurlencode(serialize($msg_composer))));
             $event->setProperty('userdeleted', $idst);
             DoceboEventManager::dispatch($event);
             $this->aclManager->deleteUser($idst);
             $GLOBALS['page']->add(getResultUi($this->lang->def('_OPERATION_SUCCESSFUL')));
         }
     }
     if (!isset($arrayState[$this->id])) {
         return;
     }
     foreach ($arrayState[$this->id] as $key => $action) {
         if ($key == 'save_newfolder') {
             $array_lang = Docebo::langManager()->getAllLangCode();
             $mand_lang = getLanguage();
             if (!isset($action[$mand_lang])) {
                 $this->op = 'newfolder';
             } else {
                 $folderName = array();
                 foreach ($array_lang as $langItem) {
                     $folderName[$langItem] = $arrayState[$this->id]['new_folder'][$langItem];
                 }
                 $this->tdb->addFolderByIdTranslation($this->selectedFolder, $folderName);
                 $this->refresh = TRUE;
             }
         } elseif ($key == 'save_renamefolder') {
             $array_lang = Docebo::langManager()->getAllLangCode();
             if ($this->getSelectedFolderId() == '0') {
                 $mand_lang = 'root';
             } else {
                 $mand_lang = getLanguage();
             }
             if (!isset($action[$mand_lang]) || $action[$mand_lang] == '') {
                 $this->op = 'renamefolder';
             } else {
                 $folder_id = $this->getSelectedFolderId();
                 $acl =& Docebo::user()->getACL();
                 //-extra field check mandatory -----------------------------
                 require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
                 $fields = new FieldList();
                 $fields->setGroupFieldsTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDTABLE);
                 $fields->setFieldEntryTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDENTRYTABLE);
                 $folder_id = $this->getSelectedFolderId();
                 $folder =& $this->tdb->getFolderById($folder_id);
                 $ancestor = $this->tdb->getAllParentId($folder, $this->tdb);
                 array_push($ancestor, $folder_id);
                 //$filled = $fields->isFilledFieldsForUser($folder_id, $ancestor, FALSE );
                 //----------------------------------------------------------
                 //if( $filled === true ) {
                 $folderName = array();
                 if ($this->getSelectedFolderId() == '0') {
                     // is root
                     $folderName = $arrayState[$this->id]['rename_folder']['root'];
                     $query_root_name = "\r\n\t\t\t\t\t\t\tUPDATE " . $GLOBALS['prefix_fw'] . "_setting \r\n\t\t\t\t\t\t\tSET param_value = '" . $folderName . "'\r\n\t\t\t\t\t\t\tWHERE param_name = 'title_organigram_chart'";
                     sql_query($query_root_name);
                 } else {
                     foreach ($array_lang as $langItem) {
                         $folderName[$langItem] = $arrayState[$this->id]['rename_folder'][$langItem];
                     }
                     $this->tdb->updateFolderByIdTranslation($this->selectedFolder, $folderName);
                 }
                 //-extra field store --------------------------------------
                 $folder_idst = $this->tdb->getGroupST($folder_id);
                 $fl = new FieldList();
                 $fl->setGroupFieldsTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDTABLE);
                 $fl->setFieldEntryTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDENTRYTABLE);
                 $arr_groups_filterd = $acl->getSTGroupsST($folder_idst, FILTER_FOLD);
                 $fl->storeFieldsForUser($folder_id, $ancestor, FALSE);
                 //----------------------------------------------------------
                 $this->refresh = TRUE;
                 if ($this->getSelectedFolderId() == '0') {
                     Util::jump_to('index.php?modname=directory&op=org_chart');
                 }
                 /*} else {
                 			
                 			$this->op = 'renamefolder';
                 			$GLOBALS['page']->add( getErrorUi(implode('<br/>', $filled)), 'content' );
                 		}*/
             }
         } elseif ($key == 'next_formfield1') {
             $this->op = 'folder_field2';
         } elseif ($key == 'save_formfield') {
             require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
             if (isset($arrayState[$this->id]['field_set'])) {
                 $arr_fields = $arrayState[$this->id]['field_set'];
             } else {
                 $arr_fields = array();
             }
             if (isset($arrayState[$this->id]['field_mandatory'])) {
                 $arr_fields_mandatory = $arrayState[$this->id]['field_mandatory'];
             } else {
                 $arr_fields_mandatory = array();
             }
             $fl = new FieldList();
             $fl->setGroupFieldsTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDTABLE);
             $arr_all_fields = $fl->getAllFields();
             $id_folder = $this->getSelectedFolderId();
             // remove all fields
             foreach ($arr_all_fields as $id_field => $field) {
                 $fl->removeFieldFromGroup($id_field, $id_folder);
             }
             // add selected fields
             foreach ($arr_fields as $id_field => $dummy_val) {
                 $fl->addFieldToGroup($id_field, $id_folder, isset($arr_fields_mandatory[$id_field]) ? $arr_fields_mandatory[$id_field] : 'false');
             }
         } elseif ($key == 'next1_assignfield') {
             $this->op = 'assign2_field';
         } elseif ($key == 'next2_assignfield') {
             $this->op = 'assign3_field';
         } elseif ($key == 'save_assignfield') {
             $arr_fields = $arrayState[$this->id]['field_set'];
             $arr_fields_mandatory = isset($arrayState[$this->id]['field_mandatory']) ? $arrayState[$this->id]['field_mandatory'] : array();
             $arr_fields_useraccess = isset($arrayState[$this->id]['field_useraccess']) ? $arrayState[$this->id]['field_useraccess'] : array();
             require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
             $fl = new FieldList();
             foreach ($arr_fields as $id_filed => $status) {
                 switch ($status) {
                     case ORG_CHART_FIELD_NO:
                         $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupST($this->getSelectedFolderId()));
                         $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupDescendantsST($this->getSelectedFolderId()));
                         break;
                     case ORG_CHART_FIELD_NORMAL:
                         $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupDescendantsST($this->getSelectedFolderId()));
                         $fl->addFieldToGroup($id_filed, $this->tdb->getGroupST($this->getSelectedFolderId()), isset($arr_fields_mandatory[$id_filed]) ? $arr_fields_mandatory[$id_filed] : 'false', isset($arr_fields_useraccess[$id_filed]) ? $arr_fields_useraccess[$id_filed] : 'readonly');
                         break;
                     case ORG_CHART_FIELD_DESCEND:
                         $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupST($this->getSelectedFolderId()));
                         $fl->addFieldToGroup($id_filed, $this->tdb->getGroupDescendantsST($this->getSelectedFolderId()), isset($arr_fields_mandatory[$id_filed]) ? $arr_fields_mandatory[$id_filed] : 'false', isset($arr_fields_useraccess[$id_filed]) ? $arr_fields_useraccess[$id_filed] : 'readonly');
                         break;
                 }
             }
         } elseif ($key == $this->_getOpFolderField()) {
             if (is_array($action)) {
                 $this->selectedFolder = key($action);
             }
             $this->op = 'folder_field';
         } elseif ($key == $this->_getOpImportUsers()) {
             if (is_array($action)) {
                 $this->selectedFolder = key($action);
             }
             $this->op = 'import_users';
         } elseif ($key == 'next1_importusers') {
             $this->op = 'import_users2';
         } elseif ($key == 'next2_importusers') {
             $this->op = 'import_users3';
         } elseif ($key == $this->_getOpAssignField()) {
             if (is_array($action)) {
                 $this->selectedFolder = key($action);
             }
             $this->op = 'assign_field';
         } elseif ($key == $this->_getOpAssignUser()) {
             if (is_array($action)) {
                 $this->selectedFolder = key($action);
             }
             $this->op = 'addtotree';
         } elseif ($key == $this->_getOpCreateUser()) {
             if (is_array($action)) {
                 $this->selectedFolder = key($action);
             }
             $this->op = 'create_user';
         } elseif ($key == $this->_getOpWaitingUser()) {
             $this->op = 'waiting_user';
         }
     }
     return;
     $arrayExpand = $arrayExpand;
     $arrayCompress = $arrayCompress;
 }