Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 public function body()
 {
     ob_start();
     //create default module form
     print '<div class="title">Select modules to disable</div>';
     print 'Selected modules will be marked as not installed but uninstall methods will not be called. Any database tables and other modifications made by modules\' install methods will not be reverted.<br><br>';
     print 'To uninstall module please use Modules Administration in Application.';
     print '<hr/><br/>';
     $form = new HTML_QuickForm('modulesform', 'post', $_SERVER['PHP_SELF'] . '?' . http_build_query($_GET), '', null, true);
     $states = array(ModuleManager::MODULE_ENABLED => 'Active', ModuleManager::MODULE_DISABLED => 'Inactive');
     $modules = DB::GetAssoc('SELECT * FROM modules ORDER BY state, name');
     foreach ($modules as $m) {
         $name = $m['name'];
         $state = isset($m['state']) ? $m['state'] : ModuleManager::MODULE_ENABLED;
         if ($state == ModuleManager::MODULE_NOT_FOUND) {
             $state = ModuleManager::MODULE_DISABLED;
         }
         $form->addElement('select', $name, $name, $states);
         $form->setDefaults(array($name => $state));
     }
     $form->addElement('button', 'submit_button', 'Save', array('class' => 'button', 'onclick' => 'if(confirm("Are you sure?")) document.modulesform.submit();'));
     //validation or display
     if ($form->validate()) {
         //uninstall
         $vals = $form->exportValues();
         foreach ($vals as $k => $v) {
             if (isset($modules[$k]['state']) && $modules[$k]['state'] != $v) {
                 ModuleManager::set_module_state($k, $v);
             }
         }
     }
     $form->display();
     return ob_get_clean();
 }
 /**
  * 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));
 }
Exemplo n.º 4
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $this->table =& Dataface_Table::loadTable($query['-table']);
     $translations =& $this->table->getTranslations();
     foreach (array_keys($translations) as $trans) {
         $this->table->getTranslation($trans);
     }
     //print_r($translations);
     if (!isset($translations) || count($translations) < 2) {
         // there are no translations to be made
         trigger_error('Attempt to translate a record in a table "' . $this->table->tablename . '" that contains no translations.', E_USER_ERROR);
     }
     $this->translatableLanguages = array_keys($translations);
     $translatableLanguages =& $this->translatableLanguages;
     $this->languageCodes = new I18Nv2_Language($app->_conf['lang']);
     $languageCodes =& $this->languageCodes;
     $currentLanguage = $languageCodes->getName($app->_conf['lang']);
     if (count($translatableLanguages) < 2) {
         return PEAR::raiseError(df_translate('Not enough languages to translate', 'There aren\'t enough languages available to translate.'), DATAFACE_E_ERROR);
     }
     //$defaultSource = $translatableLanguages[0];
     //$defaultDest = $translatableLanguages[1];
     $options = array();
     foreach ($translatableLanguages as $lang) {
         $options[$lang] = $languageCodes->getName($lang);
     }
     unset($options[$app->_conf['default_language']]);
     $tt = new Dataface_TranslationTool();
     $form = new HTML_QuickForm('StatusForm', 'POST');
     $form->addElement('select', '--language', 'Translation', $options);
     $form->addElement('select', '--status', 'Status', $tt->translation_status_codes);
     //$form->setDefaults( array('-sourceLanguage'=>$defaultSource, '-destinationLanguage'=>$defaultDest));
     $form->addElement('submit', '--set_status', 'Set Status');
     foreach ($query as $key => $value) {
         $form->addElement('hidden', $key);
         $form->setDefaults(array($key => $value));
     }
     if ($form->validate()) {
         $res = $form->process(array(&$this, 'processForm'));
         if (PEAR::isError($res)) {
             return $res;
         } else {
             header('Location: ' . $app->url('-action=list&-sourceLanguage=&-destinationLanguage=&-translate=') . '&--msg=' . urlencode('Translation status successfully set.'));
             exit;
         }
     }
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $records =& $this->getRecords();
     df_display(array('form' => $out, 'translationTool' => &$tt, 'records' => &$records, 'translations' => &$options, 'context' => &$this), 'Dataface_set_translation_status.html');
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new HTML_QuickForm('calendar', 'post', 'http://kalendersiden.dk/generate.php');
     $form->addElement('text', 'month', 'Første måned');
     $form->addElement('text', 'months', 'Antal måneder');
     $form->addElement('text', 'year', 'Årstal');
     $form->addElement('hidden', 'pages');
     $form->addElement('hidden', 'format');
     $form->addElement('hidden', 'head');
     $form->addElement('hidden', 'color');
     $form->addElement('hidden', 'weeks');
     $form->addElement('hidden', 'userdata');
     $form->setDefaults(array('month' => date('m'), 'months' => 6, 'year' => date('Y'), 'pages' => 2, 'format' => 'portrait', 'head' => 'Vejle Idrætshøjskole', 'color' => '90 90 100:100 100 100:', 'weeks' => 't', 'userdata' => $this->getUserData()));
     $form->addElement('submit', null, 'Hent kalender');
     return $this->form = $form;
 }
Exemplo n.º 7
0
$form -> addElement('select', 'import_type', _IMPORTTYPE, array('efront'    => _EFRONTFILE,
'scorm2004' => _SCORM2004,
'scorm12'   => _SCORM12,
//'aicc'      => _AICC,
//'csv'       => _CSV,
'pdf'       => _PDF,
//'doc'       => _DOC,
'html'      => _HTML,
'xml'       => _XML,
'auto'      => _AUTODETECT));
*/
$form->addElement('advcheckbox', 'folders_to_hierarchy', _CONVERTFOLDERSTOHIERARCHY, null, 'class = "inputCheckbox"', array(0, 1));
$form->addElement('advcheckbox', 'uncompress_recursive', _UNCOMPRESSRECURSIVELYIMPORT, null, 'class = "inputCheckbox"', array(0, 1));
$form->addElement('advcheckbox', 'prompt_download', _FORCEDOWNLOADFILE, null, 'class = "inputCheckbox"', array(0, 1));
$form->addElement('static', 'note', _FORCEDOWNLOADFILEINFO);
$form->setDefaults(array('folders_to_hierarchy' => true));
//$form -> addElement('select', 'import_method', _IMPORTMETHOD, array(_UPLOADFILE, _FROMURL, _FROMPATH), 'onchange = "selectBox(this);"');
$form->addElement('file', 'import_file[0]', _IMPORTFILE);
for ($i = 1; $i < 10; $i++) {
    $form->addElement('file', "import_file[{$i}]", null);
}
$form->addElement('text', "import_url[0]", _IMPORTFROMURL, 'class = "inputText"');
for ($i = 1; $i < 10; $i++) {
    $form->addElement('text', "import_url[{$i}]", null, 'class = "inputText"');
}
$form->addElement('text', "import_path[0]", _IMPORTFROMPATH, 'class = "inputText"');
for ($i = 1; $i < 10; $i++) {
    $form->addElement('text', "import_path[{$i}]", null, 'class = "inputText"');
}
$form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
//getUploadMaxSize returns size in KB
Exemplo n.º 8
0
        $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 {
        $menuBar = array('cancel' => '/ushop/tax/overview', 'save' => null);
        $this->content .= $this->makeToolbar($menuBar, 24);
        $form->setDefaults(array('tax_rate' => $rate[0]->tax_rate));
        $renderer = new UthandoForm(TEMPLATES . $template);
        $renderer->setFormTemplate('form');
        $renderer->setHeaderTemplate('header');
        $renderer->setElementTemplate('element');
        $form->accept($renderer);
        // output the form
        $this->content .= $renderer->toHtml();
    }
    if (isset($params)) {
        $params['CONTENT'] = $this->makeMessageBar($menuBar, 24);
        $this->content .= $this->message($params);
    }
} else {
    header("Location:" . $this->get('config.server.web_url'));
    exit;
Exemplo n.º 9
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;
 }
