static function form() { try { $anonymous = Variable::get('anonymous_setup'); } catch (NoSuchVariableException $e) { $anonymous = true; } if (!Base_AclCommon::is_user() && Base_User_LoginCommon::is_banned()) { return self::t('You have exceeded the number of allowed login attempts.'); } require_once 'modules/Libs/QuickForm/requires.php'; if (!Base_AclCommon::is_user() && !$anonymous) { Base_User_LoginCommon::autologin(); } if (!Base_AclCommon::is_user() && !$anonymous) { $get = count($_GET) ? '?' . http_build_query($_GET) : ''; $form = new HTML_QuickForm('loginform', 'post', $_SERVER['PHP_SELF'] . $get); $form->setRequiredNote('<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;">' . self::t('denotes required field') . '</span>'); $form->addElement('text', 'username', self::t('Username')); $form->addRule('username', 'Field required', 'required'); $form->addElement('password', 'password', self::t('Password')); $form->addRule('password', 'Field required', 'required'); // register and add a rule to check if user is banned $form->registerRule('check_user_banned', 'callback', 'rule_login_banned', 'Base_User_LoginCommon'); $form->addRule('username', self::t('You have exceeded the number of allowed login attempts.'), 'check_user_banned'); // register and add a rule to check if user and password exists $form->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon'); $form->addRule(array('username', 'password'), self::t('Login or password incorrect'), 'check_login', $form); $form->addElement('submit', null, self::t('Login')); if ($form->validate()) { $user = $form->exportValue('username'); Base_AclCommon::set_user(Base_UserCommon::get_user_id($user), true); // redirect below is used to better browser refresh behavior. header('Location: ' . $_SERVER['REQUEST_URI']); } else { return "<center>" . $form->toHtml() . "</center>"; } } }
public function getModule() { $currentUser = $this->getCurrentUser(); // Get smarty global variable $smarty = $this->getSmartyVar(); if (isset($_GET['postAjaxRequest']) && isset($_GET['id'])) { $currentLesson = $this->getCurrentLesson(); $youtube = eF_getTableData("module_youtube", "*", "lessons_ID = '" . $currentLesson->lesson['id'] . "'"); // Find the video with the requested id foreach ($youtube as $id => $video) { if ($video['id'] == $_GET['id']) { $idfound = $id; $videolink = $video['link']; break; } } // Find the previous and the next video if (isset($youtube[$idfound - 1])) { $prev = $youtube[$idfound - 1]['id']; $prev_tag = $youtube[$idfound - 1]['title'] . ": " . $youtube[$idfound - 1]['description']; } if (isset($youtube[$idfound + 1])) { $next = $youtube[$idfound + 1]['id']; $next_tag = $youtube[$idfound + 1]['title'] . ": " . $youtube[$idfound + 1]['description']; } echo '<table id="youtube_player"><tr><td colspan=\\"2\\"><object><param name="movie" value="http://www.youtube.com/v/' . $videolink . '"></param>'; echo '<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $videolink . '" type="application/x-shockwave-flash" allowfullscreen="true" width="400" height="323"></embed></object></td></tr><tr><td width="50%" align="left">'; if ($prev) { echo '<a href = "javascript:void(0);" alt="' . $prev_tag . '" title="' . $prev_tag . '" onClick="requestVideo(\'' . $prev . '\')">' . _YOUTUBE_PREVIOUS . '</a>'; } echo '</td><td width="50%" align="right">'; if ($next) { echo '<a href = "javascript:void(0);" alt="' . $next_tag . '" title="' . $next_tag . '" onClick="requestVideo(\'' . $next . '\')">' . _YOUTUBE_NEXT . '</a>'; } echo '</td></tr></table>'; exit; } if (isset($_GET['delete_youtube']) && eF_checkParameter($_GET['delete_youtube'], 'id')) { eF_deleteTableData("module_youtube", "id=" . $_GET['delete_youtube']); //eF_deleteTableData("module_youtube_users_to_meeting", "meeting_ID=".$_GET['delete_youtube']); eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_YOUTUBE_SUCCESFULLYDELETEDYOUTUBEENTRY) . "&message_type=success"); } else { if (isset($_GET['add_youtube']) || isset($_GET['edit_youtube']) && eF_checkParameter($_GET['edit_youtube'], 'id')) { $form = new HTML_QuickForm("youtube_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('text', 'title', null, 'class = "inputText"'); $form->addRule('title', _YOUTUBETHEFIELDNAMEISMANDATORY, 'required', null, 'client'); $form->addElement('text', 'link', null, 'class = "inputText"'); $form->addRule('link', _YOUTUBETHEFIELDLINKSISMANDATORY, 'required', null, 'client'); $form->addElement('textarea', 'description', null); $form->addElement('submit', 'submit_youtube', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_youtube'])) { $youtube_entry = eF_getTableData("module_youtube", "*", "id=" . $_GET['edit_youtube']); $timestamp_info = getdate($youtube_entry[0]['timestamp']); $form->setDefaults(array('title' => $youtube_entry[0]['title'], 'lessons_ID' => $youtube_entry[0]['lessons_ID'], 'link' => "http://www.youtube.com/watch?v=" . $youtube_entry[0]['link'], 'description' => $youtube_entry[0]['description'])); } if ($form->isSubmitted() && $form->validate()) { $pos = strpos($form->exportValue('link'), "watch?v="); if ($pos) { $link = substr($form->exportValue('link'), $pos + 8); //after the watch?v= $pos_end = strpos($link, "&"); if ($pos_end) { $link = substr($link, 0, $pos_end); } $smarty = $this->getSmartyVar(); $currentLesson = $this->getCurrentLesson(); $fields = array('title' => $form->exportValue('title'), 'lessons_ID' => $currentLesson->lesson['id'], 'link' => $link, 'description' => $form->exportValue('description')); if (isset($_GET['edit_youtube'])) { if (eF_updateTableData("module_youtube", $fields, "id=" . $_GET['edit_youtube'])) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_YOUTUBE_SUCCESFULLYUPDATEDYOUTUBEENTRY) . "&message_type=success"); } else { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_YOUTUBE_PROBLEMUPDATINGYOUTUBEENTRY) . "&message_type=failure"); } } else { // The key will be the current time when the event was set concatenated with the initial timestamp for the meeting // If the latter changes after an event editing the key will not be changed if ($result = eF_insertTableData("module_youtube", $fields)) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_YOUTUBE_SUCCESFULLYINSERTEDYOUTUBEENTRY) . "&message_type=success"); } else { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_YOUTUBE_PROBLEMINSERTINGYOUTUBEENTRY) . "&message_type=failure"); } } } else { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_YOUTUBE_PROBLEMINSERTINGYOUTUBEENTRY) . "&message_type=failure"); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_YOUTUBE_FORM', $renderer->toArray()); } else { $currentUser = $this->getCurrentUser(); $currentLesson = $this->getCurrentLesson(); $youtube = eF_getTableData("module_youtube", "*", "lessons_ID = '" . $currentLesson->lesson['id'] . "'"); $smarty->assign("T_USERLESSONTYPE", $currentUser->getRole($currentLesson)); $smarty->assign("T_YOUTUBE", $youtube); $smarty->assign("T_USERINFO", $currentUser->user); } } return true; }
/** * limitsForm * * Create limits form * * @access protected * @return HTML_QuickForm object */ protected function limitsForm() { $defaults = $this->user->getLimits($this->domain); // To MB if ($defaults['default_quota'] > 0) { $defaults['default_quota'] = $defaults['default_quota'] / 1024 / 1024; } $url = './?module=Main&class=Limits&event=modifyLimitsNow&domain='; $url .= $this->domain; $form = new HTML_QuickForm('limitsForm', 'post', $url); $form->setDefaults($defaults); $form->addElement('text', 'max_aliases', _('Maximum Aliases (-1 for unlimited)'), array('size' => 4)); $form->addElement('text', 'max_forwards', _('Maximum Forwards (-1 for unlimited)'), array('size' => 4)); $form->addElement('text', 'max_autoresponders', _('Maximum Mail Robots (-1 for unlimited)'), array('size' => 4)); $form->addElement('text', 'max_mailinglists', _('Maximum EZMLM-IDX Mailing Lists (-1 for unlimited)'), array('size' => 4)); $form->addElement('text', 'default_quota', _('Default Quota in MB (0 for unlimited)'), array('size' => 4)); $form->addElement('text', 'default_maxmsgcount', _('Default Message Count Limit (0 for unlimited)'), array('size' => 4)); $form->addElement('checkbox', 'disable_pop', _('Disable POP')); $form->addElement('checkbox', 'disable_imap', _('Disable IMAP')); $form->addElement('checkbox', 'disable_dialup', _('Disable Dial-Up')); $form->addElement('checkbox', 'disable_password_changing', _('Disable Password Changing')); $form->addElement('checkbox', 'disable_webmail', _('Disable Webmail (SqWebmail)')); $form->addElement('checkbox', 'disable_external_relay', _('Disable Relaying')); $form->addElement('checkbox', 'disable_smtp', _('Disable SMTP-AUTH')); $form->addElement('submit', 'submit', _('Modify')); $form->registerRule('minusOne', 'regex', '/^(-1|[0-9]+)$/'); $form->registerRule('zero', 'regex', '/^(0|[1-9][0-9]+)$/'); $form->addRule('max_aliases', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client'); $form->addRule('max_forwards', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client'); $form->addRule('max_autoresponders', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client'); $form->addRule('max_mailinglists', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client'); $form->addRule('default_quota', _('Error: only integers of 0 and greater allowed here'), 'zero', null, 'client'); $form->addRule('default_maxmsgcount', _('Error: only integers of 0 and greater allowed here'), 'zero', null, 'client'); $form->applyFilter('__ALL__', 'trim'); return $form; }
private function doChangeLogin() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $form = new HTML_QuickForm("change_login_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&do=user", "", null, true); $form->addElement('static', 'sidenote', '<img id = "module_administrator_tools_busy" src = "images/16x16/clock.png" style="display:none;" alt = "' . _LOADING . '" title = "' . _LOADING . '"/>'); $form->addElement('text', 'selection_user', _MODULE_ADMINISTRATOR_TOOLS_SELECTUSERTOCHANGELOGINFOR, 'id = "module_administrator_tools_autocomplete_users" class = "autoCompleteTextBox" style = "width:400px"'); $form->addElement('static', 'autocomplete_note', _STARTTYPINGFORRELEVENTMATCHES); $form->addElement('text', 'new_login', _MODULE_ADMINISTRATOR_TOOLS_NEWLOGIN, 'class = "inputText"'); $form->addElement('hidden', 'users_LOGIN', '', 'id="module_administrator_tools_users_LOGIN"'); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addRule('selection_user', _THEFIELD . ' "' . _USER . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('users_LOGIN', _MODULE_ADMINISTRATOR_TOOLS_THISUSERWASNOTFOUND, 'required', null, 'client'); $form->addRule('new_login', _THEFIELD . ' ' . _MODULE_ADMINISTRATOR_TOOLS_NEWLOGIN . ' ' . _HASINVALIDCHARACTERS . '. ' . _ONLYALLOWEDCHARACTERSLOGIN, 'checkParameter', 'login'); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { try { $values = $form->exportValues(); if (!$values['new_login']) { throw new Exception(_MODULE_ADMINISTRATOR_TOOLS_YOUMUSTDEFINEUSER); } $user = EfrontUserFactory::factory($values['users_LOGIN']); try { $existingUser = true; if (strcasecmp($values['new_login'], $values['users_LOGIN']) === 0) { //Allow changing same user, for case conversions etc $existingUser = false; } else { $newUser = EfrontUserFactory::factory($values['new_login']); } } catch (Exception $e) { $existingUser = false; } if ($existingUser) { throw new Exception(_MODULE_ADMINISTRATOR_TOOLS_USERALREADYEXISTS); } $existingTables = $GLOBALS['db']->GetCol("show tables"); $views = $GLOBALS['db']->GetCol("show tables like '%_view'"); $errors = array(); foreach ($existingTables as $table) { try { if (!in_array($table, $views)) { $this->changeLogin($table, $values['users_LOGIN'], $values['new_login']); } } catch (Exception $e) { $errors[] = $e->getMessage(); } } EfrontCache::getInstance()->deleteCache('usernames'); if (empty($errors)) { $message = _OPERATIONCOMPLETEDSUCCESSFULLY; $message_type = 'success'; } else { $message = _MODULE_ADMINISTRATOR_TOOLS_OPERATIONCOMPLETEDSUCCESSFULLYBUTHEFOLLOWINGTABLESCOULDNOTBEUPDATED . ': <br>' . implode("<br>", $errors); $message_type = 'failure'; } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } $this->setMessageVar($message, $message_type); } $smarty->assign("T_TOOLS_FORM", $form->toArray()); try { if (isset($_GET['ajax']) && isset($_GET['user']) && eF_checkParameter($_GET['user'], 'login')) { $user = EfrontUserFactory::factory($_GET['user']); echo json_encode(array('status' => 1, 'supervisors' => $supervisors, 'supervisor_names' => $supervisorNames)); exit; } elseif (isset($_GET['ajax']) && $_GET['ajax'] == 'fix_case') { $existingTables = $GLOBALS['db']->GetCol("show tables"); $views = $GLOBALS['db']->GetCol("show tables like '%_view'"); $users = eF_getTableDataFlat("users", "login"); $errors = array(); foreach ($existingTables as $table) { $t = microtime(true); try { if (!in_array($table, $views)) { $fields = $GLOBALS['db']->GetCol("describe {$table}"); foreach ($users['login'] as $key => $login) { foreach ($fields as $value) { if (stripos($value, 'login') !== false) { eF_executeNew("update {$table} set {$value}='{$login}' where {$value}='{$login}'"); } } if ($table == 'f_personal_messages') { eF_updateTableData($table, array("sender" => $login), "sender = '" . $login . "'"); } if ($table == 'notifications' || $table == 'sent_notifications') { eF_updateTableData($table, array("recipient" => $login), "recipient = '" . $login . "'"); } if ($table == 'surveys' || $table == 'module_hcd_events') { eF_updateTableData($table, array("author" => $login), "author = '" . $login . "'"); } } } } catch (Exception $e) { $errors[] = $e->getMessage(); } //pr("Time for $table: ".(microtime(true)-$t));flush();ob_flush(); } EfrontCache::getInstance()->deleteCache('usernames'); echo json_encode(array('status' => 1)); exit; } } catch (Exception $e) { handleAjaxExceptions($e); } }
/** * 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() . ') <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; }
#cpp#endif } #cpp#endif $select = $form->addElement('select', 'user_type', _USERTYPE, $roles); $languages = EfrontSystem::getLanguages(true, true); if ($GLOBALS['configuration']['onelanguage']) { $languages = array($GLOBALS['configuration']['default_language'] => $languages[$GLOBALS['configuration']['default_language']]); } $form->addElement('select', 'languages_NAME', _LANGUAGE, $languages); $form->addElement("select", "timezone", _TIMEZONE, eF_getTimezones(), 'class = "inputText" style="width:20em"'); if ($GLOBALS['configuration']['social_modules_activated'] > 0) { $load_editor = true; $form->addElement('textarea', 'short_description', _SHORTDESCRIPTIONCV, 'class = "inputContentTextarea simpleEditor" style = "width:100%;height:14em;"'); } $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 . ' "' . $form->exportValue('login') . '" ' . _ALREADYEXISTS, 'checkNotExist', 'login'); $form->addRule('login', _THEFIELD . ' ' . _LOGIN . ' ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('password_', _THEFIELD . ' ' . _PASSWORD . ' ' . _ISMANDATORY, 'required', null, 'client');
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; }
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); $dir = $this->moduleBaseDir . 'assets/'; if (!is_dir($dir)) { mkdir($dir, 0755); } if ($_SESSION['s_type'] == 'administrator') { try { $form = new HTML_QuickForm("upload_files_form", "post", $this->moduleBaseUrl . '&tab=upload', "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('file', 'file', _UPLOADFILE); if (G_VERSIONTYPE == 'enterprise') { $tree = new EfrontBranchesTree(); $pathString = $tree->toPathString(); //$result = eF_getTableData("module_hcd_branch", "*", "url is not null and url !=''"); $handle = '<img id = "busy" src = "images/16x16/clock.png" style = "display:none;" alt = "{$smarty.const._LOADING}" title = "{$smarty.const._LOADING}"/><div id = "autocomplete_leaflet_branches" class = "autocomplete"></div> '; $form->addElement('static', 'sidenote', $handle); $form->addElement('text', 'leaflet_branch_autoselect', _BRANCH, 'class = "autoCompleteTextBox" id = "autocomplete"'); $form->addElement('hidden', 'leaflet_branch', '', 'id = "leaflet_branch_value"'); } $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024); $form->addElement('submit', 'submit_upload', _UPLOAD, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); try { if ($values['leaflet_branch'] && eF_checkParameter($values['leaflet_branch'], 'id')) { $branch = new EfrontBranch($values['leaflet_branch']); if (!$branch->branch['url']) { throw new Exception("You must assign a url to the selected branch to upload files for it"); } $dir = $this->moduleBaseDir . 'assets/' . $branch->branch['url']; mkdir($dir, 0755); } $filesystem = new FileSystemTree($dir); $file = $filesystem->uploadFile("file", $dir); } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = failure; $this->setMessageVar($message, $message_type); } } $smarty->assign('T_UPLOAD_FORM', $form->toArray()); $url = $this->moduleBaseUrl; $basedir = $dir; $options = array('zip' => false, 'upload' => false, 'create_folder' => false, 'folders' => true); /**The file manager*/ include "file_manager.php"; } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; $this->setMessageVar($message, $message_type); } } else { if (defined('G_BRANCH_URL') && G_BRANCH_URL) { try { $assets_path = $root_path = $this->moduleBaseDir . 'assets/' . G_BRANCH_URL; } catch (Exception $e) { //do nothing here if the directory doesn't exist } } else { $assets_path = $root_path = $this->moduleBaseDir . 'assets/'; } $files = array(); if (!empty($_GET['folder'])) { $folder = urldecode($_GET['folder']); if (is_dir($assets_path . $folder)) { $folder = new EfrontDirectory($assets_path . $folder); if (strpos(realpath($folder['path']), $root_path) === false) { throw new Exception("Invalid folder"); } $parent_folder = dirname($folder['path']); $url = urlencode(str_replace($root_path, '', $folder['path'])); $assets_path = $folder['path']; $parent_url = $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', dirname($folder['path']) . '/')); $parent_url or $parent_url = $this->moduleBaseUrl . 'assets/'; $files[] = array('text' => '.. (Up one level)', 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $parent_url); } } //pr($url);pr($parent_url); // $filesystem = new FileSystemTree($assets_path, true); foreach ($filesystem->tree as $key => $value) { if ($value instanceof EfrontDirectory) { $files[] = array('text' => basename($key), 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', $value['path'] . '/'))); } } foreach ($filesystem->tree as $key => $value) { if ($value instanceof EfrontFile) { if (is_file($this->moduleBaseDir . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png')) { $icon = $this->moduleBaseLink . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png'; } else { $icon = $this->moduleBaseLink . 'ico/unknown.png'; } $files[] = array('text' => basename($key), 'image' => $icon, 'href' => $this->moduleBaseLink . str_replace($this->moduleBaseDir, '', $key)); } } $smarty->assign("T_FILES", $files); } return true; }
$imageInfo_getExtraInfo = $cache->createProxy('ImageCache2_ImageInfo::getExtraInfo'); $imageInfo_getExifData = $cache->createProxy('ImageCache2_ImageInfo::getExifData'); $editForm_imgManager = $cache->createProxy('ImageCache2_EditForm::imgManager'); $use_cache = true; } else { $use_cache = false; } // }}} // {{{ prepare (Form & Template) // ページ遷移用フォームを設定 // ページ遷移はGETで行うが、画像情報の更新はPOSTで行うのでどちらでも受け入れるようにする // (レンダリング前に $qf->updateAttributes(array('method' => 'get')); とする) $_attribures = array('accept-charset' => 'UTF-8,Shift_JIS'); $_method = $_SERVER['REQUEST_METHOD'] == 'GET' ? 'get' : 'post'; $qf = new HTML_QuickForm('go', $_method, $_SERVER['SCRIPT_NAME'], '_self', $_attribures); $qf->registerRule('numberInRange', null, 'ImageCache2_QuickForm_Rule_NumberInRange'); $qf->registerRule('inArray', null, 'ImageCache2_QuickForm_Rule_InArray'); $qf->registerRule('arrayKeyExists', null, 'ImageCache2_QuickForm_ArrayKeyExists'); $qf->setDefaults($_defaults); $qf->setConstants($_constants); $qfe = array(); // フォーム要素の定義 // ページ移動のためのsubmit要素 $qfe['start'] = $qf->addElement('button', 'start'); $qfe['prev'] = $qf->addElement('button', 'prev'); $qfe['next'] = $qf->addElement('button', 'next'); $qfe['end'] = $qf->addElement('button', 'end'); $qfe['jump'] = $qf->addElement('button', 'jump'); // 表示方法などを指定するinput要素 $qfe['page'] = $qf->addElement('text', 'page', 'ページ番号を指定', array('size' => 3)); $qfe['cols'] = $qf->addElement('text', 'cols', '横', array('size' => 3, 'maxsize' => 2));
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(); }
public function getModule() { $smarty = $this->getSmartyVar(); // Always show the preview of the data if ($_POST['preview'] || $_POST['submit']) { if ($_POST['questions_format'] == "gift") { $questions = $this->scanGIFT($_POST['imported_data']); } else { $questions = $this->scanAIKEN(str_replace('\\"', '"', str_replace("\\'", "'", $_POST['imported_data']))); } if (sizeof($questions)) { $smarty->assign("T_PREVIEW_DIV", $this->createPreviewHTML($questions)); } } // Submit the data the data if ($_POST['submit']) { if ($_POST['select_unit'] == -1 || $_POST['select_unit'] == -2) { $content_ID = 0; } else { $content_ID = $_POST['select_unit']; } $currentLesson = $this->getCurrentLesson(); $lessons_ID = $currentLesson->lesson['id']; $count = 0; foreach ($questions as $key => $question) { if ($question['type'] != "same" && $question['type'] != "error" && $question['type'] != "no_answer_error") { $question['content_ID'] = $content_ID; $question['lessons_ID'] = $lessons_ID; $question['difficulty'] = "medium"; if (sizeof($question['options'])) { $question['options'] = serialize($question['options']); //$question['options'] = str_replace("'", "'", $question['options']); //$question['options'] = str_replace("\r", "", $question['options']); } if (sizeof($question['answer'])) { // Different accounting for answers of multiple many type if ($question['type'] == "multiple_many") { $answers = array(); foreach ($question['answer'] as $answer) { $answers[$answer] = "1"; } $question['answer'] = $answers; } $question['answer'] = serialize($question['answer']); //$question['answer'] = str_replace("'", "'", $question['answer']); //$question['answer'] = str_replace("\r", "", $question['answer']); } //$question['text'] = str_replace("'", "'", $question['text']); if (isset($question['explanation'])) { //$question['explanation'] = str_replace("'", "'", $question['explanation']); //$question['explanation'] = str_replace("\r", "", $question['explanation']); } if (Question::createQuestion($question)) { $count++; } } } if ($count) { $this->setMessageVar($count . " " . _GIFTAIKEN_QUESTIONSIMPORTEDSUCCESSFULLY, "success"); } else { $this->setMessageVar(_GIFTAIKEN_NOQUESTIONCOULDBEIMPORTED, "failure"); } } $pos = strpos($_SERVER['REQUEST_URI'], "&message"); if ($pos) { $postUrl = substr($_SERVER['REQUEST_URI'], 0, $pos); } else { $postUrl = $_SERVER['REQUEST_URI']; } $importForm = new HTML_QuickForm("import_users_form", "post", $postUrl, "", null, true); $importForm->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $importForm->addElement('radio', 'questions_format', _GIFTAIKEN_GIFT, null, 'gift', 'id="gift_selection"'); $importForm->addElement('radio', 'questions_format', _GIFTAIKEN_AIKEN, null, 'aiken', 'id="aiken_selection"'); $currentLesson = $this->getCurrentLesson(); $currentContent = new EfrontContentTree($currentLesson->lesson['id']); $smarty->assign("T_UNITS", $currentContent->toHTMLSelectOptions()); $importForm->addElement('textarea', 'imported_data', _GIFTAIKEN_QUESTIONDATATOIMPORT, 'class = "inputProjectTextarea" id="imported_data"'); $importForm->addElement('submit', 'preview', _PREVIEW, 'class=flatButton onclick="$(\'import_users_form\').action += \'&preview=1\'"'); $importForm->addElement('submit', 'submit', _SUBMIT, 'class=flatButton'); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $importForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $importForm->setRequiredNote(_REQUIREDNOTE); $importForm->accept($renderer); $smarty->assign('T_GIFTAIKENQUESTIONS_FORM', $renderer->toArray()); return true; }
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; }
public function getModule() { $smarty = $this->getSmartyVar(); $currentLesson = $this->getCurrentLesson(); $currentUser = $this->getCurrentUser(); try { $currentContent = new EfrontContentTree($_SESSION['s_lessons_ID']); //Initialize content } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = _ERRORLOADINGCONTENT . ": " . $_SESSION['s_lessons_ID'] . ": " . $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; } //pr($currentUser);exit; $roles = EfrontUser::getRoles(); //pr($roles); if ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "professor") { if (isset($_GET['view_list']) && eF_checkParameter($_GET['view_list'], 'id')) { $list = $currentContent->seekNode($_GET['view_list']); $questions = $list->getQuestions(true); $crosslists = array(); $possibleCrosslistsIds = array(); foreach ($questions as $key => $value) { if ($value->question['type'] == 'empty_spaces') { $crosslists[] = $value; $possibleCrosslistsIds[] = $value->question['id']; } } $questions = $crosslists; //pr($questions); foreach ($questions as $qid => $question) { $questions[$qid]->question['text'] = str_replace('#', '_', strip_tags($question->question['text'])); //If we ommit this line, then the questions list is html formatted, images are displayed etc, which is *not* the intended behaviour //$questions[$qid]->question['answer'] = unserialize($question->question['answer']); } $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']); $resCrosslists = unserialize($res[0]['crosslists']); $smarty->assign("T_CROSSWORD_LIST_WORDS", $resCrosslists); $post_target = $this->moduleBaseUrl . '&view_list=' . $_GET['view_list'] . "&tab=options"; //Create form elements $form = new HTML_QuickForm("list_options", "post", $post_target, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addElement('advcheckbox', 'active', _CROSSWORD_ACTIVE, null, 'class = "inputCheckbox"', array(0, 1)); $form->addElement("text", "max_word", _LOW, 'size = "5"'); $form->addRule('max_word', _INVALIDFIELDDATA . ":" . _LOW, 'checkParameter', 'id'); $form->addElement('advcheckbox', 'reveal_answer', _CROSSWORD_SHOWANSWERFIRST, null, 'class = "inputCheckbox"', array(0, 1)); $form->addElement('advcheckbox', 'save_pdf', _CROSSWORD_SAVEPDF, null, 'class = "inputCheckbox"', array(0, 1)); $form->addElement('submit', 'submit_options', _SAVECHANGES, 'onclick ="return optionSubmit();" class = "flatButton"'); //The submit content button $options = unserialize($res[0]['options']); $form->setDefaults(array('active' => $options['active'], 'reveal_answer' => $options['reveal_answer'], 'save_pdf' => $options['save_pdf'], 'max_word' => $options['max_word'])); if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); unset($values['submit_options']); $options = serialize($values); if (sizeof($res) != 0) { $ok = eF_updateTableData("module_crossword_words", array('options' => $options), "content_ID=" . $_GET['view_list']); } else { $fields = array('content_ID' => $_GET['view_list'], 'options' => $options); $ok = eF_insertTableData("module_crossword_words", $fields); } if ($ok !== false) { $message = _CROSSWORD_SUCCESSFULLY; $message_type = 'success'; } else { $message = _CROSSWORD_PROBLEMOCCURED; $message_type = 'failure'; } eF_redirect("" . $this->moduleBaseUrl . "&view_list=" . $_GET['view_list'] . "&tab=options&message=" . urlencode($message) . "&message_type=" . $message_type); } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_CROSSWORD_OPTIONS', $renderer->toArray()); //Assign the form to the template if (isset($_GET['postAjaxRequest'])) { try { $result = eF_getTableData("module_crossword_words", "crosslists", "content_ID=" . $_GET['view_list']); //pr($result);exit; $crosslistsArray = unserialize($result[0]['crosslists']); if (isset($_GET['id']) && eF_checkParameter($_GET['id'], 'id')) { if (!in_array($_GET['id'], array_values($crosslistsArray))) { $crosslistsArray[] = $_GET['id']; $crosslists = serialize($crosslistsArray); if (sizeof($result) != 0) { $fields = array('crosslists' => $crosslists); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } else { $fields = array('content_ID' => $_GET['view_list'], 'crosslists' => $crosslists); eF_insertTableData("module_crossword_words", $fields); } } elseif (in_array($_GET['id'], array_values($crosslistsArray))) { unset($crosslistsArray[array_search($_GET['id'], $crosslistsArray)]); if (!empty($crosslistsArray)) { $crosslists = serialize($crosslistsArray); $fields = array('crosslists' => $crosslists); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } else { eF_deleteTableData("module_crossword_words", "content_ID=" . $_GET['view_list']); } } } else { if (isset($_GET['addAll'])) { $crosslists = serialize($possibleCrosslistsIds); if (sizeof($result) != 0) { $fields = array('crosslists' => $crosslists); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } else { $fields = array('content_ID' => $_GET['view_list'], 'crosslists' => $crosslists); eF_insertTableData("module_crossword_words", $fields); } } else { if (isset($_GET['removeAll'])) { $fields = array('crosslists' => ""); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } } } } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } exit; } $smarty->assign("T_CROSSWORD_CROSSLISTS", $crosslists); $smarty->assign("T_CROSSWORD_CROSSLISTS_SIZE", sizeof($crosslists)); } else { $listsArray = array(); $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST))); foreach ($iterator as $key => $value) { $questions = $value->getQuestions(true); $crosslists = array(); foreach ($questions as $key2 => $value2) { if ($value2->question['type'] == 'empty_spaces') { $crosslists[] = $value2; } } if (sizeof($crosslists) > 0) { $listsArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name'], 'questions' => sizeof($crosslists)); } } if (!empty($listsArray)) { $str = implode(",", array_keys($listsArray)); $lists = eF_getTableDataFlat("module_crossword_words", "*", "content_ID IN (" . $str . ")"); $listsTemp = array_combine(array_values($lists['content_ID']), array_values($lists['options'])); $listsTemp2 = array_combine(array_values($lists['content_ID']), array_values($lists['crosslists'])); foreach ($listsArray as $key => $value) { $listsArray[$value['id']]['options'] = unserialize($listsTemp[$key]); $crosslistsTemp = unserialize($listsTemp2[$key]); $listsArray[$value['id']]['num_crosslists'] = empty($crosslistsTemp) ? 0 : sizeof($crosslistsTemp); } } $smarty->assign("T_CROSSWORD_WORDS", $listsArray); } } elseif ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "student") { if (isset($_GET['restart_list']) && eF_checkParameter($_GET['restart_list'], 'id')) { eF_deleteTableData("module_crossword_users", "users_LOGIN='******'s_login'] . "' AND content_ID=" . $_GET['restart_list']); } if (isset($_GET['restart_lists'])) { eF_deleteTableData("module_crossword_users", "users_LOGIN='******'s_login'] . "'"); } if ($_GET['answer'] == "true") { $resUserCard = eF_getTableData("module_crossword_users", "*", "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); if (sizeof($resUserCard) == 0) { $fields = array('users_LOGIN' => $_SESSION['s_login'], 'content_ID' => $_GET['view_list'], 'crosslists_ID' => $_GET['view_card'], 'success' => '1'); eF_insertTableData("module_crossword_users", $fields); } else { $success = $resUserCard[0]['success'] + 1; eF_updateTableData("module_crossword_users", array('success' => $success), "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); } } elseif ($_GET['answer'] == "false") { $resUserCard = eF_getTableData("module_crossword_users", "*", "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); $currentListTemp = eF_getTableData("module_crossword_words", "options", "content_ID=" . $_GET['view_list']); $listTemp = unserialize($currentListTemp[0]['options']); if ($listTemp['wrong'] == 1 && sizeof($resUserCard) != 0 && $resUserCard[0]['success'] != 0) { $success = $resUserCard[0]['success'] - 1; eF_updateTableData("module_crossword_users", array('success' => $success), "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); } } $listsArray = array(); $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST))); foreach ($iterator as $key => $value) { $listsArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name']); } if (empty($listsArray)) { $smarty->assign("T_CROSSWORD_WORDSNAMES", $listsArray); return true; } $str = implode(",", array_keys($listsArray)); $lists = eF_getTableData("module_crossword_words", "*", "content_ID IN (" . $str . ")"); $mastery = eF_getTableDataFlat("module_crossword_users", "*", "content_ID IN (" . $str . ")"); $masteryArray = array_combine(array_values($mastery['crosslists_ID']), array_values($mastery['success'])); $questionsDiff = eF_getTableDataFlat("questions", "*", "content_ID IN (" . $str . ")"); $questionsDiffArray = array_combine(array_values($questionsDiff['id']), array_values($questionsDiff['difficulty'])); $validLists = array(); foreach ($lists as $key => $value) { $opt = unserialize($value['options']); $crosslists = unserialize($value['crosslists']); if ($opt['active'] == 1 && !empty($crosslists)) { $value['number_crosslists'] = empty($crosslists) ? 0 : sizeof($crosslists); $validLists[$value['content_ID']] = $value; $validLists[$value['content_ID']]['options'] = $opt; $finishedCrosslists = 0; foreach ($crosslists as $index => $item) { if ($masteryArray[$item] == $opt[$questionsDiffArray[$item]]) { $finishedCrosslists++; } } $conid = $validLists[$value['content_ID']]['content_ID']; $validLists[$value['content_ID']]['non_finished'] = $value['number_crosslists'] - $finishedCrosslists; $validLists[$value['content_ID']]['mastery'] = (double) $finishedCrosslists / sizeof($crosslists) * 100; $respoints = eF_getTableDataFlat("module_crossword_users", "*", "content_ID = '{$conid}' and users_LOGIN='******'s_login'] . "'"); $validLists[$value['content_ID']]['points'] = round($respoints['points'][0] / $respoints['totallength'][0] * 100); $validLists[$value['content_ID']]['crosstime'] = $respoints['wordtime'][0]; } } //print_r($validLists); $smarty->assign("T_CROSSWORD_WORDS", $validLists); $smarty->assign("T_CROSSWORD_WORDSNAMES", $listsArray); if (isset($_GET['view_list']) && !isset($_GET['pdf'])) { $resunit = eF_getTableData("content", "name", "id=" . $_GET['view_list']); $smarty->assign("T_CROSSWORD_UNITNAME", $resunit[0]['name']); $_SESSION['contentid'] = $_GET['view_list']; if (isset($_POST) && !empty($_POST['crosstime'])) { $userlist = eF_getTableData("module_crossword_users", "*", "users_LOGIN='******'s_login'] . "' and content_ID=" . $_GET['view_list'] . ""); if (count($userlist) == 0) { $fields = array('users_LOGIN' => $_SESSION['s_login'], 'content_ID' => $_GET['view_list'], 'points' => $_POST['points'], 'totallength' => $_SESSION['WORDLEN'], 'wordtime' => $_POST['crosstime']); eF_insertTableData("module_crossword_users", $fields); } else { $fields = array('points' => $_POST['points'], 'totallength' => $_SESSION['WORDLEN'], 'wordtime' => $_POST['crosstime']); eF_updateTableData("module_crossword_users", $fields, "content_ID=" . $_GET['view_list'] . " and users_LOGIN='******'s_login'] . "'"); } $message_type = 'success'; $message = _CROSSWORD_GAME_SUCCESSFULLY; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } $contentid = $_GET['view_list']; $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']); $reswords = unserialize($res[0]['crosslists']); $maxwords = unserialize($res[0]['options']); $maxwords1 = $maxwords['max_word']; $smarty->assign("T_CROSSWORD_REVEALANSWER", $maxwords['reveal_answer']); $smarty->assign("T_CROSSWORD_MAXWORD", $maxwords1 + 1); $_SESSION['CROSSWORD_MAXWORD'] = $maxwords1; require_once 'init.php'; $rowquesans = ""; foreach ($reswords as $rowques) { $rowquesans .= $rowques . ","; } $quesids = mb_substr($rowquesans, 0, -1); $quesans = eF_getTableData("questions", "text,answer", "id IN({$quesids}) order by rand() limit {$maxwords1}"); $value = array(); foreach ($quesans as $row) { $answer = unserialize($row['answer']); $answer1 = explode("|", $answer['0']); $value[] = array('ANSWER' => $answer1['0'], 'QUESTION' => $row['text']); } if (!empty($value)) { //pr($value);exit; $success = $pc->generateFromWords($value); if (!$success) { $message_type = 'failure'; $message = _CROSSWORD_UNABLEGENERATECROSSWORD; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } else { $words = $pc->getWords(); $wordlen = ""; foreach ($words as $rowwords) { $wordlen = $wordlen + $rowwords['wordlength']; } $_SESSION['WORDLEN'] = $wordlen; $smarty->assign("T_CROSSWORD_LENGTH", $_SESSION['WORDLEN']); //vd($words); //because of #1599 foreach ($words as $key => $word) { $words[$key]['question'] = str_replace(array("\r\n", "\n"), '<br/>', $word['question']); } //vd($words); $smarty->assign("T_CROSSWORD_ANSWERS", $words); } } $post_target = $this->moduleBaseUrl . "&view_list=" . $_GET['view_list'] . ""; $form = new HTML_QuickForm("crossword_game", "post", $post_target, "", null, true); $form->addElement('submit', 'submit_crossword', 'SUBMIT', 'class = "flatButton"'); //The submit content button $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_CROSSWORD_SUBMIT', $renderer->toArray()); //Assign the form to the template $message = ""; //$message_type = 'success'; // eF_redirect("".$this -> moduleBaseUrl."&popup=1&finish=1&message=".$message."&message_type=".$message_type); } else { if (isset($_GET['view_list']) && isset($_GET['pdf']) && $_GET['pdf'] == 'cross') { $resunit = eF_getTableData("content", "name,lessons_ID", "id=" . $_GET['view_list']); $reslesson = eF_getTableData("lessons", "name", "id=" . $resunit[0]['lessons_ID']); $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']); $reswords = unserialize($res[0]['crosslists']); $maxwords = unserialize($res[0]['options']); $maxwords1 = $maxwords['max_word']; $_SESSION['CROSSWORD_MAXWORD'] = $maxwords1; require_once 'init.php'; $rowquesans = ""; foreach ($reswords as $rowques) { $rowquesans .= $rowques . ","; } $quesids = mb_substr($rowquesans, 0, -1); $quesans = eF_getTableData("questions", "text,answer", "id IN({$quesids}) order by rand() limit {$maxwords1}"); $value = array(); foreach ($quesans as $row) { $answer = unserialize($row['answer']); $answer1 = explode("|", $answer['0']); $value[] = array('ANSWER' => $answer1['0'], 'QUESTION' => $row['text']); } $success = $pc->generateFromWords($value); if (!$success) { $message_type = 'failure'; $message = _CROSSWORD_UNABLEGENERATECROSSWORD; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } else { $currentlesson = $reslesson[0]['name']; $words = $pc->getWords(); $answor = array(); $html1 = array(); $html2 = array(); $html1[] = $currentlesson; $html1[] .= $resunit[0]['name']; $html1[] .= _CROSSWORD_ACROSS; $html2[] = _CROSSWORD_DOWN; $k = 1; //pr($words); foreach ($words as $row) { if ($row['axis'] == 1) { $html1[] .= $k . '. ' . $row['question']; } else { $html2[] .= $k . '. ' . $row['question']; } $k++; } //pr($html1); //pr($html2); //exit; $answor[] = array_merge($html1, $html2); //pr($answor); exit; $dd = $pc->getHTML($answor); exit; } } } } return true; }
} else { $message = _LOGINERRORPLEASEMAKESURECAPSLOCKISOFF; $message_type = 'failure'; } $fb_form_existing->setConstants(array("fb_existing_login" => $values['login'], "fb_existing_password" => "")); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $fb_form_existing->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $fb_form_existing->setRequiredNote(_REQUIREDNOTE); $fb_form_existing->accept($renderer); $smarty->assign('T_EXISTING_USER_LOGIN_FORM', $renderer->toArray()); // If external login option enabled if ($GLOBALS['configuration']['social_modules_activated'] & FB_FUNC_LOGGING) { $fb_form_new = new HTML_QuickForm("facebook_login_new_form", "post", basename($_SERVER['PHP_SELF']), "", "class = 'indexForm'", true); $fb_form_new->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $fb_form_new->addElement('text', 'fb_new_login', _NEWLOGIN, 'class = "inputText"'); //$fb_form_new -> addRule('fb_new_login', _THEFIELD.' "'._LOGIN.'" '._ISMANDATORY, 'required', null, 'client'); $fb_form_new->addRule('fb_new_login', _YOUCANNOTLOGINAS . '"' . $_POST['login'] . '"', 'checkParameter', 'login'); $fb_form_new->addElement('password', 'fb_new_password', _PASSWORD, 'class = "inputText" tabindex = "0"'); //$fb_form_new -> addRule('fb_new_password', _THEFIELD.' "'._PASSWORD.'" '._ISMANDATORY, 'required', null, 'client'); $fb_form_new->addElement('password', 'fb_new_passrepeat', _REPEATPASSWORD, 'class = "inputText "'); //$form -> addRule('passrepeat', _THEFIELD.' '._REPEATPASSWORD.' '._ISMANDATORY, 'required', null, 'client'); $fb_form_new->addRule(array('fb_new_password', 'fb_new_passrepeat'), _PASSWORDSDONOTMATCH, 'compare', null, 'client'); $fb_form_new->addElement('text', 'fb_new_email', _EMAILADDRESS, 'class = "inputText"'); $fb_form_new->addElement('submit', 'submit_login_new', _REGISTER, 'class = "flatButton"'); if ($fb_form_new->isSubmitted() && $fb_form_new->validate()) { $values = $fb_form_new->exportValues(); // Create array from normal user data $users_content = array('login' => $values['fb_new_login'], 'name' => $_SESSION['facebook_details']['first_name'], 'surname' => $_SESSION['facebook_details']['last_name'], 'active' => 1, 'email' => $values['fb_new_email'], 'password' => $values['fb_new_password'], 'user_type' => "student", 'timezone' => $GLOBALS['configuration']['time_zone'], 'user_types_ID' => 0);
* @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <*****@*****.**> * @copyright 2006 by 11abacus * @license LGPL * @version CVS: $Id$ * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA */ require_once 'HTML/QuickForm/Rule.php'; /** * Rule to compare a field with a CAPTCHA image * * @access public * @package HTML_QuickForm_CAPTCHA * @version $Revision:$ */ class HTML_QuickForm_Rule_CAPTCHA extends HTML_QuickForm_Rule { /** * Validates the data enter matches the CAPTCHA image that was * displayed * * @param string $value data to validate * @param HTML_QuickForm_CAPTCHA_Common $captcha_element to check against */ function validate($value, $captcha) { return $value == $captcha->getValue(); } } HTML_QuickForm::registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); $form = new HTML_QuickForm("bootstrap_form", "post", $this->moduleBaseUrl, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addElement('text', 'name', _NAME, 'class = "inputText"'); $form->addElement('static', '', _MODULE_BOOTSTRAP_WITHOUTTHECLASS, 'class = "inputText"'); $form->addRule('name', _THEFIELD . ' ' . _NAME . ' ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'alnum'); $form->addElement('text', 'title', _TITLE, 'class = "inputText"'); $form->addElement('text', 'creator', _MODULE_BOOTSTRAP_CREATOR, 'class = "inputText"'); $form->addElement('checkbox', 'administrator', _ADMINISTRATOR); $form->addElement('checkbox', 'professor', _PROFESSOR); $form->addElement('checkbox', 'student', _STUDENT); $form->addElement('checkbox', 'supervisor', _MODULE_BOOTSTRAP_SUPERVISORONLY); $form->addElement('checkbox', 'tabber', _MODULE_BOOTSTRAP_TABBER); $form->addElement('textarea', 'form', _MODULE_BOOTSTRAP_FORMFIELDS, 'class = "inputTextarea" style = "height:40px"'); $form->addElement('static', '', _MODULE_BOOTSTRAP_FORMINSTRUCTIONS); $form->addElement('textarea', 'grid', _MODULE_BOOTSTRAP_GRIDFIELDS, 'class = "inputTextarea" style = "height:40px"'); $form->addElement('static', '', _MODULE_BOOTSTRAP_GRIDINSTRUCTIONS); $form->addElement('checkbox', 'filemanager', _MODULE_BOOTSTRAP_FILEMANAGER); $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTextarea" style = "height:80px"'); //$form -> addElement('placing', 'student', _MODULE_BOOTSTRAP_NAME); $form->addElement('checkbox', 'overwrite', _MODULE_BOOTSTRAP_OVERWRITEIFEXISTS); $form->addElement('submit', 'submit', _INSTALL, 'class = "flatButton"'); $form->setDefaults(array('creator' => $this->getCurrentUser()->user['name'] . ' ' . $this->getCurrentUser()->user['surname'])); if ($form->isSubmitted() && $form->validate()) { try { $values = $form->exportValues(); if (!$values['administrator'] && !$values['student'] && !$values['professor']) { throw new Exception(_MODULE_BOOTSTRAP_YOUMUSTSELECTATLEASTATYPE); } $module_name = $values['name']; $module_dir = $this->moduleBaseDir . 'module_' . $module_name; if (!is_dir($module_dir)) { mkdir($module_dir, 0755); } if (!is_dir("{$module_dir}/img")) { mkdir("{$module_dir}/img", 0755); } if (!is_dir("{$module_dir}/assets")) { mkdir("{$module_dir}/assets", 0755); } if ($values['administrator']) { $roles[] = 'administrator'; } if ($values['professor']) { $roles[] = 'professor'; } if ($values['student']) { $roles[] = 'student'; } $roles = '"' . implode('","', $roles) . '"'; $contents = $tabber = $block = $grid_content = $fields_content = ''; $fields = array(); if ($values['form']) { foreach (explode(",", $values['form']) as $property) { $property = explode(":", $property); array_walk($property, create_function('&$v', '$v = trim($v);')); $fields[] = array('type' => $property[0], 'name' => $property[1], 'title' => $property[2], 'extra' => $property[3]); } foreach ($fields as $value) { $fields_content .= '$form -> addElement("' . $value["type"] . '", "' . $value["name"] . '", "' . $value["title"] . '", "' . $value["extra"] . '");'; } } else { $fields = "return false;"; } if ($values['filemanager']) { $file_manager = "true"; } else { $file_manager = "false"; } if ($values['grid']) { $headers = $rows = $grid_contents = array(); $grid_content = "\$data = array(array("; foreach (explode(",", $values['grid']) as $property) { $property = trim($property); if ($property) { $property = explode(":", $property); array_walk($property, create_function('&$v', '$v = trim($v);')); $headers[] = "\r\n\t\t\t\t\t\t\t\t<td class = 'topTitle' name = '{$property[0]}'>{$property[1]}</td>"; $rows[] = "\r\n\t\t\t\t\t\t\t\t<td>{\$item.{$property[0]}}</td>"; $grid_content .= "'{$property[0]}' => 'sample value',"; } } $grid_content .= "));"; $headers = implode("\n", $headers); $rows = implode("\n", $rows); $contents .= <<<GRID {capture name = "t_grid_code"} <!--ajax:{$module_name}Table--> \t\t\t\t\t<table style = "width:100%" class = "sortedTable" size = "{\$T_TABLE_SIZE}" sortBy = "0" id = "{$module_name}Table" useAjax = "1" rowsPerPage = "{\$smarty.const.G_DEFAULT_TABLE_SIZE}" url = "{\$T_MODULE_BASEURL}&"> \t\t\t\t\t\t<tr class = "topTitle"> \t\t\t\t\t\t\t{$headers} \t\t\t\t\t\t</tr> \t{foreach name = 'demo_data_list' key = 'key' item = 'item' from = \$T_DATA_SOURCE} \t\t\t\t\t\t<tr class = "defaultRowHeight {cycle values = "oddRowColor, evenRowColor"}"> \t\t\t\t\t\t\t{$rows} \t\t\t\t\t\t</tr> \t{foreachelse} \t\t\t\t\t<tr class = "defaultRowHeight oddRowColor"><td class = "emptyCategory" colspan = "100%">{\$smarty.const._NODATAFOUND}</td></tr> \t{/foreach} \t\t\t\t</table> <!--/ajax:{$module_name}Table--> {/capture} GRID; if ($values['tabber']) { $tabber = "tabber = \"{$module_name}_grid\""; } $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_DATA . '" data = $smarty.capture.t_grid_code}' . "\n"; } if ($values['form']) { $contents .= <<<FORM {capture name = "t_form_block_code"} \t{eF_template_printForm form = \$T_FORM} {/capture} FORM; if ($values['tabber']) { $tabber = "tabber = \"{$module_name}_form\""; } $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_FORM . '" data = $smarty.capture.t_form_block_code}' . "\n"; } if ($values['filemanager']) { $contents .= <<<FILEMANAGER {capture name = "t_block_code"} \t{\$T_FILE_MANAGER} {/capture} FILEMANAGER; if ($values['tabber']) { $tabber = "tabber = \"{$module_name}_filemanager\""; } $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_FILES . '" data = $smarty.capture.t_block_code}'; } if ($values['empty_page']) { $contents .= <<<EMPTY {capture name = "t_block_code"} \tCode here {/capture} EMPTY; if ($values['tabber']) { $tabber = "tabber = \"{$module_name}_page\""; } $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_PAGE . '" data = $smarty.capture.t_block_code}'; } if ($values['tabber']) { $contents = <<<CONTENTS {$contents} {capture name = "t_code"} <div class = "tabber"> {$block} </div> {/capture} {eF_template_printBlock title = "{$values["title"]}" data = \$smarty.capture.t_code} CONTENTS; } else { $contents = $contents . $block; } file_put_contents("{$module_dir}/module.tpl", $contents); $search = array("###NAME###", "###TITLE###", "###ROLES###", "###FIELDS###", "###FILE_MANAGER###", "###GRID_DATA###"); $replace = array($module_name, $values['title'], $roles, $fields_content, $file_manager, $grid_content); $contents = file_get_contents($this->moduleBaseDir . "template/module_.class.php"); $contents = str_replace($search, $replace, $contents); file_put_contents("{$module_dir}/module_{$module_name}.class.php", $contents); $date = date("Y m d"); $xml = <<<XML <?xml version="1.0" ?> <module> \t<title>{$values['title']}</title> \t<author>{$values['creator']}</author> \t<date>{$date}</date> \t<version>1.0</version> \t<description>{$values['description']}</description> \t<className>module_{$module_name}</className> \t<requires>3.6.11</requires> </module> XML; file_put_contents("{$module_dir}/module.xml", $xml); copy($this->moduleBaseDir . "img/logo.png", "{$module_dir}/img/logo.png"); copy($this->moduleBaseDir . "img/generic.png", "{$module_dir}/img/generic.png"); $directory = new EfrontDirectory($module_dir); if (is_dir(G_MODULESPATH . basename($module_dir))) { if ($values['overwrite']) { $file = $directory->copy(G_MODULESPATH . basename($module_dir), true); } else { throw new Exception(_MODULE_BOOTSTRAP_MODULEEXISTS); } } else { $file = $directory->copy(G_MODULESPATH . basename($module_dir)); } $this->setMessageVar(_MODULE_BOOTSTRAP_MODULEINSTALLED, 'success'); } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $this->setMessageVar($message, 'failure'); } } $smarty->assign("T_FORM", $form->toArray()); return true; }
private function &_widgetDate(&$field, $args) { HTML_QuickForm::registerRule('date', 'callback', '_ruleDate', 'TIP_Form'); $id = $field['id']; $label = $this->getLocale('label.' . $id); $info = TIP::getLocale('comment.' . $id, $this->locale_prefix); // Set the date in a format suitable for HTML_QuickForm_date $sql_date = @$this->_defaults[$id]; $timestamp = empty($sql_date) ? time() : TIP::getTimestamp($sql_date, 'sql'); $this->_defaults[$id] = $timestamp; $field_year = date('Y', $this->_defaults[$id]); $this_year = date('Y'); // $min_year > $max_year, so the year list is properly sorted in reversed // order $options = array('language' => substr(TIP::getLocaleId(), 0, 2), 'format' => 'dFY', 'minYear' => $this_year + 1, 'maxYear' => $field_year < $this_year - 5 ? $field_year : $this_year - 5); ++$this->_tabindex; $element =& $this->_form->addElement('date', $id, $label, $options, array('tabindex' => $this->_tabindex)); $element->setInfo($info); $this->_addRule($id, 'date'); $this->_addConverter($id, 'SqlDate'); return $element; }
/** * Get the create directory form * * This function is responsible for creating the "create directory" * form, as well as the equivalent HTML code. * * @param HTML_QuickForm $form The form to populate * @return string The HTML code of the form * @since 3.5.0 * @access protected */ protected function getCreateDirectoryForm(&$form) { $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'create_directory', null, 'class = "inputText"'); $form->addElement('hidden', 'current_directory', null, 'id = "current_directory" class = "inputText"'); $form->addElement('submit', 'submit_create_directory', _CREATE, 'class = "flatButton"'); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $formArray = $renderer->toArray(); $formString = ' ' . $formArray['javascript'] . ' <form ' . $formArray['attributes'] . '> ' . $formArray['hidden'] . ' <table width = "100%"> <tr><td class = "labelCell">' . _FOLDERNAME . ': </td> <td class = "elementCell">' . $formArray['create_directory']['html'] . '</td></tr> <tr><td></td> <td class = "elementCell"> ' . $formArray['submit_create_directory']['html'] . ' </td></tr> </table> </form>'; return $formString; }
// Set the default values for form elements $form->setDefaults(array('delivery' => 'yes', 'size' => 'medium')); // Add each element to the form $form->addElement('text', 'name', 'Your Name: '); $form->addElement('radio', 'size', 'Size:', 'Small', 'small'); $form->addElement('radio', 'size', '', 'Medium', 'medium'); $form->addElement('radio', 'size', '', 'Large', 'large'); $form->addElement('select', 'sweet', 'Pick one sweet item:', $sweets); $form->addElement('select', 'main_dish', 'Pick two main dishes:', $main_dishes, 'multiple="multiple"'); $form->addElement('radio', 'delivery', 'Do you want your order delivered?', 'Yes', 'yes'); $form->addElement('textarea', 'comments', 'Enter any special instructions. <br/> If you want your order delivered, put your address here:'); $form->addElement('submit', 'save', 'Order'); // Create two custom validation rules (implemented by the functions // add the end of the script) $form->registerRule('check_array', 'function', 'check_array'); $form->registerRule('check_array_size', 'function', 'check_array_size'); // The name field is required $form->addRule('name', 'Please enter your name.', 'required'); // The size field is required and its value must be // one of "small", "medium", or "large" $form->addRule('size', 'Please select a size.', 'required'); $form->addRule('size', 'Please select a size.', 'check_array', array('small' => 1, 'medium' => 1, 'large' => 1)); // The sweet field is required and its value must be in the // $sweets array $form->addRule('sweet', 'Please select a valid sweet item.', 'required'); $form->addRule('sweet', 'Please select a valid sweet item.', 'check_array', $sweets); // The main_dish field is required, it must have exactly two values // and those values must be in the $main_dishes array $form->addRule('main_dish', 'Please select exactly two main dishes.', 'required'); $form->addRule('main_dish', 'Please select exactly two main dishes.', 'check_array_size', 2);
} eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=external&tab=main&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success"); } } $smarty->assign("T_EXTERNAL_MAIN_FORM", $externalMainForm->toArray()); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY $all_social_enabled_value = pow(2, SOCIAL_MODULES_ALL); if (!isset($GLOBALS['configuration']['social_modules_activated'])) { EfrontConfiguration::setValue('social_modules_activated', pow(2, SOCIAL_MODULES_ALL) - 1); $socialModulesActivated = $all_social_enabled_value - 1; } else { $socialModulesActivated = intval($GLOBALS['configuration']['social_modules_activated']); } $externalFacebookForm = new HTML_QuickForm("external_fb_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=external&tab=facebook", "", null, true); $externalFacebookForm->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $externalFacebookForm->addElement("advcheckbox", "social_" . FB_FUNC_DATA_ACQUISITION, _FACEBOOKDATAACQUISITION, null, 'class = "inputCheckBox"', array(0, 1)); $externalFacebookForm->addElement("advcheckbox", "social_" . FB_FUNC_LOGGING, _FACEBOOKEXTERNALLOGGING, null, 'class = "inputCheckBox"', array(0, 1)); $externalFacebookForm->addElement("advcheckbox", "social_" . FB_FUNC_CONNECT, _FACEBOOKCONNECT, null, 'class = "inputCheckBox"', array(0, 1)); $externalFacebookForm->addElement("text", "facebook_api_key", _FACEBOOKAPIKEY, 'class = "inputText"'); $externalFacebookForm->addElement("text", "facebook_secret", _FACEBOOKSECRET, 'class = "inputText"'); // Initialize values for ($i = 1; $i < $all_social_enabled_value; $i = $i << 1) { if ($i & $socialModulesActivated) { $externalFacebookForm->setDefaults(array('social_' . $i => 1)); } } $externalFacebookForm->setDefaults(array("facebook_api_key" => $GLOBALS['configuration']['facebook_api_key'], "facebook_secret" => $GLOBALS['configuration']['facebook_secret'])); if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') { $externalFacebookForm->freeze(); } else {
/** * addAccountForm * * Create HTML_QuickForm instance of add account form * * @access protected * @return object HTML_QuickForm object */ protected function addAccountForm() { $form = new HTML_QuickForm('formAddAccount', 'post', "./?module=Accounts&event=addAccountNow&domain={$this->domain}"); $form->setDefaults(array('account' => '@' . $this->domain)); $form->addElement('text', 'account', _("Account")); $form->addElement('text', 'comment', _("Real Name/Comment")); $form->addElement('text', 'password', _("Password")); $form->addElement('submit', 'submit', _("Add Account")); $form->registerRule('sameDomain', 'regex', "/@{$this->domain}\$/i"); $form->addRule('account', _("Account is required"), 'required', null, 'client'); $form->addRule('comment', _("Comment is required"), 'required', null, 'client'); $form->addRule('account', _("Account must be the full email address"), 'email', null, 'client'); $form->addRule('account', _('Error: wrong domain in email address'), 'sameDomain'); $form->addRule('password', _("Password is required"), 'required', null, 'client'); return $form; }
$form->addElement('text', 'pdfreports_email_sender', _("Email Sender"), $attrsText); $form->addElement('text', 'pdfreports_report_author', _("Report Author"), $attrsText); $form->addElement('select', 'pdfreports_report_header_logo', _("Header Logo"), $logoImg, array("id" => "pdfreports_report_header_logo")); $form->addElement('text', 'pdfreports_path_gen', _("Path to report files"), $attrsText); # ## Form Rules # function slash($elem = NULL) { if ($elem) { return rtrim($elem, "/") . "/"; } } $form->applyFilter('__ALL__', 'myTrim'); $form->applyFilter('pdfreports_path_gen', 'slash'); $form->registerRule('is_writable_file_if_exist', 'callback', 'is_writable_file_if_exist'); $form->registerRule('is_writable_path', 'callback', 'is_writable_path'); $form->addRule('pdfreports_smtp_server_address', _("Required Field"), 'required'); $form->addRule('pdfreports_email_sender', _("Required Field"), 'required'); $form->addRule('pdfreports_report_author', _("Required Field"), 'required'); $form->addRule('pdfreports_path_gen', _("Required Field"), 'required'); $form->addRule('pdfreports_path_gen', _("Can't write in directory"), 'is_writable_path'); # ##End of form definition # $form->addElement('hidden', 'gopt_id'); $redirect =& $form->addElement('hidden', 'o'); $redirect->setValue($o); # Smarty template Init $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl);
public function getSmartyTpl() { $smarty = $this->getSmartyVar(); $smarty->assign("T_RSS_MODULE_BASEURL", $this->moduleBaseUrl); $smarty->assign("T_RSS_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_RSS_PROVIDED_FEEDS_MODES", $this->feedProviderModes); $smarty->assign("T_RSS_PROVIDED_FEEDS_TYPES", $this->providedFeeds); $smarty->assign("T_RSS_PROVIDED_FEEDS_LESSON_TYPES", $this->lessonProvidedFeeds); if (isset($_GET['delete_feed']) && eF_checkParameter($_GET['delete_feed'], 'id')) { try { if ($_GET['type'] == 'provider') { eF_deleteTableData("module_rss_provider", "id=" . $_GET['delete_feed']); } else { eF_deleteTableData("module_rss_feeds", "id=" . $_GET['delete_feed']); } } catch (Exception $e) { handleAjaxExceptions($e); } exit; } elseif (isset($_GET['deactivate_feed']) && eF_checkParameter($_GET['deactivate_feed'], 'id')) { try { if ($_GET['type'] == 'provider') { eF_updateTableData("module_rss_provider", array("active" => 0), "id=" . $_GET['deactivate_feed']); } else { eF_updateTableData("module_rss_feeds", array("active" => 0), "id=" . $_GET['deactivate_feed']); } echo 0; } catch (Exception $e) { handleAjaxExceptions($e); } exit; } elseif (isset($_GET['activate_feed']) && eF_checkParameter($_GET['activate_feed'], 'file')) { //Although db operations do not support exceptions (yet), we leave this here for future support try { if ($_GET['type'] == 'provider') { eF_updateTableData("module_rss_provider", array("active" => 1), "id=" . $_GET['activate_feed']); } else { eF_updateTableData("module_rss_feeds", array("active" => 1), "id=" . $_GET['activate_feed']); } echo 1; } catch (Exception $e) { handleAjaxExceptions($e); } exit; } else { if (isset($_GET['add_feed']) || isset($_GET['edit_feed']) && eF_checkParameter($_GET['edit_feed'], 'id')) { if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; } else { $type = $this->getCurrentUser()->getType(); } $smarty->assign("T_RSS_USERTYPE", $type); $feeds = $this->getFeeds(); $lessons = array(-1 => _RSS_NONE, 0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } isset($_GET['add_feed']) ? $postTarget = "&add_feed=1" : ($postTarget = "&edit_feed=" . $_GET['edit_feed']); $form = new HTML_QuickForm("add_feed_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addElement('text', 'title', _RSS_FEEDTITLE, 'class = "inputText"'); $form->addElement('text', 'url', _RSS_FEEDURL, 'class = "inputText"'); $form->addElement('select', 'lessons_ID', _LESSON, $lessons); if ($type != 'administrator' && $_SESSION['s_lessons_ID']) { $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID'])); $form->freeze(array('lessons_ID')); } $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1)); $form->setDefaults(array('active' => 1)); $form->addElement("advcheckbox", "only_summary", _RSS_ONLYSUMMARY, null, 'class = "inputCheckBox"', array(0, 1)); $form->addRule('title', _THEFIELD . ' "' . _RSS_FEEDTITLE . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('url', _THEFIELD . ' "' . _RSS_FEEDURL . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('title', _INVALIDFIELDDATA, 'checkParameter', 'text'); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_feed'])) { $editFeed = $feeds[$_GET['edit_feed']]; $form->setDefaults($editFeed); } if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("title" => $values['title'], "url" => $values['url'], "active" => $values['active'], "only_summary" => $values['only_summary'], "lessons_ID" => $values['lessons_ID']); if (isset($_GET['add_feed'])) { eF_insertTableData("module_rss_feeds", $fields); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED); } else { eF_updateTableData("module_rss_feeds", $fields, "id=" . $_GET['edit_feed']); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED); EfrontCache::getInstance()->deleteCache('rss_cache:' . $_GET['edit_feed']); } } $smarty->assign("T_RSS_ADD_RSS_FORM", $form->toArray()); } else { if (isset($_GET['add_feed_provider']) || isset($_GET['edit_feed_provider']) && eF_checkParameter($_GET['edit_feed_provider'], 'id')) { if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; } else { $type = $this->getCurrentUser()->getType(); } $smarty->assign("T_RSS_USERTYPE", $type); $feeds = $this->getProvidedFeeds(); isset($_GET['add_feed_provider']) ? $postTarget = "&add_feed_provider=1" : ($postTarget = "&edit_feed_provider=" . $_GET['edit_feed_provider']); !isset($_GET['lesson']) or $postTarget .= '&lesson=1'; $form = new HTML_QuickForm("add_feed_provider_form", "post", $this->moduleBaseUrl . $postTarget . '&tab=rss_provider', "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); if ($_GET['lesson']) { $lessons = array(0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->lessonProvidedFeeds); $form->addElement('select', 'lessons_ID', _LESSON, $lessons); if ($type != 'administrator' && $_SESSION['s_lessons_ID']) { $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID'])); $form->freeze(array('lessons_ID')); } } else { $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->providedFeeds); } $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1)); $form->setDefaults(array('active' => 1)); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_feed_provider'])) { $editFeed = $feeds[$_GET['edit_feed_provider']]; $form->setDefaults($editFeed); } try { if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("mode" => $_GET['lesson'] ? 'lesson' : 'system', "type" => $values['feeds_provided'], "active" => $values['active'], "lessons_ID" => $values['lessons_ID']); foreach ($feeds as $feed) { if ($feed['type'] == $fields['type'] && $feed['mode'] == $fields['mode'] && $feed['lessons_ID'] == $fields['lessons_ID']) { throw new Exception(_FEEDALREADYEXISTS); } } if (isset($_GET['add_feed_provider'])) { eF_insertTableData("module_rss_provider", $fields); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED); } else { eF_updateTableData("module_rss_provider", $fields, "id=" . $_GET['edit_feed_provider']); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED); } } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } $smarty->assign("T_RSS_PROVIDE_RSS_FORM", $form->toArray()); } else { if (isset($_GET['ajax'])) { echo $this->getRssFeeds($_GET['refresh']); //echo $this -> getRssFeeds(true); exit; } else { $lessons = array(0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } $smarty->assign("T_LESSON_NAMES", $lessons); if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds($_SESSION['s_lessons_ID'])); $smarty->assign("T_RSS_FEEDS", $this->getFeeds(false, $_SESSION['s_lessons_ID'])); } else { $type = $this->getCurrentUser()->getType(); $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds()); $smarty->assign("T_RSS_FEEDS", $this->getFeeds()); } $smarty->assign("T_RSS_USERTYPE", $type); } } } } if ($message) { $this->setMessageVar($message, $message_type); } return $this->moduleBaseDir . "module_rss.tpl"; }
$userMultipleLoginsForm->addElement("static", "", _HOLDDOWNCTRLFORMULTIPLESELECT); $userMultipleLoginsForm->setDefaults(unserialize($GLOBALS['configuration']['multiple_logins'])); if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') { $userMultipleLoginsForm->freeze(); } else { $userMultipleLoginsForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"'); if ($userMultipleLoginsForm->isSubmitted() && $userMultipleLoginsForm->validate()) { $values = $userMultipleLoginsForm->exportValues(); $multipleLogins = array('global' => $values['global'] ? 1 : 0, 'user_types' => $values['user_types'], 'groups' => $values['groups']); EfrontConfiguration::setValue('multiple_logins', serialize($multipleLogins)); eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=multiple_logins&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success"); } } $smarty->assign("T_USER_MULTIPLE_LOGINS_FORM", $userMultipleLoginsForm->toArray()); $userWebserverAuthenticationForm = new HTML_QuickForm("user_webserver_authentication_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=webserver_authentication", "", null, true); $userWebserverAuthenticationForm->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $userWebserverAuthenticationForm->addElement("advcheckbox", "webserver_auth", _WEBSERVERAUTHENTICATION, null, 'class = "inputCheckBox"', array(0, 1)); $userWebserverAuthenticationForm->addElement("advcheckbox", "webserver_registration", _WEBSERVERREGISTRATION, null, 'class = "inputCheckBox"', array(0, 1)); $userWebserverAuthenticationForm->addElement("text", "error_page", _ERRORPAGEFORINVALIDLOGIN, 'class = "inputText"'); $userWebserverAuthenticationForm->addElement("text", "unauthorized_page", _ERRORPAGEFORUNAUTHORIZED, 'class = "inputText"'); $userWebserverAuthenticationForm->addElement("text", "username_variable", _VARIABLEFORUSERNAME, 'class = "inputText"'); $userWebserverAuthenticationForm->addElement("text", "registration_file", _INCLUDEFILETHATHANDLESUSERCREATION, 'class = "inputText"'); eval('$usernameVar=' . $GLOBALS['configuration']['username_variable'] . ';'); $userWebserverAuthenticationForm->addRule('webserver_auth', str_replace(array("%x", "%y"), array($GLOBALS['configuration']['username_variable'], $_SESSION['s_login']), _VARIABLEMUSTCONTAINLOGIN), 'callback', create_function('$checkbox', "if (\$GLOBALS['usernameVar'] == \$_SESSION['s_login']) {return true;}")); $userWebserverAuthenticationForm->setDefaults($GLOBALS['configuration']); if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') { $userWebserverAuthenticationForm->freeze(); } else { $userWebserverAuthenticationForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"'); if ($userWebserverAuthenticationForm->isSubmitted() && $userWebserverAuthenticationForm->validate()) { $values = $userWebserverAuthenticationForm->exportValues();
public function __construct() { parent::__construct('add_author'); $this->loadHttpVars(); $this->use_mootools = true; $this->all_interests = pdAuthInterests::createList($this->db); // before showing a loggin error, show the correct title for the page if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $pub =& $_SESSION['pub']; if (isset($pub->pub_id)) { $this->page_title = 'Edit Publication'; } else { $this->page_title = 'Add Publication'; } } else { if ($this->author_id == null) { $this->page_title = 'Add Author'; } else { $this->page_title = 'Edit Author'; } } if ($this->loginError) { return; } $author = new pdAuthor(); if ($this->author_id != null) { $result = $author->dbLoad($this->db, $this->author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_INTERESTS); if (!$result) { $this->pageError = true; return; } } $form = new HTML_QuickForm('authorForm'); $form->addElement('hidden', 'author_id', $this->author_id); if ($this->author_id == null) { $form->addElement('header', 'add_author_hdr', '<span class="Tips1" title="Adding an Author::Input the author\'s first name, last name, email address and organization. Optionally, interests may be selected from the list given or new interest can be added to the database. <p/> Multiple interests can be selected by holding down the control key and then left-clicking on the text. If you do not see the appropriate interests you can add them using the <b>Add Interest</b> link. <p/> Clicking the <b>Add Interest</b> link will bring up a new field each it is pressed. Type the text of the new interest into the this field.">Add Author</span>'); } else { $form->addElement('header', null, 'Edit Author'); } $form->addElement('text', 'firstname', 'First Name:', array('size' => 50, 'maxlength' => 250)); $form->registerRule('invalid_punct', 'regex', '/^[^()\\/\\*\\^\\?#!@$%+=,\\"\'><~\\[\\]{}]+$/'); $form->addRule('firstname', 'the first name cannot contain punctuation', 'invalid_punct', null, 'client'); $form->addElement('text', 'lastname', 'Last Name:', array('size' => 50, 'maxlength' => 250)); $form->addElement('select', 'authors_in_db', null, pdAuthorList::create($this->db), array('style' => 'overflow: hidden; visibility: hidden; width: 1px; height: 0;')); $tooltip = 'Title::The author\'s formal title. For example: <ul> <li>Professor</li> <li>PostDoc</li> <li>PhD Student</li> <li>MSc Student</li> <li>Colleague</li> </ul>'; $form->addElement('text', 'title', "<span class=\"Tips1\" title=\"{$tooltip}\">Title:</span>", array('size' => 50, 'maxlength' => 250)); $form->addElement('text', 'email', 'email:', array('size' => 50, 'maxlength' => 250)); $form->addRule('email', 'invalid email address', 'email', null, 'client'); $form->addElement('text', 'organization', 'Organization:', array('size' => 50, 'maxlength' => 250)); $form->addElement('text', 'webpage', 'Webpage:', array('size' => 50, 'maxlength' => 250)); $ref = '<br/><div class="small"><a href="javascript:dataKeep(' . ($this->numNewInterests + 1) . ')">[Add Interest]</a></div>'; $ams = $form->addElement('advmultiselect', 'interests', null, $this->all_interests, array('size' => 15, 'class' => 'pool', 'style' => 'width:200px;')); $ams->setLabel(array('Interests:' . $ref, 'Available', 'Selected')); $ams->setButtonAttributes('add', array('value' => 'Add >>', 'class' => 'inputCommand')); $ams->setButtonAttributes('remove', array('value' => '<< Remove', 'class' => 'inputCommand')); $template = <<<TEMPLATE_END {javascript} <table{class}> <thead> <tr> <!-- BEGIN label_2 --><tr><th align="center">{label_2}</th><!-- END label_2 --> <!-- BEGIN label_3 --><th align="center">{label_3}</th><!-- END label_3 --> <tr> </thead> <tr> <td>{unselected}</td> <td>{selected}</td> </tr> <tr> <td>{add}</td> <td>{remove}</td> </tr> </table> TEMPLATE_END; $ams->setElementTemplate($template); if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $form->addElement('static', null, null, '<span class="small">When done adding new authors press the "Next Step" button</span>'); } for ($i = 0; $i < $this->numNewInterests; $i++) { $form->addElement('text', 'newInterests[' . $i . ']', 'Interest Name ' . ($i + 1) . ':', array('size' => 50, 'maxlength' => 250)); } if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $pos = strpos($_SERVER['PHP_SELF'], 'papersdb'); $next_page = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb/Admin/add_pub2.php'; $url = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb'; $buttons[] = HTML_QuickForm::createElement('button', 'prev_step', '<< Previous Step', array('onClick' => "location.href='" . $next_page . "';")); $buttons[] = HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "cancelConfirm();")); $buttons[] = HTML_QuickForm::createElement('reset', 'reset', 'Reset'); $buttons[] = HTML_QuickForm::createElement('submit', 'add_another', 'Submit and Add Another Author'); $buttons[] = HTML_QuickForm::createElement('submit', 'next_step', 'Next Step >>'); if ($pub->pub_id != '') { $buttons[] = HTML_QuickForm::createElement('submit', 'finish', 'Finish'); } $form->addGroup($buttons, 'buttons', '', ' ', false); add_pub_base::addPubDisableMenuItems(); } else { $form->addRule('firstname', 'a first name is required', 'required', null, 'client'); $form->addRule('lastname', 'a last name is required', 'required', null, 'client'); if ($this->author_id == null) { $button_label = 'Add Author'; } else { $button_label = 'Submit'; } $form->addGroup(array(HTML_QuickForm::createElement('reset', 'reset', 'Reset'), HTML_QuickForm::createElement('submit', 'submit', $button_label)), null, null, ' '); } $form->addElement('hidden', 'numNewInterests', $this->numNewInterests); $this->form =& $form; if ($form->validate()) { $this->processForm(); } else { $this->renderForm($author); } }
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; }
<div class = "formError">{$error}</div> {/if}'); $form->accept($renderer); $smarty->assign('T_UPLOAD_SCORM_FORM', $renderer->toArray()); } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = failure; } } else { if ($_GET['scorm_export']) { if (isset($currentUser->coreAccess['content']) && $currentUser->coreAccess['content'] != 'change') { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } $form = new HTML_QuickForm("export_scorm_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=scorm&scorm_export=1', "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('submit', 'submit_export_scorm', _EXPORT, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { try { $compressedFile = $currentLesson->scormExport(); $smarty->assign("T_SCORM_EXPORT_FILE", $compressedFile); $smarty->assign("T_MESSAGE", _SUCCESSFULLYEXPORTEDSCORMFILE); $smarty->assign("T_MESSAGE_TYPE", "success"); } catch (Exception $e) { handleNormalFlowExceptions($e); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_EXPORT_SCORM_FORM', $renderer->toArray());
eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } try { $currentLesson->deleteConditions($_GET['delete_condition']); } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } exit; } elseif (isset($_GET['add_condition']) || isset($_GET['edit_condition']) && eF_checkParameter($_GET['edit_condition'], 'id')) { if (isset($currentUser->coreAccess['content']) && $currentUser->coreAccess['content'] != 'change') { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } isset($_GET['add_condition']) ? $post_target = 'add_condition=1' : ($post_target = 'edit_condition=' . $_GET['edit_condition']); $form = new HTML_QuickForm("complete_lesson_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=rules&tab=conditions&' . $post_target, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->registerRule('in_array', 'callback', 'in_array'); $testsIterator = new EfrontTestsFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1))); $testUnits = $currentContent->toHTMLSelectOptions($testsIterator); $contentIterator = new EfrontContentFeedbackFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1))); //Get active units that are anything but tests (false negates both rules) $noTestUnits = $currentContent->toHTMLSelectOptions($contentIterator); if (!empty($noTestUnits)) { $form->addElement('select', 'specific_unit', null, $noTestUnits, 'class = "inputSelect"'); $form->addRule('specific_unit', _INVALIDID, 'numeric', null, 'client'); } else { unset($condition_types['specific_unit']); } if (!empty($testUnits) && EfrontUser::isOptionVisible('tests')) { $form->addElement('select', 'specific_test', null, $testUnits, 'class = "inputSelect"');
// | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Adam Daniel <*****@*****.**> | // | Bertrand Mansion <*****@*****.**> | // +----------------------------------------------------------------------+ // // $Id$ require_once "HTML/QuickForm/input.php"; // register file-related rules if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerRule('uploadedfile', 'callback', '_ruleIsUploadedFile', 'HTML_QuickForm_file'); HTML_QuickForm::registerRule('maxfilesize', 'callback', '_ruleCheckMaxFileSize', 'HTML_QuickForm_file'); HTML_QuickForm::registerRule('mimetype', 'callback', '_ruleCheckMimeType', 'HTML_QuickForm_file'); HTML_QuickForm::registerRule('filename', 'callback', '_ruleCheckFileName', 'HTML_QuickForm_file'); } /** * HTML class for a file type element * * @author Adam Daniel <*****@*****.**> * @author Bertrand Mansion <*****@*****.**> * @version 1.0 * @since PHP4.04pl1 * @access public */ class HTML_QuickForm_file extends HTML_QuickForm_input { // {{{ properties /** * Uploaded file data, from $_FILES
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; $path = './modules/centreon-nagvis/'; $attrsTextLong = array("size" => "50"); $form = new HTML_QuickForm('Form', 'post', '?p=' . $p); $form->addElement('header', 'title', _('Centreon Nagvis configuration')); $form->addElement('header', 'information', _('Nagvis information')); $form->addElement('header', 'information2', _('Nagvis authentication')); $form->addElement('text', 'centreon_nagvis_uri', _('Nagvis URI'), $attrsTextLong); $form->addElement('text', 'centreon_nagvis_path', _('Nagvis Path'), $attrsTextLong); $form->addElement('select', 'centreon_nagvis_auth', _("Single NagVis user auth or Centreon user auth ? "), array("single" => "Single User", "centreon" => "Centreon User")); $form->addElement('text', 'centreon_nagvis_single_user', _('Nagvis user name'), $attrsTextLong); $form->addRule('centreon_nagvis_uri', _('Compulsory field'), 'required'); $form->addRule('centreon_nagvis_path', _('Compulsory field'), 'required'); $form->addRule('centreon_nagvis_auth', _('Compulsory field'), 'required'); $form->addRule('centreon_nagvis_single_user', _('Compulsory field'), 'required'); $form->registerRule('exist', 'callback', 'nagvisInstall'); $form->addRule('centreon_nagvis_path', _('Directory does not exist'), 'exist'); $form->setRequiredNote("<font style='color: red;'>*</font>" . _(" Required fields")); $form->addElement('submit', 'submitC', _("Save")); $form->addElement('reset', 'reset', _("Reset")); if ($form->validate()) { $values = $form->getSubmitValues(); $queryInsert = 'UPDATE `options` SET `value` = "%s" WHERE `key` = "%s"'; $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_uri']), 'centreon_nagvis_uri')); $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_path']), 'centreon_nagvis_path')); $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_auth']), 'centreon_nagvis_auth')); $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_single_user']), 'centreon_nagvis_single_user')); } /* * Get options */