Exemple #1
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $options = array('format' => 'd m Y H i', 'optionIncrement' => array('i' => 15), 'minYear' => date('Y') - 2, 'maxYear' => date('Y') + 2);
     $form = new HTML_QuickForm('protokol', 'POST', $this->url());
     $form->addElement('hidden', 'elev_id');
     $form->addElement('hidden', 'id');
     $form->addElement('date', 'date_start', 'Startdato:', $options);
     $form->addElement('date', 'date_end', 'Slutdato:', $options);
     $radio[0] =& HTML_QuickForm::createElement('radio', null, null, 'fri', '1');
     $radio[1] =& HTML_QuickForm::createElement('radio', null, null, 'syg', '2');
     $radio[2] =& HTML_QuickForm::createElement('radio', null, null, 'fraværende', '3');
     $radio[5] =& HTML_QuickForm::createElement('radio', null, null, 'henstilling', '6');
     $radio[3] =& HTML_QuickForm::createElement('radio', null, null, 'mundtlig advarsel', '4');
     $radio[4] =& HTML_QuickForm::createElement('radio', null, null, 'skriftlig advarsel', '5');
     $radio[6] =& HTML_QuickForm::createElement('radio', null, null, 'hjemsendt', '7');
     $radio[7] =& HTML_QuickForm::createElement('radio', null, null, 'andet', '8');
     $form->addGroup($radio, 'type', 'Type:', ' ');
     $form->addElement('textarea', 'text', '');
     $form->addElement('submit', null, 'Send');
     $form->addRule('date_start', 'Husk dato', 'required', null, 'client');
     $form->addRule('date_end', 'Husk dato', 'required', null, 'client');
     $form->addRule('type', 'Husk type', 'required', null, 'client');
     $form->addRule('text', 'Tekst', 'required', null, 'client');
     return $this->form = $form;
 }
 /**
  * function_description
  *
  * @author	John.meng
  * @since    version - Jan 5, 2006
  * @param	datatype paramname description
  * @return   datatype description
  */
 function drawLogin()
 {
     global $__Lang__, $UrlParameter, $SiteDB, $AddIPObj, $FlushPHPObj, $form, $smarty;
     include_once PEAR_DIR . 'HTML/QuickForm.php';
     $form = new HTML_QuickForm('firstForm');
     $replace_str = "../";
     $html_code = str_replace(ROOT_DIR, $replace_str, THEMES_DIR);
     echo "<link href='" . $html_code . "style.css' rel='stylesheet' type='text/css'>";
     $renderer =& $form->defaultRenderer();
     $renderer->setFormTemplate("\n<form{attributes}>\n<table border=\"0\" class=\"log_table\" align=\"center\">\n{content}\n</table>\n</form>");
     $renderer->setHeaderTemplate("\n\t<tr>\n\t\t<td class=\"log_table_head\" align=\"left\" valign=\"top\" colspan=\"2\" ><b>{header}</b></td>\n\t</tr>");
     $form->addElement('header', null, "<img src=\"" . $html_code . "images/logo.gif\" border=\"0\" >");
     $form->addElement('text', 'user_name', $__Lang__['langMenuUser'] . $__Lang__['langGeneralName'] . ' : ');
     $form->addElement('password', 'user_passwd', $__Lang__['langMenuUser'] . $__Lang__['langGeneralPassword'] . ' : ');
     $form->addRule('user_name', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langMenuUser'] . " " . $__Lang__['langGeneralName'], 'required');
     $form->addRule('user_passwd', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langMenuUser'] . " " . $__Lang__['langGeneralPassword'], 'required');
     $form->addElement('hidden', 'Action', 'LOGON');
     $form->setDefaults(array('user_name' => $_COOKIE['UserName']));
     $form->addElement('submit', null, $__Lang__['langGeneralSubmit']);
     $form->addElement('static', 'login_message');
     if ($form->validate() && $_POST['Action'] == 'LOGON') {
         $user_name = $_POST['user_name'];
         $user_password = md5($_POST['user_passwd']);
         $this->checkAuth($user_name, $user_password);
     }
     $form->display();
     exit;
 }
 function execute(ActionMapping $map, ActionForm $form, Request $req)
 {
     global $papyrine;
     $papyrine->entries =& $papyrine->getEntries();
     // Instantiate the HTML_QuickForm object
     require_once 'HTML/QuickForm.php';
     require_once 'HTML/QuickForm/group.php';
     $form = new HTML_QuickForm('create_entry');
     $form->addElement('text', 'title', 'Title:');
     $form->addElement('text', 'date', 'Date:');
     $form->addElement('text', 'status', 'Status:');
     // Get the default handler
     $form->addElement('text', 'body', 'Body:');
     $form->addElement('submit', null, 'Create');
     // Define filters and validation rules
     $form->applyFilter('name', 'trim');
     $form->addRule('name', 'Please enter your name', 'required', null, 'client');
     //get classes registered for entry
     //call method
     $plugin = new PapyrinePlugin(BASE . 'plugins/categories/');
     $object = $plugin->getInstance();
     $object->recieveNewEntryForm($form);
     $plugin = new PapyrinePlugin(BASE . 'plugins/comments/');
     $object = $plugin->getInstance();
     $object->recieveNewEntryForm($form);
     // Output the form
     $papyrine->form = $form->toHTML();
     header("Content-Type: application/xhtml+xml;charset=UTF-8");
     $papyrine->display('admin/header.html');
     $papyrine->display($map->getParameter());
     $papyrine->display('admin/footer.html');
 }
 /**
  * function_description
  *
  * @author	John.meng
  * @since    version - Jan 19, 2006
  * @param	datatype paramname description
  * @return   datatype description
  */
 function opAdd()
 {
     global $__Lang__, $UrlParameter, $SiteDB, $AddIPObj, $__SITE_VAR__, $form, $FlushPHPObj, $thisDAO, $smarty, $class_path;
     include_once PEAR_DIR . 'HTML/QuickForm.php';
     $form = new HTML_QuickForm('firstForm', 'post', '', '_self', "onsubmit='save_in_textarea_all();'");
     $renderer =& $form->defaultRenderer();
     $renderer->setFormTemplate("\n<form{attributes}>\n<table border=\"0\" class=\"new_table\" width='100%'>\n{content}\n</table>\n</form>");
     $renderer->setHeaderTemplate("\n\t<tr>\n\t\t<td class=\"grid_table_head\" align=\"left\" valign=\"top\" colspan=\"2\"><b>{header}</b></td>\n\t</tr>");
     $Content = $_POST['Content'];
     if ($_REQUEST['Action'] == 'Update') {
         $this_data = $this->_DAO->getRowByID(SITE_NEWS_TABLE, "NewsID", $_REQUEST['ID']);
         $form->setDefaults(array("Title" => $this_data['Title'], "Summary" => $this_data['Summary'], "Source" => $this_data['Source'], "Author" => $this_data['Author']));
         $Content = $this_data['Content'];
         $form->addElement('hidden', 'ID', $this_data['NewsID']);
     }
     $class_path = INCLUDE_DIR . "editor/";
     $CurrentUserPathImages = HTML_IMAGES_DIR;
     $SiteCssFile = CURRENT_HTML_DIR . "style.css";
     $ed_4 =& new rich("", 'Content', $Content, "380", "350", "../../" . $CurrentUserPathImages, "../../" . $CurrentUserPathImages, false, false);
     $ed_4->set_default_stylesheet($SiteCssFile);
     $ed_4->myModule(true);
     $editors = $ed_4->draw();
     $smarty->assign("class_path_editor", $class_path);
     $form->addElement('header', null, $__Lang__['langGeneralAdd'] . " " . $__Lang__['langSiteModuleNews']);
     $form->addElement('text', 'Title', $__Lang__['langModuleNewsTitle'] . ' : ', array('size' => 40));
     $form->addElement('textarea', 'Summary', $__Lang__['langModuleNewsSummary'] . ' : ', array('rows' => 5, 'cols' => 40));
     $form->addElement('static', 'Content', NULL, $editors);
     $form->addElement('text', 'Source', $__Lang__['langModuleNewsSource'] . ' : ', array('size' => 30));
     $form->addElement('text', 'Author', $__Lang__['langModuleNewsAuthor'] . ' : ', array('size' => 20));
     $form->addElement('submit', null, $__Lang__['langGeneralSubmit']);
     $form->addRule('Title', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langModuleNewsTitle'], 'required');
     $form->addElement('hidden', 'Module', $_REQUEST['Module']);
     $form->addElement('hidden', 'Page', $_REQUEST['Page']);
     $form->addElement('hidden', 'Action', $_REQUEST['Action']);
     $form->addElement('hidden', 'MenuID', $_GET['MenuID']);
     if ($form->validate()) {
         if (get_magic_quotes_gpc()) {
             $record["Content"] = stripslashes($_POST['Content']);
         } else {
             $record["Content"] = $_POST['Content'];
         }
         $record["Title"] = $_POST['Title'];
         $record["Summary"] = $_POST['Summary'];
         $record["Source"] = $_POST['Source'];
         $record["Author"] = $_POST['Author'];
         $record["SiteMenuID"] = $_POST['MenuID'];
         $record = $record + $this->_DAO->baseField();
         if ($_POST['ID'] && $_POST['Action'] == 'Update') {
             $this->_DAO->opUpdate(SITE_NEWS_TABLE, $record, " NewsID = " . $_POST['ID']);
         } else {
             $this->_DAO->opAdd(SITE_NEWS_TABLE, $record);
         }
         echo "<SCRIPT LANGUAGE='JavaScript'>opener.window.location.reload();window.close();</SCRIPT>";
     }
     $html_code = "<link rel=\"StyleSheet\" type=\"text/css\" href=\"" . $class_path . "rich_files/rich.css\"><script language=\"JScript.Encode\" src=\"" . $class_path . "rich_files/rich.js\"></script>" . $form->toHTML();
     $smarty->assign("Main", str_replace(ROOT_DIR, "../", $html_code));
 }
Exemple #5
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new HTML_QuickForm('underviser', 'POST', $this->url());
     $form->addElement('text', 'navn', 'Navn');
     $form->addElement('text', 'email', 'E-mail');
     $form->addElement('textarea', 'besked', 'Besked', array('rows' => 12, 'cols' => 30));
     $form->addElement('submit', null, 'Send');
     $form->addRule('navn', 'Du skal indtaste et navn', 'required');
     $form->addRule('email', 'Du skal indtaste en email', 'required');
     $form->addRule('email', 'Du skal indtaste en gyldig email', 'email');
     $form->addRule('besked', 'Du skal indtaste en gyldig besked', 'required');
     $form->applyFilter('__ALL__', 'trim');
     $form->applyFilter('__ALL__', 'strip_tags');
     $form->applyFilter('__ALL__', 'addslashes');
     return $this->form = $form;
 }
Exemple #6
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new HTML_QuickForm('confirm', 'POST', $this->url());
     $form->addElement('header', null, 'Accepterer du betingelserne?');
     $form->addElement('checkbox', 'confirm', null, 'Ja, jeg accepterer betingelserne', 'id="confirm"');
     $form->addElement('submit', null, 'Send');
     $form->addRule('confirm', 'Du skal acceptere betingelserne', 'required');
     return $this->form = $form;
 }
Exemple #7
0
 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>";
         }
     }
 }