Exemplo n.º 10
0
function ic2_display($path, $params)
{
    global $_conf, $ini, $thumb, $dpr, $redirect, $id, $uri, $file, $thumbnailer;
    if (P2_OS_WINDOWS) {
        $path = str_replace('\\', '/', $path);
    }
    if (strncmp($path, '/', 1) == 0) {
        $s = empty($_SERVER['HTTPS']) ? '' : 's';
        $to = 'http' . $s . '://' . $_SERVER['HTTP_HOST'] . $path;
    } else {
        $dir = dirname(P2Util::getMyUrl());
        if (strncasecmp($path, './', 2) == 0) {
            $to = $dir . substr($path, 1);
        } elseif (strncasecmp($path, '../', 3) == 0) {
            $to = dirname($dir) . substr($path, 2);
        } else {
            $to = $dir . '/' . $path;
        }
    }
    $name = basename($path);
    $ext = strrchr($name, '.');
    switch ($redirect) {
        case 1:
            header("Location: {$to}");
            exit;
        case 2:
            switch ($ext) {
                case '.jpg':
                    header("Content-Type: image/jpeg; name=\"{$name}\"");
                    break;
                case '.png':
                    header("Content-Type: image/png; name=\"{$name}\"");
                    break;
                case '.gif':
                    header("Content-Type: image/gif; name=\"{$name}\"");
                    break;
                default:
                    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
                        header("Content-Type: application/octetstream; name=\"{$name}\"");
                    } else {
                        header("Content-Type: application/octet-stream; name=\"{$name}\"");
                    }
            }
            header("Content-Disposition: inline; filename=\"{$name}\"");
            header('Content-Length: ' . filesize($path));
            readfile($path);
            exit;
        default:
            if (!class_exists('HTML_Template_Flexy', false)) {
                require 'HTML/Template/Flexy.php';
            }
            if (!class_exists('HTML_QuickForm', false)) {
                require 'HTML/QuickForm.php';
            }
            if (!class_exists('HTML_QuickForm_Renderer_ObjectFlexy', false)) {
                require 'HTML/QuickForm/Renderer/ObjectFlexy.php';
            }
            if (isset($uri)) {
                $img_o = 'uri';
                $img_p = $uri;
            } elseif (isset($id)) {
                $img_o = 'id';
                $img_p = $id;
            } else {
                $img_o = 'file';
                $img_p = $file;
            }
            $img_q = $img_o . '=' . rawurlencode($img_p);
            // QuickFormの初期化
            $_size = explode('x', $thumbnailer->calc($params['width'], $params['height']));
            $_constants = array('o' => sprintf('原寸 (%dx%d)', $params['width'], $params['height']), 's' => '作成', 't' => $thumb, 'd' => $dpr, 'u' => $img_p, 'v' => $img_o, 'x' => $_size[0], 'y' => $_size[1]);
            $_defaults = array('q' => $ini["Thumb{$thumb}"]['quality'], 'r' => '0');
            $mobile = Net_UserAgent_Mobile::singleton();
            $qa = 'size=3 maxlength=3';
            if ($mobile->isDoCoMo()) {
                $qa .= ' istyle=4';
            } elseif ($mobile->isEZweb()) {
                $qa .= ' format=*N';
            } elseif ($mobile->isSoftBank()) {
                $qa .= ' mode=numeric';
            }
            $_presets = array('' => 'サイズ・品質');
            foreach ($ini['Dynamic']['presets'] as $_preset_name => $_preset_params) {
                $_presets[$_preset_name] = $_preset_name;
            }
            $qf = new HTML_QuickForm('imgmaker', 'get', 'ic2_mkthumb.php');
            $qf->setConstants($_constants);
            $qf->setDefaults($_defaults);
            $qf->addElement('hidden', 't');
            $qf->addElement('hidden', 'u');
            $qf->addElement('hidden', 'v');
            $qf->addElement('text', 'x', '高さ', $qa);
            $qf->addElement('text', 'y', '横幅', $qa);
            $qf->addElement('text', 'q', '品質', $qa);
            $qf->addElement('select', 'p', 'プリセット', $_presets);
            $qf->addElement('select', 'r', '回転', array('0' => 'なし', '90' => '右に90°', '270' => '左に90°', '180' => '180°'));
            $qf->addElement('checkbox', 'w', 'トリム');
            $qf->addElement('checkbox', 'z', 'DL');
            $qf->addElement('submit', 's');
            $qf->addElement('submit', 'o');
            // FlexyとQurickForm_Rendererの初期化
            $_flexy_options = array('locale' => 'ja', 'charset' => 'cp932', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ic2/templates', 'numberFormat' => '');
            $flexy = new HTML_Template_Flexy($_flexy_options);
            $rdr = new HTML_QuickForm_Renderer_ObjectFlexy($flexy);
            $qf->accept($rdr);
            // 表示
            $flexy->setData('p2vid', P2_VERSION_ID);
            $flexy->setData('title', 'IC2::Cached');
            $flexy->setData('pc', !$_conf['ktai']);
            $flexy->setData('iphone', $_conf['iphone']);
            if (!$_conf['ktai']) {
                $flexy->setData('skin', $GLOBALS['skin_name']);
                //$flexy->setData('stylesheets', array('css'));
                //$flexy->setData('javascripts', array('js'));
            } else {
                $flexy->setData('k_color', array('c_bgcolor' => !empty($_conf['mobile.background_color']) ? $_conf['mobile.background_color'] : '#ffffff', 'c_text' => !empty($_conf['mobile.text_color']) ? $_conf['mobile.text_color'] : '#000000', 'c_link' => !empty($_conf['mobile.link_color']) ? $_conf['mobile.link_color'] : '#0000ff', 'c_vlink' => !empty($_conf['mobile.vlink_color']) ? $_conf['mobile.vlink_color'] : '#9900ff'));
            }
            $rank = isset($params['rank']) ? $params['rank'] : 0;
            if ($_conf['iphone']) {
                $img_dir = 'img/iphone/';
                $img_ext = '.png';
            } else {
                $img_dir = 'img/';
                $img_ext = $_conf['ktai'] ? '.gif' : '.png';
            }
            $stars = array();
            $stars[-1] = $img_dir . ($rank == -1 ? 'sn1' : 'sn0') . $img_ext;
            //$stars[0] = $img_dir . (($rank ==  0) ? 'sz1' : 'sz0') . $img_ext;
            $stars[0] = $img_dir . ($_conf['iphone'] ? 'sz0' : 'sz1') . $img_ext;
            for ($i = 1; $i <= 5; $i++) {
                $stars[$i] = $img_dir . ($rank >= $i ? 's1' : 's0') . $img_ext;
            }
            $k_at_a = str_replace('&amp;', '&', $_conf['k_at_a']);
            $setrank_url = "ic2.php?{$img_q}&t={$thumb}&r=0{$k_at_a}";
            $flexy->setData('stars', $stars);
            $flexy->setData('params', $params);
            if ($thumb == 2 && $rank >= 0) {
                if ($ini['General']['inline'] == 1) {
                    $t = 2;
                    $link = null;
                } else {
                    $t = 1;
                    $link = $path;
                }
                $r = $ini['General']['redirect'] == 1 ? 1 : 2;
                $preview = "{$_SERVER['SCRIPT_NAME']}?o=1&r={$r}&t={$t}&{$img_q}{$k_at_a}";
                $flexy->setData('preview', $preview);
                $flexy->setData('link', $link);
                $flexy->setData('info', null);
            } else {
                $flexy->setData('preview', null);
                $flexy->setData('link', $path);
                $flexy->setData('info', null);
            }
            if (!$_conf['ktai'] || $_conf['iphone']) {
                $flexy->setData('backto', null);
            } elseif (isset($_REQUEST['from'])) {
                $flexy->setData('backto', $_REQUEST['from']);
                $setrank_url .= '&from=' . rawurlencode($_REQUEST['from']);
            } elseif (isset($_SERVER['HTTP_REFERER'])) {
                $flexy->setData('backto', $_SERVER['HTTP_REFERER']);
            } else {
                $flexy->setData('backto', null);
            }
            $flexy->setData('stars', $stars);
            $flexy->setData('sertank', $setrank_url . '&rank=');
            if ($_conf['iphone']) {
                $_conf['extra_headers_ht'] .= <<<EOP
<link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}">
EOP;
                $_conf['extra_headers_xht'] .= <<<EOP
<link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}" />
EOP;
            }
            $flexy->setData('edit', extension_loaded('gd') && $rank >= 0);
            $flexy->setData('form', $rdr->toObject());
            $flexy->setData('doctype', $_conf['doctype']);
            $flexy->setData('extra_headers', $_conf['extra_headers_ht']);
            $flexy->setData('extra_headers_x', $_conf['extra_headers_xht']);
            $flexy->compile('preview.tpl.html');
            P2Util::header_nocache();
            $flexy->output();
    }
    exit;
}
Exemplo n.º 11
0
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
/*
 * Smarty template Init
 */
