示例#1
0
 function renderHtml()
 {
     $type_key = $this->context->getTypeKeys();
     if (is_numeric($this->query('sletbillede'))) {
         $fields = array('date_updated', 'pic_id');
         $values = array('NOW()', 0);
         $sth = $this->db->autoPrepare('langtkursus_tilmelding', $fields, DB_AUTOQUERY_UPDATE, 'id = ' . $this->query('id'));
         $res = $this->db->execute($sth, $values);
         if (PEAR::isError($res)) {
             throw new Exception($res->getMessage());
         }
     }
     $form = new HTML_QuickForm();
     $form->addElement('hidden', 'id', $this->name());
     $form->addElement('file', 'userfile', 'Fil');
     $form->addElement('submit', null, 'Upload');
     if ($form->validate()) {
         $file = new VIH_FileHandler();
         if ($file->upload('userfile')) {
             $fields = array('date_updated', 'pic_id');
             $values = array('NOW()', $file->get('id'));
             $sth = $this->db->autoPrepare('langtkursus_tilmelding', $fields, DB_AUTOQUERY_UPDATE, 'id = ' . $form->exportValue('id'));
             $res = $this->db->execute($sth, $values);
             if (PEAR::isError($res)) {
                 throw new Exception($res->getMessage());
             }
             return new k_SeeOther($this->url('./'));
         }
     }
     $tilmelding = new VIH_Model_LangtKursus_Tilmelding($this->name());
     if ($tilmelding->get('id') == 0) {
         throw new k_http_Response(404);
     }
     $file = new VIH_FileHandler($tilmelding->get('pic_id'));
     $file->loadInstance('small');
     $extra_html = $file->getImageHtml($tilmelding->get('name'), 'width="100""');
     $file->loadInstance('medium');
     $stor = $file->get('file_uri');
     if (empty($extra_html)) {
         $extra_html = $form->toHTML();
     } else {
         $extra_html .= ' <br /><a href="' . $stor . '">stor</a> <a href="' . url('./') . '?sletbillede=' . $this->name() . '" onclick="return confirm(\'Er du sikker\');">slet billede</a>';
     }
     $res = $this->db->query('SELECT *, DATE_FORMAT(date_start, "%d-%m %H:%i") AS date_start_dk, DATE_FORMAT(date_end, "%d-%m %H:%i") AS date_end_dk FROM langtkursus_tilmelding_protokol_item WHERE tilmelding_id = ' . (int) $this->name() . ' ORDER BY date_start DESC, date_end DESC');
     if (PEAR::isError($res)) {
         throw new Exception($res->getMessage());
     }
     $data = array('items' => $res, 'type_key' => $type_key, 'vis_navn' => false);
     $this->document->setTitle($tilmelding->get('navn'));
     $this->document->addOption('Ret', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id')));
     $this->document->addOption('Indtast', $this->url('indtast'));
     $this->document->addOption('Tilmelding', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id')));
     $this->document->addOption('F*g', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id') . '/f*g'));
     $this->document->addOption('Holdliste', $this->context->url());
     $this->document->addOption('Diplom', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id') . '/diplom'));
     $tpl = $this->template->create('protokol/liste');
     return '<div style="border: 1px solid #ccc; padding: 0.5em; float: right;">' . $extra_html . '</div>
         ' . $tpl->render($this, $data);
 }
示例#2
0
 //Register this rule for checking user input with our function, eF_checkParameter
 $form->addElement('text', 'name', _DIRECTIONNAME, 'class = "inputText"');
 $form->addRule('name', _THEFIELD . ' ' . _DIRECTIONNAME . ' ' . _ISMANDATORY, 'required', null, 'client');
 //$form -> addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'text');
 $selectOptions = $directionsPaths;
 $selectOptions[0] = _ROOTDIRECTION;
 ksort($selectOptions);
 $form->addElement('select', 'parent_direction_ID', _PARENTDIRECTION, $selectOptions);
 //$form -> addElement("advcheckbox", "active", _ACTIVEFEM, null, 'class = "inputCheckBox"', array(0, 1));
 $form->setDefaults($defaults_array);
 if (!$_change_) {
     $form->freeze();
 } else {
     $form->addElement('submit', 'submit_direction', _SUBMIT, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $direction_content = array("name" => $form->exportValue('name'), "parent_direction_ID" => $form->exportValue('parent_direction_ID'), "active" => 1);
         if (isset($_GET['edit_direction'])) {
             $editDirection['name'] = $direction_content['name'];
             $editDirection['parent_direction_ID'] = $direction_content['parent_direction_ID'];
             $editDirection['active'] = $direction_content['active'];
             try {
                 $editDirection->persist();
                 eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=directions&message=" . urlencode(_SUCCESFULLYUPDATEDDIRECTION) . "&message_type=success");
             } catch (Exception $e) {
                 $message = _SOMEPROBLEMEMERGED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ')';
                 $message_type = 'failure';
             }
         } else {
             try {
                 EfrontDirection::createDirection($direction_content);
                 eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=directions&message=" . urlencode(_SUCCESFULLYADDEDDIRECTION) . "&message_type=success");
     $form->freeze();
 } else {
     $form->addElement('submit', 'submit_certificate', _SAVE, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $certificateDirectory = G_CERTIFICATETEMPLATEPATH;
         if (!is_dir($certificateDirectory)) {
             mkdir($certificateDirectory, 0755);
         }
         $logoid = 0;
         try {
             if ($_FILES['file_upload']['size'] > 0) {
                 $filesystem = new FileSystemTree($certificateDirectory);
                 $uploadedFile = $filesystem->uploadFile('file_upload', $certificateDirectory);
                 $certificateid = $uploadedFile['id'];
             } else {
                 $selectedCertificate = $form->exportValue('existing_certificate');
                 $certificateFile = new EfrontFile(G_CERTIFICATETEMPLATEPATH . $selectedCertificate);
                 if ($certificateFile['id'] < 0) {
                     //if the file doesn't exist, then import it
                     $selectedCertificate = $certificateFileSystemTree->seekNode(G_CERTIFICATETEMPLATEPATH . $selectedCertificate);
                     $newList = FileSystemTree::importFiles($selectedCertificate['path']);
                     $certificateid = key($newList);
                 } else {
                     $certificateid = $certificateFile['id'];
                 }
             }
             if (G_VERSIONTYPE != 'standard') {
                 #cpp#ifndef STANDARD
                 $duration = $_POST['days'] * 24 * 60 * 60 + $_POST['months'] * 30 * 24 * 60 * 60;
                 $currentCourse->course['certificate_expiration'] = $duration;
                 $duration_reset = $form->exportValue('days_reset') * 24 * 60 * 60 + $form->exportValue('months_reset') * 30 * 24 * 60 * 60;
示例#4
0
 $fields_insert = array('name' => $values['name'], 'languages_NAME' => $languages_NAME, 'directions_ID' => $values['directions_ID'], 'active' => $values['active'], 'duration' => $values['duration'] ? $values['duration'] : 0, 'access_limit' => $values['access_limit'] ? $values['access_limit'] : 0, 'share_folder' => $values['share_folder'] ? $values['share_folder'] : 0, 'max_users' => $values['max_users'] ? $values['max_users'] : null, 'show_catalog' => $values['show_catalog'], 'course_only' => $values['course_only'] == '' ? 0 : $values['course_only'], 'created' => time(), 'price' => str_replace($localeSettings['decimal_point'], '.', $values['price']));
 try {
     //If we asked to copy properties for another lesson, initialize it and get its properties (except for recurring options, which are already defined in the same page)
     if ($values['copy_properties']) {
         $copyPropertiesLesson = new EfrontLesson($values['copy_properties']);
         unset($copyPropertiesLesson->options['recurring']);
         unset($copyPropertiesLesson->options['recurring_duration']);
         $fields_insert['options'] = serialize($copyPropertiesLesson->options);
     }
     //Create the new lesson
     $newLesson = EfrontLesson::createLesson($fields_insert);
     //If a recurring payment is set, set this up to the lesson properties
     if ($values['price'] && $values['recurring'] && in_array($values['recurring'], array_keys($recurringOptions))) {
         $newLesson->options['recurring'] = $values['recurring'];
         if ($newLesson->options['recurring']) {
             $newLesson->options['recurring_duration'] = $form->exportValue($newLesson->options['recurring'] . '_duration');
         }
         $newLesson->persist();
     }
     //Import file, if any specified
     if ($values['clone_lesson']) {
         $cloneLesson = new EfrontLesson($values['clone_lesson']);
         $file = $cloneLesson->export();
         $exportedFile = $file->copy($newLesson->getDirectory() . '/' . $exportedFile['name']);
     }
     if (isset($exportedFile)) {
         $newLesson->import($exportedFile);
     } else {
         //There was no file imported, then it's safe to add a default completion condition
         $fields = array('lessons_ID' => $newLesson->lesson['id'], 'type' => 'all_units', 'relation' => 'and');
         eF_insertTableData('lesson_conditions', $fields);
 private function doJobCourses()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $result = eF_getTableData("module_hcd_job_description j left outer join module_hcd_course_to_job_description cj on cj.job_description_ID=j.job_description_ID", "j.job_description_ID,description,branch_ID,count(courses_ID) as total_courses", "", "", "j.job_description_ID");
     $branchesTree = new EfrontBranchesTree();
     $branchesTreePaths = $branchesTree->toPathString();
     $jobs = array();
     foreach ($result as $value) {
         $jobsArray[$value['job_description_ID']] = $value;
         $jobs[$value['job_description_ID']] = $branchesTreePaths[$value['branch_ID']] . "&nbsp;&rarr;&nbsp;" . $value['description'] . " (" . $value['total_courses'] . ")";
     }
     $form = new HTML_QuickForm("job_courses_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=job_courses&do=enterprise", "", null, true);
     $form->addElement('select', 'job', _JOBDESCRIPTION, $jobs);
     $form->addElement("submit", "submit", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTION, 'class = "flatButton"');
     $form->addElement("static", "", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTIONTOALLSIMILARJOBS);
     $form->setDefaults(array("idle_from_timestamp" => $_SESSION['timestamp_from']));
     if ($form->isSubmitted() && $form->validate()) {
         $GLOBALS['currentEmployee'] = $currentUser->aspects['hcd'];
         $job = new EfrontJob($form->exportValue('job'));
         $courses = $job->getJobCourses();
         foreach ($sameJobs = $job->getSameDescriptions() as $value) {
             eF_deleteTableData("module_hcd_course_to_job_description", "job_description_id = '" . $value . "'");
         }
         $job->associateCoursesToJob($courses, true);
         $message = str_replace(array("%x", "%y"), array(sizeof($sameJobs), sizeof($courses)), _MODULE_ADMINISTRATOR_TOOLS_SUCCESSFULLYASSIGNEDCOURSESTOJOBS);
         $message_type = 'success';
         $this->setMessageVar($message, $message_type);
     }
     $smarty->assign("T_JOB_COURSES_FORM", $form->toArray());
 }
示例#6
0
             $smarty->assign("T_COURSE_INSTANCES", $courseInstances);
         }
         #cpp#endif
     }
     #cpp#endif
 } else {
     $form->setDefaults(array('active' => 1, 'show_catalog' => 1, 'price' => 0, 'languages_NAME' => $GLOBALS['configuration']['default_language']));
 }
 if (!$_change_) {
     $form->freeze();
 } else {
     $form->addElement('submit', 'submit_course', _SUBMIT, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $localeSettings = localeconv();
         $values = $form->exportValues();
         $fields = array('languages_NAME' => $GLOBALS['configuration']['onelanguage'] ? $GLOBALS['configuration']['default_language'] : $form->exportValue('languages_NAME'), 'show_catalog' => $form->exportValue('show_catalog'), 'directions_ID' => $form->exportValue('directions_ID'), 'name' => $form->exportValue('name'), 'active' => $form->exportValue('active'), 'max_users' => $form->exportValue('max_users') ? $form->exportValue('max_users') : null, 'price' => str_replace($localeSettings['decimal_point'], '.', $form->exportValue('price')), 'ceu' => $form->exportValue('ceu'), 'supervisor_LOGIN' => $values['supervisor_LOGIN'] ? $values['supervisor_LOGIN'] : null);
         try {
             if (isset($_GET['edit_course'])) {
                 if ($fields['directions_ID'] != $editCourse->course['directions_ID']) {
                     $updateCourseInstancesCategory = true;
                     //This means we need to update instances to match the course's new category
                 }
                 $editCourse->course = array_merge($editCourse->course, $fields);
                 if ($courseSk = $editCourse->getCourseSkill()) {
                     eF_updateTableData("module_hcd_skills", array("description" => _KNOWLEDGEOFCOURSE . " " . $form->exportValue('name')), "skill_ID = " . $courseSk['skill_ID']);
                 }
                 $message = _COURSEUPDATED;
                 //$redirect = basename($_SERVER['PHP_SELF']).'?ctg=courses&message='.urlencode(_COURSEUPDATED).'&message_type=success';
             } else {
                 $editCourse = EfrontCourse::createCourse($fields);
                 $message = _SUCCESFULLYCREATEDCOURSE;
}
$form->addElement('textarea', 'comments', _COMMENTS, 'class = "inputContentTextarea" style = "width:100%;height:5em;"');
$form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$form->registerRule('checkNotExist', 'callback', 'eF_checkNotExist');
$form->registerRule('checkRule', 'callback', 'eF_checkRule');
//Register this rule for checking user input with our function, eF_checkParameter
$form->addRule('password_', str_replace("%x", $GLOBALS['configuration']['password_length'], _PASSWORDMUSTBE6CHARACTERS), 'minlength', $GLOBALS['configuration']['password_length'], 'client');
$form->addRule(array('password_', 'passrepeat'), _PASSWORDSDONOTMATCH, 'compare', null, 'client');
$form->addRule('name', _THEFIELD . ' ' . _FIRSTNAME . ' ' . _ISMANDATORY, 'required', null, 'client');
$form->addRule('surname', _THEFIELD . ' ' . _LASTNAME . ' ' . _ISMANDATORY, 'required', null, 'client');
$form->addRule('email', _THEFIELD . ' ' . _EMAILADDRESS . ' ' . _ISMANDATORY, 'required', null, 'client');
$form->addRule('email', _INVALIDFIELDDATA, 'checkParameter', 'email');
if (isset($_GET['add_user'])) {
    $form->addRule('login', _INVALIDFIELDDATA, 'checkParameter', 'login');
    $form->addRule('login', _THELOGIN . ' &quot;' . $form->exportValue('login') . '&quot; ' . _ALREADYEXISTS, 'checkNotExist', 'login');
    $form->addRule('login', _THEFIELD . ' ' . _LOGIN . ' ' . _ISMANDATORY, 'required', null, 'client');
    $form->addRule('password_', _THEFIELD . ' ' . _PASSWORD . ' ' . _ISMANDATORY, 'required', null, 'client');
    $form->addRule('passrepeat', _THEFIELD . ' ' . _REPEATPASSWORD . ' ' . _ISMANDATORY, 'required', null, 'client');
}
$form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
//getUploadMaxSize returns size in KB
if (G_VERSIONTYPE != 'community') {
    #cpp#ifndef COMMUNITY
    //Add custom fields, defined in user_profile database table
    if ($currentUser->user['login'] == $editedUser->user['login']) {
        if (isset($_GET['add_user'])) {
            $userProfile = eF_getTableData("user_profile", "*", "active=1 AND type <> 'branchinfo' AND type <> 'groupinfo'", "field_order");
            //Get admin-defined form fields for user registration
        } else {
            $userProfile = eF_getTableData("user_profile", "*", "active=1 and visible=1 AND type <> 'branchinfo' AND type <> 'groupinfo'", "field_order");
示例#8
0
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 } elseif (isset($_GET['add_evaluation']) || isset($_GET['edit_evaluation']) && eF_checkParameter($_GET['edit_evaluation'], 'id') && $_change_evaluations_) {
     $load_editor = true;
     $form = new HTML_QuickForm("evaluations_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=evaluations&" . (isset($_GET['edit_evaluation']) ? "&edit_evaluation=" . $_GET['edit_evaluation'] : "&add_evaluation=1"), "", null, true);
     $form->addElement('textarea', 'specification', _EVALUATIONCOMMENT, 'class = "simpleEditor" style = "width:400px;"');
     $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"');
     if (isset($_GET['edit_evaluation'])) {
         $evaluations = eF_getTableData("module_hcd_events", "*", "event_ID = '" . $_GET['edit_evaluation'] . "'");
         $form->setDefaults(array('specification' => $evaluations[0]['specification']));
     }
     try {
         if ($form->isSubmitted() && $form->validate()) {
             $evaluation_content = array('specification' => $form->exportValue('specification'), 'event_code' => 10, 'users_login' => $editedUser->user['login'], 'author' => $currentUser->user['login'], 'timestamp' => time());
             if (isset($_GET['add_evaluation'])) {
                 eF_insertTableData("module_hcd_events", $evaluation_content);
             } elseif (isset($_GET['edit_evaluation'])) {
                 eF_updateTableData("module_hcd_events", $evaluation_content, "event_ID = '" . $_GET['edit_evaluation'] . "'");
             }
             $message = _OPERATIONCOMPLETEDSUCCESSFULLY;
             $message_type = 'success';
         }
     } catch (Exception $e) {
         handleNormalFlowExceptions($e);
     }
     $smarty->assign("T_EVALUATIONS_FORM", $form->toArray());
 } else {
     $evaluations = eF_getTableData("module_hcd_events", "*", "users_login = '******'login'] . "' AND event_code >=10", "timestamp");
     $smarty->assign("T_EVALUATIONS", $evaluations);
示例#9
0
 public static function mobile_login()
 {
     $t = Variable::get('host_ban_time');
     if ($t > 0) {
         $fails = DB::GetOne('SELECT count(*) FROM user_login_ban WHERE failed_on>%d AND from_addr=%s', array(time() - $t, get_client_ip_address()));
         if ($fails >= 3) {
             print __('You have exceeded the number of allowed login attempts.') . '<br>';
             print '<a href="' . get_epesi_url() . '">' . __('Host banned. Click here to refresh.') . '</a>';
             return;
         }
     }
     $qf = new HTML_QuickForm('login', 'post', 'mobile.php?' . http_build_query($_GET));
     $qf->addElement('text', 'username', __('Login'));
     $qf->addElement('password', 'password', __('Password'));
     $qf->addElement('submit', 'submit_button', __('Login'));
     $qf->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon');
     $qf->addRule(array('username', 'password'), __('Login or password incorrect'), 'check_login');
     $qf->addRule('username', __('Field required'), 'required');
     $qf->addRule('password', __('Field required'), 'required');
     if ($qf->validate()) {
         self::set_logged($qf->exportValue('username'));
         self::new_autologin_id();
         return false;
     }
     $qf->display();
 }
示例#10
0
 public function getModule()
 {
     // Get smarty variable
     $smarty = $this->getSmartyVar();
     if (isset($_GET['delete_faq']) && eF_checkParameter($_GET['delete_faq'], 'id')) {
         eF_deleteTableData("module_faq", "id=" . $_GET['delete_faq']);
         eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYDELETEDFAQENTRY) . "&message_type=success");
     } else {
         if (isset($_GET['add_faq']) || isset($_GET['edit_faq']) && eF_checkParameter($_GET['edit_faq'], 'id')) {
             $load_editor = true;
             //TODO
             $form = new HTML_QuickForm("faq_entry_form", "post", $_SERVER['REQUEST_URI'], "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             //Register this rule for checking user input with our function, eF_checkParameter
             $form->addElement('textarea', 'question', null, 'class = "simpleEditor" style = "width:100%;height:5em;"');
             $form->addElement('textarea', 'answer', null, 'class = "simpleEditor" style = "width:100%;height:25em;"');
             $currentLesson = $this->getCurrentLesson();
             $units = eF_getTableDataFlat("content", "id, name", "lessons_ID = " . $currentLesson->lesson['id']);
             //$units['id'] = array_merge(array("0"), $units['id']);
             //$units['name'] = array_merge(array(_FAQ_GENERAL_LESSON), $units['name']);
             sizeof($units) > 0 ? $units = array(0 => _FAQ_GENERAL_LESSON) + array_combine($units['id'], $units['name']) : ($units = array("0" => _FAQ_GENERAL_LESSON));
             $form->addElement('select', 'related_content', _CONTENT, $units, 'class = "inputSelectLong"');
             $form->addElement('submit', 'submit_faq', _SUBMIT, 'class = "flatButton"');
             if (isset($_GET['edit_faq'])) {
                 $faq_entry = eF_getTableData("module_faq", "*", "id=" . $_GET['edit_faq']);
                 $form->setDefaults(array('related_content' => $faq_entry[0]['unit_ID'], 'question' => $faq_entry[0]['question'], 'answer' => $faq_entry[0]['answer']));
             }
             if ($form->isSubmitted() && $form->validate()) {
                 $fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'unit_ID' => $form->exportValue('related_content'), 'question' => $form->exportValue('question'), 'answer' => $form->exportValue('answer'));
                 if (isset($_GET['edit_faq'])) {
                     if (eF_updateTableData("module_faq", $fields, "id=" . $_GET['edit_faq'])) {
                         eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYUPDATEDFAQENTRY) . "&message_type=success");
                     } else {
                         $this->setMessageVar(_FAQ_PROBLEMUPDATINGFAQENTRY, 'failure');
                     }
                 } else {
                     if (eF_insertTableData("module_faq", $fields)) {
                         eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYINSERTEDFAQENTRY) . "&message_type=success");
                     } else {
                         $this->setMessageVar(_FAQ_PROBLEMINSERTINGFAQENTRY, 'failure');
                     }
                 }
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             $form->accept($renderer);
             $smarty->assign('T_FAQ_FORM', $renderer->toArray());
         } else {
             $currentLesson = $this->getCurrentLesson();
             $faq = eF_getTableDataFlat("module_faq", "*", "lessons_ID=" . $currentLesson->lesson['id']);
             $currentUser = $this->getCurrentUser();
             $smarty->assign("T_FAQUSERLESSONROLE", $currentUser->getRole($currentLesson));
             $smarty->assign("T_FAQ", $faq);
             $smarty->assign("T_QUESTIONS_FOUND", sizeof($faq));
         }
     }
     return true;
 }
示例#11
0
 $user = EfrontUserFactory::factory($_SESSION['s_login']);
 $changePasswordForm = new HTML_QuickForm("change_password_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=password_change", "", "class = 'indexForm'", true);
 $changePasswordForm->addElement('password', 'old_password', _OLDPASSWORD, 'class = "inputText"');
 // SMS: 7/23/2014 Changed to support vLab
 // $changePasswordForm -> addElement('password', 'password', _NEWPASSWORD, 'class = "inputText"');
 $changePasswordForm->addElement('password', 'password', _NEWPASSWORD, 'class = "inputText"');
 $changePasswordForm->addElement('password', 'passrepeat', _REPEATPASSWORD, 'class = "inputText"');
 $changePasswordForm->addRule('password', _THEFIELD . ' ' . _PASSWORD . ' ' . _ISMANDATORY, 'required', null, 'client');
 $changePasswordForm->addRule('passrepeat', _THEFIELD . ' ' . _REPEATPASSWORD . ' ' . _ISMANDATORY, 'required', null, 'client');
 // SMS: 7/23/2014 Changed to support vLab
 // $changePasswordForm -> addRule(array('password', 'passrepeat'), _PASSWORDSDONOTMATCH, 'compare', null, 'client');
 $changePasswordForm->addRule(array('password', 'passrepeat'), _PASSWORDSDONOTMATCH, 'compare', null, 'client');
 $changePasswordForm->addRule('passrepeat', str_replace("%x", $GLOBALS['configuration']['password_length'], _PASSWORDMUSTBE6CHARACTERS), 'minlength', $GLOBALS['configuration']['password_length'], 'client');
 $changePasswordForm->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"');
 if ($changePasswordForm->isSubmitted() && $changePasswordForm->validate()) {
     $newPassword = $changePasswordForm->exportValue('password');
     $newPassword = EfrontUser::createPassword($newPassword);
     if ($user->user['password'] != EfrontUser::createPassword($changePasswordForm->exportValue('old_password'))) {
         $message = _OLDPASSWORDWRONG;
         $message_type = 'failure';
     } else {
         if ($user->user['password'] == $newPassword) {
             $message = _PASSWORDISTHESAME;
             $message_type = 'failure';
         } else {
             $user->user['password'] = $newPassword;
             $user->user['need_pwd_change'] = 0;
             $user->persist();
             unset($_SESSION['s_index_comply']);
             if ($GLOBALS['configuration']['show_license_note'] && $user->user['viewed_license'] == 0) {
                 eF_redirect("index.php?ctg=agreement");
示例#12
0
         foreach ($values['multiple_many'] as $key => $value) {
             $form->addElement('text', 'multiple_many[' . $key . ']', 'Insert Questions', 'class = "inputText inputText_QuestionChoice"');
             $form->addElement('checkbox', 'correct_multiple_many[' . $key . ']');
             $form->addElement('text', 'answers_explanation[' . $key . ']', null, 'class = "inputText inputText_QuestionChoice"' . (!$values['answers_explanation'][$key] ? 'style = "display:none"' : ''));
             $form->addRule('multiple_many[' . $key . ']', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
             $form->setDefaults(array('multiple_many[' . $key . ']' => $value));
             $form->setDefaults(array('correct_multiple_many[' . $key . ']' => $values['correct_multiple_many'][$key]));
             $form->setDefaults(array('answers_explanation[' . $key . ']' => $values['answers_explanation'][$key]));
         }
         $form->setDefaults(array('answers_logic' => $currentQuestion->settings['answers_logic']));
         if ($currentQuestion->settings['answers_or']) {
             //For compatibility reasons, this used to be 'answers_or'
             $form->setDefaults(array('answers_logic' => 'or'));
         }
         if ($form->validate()) {
             $question_values = array('type' => 'multiple_many', 'options' => serialize($values['multiple_many']), 'answer' => serialize($values['correct_multiple_many']), 'settings' => serialize(array('answers_logic' => $form->exportValue('answers_logic'))));
         }
     } else {
         //By default, only 2 options are displayed
         $form->addElement('text', 'multiple_many[0]', 'Insert Multiple Questions (many)', 'class = "inputText inputText_QuestionChoice"');
         $form->addElement('text', 'multiple_many[1]', null, 'class = "inputText inputText_QuestionChoice"');
         $form->addElement('text', 'answers_explanation[0]', null, 'class = "inputText inputText_QuestionChoice" style = "display:none"');
         $form->addElement('text', 'answers_explanation[1]', null, 'class = "inputText inputText_QuestionChoice" style = "display:none"');
         $form->addElement('checkbox', 'correct_multiple_many[0]');
         $form->addElement('checkbox', 'correct_multiple_many[1]');
         $form->addRule('multiple_many[1]', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
         $form->addRule('multiple_many[1]', _INVALIDFIELDDATA, 'checkParameter', 'text');
         $form->addRule('multiple_many[0]', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
     }
     break;
 case 'raw_text':
if ($form->validate()) {
    // først skal vi oprette en betaling - som kan fungere som id hos qp
    // betalingen skal kobles til den aktuelle tilmelding
    // når vi så har haft den omkring pbs skal betalingen opdateres med status for betalingen
    // status sættes til 000, hvis den er godkendt hos pbs.
    $eval = false;
    $betaling = new VIH_Model_Betaling('elevforeningen', $order_id);
    $betaling_amount_quickpay = $betaling_amount * 100;
    $betaling_id = $betaling->save(array('type' => 'quickpay', 'amount' => $betaling_amount));
    if ($betaling_id == 0) {
        trigger_error("Kunne ikke oprette betaling", E_USER_ERROR);
    }
    $onlinebetaling = new VIH_Onlinebetaling('authorize');
    $onlinebetaling->addCustomVar('Elevforeningsmedlem', $contact['number']);
    $onlinebetaling->addCustomVar('Kontaktid', $contact['id']);
    $eval = $onlinebetaling->authorize($form->exportValue('cardnumber'), $form->exportValue('yy') . $form->exportValue('mm'), $form->exportValue('cvd'), $betaling_id, $betaling_amount_quickpay);
    if ($eval) {
        if ($eval['qpstat'] === '000') {
            // The authorization was completed
            /*
            echo 'Authorization: ' . $qpstatText["" . $eval['qpstat'] . ""] . '<br />';
            echo "<pre>";
            var_dump($eval);
            echo "</pre>";
            */
            $betaling->setTransactionnumber($eval['transaction']);
            $betaling->setStatus('completed');
            $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id'));
            if (!$historik->save(array('type' => 'dankort', 'comment' => 'Onlinebetaling # ' . $betaling->get('transactionnumber')))) {
                trigger_error('Der var en fejl med at gemme historikken.', E_USER_ERROR);
            }
示例#14
0
 } else {
     $target = basename($_SERVER['PHP_SELF']) . '?ctg=lessons&catalog=1&checkout=1';
     $cancelReturn = G_SERVERNAME . 'studentpage.php?message=' . urlencode(_YOUHAVECANCELLEDTHETRANSACTION);
 }
 $form = new HTML_QuickForm("my_checkout_form", "post", $target, "", 'style = "display:inline"', true);
 $form->addElement('text', 'coupon', null, 'style = "display:none" id = "coupon_code"');
 if (G_VERSIONTYPE != 'community') {
     #cpp#ifndef COMMUNITY
     if ($totalPrice > 0 && ($GLOBALS['configuration']['paypalbusiness'] || $GLOBALS['configuration']['enable_balance'] && $currentUser->user['balance'] && $currentUser->user['balance'] >= $totalPrice)) {
         if ($GLOBALS['configuration']['paypalbusiness']) {
             $GLOBALS['configuration']['paypalmode'] == 'sandbox' ? $paypalUrl = "www.sandbox.paypal.com" : ($paypalUrl = "www.paypal.com");
             //Toggle sandbox/normal use
             $GLOBALS['configuration']['paypaldebug'] ? $fieldType = 'text' : ($fieldType = 'hidden');
             //$form -> addElement('submit', 'submit_checkout_paypal', _PAYPALPAYNOW, 'class = "flatButton"');
             //Calculate price after discount, if any
             if ($form->isSubmitted() && $form->validate() && $form->exportValue('coupon') && ($coupon = new coupons($form->exportValue('coupon'), true))) {
                 if (!$coupon->checkEligibility($currentUser)) {
                     throw new Exception(_INVALIDCOUPON);
                 }
                 $totalPrice = $totalPrice * (1 - $coupon->{$coupon->entity}['discount'] / 100);
                 $useCoupon = 1;
             }
             $productNames = $lessonIds = $courseIds = array();
             foreach ($cart['lesson'] as $lesson) {
                 if ($lesson['recurring']) {
                     !$useCoupon or $lesson['price'] = $lesson['price'] * (1 - $coupon->{$coupon->entity}['discount'] / 100);
                     //$lesson['product_type'] = 'lesson';
                     $recurring = $lesson;
                 }
                 $productNames[] = $lesson['name'];
                 $lessonIds[] = $lesson['id'];
示例#15
0
 foreach ($items = $tree->getTree() as $item) {
     $items_opts[$item['category_id']] = str_repeat(str_repeat('&nbsp;', 4), $item['depth']) . $item['category'];
 }
 $s = $form->createElement('select', 'item_position', 'Position:', null, array('size' => '10', 'id' => 'item_position'));
 $s->loadArray($items_opts);
 $form->addElement($s);
 // Creates a radio buttons group
 $radio[] = $form->createElement('radio', null, null, 'at top', 'new child');
 if (count($items) > 0) {
     $radio[] = $form->createElement('radio', null, null, 'after this item', 'after child');
 }
 $form->addGroup($radio, 'insert_type', 'Insert as new sub item');
 $form->addElement('html', '</fieldset>');
 $form->addRule('category', 'Please enter a category', 'required');
 if ($form->validate()) {
     $c = ucwords($form->exportValue('category'));
     $ip = $form->exportValue('item_position');
     $it = $form->exportValue('insert_type');
     $form->freeze();
     $values = $form->process(array(&$this, 'formValues'), false);
     // format values.
     $values['category'] = ucwords($values['category']);
     $menuBar['add_category'] = '/ushop/products/action-new_category';
     $menuBar['back'] = $_SESSION['referer_link'];
     //check then enter the record.
     if (!$this->getResult('category_id', $ushop->db_name . 'product_categories', null, array('where' => "category='" . $values['category'] . "'"))) {
         $insert = array('category' => $values['category']);
         $category_id = $tree->insert($values['item_position'], $insert, $values['insert_type']);
         if ($category_id) {
             $params['TYPE'] = 'pass';
             $params['MESSAGE'] = '<h2>Category was successfully entered.</h2>';
示例#16
0
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$importForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
$importForm->setRequiredNote(_REQUIREDNOTE);
$importForm->accept($renderer);
$smarty->assign('T_IMPORT_FORM', $renderer->toArray());
// ******************************************* Export form *******************************************
$exportForm = new HTML_QuickForm("export_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=import_export&op=export&tab=export", "", null, true);
unset($import_export_types['anything']);
$exportForm->addElement('select', 'export_type', _DATATYPE, $import_export_types, 'class = "inputCheckbox"', array(0, 1));
$exportForm->addElement("select", "date_format", _DATEFORMAT, array("DD/MM/YYYY" => "DD/MM/YYYY", "MM/DD/YYYY" => "MM/DD/YYYY", "YYYY/MM/DD" => "YYYY/MM/DD"));
$exportForm->addElement('radio', 'export_separator', _KEEPEXISTINGUSERS, null, 'csvA');
$exportForm->addElement('radio', 'export_separator', _KEEPEXISTINGUSERS, null, 'csvB');
$exportForm->setDefaults(array('export_separator' => "csvA"));
$exportForm->addElement('submit', 'submit_export', _EXPORTDATA, 'class = "flatButton"');
if ($exportForm->isSubmitted() && $exportForm->validate()) {
    $exportForm->exportValue('export_separator') == 'csvA' ? $separator = ',' : ($separator = ';');
    try {
        $options = array("separator" => $separator, "date_format" => $exportForm->exportValue('date_format'));
        $exporter = EfrontExportFactory::factory("csv", $options);
        $file = $exporter->export($exportForm->exportValue('export_type'));
        header("content-type:" . $file['mime_type']);
        header('content-disposition: attachment; filename= "' . $file['name'] . '"');
        readfile($file['path']);
        exit;
    } catch (Exception $e) {
        $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
        $message = _ERRORRESTORINGFILE . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
        $message_type = 'failure';
    }
    //$smarty -> assign("T_EXPORTED_FILE", $file);
}
示例#17
0
     }
     if (in_array("[*]", $recipients)) {
         if ($_admin_) {
             $rec_users = eF_getTableDataFlat("users", "login", "active=1");
             // entry [*] means message for all system users
             $recipients = array_merge($recipients, array_values($users));
         } elseif ($_professor_) {
             $rec_users = $currentUser->getProfessorStudents();
             $recipients = array_merge($recipients, $rec_users);
         }
         unset($recipients[array_search('[*]', $recipients)]);
     }
     $recipients = array_combine(array_values($recipients), array_values($recipients));
 }
 //pr($recipients);
 switch ($form->exportValue('recipients')) {
     // case 'all_users':
     //     $result = eF_getTableDataFlat("users", "login");
     //     break;
     case 'active_users':
         $result = eF_getTableDataFlat("users", "login", "active=1");
         $values['body'] = $values['body'] . '<br />' . _THISPMISSENTALLUSERS;
         break;
     case 'specific_lesson':
         $result = eF_getTableDataFlat("users, users_to_lessons,lessons", "login", "users_to_lessons.archive=0 and lessons.archive=0 and users.active=1 AND users_to_lessons.active=1 AND users.login=users_to_lessons.users_LOGIN AND users_to_lessons.lessons_ID=lessons.id AND users_to_lessons.lessons_ID=" . $form->exportValue('lesson'));
         $lesson = new EfrontLesson($form->exportValue('lesson'));
         $values['body'] = $values['body'] . '<br />' . _THISPMISSENTLESSONUSERS . ' <a href=' . G_SERVERNAME . '##EFRONTINNERLINK##.php?lessons_ID=' . $form->exportValue('lesson') . '>' . $lesson->lesson['name'] . '</a>';
         break;
     case 'specific_course':
         $course = new EfrontCourse($form->exportValue('specific_course'));
         if ($_POST['specific_course_completed']) {
 /**
  * Handle upload form
  *
  * This function is used to perform all the actions necessary for when creating a directory
  * from within the file manager
  * <br/>Example:
  * <code>
  *   $createFolderForm   = new HTML_QuickForm("create_folder_form", "post", $url, "", null, true);
  *   if ($createFolderForm -> isSubmitted() && $createFolderForm -> validate()) {
  *       $this -> handleCreateDirectoryForm($createFolderForm);
  *   }
  *
  * </code>
  *
  * @param HTML_QuickForm $form The form used to create the directory
  * @return EfrontDirectory The created directory
  * @since 3.5.0
  * @access public
  */
 protected function handleCreateDirectoryForm(&$form)
 {
     $newDir = basename(EfrontDirectory::normalize($form->exportValue('create_directory')));
     if ($form->exportValue('current_directory')) {
         $curDir = EfrontDirectory::normalize($form->exportValue('current_directory'));
     } else {
         $curDir = $this->dir['path'];
     }
     if (strpos($curDir, $this->dir['path']) !== false) {
         $createdDirectory = EfrontDirectory::createDirectory($curDir . '/' . $newDir);
         $this->reset();
     }
     return $createdDirectory;
 }
示例#19
0
 public function getModule()
 {
     $currentLesson = $this->getCurrentLesson();
     $smarty = $this->getSmartyVar();
     $smarty->assign("T_LESSON_ID", $currentLesson->lesson['id']);
     if (isset($_GET['delete_link']) && eF_checkParameter($_GET['delete_link'], 'id')) {
         eF_deleteTableData("module_links", "id=" . $_GET['delete_link']);
         $this->setMessageVar(_LINKS_SUCCESFULLYDELETEDLINK, 'success');
         eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type={$message_type}");
     } else {
         if (isset($_GET['add_link']) || isset($_GET['edit_link']) && eF_checkParameter($_GET['edit_link'], 'id')) {
             $form = new HTML_QuickForm("link_entry_form", "POST", $_SERVER['REQUEST_URI'], "");
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             //Register this rule for checking user input with our function, eF_checkParameter
             $form->addElement('text', 'display', null);
             $form->addElement('text', 'link', null);
             $form->addElement('textarea', 'description', null);
             $form->addElement('submit', 'submit_link', _SUBMIT, 'class = "flatButton"');
             $element =& $form->getElement('display');
             $element->setSize(50);
             $element =& $form->getElement('link');
             $element->setSize(50);
             $element =& $form->getElement('description');
             $element->setCols(50);
             if (isset($_GET['edit_link'])) {
                 $link_entry = eF_getTableData("module_links", "*", "id=" . $_GET['edit_link']);
                 $form->setDefaults(array('display' => $link_entry[0]['display'], 'link' => $link_entry[0]['link'], 'description' => $link_entry[0]['description']));
             } else {
                 $form->setDefaults(array('link' => "http://"));
             }
             if ($form->isSubmitted() && $form->validate()) {
                 $fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'display' => $form->exportValue('display'), 'link' => $form->exportValue('link'), 'description' => $form->exportValue('description'));
                 if (isset($_GET['edit_link'])) {
                     if (eF_updateTableData("module_links", $fields, "id=" . $_GET['edit_link'])) {
                         $message = _LINKS_SUCCESFULLYUPDATEDLINKENTRY;
                         $message_type = 'success';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     } else {
                         $message = _LINKS_PROBLEMUPDATINGLINKENTRY;
                         $message_type = 'failure';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     }
                 } else {
                     if (eF_insertTableData("module_links", $fields)) {
                         $message = _LINKS_SUCCESFULLYINSERTEDLINKENTRY;
                         $message_type = 'success';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     } else {
                         $message = _LINKS_PROBLEMINSERTINGLINKENTRY;
                         $message_type = 'failure';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     }
                 }
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             $form->accept($renderer);
             $smarty->assign('T_LINKS_FORM', $renderer->toArray());
         } else {
             $links = eF_getTableDataFlat("module_links", "*", "lessons_ID = " . $_SESSION['s_lessons_ID']);
             $smarty->assign("T_LINKS", $links);
         }
     }
     return true;
 }
             $form->addElement('text', 'multiple_many[' . $key . ']', 'Insert Questions', 'class = "inputText inputText_QuestionChoice"');
             $form->addElement('checkbox', 'correct_multiple_many[' . $key . ']');
             $form->addElement('text', 'answers_explanation[' . $key . ']', null, 'class = "inputText inputText_QuestionChoice"' . (!$values['answers_explanation'][$key] ? 'style = "display:none"' : ''));
             $form->addRule('multiple_many[' . $key . ']', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
             $form->setDefaults(array('multiple_many[' . $key . ']' => $value));
             $form->setDefaults(array('correct_multiple_many[' . $key . ']' => $values['correct_multiple_many'][$key]));
             $form->setDefaults(array('answers_explanation[' . $key . ']' => $values['answers_explanation'][$key]));
         }
         $form->setDefaults(array('answers_logic' => $currentQuestion->settings['answers_logic']));
         $form->setDefaults(array('limit_answers' => $currentQuestion->settings['limit_answers']));
         if ($currentQuestion->settings['answers_or']) {
             //For compatibility reasons, this used to be 'answers_or'
             $form->setDefaults(array('answers_logic' => 'or'));
         }
         if ($form->validate()) {
             $question_values = array('type' => 'multiple_many', 'options' => serialize($values['multiple_many']), 'answer' => serialize($values['correct_multiple_many']), 'settings' => serialize(array('answers_logic' => $form->exportValue('answers_logic'), 'limit_answers' => $form->exportValue('limit_answers'))));
         }
     } else {
         //By default, only 2 options are displayed
         $form->addElement('text', 'multiple_many[0]', 'Insert Multiple Questions (many)', 'class = "inputText inputText_QuestionChoice"');
         $form->addElement('text', 'multiple_many[1]', null, 'class = "inputText inputText_QuestionChoice"');
         $form->addElement('text', 'answers_explanation[0]', null, 'class = "inputText inputText_QuestionChoice" style = "display:none"');
         $form->addElement('text', 'answers_explanation[1]', null, 'class = "inputText inputText_QuestionChoice" style = "display:none"');
         $form->addElement('checkbox', 'correct_multiple_many[0]');
         $form->addElement('checkbox', 'correct_multiple_many[1]');
         $form->addRule('multiple_many[1]', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
         $form->addRule('multiple_many[1]', _INVALIDFIELDDATA, 'checkParameter', 'text');
         $form->addRule('multiple_many[0]', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
     }
     break;
 case 'raw_text':
require_once 'include_elevforeningen.php';
require_once 'HTML/QuickForm.php';
//require_once 'Template/Template.php';
require_once 'IntrafacePublic/Contact/XMLRPC/Client.php';
session_start();
$credentials = array('private_key' => INTRAFACE_PRIVATE_KEY, 'session_id' => md5(session_id()));
$form = new HTML_QuickForm('login', 'get');
$form->addElement('text', 'handle', 'Kode');
$form->addElement('submit', null, 'Login');
$form->addRule('handle', 'Du skal indtaste en kode', 'required');
$form->applyFilter('__ALL__', 'trim');
$form->applyFilter('__ALL__', 'strip_tags');
$form->applyFilter('__ALL__', 'addslashes');
$form->setDefaults(array('handle' => @$_GET['handle']));
if ($form->validate()) {
    $auth = new IntrafacePublic_Contact_XMLRPC_Client($credentials);
    $contact_array = $auth->authenticateContact($form->exportValue('handle'));
    $_SESSION['contact_id'] = $contact_array['id'];
    if ($auth->isLoggedIn()) {
        header('Location: index.php');
        exit;
    }
}
$tpl = new Template(PATH_TEMPLATE_KUNDELOGIN);
$tpl->set('title', 'Login');
$tpl->set('content_main', '
    <h1>Login</h1>
    <p>Du kan logge ind ved at indtaste din kode.</p>
    ' . $form->toHTML());
echo $tpl->fetch('main.tpl.php');
示例#22
0
 $config_form->addRule('notifications_messages_per_time', _THEFIELD . ' "' . _MESSAGESTOSENDEVERYTIME . '" ' . _ISMANDATORY, 'required', null, 'client');
 $config_form->addElement('text', 'notifications_max_sent_messages', _MAXIMUMSENTMESSAGESSTORED, 'class = "inputText"');
 $config_form->addRule('notifications_max_sent_messages', _POSITIVENUMBERREQUIRED, 'callback', create_function('$a', 'return ($a > 0);'));
 //The score must be between 0 and 100
 $config_form->addRule('notifications_max_sent_messages', _THEFIELD . ' "' . _MAXIMUMSENTMESSAGESSTORED . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client');
 $config_form->addRule('notifications_max_sent_messages', _THEFIELD . ' "' . _MAXIMUMSENTMESSAGESSTORED . '" ' . _ISMANDATORY, 'required', null, 'client');
 $config_form->addElement('select', 'notifications_send_mode', _SENDMODE, array(_EMAIL, _PERSONALMESSAGE, _EMAILANDPM));
 $config_form->addRule('notifications_max_sent_messages', _THEFIELD . ' "' . _MAXIMUMSENTMESSAGESSTORED . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client');
 $config_form->addElement('submit', 'submit_variables', _SUBMIT, 'class = "flatButton"');
 $notification_configurations = array('notifications_use_cron', 'notifications_pageloads', 'notifications_maximum_inter_time', 'notifications_messages_per_time', 'notifications_max_sent_messages', 'notifications_send_mode');
 foreach ($notification_configurations as $conf_option) {
     $config_form->setDefaults(array($conf_option => $GLOBALS['configuration'][$conf_option]));
 }
 if ($config_form->isSubmitted()) {
     foreach ($notification_configurations as $conf_option) {
         EfrontConfiguration::setValue($conf_option, $config_form->exportValue($conf_option));
     }
     // Clear the stored sent messages according to the new limitations
     EfrontNotification::clearSentMessages();
     $message = _NOTIFICATIONCONFIGURATIONSUPDATEDSUCCESSFULLY;
     $message_type = 'success';
     eF_redirect("" . $_SESSION['s_type'] . ".php?ctg=digests&message=" . urlencode($message) . "&message_type=" . $message_type);
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
 //Create a smarty renderer
 $renderer->setRequiredTemplate('{$html}{if $required}
         &nbsp;<span class = "formRequired">*</span>
     {/if}');
 if (isset($currentUser->coreAccess['notifications']) && $currentUser->coreAccess['notifications'] != 'change') {
     $config_form->freeze();
 }
 /**
  * The main functionality
  *
  * (non-PHPdoc)
  * @see libraries/EfrontModule#getModule()
  */
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $directionsTree = new EfrontDirectionsTree();
     $directionsPaths = $directionsTree->toPathString();
     $smarty->assign("T_MODULE_OUTLOOK_INVITATION_DIRECTION_PATHS", $directionsPaths);
     $temp = eF_getTableData("module_outlook_invitation as m,courses as c", "m.*,c.name,c.directions_ID", "m.courses_ID=c.id");
     $events = array();
     foreach ($temp as $value) {
         $events[$value['courses_ID']] = $value;
     }
     if (isset($_GET['delete_event']) && eF_checkParameter($_GET['delete_event'], 'id') && in_array($_GET['delete_event'], array_keys($events))) {
         try {
             $event = $events[$_GET['delete_event']];
             $course = new EfrontCourse($event['courses_ID']);
             $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false));
             $recipients = array();
             foreach ($users as $value) {
                 $recipients[] = $value['email'];
             }
             $this->cancelInvitation($course->course['id'], $recipients);
             eF_deleteTableData("module_outlook_invitation", "courses_ID=" . $_GET['delete_event']);
         } catch (Exception $e) {
             header("HTTP/1.0 500 ");
             echo $e->getMessage() . ' (' . $e->getCode() . ')';
         }
         exit;
     }
     if ($_SESSION['s_type'] != 'administrator') {
         $userCourses = $currentUser->getUserCourses(array('archive' => 0, 'active' => true, 'return_objects' => false));
         if (G_VERSIONTYPE == 'enterprise') {
             if ($_SESSION['s_current_branch']) {
                 $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID='{$_SESSION['s_current_branch']}'");
             } else {
                 if ($currentUser->aspects['hcd']->isSupervisor()) {
                     $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID in (select branches_ID from module_hcd_employee_works_at_branch where users_login='******'login']}' and supervisor=1)");
                 }
             }
             $branchCourses = array();
             foreach ($result as $value) {
                 $branchCourses[$value['courses_ID']] = $value['courses_ID'];
             }
             foreach ($events as $key => $value) {
                 if (!isset($branchCourses[$key]) && !isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         } else {
             foreach ($events as $key => $value) {
                 if (!isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         }
     }
     if (!isset($_GET['course'])) {
         $dataSource = $events;
         $tableName = 'outlookInvitationsTable';
         isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE);
         if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) {
             $sort = $_GET['sort'];
             isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc');
         } else {
             $sort = 'login';
         }
         $dataSource = eF_multiSort($dataSource, $sort, $order);
         $smarty->assign("T_TABLE_SIZE", sizeof($dataSource));
         if (isset($_GET['filter'])) {
             $dataSource = eF_filterData($dataSource, $_GET['filter']);
         }
         if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) {
             isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0);
             $dataSource = array_slice($dataSource, $offset, $limit);
         }
         $smarty->assign("T_DATA_SOURCE", $dataSource);
     } else {
         $course = new EfrontCourse($_GET['course']);
         $form = new HTML_QuickForm("import_outlook_invitation_form", "post", $this->moduleBaseUrl . "&course={$course->course['id']}&add_event=1" . (isset($_GET['popup']) ? '&popup=1' : ''), "", null, true);
         $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
         //Register this rule for checking user input with our function, eF_checkParameter
         $form->addElement('text', 'email', _SENDER, 'class = "inputText"');
         $form->addElement('text', 'location', _LOCATION, 'class = "inputText"');
         $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText"');
         $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTestTextarea" style = "width:80%;height:6em;"');
         //$form -> addElement('checkbox', 'calendar', _MODULE_OUTLOOK_INVITATION_CREATE_CALENDAR);
         //$form -> addElement('static', 'static', _MODULE_OUTLOOK_INVITATION_INFO);
         $form->addElement('submit', 'submit_event_all', _MODULE_OUTLOOK_INVITATION_SENDALL, 'class=flatButton');
         $form->addElement('submit', 'submit_event_new', _MODULE_OUTLOOK_INVITATION_SENDNEW, 'class=flatButton');
         if (empty($events[$course->course['id']])) {
             //new invitation
             $currentEvent = null;
             $form->setDefaults(array('email' => $currentUser->user['email'], 'subject' => 'Invitation to attend training: ' . $course->course['name']));
         } else {
             //existing invitation
             $currentEvent = $events[$course->course['id']];
             $form->setDefaults(array('email' => $currentEvent['email'], 'description' => $currentEvent['description'], 'subject' => $currentEvent['subject'], 'location' => $currentEvent['location']));
         }
         if ($form->isSubmitted() && $form->validate()) {
             try {
                 $message = "";
                 // Set info to store into database
                 $permanent_info = array("courses_ID" => $course->course['id'], "email" => $form->exportValue('email') ? $form->exportValue('email') : $GLOBALS['configuration']['system_email'], "location" => $form->exportValue('location'), "subject" => $form->exportValue('subject'), "description" => $form->exportValue('description'));
                 if ($currentEvent) {
                     $permanent_info['sequence'] = $currentEvent['sequence'] + 1;
                     eF_updateTableData("module_outlook_invitation", $permanent_info, "courses_ID={$course->course['id']}");
                 } else {
                     eF_insertTableData("module_outlook_invitation", $permanent_info);
                 }
                 if ($form->exportValue('submit_event_all')) {
                     $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false));
                     $recipients = array();
                     foreach ($users as $value) {
                         $recipients[] = $value['email'];
                     }
                     $this->sendInvitation($course->course['id'], $recipients);
                 }
                 //					$smarty->assign('T_RELOAD', true);
                 if (isset($_GET['popup'])) {
                     $this->setMessageVar(_OPERATIONCOMPLETEDSUCCESSFULLY, 'success');
                 } else {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success");
                 }
             } catch (Exception $e) {
                 $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                 $this->setMessageVar($e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>', 'failure');
             }
         }
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $smarty->assign('T_MODULE_OUTLOOK_INVITATION_FORM', $form->toArray());
     }
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     return true;
 }
示例#24
0
 $form->addRule('score', _THEFIELD . ' "' . _SCORE . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client');
 //The score must be numeric
 $form->addRule('score', _RATEMUSTBEBETWEEN0100, 'callback', create_function('$a', 'return ($a >= 0 && $a <= 100);'));
 //The score must be between 0 and 100
 $form->addElement('textarea', 'comments', _COMMENTS, 'class = "inputContentTextarea simpleEditor" style = "width:100%;height:5em;"');
 //Comments on student's performance
 $userStats = $editedUser->getUserStatusInLessons($currentLesson);
 $userStats = $userStats[$currentLesson->lesson['id']]->lesson;
 $form->setDefaults(array("completed" => $userStats['completed'], "score" => $userStats['score'], "comments" => $userStats['comments'] ? $userStats['comments'] : ''));
 if (isset($currentUser->coreAccess['progress']) && $currentUser->coreAccess['progress'] != 'change') {
     $form->freeze();
 } else {
     $form->addElement('submit', 'submit_lesson_complete', _SUBMIT, 'class = "flatButton"');
     //The submit button
     if ($form->isSubmitted() && $form->validate()) {
         if ($form->exportValue('completed')) {
             $lessonUser = EfrontUserFactory::factory($editedUser->user['login'], false, 'student');
             $lessonUser->completeLesson($currentLesson->lesson['id'], $form->exportValue('score'), $form->exportValue('comments'));
         } else {
             eF_updateTableData("users_to_lessons", array('completed' => 0, 'score' => 0, 'to_timestamp' => null), "users_LOGIN = '******'login'] . "' and lessons_ID=" . $currentLesson->lesson['id']);
             //		        $cacheKey = "user_lesson_status:lesson:".$currentLesson -> lesson['id']."user:".$editedUser -> user['login'];
             //		        Cache::resetCache($cacheKey);
         }
         eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=progress&message=' . urlencode(_STUDENTSTATUSCHANGED) . '&message_type=success');
     }
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
 $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
 $form->setRequiredNote(_REQUIREDNOTE);
 $form->accept($renderer);
 $smarty->assign('T_COMPLETE_LESSON_FORM', $renderer->toArray());
示例#25
0
                                    if ($position = strpos($previous_url, "&message")) {
                                        $previous_url = substr($previous_url, 0, $position);
                                    }
                                    $form->setDefaults(array('previous_url' => $previous_url));
                                    $form->addElement('submit', 'submit_topic_details', _SUBMIT, 'class = "flatButton" tabindex="2"');
                                    if (isset($_GET['edit_topic'])) {
                                        $form->setDefaults(array('topic_description' => $topic[0]['title']));
                                    }
                                    $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
                                    $renderer->setRequiredTemplate('{$html}{if $required}
							&nbsp;<span class = "formRequired">*</span>
						{/if}');
                                    //LESSONTIMELINE DATA SUBMISSION
                                    if ($form->isSubmitted()) {
                                        if ($form->validate()) {
                                            $topic_content = array('title' => $form->exportValue('topic_description'), 'lessons_ID' => $currentLesson->lesson['id']);
                                            if (isset($_GET['add_topic'])) {
                                                eF_insertTableData("lessons_timeline_topics", $topic_content);
                                                $message = _SUCCESSFULLYCREATEDLESSONTIMELINETOPIC;
                                                $message_type = 'success';
                                            } elseif (isset($_GET['edit_topic'])) {
                                                eF_updateTableData("lessons_timeline_topics", $topic_content, "id = '" . $_GET['edit_topic'] . "'");
                                                $message = _LESSONTIMELINETOPICDATAUPDATED;
                                                $message_type = 'success';
                                            }
                                            // Return to previous url stored in a hidden - that way, after the insertion we can immediately return to where we were
                                            echo "<script>!/\\?/.test(parent.location) ? parent.location = '" . basename($form->exportValue('previous_url')) . "&message=" . urlencode($message) . "&message_type=" . $message_type . "' : parent.location = '" . basename($form->exportValue('previous_url')) . "&message=" . urlencode($message) . "&message_type=" . $message_type . "';</script>";
                                            //eF_redirect("".$form->exportValue('previous_url')."&message=". $message . "&message_type=" . $message_type . "&tab=skills");
                                            exit;
                                        }
                                    }
示例#26
0
 public function getModule()
 {
     // Get smarty variable
     $smarty = $this->getSmartyVar();
     //This could become a module function...
     global $load_editor;
     $load_editor = true;
     //$smarty -> assign("T_HEADER_EDITOR", $load_editor);
     $form = new HTML_QuickForm("billboard_entry_form", "post", $_SERVER['REQUEST_URI'], "", null, true);
     $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
     //Register this rule for checking user input with our function, eF_checkParameter
     $form->addElement('textarea', 'data', _BILLBOARDCONTENT, 'class = "inputContentTextarea mceEditor" style = "width:100%;height:300px;"');
     //The unit content itself
     $form->addElement('submit', 'submit_billboard', _SUBMIT, 'class = "flatButton"');
     $currentLesson = $this->getCurrentLesson();
     $billboard = eF_getTableData("module_billboard", "*", "lessons_ID=" . $currentLesson->lesson['id']);
     $form->setDefaults(array('data' => $billboard[0]['data']));
     if ($form->isSubmitted() && $form->validate()) {
         $fields = array('lessons_ID' => $currentLesson->lesson['id'], 'data' => $form->exportValue('data'));
         $currentUser = $this->getCurrentUser();
         // if ($billboard[0]['data'] != "") {
         if (!empty($billboard)) {
             if (eF_updateTableData("module_billboard", $fields, "lessons_ID=" . $currentLesson->lesson['id'])) {
                 eF_redirect("professor.php?ctg=control_panel&message=" . urlencode(_BILLBOARD_SUCCESFULLYUPDATEDBILLBOARDENTRY) . "&message_type=success");
             } else {
                 $this->setMessageVar(_BILLBOARD_PROBLEMUPDATINGBILLBOARDENTRY, 'failure');
             }
         } else {
             if (eF_insertTableData("module_billboard", $fields)) {
                 eF_redirect("professor.php?ctg=control_panel&message=" . urlencode(_BILLBOARD_SUCCESFULLYUPDATEDBILLBOARDENTRY) . "&message_type=success");
                 //eF_redirect("".$this -> moduleBaseUrl."&message="._BILLBOARD_SUCCESFULLYINSERTEDBILLBOARDENTRY."&message_type=success");
             } else {
                 $this->setMessageVar(_BILLBOARD_PROBLEMINSERTINGBILLBOARDENTRY, 'failure');
             }
         }
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     $form->accept($renderer);
     $smarty->assign('T_BILLBOARD_FORM', $renderer->toArray());
     $smarty->assign("T_BILLBOARD", $billboard[0]['data']);
     return true;
 }
示例#27
0
文件: index.php 项目: bqq1986/efront
 $form->addRule('email', _INVALIDFIELDDATA, 'checkParameter', 'email');
 $form->addElement('text', 'message_subject', _MESSAGESUBJECT, 'class = "inputText"');
 //$form -> addRule('message_subject', _INVALIDFIELDDATA, 'checkParameter', 'text');
 $form->addElement('textarea', 'message_body', _TEXT, 'class = "inputText" id = "contact"');
 $form->addElement('submit', 'submit_contact', _SUBMIT, 'class = "flatButton"');
 if ($_GET['limit_reached']) {
     $form->setDefaults(array('message_subject' => _IWANTTOSIGNUPBUTMAXIMUMUSERSLIMITREACHED, 'message_body' => _IWANTTOSIGNUPBUTMAXIMUMUSERSLIMITREACHEDBODY));
 }
 if ($_SESSION['s_login']) {
     $form->setDefaults(array('email' => $currentUser->user['email']));
 }
 if ($form->isSubmitted()) {
     $fields_insert = array('users_LOGIN' => 'visitor', 'timestamp' => time(), 'action' => 'forms', 'comments' => 'contact', 'session_ip' => eF_encodeIP(eF_getRemoteAddress()));
     eF_insertTableData("logs", $fields_insert);
     if ($form->validate()) {
         $to = $form->exportValue("email");
         $subject = $form->exportValue("message_subject");
         $body = $form->exportValue("message_body") . "\r\n\r\n(" . $subject . " [" . _FROM . ": " . $to . "])";
         if (eF_mail($to, $GLOBALS['configuration']['system_email'], $subject . " [" . _FROM . ": " . $to . "]", $body, false, true)) {
             $copied_body = _THANKYOUFORCONTACTINGUSBODY . "<br/><hr/><br/>" . $form->exportValue("message_body");
             eF_mail($GLOBALS['configuration']['system_email'], $to, _THANKYOUFORCONTACTINGUS, $copied_body, false, false);
             $message = _SENDSUCCESS;
             $message_type = 'success';
             eF_redirect(basename($_SERVER['PHP_SELF']) . '?message=' . urlencode($message) . '&message_type=' . $message_type);
         } else {
             $message = _SENDFAILURE;
             $message_type = 'failure';
         }
     }
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
示例#28
0
文件: rules.php 项目: bqq1986/efront
             $defaults = array('specific_unit' => $options[0]);
             break;
         case 'time_in_lesson':
             $defaults = array('time_in_lesson' => $options[0]);
             break;
             //case 'all_tests':        $defaults = array('all_tests'        => $options[0]); break;
             //case 'specific_test':    $defaults = array('specific_test'    => $options[0]); break;
         //case 'all_tests':        $defaults = array('all_tests'        => $options[0]); break;
         //case 'specific_test':    $defaults = array('specific_test'    => $options[0]); break;
         default:
             break;
     }
     $form->setDefaults($defaults);
 }
 if ($form->isSubmitted()) {
     if ($form->exportValue('condition_types') == 'percentage_units' && ($form->exportValue('percentage_units') < 1 || $form->exportValue('percentage_units') > 100)) {
         $message = _PERCENTAGEMUSTBEBETWEEN1100;
         $message_type = 'failure';
     } elseif ($form->validate()) {
         $fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'type' => $form->exportValue('condition_types'), 'relation' => $form->exportValue('relation'));
         switch ($form->exportValue('condition_types')) {
             case 'percentage_units':
                 $fields['options'] = serialize(array(0 => $form->exportValue('percentage_units')));
                 break;
             case 'specific_unit':
                 $fields['options'] = serialize(array(0 => $form->exportValue('specific_unit')));
                 break;
                 //case 'all_tests':        $fields['options'] = serialize(array(0 => $form -> exportValue('all_tests')));           break;
             //case 'all_tests':        $fields['options'] = serialize(array(0 => $form -> exportValue('all_tests')));           break;
             case 'specific_test':
                 $fields['options'] = serialize(array(0 => $form->exportValue('specific_test')));
示例#29
0
     $form->addElement('file', "scorm_file[{$i}]", null);
 }
 //$form -> addElement('file', 'scorm_file', _SCORMFILEINZIPFORMAT);
 $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
 $form->addElement('text', 'url_upload', _UPLOADFILEFROMURL, 'class = "inputText"');
 $form->addElement('select', 'embed_type', _EMBEDTYPE, array('iframe' => _INLINEIFRAME, 'popup' => _NEWWINDOWPOPUP), 'class = "inputSelect"');
 $form->addElement('text', 'popup_parameters', _POPUPPARAMETERS, 'class = "inputText" style = "width:600px"');
 $form->addElement('text', 'iframe_parameters', _IFRAMEPARAMETERS, 'class = "inputText" style = "width:600px"');
 $form->addElement('submit', 'submit_upload_scorm', _SUBMIT, 'class = "flatButton"');
 $form->setDefaults(array('popup_parameters' => 'width=800,height=600,scrollbars=no,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,top="+(parseInt(parseInt(screen.height)/2) - 300)+",left="+(parseInt(parseInt(screen.width)/2) - 400)+"', 'iframe_parameters' => 'height = "100%"  width = "100%" frameborder = "no"'));
 //@todo: url upload, if not exists, report a human-readable error!
 $timestamp = time();
 if ($form->isSubmitted() && $form->validate()) {
     $values = $form->exportValues();
     try {
         $urlUpload = $form->exportValue('url_upload');
         $scormFiles = array();
         if ($urlUpload != "") {
             FileSystemTree::checkFile($urlUpload);
             $urlArray = explode("/", $urlUpload);
             $urlFile = preg_replace("/\\?.*/", "", urldecode($urlArray[sizeof($urlArray) - 1]));
             if (!copy($urlUpload, $currentLesson->getDirectory() . $urlFile)) {
                 $error = error_get_last();
                 throw new Exception(_PROBLEMUPLOADINGFILE . ': ' . $error['message']);
             } else {
                 $scormFiles[] = new EfrontFile($currentLesson->getDirectory() . $urlFile);
             }
         } else {
             $filesystem = new FileSystemTree($currentLesson->getDirectory(), true);
             foreach ($_FILES['scorm_file']['name'] as $key => $value) {
                 if (!in_array($value, $scormFiles)) {
示例#30
0
文件: setup.php 项目: cretzu89/EPESI
 if (file_exists($fast_install_filename)) {
     include $fast_install_filename;
     if (isset($CONFIG) && is_array($CONFIG)) {
         $txt = __('Some fields were filled to make installation easier.');
         print '<div style="text-align:center"><p style="width: 250px;margin-left: auto;margin-right: auto;">' . $txt . '</p></div>';
         foreach ($CONFIG as $key => $value) {
             $form->setDefaults(array($key => $value));
             $form->getElement($key)->freeze();
         }
     }
 }
 $required_note_text = __('denotes required field');
 $form->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . $required_note_text . '</span>');
 $form->addElement('html', '<tr><td colspan=2><br /><b>' . __('Any existing tables will be dropped!') . '</b><br />' . __('The database will be populated with data.') . '<br />' . __('This operation can take several minutes.') . '</td></tr>');
 if ($form->validate()) {
     $engine = $form->exportValue('engine');
     $direction = $form->exportValue('direction');
     $other = array('direction' => $direction);
     $host = $form->exportValue('host');
     $port = $form->exportValue('port');
     $user = $form->exportValue('user');
     $pass = $form->exportValue('password');
     $dbname = $form->exportValue('db');
     $new_db = $form->exportValue('newdb');
     switch ($engine) {
         case 'postgres':
             if (!function_exists('pg_connect')) {
                 echo __('Please enable postgresql extension in php.ini.');
             } else {
                 $port_def = $port ? " port={$port}" : '';
                 $link = pg_connect("host={$host} user={$user} password={$pass} dbname=postgres" . $port_def);