Пример #1
0
/**
 * The UI for create a new task
 * @param Module $module the caller module
 **/
function ioTask_UITaskNew_step1(&$module, &$params)
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.form.php';
    $connMgr =& $module->get_connMgr();
    $lang =& $module->get_lang();
    $out =& $module->get_out();
    $form = new Form();
    $out->add($form->getLineBox($lang->def('_NAME'), $params[CONNMGR_TASK_NAME]));
    $dimport = new DoceboImport();
    $source =& $connMgr->create_connection_byname($params[CONNMGR_TASK_SOURCE]);
    if ($source->is_raw_producer()) {
        $out->add($lang->def('_MAP_NOT_REQUIRED'));
    } else {
        $destination =& $connMgr->create_connection_byname($params[CONNMGR_TASK_DESTINATION]);
        $source->connect();
        $destination->connect();
        $dimport->set_source($source);
        $dimport->set_destination($destination);
        $dimport->set_map($params[CONNMGR_TASK_MAP]);
        $out->add($dimport->getUIMap());
    }
}
 public function importusers()
 {
     $base_url = 'index.php?r=' . $this->link . '/show';
     //check permissions
     if (!$this->permissions['add_user']) {
         Util::jump_to($base_url);
     }
     $idOrg = Get::req('id', DOTY_INT, -1);
     if ($idOrg < 0) {
         return false;
     }
     $step = Get::req('step', DOTY_INT, 1);
     $params = array('id_org' => $idOrg, 'step' => $step);
     $undo = Get::req('import_groupcancel', DOTY_MIXED, false);
     if ($undo) {
         Util::jump_to($base_url);
     }
     switch ($step) {
         case 1:
             $params['orgchart_list'] = $this->model->getOrgChartDropdownList(Docebo::user()->getIdSt());
             break;
         case 2:
             require_once _base_ . '/lib/lib.upload.php';
             // ----------- file upload -----------------------------------------
             if ($_FILES['file_import']['name'] == '') {
                 //$_SESSION['last_error'] = Lang::t('_FILEUNSPECIFIED');
                 Util::jump_to($base_url . '&err=no_file');
             } else {
                 $path = '/appCore/';
                 $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
                 if (!file_exists(Get::rel_path('base') . '/files' . $path . $savefile)) {
                     sl_open_fileoperations();
                     if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                         sl_close_fileoperations();
                         //$_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                         Util::jump_to($base_url . '&err=no_upload');
                     }
                     sl_close_fileoperations();
                 } else {
                     $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                     Util::jump_to($base_url . '&err=no_upload');
                 }
             }
             require_once _adm_ . '/modules/org_chart/import.org_chart.php';
             $separator_info = Get::req('import_separator', DOTY_STRING, ',');
             $separator = false;
             switch ($separator_info) {
                 case "comma":
                     $separator = ",";
                     break;
                 case "dotcomma":
                     $separator = ";";
                     break;
                 case "manual":
                     $separator = Get::req('import_separator_manual', DOTY_STRING, "");
                     break;
             }
             $first_row_header = Get::req('import_first_row_header', DOTY_STRING, 'false') == 'true';
             $import_charset = Get::req('import_charset', DOTY_STRING, 'UTF-8');
             if (trim($import_charset) === '') {
                 $import_charset = 'UTF-8';
             }
             $pwd_force_change_policy = Get::req('pwd_force_change_policy', DOTY_STRING, 'do_nothing');
             $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
             $dst = new ImportUser(array('dbconn' => $GLOBALS['dbConn'], 'tree' => $idOrg, 'pwd_force_change_policy' => $pwd_force_change_policy, 'send_alert' => 0, 'insert_update' => 0));
             $src->connect();
             $dst->connect();
             $importer = new DoceboImport();
             $importer->setSource($src);
             $importer->setDestination($dst);
             $params['UIMap'] = $importer->getUIMap();
             $params['filename'] = $GLOBALS['where_files_relative'] . $path . $savefile;
             $params['first_row_header'] = $first_row_header;
             $params['separator'] = $separator;
             $params['import_charset'] = $import_charset;
             $params['pwd_force_change_policy'] = $pwd_force_change_policy;
             break;
         case 3:
             $filename = Get::req('filename', DOTY_STRING, "");
             if ($filename == "") {
                 return false;
             }
             $separator = Get::req('import_separator', DOTY_STRING, ',');
             $first_row_header = Get::req('import_first_row_header', DOTY_STRING, 'false') == 'true';
             $import_charset = Get::req('import_charset', DOTY_STRING, 'UTF-8');
             if (trim($import_charset) === '') {
                 $import_charset = 'UTF-8';
             }
             require_once _adm_ . '/modules/org_chart/import.org_chart.php';
             $src = new DeceboImport_SourceCSV(array('filename' => $filename, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
             $dst = new ImportUser(array('dbconn' => $GLOBALS['dbConn'], 'tree' => $idOrg, 'pwd_force_change_policy' => Get::req('pwd_force_change_policy', DOTY_STRING, 'do_nothing'), 'send_alert' => Get::pReq('send_alert', DOTY_INT, 0), 'insert_update' => Get::pReq('insert_update', DOTY_INT, 0)));
             $src->connect();
             $dst->connect();
             $importer = new DoceboImport();
             $importer->setSource($src);
             $importer->setDestination($dst);
             $importer->parseMap();
             $results = $importer->doImport();
             $users = $dst->getNewImportedIdst();
             //apply enroll rules
             if (!empty($users)) {
                 $enrollrules = new EnrollrulesAlms();
                 $enrollrules->newRules('_NEW_IMPORTED_USER', $users, 'all', $idOrg);
             }
             $src->close();
             $dst->close();
             $buffer = "";
             if (count($results) > 1) {
                 require_once _base_ . '/lib/lib.table.php';
                 $buffer .= Lang::t('_ERRORS', 'admin_directory') . ': <b>' . (count($results) - 1) . '</b><br/>';
                 $table = new Table(Get::sett('visuItem', 25), Lang::t('_ERRORS', 'admin_directory'), Lang::t('_ERRORS', 'admin_directory'));
                 $table->setColsStyle(array('', ''));
                 $table->addHead(array(Lang::t('_ROW', 'admin_directory'), Lang::t('_DESCRIPTION', 'admin_directory')));
                 foreach ($results as $key => $err_val) {
                     if ($key != 0) {
                         $table->addBody(array($key, $err_val));
                     }
                 }
                 $buffer .= $table->getTable();
             }
             if ($buffer === '') {
                 $buffer = '<br/><br/>';
             }
             $params['backUi'] = getBackUi($base_url, Lang::t('_BACK', 'standard'));
             $params['resultUi'] = Lang::t('_IMPORT', 'standard') . ': <b>' . ($first_row_header ? $results[0] - 1 : $results[0]) . '</b><br />';
             $params['results'] = $results;
             $params['table'] = $buffer;
             // remove uploaded file:
             require_once _base_ . '/lib/lib.upload.php';
             sl_open_fileoperations();
             unlink($filename);
             sl_close_fileoperations();
             break;
     }
     $this->render('importusers', $params);
 }
Пример #3
0
 function importToGroup_step2()
 {
     require_once _base_ . '/lib/lib.upload.php';
     // ----------- file upload -----------------------------------------
     if ($_FILES['file_import']['name'] == '') {
         $_SESSION['last_error'] = Lang::t('_FILEUNSPECIFIED');
         Util::jump_to('index.php?modname=directory&amp;op=listgroup&import_result=-1');
     } else {
         $path = '/appCore/';
         $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
         if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
             sl_open_fileoperations();
             if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                 sl_close_fileoperations();
                 $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                 Util::jump_to('index.php?modname=directory&amp;op=listgroup&import_result=-1');
             }
             sl_close_fileoperations();
         } else {
             $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
             Util::jump_to('index.php?modname=directory&amp;op=listgroup&import_result=-1');
         }
     }
     require_once _base_ . '/lib/lib.form.php';
     $form = new Form();
     $tree = getTitleArea($this->lang->def('_ORG_CHART_IMPORT_USERS', 'organization_chart'), 'directory_group') . '<div class="std_block">' . $form->openForm('directory_importgroupuser', 'index.php?modname=directory&amp;op=import_groupuser_3', false, false, 'multipart/form-data');
     $tree .= $form->openElementSpace();
     require_once $GLOBALS['where_framework'] . '/modules/org_chart/import.org_chart.php';
     $separator = importVar('import_separator', false, ',');
     $first_row_header = isset($_POST['import_first_row_header']) ? $_POST['import_first_row_header'] == 'true' : FALSE;
     $import_charset = importVar('import_charset', false, 'UTF-8');
     if (trim($import_charset) === '') {
         $import_charset = 'UTF-8';
     }
     $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
     $dst = new ImportGroupUser(array('dbconn' => $GLOBALS['dbConn']));
     $src->connect();
     $dst->connect();
     $importer = new DoceboImport();
     $importer->setSource($src);
     $importer->setDestination($dst);
     $tree .= $importer->getUIMap();
     $tree .= $form->getHidden('filename', 'filename', $GLOBALS['where_files_relative'] . $path . $savefile);
     $tree .= $form->getHidden('import_first_row_header', 'import_first_row_header', $first_row_header ? 'true' : 'false');
     $tree .= $form->getHidden('import_separator', 'import_separator', $separator);
     $tree .= $form->getHidden('import_charset', 'import_charset', $import_charset);
     $tree .= $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('next_importusers_3', 'next_importusers_3', $this->lang->def('_NEXT')) . $form->getButton('import_groupcancel', 'import_groupcancel', $this->lang->def('_UNDO')) . $form->closeButtonSpace();
     $tree .= Form::closeForm() . '</div>';
     $GLOBALS['page']->add($tree, 'content');
 }