$path = "./modules/centreon-open-tickets/views/logs/templates/";
$tpl = new Smarty();
$tpl = initSmartyTpl($path, $tpl);
/*
 * Form begin
 */
$form = new HTML_QuickForm('FormTicketLogs', 'get', "?p=" . $p);
$periods = array("" => "", "10800" => _("Last 3 Hours"), "21600" => _("Last 6 Hours"), "43200" => _("Last 12 Hours"), "86400" => _("Last 24 Hours"), "172800" => _("Last 2 Days"), "302400" => _("Last 4 Days"), "604800" => _("Last 7 Days"), "1209600" => _("Last 14 Days"), "2419200" => _("Last 28 Days"), "2592000" => _("Last 30 Days"), "2678400" => _("Last 31 Days"), "5184000" => _("Last 2 Months"), "10368000" => _("Last 4 Months"), "15552000" => _("Last 6 Months"), "31104000" => _("Last Year"));
$form->addElement('select', 'period', _("Log Period"), $periods);
$form->addElement('text', 'StartDate', '', array("id" => "StartDate", "class" => "datepicker", "size" => 8));
$form->addElement('text', 'StartTime', '', array("id" => "StartTime", "class" => "timepicker", "size" => 5));
$form->addElement('text', 'EndDate', '', array("id" => "EndDate", "class" => "datepicker", "size" => 8));
$form->addElement('text', 'EndTime', '', array("id" => "EndTime", "class" => "timepicker", "size" => 5));
$form->addElement('text', 'subject', _("Subject"), array("id" => "subject", "style" => "width: 203px;", "size" => 15, "value" => ''));
$form->addElement('text', 'ticket_id', _("Ticket ID"), array("id" => "ticket_id", "style" => "width: 203px;", "size" => 15, "value" => ''));
$form->addElement('submit', 'graph', _("Apply"), array("onclick" => "return applyForm();", "class" => "btc bt_success"));
$attrHosts = array('datasourceOrigin' => 'ajax', 'allowClear' => false, 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_host&action=list', 'multiple' => true);
$attrHost1 = array_merge($attrHosts);
$form->addElement('select2', 'host_filter', _("Hosts"), array(), $attrHost1);
$attrService = array('datasourceOrigin' => 'ajax', 'allowClear' => false, 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list', 'multiple' => true);
$attrService1 = array_merge($attrService);
$form->addElement('select2', 'service_filter', _("Services"), array(), $attrService1);
$form->setDefaults(array("period" => '10800'));
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl);
$form->accept($renderer);
$tpl->assign('form', $renderer->toArray());
$tpl->display("viewLog.ihtml");
Exemplo n.º 12
0
     $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()) {
         $to = $form->exportValue("email");
         $subject = $form->exportValue("message_subject");
         $body = $form->exportValue("message_body") . "\r\n\r\n(" . $subject . " [" . _FROM . ": " . $to . "])";
         if (eF_mail($to, $GLOBALS['configuration']['system_email'], $subject . " [" . _FROM . ": " . $to . "]", $body, false, true)) {
             $copied_body = _THANKYOUFORCONTACTINGUSBODY . "<br/><hr/><br/>" . $form->exportValue("message_body");
             eF_mail($GLOBALS['configuration']['system_email'], $to, _THANKYOUFORCONTACTINGUS, $copied_body, false, false);
             $message = _SENDSUCCESS;
Exemplo n.º 13
0
 }
 //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']);
     file_put_contents($basedir . $values['name'] . '.tpl', applyEditorOffset($values['content']));
     if (isset($_GET['edit_block'])) {
         $customBlocks[$_GET['edit_block']] = $block;
 /**
  * The main functionality
  *
  * (non-PHPdoc)
  * @see libraries/EfrontModule#getModule()
  */
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $directionsTree = new EfrontDirectionsTree();
     $directionsPaths = $directionsTree->toPathString();
     $smarty->assign("T_MODULE_OUTLOOK_INVITATION_DIRECTION_PATHS", $directionsPaths);
     $temp = eF_getTableData("module_outlook_invitation as m,courses as c", "m.*,c.name,c.directions_ID", "m.courses_ID=c.id");
     $events = array();
     foreach ($temp as $value) {
         $events[$value['courses_ID']] = $value;
     }
     if (isset($_GET['delete_event']) && eF_checkParameter($_GET['delete_event'], 'id') && in_array($_GET['delete_event'], array_keys($events))) {
         try {
             $event = $events[$_GET['delete_event']];
             $course = new EfrontCourse($event['courses_ID']);
             $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false));
             $recipients = array();
             foreach ($users as $value) {
                 $recipients[] = $value['email'];
             }
             $this->cancelInvitation($course->course['id'], $recipients);
             eF_deleteTableData("module_outlook_invitation", "courses_ID=" . $_GET['delete_event']);
         } catch (Exception $e) {
             header("HTTP/1.0 500 ");
             echo $e->getMessage() . ' (' . $e->getCode() . ')';
         }
         exit;
     }
     if ($_SESSION['s_type'] != 'administrator') {
         $userCourses = $currentUser->getUserCourses(array('archive' => 0, 'active' => true, 'return_objects' => false));
         if (G_VERSIONTYPE == 'enterprise') {
             if ($_SESSION['s_current_branch']) {
                 $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID='{$_SESSION['s_current_branch']}'");
             } else {
                 if ($currentUser->aspects['hcd']->isSupervisor()) {
                     $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID in (select branches_ID from module_hcd_employee_works_at_branch where users_login='******'login']}' and supervisor=1)");
                 }
             }
             $branchCourses = array();
             foreach ($result as $value) {
                 $branchCourses[$value['courses_ID']] = $value['courses_ID'];
             }
             foreach ($events as $key => $value) {
                 if (!isset($branchCourses[$key]) && !isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         } else {
             foreach ($events as $key => $value) {
                 if (!isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         }
     }
     if (!isset($_GET['course'])) {
         $dataSource = $events;
         $tableName = 'outlookInvitationsTable';
         isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE);
         if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) {
             $sort = $_GET['sort'];
             isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc');
         } else {
             $sort = 'login';
         }
         $dataSource = eF_multiSort($dataSource, $sort, $order);
         $smarty->assign("T_TABLE_SIZE", sizeof($dataSource));
         if (isset($_GET['filter'])) {
             $dataSource = eF_filterData($dataSource, $_GET['filter']);
         }
         if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) {
             isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0);
             $dataSource = array_slice($dataSource, $offset, $limit);
         }
         $smarty->assign("T_DATA_SOURCE", $dataSource);
     } else {
         $course = new EfrontCourse($_GET['course']);
         $form = new HTML_QuickForm("import_outlook_invitation_form", "post", $this->moduleBaseUrl . "&course={$course->course['id']}&add_event=1" . (isset($_GET['popup']) ? '&popup=1' : ''), "", null, true);
         $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
         //Register this rule for checking user input with our function, eF_checkParameter
         $form->addElement('text', 'email', _SENDER, 'class = "inputText"');
         $form->addElement('text', 'location', _LOCATION, 'class = "inputText"');
         $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText"');
         $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTestTextarea" style = "width:80%;height:6em;"');
         //$form -> addElement('checkbox', 'calendar', _MODULE_OUTLOOK_INVITATION_CREATE_CALENDAR);
         //$form -> addElement('static', 'static', _MODULE_OUTLOOK_INVITATION_INFO);
         $form->addElement('submit', 'submit_event_all', _MODULE_OUTLOOK_INVITATION_SENDALL, 'class=flatButton');
         $form->addElement('submit', 'submit_event_new', _MODULE_OUTLOOK_INVITATION_SENDNEW, 'class=flatButton');
         if (empty($events[$course->course['id']])) {
             //new invitation
             $currentEvent = null;
             $form->setDefaults(array('email' => $currentUser->user['email'], 'subject' => 'Invitation to attend training: ' . $course->course['name']));
         } else {
             //existing invitation
             $currentEvent = $events[$course->course['id']];
             $form->setDefaults(array('email' => $currentEvent['email'], 'description' => $currentEvent['description'], 'subject' => $currentEvent['subject'], 'location' => $currentEvent['location']));
         }
         if ($form->isSubmitted() && $form->validate()) {
             try {
                 $message = "";
                 // Set info to store into database
                 $permanent_info = array("courses_ID" => $course->course['id'], "email" => $form->exportValue('email') ? $form->exportValue('email') : $GLOBALS['configuration']['system_email'], "location" => $form->exportValue('location'), "subject" => $form->exportValue('subject'), "description" => $form->exportValue('description'));
                 if ($currentEvent) {
                     $permanent_info['sequence'] = $currentEvent['sequence'] + 1;
                     eF_updateTableData("module_outlook_invitation", $permanent_info, "courses_ID={$course->course['id']}");
                 } else {
                     eF_insertTableData("module_outlook_invitation", $permanent_info);
                 }
                 if ($form->exportValue('submit_event_all')) {
                     $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false));
                     $recipients = array();
                     foreach ($users as $value) {
                         $recipients[] = $value['email'];
                     }
                     $this->sendInvitation($course->course['id'], $recipients);
                 }
                 //					$smarty->assign('T_RELOAD', true);
                 if (isset($_GET['popup'])) {
                     $this->setMessageVar(_OPERATIONCOMPLETEDSUCCESSFULLY, 'success');
                 } else {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success");
                 }
             } catch (Exception $e) {
                 $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                 $this->setMessageVar($e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>', 'failure');
             }
         }
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $smarty->assign('T_MODULE_OUTLOOK_INVITATION_FORM', $form->toArray());
     }
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     return true;
 }