Exemple #8
0
 public function __construct()
 {
     parent::__construct('login');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars(true, false);
     $this->password_hash = "aicml";
     if ($this->access_level > 0) {
         echo 'You are already logged in as ', $_SESSION['user']->login, '.';
         $this->pageError = true;
         return;
     }
     if (empty($this->redirect) || strpos($this->redirect, 'login.php') !== false) {
         // never redirect to the login page
         $this->redirect = 'index.php';
     }
     $form = new HTML_QuickForm('login');
     $form->addElement('header', 'login_header', 'Login');
     $form->addElement('text', 'username', 'Login:'******'size' => 25, 'maxlength' => 40));
     $form->addRule('username', 'login cannot be empty', 'required', null, 'client');
     $form->addElement('password', 'password', 'Password:'******'size' => 25, 'maxlength' => 40));
     $form->addRule('password', 'password cannot be empty', 'required', null, 'client');
     $form->addElement('submit', 'submit_username', 'Login');
     $form->addElement('header', 'new_users', 'New Users Only');
     $form->addElement('password', 'password_again', 'Confirm Password:'******'size' => 25, 'maxlength' => 40));
     $form->addElement('text', 'email', 'email:', array('size' => 25, 'maxlength' => 80));
     $form->addRule('email', 'invalid email address', 'email', null, 'client');
     $form->addElement('text', 'realname', 'Real Name:', array('size' => 25, 'maxlength' => 80));
     $form->addElement('submit', 'newaccount', 'Create new account');
     $form->addElement('hidden', 'redirect', $this->redirect);
     $this->form =& $form;
     if ($form->validate()) {
         $this->processForm();
         return;
     }
     // only get here if form hasn't been submitted
     echo '<h2><a href="#">Log In or Create a New Account</a></h2>';
 }
Exemple #9
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new HTML_QuickForm('', 'post', $this->url());
     $form->addElement('text', 'email', 'E-mail');
     $radio[0] =& HTML_QuickForm::createElement('radio', null, null, 'tilmeld', '1');
     $radio[1] =& HTML_QuickForm::createElement('radio', null, null, 'frameld', '2');
     $form->addGroup($radio, 'mode', null, null);
     $form->addElement('submit', null, 'Gem');
     $form->setDefaults(array('mode' => 1));
     $form->addRule('email', 'Du skal skrive en e-mail-adresse', 'required', null);
     return $this->form = $form;
 }