Пример #4
0
 function loadImportUsers2()
 {
     require_once _base_ . '/lib/lib.upload.php';
     $tdb =& $this->tdb;
     $folder = $tdb->getFolderById($this->getSelectedFolderId());
     $back_url = 'index.php?modname=directory&op=org_chart';
     // ----------- file upload -----------------------------------------
     if ($_FILES['file_import']['name'] == '') {
         $_SESSION['last_error'] = Lang::t('_FILEUNSPECIFIED');
         Util::jump_to($back_url . '&import_result=-1');
     } else {
         $path = '/appCore/';
         $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
         if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
             sl_open_fileoperations();
             if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                 sl_close_fileoperations();
                 $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                 Util::jump_to($back_url . '&import_result=-1');
             }
             sl_close_fileoperations();
         } else {
             $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
             Util::jump_to($back_url . '&create_result=-1');
         }
     }
     require_once _base_ . '/lib/lib.form.php';
     $form = new Form();
     $tree = $form->getFormHeader($this->lang->def('_ORG_CHART_IMPORT_USERS'));
     $tree .= $form->openElementSpace();
     $tree .= $this->printState();
     require_once dirname(__FILE__) . '/import.org_chart.php';
     $separator = isset($_POST['import_separator']) ? $_POST['import_separator'] : ',';
     $first_row_header = isset($_POST['import_first_row_header']) ? $_POST['import_first_row_header'] == 'true' : FALSE;
     $import_charset = isset($_POST['import_charset']) ? $_POST['import_charset'] : 'UTF-8';
     if (trim($import_charset) === '') {
         $import_charset = 'UTF-8';
     }
     $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
     $dst = new ImportUser(array('dbconn' => $GLOBALS['dbConn'], 'tree' => &$this));
     $src->connect();
     $dst->connect();
     $importer = new DoceboImport();
     $importer->setSource($src);
     $importer->setDestination($dst);
     $tree .= $importer->getUIMap();
     $tree .= $form->getHidden($this->id . '_filename', $this->id . '[filename]', $GLOBALS['where_files_relative'] . $path . $savefile);
     $tree .= $form->getHidden('import_first_row_header', 'import_first_row_header', $first_row_header ? 'true' : 'false');
     $tree .= $form->getHidden('import_separator', 'import_separator', $separator);
     $tree .= $form->getHidden('import_charset', 'import_charset', $import_charset);
     $tree .= $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('next2_importusers' . $this->id, $this->id . '[next2_importusers]', $this->lang->def('_SAVE')) . $form->getButton($this->_getCancelId(), $this->_getCancelId(), $this->lang->def('_UNDO')) . $form->closeButtonSpace();
     return $tree;
 }