Exemplo n.º 15
0
<?php

/**
 * Example of usage for HTML_QuickForm with ITDynamic renderer
 *
 * @author Alexey Borzov <*****@*****.**>
 *
 * $Id: ITDynamic_example.php,v 1.3 2003/09/09 10:46:51 avb Exp $ 
 */
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
// can use either HTML_Template_Sigma or HTML_Template_ITX
require_once 'HTML/Template/ITX.php';
// require_once 'HTML/Template/Sigma.php';
$form = new HTML_QuickForm('frmTest', 'post');
$form->setDefaults(array('itxtTest' => 'Test Text Box', 'itxaTest' => 'Hello World', 'iselTest' => array('B', 'C'), 'name' => array('first' => 'Alexey', 'last' => 'Borzov'), 'iradYesNo' => 'Y', 'ichkABCD' => array('A' => true, 'D' => true)));
$form->addElement('header', '', 'Normal Elements');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
// will be rendered in default qf_element block
$form->addElement('text', 'itxtTest', 'Test Text:');
// will be rendered in qf_textarea block, as it exists in template
$form->addElement('textarea', 'itxaTest', 'Test TextArea:', array('rows' => 5, 'cols' => 40));
// will be later assigned to qf_green, note that an array of labels is passed
$form->addElement('password', 'ipwdTest', array('Test Password:'******'The password is expected to be long enough.'));
$select =& $form->addElement('select', 'iselTest', 'Test Select:', array('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D'));
$select->setSize(5);
$select->setMultiple(true);
$form->addElement('submit', 'isubTest', 'Test Submit');
$form->addElement('header', '', 'Grouped Elements');
// will be rendered in default qf_group block
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
Exemplo n.º 16
0
            $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!
        } else {
            $menuBar = array('cancel' => '/ushop/postage/overview', 'save' => null);
            $this->content .= $this->makeToolbar($menuBar, 24);
            $form->setDefaults(array('post_level' => $rows[0]->post_level));
            $renderer = new UthandoForm(TEMPLATES . $template);
            $renderer->setFormTemplate('form');
            $renderer->setHeaderTemplate('header');
            $renderer->setElementTemplate('element');
            $form->accept($renderer);
            // output the form
            $this->content .= $renderer->toHtml();
        }
        if (isset($params)) {
            $params['CONTENT'] = $this->makeMessageBar($menuBar, 24);
            $this->content .= $this->message($params);
        }
    }
} else {
    header("Location:" . $this->get('config.server.web_url'));
Exemplo n.º 17
0
     		} else {
     			$branches = eF_getTableData("module_hcd_branch", "branch_ID, name, father_branch_ID","","father_branch_ID ASC,branch_ID ASC");
     			// Show all branches
     			$only_existing = 0;
     		}
     
     		//$form -> addElement('select', 'branches_ID', _LOCATIONBRANCH, eF_createBranchesTreeSelect($branches,$only_existing), 'class = "inputText"');
     		//$smarty -> assign("T_BRANCHES_FILTER", eF_createBranchesFilterSelect());
     */
     $smarty->assign("T_JOBS_FILTER", eF_createJobFilterSelect());
 }
 #cpp#endif
 if (isset($_GET['edit_lesson'])) {
     //If we are editing a lesson, we set the default form values to the ones stored in the database
     $editLesson = new EfrontLesson($_GET['edit_lesson']);
     $form->setDefaults(array('name' => $editLesson->lesson['name'], 'active' => $editLesson->lesson['active'], 'show_catalog' => $editLesson->lesson['show_catalog'], 'course_only' => $editLesson->lesson['course_only'], 'directions_ID' => $editLesson->lesson['directions_ID'], 'languages_NAME' => $editLesson->lesson['languages_NAME'], 'duration' => $editLesson->lesson['duration'] ? $editLesson->lesson['duration'] : '', 'access_limit' => $editLesson->lesson['access_limit'] ? $editLesson->lesson['access_limit'] : '', 'share_folder' => $editLesson->lesson['share_folder'] ? $editLesson->lesson['share_folder'] : 0, 'max_users' => $editLesson->lesson['max_users'] ? $editLesson->lesson['max_users'] : null, 'price' => $editLesson->lesson['price'], 'recurring' => $editLesson->options['recurring'], $editLesson->options['recurring'] . '_duration' => $editLesson->options['recurring_duration']));
     if ($editLesson->lesson['share_folder']) {
         $shareFolderLesson = new EfrontLesson($editLesson->lesson['share_folder']);
         $smarty->assign("T_SHARE_FOLDER_WITH", $shareFolderLesson->lesson['name']);
     }
     if ($editLesson->lesson['course_only'] && sizeof($editLesson->getCourses()) > 0 || !$editLesson->lesson['course_only']) {
         $result = eF_getTableData("users_to_lessons", "count(*)", "lessons_ID={$editLesson->lesson['id']} and archive=0");
         if ($result[0]['count(*)'] > 0) {
             $courseOnly->freeze();
             $directAccess->freeze();
         }
     }
     $smarty->assign("T_EDIT_LESSON", $editLesson);
 } else {
     //$form -> addElement('file', 'import_content', _UPLOADLESSONFILE, 'class = "inputText"');
     $form->setDefaults(array('active' => 1, 'show_catalog' => 1, 'price' => 0, 'course_only' => 1, 'languages_NAME' => $GLOBALS['configuration']['default_language']));
Exemplo n.º 18
0
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;
    }
}
Exemplo n.º 19
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;
		}
    }