$addr['zip'] =& HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
$addr['city'] =& HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
$form->addGroup($addr, 'address', 'Zip, city:');
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement('select', 'country', 'Country:', $select);
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'destination', 'Destination:', array('&nbsp;', '<br />'));
// Other elements
$form->addElement('checkbox', 'news', '', " Check this box if you don't want to receive our newsletter.");
$form->addElement('reset', 'reset', 'Reset');
$form->addElement('submit', 'submit', 'Register');
// Adds some validation rules
$form->addRule('email', 'Email address is required', 'required');
$form->addGroupRule('name', 'Name is required', 'required');
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
$form->addRule('country', 'Country is a required field', 'required');
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
$AddrRules['zip'][0] = array('Zip code is required', 'required');
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
$AddrRules['city'][0] = array('City is required', 'required');
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
$form->addGroupRule('address', $AddrRules);
// Tries to validate the form
if ($form->validate()) {
    // Form is validated, then freezes the data
    $form->freeze();
Exemple #11
0
 /**
  * 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;
 }
     $userTemplates[$value['id']] = $value['id'];
 }
 if (!in_array($_GET['template_id'], $userTemplates)) {
     $message = _CERTIFICATETEMPLATENOACCESS;
     $message_type = 'failure';
     $redirectUrl = "" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&message=" . urlencode($message);
     $redirectUrl .= "&message_type=" . $message_type . "&reset_popup=1";
     $smarty->assign('T_CLONE_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl);
 }
 $tid = $_GET['template_id'];
 $postTarget = basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=clone_certificate_template&template_id=' . $tid;
 $form = new HTML_QuickForm("clone_certificate_template_form", "post", $postTarget, "", null, true);
 $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
 // Register this rule for checking user input with eF_checkParameter
 $form->addElement('text', 'certificate_name', _CERTIFICATENAME, 'class="inputText"');
 $form->addRule('certificate_name', _THEFIELD . ' "' . _CERTIFICATENAME . '" ' . _ISMANDATORY, 'required', null, 'client');
 $form->addElement('submit', 'clone_certificate_template', _SAVE, 'class="flatButton"');
 if ($form->isSubmitted() && $form->validate()) {
     $cloneTemplate = eF_getTableData("certificate_templates", "certificate_xml", "id=" . $tid);
     $formValues = $form->exportValues();
     $dbFields = array("certificate_name" => $formValues['certificate_name'], "certificate_xml" => $cloneTemplate[0]['certificate_xml'], "certificate_type" => "course", "users_LOGIN" => $GLOBALS['currentUser']->user['login']);
     if ($cloned = eF_insertTableData("certificate_templates", $dbFields)) {
         $message = _SUCCESSFULLYCLONECERTIFICATETEMPLATE;
         $message_type = 'success';
     } else {
         $message = _PROBLEMCLONECERTIFICATETEMPLATE;
         $message_type = 'failure';
     }
     $redirectUrl = "" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&message=" . urlencode($message);
     $redirectUrl .= "&message_type=" . $message_type . "&reset_popup=1&tid=" . $cloned;
     $smarty->assign('T_CLONE_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl);
Exemple #13
0
    public function execute() {

       	$request = $this->getContext()->getRequest();

    	$postLoginUser = $request->getParameter('user');
    	$postLoginId = $postLoginUser['id'];

    	$id = $request->getParameter('id');

		$login = $this->getContext()->getUser()->getAttribute('Login');
    	$loginRole = $this->getLoginRole();

    	if ($loginRole == 'editor'){
    		if ($id != $login->id && $postLoginId != $login->id){

				$this->log("Unauthorized attempt edit login record. Login id: $id, user name: ". $login->name);
    					
    			$this->getContext()->getController()->forward('Default', "Secure");	
    		}
    	}

//    	$this->checkAdminAuth();

		if($request->getParameter('cancel')) {

			if ($loginRole == 'admin'){
				$this->getContext()->getController()->forward('Default', "ListLogin");
			} else {
				header("Location:Search?searchFor=Member");
			}

			return View::NONE;
		}
        
    	$form = new HTML_QuickForm("loginForm", 'post');

    	$loginDao = new BaseDao("Login");

		$affDao = new BaseDao("Affiliate"); 

    	if ($id){
    		$user = $loginDao->get($id);	

			$this->log("Editing login: "******" ,name: ".$user->name);
			$this->log("Editing login: "******" ,name: ".$user->name, true);

    		$affiliate = $affDao->getPattern();
    		$affiliate->editor = $user->id;
			$currentAffs = $affDao->search($affiliate);
			$affIds = $this->getListOfCertainFieldValues($currentAffs, 'id');

    		$form->setDefaults(array('user' => (array) $user, 
    								 "password2" => $user->password,
    								 "affiliates" => $affIds));
    	} else{
			$this->log("Creating new login.", true);

	    	$user = $loginDao->getPattern();
    	}

		$request->setAttribute('user', $user);

		$roleDao = new BaseDao("Role"); 
		$roles = $this->prepareDropdown($roleDao->search(), 'id', 'name');

		$affs = $this->prepareDropdown($affDao->searchWhereWithOrder($affDao->getPattern(), "1=1", 'name'), 'id', 'name');

		$form->addElement("text", "user[name]", "Name:", array('size' => 50, "maxlength" => 255));
		$form->addElement("text", "user[login]", "Login:"******"maxlength" => 255));
		$form->addElement("password", "user[password]", "Password:"******"maxlength" => 255));
		$form->addElement("password", "password2", "Repeat Password:"******"maxlength" => 255));
		$form->addElement('text', "user[email]", 'Email:', array('size' => 50, "maxlength" => 255));
		$form->addElement('select', "user[roleFid]", "User Role:", $roles);
		$form->addElement('select', "affiliates", "Affiliate:", $affs, array('multiple' => 'multiple', 'id' => "affDropdown") );
		$form->addElement('checkbox', "user[nationalOfficer]", "National Officer:", "", array());

		$element =& $form->getElement("affiliates");
		$element->setSize(5);
		if ($loginRole != 'admin') $element->freeze();

		$form->addElement('hidden', 'user[id]');
		$form->addElement("submit", null, "Save Changes");
		$form->addElement("submit", 'cancel', "Cancel");

		$form->addRule("user[name]", "Please enter your name.", 'required', null);
		$form->addRule("user[login]", "Login can't be blank.", 'required', null);
		$form->addRule("user[password]", "You haven't entered password.", 'required', null);
		$form->addRule("user[email]", "Please enter your email.", 'required', null);
		$form->addRule("user[email]", "Please enter valid email.", 'email', null);

		$form->addFormRule(array(&$this, "validatePassword"));
		$form->addFormRule(array(&$this, "checkEmail"));
		$form->addFormRule(array(&$this, "max5admins"));



		if (!$form->validate()) {

			$request->setAttribute("editLoginForm", $form->toHtml());

			return 'Form';
		}
		else{	
			$reqUser = $request->getParameter('user');

			$user->id = $reqUser['id'];
			$user->login = $reqUser['login'];
			$user->password = $reqUser['password'];
			$user->email = $reqUser['email'];
			$user->roleFid = $reqUser['roleFid'];
			$user->name = $reqUser['name'];

			if ($reqUser["nationalOfficer"]){
				$this->log("Assigng new national Officer: ".$user->login." ,name: ".$user->name, true);

				$user->nationalOfficer = 1;		
				$db = new PearDBStorage();
				$db->invoke("update logins set nationalOfficer=0 where nationalOfficer=1");
			}

			$loginDao->save($user);

			$affiliates = $reqUser = $request->getParameter("affiliates");
			$affText = "";
			if ($affiliates){
				foreach($affiliates as $affId){
					$affiliate = $affDao->get($affId);
					$affiliate->editor = $user->id;
					$affDao->save($affiliate);

					$affText .= $affiliate->name." ";
				}
			}

			if (!$user->id){

				$emailMessage = "Dear ".$user->name.":\n\n
				You have been assigned the role of Editor in the American Council of the Blind membership database for ".$affText.".\n
				Your User ID is ".$user->login." and your default password is ".$user->password.".  Please change this password immediately when you log into the database.\n\n
				Thank you for your work both in your affiliate and with the ACB management of the most precious resource we have:  Our members.\n\n
				Sincerely,\n\n
				The Database Management Team";

				mail($user->email, "ACB mail", $emailMessage);
			}

			if ($loginRole == 'admin'){
				$this->log("Saving login: "******" ,name: ".$user->name, true);

				$this->getContext()->getController()->forward('Default', "ListLogin");
			} else {
				$this->log("Saving login: "******" ,name: ".$user->name);

				header("Location:Search?searchFor=Member");
			}

			return View::NONE;
		}
    }
Exemple #14
0
} elseif (isset($_GET['add_lesson']) || isset($_GET['edit_lesson']) && eF_checkParameter($_GET['edit_lesson'], 'id')) {
    //The administrator asked to add or edit a lesson
    //Set the form post target in correspondance to the current function we are performing
    if (isset($_GET['add_lesson'])) {
        $post_target = 'add_lesson=1';
    } else {
        $post_target = 'edit_lesson=' . $_GET['edit_lesson'];
        $smarty->assign("T_LESSON_OPTIONS", array(array('text' => _LESSONSETTINGS, 'image' => "16x16/generic.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=lessons&lesson_settings=" . $_GET['edit_lesson'])));
    }
    $form = new HTML_QuickForm("add_lessons_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=lessons&" . $post_target, "", null, true);
    //Build the form
    $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
    //Register our custom input check function
    $form->addElement('text', 'name', _LESSONNAME, 'class = "inputText"');
    //The lesson name, it is required and of type 'text'
    $form->addRule('name', _THEFIELD . ' "' . _LESSONNAME . '" ' . _ISMANDATORY, 'required', null, 'client');
    $form->addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'noscript');
    if ($GLOBALS['configuration']['onelanguage'] != true) {
        $form->addElement('select', 'languages_NAME', _LANGUAGE, EfrontSystem::getLanguages(true, true));
        //Add a language select box to the form
    }
    try {
        //If there are no direction set, redirect to add direction page
        $directionsTree = new EfrontDirectionsTree();
        if (sizeof($directionsTree->tree) == 0) {
            eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_YOUMUSTFIRSTCREATEDIRECTION) . '&message_type=failure');
            exit;
        }
        $form->addElement('select', 'directions_ID', _DIRECTION, $directionsTree->toPathString());
        //Append a directions select box to the form
    } catch (Exception $e) {
Exemple #15
0
     include "file_manager.php";
 } catch (Exception $e) {
     handleNormalFlowExceptions($e);
 }
 //These are the entities that will be automatically replaced in custom header/footer
 $systemEntities = array('logo.png', '#siteName', '#siteMoto', '#languages', '#path', '#version');
 $smarty->assign("T_SYSTEM_ENTITIES", $systemEntities);
 //And these are the replacements of the above entities
 $systemEntitiesReplacements = array('{$T_LOGO}', '{$T_CONFIGURATION.site_name}', '{$T_CONFIGURATION.site_motto}', '{$smarty.capture.header_language_code}', '{$title}', '{$smarty.const.G_VERSION_NUM}');
 $load_editor = true;
 $layout_form = new HTML_QuickForm("add_block_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=themes&theme=" . $layoutTheme->{$layoutTheme->entity}['id'] . (isset($_GET['edit_block']) ? '&edit_block=' . $_GET['edit_block'] : '&add_block=1') . (isset($_GET['theme_layout']) ? '&theme_layout=' . $_GET['theme_layout'] : ''), "", null, true);
 $layout_form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
 $layout_form->addElement('text', 'title', _BLOCKTITLE, 'class = "inputText"');
 $layout_form->addElement('textarea', 'content', _BLOCKCONTENT, 'id="editor_data" class = "mceEditor" style = "width:100%;height:300px;"');
 $layout_form->addElement('submit', 'submit_block', _SAVE, 'class = "flatButton"');
 $layout_form->addRule('title', _THEFIELD . ' "' . _BLOCKTITLE . '" ' . _ISMANDATORY, 'required', null, 'client');
 if (isset($_GET['edit_block'])) {
     $customBlocks[$_GET['edit_block']]['content'] = file_get_contents($basedir . $customBlocks[$_GET['edit_block']]['name'] . '.tpl');
     $layout_form->setDefaults($customBlocks[$_GET['edit_block']]);
     $layout_form->freeze(array('name'));
 }
 if ($layout_form->isSubmitted() && $layout_form->validate()) {
     $values = $layout_form->exportValues();
     if (isset($_GET['edit_block'])) {
         // not rename blocks by editing. It created many unused files
         $values['name'] = $customBlocks[$_GET['edit_block']]['name'];
     } else {
         $values['name'] = time();
         //Use the timestamp as name
     }
     $block = array('name' => $values['name'], 'title' => $values['title']);
Exemple #16
0
                                $message_type = 'success';
                                eF_redirect("" . $_SESSION['s_type'] . ".php?ctg=social&op=timeline&lessons_ID=" . $_GET['lessons_ID'] . "&all=1&message=" . $message . "&message_type=" . $message_type);
                                exit;
                                //ON INSERTING OR EDITING A LESSONTIMELINE TOPIC
                            } else {
                                if (isset($_GET['add_topic']) || isset($_GET['edit_topic'])) {
                                    if (isset($_GET['add_topic'])) {
                                        $form = new HTML_QuickForm("topic_form", "post", $_SESSION['s_type'] . ".php?ctg=social&op=timeline&lessons_ID=" . $_SESSION['s_lessons_ID'] . "&add_topic=1", "", null, true);
                                    } elseif (eF_checkParameter($_GET['edit_topic'], 'id')) {
                                        $form = new HTML_QuickForm("topic_form", "post", $_SESSION['s_type'] . ".php?ctg=social&op=timeline&lessons_ID=" . $_SESSION['s_lessons_ID'] . "&edit_topic=" . $_GET['edit_topic'], "", null, true);
                                        $topic = eF_getTableData("lessons_timeline_topics", "title", "id ='" . $_GET['edit_topic'] . "'");
                                    }
                                    $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
                                    //Register this rule for checking user input with our function, eF_checkParameter
                                    $form->addElement('text', 'topic_description', _LESSONTIMELINETOPIC, 'id="topic_description" class = "inputText" tabindex="1"');
                                    $form->addRule('topic_description', _THEFIELD . ' ' . _LESSONTIMELINETOPIC . ' ' . _ISMANDATORY, 'required', null, 'client');
                                    // Hidden for maintaining the previous_url value
                                    $form->addElement('hidden', 'previous_url', null, 'id="previous_url"');
                                    $previous_url = getenv('HTTP_REFERER');
                                    if ($position = strpos($previous_url, "&message")) {
                                        $previous_url = substr($previous_url, 0, $position);
                                    }
                                    $form->setDefaults(array('previous_url' => $previous_url));
                                    $form->addElement('submit', 'submit_topic_details', _SUBMIT, 'class = "flatButton" tabindex="2"');
                                    if (isset($_GET['edit_topic'])) {
                                        $form->setDefaults(array('topic_description' => $topic[0]['title']));
                                    }
                                    $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
                                    $renderer->setRequiredTemplate('{$html}{if $required}
							&nbsp;<span class = "formRequired">*</span>
						{/if}');
<?php

// no direct access
defined('PARENT_FILE') or die('Restricted access');
if ($this->authorize()) {
    if ($this->registry->params['id']) {
        $rows = $this->getResult('post_level_id, post_level', $ushop->db_name . 'post_levels', null, array('where' => 'post_level_id = ' . $this->registry->params['id']));
        $form = new HTML_QuickForm('edit_level', 'post', $_SERVER['REQUEST_URI']);
        // Remove name attribute for xhtml strict compliance.
        $form->removeAttribute('name');
        $form->addElement('html', '<fieldset>');
        $form->addElement('header', 'edit_level', 'Edit Post Level');
        $form->addElement('text', 'post_level', 'Post Level:', array('size' => 10, 'maxlength' => 10, 'class' => 'inputbox'));
        $form->addElement('html', '</fieldset>');
        $form->addRule('post_level', 'Please enter a post level', 'required');
        $form->addRule('post_level', 'Post Levels have to be a number.', 'numeric');
        if ($form->validate()) {
            $menuBar = array();
            $form->freeze();
            $values = $form->process(array(&$this, 'formValues'), false);
            $menuBar['back'] = '/ushop/postage/overview';
            //check then enter the record.
            $res = $this->update($values, $ushop->db_name . 'post_levels', array('where' => 'post_level_id=' . $this->registry->params['id']));
            if ($res) {
                $params['TYPE'] = 'pass';
                $params['MESSAGE'] = '<h2>Post Level was successfully edited.</h2>';
            } else {
                $params['TYPE'] = 'error';
                $params['MESSAGE'] = '<h2>Post Level could not be edited due to an error.</h2>';
            }
            // done!
function manage_display($task)
{
    global $cfg, $db, $cache;
    if ($task == '') {
        $task = 'status';
    }
    // Verify that the user has management perms for the selected contest
    $res =& db_query('contest_by_id', $_GET['id']);
    $res->fetchInto($row);
    $res->free();
    if ($_SESSION['user_id'] != $row['manager'] && !auth_user_in_group('Administrators')) {
        error("Access denied. You are not the contest-manager for this contest.");
    }
    switch ($task) {
        case 'status':
            $table = new HTML_Table();
            // Re-use $row from above
            if ($row['show_future'] == 1) {
                $status = 'Hidden (not activated yet)';
            } else {
                if ($row['begin_future'] == 1) {
                    $status = 'Not started';
                } else {
                    if ($row['end_future'] == 1) {
                        $status = 'Running';
                    } else {
                        $status = 'Ended';
                    }
                }
            }
            $table->addRow(array('Contest status: ', $status), null, 'TH');
            $table->addRow(array('Name: ', $row['name']));
            $table->addRow(array('Description: ', $row['description']));
            $table->addRow(array('Activation time: ', $row['show_time']));
            $table->addRow(array('Begin time: ', $row['begin_time']));
            $table->addRow(array('End time: ', $row['end_time']));
            if ($row['team_size'] != 1) {
                $table->addRow(array('Max size of team: ', $row['team_size']));
                $prefix = 'Teams';
            } else {
                $table->addRow(array('Individual event: ', 'Yes'));
                $prefix = 'Participants';
            }
            // No. of registered teams
            $res =& db_query('count_teams_by_contest_id', $_GET['id']);
            $res->fetchInto($row);
            $res->free();
            $table->addRow(array($prefix . ' registered: ', $row['count']));
            // No. of teams logged in
            $res =& db_query('count_last_teams_by_contest_id', $_GET['id']);
            $res->fetchInto($row);
            $res->free();
            $table->addRow(array($prefix . ' seen in last 30 minutes: ', $row['count']));
            $table->altRowAttributes(1, null, array("class" => "altrow"));
            echo '<div class="overflow">' . $table->toHtml() . '</div>';
            break;
        case 'problems':
            // display problem info as table
            $table = new HTML_Table();
            $res =& db_query('problems_by_contest_id', $_GET['id']);
            if (!$res->fetchInto($row)) {
                ?>
<p>No problems added yet.</p>			
			<?php 
            } else {
                // extra attributes
                $row['content'] = null;
                $row['actions'] = null;
                $table->addRow(array_keys($row), null, 'TH');
                while ($row) {
                    $row['content'] = "<a href=\"index.php?view=manage&amp;task=show_problem&amp;id={$_GET['id']}&amp;prob_id={$row['prob_id']}\">show</a>";
                    $row['actions'] = "<a href=\"index.php?view=manage&amp;task=edit_problem&amp;id={$_GET['id']}&amp;prob_id={$row['prob_id']}\">edit</a>, " . "<a href=\"index.php?view=manage&amp;task=del_problem&amp;id={$_GET['id']}&amp;prob_id={$row['prob_id']}\">delete</a>";
                    $table->addRow(array_values($row));
                    $res->fetchInto($row);
                }
                $res->free();
                // display tables
                $table->altRowAttributes(1, null, array("class" => "altrow"));
                echo '<div class="overflow">' . $table->toHtml() . '</div>';
            }
            echo "<hr />";
            // form for adding a problem
            $form = new HTML_QuickForm('problemAddForm', 'post', selflink());
            $form->addElement('header', null, 'Add a problem');
            $form->addElement('text', 'prob_id', 'Name (one word ID): ');
            $form->addElement('text', 'summary', 'Summary: ');
            $form->addElement('text', 'weight', 'Points weightage: ');
            $form->addElement('text', 'time_limit', 'Time limit: ');
            $form->addElement('text', 'mem_limit', 'Memory limit: ');
            $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): ');
            $elem->setRows(10);
            $elem->setCols(80);
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('prob_id', 'trim');
            $form->applyFilter('summary', 'trim');
            $form->applyFilter('weight', 'trim');
            $form->applyFilter('time_limit', 'trim');
            $form->applyFilter('mem_limit', 'trim');
            $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client');
            $form->addRule('summary', 'Problem summary is required', 'required', null, 'client');
            $form->addRule('weight', 'Points weightage is required', 'required', null, 'client');
            $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client');
            $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client');
            $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client');
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $errs = problem_check($data['content']);
                if ($errs == null) {
                    $data['contest_id'] = $_GET['id'];
                    $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_INSERT);
                    if (PEAR::isError($res)) {
                        error($res->toString());
                    }
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm');
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob');
                    redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
                } else {
                    ?>
<p><b>Error:</b> The problem could not be added due to the following errors encountered while
parsing the problem XML file. Please fix them and try submitting again.</p>
				<?php 
                    echo "<ol class=\"errors\">\n";
                    foreach ($errs as $line) {
                        echo "<li>{$line}</li>\n";
                    }
                    echo "</ol>\n<hr />\n";
                }
            }
            $form->display();
            break;
        case 'del_problem':
            db_query('del_problem_by_id', array($_GET['prob_id'], $_GET['id']));
            redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
            break;
        case 'edit_problem':
            $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id']));
            $res->fetchInto($row);
            $res->free();
            // Get XML content too
            $res =& db_query('problem_content_by_id', array($_GET['prob_id'], $_GET['id']));
            $res->fetchInto($row2);
            $res->free();
            $row['content'] =& $row2['content'];
            // form for editing a problem
            $form = new HTML_QuickForm('problemAddForm', 'post', selflink());
            $form->addElement('header', null, 'Edit a problem');
            $form->addElement('text', 'prob_id', 'Name (one word ID): ');
            $form->addElement('text', 'summary', 'Summary: ');
            $form->addElement('text', 'weight', 'Points weightage: ');
            $form->addElement('text', 'time_limit', 'Time limit: ');
            $form->addElement('text', 'mem_limit', 'Memory limit: ');
            $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): ');
            $elem->setRows(10);
            $elem->setCols(80);
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('prob_id', 'trim');
            $form->applyFilter('summary', 'trim');
            $form->applyFilter('weight', 'trim');
            $form->applyFilter('time_limit', 'trim');
            $form->applyFilter('mem_limit', 'trim');
            $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client');
            $form->addRule('summary', 'Problem summary is required', 'required', null, 'client');
            $form->addRule('weight', 'Points weightage is required', 'required', null, 'client');
            $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client');
            $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client');
            $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client');
            $form->setDefaults($row);
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $errs = problem_check($data['content']);
                if ($errs == null) {
                    //$data['contest_id'] = $_GET['id'];
                    $data['version'] = $row['version'] + 1;
                    // increment version
                    $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id'] . " AND prob_id='" . $data['prob_id'] . "'");
                    if (PEAR::isError($res)) {
                        error($res->toString());
                    }
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm');
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob');
                    redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
                } else {
                    ?>
<p><b>Error:</b> The changes could not be saved due to the following errors encountered while
parsing the problem XML file. Please fix them and try submitting again.</p>
				<?php 
                    echo "<ol class=\"errors\">\n";
                    foreach ($errs as $line) {
                        echo "<li>{$line}</li>\n";
                    }
                    echo "</ol>\n<hr />\n";
                }
            }
            $form->display();
            break;
        case 'show_problem':
            $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id']));
            $res->fetchInto($problem);
            $res->free();
            problem_display($problem);
            break;
        case 'settings':
            // Re-using $row from above
            // form for editing the contest
            $form = new HTML_QuickForm('contestEditForm', 'post', selflink());
            $form->addElement('header', null, "Edit contest {$row['name']} (id: {$row['contest_id']})");
            $form->addElement('text', 'name', 'Name: ');
            $form->addElement('text', 'description', 'Description: ');
            $elem =& $form->addElement('text', 'team_size', 'Size of team: ');
            $elem->setValue('1');
            $date = getdate();
            $form->addElement('date', 'show_time', 'Activation time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'begin_time', 'Begin time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'end_time', 'End time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('text', 'rules', 'Rules URL: ');
            $form->addElement('submit', null, 'Submit');
            // convert date format and store default values
            $row['show_time'] = sql2form_datetime($row['show_time']);
            $row['begin_time'] = sql2form_datetime($row['begin_time']);
            $row['end_time'] = sql2form_datetime($row['end_time']);
            $form->setDefaults($row);
            $form->applyFilter('name', 'trim');
            $form->applyFilter('description', 'trim');
            $form->applyFilter('team_size', 'trim');
            $form->addRule('name', 'Contest name is required.', 'required', null, 'client');
            $form->addRule('team_size', 'Team size is required.', 'required', null, 'client');
            // validate or display form
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $data['show_time'] = form2sql_datetime($data['show_time']);
                $data['begin_time'] = form2sql_datetime($data['begin_time']);
                $data['end_time'] = form2sql_datetime($data['end_time']);
                $db->autoExecute('contests', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id']);
                if (PEAR::isError($res)) {
                    error($db->toString());
                }
                redirect('index.php?view=manage&id=' . $_GET['id']);
            } else {
                $form->display();
            }
            break;
        case 'submissions':
            // Re-use $row from above
            if ($row['end_future'] != '1') {
                // Contest has ended, show system test button
                if ($row['tested'] != 1) {
                    ?>
    <p>Contest has ended. 
    <a class="button" href="index.php?view=manage&amp;&amp;task=test&amp;updateratings=false&amp;id=<?php 
                    echo $_GET['id'];
                    ?>
">Test and grade all submissions.</a>
    <a class="button" href="index.php?view=manage&amp;task=test&amp;updateratings=true&amp;id=<?php 
                    echo $_GET['id'];
                    ?>
">Update Ratings</a>

    </p>
                <?php 
                } else {
                    ?>
    <p>Contest has ended and system tests are over.
    <a class="button" href="index.php?view=manage&amp;task=test&amp;id=<?php 
                    echo $_GET['id'];
                    ?>
">Re-run system tests.</a>
    </p>
                <?php 
                }
            }
            // Show table of all solutions in the contest
            $table = new HTML_Table();
            $res =& db_query('solutions_by_contest_id', $_GET['id']);
            if (!$res->fetchInto($row)) {
                // If no solutions in yet
                ?>
<p>Sorry, no solutions have been submitted yet.</p>
			<?php 
            } else {
                $table->addRow(array_keys($row), null, 'TH');
                if ($row['score'] == '') {
                    $row['score'] = 'n/a';
                }
                if ($row['passed'] == '') {
                    $row['passed'] = 'n/a';
                }
                $table->addRow(array_values($row));
                while ($res->fetchInto($row)) {
                    if ($row['score'] == '') {
                        $row['score'] = 'n/a';
                    }
                    if ($row['passed'] == '') {
                        $row['passed'] = 'n/a';
                    }
                    $table->addRow(array_values($row));
                }
                $table->altRowAttributes(1, null, array("class" => "altrow"));
                echo '<div class="overflow">' . $table->toHtml() . '</div>';
            }
            break;
        case 'test':
            require_once 'tester.php';
            ob_end_clean();
            html_reset();
            html_header(null, $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '.css', $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '-ie.css', null, "submit_frame");
            $contest_id = $_GET['id'];
            $update_ratings = $_GET['updateratings'];
            session_write_close();
            test_contest($update_ratings, $contest_id);
            echo ' <a class="white" href="index.php?view=statistics&amp;task=contest&amp;id=' . $_GET['id'] . '">See the results.</a>';
            html_footer();
            exit;
    }
}
Exemple #19
0
}
/* --------------------------------------------------- End of Sign up part--------------------------------------------------- */
/* -------------------------------------------------------Contact part--------------------------------------------------------- */
if (isset($_GET['ctg']) && $_GET['ctg'] == 'contact') {
    //The user asked to display the contact form
    if (eF_checkSpam() == true) {
        $message = _SPAMDETECTION;
        $message_type = 'failure';
        eF_redirect(basename($_SERVER['PHP_SELF']) . '?message=' . urlencode($message) . '&message_type=' . $message_type);
    }
    $smarty->assign('T_CTG', 'contact');
    $form = new HTML_QuickForm("contact_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=contact", "", "class = 'indexForm'", true);
    $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
    //Register this rule for checking user input with our function, eF_checkParameter
    $form->addElement('text', 'email', _YOUREMAIL, 'class = "inputText"');
    $form->addRule('email', _THEFIELD . ' "' . _EMAIL . '" ' . _ISMANDATORY, 'required');
    $form->addRule('email', _INVALIDFIELDDATA, 'checkParameter', 'email');
    $form->addElement('text', 'message_subject', _MESSAGESUBJECT, 'class = "inputText"');
    //$form -> addRule('message_subject', _INVALIDFIELDDATA, 'checkParameter', 'text');
    $form->addElement('textarea', 'message_body', _TEXT, 'class = "inputText" id = "contact"');
    $form->addElement('submit', 'submit_contact', _SUBMIT, 'class = "flatButton"');
    if ($_GET['limit_reached']) {
        $form->setDefaults(array('message_subject' => _IWANTTOSIGNUPBUTMAXIMUMUSERSLIMITREACHED, 'message_body' => _IWANTTOSIGNUPBUTMAXIMUMUSERSLIMITREACHEDBODY));
    }
    if ($_SESSION['s_login']) {
        $form->setDefaults(array('email' => $currentUser->user['email']));
    }
    if ($form->isSubmitted()) {
        $fields_insert = array('users_LOGIN' => 'visitor', 'timestamp' => time(), 'action' => 'forms', 'comments' => 'contact', 'session_ip' => eF_encodeIP(eF_getRemoteAddress()));
        eF_insertTableData("logs", $fields_insert);
        if ($form->validate()) {
     $votes_distrib[$poll_votes[$i]['vote']]['vote']++;
 }
 for ($i = 0; $i < sizeof($votes_distrib); $i++) {
     $votes_distrib[$i]['perc'] = round($votes_distrib[$i]['vote'] / sizeof($poll_votes), 2);
     $votes_distrib[$i]['text'] = $poll_data[0]['options'][$i];
     $votes_distrib[$i]['width'] = $votes_distrib[$i]['perc'] * 200;
 }
 $smarty->assign("T_POLL_VOTES", $votes_distrib);
 $smarty->assign("T_POLL_TOTALVOTES", sizeof($poll_votes));
 $form = new HTML_QuickForm("poll_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=forum&poll=" . $_GET['poll'], "", null, true);
 //Build the form
 foreach ($poll_data[0]['options'] as $key => $option) {
     $group[] = HTML_Quickform::createElement('radio', 'vote', null, $option, $key);
 }
 $form->addGroup($group, 'options', '', '<br/>');
 $form->addRule('options', _PLEASEPICKANOPTION, 'required', null, 'client');
 $form->addElement('submit', 'submit_poll', _VOTE, 'class = "flatButton"');
 if ($form->isSubmitted() && $form->validate()) {
     $values = $form->exportValues();
     //pr($values);
     //debug();
     $res = eF_getTableData("f_users_to_polls", "*", "f_poll_ID=" . $values['options']['vote'] . " and users_LOGIN='******'login'] . "'");
     //debug(false);
     if (sizeof($res) > 0) {
         $message = _YOUHAVEALREADYVOTED;
         $message_type = 'failure';
     } else {
         $fields = array('f_poll_ID' => $_GET['poll'], 'users_LOGIN' => $_SESSION['s_login'], 'vote' => $values['options']['vote'], 'timestamp' => time());
         if (eF_insertTableData("f_users_to_polls", $fields)) {
             $message = _SUCCESFULLYVOTED;
             $message_type = 'success';
Exemple #21
0
 /**
  * _addForm 
  * 
  * Create add form
  * 
  * @access private
  * @return void
  */
 private function _addForm()
 {
     $form = new HTML_QuickForm('addAliasDomainForm', 'post', './?module=Main&class=AliasDomain&event=addNow');
     $form->addElement('text', 'domain', _('Real Domain'));
     $form->addElement('text', 'alias', _('Alias Domain'));
     $form->addElement('submit', 'submit', _('Add'));
     $form->addRule('domain', _('Please specify a Real Domain'), 'required', null, 'client');
     $form->addRule('alias', _('Please specify an Alias Domain'), 'required', null, 'client');
     $form->applyFilter('__ALL__', 'trim');
     return $form;
 }
Exemple #22
0
function buildWriteForm($options) {
    global $fyr_values, $fyr_postcode, $fyr_who, $fyr_type;
    global $fyr_representative, $fyr_voting_area, $fyr_date;
    global $fyr_postcode_editable, $fyr_group_msg, $fyr_valid_reps;
    global $rep_text, $cobrand, $cocode;

    $form_action = cobrand_url($cobrand, '/write', $cocode);
    $form = new HTML_QuickForm('writeForm', 'post', $form_action);
    
    if ($fyr_voting_area['name']=='United Kingdom')
        $fyr_voting_area['name'] = 'House of Lords';
 
    $write_header = '';
    if ($options['include_write_header']){
        $write_header = "<strong>Now Write Your Message:</strong> <small>(* means required)</small><br><br>";
    }

    if ($options['include_fao']){
        $write_header = '<strong>For the attention of:</strong>';
    }

    $stuff_on_left = <<<END
            <div class="letter-header">
            ${write_header}
            ${rep_text}
            <span>${fyr_voting_area['name']}</span>
            <span>$fyr_date</span>
            </div>
END;
    // special formatting for letter-like code, TODO: how do this properly with QuickHtml?
    if ($options['table_layout']){
        $form->addElement("html", "<tr><td valign=\"top\">$stuff_on_left</td><td align=\"right\">\n<table>"); // CSSify
    } else {
        $form->addElement("html", "<div class=\"highlight\">$stuff_on_left<ul class=\"data-input\">");
    }  

    $form->addElement('text', 'name', "Your name:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('name', 'Please enter your name', 'required', null, null);
    $form->applyFilter('name', 'trim');

    $form->addElement('text', 'writer_address1', "Address 1:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_address1', 'Please enter your address', 'required', null, null);
    $form->applyFilter('writer_address1', 'trim');

    $form->addElement('text', 'writer_address2', "Address 2:", array('size' => 20, 'maxlength' => 255));
    $form->applyFilter('writer_address2', 'trim');

    $form->addElement('text', 'writer_town', "Town/City:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_town', 'Please enter your town/city', 'required', null, null);
    $form->applyFilter('writer_town', 'trim');

    # Call it state so that Google Toolbar (and presumably others) can auto-fill.
    $form->addElement('text', 'state', 'County:', array('size' => 20, 'maxlength' => 255));
    $form->applyFilter('state', 'trim');

    if ($fyr_postcode_editable) {
        // House of Lords
        $form->addElement('text', 'pc', "UK postcode:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
        $form->addRule('pc', 'Please enter a UK postcode (<a href="/about-lords#ukpostcode" target="_blank">why?</a>)', 'required', null, null);
        $form->addRule('pc', 'Choose a valid UK postcode (<a href="/about-lords#ukpostcode" target="_blank">why?</a>)', new RulePostcode(), null, null);
        $form->applyFilter('pc', 'trim');
    } else {
        // All other representatives (postcode fixed as must be in constituency)
        $form->addElement('static', 'staticpc', 'UK postcode:', htmlentities($fyr_postcode));
    }

    $form->addElement('text', 'writer_email', "Your email:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_email', 'Please enter your email address', 'required', null, null);
    $invalid_email_message = cobrand_invalid_email_message($cobrand);
    if (!$invalid_email_message) {
         $invalid_email_message = 'Choose a valid email address';
    }
    $form->addRule('writer_email', $invalid_email_message, 'email', null, null);
    $form->applyFilter('writer_email', 'trim');

    $form->addElement('text', 'writer_email2', "Confirm email:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_email2', 'Please re-enter your email address', 'required', null, null);
    $form->applyFilter('writer_email2', 'trim');
    $form->addFormRule('compare_email_addrs');

    /* add additional text explaining why we ask for email address twice? */

    #    $form->addElement("html", "</td><td colspan=2><p style=\"margin-top: 0em; margin-bottom: -0.2em\"><em style=\"font-size: 75%\">Optional, to let your {$fyr_voting_area['rep_name']} contact you more easily:</em>"); // CSSify

    $form->addElement('text', 'writer_phone', "Phone:", array('size' => 20, 'maxlength' => 255));
    $form->applyFilter('writer_phone', 'trim');

    // special formatting for letter-like code, TODO: how do this properly with QuickHtml?
    if ($options['table_layout']){
        $form->addElement("html", "</table>\n</td></tr>");
    } else {
        $form->addElement("html", "</ul>");
    }

    $form->addElement('textarea', 'body', null, array('rows' => 15, 'cols' => 62));
    $form->addRule('body', 'Please enter your message', 'required', null, null);
    $form->addRule('body', 'Please enter your message', new RuleAlteredBodyText(), null, null);
    $form->addRule('body', 'Please sign at the bottom with your name, or alter the "Yours sincerely" signature', new RuleSigned(), null, null);
    $form->addRule('body', 'Your message is a bit too long for us to send', 'maxlength', OPTION_MAX_BODY_LENGTH);
    if (!$options['table_layout']){
        $form->addElement("html", "</div>");
    }

    add_all_variables_hidden($form, $fyr_values, $options);
    $preview_text = cobrand_preview_text($cobrand);
    if (!$preview_text) {
        $preview_text = 'Ready? Press the "Preview" button to continue:';
    }
    $preview_button_text = cobrand_preview_button_text($cobrand);
    if (!$preview_button_text) {   
        $preview_button_text = 'preview your Message';
    }
    $buttons[0] =& HTML_QuickForm::createElement('static', 'staticpreview', null,"<p class=\"action\" id=\"preview-submit\">$preview_text"); 
    $buttons[2] =& HTML_QuickForm::createElement('submit', 'submitPreview', $preview_button_text);
    $buttons[3] =& HTML_QuickForm::createElement('static', 'staticpreview', null, "</p>");     
    $form->addGroup($buttons, 'previewStuff', '', '', false);

    return $form;
}
Exemple #23
0
 /**
  * _findForm 
  * 
  * Generate find form
  * 
  * @access private
  * @return void
  */
 private function _findForm()
 {
     $form = new HTML_QuickForm('formFind', 'post', './?module=Main&class=Find&event=findNow');
     $form->addElement('text', 'domain', _('Domain'));
     $form->addElement('submit', 'submit', _('Find Domain'));
     $form->addRule('domain', _('Please a domain name'), 'required', 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() . ') &nbsp;<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);
     }
 }
Exemple #25
0
 function db2app()
 {
     require_once 'HTML/QuickForm.php';
     $form = new HTML_QuickForm('db2app');
     $res = mysql_list_dbs(db());
     if (!$res) {
         trigger_error(mysql_error(db()), E_USER_ERROR);
     }
     $options = array('' => 'Please Select Database ...');
     while ($row = mysql_fetch_row($res)) {
         $options[$row[0]] = $row[0];
     }
     $form->addElement('hidden', '-action', 'db2app');
     $form->addElement('select', 'database_name', 'Select Database' . $this->infoLink('archive2app.database_name'), $options, array('onchange' => 'listeners.database_name.onchange(this)'));
     $form->addElement('header', 'db_info', 'Database connection details');
     //$form->addElement('html', 'this is a test');
     $form->addElement('text', 'mysql_user', 'MySQL Username ' . $this->infoLink('archive2app.mysql_user'));
     $form->addElement('password', 'mysql_password', 'MySQL Password');
     //$form->addElement('radio','output_format','Output options','Download as tar.gz archive','download');
     //$form->addElement('radio','output_format','','Install on webserver in apps directory','install');
     $form->addElement('select', 'install_type', 'Installation type ' . $this->infoLink('archive2app.install_type'), array('' => 'Please select ...', 'download_tarball' => 'Download Tarball', 'ftp_install' => 'Install on server (using FTP)'), array('onchange' => "listeners.install_type.onchange(this);"));
     $form->addElement('header', 'ftp_info', 'FTP Connection Info');
     $form->addElement('text', 'ftp_host', 'FTP Host');
     $form->addElement('checkbox', 'ftp_ssl', 'Use SSL');
     $form->setDefaults(array('ftp_host' => DB_HOST));
     $form->addElement('text', 'ftp_path', 'FTP Path', array('size' => 50));
     $form->setDefaults(array('ftp_path' => $_SERVER['DOCUMENT_ROOT']));
     $form->addElement('text', 'ftp_username', 'FTP Username');
     $form->addElement('password', 'ftp_password', 'FTP Password');
     $form->addElement('submit', 'submit', 'Submit');
     $form->addRule('database_name', 'Please select a database', 'required', null, 'client');
     $form->addRule('mysql_user', 'Please enter a mysql username that the application can connect as.', 'required', null, 'client');
     $form->addRule('install_type', 'Please select an installation type and then click submit.', 'required', null, 'client');
     $form->setDefaults(array('mysql_user' => $_SERVER['PHP_AUTH_USER'], 'mysql_password' => $_SERVER['PHP_AUTH_PW']));
     if ($form->validate()) {
         $tarpath = $form->process(array(&$this, 'db2app__process'), true);
         header('Content-type: application/x-gzip');
         header('Content-Disposition: attachment; filename="' . basename($tarpath) . '.tar.gz"');
         echo file_get_contents($tarpath);
         exit;
     }
     require_once 'HTML/QuickForm/Renderer/Array.php';
     $renderer = new HTML_QuickForm_Renderer_Array(true, true, true);
     $form->accept($renderer);
     $context = $renderer->toArray();
     //print_r($context);
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     include 'install' . DIRECTORY_SEPARATOR . 'db2app.inc.php';
 }
         $form->addElement('select', 'embed_type', _EMBEDTYPE, array('iframe' => _INLINEIFRAME, 'popup' => _NEWWINDOWPOPUP), 'class = "inputSelect"');
         $form->addElement('text', 'popup_parameters', _POPUPPARAMETERS, 'class = "inputText" style = "width:600px"');
         if (strpos($currentUnit['data'], 'window.open') !== false) {
             preg_match("/\"scormFrameName\".*\"\\)'/U", $currentUnit['data'], $matches);
             $popupParameter = mb_substr($matches[0], mb_strpos($matches[0], '"scormFrameName", "') + mb_strlen('"scormFrameName", "'), mb_strpos($matches[0], ")'"));
             $form->setDefaults(array('popup_parameters' => $popupParameter));
         } else {
             $form->setDefaults(array('popup_parameters' => 'width=800,height=600,scrollbars=no,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,top="+(parseInt(parseInt(screen.height)/2) - 300)+",left="+(parseInt(parseInt(screen.width)/2) - 400)+"'));
         }
     }
     if (strpos($currentUnit['data'], 'iframe') !== false) {
         $form->setDefaults(array('embed_type' => 'iframe'));
     } else {
         $form->setDefaults(array('embed_type' => 'popup'));
     }
     $form->addRule('scorm_size', _INVALIDFIELDDATA, 'checkParameter', 'id');
     $smarty->assign("T_SCORM", true);
 }
 //Set elements rules
 $form->addRule('name', _THEFIELD . ' "' . _UNITNAME . '" ' . _ISMANDATORY, 'required', null, 'client');
 //The name is mandatory
 //$form -> addRule('ctg_type', _THEFIELD.' '._CONTENTTYPE.' '._ISMANDATORY, 'required', null, 'client');       //The content type is mandatry
 if (!isset($_GET['edit'])) {
     // changed in case parent unit is inactive
     $form->addRule('parent_content_ID', _THEFIELD . ' ' . _UNITPARENT . ' ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('parent_content_ID', _INVALIDID, 'numeric');
 }
 //Add the content's questions, in order to setup "complete with question" field
 if (sizeof($currentLesson->getQuestions()) > 0) {
     $pathStrings = $currentContent->toPathStrings();
     foreach ($currentLesson->getQuestions() as $key => $value) {
<?php

// no direct access
defined('PARENT_FILE') or die('Restricted access');
if ($this->authorize()) {
    $rate = $this->getResult('tax_rate', $ushop->db_name . 'tax_rates', null, array('where' => 'tax_rate_id = ' . $this->registry->params['id']));
    $form = new HTML_QuickForm('edit_tax_rate', 'post', $_SERVER['REQUEST_URI']);
    // Remove name attribute for xhtml strict compliance.
    $form->removeAttribute('name');
    $form->addElement('html', '<fieldset>');
    $form->addElement('header', 'edit_tax_rate', 'Edit Tax Rate');
    $form->addElement('text', 'tax_rate', 'Tax Rate:', array('size' => 5, 'maxlength' => 5, 'class' => 'inputbox'));
    $form->addElement('html', '</fieldset>');
    $form->addRule('tax_rate', 'Please enter a tax rate', 'required');
    $form->addRule('tax_code', 'Tax rates must be a number', 'numeric');
    if ($form->validate()) {
        $menuBar = array();
        $form->freeze();
        $values = $form->process(array(&$this, 'formValues'), false);
        $menuBar['back'] = '/ushop/tax/overview';
        //check then enter the record.
        $res = $this->update($values, $ushop->db_name . 'tax_rates', array('where' => 'tax_rate_id=' . $this->registry->params['id']));
        if ($res) {
            $params['TYPE'] = 'pass';
            $params['MESSAGE'] = '<h2>Tax rate was successfully edited.</h2>';
        } else {
            $params['TYPE'] = 'error';
            $params['MESSAGE'] = '<h2>Tax rate could not be edited due to an error.</h2>';
        }
        // done!
    } else {
Exemple #28
0
    if (!isset($currentUser->coreAccess['backup']) || $currentUser->coreAccess['backup'] == 'change') {
        $extraFileTools = array(array('image' => 'images/16x16/undo.png', 'title' => _RESTORE, 'action' => 'restore'));
    }
    $extraHeaderOptions = array(array('image' => 'images/16x16/go_into.png', 'title' => _BACKUP, 'action' => 'eF_js_showDivPopup(event, \'' . _BACKUP . '\', 0, \'backup_table\')'));
    /**The file manager*/
    include "file_manager.php";
} catch (Exception $e) {
    $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
    $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
    $message_type = 'failure';
}
$backup_form = new HTML_QuickForm("backup_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=backup', "", null, true);
$backup_form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$backup_form->addElement('text', 'backupname', null, 'class = "inputText"');
$backup_form->addRule('backupname', _THEFIELD . ' ' . _FILENAME . ' ' . _ISMANDATORY, 'required', null, 'client');
$backup_form->setDefaults(array("backupname" => "backup_" . date('Y_m_d_h.i.s', time())));
if ($GLOBALS['configuration']['version_hosted']) {
    $backupTypes = array("0" => _DATABASEONLY);
} else {
    $backupTypes = array("0" => _DATABASEONLY, "1" => _ALLDATABACKUP);
    if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
        $backupTypes[3] = _ALLDATASYSTEMBACKUP;
    }
}
$backup_form->addElement('select', 'backuptype', null, $backupTypes);
$backup_form->addElement('submit', 'submit_backup', _TAKEBACKUP, 'class = "flatButton" onclick = "$(\'backup_image\').show();"');
if ($backup_form->isSubmitted() && $backup_form->validate()) {
    $values = $backup_form->exportValues();
    try {
        $backupFile = EfrontSystem::backup($values['backupname'] . '.zip', $values['backuptype']);
Exemple #29
0
 // Remove name attribute for xhtml strict compliance.
 $form->removeAttribute('name');
 $s = $form->createElement('select', 'tax_rate_id', 'Tax Rate:');
 $opts[0] = 'Select One';
 $tax_rates = $ushop->getTaxRates(true);
 foreach ($tax_rates as $rate) {
     $opts[$rate->tax_rate_id] = ucwords($rate->tax_rate);
 }
 $form->addElement('html', '<fieldset>');
 $form->addElement('header', 'edit_tax_code', 'Edit Tax Code');
 $form->addElement('text', 'tax_code', 'Tax Code:', array('size' => 2, 'maxlength' => 2, 'class' => 'inputbox'));
 $s->loadArray($opts);
 $form->addElement($s);
 $form->addElement('text', 'description', 'Description:', array('size' => 20, 'maxlength' => 20, 'class' => 'inputbox'));
 $form->addElement('html', '</fieldset>');
 $form->addRule('description', 'Please enter a decription', 'required');
 $form->addRule('tax_code', 'Please enter a tax code', 'required');
 $form->addRule('tax_code', 'Tax codes have only letters', 'lettersonly');
 if ($form->validate()) {
     $form->freeze();
     $values = $form->process(array(&$this, 'formValues'), false);
     $menuBar['back'] = '/ushop/tax/overview';
     $values['tax_code'] = strtoupper($values['tax_code']);
     //check then enter the record.
     $res = $this->update($values, $ushop->db_name . 'tax_codes', array('where' => 'tax_code_id=' . $this->registry->params['id']));
     if ($res) {
         $params['TYPE'] = 'pass';
         $params['MESSAGE'] = '<h2>Tax code was successfully edited.</h2>';
     } else {
         $params['TYPE'] = 'error';
         $params['MESSAGE'] = '<h2>Tax code could not be edited due to an error.</h2>';
 }
 if ($currentEmployee->isSupervisor()) {
     $positions = array(_EMPLOYEE);
 } else {
     $positions = array(_EMPLOYEE, _SUPERVISOR);
 }
 $form = new HTML_QuickForm("placement_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=placements" . (isset($_GET['edit_placement']) ? "&edit_placement=" . $_GET['edit_placement'] : "&add_placement=1"), "", null, true);
 $form->addElement("select", "branch", _BRANCH, $branches, 'onchange = "updateBranchJobs(this)"');
 $form->addElement("select", "job", _JOBDESCRIPTION, $jobs, 'id="jobs_for_branch"');
 $form->addElement("select", "position", _POSITION, $positions, 'id="positions_for_branch"');
 if ($_change_placements_) {
     $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"');
 } else {
     $form->freeze();
 }
 $form->addRule('job', _PLEASESELECTAJOB, 'callback', create_function('$a', 'return ($a && $a != "#empty#");'));
 //The score must be between 0 and 100
 if ($_GET['edit_placement']) {
     $userJobs = $editedEmployee->getJobs();
     $job = $userJobs[$_GET['edit_placement']];
     $form->setDefaults(array('branch' => $job['branch_ID'], 'job' => $job['description'], 'position' => $job['supervisor']));
 }
 try {
     if ($form->isSubmitted() && $form->validate() && $_change_placements_) {
         $values = $form->exportValues();
         if ($values['job'] && $values['branch']) {
             require_once "module_hcd_tools.php";
             $newJob = eF_getJobDescriptionId($values['job'], $values['branch']);
             //pr($values);pr($_GET['edit_placement']);pr($newJob);echo "A";exit;
             if ($_GET['edit_placement']) {
                 if ($_GET['edit_placement'] != $newJob) {