Exemplo n.º 20
0
 } else {
     if (isset($_GET['config'])) {
         $form = new HTML_QuickForm("forum_admin_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=forum&config=1", "", null, true);
         //Build the form
         $form->addElement('select', 'allow_html', _ALLOWHTMLFPM, array(1 => _YES, 0 => _NO));
         $form->addElement('select', 'polls', _ACTIVATEPOLLS, array(1 => _YES, 0 => _NO));
         $form->addElement('select', 'forum_attachments', _ALLOWATTACHMENTSINF, array(1 => _YES, 0 => _NO));
         $form->addElement('select', 'students_add_forums', _USERSMAYADDFORUMS, array(0 => _NO, 1 => _YES));
         $form->addElement('text', 'pm_quota', _PMQUOTA, 'class = "inputText" style = "width:40px"');
         $form->addElement('text', 'pm_attach_quota', _PMATTACHMENTSQUOTA, 'class = "inputText" style = "width:40px"');
         $form->addRule('pm_quota', _THEFIELD . ' "' . _PMQUOTA . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client');
         $form->addRule('pm_attach_quota', _THEFIELD . ' "' . _PMATTACHMENTSQUOTA . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client');
         $form->addElement('submit', 'submit_settings', _SUBMIT, 'class = "flatButton"');
         $current_values = eF_getTableDataFlat("f_configuration", "*");
         $current_values = array_combine($current_values['name'], $current_values['value']);
         $form->setDefaults($current_values);
         if ($form->isSubmitted() && $form->validate()) {
             //If the form is submitted and validated
             $values = $form->exportValues();
             eF_deleteTableData("f_configuration");
             $fields[] = array('name' => 'allow_html', "value" => $values['allow_html'] ? 1 : 0);
             $fields[] = array('name' => 'polls', "value" => $values['polls'] ? 1 : 0);
             $fields[] = array('name' => 'forum_attachments', "value" => $values['forum_attachments'] ? 1 : 0);
             $fields[] = array('name' => 'students_add_forums', "value" => $values['students_add_forums'] ? 1 : 0);
             $fields[] = array('name' => 'pm_quota', "value" => $values['pm_quota'] ? $values['pm_quota'] : "");
             $fields[] = array('name' => 'pm_attach_quota', "value" => $values['pm_attach_quota'] ? $values['pm_attach_quota'] : "");
             foreach ($fields as $field) {
                 eF_insertTableData("f_configuration", array("name" => $field['name'], "value" => $field['value']));
             }
             $message = _SUCCESSFULLYINSERTEDVALUES;
             $message_type = 'success';
Exemplo n.º 21
0
     $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_RENAME_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl);
 }
 $tid = $_GET['template_id'];
 $postTarget = basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=rename_certificate_template&template_id=' . $tid;
 $form = new HTML_QuickForm("rename_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', 'rename_certificate_template', _SAVE, 'class="flatButton"');
 $renameTemplate = eF_getTableData("certificate_templates", "certificate_name", "id=" . $tid);
 $form->setDefaults(array('certificate_name' => $renameTemplate[0]['certificate_name']));
 if ($form->isSubmitted() && $form->validate()) {
     $formValues = $form->exportValues();
     $dbFields = array("certificate_name" => $formValues['certificate_name']);
     if (eF_updateTableData("certificate_templates", $dbFields, "id=" . $tid)) {
         $message = _SUCCESSFULLYRENAMECERTIFICATETEMPLATE;
         $message_type = 'success';
     } else {
         $message = _PROBLEMRENAMECERTIFICATETEMPLATE;
         $message_type = 'failure';
     }
     $redirectUrl = "" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&message=" . urlencode($message);
     $redirectUrl .= "&message_type=" . $message_type . "&reset_popup=1&tid=" . $tid;
     $smarty->assign('T_RENAME_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl);
 }
 $renderer = prepareFormRenderer($form);
 private function doJobCourses()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $result = eF_getTableData("module_hcd_job_description j left outer join module_hcd_course_to_job_description cj on cj.job_description_ID=j.job_description_ID", "j.job_description_ID,description,branch_ID,count(courses_ID) as total_courses", "", "", "j.job_description_ID");
     $branchesTree = new EfrontBranchesTree();
     $branchesTreePaths = $branchesTree->toPathString();
     $jobs = array();
     foreach ($result as $value) {
         $jobsArray[$value['job_description_ID']] = $value;
         $jobs[$value['job_description_ID']] = $branchesTreePaths[$value['branch_ID']] . "&nbsp;&rarr;&nbsp;" . $value['description'] . " (" . $value['total_courses'] . ")";
     }
     $form = new HTML_QuickForm("job_courses_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=job_courses&do=enterprise", "", null, true);
     $form->addElement('select', 'job', _JOBDESCRIPTION, $jobs);
     $form->addElement("submit", "submit", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTION, 'class = "flatButton"');
     $form->addElement("static", "", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTIONTOALLSIMILARJOBS);
     $form->setDefaults(array("idle_from_timestamp" => $_SESSION['timestamp_from']));
     if ($form->isSubmitted() && $form->validate()) {
         $GLOBALS['currentEmployee'] = $currentUser->aspects['hcd'];
         $job = new EfrontJob($form->exportValue('job'));
         $courses = $job->getJobCourses();
         foreach ($sameJobs = $job->getSameDescriptions() as $value) {
             eF_deleteTableData("module_hcd_course_to_job_description", "job_description_id = '" . $value . "'");
         }
         $job->associateCoursesToJob($courses, true);
         $message = str_replace(array("%x", "%y"), array(sizeof($sameJobs), sizeof($courses)), _MODULE_ADMINISTRATOR_TOOLS_SUCCESSFULLYASSIGNEDCOURSESTOJOBS);
         $message_type = 'success';
         $this->setMessageVar($message, $message_type);
     }
     $smarty->assign("T_JOB_COURSES_FORM", $form->toArray());
 }
Exemplo n.º 23
0
 $form = new HTML_QuickForm("upload_scorm_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=scorm&scorm_import=1', "", null, true);
 $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
 //Register this rule for checking user input with our function, eF_checkParameter
 $form->addElement('file', 'scorm_file[0]', _UPLOADTHESCORMFILEINZIPFORMAT);
 //$form -> addRule('scorm_file[0]', _THEFIELD.' "'._UPLOADTHESCORMFILEINZIPFORMAT.'" '._ISMANDATORY, 'required', null, 'client');
 for ($i = 1; $i < $maxUploads; $i++) {
     $form->addElement('file', "scorm_file[{$i}]", null);
 }
 //$form -> addElement('file', 'scorm_file', _SCORMFILEINZIPFORMAT);
 $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
 $form->addElement('text', 'url_upload', _UPLOADFILEFROMURL, 'class = "inputText"');
 $form->addElement('select', 'embed_type', _EMBEDTYPE, array('iframe' => _INLINEIFRAME, 'popup' => _NEWWINDOWPOPUP), 'class = "inputSelect"');
 $form->addElement('text', 'popup_parameters', _POPUPPARAMETERS, 'class = "inputText" style = "width:600px"');
 $form->addElement('text', 'iframe_parameters', _IFRAMEPARAMETERS, 'class = "inputText" style = "width:600px"');
 $form->addElement('submit', 'submit_upload_scorm', _SUBMIT, 'class = "flatButton"');
 $form->setDefaults(array('popup_parameters' => 'width=800,height=600,scrollbars=no,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,top="+(parseInt(parseInt(screen.height)/2) - 300)+",left="+(parseInt(parseInt(screen.width)/2) - 400)+"', 'iframe_parameters' => 'height = "100%"  width = "100%" frameborder = "no"'));
 //@todo: url upload, if not exists, report a human-readable error!
 $timestamp = time();
 if ($form->isSubmitted() && $form->validate()) {
     $values = $form->exportValues();
     try {
         $urlUpload = $form->exportValue('url_upload');
         $scormFiles = array();
         if ($urlUpload != "") {
             FileSystemTree::checkFile($urlUpload);
             $urlArray = explode("/", $urlUpload);
             $urlFile = preg_replace("/\\?.*/", "", urldecode($urlArray[sizeof($urlArray) - 1]));
             if (!copy($urlUpload, $currentLesson->getDirectory() . $urlFile)) {
                 $error = error_get_last();
                 throw new Exception(_PROBLEMUPLOADINGFILE . ': ' . $error['message']);
             } else {
Exemplo n.º 24
0
 $form->addElement('select', 'parent_content_ID', _UNITPARENT, array(0 => _NOPARENT) + $currentContent->toHTMLSelectOptions($iterator));
 $form->addElement('file', 'pdf_upload', _PDFFILE, null);
 $form->addElement('submit', 'submit_insert_content', _SAVECHANGES, 'class = "flatButton"');
 $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
 if (strpos($currentUnit['ctg_type'], 'scorm') !== false || strpos($currentUnit['scorm_version'], 'tincan') !== false) {
     $form->addElement('text', 'scorm_size', _EXPLICITIFRAMESIZE, 'class = "inputText" style = "width:50px"');
     //Set an explicit size for the SCORM content
     $form->addElement('select', 'reentry_action', _ACTIONONRENTRYCOMPLETED, array(0 => _LETCONTENTDECIDE, 1 => _DONTCHANGE), 'class = "inputText"');
     //Set what action should be performed when a user re-enters a visited content
     if (!$currentUnit['scorm_version'] || $currentUnit['scorm_version'] == '1.2' || $currentUnit['scorm_version'] == 'tincan') {
         $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
Exemplo n.º 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';
 }
Exemplo n.º 26
0
        $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']);
        eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=backup&message=" . urlencode(_SUCCESFULLYBACKEDUP) . "&message_type=success");
Exemplo n.º 27
0
 * @author      Thomas Schulz <*****@*****.**>
 * @version     CVS: $Id: SmartyStatic_example.php,v 1.5 2007/05/29 19:12:26 avb Exp $
 * @ignore
 */
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
// fix this if your Smarty is somewhere else
require_once 'Smarty.class.php';
// Form name will be used to find the placeholders.
$form = new HTML_QuickForm('form', 'POST');
// Fills with some defaults values
$defaultValues['company'] = 'Mamasam';
$defaultValues['country'] = array();
$defaultValues['name'] = array('first' => 'Bertrand', 'last' => 'Mansion');
$defaultValues['phone'] = array('513', '123', '4567');
$form->setDefaults($defaultValues);
// Hidden
$form->addElement('hidden', 'session', '1234567890');
// Personal information
$form->addElement('header', 'personal', 'Personal Information');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'email', 'Your email:');
$form->addElement('password', 'pass', array('Your password:'******'note' => 'Please, choose a 8-10 characters password.'), 'size=10');
$name['last'] =& HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
$name['first'] =& HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
$form->addGroup($name, 'name', 'Name:', ',&nbsp;');
$areaCode =& HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
$phoneNo1 =& HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
$phoneNo2 =& HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
// Company information
Exemplo n.º 28
0
 }
 $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) {
                     $editedEmployee->removeJob($_GET['edit_placement']);
                 } elseif (isset($userJobs[$newJob]) && $userJobs[$newJob]['supervisor'] != $_POST['position']) {
                     $editedEmployee->removeJob($_GET['edit_placement']);
                 }
             }
Exemplo n.º 29
0
        $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>';
        }
        // done!
    } else {
        $form->setDefaults(array('tax_code' => $rows[0]->tax_code, 'tax_rate_id' => $rows[0]->tax_rate_id, 'description' => $rows[0]->description));
        $renderer = new UthandoForm(__SITE_PATH . '/templates/' . $template);
        $renderer->setFormTemplate('form');
        $renderer->setHeaderTemplate('header');
        $renderer->setElementTemplate('element');
        $form->accept($renderer);
        // output the form
        $this->content .= $renderer->toHtml();
    }
    if (isset($params)) {
        $params['CONTENT'] = $this->makeMessageBar($menuBar, 24);
        $this->content .= $this->message($params);
    }
} else {
    header("Location:" . $this->get('config.server.web_url'));
    exit;
Exemplo n.º 30
0
             $smarty->assign('T_LESSONTIMELINE_TOPIC_FORM', $renderer->toArray());
         }
     }
 }
 // The main lesson timeline page contains also the form for inserting new topical timelines
 if (isset($_GET['all']) && eF_checkParameter($_GET['lessons_ID'], 'id')) {
     $form = new HTML_QuickForm("timeline_form", "post", $_SESSION['s_type'] . ".php?ctg=social&op=timeline&lessons_ID=" . $_GET['lessons_ID'] . "&all=1", "", null, true);
     $result = eF_getTableData("lessons_timeline_topics", "id, title", "lessons_ID = " . $editedLesson->lesson['id']);
     $topics = array("0" => _ANYTOPIC);
     foreach ($result as $topic) {
         $id = $topic['id'];
         $topics[$id] = $topic['title'];
     }
     $form->addElement('select', 'topic', _SELECTTIMELINETOPIC, $topics, 'class = "inputText"  id="timeline_topic" onchange="javascript:change_topic(\'timeline_topic\')"');
     if (isset($_GET['topics_ID']) && eF_checkParameter($_GET['topics_ID'], 'id')) {
         $form->setDefaults(array('topic' => $_GET['topics_ID']));
         $smarty->assign("T_TOPIC_TITLE", $topics[$_GET['topics_ID']]);
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     $form->accept($renderer);
     $smarty->assign('T_TIMELINE_FORM', $renderer->toArray());
     if ($currentUser->getRole($editedLesson) == "student") {
         $smarty->assign("T_STUDENT", 1);
     }
 }
 if (isset($_GET['ajax'])) {
     isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = 10);
     // No sorting needed: getEvents returns sorted results according to time
     if (isset($_GET['all'])) {
         $avatarNormalDims = 50;
     } else {