Example #1
0
 /**
  * factory 
  * 
  * Factory method
  * 
  * @param mixed $name name of the form
  * @param mixed $url  action url
  * 
  * @static
  * @access public
  * @return Object HTML_QuickForm Object
  */
 static function factory($name, $url)
 {
     $form = new HTML_QuickForm($name, 'post', $url);
     $star = '<span style="color: #ff0000">*</span> ';
     $form->setRequiredNote($star . _('denotes required field'));
     return $form;
 }
Example #2
0
 static function form()
 {
     try {
         $anonymous = Variable::get('anonymous_setup');
     } catch (NoSuchVariableException $e) {
         $anonymous = true;
     }
     if (!Base_AclCommon::is_user() && Base_User_LoginCommon::is_banned()) {
         return self::t('You have exceeded the number of allowed login attempts.');
     }
     require_once 'modules/Libs/QuickForm/requires.php';
     if (!Base_AclCommon::is_user() && !$anonymous) {
         Base_User_LoginCommon::autologin();
     }
     if (!Base_AclCommon::is_user() && !$anonymous) {
         $get = count($_GET) ? '?' . http_build_query($_GET) : '';
         $form = new HTML_QuickForm('loginform', 'post', $_SERVER['PHP_SELF'] . $get);
         $form->setRequiredNote('<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;">' . self::t('denotes required field') . '</span>');
         $form->addElement('text', 'username', self::t('Username'));
         $form->addRule('username', 'Field required', 'required');
         $form->addElement('password', 'password', self::t('Password'));
         $form->addRule('password', 'Field required', 'required');
         // register and add a rule to check if user is banned
         $form->registerRule('check_user_banned', 'callback', 'rule_login_banned', 'Base_User_LoginCommon');
         $form->addRule('username', self::t('You have exceeded the number of allowed login attempts.'), 'check_user_banned');
         // register and add a rule to check if user and password exists
         $form->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon');
         $form->addRule(array('username', 'password'), self::t('Login or password incorrect'), 'check_login', $form);
         $form->addElement('submit', null, self::t('Login'));
         if ($form->validate()) {
             $user = $form->exportValue('username');
             Base_AclCommon::set_user(Base_UserCommon::get_user_id($user), true);
             // redirect below is used to better browser refresh behavior.
             header('Location: ' . $_SERVER['REQUEST_URI']);
         } else {
             return "<center>" . $form->toHtml() . "</center>";
         }
     }
 }
    public function getModule()
    {
        $smarty = $this->getSmartyVar();
        $currentLesson = $this->getCurrentLesson();
        $currentUser = $this->getCurrentUser();
        try {
            $role = $currentUser->getRole($this->getCurrentLesson());
        } catch (Exception $e) {
            $currentUser = EfrontUserFactory::factory($_SESSION['s_login']);
            $role = $currentUser->getRole($this->getCurrentLesson());
        }
        if (isset($_GET['delete_blog']) && eF_checkParameter($_GET['delete_blog'], 'id')) {
            $blog = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $_GET['delete_blog']);
            if ($blog[0]['users_LOGIN'] != $_SESSION['s_login']) {
                eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS));
                exit;
            }
            $articles = eF_getTableDataFlat("module_blogs_articles", "id", "blogs_ID=" . $_GET['delete_blog']);
            if (sizeof($articles) > 0) {
                $articlesList = implode(",", $articles['id']);
                eF_deleteTableData("module_blogs_comments", "blogs_articles_ID IN ({$articlesList})");
            }
            eF_deleteTableData("module_blogs_articles", "blogs_ID=" . $_GET['delete_blog']);
            eF_deleteTableData("module_blogs", "id=" . $_GET['delete_blog']);
        }
        if (isset($_GET['deactivate_blog']) && eF_checkParameter($_GET['deactivate_blog'], 'id')) {
            $blog = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $_GET['deactivate_blog']);
            if ($blog[0]['users_LOGIN'] != $_SESSION['s_login']) {
                eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS));
                exit;
            }
            if (eF_updateTableData("module_blogs", array('active' => 0), "id=" . $_GET['deactivate_blog'])) {
                $message = _BLOGS_BLOGDEACTIVATED;
                $message_type = 'success';
            } else {
                $message = _BLOGS_BLOGDEACTIVATEDPROBLEM;
                $message_type = "failure";
            }
        }
        if (isset($_GET['activate_blog']) && eF_checkParameter($_GET['activate_blog'], 'id')) {
            $blog = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $_GET['activate_blog']);
            if ($blog[0]['users_LOGIN'] != $_SESSION['s_login']) {
                eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS));
                exit;
            }
            if (eF_updateTableData("module_blogs", array('active' => 1), "id=" . $_GET['activate_blog'])) {
                $message = _BLOGS_BLOGACTIVATED;
                $message_type = 'success';
            } else {
                $message = _BLOGS_BLOGACTIVATEDPROBLEM;
                $message_type = "failure";
            }
        }
        if (isset($_GET['delete_article']) && eF_checkParameter($_GET['delete_article'], 'id')) {
            $blog = eF_getTableData("module_blogs_articles", "blogs_ID,users_LOGIN", "id=" . $_GET['delete_article']);
            $blogTemp = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $blog[0]['blogs_ID']);
            if ($blog[0]['users_LOGIN'] != $_SESSION['s_login'] && $blogTemp[0]['users_LOGIN'] != $_SESSION['s_login']) {
                eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $blog[0]['blogs_ID'] . "&message=" . urlencode(_BLOGS_NOACCESS));
                exit;
            }
            eF_deleteTableData("module_blogs_comments", "blogs_articles_ID=" . $_GET['delete_article']);
            eF_deleteTableData("module_blogs_articles", "id=" . $_GET['delete_article']);
            $message = _BLOGS_ARTICLEWASDELETEDSUCCESSFULLY;
            $message_type = "success";
            eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $blog[0]['blogs_ID'] . "&message=" . urlencode($message) . "&message_type=" . $message_type);
        }
        if (isset($_GET['delete_comment']) && eF_checkParameter($_GET['delete_comment'], 'id')) {
            $article = eF_getTableData("module_blogs_articles", "blogs_ID,users_LOGIN", "id=" . $_GET['article_id']);
            $blogTemp = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $article[0]['blogs_ID']);
            $commentTemp = eF_getTableData("module_blogs_comments", "users_LOGIN", "id=" . $_GET['delete_comment']);
            if ($commentTemp[0]['users_LOGIN'] != $_SESSION['s_login'] && $blogTemp[0]['users_LOGIN'] != $_SESSION['s_login']) {
                eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode(_BLOGS_NOACCESS));
                exit;
            }
            eF_deleteTableData("module_blogs_comments", "id=" . $_GET['delete_comment']);
            $message = _BLOGS_COMMENTWASDELETEDSUCCESSFULLY;
            $message_type = "success";
            eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type);
        }
        if (isset($_GET['add_blog']) || isset($_GET['edit_blog'])) {
            if (isset($_GET['add_blog']) && $_SESSION['s_type'] != "professor") {
                eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS));
            }
            if (isset($_GET['edit_blog'])) {
                $blog_data = eF_getTableData("module_blogs", "*", "id=" . $_GET['edit_blog']);
                if ($blog_data[0]['users_LOGIN'] != $_SESSION['s_login']) {
                    eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS));
                }
                $post_target = $this->moduleBaseUrl . '&edit_blog=' . $_GET['edit_blog'];
            } else {
                $post_target = $this->moduleBaseUrl . '&add_blog';
            }
            global $load_editor;
            $load_editor = true;
            $form = new HTML_QuickForm("blog_add_form", "post", $post_target . "&blog_id=" . $_GET['blog_id'], "", null, true);
            //Build the form
            $form->addElement('text', 'title', _TITLE, 'class = "inputText"');
            $form->addRule('title', _THEFIELD . ' "' . _TITLE . '" ' . _ISMANDATORY, 'required', null, 'client');
            $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputContentTextarea simpleEditor" style = "width:100%;height:20em;"');
            $form->addElement("advcheckbox", "registered", _BLOGS_ACCESSIBLE, null, 'class = "inputCheckBox"', array(0, 1));
            $form->addElement('submit', 'submit_add_blog', _SUBMIT, 'class = "flatButton"');
            if (isset($_GET['edit_blog'])) {
                $form->setDefaults(array('title' => $blog_data[0]['name'], 'description' => $blog_data[0]['description'], 'registered' => $blog_data[0]['registered']));
            }
            if ($form->isSubmitted() && $form->validate()) {
                //If the form is submitted and validated
                $values = $form->exportValues();
                $fields = array("name" => $values['title'], "lessons_ID" => $values['lessons_ID'] ? $values['lessons_ID'] : $_SESSION['s_lessons_ID'], "description" => $values['description'], "registered" => $values['registered']);
                if (isset($_GET['edit_blog'])) {
                    if (eF_updateTableData("module_blogs", $fields, "id=" . $_GET['edit_blog'])) {
                        $message = _BLOGS_BLOGUPDATEDSUCCESSFULLY;
                        $message_type = 'success';
                    } else {
                        $message = _BLOGS_BLOGNOTUPDATED;
                        $message_type = 'failure';
                    }
                    eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                } else {
                    $fields['users_LOGIN'] = $_SESSION['s_login'];
                    $fields['timestamp'] = time();
                    //pr($fields);
                    $new_id = eF_insertTableData("module_blogs", $fields);
                    if ($new_id) {
                        $message = _BLOGS_BLOGADDEDSUCCESSFULLY;
                        $message_type = 'success';
                        eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type . "&edit_blog=" . $new_id . "&tab=blog_creators");
                    } else {
                        $message = _BLOGS_BLOGNOTADDED;
                        $message_type = 'failure';
                        eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                    }
                }
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            //Create a smarty renderer
            $renderer->setRequiredTemplate('{$html}{if $required}
				&nbsp;<span class = "formRequired">*</span>
			{/if}');
            $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
            //Set javascript error messages
            $form->setRequiredNote(_REQUIREDNOTE);
            $form->accept($renderer);
            //Assign this form to the renderer, so that corresponding template code is created
            $smarty->assign('T_BLOG_ADD_FORM', $renderer->toArray());
            //Assign the form to the template
            try {
                $lessonUsers = $currentLesson->getUsers();
                //Get all users that have this lesson
                unset($lessonUsers[$currentUser->login]);
                //Remove the current user from the list, he can't set parameters for his self!
                $users = $lessonUsers;
                $blogsCreators = eF_getTableDataFlat("module_blogs_users", "*", "blogs_ID=" . $_GET['edit_blog']);
                $creatorsAssoc = array_combine(array_values($blogsCreators['users_LOGIN']), array_values($blogsCreators['users_LOGIN']));
                $nonBlogsCreators = array_diff_key($users, $creatorsAssoc);
                $blogsCreatorsTemp = array_diff_key($users, $nonBlogsCreators);
                foreach ($users as $key => $user) {
                    in_array($key, array_values($blogsCreators['users_LOGIN'])) ? $users[$key]['blog_creator'] = true : ($users[$key]['blog_creator'] = false);
                }
                //pr($users);
                $roles = eF_getTableDataFlat("user_types", "name", "active=1 AND basic_user_type!='administrator'");
                //Get available roles
                if (sizeof($roles) > 0) {
                    $roles = array_combine($roles['name'], $roles['name']);
                    //Match keys with values, it's more practical this way
                }
                $roles = array_merge(array('student' => _STUDENT, 'professor' => _PROFESSOR), $roles);
                //Append basic user types to the beginning of the array
                //pr($roles);
                if (isset($_GET['ajax']) && $_GET['ajax'] == 'usersTable') {
                    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';
                    }
                    $users = eF_multiSort($users, $sort, $order);
                    $smarty->assign("T_USERS_SIZE", sizeof($users));
                    if (isset($_GET['filter'])) {
                        $users = eF_filterData($users, $_GET['filter']);
                    }
                    if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) {
                        isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0);
                        $users = array_slice($users, $offset, $limit);
                    }
                    $smarty->assign("T_ROLES", $roles);
                    $smarty->assign("T_ALL_USERS", $users);
                    $smarty->assign("T_BLOGS_USERS", $blogsCreators['users_LOGIN']);
                    //We assign separately the lesson's users, to know when to display the checkboxes as "checked"
                    $smarty->assign("T_CURRENT_USER", $currentUser);
                    return true;
                }
            } 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';
            }
            if (isset($_GET['postAjaxRequest'])) {
                try {
                    if (isset($_GET['login']) && eF_checkParameter($_GET['login'], 'login')) {
                        if (!in_array($_GET['login'], array_values($blogsCreators['users_LOGIN']))) {
                            $fields = array('blogs_ID' => $_GET['edit_blog'], 'users_login' => $_GET['login']);
                            $res = eF_insertTableData("module_blogs_users", $fields);
                        }
                        if (in_array($_GET['login'], array_values($blogsCreators['users_LOGIN']))) {
                            eF_deleteTableData("module_blogs_users", "blogs_ID=" . $_GET['edit_blog'] . " AND users_LOGIN='******'login'] . "'");
                        }
                    } else {
                        if (isset($_GET['addAll'])) {
                            isset($_GET['filter']) ? $nonBlogsCreators = eF_filterData($nonBlogsCreators, $_GET['filter']) : null;
                            foreach ($nonBlogsCreators as $key => $value) {
                                $fields = array('blogs_ID' => $_GET['edit_blog'], 'users_login' => $key);
                                $res = eF_insertTableData("module_blogs_users", $fields);
                            }
                        } else {
                            if (isset($_GET['removeAll'])) {
                                isset($_GET['filter']) ? $blogCreators = eF_filterData($blogsCreatorsTemp, $_GET['filter']) : null;
                                foreach ($blogsCreatorsTemp as $key => $value) {
                                    eF_deleteTableData("module_blogs_users", "blogs_ID=" . $_GET['edit_blog'] . " AND users_LOGIN='******'");
                                }
                            }
                        }
                    }
                } catch (Exception $e) {
                    header("HTTP/1.0 500 ");
                    echo $e->getMessage() . ' (' . $e->getCode() . ')';
                }
                exit;
            }
        } elseif (isset($_GET['add_article']) || isset($_GET['edit_article'])) {
            $resAccess = eF_getTableData("module_blogs", "*", "id=" . $_GET['blog_id']);
            if (isset($_GET['edit_article'])) {
                $article_data = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['edit_article']);
                if ($resAccess[0]['users_LOGIN'] != $_SESSION['s_login'] && $article_data[0]['users_LOGIN'] != $_SESSION['s_login']) {
                    eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode(_BLOGS_NOACCESS));
                }
                $post_target = $this->moduleBaseUrl . '&edit_article=' . $_GET['edit_article'];
            } else {
                $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $_GET['blog_id'] . " and users_LOGIN='******'s_login'] . "'");
                if ($resAccess[0]['users_LOGIN'] != $_SESSION['s_login'] && sizeof($creator) == 0) {
                    eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode(_BLOGS_NOACCESS));
                }
                $post_target = $this->moduleBaseUrl . '&add_article';
            }
            global $load_editor;
            $load_editor = true;
            $form = new HTML_QuickForm("article_add_form", "post", $post_target . "&blog_id=" . $_GET['blog_id'], "", null, true);
            //Build the form
            $form->addElement('text', 'title', _TITLE, 'class = "inputText"');
            $form->addRule('title', _THEFIELD . ' "' . _TITLE . '" ' . _ISMANDATORY, 'required', null, 'client');
            $form->addElement('textarea', 'data', _DATA, 'class = "simpleEditor"  id="blog_article_data" style = "width:100%;height:25em;"');
            $form->addElement('submit', 'submit_add_article', _SUBMIT, 'class = "flatButton"');
            if (isset($_GET['edit_article'])) {
                $form->setDefaults(array('title' => $article_data[0]['title'], 'data' => $article_data[0]['data']));
            }
            if ($form->isSubmitted() && $form->validate()) {
                //If the form is submitted and validated
                $values = $form->exportValues();
                $fields = array("title" => $values['title'], "data" => $values['data']);
                if (isset($_GET['edit_article'])) {
                    if (eF_updateTableData("module_blogs_articles", $fields, "id=" . $_GET['edit_article'])) {
                        $message = _BLOGS_ARTICLEUPDATEDSUCCESSFULLY;
                        $message_type = 'success';
                    } else {
                        $message = _BLOGS_ARTICLENOTUPDATED;
                        $message_type = 'failure';
                    }
                    eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                } else {
                    $fields['users_LOGIN'] = $_SESSION['s_login'];
                    $fields['timestamp'] = time();
                    $fields['blogs_ID'] = $_GET['blog_id'];
                    //pr($fields);exit;
                    $new_id = eF_insertTableData("module_blogs_articles", $fields);
                    if ($new_id) {
                        $message = _BLOGS_ARTICLEADDEDSUCCESSFULLY;
                        $message_type = 'success';
                    } else {
                        $message = _BLOGS_ARTICLENOTADDED;
                        $message_type = 'failure';
                    }
                    eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                }
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            //Create a smarty renderer
            $renderer->setRequiredTemplate('{$html}{if $required}
				&nbsp;<span class = "formRequired">*</span>
			{/if}');
            $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
            //Set javascript error messages
            $form->setRequiredNote(_REQUIREDNOTE);
            $form->accept($renderer);
            //Assign this form to the renderer, so that corresponding template code is created
            $smarty->assign('T_ARTICLE_ADD_FORM', $renderer->toArray());
            //Assign the form to the template
        } elseif (isset($_GET['add_comment']) || isset($_GET['edit_comment'])) {
            if (isset($_GET['edit_comment'])) {
                $comment_data = eF_getTableData("module_blogs_comments", "*", "id=" . $_GET['edit_comment']);
                $blogAccess = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['article_id']);
                if ($comment_data[0]['users_LOGIN'] != $_SESSION['s_login'] && $blogAccess[0]['users_LOGIN'] != $_SESSION['s_login']) {
                    eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode(_BLOGS_NOACCESS));
                }
                $post_target = $this->moduleBaseUrl . '&edit_comment=' . $_GET['edit_comment'];
            } else {
                $post_target = $this->moduleBaseUrl . '&add_comment';
            }
            global $load_editor;
            $load_editor = true;
            $form = new HTML_QuickForm("blog_comment_form", "post", $post_target . "&article_id=" . $_GET['article_id'], "", null, true);
            //Build the form
            $form->addElement('textarea', 'data', _COMMENT, 'class = "inputContentTextarea simpleEditor" style = "width:80%;height:10em;"');
            $form->addElement('submit', 'submit_add_comment', _SUBMIT, 'class = "flatButton"');
            if (isset($_GET['edit_comment'])) {
                $form->setDefaults(array('data' => $comment_data[0]['data']));
            }
            if ($form->isSubmitted() && $form->validate()) {
                //If the form is submitted and validated
                $values = $form->exportValues();
                $fields = array("data" => $values['data'], "users_LOGIN" => $currentUser->user['login'], "blogs_articles_ID" => $_GET['article_id'], "timestamp" => time());
                if (isset($_GET['edit_comment'])) {
                    if (eF_updateTableData("module_blogs_comments", $fields, "id=" . $_GET['edit_comment'])) {
                        $message = _BLOGS_COMMENTUPDATEDSUCCESSFULLY;
                        $message_type = 'success';
                    } else {
                        $message = _BLOGS_COMMENTNOTUPDATED;
                        $message_type = 'failure';
                    }
                    eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                } else {
                    //pr($fields);
                    $new_id = eF_insertTableData("module_blogs_comments", $fields);
                    if ($new_id) {
                        $message = _BLOGS_COMMENTADDEDSUCCESSFULLY;
                        $message_type = 'success';
                    } else {
                        $message = _BLOGS_COMMENTNOTADDED;
                        $message_type = 'failure';
                    }
                    eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                }
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            //Create a smarty renderer
            $renderer->setRequiredTemplate('{$html}{if $required}
				&nbsp;<span class = "formRequired">*</span>
			{/if}');
            $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
            //Set javascript error messages
            $form->setRequiredNote(_REQUIREDNOTE);
            $form->accept($renderer);
            //Assign this form to the renderer, so that corresponding template code is created
            $smarty->assign('T_COMMENT_ADD_FORM', $renderer->toArray());
            //Assign the form to the template
            $article = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['article_id']);
            $blogComments = eF_getTableData("module_blogs_comments", "*", "blogs_articles_ID=" . $_GET['article_id'], "timestamp asc");
            $article[0]['comments'] = sizeof($blogComments);
            $blog = eF_getTableData("module_blogs", "*", "id=" . $article[0]['blogs_ID']);
            $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $article[0]['blogs_ID'] . " and users_LOGIN='******'s_login'] . "'");
            if (sizeof($creator) > 0) {
                $smarty->assign("T_BLOGS_ISBLOGCREATOR", 1);
            }
            $smarty->assign("T_BLOGS_BLOG", $blog[0]);
            $smarty->assign("T_BLOGS_ARTICLE", $article[0]);
            $smarty->assign("T_BLOGS_COMMENTS", $blogComments);
        } elseif (isset($_GET['view_blog'])) {
            $blog = eF_getTableData("module_blogs", "*", "id=" . $_GET['view_blog']);
            $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $_GET['view_blog'] . " and users_LOGIN='******'s_login'] . "'");
            if (sizeof($creator) > 0) {
                $smarty->assign("T_BLOGS_ISBLOGCREATOR", 1);
            }
            $blogPosts = eF_getTableData("module_blogs_articles", "*", "blogs_ID=" . $_GET['view_blog'], "timestamp desc");
            //pr($blogPosts);
            $indexing = array();
            foreach ($blogPosts as $key => $value) {
                $indexing[date('Y', $blogPosts[$key]['timestamp'])][date('F', $blogPosts[$key]['timestamp'])][$value['id']] = $value['title'];
                $blogComments = eF_getTableData("module_blogs_comments", "*", "blogs_articles_ID=" . $value['id'], "timestamp desc");
                $blogPosts[$key]['last_comment'] = $blogComments[0];
                $blogPosts[$key]['comments'] = sizeof($blogComments);
            }
            //pr($indexing);
            //pr($blogPosts);
            $lastComments = eF_getTableData("module_blogs_comments as com,module_blogs_articles as art", "com.id as comment_id,com.data,com.timestamp,art.id as article_id,art.title,com.users_LOGIN", "com.blogs_articles_ID=art.id and art.blogs_ID=" . $_GET['view_blog'], "com.timestamp desc");
            $smarty->assign("T_BLOGS_INDEXING", $indexing);
            $smarty->assign("T_BLOGS_LASTCOMMENTS", $lastComments);
            $smarty->assign("T_BLOGS_BLOG", $blog[0]);
            $smarty->assign("T_BLOGS_POSTS", $blogPosts);
        } elseif (isset($_GET['view_article'])) {
            $article = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['view_article']);
            $blogComments = eF_getTableData("module_blogs_comments", "*", "blogs_articles_ID=" . $_GET['view_article'], "timestamp asc");
            $article[0]['comments'] = sizeof($blogComments);
            $blog = eF_getTableData("module_blogs", "*", "id=" . $article[0]['blogs_ID']);
            $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $article[0]['blogs_ID'] . " and users_LOGIN='******'s_login'] . "'");
            if (sizeof($creator) > 0) {
                $smarty->assign("T_BLOGS_ISBLOGCREATOR", 1);
            }
            $smarty->assign("T_BLOGS_BLOG", $blog[0]);
            $smarty->assign("T_BLOGS_ARTICLE", $article[0]);
            $smarty->assign("T_BLOGS_COMMENTS", $blogComments);
        } else {
            $lessonBlogs = eF_getTableData("module_blogs", "*", "lessons_ID=" . $currentLesson->lesson['id']);
            foreach ($lessonBlogs as $key => $value) {
                //echo $value['id'];
                $res = eF_getTableData("module_blogs_articles", "*", "blogs_ID=" . $value['id'], "timestamp desc");
                $lessonBlogs[$key]['last_article'] = $res[0];
                /*		$creators  = eF_getTableData("module_blogs_users","*","blogs_ID=".$value['id']." and users_LOGIN='******'s_login']."'");
                				if (sizeof($creators) > 0) {
                					$lessonBlogs[$key]['is_creator'] = 1;
                				} else{
                					$lessonBlogs[$key]['is_creator'] = 0;
                				} */
            }
            //pr($lessonBlogs);
            //$smarty -> assign("T_BLOGS_LASTARTICLE", $lastArticle);
            $smarty->assign("T_BLOGS_LESSONBLOGS", $lessonBlogs);
            $smarty->assign("T_BLOGS_CLESSON", $currentLesson);
            $smarty->assign("T_BLOGS_CUSER", $currentUser);
            $smarty->assign("T_BLOGS_ROLE", $role);
            return true;
        }
    }
 /**
  * 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;
 }
</head>
<body>
<?php 
set_include_path(get_include_path() . ";c:\\php\\pear");
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('frmTest', 'post');
$form->addElement('text', 'Pseudo', 'Votre pseudo : ');
$form->addElement('text', 'Nom', 'Votre nom : ');
$form->addElement('text', 'Email', 'Votre adresse email : ');
$options = array('language' => 'fr', 'format' => 'dMY', 'minYear' => 2001, 'maxYear' => 2005);
$form->addElement('date', 'date', 'votre date de naissance : ', $options);
$form->addRule('Pseudo', 'Vous devez saisir un pseudo', 'required', '', 'client');
$form->addRule('Nom', 'Vous devez saisir un nom', 'required', '', 'client');
$form->addRule('Email', 'Vous devez saisir une adresse Email', 'required', '', 'client');
$form->addRule('Pseudo', 'Votre pseudo doit avoir entre 6 caractères et 10 caractères', 'rangelength', array(6, 10), 'client');
$form->addRule('Email', 'Vous devez saisir une adresse email valide', 'email', '', 'client');
$form->applyFilter('Nom', 'trim');
$form->applyFilter('Pseudo', 'trim');
$form->setRequiredNote('<span style="color: #ff0000">*</span> = champs obligatoires');
$form->setJsWarnings('Erreur de saisie', 'Veuillez corriger');
$form->addElement('reset', 'bouton_clear', 'Effacer');
$form->addElement('submit', 'bouton_effacer', 'Envoyer');
if ($form->validate()) {
    echo "Toutes les règles sont respectées<br>";
} else {
    $form->display();
}
?>
</body>
</html>
 public function getSmartyTpl()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $currentLesson = $this->getCurrentLesson();
     $currentLessonID = $currentLesson->lesson['id'];
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
         // XXX
         $workbookLessonName = _WORKBOOK_NAME . ' [' . $this->getWorkbookLessonName($currentLessonID) . ']';
         $smarty->assign("T_WORKBOOK_LESSON_NAME", $workbookLessonName);
         $lessonQuestions = $this->getLessonQuestions($currentLessonID);
         $workbookLessons = $this->isWorkbookInstalledByUser($currentUser, $currentUser->getRole($this->getCurrentLesson()), $currentLessonID);
         $workbookItems = $this->getWorkbookItems($currentLessonID);
         $nonOptionalQuestionsNr = $this->getNonOptionalQuestionsNr($workbookItems);
         if ($nonOptionalQuestionsNr != 0) {
             $questionPercentage = (double) (100 / $nonOptionalQuestionsNr);
             $questionPercentage = round($questionPercentage, 2);
         }
         $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID);
     }
     if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         $smarty->assign("T_WORKBOOK_SETTINGS", $workbookSettings);
     }
     $smarty->assign("T_WORKBOOK_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_WORKBOOK_BASELINK", $this->moduleBaseLink);
     global $popup;
     isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = '');
     if (isset($_REQUEST['question_preview']) && $_REQUEST['question_preview'] == '1' && isset($_REQUEST['question_id']) && eF_checkParameter($_REQUEST['question_id'], 'id')) {
         $id = $_REQUEST['question_id'];
         if (!in_array($id, array_keys($lessonQuestions))) {
             // reused item
             $reusedQuestion = $this->getReusedQuestionDetails($id);
             $type = $reusedQuestion['type'];
         } else {
             $type = $lessonQuestions[$id]['type'];
         }
         echo $this->questionToHtml($id, $type);
         exit;
     }
     if (isset($_REQUEST['get_progress']) && $_REQUEST['get_progress'] == '1') {
         $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr);
         $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID);
         if ($isWorkbookCompleted['is_completed'] == 1) {
             $unitToComplete = $workbookSettings['unit_to_complete'];
             $result = eF_updateTableData('module_workbook_progress', array('completion_date' => time()), "lessons_ID='" . $currentLessonID . "' AND users_LOGIN='******'login'] . "'");
             if ($unitToComplete != -1) {
                 $currentUser->setSeenUnit($unitToComplete, $currentLessonID, true);
             }
         }
         echo $studentProgress . '-' . $isWorkbookCompleted['id'];
         exit;
     }
     if (isset($_GET['edit_settings']) && $_GET['edit_settings'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $content = new EfrontContentTree($currentLessonID);
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'theory'));
         $contentOptions = $content->toHTMLSelectOptions($iterator);
         $contentOptions = array(-1 => '-------------') + $contentOptions;
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         if ($isWorkbookPublished == 1) {
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace('&nbsp;', '', $contentOptions[$workbookSettings['unit_to_complete']]);
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace('&raquo;', '', $contentOptions[$workbookSettings['unit_to_complete']]);
         }
         $form = new HTML_QuickForm("edit_settings_form", "post", $this->moduleBaseUrl . "&edit_settings=1", "", null, true);
         $form->addElement('text', 'lesson_name', _WORKBOOK_LESSON_NAME, 'class="inputText"');
         $form->addRule('lesson_name', _THEFIELD . ' "' . _WORKBOOK_LESSON_NAME . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('advcheckbox', 'allow_print', _WORKBOOK_ALLOW_PRINT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'allow_export', _WORKBOOK_ALLOW_EXPORT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'edit_answers', _WORKBOOK_EDIT_ANSWERS, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('select', 'unit_to_complete', _WORKBOOK_UNIT_TO_COMPLETE, $contentOptions);
         $form->addElement('submit', 'submit', _UPDATE, 'class="flatButton"');
         if ($isWorkbookPublished == 1) {
             $form->freeze('unit_to_complete');
         }
         $form->setDefaults($workbookSettings);
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $fields = array("lesson_name" => $values['lesson_name'], "allow_print" => $values['allow_print'], "allow_export" => $values['allow_export'], "edit_answers" => $values['edit_answers'], "unit_to_complete" => $values['unit_to_complete']);
             if (eF_updateTableData("module_workbook_settings", $fields, "id=" . $workbookSettings['id'])) {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_SUCCESSFULLY_EDITED);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
             } else {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_EDIT_PROBLEM);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'failure');
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_EDIT_SETTINGS_FORM', $renderer->toArray());
     }
     if (isset($_GET['reuse_item']) && $_GET['reuse_item'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $form = new HTML_QuickForm("reuse_item_form", "post", $this->moduleBaseUrl . "&reuse_item=1", "", null, true);
         $form->addElement('text', 'item_id', _WORKBOOK_ITEM_ID, 'class="inputText"');
         $form->addRule('item_id', _THEFIELD . ' "' . _WORKBOOK_ITEM_ID . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('submit', 'submit', _WORKBOOK_REUSE_ITEM, 'class="flatButton"');
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $existingIDs = $this->getItemsUniqueIDs();
             if (!in_array($values['item_id'], $existingIDs)) {
                 $message = _WORKBOOK_INVALID_UNIQUE_ID;
                 $message_type = 'failure';
                 $this->setMessageVar(urlencode($message), $message_type);
             } else {
                 $item = $this->getItemByUniqueID($values['item_id']);
                 $fields = array("item_title" => $item['item_title'], "item_text" => $item['item_text'], "item_question" => $item['item_question'], "question_text" => $item['question_text'], "check_answer" => $item['check_answer'], "lessons_ID" => $currentLessonID, "unique_ID" => $this->generateItemID(), "position" => $this->itemPosition($currentLessonID));
                 if (eF_insertTableData("module_workbook_items", $fields)) {
                     $smarty->assign("T_WORKBOOK_MESSAGE", urlencode(_WORKBOOK_ITEM_SUCCESSFULLY_ADDED));
                     $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
                 } else {
                     $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_ADD_PROBLEM);
                     $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'failure');
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_REUSE_ITEM_FORM', $renderer->toArray());
     }
     if (isset($_GET['move_item']) && eF_checkParameter($_GET['move_item'], 'id') && in_array($_GET['move_item'], array_keys($workbookItems))) {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $smarty->assign("T_WORKBOOK_ITEMS_COUNT", count($workbookItems));
         $itemPosition = $workbookItems[$_GET['move_item']]['position'];
         $availablePositions = array();
         foreach ($workbookItems as $key => $value) {
             if ($value['position'] != $itemPosition) {
                 $availablePositions[$value['position']] = $value['position'];
             }
         }
         $form = new HTML_QuickForm("move_item_form", "post", $this->moduleBaseUrl . "&move_item=" . $_GET['move_item'], "", null, true);
         $form->addElement('select', 'item_position', _WORKBOOK_ITEM_NEW_POSITION, $availablePositions, '');
         $form->addElement('submit', 'submit', _WORKBOOK_MOVE_ITEM, 'class="flatButton"');
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $newPosition = $values['item_position'];
             if ($newPosition > $itemPosition) {
                 foreach ($workbookItems as $key => $value) {
                     if ($value['position'] > $itemPosition && $value['position'] <= $newPosition) {
                         eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key);
                     }
                 }
             } else {
                 foreach ($workbookItems as $key => $value) {
                     if ($value['position'] < $itemPosition && $value['position'] >= $newPosition) {
                         eF_updateTableData("module_workbook_items", array('position' => $value['position'] + 1), "id=" . $key);
                     }
                 }
             }
             eF_updateTableData("module_workbook_items", array('position' => $newPosition), "id=" . $_GET['move_item']);
             $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_SUCCESSFULLY_MOVED);
             $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_MOVE_ITEM_FORM', $renderer->toArray());
     }
     if (isset($_GET['delete_item']) && eF_checkParameter($_GET['delete_item'], 'id') && in_array($_GET['delete_item'], array_keys($workbookItems))) {
         $item_id = $_GET['delete_item'];
         $itemPosition = $workbookItems[$item_id]['position'];
         foreach ($workbookItems as $key => $value) {
             if ($value['position'] > $itemPosition) {
                 eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key);
             }
         }
         eF_deleteTableData("module_workbook_items", "id=" . $item_id);
     }
     if (isset($_GET['switch_lesson']) && eF_checkParameter($_GET['switch_lesson'], 'id') && in_array($_GET['switch_lesson'], array_keys($workbookLessons))) {
         $lessonID = $_GET['switch_lesson'];
         eF_redirect("location:" . $this->moduleBaseUrl . "&lessons_ID=" . $lessonID . $popup_);
     }
     if (isset($_GET['add_item']) && $_GET['add_item'] == '1' || isset($_GET['edit_item']) && eF_checkParameter($_GET['edit_item'], 'id') && in_array($_GET['edit_item'], array_keys($workbookItems))) {
         if ($_SESSION['s_type'] != "professor") {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_);
         }
         global $load_editor;
         $load_editor = true;
         $questionsText = array();
         $questionsText[-1] = "-----------------------";
         foreach ($lessonQuestions as $key => $value) {
             $questionsText[$key] = $this->truncateText(strip_tags($value['text']), 70);
         }
         if (isset($_GET['edit_item'])) {
             $editItemID = $_GET['edit_item'];
             $editItemQuestion = $workbookItems[$editItemID]['item_question'];
             if ($editItemQuestion != '-1' && !in_array($editItemQuestion, array_keys($questionsText))) {
                 // reused item
                 $reusedQuestion = $this->getReusedQuestionDetails($editItemQuestion);
                 $questionsText[$editItemQuestion] = $this->truncateText(strip_tags($reusedQuestion['text']), 70);
             }
         }
         isset($_GET['add_item']) ? $postTarget = "&add_item=1" : ($postTarget = "&edit_item=" . $_GET['edit_item']);
         $form = new HTML_QuickForm("add_edit_item_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
         $form->addElement('text', 'item_title', _WORKBOOK_ITEM_TITLE, 'class="inputText" style="width:500px;"');
         $form->addElement('textarea', 'item_text', _WORKBOOK_ITEM_TEXT, 'class="mceEditor" style="width:99%;height:300px;" id="editor_content_data"');
         $form->addElement('select', 'item_question', _WORKBOOK_ITEM_QUESTION, $questionsText, 'onchange="questionPreview(this)"');
         $form->addElement('advcheckbox', 'check_answer', _WORKBOOK_ITEM_GRADE_ANSWER, null, 'class="inputCheckBox"', array(0, 1));
         if (isset($_GET['add_item'])) {
             $form->addElement('submit', 'submit', _WORKBOOK_ADD_ITEM, 'class="flatButton"');
         } else {
             $form->addElement('submit', 'submit', _WORKBOOK_UPDATE_ITEM, 'class="flatButton"');
         }
         if (isset($_GET['edit_item'])) {
             $editItem = $workbookItems[$_GET['edit_item']];
             $form->setDefaults($editItem);
             if ($isWorkbookPublished == '1') {
                 $editItem['question_title'] = $questionsText[$editItem['item_question']];
                 if ($editItem['check_answer'] == '1') {
                     $editItem['check_answer_text'] = _YES;
                 } else {
                     $editItem['check_answer_text'] = _NO;
                 }
             }
             $smarty->assign('T_WORKBOOK_EDIT_ITEM_DETAILS', $editItem);
         }
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             isset($_GET['add_item']) ? $lessonID = $currentLessonID : ($lessonID = $editItem['lessons_ID']);
             isset($_GET['add_item']) ? $uniqueID = $this->generateItemID() : ($uniqueID = $editItem['unique_ID']);
             isset($_GET['add_item']) ? $position = $this->itemPosition($currentLessonID) : ($position = $editItem['position']);
             if ($values['item_question'] != '-1') {
                 $id = $values['item_question'];
                 if (!in_array($id, array_keys($lessonQuestions))) {
                     // edit reused item
                     $reusedQuestion = $this->getReusedQuestionDetails($id);
                     $type = $reusedQuestion['type'];
                 } else {
                     $type = $lessonQuestions[$id]['type'];
                 }
                 $questionText = $this->questionToHtml($id, $type);
             } else {
                 $questionText = '';
             }
             $fields = array("item_title" => $values['item_title'], "item_text" => $values['item_text'], "item_question" => $values['item_question'], "question_text" => $questionText, "check_answer" => $values['check_answer'], "lessons_ID" => $lessonID, "unique_ID" => $uniqueID, "position" => $position);
             if ($values['item_title'] == '' && $values['item_text'] == '' && $values['item_question'] == '-1') {
                 $message = _WORKBOOK_ITEM_EMPTY_FIELDS;
                 if (isset($_GET['add_item'])) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&add_item=1" . $popup_);
                 } else {
                     $itemID = $_GET['edit_item'];
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&edit_item=" . $itemID . $popup_);
                 }
             }
             if (isset($_GET['add_item'])) {
                 if (eF_insertTableData("module_workbook_items", $fields)) {
                     $message = _WORKBOOK_ITEM_SUCCESSFULLY_ADDED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
                 } else {
                     $message = _WORKBOOK_ITEM_ADD_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
                 }
             } else {
                 if (eF_updateTableData("module_workbook_items", $fields, "id=" . $_GET['edit_item'])) {
                     $message = _WORKBOOK_ITEM_SUCCESSFULLY_EDITED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
                 } else {
                     $message = _WORKBOOK_ITEM_EDIT_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_ADD_EDIT_ITEM_FORM', $renderer->toArray());
         $basedir = $currentLesson->getDirectory();
         $options = array('lessons_ID' => $currentLessonID, 'metadata' => 0);
         $url = $_SERVER['REQUEST_URI'];
         $extraFileTools = array(array('image' => 'images/16x16/arrow_right.png', 'title' => _INSERTEDITOR, 'action' => 'insert_editor'));
         include "file_manager.php";
     }
     if (isset($_GET['publish_workbook']) && $_GET['publish_workbook'] == '1') {
         $result = eF_getTableData("module_workbook_publish", "publish", "lessons_ID=" . $currentLessonID);
         if (count($result) == 0) {
             if (eF_insertTableData("module_workbook_publish", array('lessons_ID' => $currentLessonID, 'publish' => 1))) {
                 $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
             } else {
                 $message = _WORKBOOK_PUBLISH_PROBLEM;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
             }
         } else {
             if (eF_updateTableData("module_workbook_publish", array('publish' => 1), "lessons_ID=" . $currentLessonID)) {
                 $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
             } else {
                 $message = _WORKBOOK_PUBLISH_PROBLEM;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
             }
         }
     }
     if (isset($_GET['reset_workbook_professor']) && $_GET['reset_workbook_professor'] == '1') {
         eF_updateTableData("module_workbook_publish", array('publish' => 0), "lessons_ID=" . $currentLessonID);
         foreach ($workbookItems as $key => $value) {
             eF_deleteTableData("module_workbook_answers", "item_id=" . $key);
             eF_deleteTableData("module_workbook_autosave", "item_id=" . $key);
             eF_deleteTableData("module_workbook_progress", "lessons_ID=" . $currentLessonID);
         }
     }
     if (isset($_GET['reset_workbook_student']) && eF_checkParameter($_GET['reset_workbook_student'], 'id')) {
         $id = $_GET['reset_workbook_student'];
         $result = eF_getTableData("module_workbook_progress", "users_LOGIN", "id=" . $id);
         if ($result[0]['users_LOGIN'] != $currentUser->user['login']) {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_);
         }
         eF_deleteTableData("module_workbook_progress", "id=" . $id);
         foreach ($workbookItems as $key => $value) {
             eF_deleteTableData("module_workbook_answers", "item_id=" . $key . " AND users_LOGIN='******'login'] . "'");
         }
         $unitToComplete = $workbookSettings['unit_to_complete'];
         if ($unitToComplete != -1) {
             $currentUser->setSeenUnit($unitToComplete, $currentLessonID, false);
         }
     }
     if (isset($_GET['download_as']) && $_GET['download_as'] == 'doc') {
         include dirname(__FILE__) . "/classes/html_to_doc.inc.php";
         $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
         $workbookHTML = '';
         foreach ($workbookItems as $key => $value) {
             $workbookHTML .= '<div style="width:98%;float:left;border:1px dotted #808080;padding: 5px 10px;">';
             $workbookHTML .= '<div style="background-color: #EAEAEA;border: 1px solid #AAAAAA;padding: 2px;font-weight: bold;">';
             $workbookHTML .= _WORKBOOK_ITEMS_COUNT . $value['position'];
             if ($value['item_title'] != '') {
                 $workbookHTML .= '&nbsp;-&nbsp;' . $value['item_title'];
             }
             $workbookHTML .= '</div><br/>';
             if ($value['item_text'] != '') {
                 $workbookHTML .= '<div>' . $value['item_text'] . '</div><br/>';
             }
             if ($value['item_question'] != '-1') {
                 $questionType = $lessonQuestions[$value['item_question']]['type'];
                 if ($workbookAnswers[$value['id']] == '') {
                     if ($questionType == 'drag_drop') {
                         $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']);
                         $options = unserialize($dragDrop[0]['options']);
                         $answer = unserialize($dragDrop[0]['answer']);
                         shuffle($options);
                         shuffle($answer);
                         $workbookHTML .= $dragDrop[0]['text'];
                         for ($i = 0; $i < count($options); $i++) {
                             $workbookHTML .= '<div>' . $options[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                             $workbookHTML .= $answer[$i] . '</div>';
                         }
                     } else {
                         $workbookHTML .= '<div>' . $value['question_text'] . '</div>';
                     }
                 } else {
                     $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>';
                 }
             }
             $workbookHTML .= '</div><br/>';
         }
         $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML);
         $fileName = _WORKBOOK_NAME . '_' . $this->getWorkbookLessonName($currentLessonID);
         $fileName = preg_replace('/[\\s]+/', '_', $fileName);
         $htmltodoc = new HTML_TO_DOC();
         $htmltodoc->createDoc($workbookHTML, $fileName, true);
         exit(0);
     }
     if (isset($_GET['download_as']) && $_GET['download_as'] == 'pdf') {
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor(PDF_AUTHOR);
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->setFontSubsetting(false);
         $pdf->AddPage();
         $completion_date = '';
         $resutlt = eF_getTableData('module_workbook_progress', 'completion_date', "users_LOGIN='******'login'] . "' and lessons_ID='" . $currentLessonID . "'");
         if ($resutlt) {
             $completion_date = $resutlt[0]['completion_date'];
         }
         $workbookHTML = '';
         $workbookHTML .= '<table>';
         $workbookHTML .= '<tr>';
         $workbookHTML .= '<td colspan="2">';
         $workbookHTML .= formatLogin($currentUser->user['login']);
         $workbookHTML .= '</td>';
         $workbookHTML .= '</tr>';
         $workbookHTML .= '<tr>';
         $workbookHTML .= '<td>';
         $workbookHTML .= $workbookLessonName;
         $workbookHTML .= '</td>';
         $workbookHTML .= '<td>';
         $workbookHTML .= formatTimestamp($completion_date);
         $workbookHTML .= '</td>';
         $workbookHTML .= '</tr>';
         $workbookHTML .= '</table>';
         $pdf->writeHTML($workbookHTML, true, false, true, false, '');
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->setHeaderFont(array('Freeserif', 'I', 11));
         $pdf->setFooterFont(array('Freeserif', '', 8));
         $pdf->setHeaderData('', '', '', $workbookLessonName);
         $pdf->AliasNbPages();
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
         $pdf->AddPage();
         $workbookHTML .= '';
         $itemLogo = new EfrontFile(G_DEFAULTIMAGESPATH . "32x32/unit.png");
         $itemLogoUrl = $itemLogo['path'];
         foreach ($workbookItems as $key => $value) {
             $workbookHTML .= '<div id="pdf-block" style="width:98%;float:left;border:1px dotted #808080;page-break-after:always;">';
             $workbookHTML .= '<div style="background-color: #EAEAEA;font-weight: bold;">';
             $workbookHTML .= '<img src="' . $itemLogoUrl . '"/>&nbsp;' . _WORKBOOK_ITEMS_COUNT . $value['position'];
             if ($value['item_title'] != '') {
                 $workbookHTML .= '&nbsp;-&nbsp;' . $value['item_title'];
             }
             $workbookHTML .= '</div>';
             if ($value['item_text'] != '') {
                 $workbookHTML .= '<div>' . $value['item_text'] . '</div>';
             }
             if ($value['item_question'] != '-1') {
                 $questionType = $lessonQuestions[$value['item_question']]['type'];
                 if ($workbookAnswers[$value['id']] == '') {
                     if ($questionType == 'drag_drop') {
                         $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']);
                         $options = unserialize($dragDrop[0]['options']);
                         $answer = unserialize($dragDrop[0]['answer']);
                         shuffle($options);
                         shuffle($answer);
                         $workbookHTML .= $dragDrop[0]['text'];
                         for ($i = 0; $i < count($options); $i++) {
                             $workbookHTML .= '<div>' . $options[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                             $workbookHTML .= $answer[$i] . '</div>';
                         }
                     } else {
                         $workbookHTML .= '<div>' . $value['question_text'] . '</div>';
                     }
                 } else {
                     $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>';
                 }
             }
             $workbookHTML .= '</div><br/>';
         }
         $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML);
         $pdf->writeHTML($workbookHTML, true, false, true, false, '');
         $fileName = _WORKBOOK_NAME . '_' . str_replace(' ', '_', $this->getWorkbookLessonName($currentLessonID)) . '.pdf';
         header("Content-type: application/pdf");
         header("Content-disposition: attachment; filename=" . $fileName);
         echo $pdf->Output('', 'S');
         exit(0);
     }
     if (isset($_GET['check_workbook_progress']) && $_GET['check_workbook_progress'] == '1') {
         $lessonStudents = $currentLesson->getUsers('student');
         $workbookStudents = array();
         foreach ($lessonStudents as $userLogin => $value) {
             if ($nonOptionalQuestionsNr != 0) {
                 $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID);
                 $studentProgress .= '%';
             } else {
                 $studentProgress = '-';
             }
             $workbookStudents[$userLogin] = array('login' => $userLogin, 'progress' => $studentProgress);
         }
         $smarty->assign("T_WORKBOOK_STUDENTS", $workbookStudents);
     }
     if (isset($_GET['preview_workbook']) && $_GET['preview_workbook'] == '1' && isset($_GET['student']) && eF_checkParameter($_GET['student'], 'login')) {
         $userLogin = $_GET['student'];
         $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID);
         $smarty->assign("T_WORKBOOK_PREVIEW_STUDENT_PROGRESS", $studentProgress);
         $workbookAnswers = $this->getWorkbookAnswers($userLogin, array_keys($workbookItems));
         $smarty->assign("T_WORKBOOK_PREVIEW_ANSWERS", $workbookAnswers);
     }
     if (isset($_GET['get_reset_message']) && $_GET['get_reset_message'] == '1') {
         echo $this->getResetMessage(array_keys($workbookItems));
         exit;
     }
     if (isset($_POST['item_submitted'])) {
         $itemID = $_POST['item_submitted'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $checkAnswer = $workbookItems[$itemID]['check_answer'];
         if (!in_array($questionID, array_keys($lessonQuestions))) {
             // reused item
             $reusedQuestion = $this->getReusedQuestionDetails($questionID);
             $questionType = $reusedQuestion['type'];
         } else {
             $questionType = $lessonQuestions[$questionID]['type'];
         }
         $question = QuestionFactory::factory($questionID);
         $question->setDone($_POST['question'][$questionID]);
         $results = $question->correct();
         if ($questionType != 'raw_text' && !ef_compare_float($results['score'], 1)) {
             print '-1';
         } else {
             $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
             $fields = array('item_id' => $itemID, 'html_solved' => $question->toHTMLSolved($form), 'users_LOGIN' => $currentUser->user['login']);
             eF_insertTableData("module_workbook_answers", $fields);
             if ($checkAnswer == '1') {
                 $this->updateStudentProgress($currentUser->user['login'], $currentLessonID, $questionPercentage, $nonOptionalQuestionsNr);
             }
             echo $question->toHTMLSolved($form);
         }
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         exit(0);
     }
     if (isset($_POST['item_submitted_autosave'])) {
         $itemID = $_POST['item_submitted_autosave'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $form->setDefaults($_POST);
         $fields = array('item_id' => $itemID, 'autosave_text' => $question->toHTML($form), 'users_LOGIN' => $currentUser->user['login']);
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         eF_insertTableData("module_workbook_autosave", $fields);
         exit(0);
     }
     if (isset($_POST['item_to_update'])) {
         $itemID = $_POST['item_to_update'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $question->userAnswer = urldecode($_POST['ans']);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $form->setDefaults($_POST);
         print $question->toHTML($form);
         exit(0);
     }
     if (isset($_POST['item_updated'])) {
         $itemID = $_POST['item_updated'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $question->setDone($_POST['question'][$questionID]);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $answerToUpdate = eF_getTableData("module_workbook_answers", "id", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         eF_updateTableData("module_workbook_answers", array('html_solved' => $question->toHTMLSolved($form)), "id=" . $answerToUpdate[0]['id']);
         echo $question->toHTMLSolved($form);
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         exit(0);
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
             $workbookItems = $this->getWorkbookItems($currentLessonID);
             $smarty->assign("T_WORKBOOK_ITEMS", $workbookItems);
             $smarty->assign("T_WORKBOOK_LESSONS", $workbookLessons);
             $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID);
             $smarty->assign("T_WORKBOOK_IS_PUBLISHED", $isWorkbookPublished);
             $smarty->assign("T_WORKBOOK_NON_OPTIONAL_QUESTIONS_NR", $nonOptionalQuestionsNr);
         }
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
             $workbookOptions[] = array('text' => _SETTINGS, 'image' => $this->moduleBaseLink . 'images/settings.png', 'href' => $this->moduleBaseUrl . '&edit_settings=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _SETTINGS . "', 0)", 'target' => 'POPUP_FRAME', 'id' => 'edit_settings');
             $workbookOptions[] = array('text' => _WORKBOOK_POPUP_INFO, 'image' => $this->moduleBaseLink . 'images/info.png', 'href' => $this->moduleBaseUrl . '&popup_info=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _WORKBOOK_POPUP_INFO . "', 2)", 'target' => 'POPUP_FRAME', 'id' => 'popup_info');
             $smarty->assign("T_WORKBOOK_OPTIONS", $workbookOptions);
         } else {
             if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
                 $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
                 $smarty->assign("T_WORKBOOK_ANSWERS", $workbookAnswers);
                 $autoSaveAnswers = $this->getAutoSaveAnswers($currentUser->user['login'], array_keys($workbookItems));
                 $smarty->assign("T_WORKBOOK_AUTOSAVE_ANSWERS", $autoSaveAnswers);
                 $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID);
                 $smarty->assign("T_WORKBOOK_STUDENT_PROGRESS", $studentProgress);
                 $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr);
                 $smarty->assign("T_WORKBOOK_IS_COMPLETED", $isWorkbookCompleted);
             }
         }
     }
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
         return $this->moduleBaseDir . "module_workbook_professor.tpl";
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
             return $this->moduleBaseDir . "module_workbook_student.tpl";
         }
     }
 }
Example #7
0
 $form->addElement('select', 'engine', __('Database engine'), array('postgres' => 'PostgreSQL', 'mysqlt' => 'MySQL'));
 $form->addRule('engine', __('Field required'), 'required');
 $form->addElement('text', 'user', __('Database server user'));
 $form->addRule('user', __('Field required'), 'required');
 $form->addElement('password', 'password', __('Database server password'));
 $form->addRule('password', __('Field required'), 'required');
 $form->addElement('text', 'db', __('Database name'));
 $form->addRule('db', __('Field required'), 'required');
 $create_db_warn_msg = __('WARNING: Make sure you have CREATE access level to do this!');
 $form->addElement('select', 'newdb', __('Create new database'), array(0 => __('No'), 1 => __('Yes')), array('onChange' => 'if(this.value==1) alert("' . $create_db_warn_msg . '","warning");'));
 $form->addRule('newdb', __('Field required'), 'required');
 $form->addElement('header', null, __('Other settings'));
 $form->addElement('select', 'direction', __('Text direction'), array(0 => __('Left to Right'), 1 => __('Right to Left')));
 $form->addElement('submit', 'submit', __('Next'));
 $form->setDefaults(array('engine' => 'mysqlt', 'db' => 'epesi', 'host' => 'localhost'));
 $form->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . __('denotes required field') . '</span>');
 if (file_exists($fast_install_filename)) {
     include $fast_install_filename;
     if (isset($CONFIG) && is_array($CONFIG)) {
         $txt = __('Some fields were filled to make installation easier.');
         print '<div style="text-align:center"><p style="width: 250px;margin-left: auto;margin-right: auto;">' . $txt . '</p></div>';
         foreach ($CONFIG as $key => $value) {
             $form->setDefaults(array($key => $value));
             $form->getElement($key)->freeze();
         }
     }
 }
 $required_note_text = __('denotes required field');
 $form->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . $required_note_text . '</span>');
 $form->addElement('html', '<tr><td colspan=2><br /><b>' . __('Any existing tables will be dropped!') . '</b><br />' . __('The database will be populated with data.') . '<br />' . __('This operation can take several minutes.') . '</td></tr>');
 if ($form->validate()) {
$attrsTextLong = array("size" => "50");
$form = new HTML_QuickForm('Form', 'post', '?p=' . $p);
$form->addElement('header', 'title', _('Centreon Nagvis configuration'));
$form->addElement('header', 'information', _('Nagvis information'));
$form->addElement('header', 'information2', _('Nagvis authentication'));
$form->addElement('text', 'centreon_nagvis_uri', _('Nagvis URI'), $attrsTextLong);
$form->addElement('text', 'centreon_nagvis_path', _('Nagvis Path'), $attrsTextLong);
$form->addElement('select', 'centreon_nagvis_auth', _("Single NagVis user auth or Centreon user auth ? "), array("single" => "Single User", "centreon" => "Centreon User"));
$form->addElement('text', 'centreon_nagvis_single_user', _('Nagvis user name'), $attrsTextLong);
$form->addRule('centreon_nagvis_uri', _('Compulsory field'), 'required');
$form->addRule('centreon_nagvis_path', _('Compulsory field'), 'required');
$form->addRule('centreon_nagvis_auth', _('Compulsory field'), 'required');
$form->addRule('centreon_nagvis_single_user', _('Compulsory field'), 'required');
$form->registerRule('exist', 'callback', 'nagvisInstall');
$form->addRule('centreon_nagvis_path', _('Directory does not exist'), 'exist');
$form->setRequiredNote("<font style='color: red;'>*</font>" . _(" Required fields"));
$form->addElement('submit', 'submitC', _("Save"));
$form->addElement('reset', 'reset', _("Reset"));
if ($form->validate()) {
    $values = $form->getSubmitValues();
    $queryInsert = 'UPDATE `options` SET `value` = "%s" WHERE `key` = "%s"';
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_uri']), 'centreon_nagvis_uri'));
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_path']), 'centreon_nagvis_path'));
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_auth']), 'centreon_nagvis_auth'));
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_single_user']), 'centreon_nagvis_single_user'));
}
/*
 * Get options
 */
if (!isset($values)) {
    $values = array();
Example #9
0
    public function __construct()
    {
        parent::__construct('batch_add_authors');
        if ($this->loginError) {
            return;
        }
        $this->use_mootools = true;
        $form = new HTML_QuickForm('batch_add', 'post', null, '_self', 'multipart/form-data');
        $tooltip = <<<TOOLTIP_END
New Authors::A semi-colon separated list of author names. Names can be in the following
formats:
&lt;ul&gt;
  &lt;li&gt;fist last&lt;/li&gt;
  &lt;li&gt;fist initials last&lt;/li&gt;
  &lt;li&gt;last, first&lt;/li&gt;
  &lt;li&gt;last, first initials&lt;/li&gt;
&lt;/ul&gt;
TOOLTIP_END;
        $form->addGroup(array(HTML_QuickForm::createElement('textarea', 'new_authors', null, array('cols' => 60, 'rows' => 10)), HTML_QuickForm::createElement('static', 'kwgroup_help', null, '<span class="small">Name format is: GIVEN_NAME1 [GIVEN_NAME2 .. etc.] LAST_NAME. Separate using semi-colons (;)</span>')), 'new_auth_group', "<span class=\"Tips1\" title=\"{$tooltip}\">New Authors:</span>", '<br/>', false);
        $form->addGroup(array(HTML_QuickForm::createElement('submit', 'submit', 'Add New Authors'), HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => 'history.back()'))), null, null, '&nbsp;', false);
        if ($form->validate()) {
            $values = $form->exportValues();
            $values['new_authors'] = preg_replace("/;\\s*;/", ';', $values['new_authors']);
            $new_authors = preg_split('/;\\s*/', $values['new_authors']);
            $fl_auth_list = pdAuthorList::create($this->db, null, null, true);
            $in_db_auths = array_intersect($fl_auth_list, $new_authors);
            $new_auths = array_diff($new_authors, $fl_auth_list);
            foreach ($new_auths as $auth_name) {
                $auth = new pdAuthor();
                $auth->nameSet($auth_name);
                $auth->dbSave($this->db);
                unset($auth);
            }
            if (count($in_db_auths) > 0) {
                echo 'These authors were already in the database:<ul>';
                foreach ($in_db_auths as $auth_name) {
                    echo '<li>', $auth_name, '</li>';
                }
            }
            if (count($new_auths) > 0) {
                if (count($in_db_auths) > 0) {
                    echo '</ul>', 'Only these authors were added to the database:', '<ul>';
                } else {
                    echo 'These authors were added to the database:<ul>';
                }
                foreach ($new_auths as $auth_name) {
                    echo '<li>', $auth_name, '</li>';
                }
                echo '</ul>';
            } else {
                echo '</ul>No authors were added to the database.';
            }
        } else {
            echo '<h2>Batch Add Authors</h2>';
            $renderer =& $form->defaultRenderer();
            $form->setRequiredNote('<font color="#FF0000">*</font> shows the required fields.');
            $form->accept($renderer);
            $this->form =& $form;
            $this->renderer =& $renderer;
            $this->js = <<<JS_END
window.addEvent('domready', function() {
                    var Tips1 = new Tips(\$\$('.Tips1'));
                });
JS_END;
        }
    }
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $currentLesson = $this->getCurrentLesson();
     $currentUser = $this->getCurrentUser();
     try {
         $currentContent = new EfrontContentTree($_SESSION['s_lessons_ID']);
         //Initialize content
     } catch (Exception $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _ERRORLOADINGCONTENT . ": " . $_SESSION['s_lessons_ID'] . ": " . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
     }
     //pr($currentUser);exit;
     $roles = EfrontUser::getRoles();
     //pr($roles);
     if ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "professor") {
         if (isset($_GET['view_deck']) && eF_checkParameter($_GET['view_deck'], 'id')) {
             $deck = $currentContent->seekNode($_GET['view_deck']);
             $questions = $deck->getQuestions(true);
             $cards = array();
             $possibleCardsIds = array();
             foreach ($questions as $key => $value) {
                 if ($value->question['type'] == 'empty_spaces') {
                     $cards[] = $value;
                     $possibleCardsIds[] = $value->question['id'];
                 }
             }
             $questions = $cards;
             //pr($questions);
             foreach ($questions as $qid => $question) {
                 $questions[$qid]->question['text'] = strip_tags($question->question['text']);
                 //If we ommit this line, then the questions list is html formatted, images are displayed etc, which is *not* the intended behaviour
                 //$questions[$qid]->question['answer']           = unserialize($question->question['answer']);
             }
             $res = eF_getTableData("module_flashcards_decks", "cards,options", "content_ID=" . $_GET['view_deck']);
             $resCards = unserialize($res[0]['cards']);
             $smarty->assign("T_FLASHCARDS_DECK_CARDS", $resCards);
             $post_target = $this->moduleBaseUrl . '&view_deck=' . $_GET['view_deck'] . "&tab=options";
             //Create form elements
             $form = new HTML_QuickForm("deck_options", "post", $post_target, "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             $form->addElement('advcheckbox', 'active', _FLASHCARDS_ACTIVE, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement("text", "low", _LOW, 'size = "5"');
             $form->addElement("text", "medium", _MEDIUM, 'size = "5"');
             $form->addElement("text", "hard", _HIGH, 'size = "5"');
             $form->addElement("text", "very_hard", _VERYHIGH, 'size = "5"');
             $form->addRule('low', _INVALIDFIELDDATA . ":" . _LOW, 'checkParameter', 'id');
             $form->addRule('medium', _INVALIDFIELDDATA . ":" . _MEDIUM, 'checkParameter', 'id');
             $form->addRule('hard', _INVALIDFIELDDATA . ":" . _HIGH, 'checkParameter', 'id');
             $form->addRule('very_hard', _INVALIDFIELDDATA . ":" . _VERYHIGH, 'checkParameter', 'id');
             $form->addElement('advcheckbox', 'answer_first', _FLASHCARDS_SHOWANSWERFIRST, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'shuffle', _FLASHCARDS_SHUFFLECARDS, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'display_mastery', _FLASHCARDS_DISPLAYMASTERY, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'wrong', _FLASHCARDS_WRONGREDUCES, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'show_count', _FLASHCARDS_SHOWSUCCESSCOUNT, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'show_explanation', _FLASHCARDS_SHOWEXPLANATION, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('submit', 'submit_options', _SAVECHANGES, 'class = "flatButton"');
             //The submit content button
             $options = unserialize($res[0]['options']);
             $form->setDefaults(array('active' => $options['active'], 'answer_first' => $options['answer_first'], 'shuffle' => $options['shuffle'], 'display_mastery' => $options['display_mastery'], 'wrong' => $options['wrong'], 'show_count' => $options['show_count'], 'show_explanation' => $options['show_explanation'], 'low' => $options['low'] == "" ? 1 : $options['low'], 'medium' => $options['medium'] == "" ? 2 : $options['medium'], 'hard' => $options['hard'] == "" ? 4 : $options['hard'], 'very_hard' => $options['very_hard'] == "" ? 6 : $options['very_hard']));
             if ($form->isSubmitted() && $form->validate()) {
                 //If the form is submitted and validated
                 $values = $form->exportValues();
                 unset($values['submit_options']);
                 $options = serialize($values);
                 if (sizeof($res) != 0) {
                     $ok = eF_updateTableData("module_flashcards_decks", array('options' => $options), "content_ID=" . $_GET['view_deck']);
                 } else {
                     $fields = array('content_ID' => $_GET['view_deck'], 'options' => $options);
                     $ok = eF_insertTableData("module_flashcards_decks", $fields);
                 }
                 if ($ok !== false) {
                     $message = _FLASHCARDS_SUCCESSFULLY;
                     $message_type = 'success';
                 } else {
                     $message = _FLASHCARDS_PROBLEMOCCURED;
                     $message_type = 'failure';
                 }
                 eF_redirect("" . $this->moduleBaseUrl . "&view_deck=" . $_GET['view_deck'] . "&tab=options&message=" . $message . "&message_type=" . $message_type);
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             //Create a smarty renderer
             $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
             //Set javascript error messages
             $form->setRequiredNote(_REQUIREDNOTE);
             $form->accept($renderer);
             //Assign this form to the renderer, so that corresponding template code is created
             $smarty->assign('T_FLASHCARDS_OPTIONS', $renderer->toArray());
             //Assign the form to the template
             if (isset($_GET['postAjaxRequest'])) {
                 try {
                     $result = eF_getTableData("module_flashcards_decks", "cards", "content_ID=" . $_GET['view_deck']);
                     //pr($result);exit;
                     $cardsArray = unserialize($result[0]['cards']);
                     if (isset($_GET['id']) && eF_checkParameter($_GET['id'], 'id')) {
                         if (!in_array($_GET['id'], array_values($cardsArray))) {
                             $cardsArray[] = $_GET['id'];
                             $cards = serialize($cardsArray);
                             if (sizeof($result) != 0) {
                                 $fields = array('cards' => $cards);
                                 eF_updateTableData("module_flashcards_decks", $fields, "content_ID=" . $_GET['view_deck']);
                             } else {
                                 $fields = array('content_ID' => $_GET['view_deck'], 'cards' => $cards);
                                 eF_insertTableData("module_flashcards_decks", $fields);
                             }
                         } elseif (in_array($_GET['id'], array_values($cardsArray))) {
                             unset($cardsArray[array_search($_GET['id'], $cardsArray)]);
                             if (!empty($cardsArray)) {
                                 $cards = serialize($cardsArray);
                                 $fields = array('cards' => $cards);
                                 eF_updateTableData("module_flashcards_decks", $fields, "content_ID=" . $_GET['view_deck']);
                             } else {
                                 eF_deleteTableData("module_flashcards_decks", "content_ID=" . $_GET['view_deck']);
                             }
                         }
                     } else {
                         if (isset($_GET['addAll'])) {
                             $cards = serialize($possibleCardsIds);
                             if (sizeof($result) != 0) {
                                 $fields = array('cards' => $cards);
                                 eF_updateTableData("module_flashcards_decks", $fields, "content_ID=" . $_GET['view_deck']);
                             } else {
                                 $fields = array('content_ID' => $_GET['view_deck'], 'cards' => $cards);
                                 eF_insertTableData("module_flashcards_decks", $fields);
                             }
                         } else {
                             if (isset($_GET['removeAll'])) {
                                 $fields = array('cards' => "");
                                 eF_updateTableData("module_flashcards_decks", $fields, "content_ID=" . $_GET['view_deck']);
                             }
                         }
                     }
                 } catch (Exception $e) {
                     header("HTTP/1.0 500 ");
                     echo $e->getMessage() . ' (' . $e->getCode() . ')';
                 }
                 exit;
             }
             $smarty->assign("T_FLASHCARDS_CARDS", $cards);
             $smarty->assign("T_FLASHCARDS_CARDS_SIZE", sizeof($cards));
         } else {
             $decksArray = array();
             $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST)));
             foreach ($iterator as $key => $value) {
                 $questions = $value->getQuestions(true);
                 $cards = array();
                 foreach ($questions as $key2 => $value2) {
                     if ($value2->question['type'] == 'empty_spaces') {
                         $cards[] = $value2;
                     }
                 }
                 if (sizeof($cards) > 0) {
                     $decksArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name'], 'questions' => sizeof($cards));
                 }
             }
             if (!empty($decksArray)) {
                 $str = implode(",", array_keys($decksArray));
                 $decks = eF_getTableDataFlat("module_flashcards_decks", "*", "content_ID IN (" . $str . ")");
                 $decksTemp = array_combine(array_values($decks['content_ID']), array_values($decks['options']));
                 $decksTemp2 = array_combine(array_values($decks['content_ID']), array_values($decks['cards']));
                 foreach ($decksArray as $key => $value) {
                     $decksArray[$value['id']]['options'] = unserialize($decksTemp[$key]);
                     $cardsTemp = unserialize($decksTemp2[$key]);
                     $decksArray[$value['id']]['num_cards'] = empty($cardsTemp) ? 0 : sizeof($cardsTemp);
                 }
             }
             //pr($decksArray);
             $smarty->assign("T_FLASHCARDS_DECKS", $decksArray);
         }
     } elseif ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "student") {
         if (isset($_GET['restart_deck']) && eF_checkParameter($_GET['restart_deck'], 'id')) {
             eF_deleteTableData("module_flashcards_users_to_cards", "users_LOGIN='******'s_login'] . "' AND content_ID=" . $_GET['restart_deck']);
         }
         if (isset($_GET['restart_decks'])) {
             eF_deleteTableData("module_flashcards_users_to_cards", "users_LOGIN='******'s_login'] . "'");
         }
         if ($_GET['answer'] == "true") {
             $resUserCard = eF_getTableData("module_flashcards_users_to_cards", "*", "cards_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             if (sizeof($resUserCard) == 0) {
                 $fields = array('users_LOGIN' => $_SESSION['s_login'], 'content_ID' => $_GET['view_deck'], 'cards_ID' => $_GET['view_card'], 'success' => '1');
                 eF_insertTableData("module_flashcards_users_to_cards", $fields);
             } else {
                 $success = $resUserCard[0]['success'] + 1;
                 eF_updateTableData("module_flashcards_users_to_cards", array('success' => $success), "cards_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             }
         } elseif ($_GET['answer'] == "false") {
             $resUserCard = eF_getTableData("module_flashcards_users_to_cards", "*", "cards_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             $currentDeckTemp = eF_getTableData("module_flashcards_decks", "options", "content_ID=" . $_GET['view_deck']);
             $deckTemp = unserialize($currentDeckTemp[0]['options']);
             if ($deckTemp['wrong'] == 1 && sizeof($resUserCard) != 0 && $resUserCard[0]['success'] != 0) {
                 $success = $resUserCard[0]['success'] - 1;
                 eF_updateTableData("module_flashcards_users_to_cards", array('success' => $success), "cards_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             }
         }
         $decksArray = array();
         $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST)));
         foreach ($iterator as $key => $value) {
             $decksArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name']);
         }
         if (empty($decksArray)) {
             $smarty->assign("T_FLASHCARDS_DECKSNAMES", $decksArray);
             return true;
         }
         $str = implode(",", array_keys($decksArray));
         $decks = eF_getTableData("module_flashcards_decks", "*", "content_ID IN (" . $str . ")");
         $mastery = eF_getTableDataFlat("module_flashcards_users_to_cards", "*", "content_ID IN (" . $str . ") and users_LOGIN='******'s_login'] . "'");
         $masteryArray = array_combine(array_values($mastery['cards_ID']), array_values($mastery['success']));
         $questionsDiff = eF_getTableDataFlat("questions", "*", "content_ID IN (" . $str . ")");
         $questionsDiffArray = array_combine(array_values($questionsDiff['id']), array_values($questionsDiff['difficulty']));
         $validDecks = array();
         foreach ($decks as $key => $value) {
             $opt = unserialize($value['options']);
             $cards = unserialize($value['cards']);
             if ($opt['active'] == 1 && !empty($cards)) {
                 $value['number_cards'] = empty($cards) ? 0 : sizeof($cards);
                 $validDecks[$value['content_ID']] = $value;
                 $validDecks[$value['content_ID']]['cards'] = $cards;
                 $validDecks[$value['content_ID']]['options'] = $opt;
                 $finishedCards = 0;
                 foreach ($cards as $index => $item) {
                     if ($masteryArray[$item] == $opt[$questionsDiffArray[$item]]) {
                         $finishedCards++;
                     }
                 }
                 $validDecks[$value['content_ID']]['non_finished'] = $value['number_cards'] - $finishedCards;
                 $validDecks[$value['content_ID']]['mastery'] = (double) $finishedCards / sizeof($cards) * 100;
             }
         }
         //pr($masteryArray);
         //pr($validDecks);
         //pr($decksArray);
         $smarty->assign("T_FLASHCARDS_DECKS", $validDecks);
         $smarty->assign("T_FLASHCARDS_DECKSNAMES", $decksArray);
         if (isset($_GET['view_deck'])) {
             $currentDeck = $validDecks[$_GET['view_deck']];
             $resUserSuccess = eF_getTableDataFlat("module_flashcards_users_to_cards", "*", "content_ID=" . $_GET['view_deck'] . " and users_LOGIN='******'s_login'] . "'");
             $successArray = array_combine(array_values($resUserSuccess['cards_ID']), array_values($resUserSuccess['success']));
             //pr($successArray);
             foreach ($currentDeck['cards'] as $key => $value) {
                 $questionTemp = new EmptySpacesQuestion($value);
                 $limit = $currentDeck['options'][$questionTemp->question['difficulty']];
                 if ($successArray[$value] == $limit && $value != $_GET['view_card']) {
                     unset($currentDeck['cards'][$key]);
                 }
             }
             $currentDeck['cards'] = array_values($currentDeck['cards']);
             if ($currentDeck['options']['shuffle'] == 1) {
                 shuffle($currentDeck['cards']);
             }
             if (!empty($currentDeck['cards'])) {
                 if (isset($_GET['view_card'])) {
                     while (current($currentDeck['cards']) != $_GET['view_card'] & next($currentDeck['cards']) !== false) {
                     }
                     if (current($currentDeck['cards']) === false) {
                         reset($currentDeck['cards']);
                     }
                     $_GET['view_card'] = current($currentDeck['cards']);
                 } else {
                     $_GET['view_card'] = $currentDeck['cards'][0];
                 }
                 //echo $_GET['view_card'];
                 $question = new EmptySpacesQuestion($_GET['view_card']);
                 $limit = $currentDeck['options'][$question->question['difficulty']];
                 if ($successArray[$_GET['view_card']] == $limit) {
                     $message = _FLASHCARDS_SUCCESSFULLYCOMPLETEDDECK;
                     $message_type = 'success';
                     eF_redirect($this->moduleBaseUrl . "&reset_popup=1&message=" . urlencode($message) . "&message_type=" . $message_type, true, 'parent');
                 } else {
                     //$form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
                     $form = new HTML_QuickForm();
                     $question->toHTMLQuickForm($form);
                     foreach ($question->answer as $key => $value) {
                         $form->setDefaults(array("question[" . $question->question['id'] . "][{$key}]" => "________"));
                     }
                     $form->freeze();
                     $smarty->assign("T_FLASHCARDS_CURRENTCARD_PREVIEW", $question->toHTML($form));
                     //$smarty -> assign("T_FLASHCARDS_CURRENTCARD_PREVIEW_ANSWERED", $question -> toHTMLSolved(new HTML_QuickForm(), true, false, false));
                     $smarty->assign("T_FLASHCARDS_CURRENTCARD_PREVIEW_ANSWERED", implode("<br/>", $question->answer));
                 }
             } else {
                 $message = _FLASHCARDS_SUCCESSFULLYCOMPLETEDDECK;
                 //$message_type = 'success';
                 eF_redirect("" . $this->moduleBaseUrl . "&popup=1&finish=1&message=" . $message . "&message_type=" . $message_type);
             }
             //pr($question);
             //pr($currentDeck);
             $smarty->assign("T_FLASHCARDS_CURRENTDECK", $currentDeck);
             $smarty->assign("T_FLASHCARDS_CURRENTCARD", $question);
             //pr($currentDeck);
             $smarty->assign("T_FLASHCARDS_SUCCESSARRAY", $successArray);
             $smarty->assign("T_FLASHCARDS_LESSONNAME", $currentLesson->lesson['name']);
         }
     }
     return true;
 }
Example #11
0
             }
             echo $res;
         } elseif ($type == 'form') {
             // template d'un formulaire bazar
             $url = $this->href('json', $this->GetPageTag(), 'demand=save_entry');
             //contruction du squelette du formulaire
             $formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace('/&amp;/', '&', $url));
             $squelette =& $formtemplate->defaultRenderer();
             $squelette->setFormTemplate('<form {attributes} class="form-horizontal content-padded list-spacer" ' . 'novalidate="novalidate">' . "\n" . '{content}' . "\n" . '</form>');
             $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="control-label col-xs-3">' . "\n" . '<!-- BEGIN required --><span class="symbole_obligatoire">*</span> <!-- END required -->' . "\n" . '{label} :</div>' . "\n" . '<div class="controls col-xs-8"> ' . "\n" . '{element}' . "\n" . '<!-- BEGIN error -->' . '<span class="alert alert-error alert-danger">{error}</span>' . '<!-- END error -->' . "\n" . '</div>' . "\n" . '</div>' . "\n");
             $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>' . "\n" . '<!-- BEGIN required -->' . '<span class="symbole_obligatoire">&nbsp;*</span>' . '<!-- END required -->' . "\n" . '</div>' . "\n" . '</div>' . "\n", 'accept_condition');
             $squelette->setElementTemplate('<div class="form-actions">{label}{element}</div>' . "\n", 'groupe_boutons');
             $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="control-label col-xs-3">' . "\n" . '{label} :</div>' . "\n" . '<div class="controls col-xs-8"> ' . "\n" . '{element}' . "\n" . '</div>' . "\n" . '</div>', 'select');
             $squelette->setRequiredNoteTemplate("<div class=\"symbole_obligatoire\">* {requiredNote}</div>\n");
             //Traduction de champs requis
             $formtemplate->setRequiredNote(_t('BAZ_CHAMPS_REQUIS'));
             $formtemplate->setJsWarnings(_t('BAZ_ERREUR_SAISIE'), _t('BAZ_VEUILLEZ_CORRIGER'));
             //antispam
             $formtemplate->addElement('hidden', 'antispam', 1);
             // generation du formulaire
             $form = baz_afficher_formulaire_fiche('saisie', $formtemplate, $url, '', true);
             $form = preg_replace('~<div class="form-actions">.*</div>~Ui', "\n" . '<a href="#" class="btn btn-block btn-positive btn-save">' . _t('BAZ_SAVE') . '</a>', $form);
             $form = preg_replace('~<div id="map".*>~Ui', "\n" . '<div id="map">', $form);
             echo json_encode(array('html' => $form));
         }
     }
     break;
 case "forms":
     // les formulaires bazar
     $formval = baz_valeurs_formulaire($form);
     // si un seul formulaire, on cree un tableau à une entrée
    /**
     * Constructor
     * @param string $form_name					Name of the form
     * @param string $method (optional			Method ('post' (default) or 'get')
     * @param string $action (optional			Action (default is $PHP_SELF)
     * @param string $target (optional			Form's target defaults to '_self'
     * @param mixed $attributes (optional)		Extra attributes for <form> tag
     * @param bool $track_submit (optional)		Whether to track if the form was
     * submitted by adding a special hidden field (default = true)
     */
    public function __construct($form_name, $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true)
    {
        // Default form class.
        if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
            $attributes['class'] = 'form-horizontal';
        }
        parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit);
        // Load some custom elements and rules
        $dir = api_get_path(LIBRARY_PATH) . 'formvalidator/';
        $this->registerElementType('html_editor', $dir . 'Element/html_editor.php', 'HTML_QuickForm_html_editor');
        $this->registerElementType('date_range_picker', $dir . 'Element/DateRangePicker.php', 'DateRangePicker');
        $this->registerElementType('date_time_picker', $dir . 'Element/DateTimePicker.php', 'DateTimePicker');
        $this->registerElementType('date_picker', $dir . 'Element/DatePicker.php', 'DatePicker');
        $this->registerElementType('datepicker', $dir . 'Element/datepicker_old.php', 'HTML_QuickForm_datepicker');
        $this->registerElementType('datepickerdate', $dir . 'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
        $this->registerElementType('receivers', $dir . 'Element/receivers.php', 'HTML_QuickForm_receivers');
        $this->registerElementType('select_language', $dir . 'Element/select_language.php', 'HTML_QuickForm_Select_Language');
        $this->registerElementType('select_ajax', $dir . 'Element/select_ajax.php', 'HTML_QuickForm_Select_Ajax');
        $this->registerElementType('select_theme', $dir . 'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
        $this->registerElementType('style_submit_button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('style_reset_button', $dir . 'Element/style_reset_button.php', 'HTML_QuickForm_styleresetbutton');
        $this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
        $this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
        $this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
        $this->registerRule('datetime', null, 'DateTimeRule', $dir . 'Rule/DateTimeRule.php');
        $this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
        $this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
        $this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir . 'Rule/UsernameAvailable.php');
        $this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir . 'Rule/Username.php');
        $this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir . 'Rule/Filetype.php');
        $this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir . 'Rule/MultipleRequired.php');
        $this->registerRule('url', null, 'HTML_QuickForm_Rule_Url', $dir . 'Rule/Url.php');
        $this->registerRule('mobile_phone_number', null, 'HTML_QuickForm_Rule_Mobile_Phone_Number', $dir . 'Rule/MobilePhoneNumber.php');
        $this->registerRule('compare_fields', null, 'HTML_QuickForm_Compare_Fields', $dir . 'Rule/CompareFields.php');
        $this->registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
        // Modify the default templates
        $renderer =& $this->defaultRenderer();
        //Form template
        $form_template = '<form{attributes}>
<fieldset>
	{content}
	<div class="clear"></div>
</fieldset>
{hidden}
</form>';
        $renderer->setFormTemplate($form_template);
        //Element template
        if (isset($attributes['class']) && $attributes['class'] == 'well form-inline') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } elseif (isset($attributes['class']) && $attributes['class'] == 'form-search') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } else {
            $element_template = '
            <div class="control-group {error_class}">
                <label class="control-label" {label-for}>
                    <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
                    {label}
                </label>
                <div class="controls">
                    {element}

                    <!-- BEGIN label_3 -->
                        {label_3}
                    <!-- END label_3 -->

                    <!-- BEGIN label_2 -->
                        <p class="help-block">{label_2}</p>
                    <!-- END label_2 -->

                    <!-- BEGIN error -->
                        <span class="help-inline">{error}</span>
                    <!-- END error -->
                </div>
            </div>';
            $renderer->setElementTemplate($element_template);
            //Display a gray div in the buttons
            $button_element_template_simple = '<div class="form-actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_simple, 'submit_in_actions');
            //Display a gray div in the buttons + makes the button available when scrolling
            $button_element_template_in_bottom = '<div class="form-actions bottom_actions bg-form">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_in_bottom, 'submit_fixed_in_bottom');
            //When you want to group buttons use something like this
            /* $group = array();
                $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll'));
                $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll'));
                $form->addGroup($group, 'buttons_in_action');
               */
            $renderer->setElementTemplate($button_element_template_simple, 'buttons_in_action');
            $button_element_template_simple_right = '<div class="form-actions"> <div class="pull-right">{label} {element}</div></div>';
            $renderer->setElementTemplate($button_element_template_simple_right, 'buttons_in_action_right');
            /*
             $renderer->setElementTemplate($button_element_template, 'submit_button');
             $renderer->setElementTemplate($button_element_template, 'submit');
             $renderer->setElementTemplate($button_element_template, 'button');
            *
            */
        }
        //Set Header template
        $renderer->setHeaderTemplate('<legend>{header}</legend>');
        //Set required field template
        HTML_QuickForm::setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
        $required_note_template = <<<EOT
\t<div class="control-group">
\t\t<div class="controls">{requiredNote}</div>
\t</div>
EOT;
        $renderer->setRequiredNoteTemplate($required_note_template);
    }
Example #13
0
                EfrontStats::createViews();
                if (!isset($_GET['unattended'])) {
                    header("location:" . $_SERVER['PHP_SELF'] . "?finish=1");
                    exit;
                }
            }
        } catch (Exception $e) {
            Installation::handleInstallationExceptions($e);
        }
    }
    $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
    $renderer->setRequiredTemplate('{$html}{if $required}
            &nbsp;<span class = "formRequired">*</span>
        {/if}');
    $form->setJsWarnings('The following errors occured:', 'Please correct the above errors');
    $form->setRequiredNote('* Denotes mandatory fields');
    $form->accept($renderer);
    $smarty->assign('T_DATABASE_FORM', $renderer->toArray());
}
if (isset($_GET['finish']) || isset($_GET['unattended'])) {
    if (isset($_GET['unattended'])) {
        if ($_GET['ajax']) {
            echo json_encode(array('status' => 1, 'message' => 'Successfully completed Unattended upgrade'));
            EfrontSystem::unlockSystem();
        } else {
            header("location:" . G_SERVERNAME . "index.php?delete_install=1");
        }
    } else {
        session_destroy();
        unset($_SESSION);
    }
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     global $load_editor;
     $load_editor = true;
     $current_user = $this->getCurrentUser();
     $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType());
     $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'");
     $form->addElement('hidden', 'recipients', $_GET['rec']);
     $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"');
     $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"');
     $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"');
     $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"');
     $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         switch ($values['recipients']) {
             case "lesson_students":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("student");
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 //pr($mail_recipients);return;
                 break;
             case "lesson_professors":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("professor");
                 if (isset($_SESSION['s_courses_ID'])) {
                     $course = new EfrontCourse($_SESSION['s_courses_ID']);
                     $course_users = $course->getCourseUsers();
                     foreach ($lessonUsers as $key => $value) {
                         if (!isset($course_users[$key])) {
                             unset($lessonUsers[$key]);
                         }
                     }
                 }
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
             case "admin":
                 $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0");
                 //not
                 foreach ($result as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
         }
         //$list = implode(",",$mail_recipients);
         $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']);
         if ($_FILES['attachment']['name'][0] != "") {
             $maxFileSize = FileSystemTree::getUploadMaxSize();
             if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
                 //	G_MAXFILESIZE is deprecated
                 $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes";
                 $message_type = 'failure';
             }
             //Upload user avatar file
             $pm->sender_attachment_timestamp = time();
             $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
             mkdir($user_dir, 0755);
             $filesystem = new FileSystemTree($user_dir);
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         }
         if ($pm->send($values['email'], $values)) {
             $message = _MESSAGEWASSENT;
             $message_type = 'success';
         } else {
             $message = $pm->errorMessage;
             $message_type = 'failure';
         }
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     //Create a smarty renderer
     $renderer->setRequiredTemplate('{$html}{if $required}
     	&nbsp;<span class = "formRequired">*</span>
 		{/if}');
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     //Set javascript error messages
     $form->setRequiredNote(_REQUIREDNOTE);
     $form->accept($renderer);
     //Assign this form to the renderer, so that corresponding template code is created
     $smarty->assign('T_MODULE_MAIL_FORM', $renderer->toArray());
     $smarty->assign("T_MESSAGE_MAIL", $message);
     $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type);
     //pr($renderer -> toArray());
     return true;
 }
    /**
     * Constructor
     * @param string $form_name					Name of the form
     * @param string $method (optional			Method ('post' (default) or 'get')
     * @param string $action (optional			Action (default is $PHP_SELF)
     * @param string $target (optional			Form's target defaults to '_self'
     * @param mixed $attributes (optional)		Extra attributes for <form> tag
     * @param bool $track_submit (optional)		Whether to track if the form was
     * submitted by adding a special hidden field (default = true)
     */
    public function __construct($form_name = null, $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true)
    {
        // Default form class
        if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
            $attributes['class'] = 'form-horizontal';
        }
        // Fixing form search
        if (is_array($attributes) && isset($attributes['class'])) {
            //if (strpos($attributes['class'], 'form-search')) {
            if ($attributes['class'] == 'form-search') {
                //    $attributes['class'] = str_replace('form-search', 'form-inline', $attributes['class']);
                $attributes['class'] = 'form-inline';
            }
        }
        // Allow form with no names
        if (empty($form_name)) {
            $form_name = uniqid();
        }
        parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit);
        // Load some custom elements and rules
        $dir = api_get_path(LIBRARY_PATH) . 'formvalidator/';
        $this->registerElementType('html_editor', $dir . 'Element/html_editor.php', 'HTML_QuickForm_html_editor');
        $this->registerElementType('datepicker', $dir . 'Element/datepicker.php', 'HTML_QuickForm_datepicker');
        $this->registerElementType('datepickerdate', $dir . 'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
        $this->registerElementType('receivers', $dir . 'Element/receivers.php', 'HTML_QuickForm_receivers');
        $this->registerElementType('select_language', $dir . 'Element/select_language.php', 'HTML_QuickForm_Select_Language');
        $this->registerElementType('select_theme', $dir . 'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
        $this->registerElementType('style_submit_button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
        $this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
        $this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
        $this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
        $this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
        $this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir . 'Rule/UsernameAvailable.php');
        $this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir . 'Rule/Username.php');
        $this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir . 'Rule/Filetype.php');
        $this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir . 'Rule/MultipleRequired.php');
        $this->registerRule('url', null, 'HTML_QuickForm_Rule_Url', $dir . 'Rule/Url.php');
        $this->registerRule('compare_fields', null, 'HTML_QuickForm_Compare_Fields', $dir . 'Rule/CompareFields.php');
        $this->registerRule('compare_datetime_text', null, 'HTML_QuickForm_Rule_CompareDateTimeText', $dir . 'Rule/CompareDateTimeText.php');
        $this->registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
        // Modify the default templates
        /** @var  HTML_QuickForm_Renderer_Default $renderer */
        $renderer =& $this->defaultRenderer();
        // Form template
        $renderer->setFormTemplate($this->getFormTemplate());
        // Element template
        if (isset($attributes['class']) && $attributes['class'] == 'well form-inline') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } elseif (isset($attributes['class']) && $attributes['class'] == 'form-search') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } else {
            if (is_array($attributes) && isset($attributes['class']) && $attributes['class'] == 'form-inline') {
                $element_template = $this->getDefaultInlineElementTemplate();
            } else {
                $element_template = $this->getDefaultElementTemplate();
            }
            $renderer->setElementTemplate($element_template);
            // Display a gray div in the buttons
            $button_element_template_simple = '<div class="form-actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_simple, 'submit_in_actions');
            //Display a gray div in the buttons + makes the button available when scrolling
            $button_element_template_in_bottom = '<div class="form-actions bottom_actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_in_bottom, 'submit_fixed_in_bottom');
            $renderer->setElementTemplate($button_element_template_simple, 'buttons_in_action');
            $button_element_template_simple_right = '<div class="form-actions"> <div class="pull-right">{label} {element}</div></div>';
            $renderer->setElementTemplate($button_element_template_simple_right, 'buttons_in_action_right');
        }
        // Set Header template
        $renderer->setHeaderTemplate('<h2>{header}</h2>');
        //Set required field template
        HTML_QuickForm::setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
        $required_note_template = <<<EOT
\t<div class="form-group">
\t\t<div class="col-sm-2">{requiredNote}</div>
\t</div>
EOT;
        $renderer->setRequiredNoteTemplate($required_note_template);
    }
Example #16
0
/** baz_formulaire_des_formulaires() retourne le formulaire de saisie des formulaires
 *   @return  Object    le code HTML
 */
function baz_formulaire_des_formulaires($mode, $valeursformulaire = '')
{
    $GLOBALS['_BAZAR_']['url']->addQueryString('action_formulaire', $mode);
    //contruction du squelette du formulaire
    $formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()));
    $GLOBALS['_BAZAR_']['url']->removeQueryString('action_formulaire');
    $squelette =& $formtemplate->defaultRenderer();
    $squelette->setFormTemplate('<form {attributes} class="form-horizontal">' . "\n" . '{content}' . "\n" . '</form>' . "\n");
    $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<label class="control-label col-sm-3">' . "\n" . '{label}' . '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->' . "\n" . ' </label>' . "\n" . '<div class="controls col-sm-9"> ' . "\n" . '{element}' . "\n" . '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->' . "\n" . '</div>' . "\n" . '</div>' . "\n");
    $squelette->setElementTemplate('<div class="form-actions form-group">' . "\n" . '<div class="col-sm-9 col-sm-offset-3">{label}{element}</div></div>' . "\n", 'groupe_boutons');
    $squelette->setRequiredNoteTemplate("\n" . '<div class="col-sm-9 col-sm-offset-3 symbole_obligatoire">* {requiredNote}</div>' . "\n");
    //traduction de champs requis
    $formtemplate->setRequiredNote(_t('BAZ_CHAMPS_REQUIS'));
    $formtemplate->setJsWarnings(_t('BAZ_ERREUR_SAISIE'), _t('BAZ_VEUILLEZ_CORRIGER'));
    //champs du formulaire
    if (isset($_GET['idformulaire'])) {
        $formtemplate->addElement('hidden', 'bn_id_nature', $_GET['idformulaire']);
    }
    $formtemplate->addElement('text', 'bn_label_nature', _t('BAZ_NOM_FORMULAIRE'), array('class' => 'form-control input-xxlarge'));
    $formtemplate->addElement('text', 'bn_type_fiche', _t('BAZ_CATEGORIE_FORMULAIRE'), array('class' => 'form-control input-xxlarge'));
    $formtemplate->addElement('textarea', 'bn_description', _t('BAZ_DESCRIPTION'), array('class' => 'form-control input-xxlarge', 'cols' => '20', 'rows' => '3'));
    $formtemplate->addElement('textarea', 'bn_condition', _t('BAZ_CONDITION'), array('class' => 'form-control input-xxlarge', 'cols' => '20', 'rows' => '3'));
    $formtemplate->addElement('text', 'bn_label_class', _t('BAZ_NOM_CLASSE_CSS'), array('class' => 'form-control input-xxlarge'));
    $formtemplate->addElement('textarea', 'bn_template', _t('BAZ_TEMPLATE'), array('class' => 'form-control input-xxlarge', 'cols' => '20', 'rows' => '15'));
    //champs obligatoires
    $formtemplate->addRule('bn_label_nature', _t('BAZ_CHAMPS_REQUIS') . ' : ' . _t('BAZ_FORMULAIRE'), 'required', '', 'client');
    $formtemplate->addRule('bn_template', _t('BAZ_CHAMPS_REQUIS') . ' : ' . _t('BAZ_TEMPLATE'), 'required', '', 'client');
    // Nettoyage de l'url avant les return
    $GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
    $HTML_QuickForm = new HTML_QuickForm();
    $buttons[] = $HTML_QuickForm->createElement('submit', 'valider', _t('BAZ_VALIDER'), array('class' => 'btn btn-success'));
    $buttons[] = $HTML_QuickForm->createElement('link', 'annuler', _t('BAZ_ANNULER'), str_replace('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL()), _t('BAZ_ANNULER'), array('class' => 'btn btn-mini btn-xs btn-danger'));
    $formtemplate->addGroup($buttons, 'groupe_boutons', null, '&nbsp;', 0);
    return $formtemplate;
}
Example #17
0
 /**
  * ファクトリー
  *
  * HTML_QuickFormインスタンス生成
  *
  * @param mixed $formName フォーム名 | フォーム名配列
  * @param array $options  オプション
  *
  * @return HTML_QuickForm
  * @access private
  */
 private function _factory($formName, array $options)
 {
     // QuickForm作成
     $form = new HTML_QuickForm($formName, $options['method'], $options['action'], $options['target'], $options['attributes'], $options['trackSubmit']);
     // 必須項目メッセージ日本語化
     $form->setRequiredNote(self::$requireNotes);
     // JSメッセージ日本語化
     $form->setJsWarnings(self::$jsWarning, '');
     // BEAR使用hidden項目
     $token = $this->_formToken->getToken();
     $form->addElement('hidden', '_token', $token);
     $log = $options;
     $log['formNames'] = $formName;
     $log['token'] = $token;
     $this->_log->log('Form', $log);
     return $form;
 }
Example #18
0
            $config_form->setDefaults(array($conf_option => $GLOBALS['configuration'][$conf_option]));
        }
        if ($config_form->isSubmitted()) {
            foreach ($notification_configurations as $conf_option) {
                EfrontConfiguration::setValue($conf_option, $config_form->exportValue($conf_option));
            }
            // Clear the stored sent messages according to the new limitations
            EfrontNotification::clearSentMessages();
            $message = _NOTIFICATIONCONFIGURATIONSUPDATEDSUCCESSFULLY;
            $message_type = 'success';
            eF_redirect("" . $_SESSION['s_type'] . ".php?ctg=digests&message=" . urlencode($message) . "&message_type=" . $message_type);
        }
        $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
        //Create a smarty renderer
        $renderer->setRequiredTemplate('{$html}{if $required}
                &nbsp;<span class = "formRequired">*</span>
            {/if}');
        if (isset($currentUser->coreAccess['notifications']) && $currentUser->coreAccess['notifications'] != 'change') {
            $config_form->freeze();
        }
        $config_form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
        //Set javascript error messages
        $config_form->setRequiredNote(_REQUIREDNOTE);
        $config_form->accept($renderer);
        //Assign this form to the renderer, so that corresponding template code is created
        $smarty->assign('T_NOTIFICATION_VARIABLES_FORM', $renderer->toArray());
        //Assign the form to the template
        $options = array(array('image' => '16x16/go_into.png', 'text' => _RESTOREDEFAULTNOTIFICATIONS, 'href' => 'administrator.php?ctg=digests&add_default=1'));
        $smarty->assign("T_TABLE_OPTIONS", $options);
    }
}
                }
                $fields = array("name" => $values['english_name'], "translation" => $values['translation'], "active" => 1, "rtl" => $values['rtl']);
                if (!$values['custom']) {
                    eF_insertTableData("languages", $fields);
                }
                EfrontCache::getInstance()->deleteCache('languages');
                //$RetValues = file(G_SERVERNAME."/editor/tiny_mce/langs/language.php?langname=".$values['english_name']);
                eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=languages&message=" . urlencode(_SUCCESSFULLYADDEDLANGUAGE) . "&message_type=success");
            }
        } 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';
        }
    }
    $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
    $renderer->setRequiredTemplate('{$html}{if $required}
                        &nbsp;<span class = "formRequired">*</span>
                    {/if}');
    $createForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
    //Set javascript error messages
    $createForm->setRequiredNote(_REQUIREDNOTE);
    $createForm->accept($renderer);
    $smarty->assign("T_CREATE_LANGUAGE_FORM", $renderer->toArray());
    $smarty->assign("T_MAX_FILE_SIZE", FileSystemTree::getUploadMaxSize());
    $dataSource = $languages;
    $tableName = 'languagesTable';
    /**Handle sorted table's sorting and filtering*/
    include "sorted_table.php";
}
$smarty->assign("T_LANGUAGES", $languages);
 public function getSmartyTpl()
 {
     $smarty = $this->getSmartyVar();
     $smarty->assign('T_CHAT_ERROR_RATE', "");
     $smarty->assign('T_CHAT_ERROR2_RATE', "");
     if (isset($_POST['rate']) && isset($_POST['rate2'])) {
         $ok = true;
         if ($_POST['rate'] < 1) {
             $smarty->assign('T_CHAT_ERROR_RATE', " New Rate must be greater or equal to 1.");
             $ok = false;
         }
         if ($_POST['rate2'] < 1) {
             $smarty->assign('T_CHAT_ERROR2_RATE', " New Rate must be greater or equal to 1.");
             $ok = false;
         }
         if ($ok) {
             $this->setChatHeartbeat($_POST['rate'] * 1000);
             $this->setRefresh_rate($_POST['rate2'] * 1000);
         }
     }
     $r = $this->getChatHeartbeat();
     $r2 = $this->getRefresh_rate();
     $smarty->assign('T_CHAT_CURRENT_RATE', $r / 1000);
     $form = new HTML_QuickForm("change_chatheartbeat_form", "post", $this->moduleBaseUrl . "&setChatHeartBeat=1", "", null, true);
     $form->addElement('text', 'rate', "rate", 'class="inputText" value="' . $r / 1000 . '" style="width:100px;"');
     $form->addRule('rate', _THEFIELD . ' "Rate" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('rate', "Non numeric Value", 'numeric', null, 'client');
     $form->addRule('rate', "Rate must be greater than 1", 'callback', create_function('$rate', 'return ($rate >= 1);'));
     $form->addElement('text', 'rate2', "rate2", 'class="inputText" value="' . $r2 / 1000 . '" style="width:100px;"');
     $form->addRule('rate2', _THEFIELD . ' "Rate" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('rate2', "Non numeric Value", 'numeric', null, 'client');
     $form->addElement('submit', 'submit1', _SUBMIT, 'class="flatButton"');
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     $form->setRequiredNote("mesh");
     $form->accept($renderer);
     $smarty->assign('T_CHAT_CHANGE_CHATHEARTBEAT_FORM', $renderer->toArray());
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     /*$smarty->assign('T_CHAT_ERROR2_RATE', "");
     			
     			if (isset($_POST['rate2'])){
     				if ($_POST['rate2'] >= 1)
     					$this -> setRefresh_rate($_POST['rate2']*1000);
     				else
     					$smarty->assign('T_CHAT_ERROR2_RATE', " New Rate must be greater or equal to 1.");
     			}
     
     			$r2 = $this->getRefresh_rate();
     
     			$smarty->assign('T_CHAT_CURRENT_REFRESH_RATE', $r2/1000);
     
     			$form = new HTML_QuickForm("change_refreshrate_form", "post", $this->moduleBaseUrl."&setRefresh_rate=1", "", null, true);
     			$form->addElement('text', 'rate2', "rate2", 'class="inputText" value="'.($r2/1000).'" style="width:100px;"');
     			$form->addRule('rate2', _THEFIELD.' "New Rate" '._ISMANDATORY, 'required', null, 'client');
     			$form->addRule('rate2', "Non numeric Value", 'numeric', null, 'client');
     			$form->addElement('submit', 'submit2', _SUBMIT, 'class="flatButton"');
     			$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     			$form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     			$form->setRequiredNote("mesh");
     			$form->accept($renderer);
     			$smarty->assign('T_CHAT_CHANGE_REFRESHRATE_FORM', $renderer->toArray());*/
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //$lessons = $this -> getLessonsCatalogue();
     //$smarty->assign('T_CHAT_LESSONS', $lessons);
     $textfieldcontent = "";
     if (isset($_POST['lessontitle'])) {
         $textfieldcontent = $_POST['lessontitle'];
         //$l = strip_tags($_POST['lessontitle']);
         //$l2 = substr($l, strpos($l, '→')+5);
         $log = $this->createLessonHistory($_POST['lessontitle'], $_POST['from']['Y'] . '-' . $_POST['from']['M'] . '-' . $_POST['from']['d'] . ' ' . "00:00:00", $_POST['until']['Y'] . '-' . $_POST['until']['M'] . '-' . $_POST['until']['d'] . ' ' . "23:59:59");
         $smarty->assign('T_LOG', $log);
         $smarty->assign('T_CHAT_LESSON_TITLE', $l2);
     }
     $form = new HTML_QuickForm("create_log_form", "post", $this->moduleBaseUrl . "&createLog=1", "", null, true);
     $date_from = $form->addElement('date', 'from', 'From Date:', array('format' => 'dMY', 'minYear' => 2010, 'maxYear' => date('Y')));
     $date_until = $form->addElement('date', 'until', 'Until Date:', array('format' => 'dMY', 'minYear' => 2010, 'maxYear' => date('Y')));
     $form->addElement('text', 'lessontitle', "lessontitle", 'maxlength="100" size="100" class="autoCompleteTextBox" id="autocomplete" value="' . $textfieldcontent . '"');
     $form->addRule('lessontitle', _THEFIELD . ' "Lesson Title" ' . _ISMANDATORY, 'required', null, 'client');
     $week_ago = $this->subtractDaysFromToday(7);
     $form->setDefaults(array('until' => array('d' => date('d'), 'M' => date('m'), 'Y' => date('Y')), 'from' => $week_ago));
     $form->addElement('submit', 'submit', "Create Log", 'class="flatButton"');
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     $form->setRequiredNote("mesh");
     $form->accept($renderer);
     $smarty->assign('T_CHAT_CREATE_LOG_FORM', $renderer->toArray());
     ////////
     return $this->moduleBaseDir . "control_panel.tpl";
 }
Example #21
0
 public function getSmartyTpl()
 {
     $currentUser = $this->getCurrentUser();
     $rules = $this->getRules();
     $smarty = $this->getSmartyVar();
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
         $currentLesson = $this->getCurrentLesson();
         $currentLessonID = $currentLesson->lesson['id'];
         if (!isset($_SESSION['module_journal_dimension']) || count($_GET) == 2 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' || count($_GET) == 3 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' && $_GET['new_lesson_id'] == $currentLessonID) {
             $_SESSION['module_journal_dimension'] = 'small';
         }
         if (!isset($_SESSION['module_journal_entries_from']) || count($_GET) == 2 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' || count($_GET) == 3 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' && $_GET['new_lesson_id'] == $currentLessonID) {
             $_SESSION['module_journal_entries_from'] = '-1';
         }
         if (isset($_SESSION['module_journal_scroll_position'])) {
             $smarty->assign("T_JOURNAL_SCROLL_POSITION", $_SESSION['module_journal_scroll_position']);
         }
         $smarty->assign("T_JOURNAL_DIMENSIONS", $_SESSION['module_journal_dimension']);
         $smarty->assign("T_JOURNAL_ENTRIES_FROM", $_SESSION['module_journal_entries_from']);
         $entries = $this->getEntries($currentUser->user['login'], $_SESSION['module_journal_entries_from']);
         global $popup;
         isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = '');
     }
     $smarty->assign("T_JOURNAL_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_JOURNAL_BASELINK", $this->moduleBaseLink);
     if (isset($_GET['edit_allow_export']) && $_GET['edit_allow_export'] == '1' && isset($_GET['allow'])) {
         try {
             $object = eF_getTableData("module_journal_settings", "id", "name='export'");
             eF_updateTableData("module_journal_settings", array("value" => $_GET['allow']), "id=" . $object[0]['id']);
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     }
     if (isset($_GET['edit_professor_preview']) && $_GET['edit_professor_preview'] == '1' && isset($_GET['preview'])) {
         try {
             $object = eF_getTableData("module_journal_settings", "id", "name='preview'");
             eF_updateTableData("module_journal_settings", array("value" => $_GET['preview']), "id=" . $object[0]['id']);
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     }
     if (isset($_GET['dimension']) && eF_checkParameter($_GET['dimension'], 'string')) {
         $smarty->assign("T_JOURNAL_DIMENSIONS", $_GET['dimension']);
         $_SESSION['module_journal_dimension'] = $_GET['dimension'];
     }
     if (isset($_GET['entries_from'])) {
         $smarty->assign("T_JOURNAL_ENTRIES_FROM", $_GET['entries_from']);
         $_SESSION['module_journal_entries_from'] = $_GET['entries_from'];
     }
     if (isset($_GET['delete_rule']) && eF_checkParameter($_GET['delete_rule'], 'id') && in_array($_GET['delete_rule'], array_keys($rules))) {
         try {
             eF_deleteTableData("module_journal_rules", "id=" . $_GET['delete_rule']);
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     }
     if (isset($_GET['deactivate_rule']) && eF_checkParameter($_GET['deactivate_rule'], 'id') && in_array($_GET['deactivate_rule'], array_keys($rules))) {
         eF_updateTableData("module_journal_rules", array('active' => 0), "id=" . $_GET['deactivate_rule']);
     }
     if (isset($_GET['activate_rule']) && eF_checkParameter($_GET['activate_rule'], 'id') && in_array($_GET['activate_rule'], array_keys($rules))) {
         eF_updateTableData("module_journal_rules", array('active' => 1), "id=" . $_GET['activate_rule']);
     }
     if (isset($_GET['delete_entry']) && eF_checkParameter($_GET['delete_entry'], 'id') && in_array($_GET['delete_entry'], array_keys($entries))) {
         $object = eF_getTableData("module_journal_entries", "users_LOGIN", "id=" . $_GET['delete_entry']);
         if ($object[0]['users_LOGIN'] != $_SESSION['s_login']) {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS) . $popup_);
             exit;
         }
         eF_deleteTableData("module_journal_entries", "id=" . $_GET['delete_entry']);
     }
     if (isset($_GET['saveas']) && $_GET['saveas'] == 'pdf') {
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor(PDF_AUTHOR);
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->setFontSubsetting(false);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->setHeaderFont(array('Freeserif', 'I', 11));
         $pdf->setFooterFont(array('Freeserif', '', 8));
         $pdf->setHeaderData('', '', '', _JOURNAL_NAME);
         $pdf->AliasNbPages();
         $pdf->AddPage();
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         foreach ($entries as $entry) {
             $pdf->Cell(0, 0, $entry['entry_date_formatted'], 0, 1, L, 0);
             $pdf->writeHTML('<br/>', true, false, true, false, '');
             $pdf->writeHTML($entry['entry_body'], true, false, true, false, '');
             $pdf->writeHTML('<div style="height: 5px;"></div>', true, false, true, false, '');
             $pdf->writeHTML('<hr>', true, false, true, false, '');
         }
         $fileNamePdf = "journal.pdf";
         header("Content-type: application/pdf");
         header("Content-disposition: attachment; filename=" . $fileNamePdf);
         echo $pdf->Output('', 'S');
         exit(0);
     }
     if (isset($_GET['saveas']) && $_GET['saveas'] == 'doc') {
         include dirname(__FILE__) . "/classes/html_to_doc.inc.php";
         $entriesHTML = '';
         foreach ($entries as $entry) {
             $entriesHTML .= $entry['entry_date_formatted'];
             $entriesHTML .= $entry['entry_body'];
             $entriesHTML .= '<hr><br/>';
         }
         $htmltodoc = new HTML_TO_DOC();
         $htmltodoc->createDoc($entriesHTML, "journal", true);
         exit(0);
     }
     if (isset($_GET['saveas']) && $_GET['saveas'] == 'txt') {
         include dirname(__FILE__) . "/classes/html2text.inc";
         header('Content-Type: text/plain');
         header('Content-Disposition: attachment; filename="journal.txt"');
         $entriesHTML = '';
         foreach ($entries as $entry) {
             $entriesHTML .= $entry['entry_date_formatted'];
             $entriesHTML .= $entry['entry_body'];
             $entriesHTML .= '<p></p>';
             $entriesHTML .= '_______________________________________________________';
             $entriesHTML .= '<p></p>';
         }
         $htmlToText = new Html2Text($entriesHTML, 100);
         $entriesHTMLtext = $htmlToText->convert();
         echo $entriesHTMLtext;
         exit(0);
     }
     if (isset($_GET['check_students_journals']) && $_GET['check_students_journals'] == '1') {
         $professorJournalLessons = $this->getProfessorJournalLessons($currentUser);
         $journalLessonsStudents = $this->getJournalLessonsStudents($professorJournalLessons);
         $smarty->assign("T_JOURNAL_STUDENTS", $journalLessonsStudents);
     }
     if (isset($_GET['preview_journal']) && $_GET['preview_journal'] == '1' && isset($_GET['student']) && eF_checkParameter($_GET['student'], 'login')) {
         $userLogin = $_GET['student'];
         $professorJournalLessons = $this->getProfessorJournalLessons($currentUser);
         $studentEntries = $this->getStudentEntries($userLogin, $professorJournalLessons);
         $smarty->assign("T_JOURNAL_STUDENT_ENTRIES", $studentEntries);
     }
     if (isset($_REQUEST['autosave']) && $_REQUEST['autosave'] == "1" && isset($_REQUEST['entry_body']) && isset($_REQUEST['edit_entry'])) {
         if ($_REQUEST['edit_entry'] != "-1") {
             if (eF_checkParameter($_GET['edit_entry'], 'id')) {
                 $object = eF_getTableData("module_journal_entries", "lessons_ID", "id=" . $_GET['edit_entry']);
                 $fields = array("entry_body" => $_REQUEST['entry_body'], "entry_date" => date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i') . ':' . date('s'), "lessons_ID" => $object[0]['lessons_ID'], "users_LOGIN" => $currentUser->user['login']);
                 eF_updateTableData("module_journal_entries", $fields, "id=" . $_REQUEST['edit_entry']);
             }
         } else {
             $fields = array("entry_body" => $_REQUEST['entry_body'], "entry_date" => date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i') . ':' . date('s'), "lessons_ID" => $currentLessonID, "users_LOGIN" => $currentUser->user['login']);
             $id = eF_insertTableData("module_journal_entries", $fields);
             if ($id) {
                 if (isset($_SESSION['module_journal_autosave_entry'])) {
                     $this->deleteAutoSaveEntry();
                     $_SESSION['module_journal_autosave_entry'] = $id;
                 } else {
                     $_SESSION['module_journal_autosave_entry'] = $id;
                 }
             }
         }
         exit(0);
     }
     if (isset($_REQUEST['show_right']) && $_REQUEST['show_right'] == "1" && isset($_REQUEST['entry_body']) && $_REQUEST['entry_body'] != "" && isset($_REQUEST['edit']) && isset($_REQUEST['edit_entry'])) {
         if (isset($_SESSION['module_journal_show_right_entry'])) {
             unset($_SESSION['module_journal_show_right_entry']);
         }
         $_SESSION['module_journal_show_right_entry'] = $_REQUEST['entry_body'];
     }
     if (isset($_REQUEST['hide_right']) && $_REQUEST['hide_right'] == "1" && isset($_REQUEST['entry_body']) && $_REQUEST['entry_body'] != "" && isset($_REQUEST['edit']) && isset($_REQUEST['edit_entry'])) {
         if (isset($_SESSION['module_journal_hide_right_entry'])) {
             unset($_SESSION['module_journal_hide_right_entry']);
         }
         $_SESSION['module_journal_hide_right_entry'] = $_REQUEST['entry_body'];
     }
     if (isset($_REQUEST['hide_left']) && $_REQUEST['hide_left'] == "1" && isset($_REQUEST['entry_body']) && $_REQUEST['entry_body'] != "" && isset($_REQUEST['edit']) && isset($_REQUEST['edit_entry'])) {
         if (isset($_SESSION['module_journal_hide_left_entry'])) {
             unset($_SESSION['module_journal_hide_left_entry']);
         }
         $_SESSION['module_journal_hide_left_entry'] = $_REQUEST['entry_body'];
     }
     if (isset($_REQUEST['scroll_position']) && eF_checkParameter($_REQUEST['scroll_position'], 'id')) {
         $_SESSION['module_journal_scroll_position'] = $_REQUEST['scroll_position'];
     }
     if (isset($_GET['add_rule']) || isset($_GET['edit_rule']) && eF_checkParameter($_GET['edit_rule'], 'id') && in_array($_GET['edit_rule'], array_keys($rules))) {
         if ($_SESSION['s_type'] != "administrator") {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS));
         }
         isset($_GET['add_rule']) ? $postTarget = "&add_rule=1" : ($postTarget = "&edit_rule=" . $_GET['edit_rule']);
         global $load_editor;
         $load_editor = true;
         $form = new HTML_QuickForm("add_edit_rule_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
         $form->addElement('text', 'title', _TITLE, 'class="inputText" style="width:498px;"');
         $form->addRule('title', _THEFIELD . ' "' . _TITLE . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('textarea', 'description', _DESCRIPTION, 'class="inputContentTextarea simpleEditor" style="width:500px;height:20em;"');
         $form->addElement('submit', 'submit', _SUBMIT, 'class="flatButton"');
         if (isset($_GET['edit_rule'])) {
             $editRule = $rules[$_GET['edit_rule']];
             $form->setDefaults($editRule);
         }
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $fields = array("title" => $values['title'], "description" => $values['description']);
             if ($values['description'] == '') {
                 $message = _JOURNAL_EMPTY_RULE_DESCRIPTION;
                 if (isset($_GET['add_rule'])) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure&add_rule=1");
                 } else {
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure&edit_rule=" . $_GET['edit_rule']);
                 }
             }
             if (isset($_GET['add_rule'])) {
                 if (eF_insertTableData("module_journal_rules", $fields)) {
                     $message = _JOURNAL_RULE_SUCCESSFULLY_ADDED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success");
                 } else {
                     $message = _JOURNAL_RULE_ADD_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure");
                 }
             } else {
                 if (eF_updateTableData("module_journal_rules", $fields, "id=" . $_GET['edit_rule'])) {
                     $message = _JOURNAL_RULE_SUCCESSFULLY_EDITED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success");
                 } else {
                     $message = _JOURNAL_RULE_EDIT_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure");
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_JOURNAL_ADD_EDIT_RULE_FORM', $renderer->toArray());
     } else {
         $rules = $this->getRules();
         $smarty->assign("T_JOURNAL_RULES", $rules);
         $object = eF_getTableData("module_journal_settings", "value", "name='export'");
         $smarty->assign("T_JOURNAL_ALLOW_EXPORT", $object[0]['value']);
         $object = eF_getTableData("module_journal_settings", "value", "name='preview'");
         $smarty->assign("T_JOURNAL_ALLOW_PROFESSOR_PREVIEW", $object[0]['value']);
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
             $activeRules = $this->getRules(true);
             $smarty->assign("T_JOURNAL_ACTIVE_RULES", $activeRules);
             $entries = $this->getEntries($currentUser->user['login'], $_SESSION['module_journal_entries_from']);
             $smarty->assign("T_JOURNAL_ENTRIES", $entries);
             $journalLessons = $this->getJournalLessons($currentUser->user['login']);
             $smarty->assign("T_JOURNAL_LESSONS", $journalLessons);
             /*					*/
             global $load_editor;
             $load_editor = true;
             if (isset($_GET['edit_entry']) && $_GET['edit_entry'] != '-1') {
                 $postTarget = "&edit_entry=" . $_GET['edit_entry'];
             } else {
                 $postTarget = "&add_entry=1";
             }
             if (isset($_GET['hide_right']) && $_GET['hide_right'] == '1') {
                 $editorStyle = array('small' => 'width:588px; height:320px;', 'medium' => 'width:673px; height:375px;', 'large' => 'width:759px; height:430px;');
             } else {
                 $editorStyle = array('small' => 'width:300px; height:320px;', 'medium' => 'width:344px; height:375px;', 'large' => 'width:388px; height:430px;');
             }
             $form = new HTML_QuickForm("add_edit_entry_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
             $form->addElement('textarea', 'entry_body', _DESCRIPTION, 'class="inputContentTextarea simpleEditor" style="' . $editorStyle[$_SESSION['module_journal_dimension']] . '"');
             if (isset($_GET['edit_entry']) && $_GET['edit_entry'] != '-1') {
                 $form->addElement('submit', 'submit', _UPDATE . ' ' . _JOURNAL_ENTRY, 'class="flatButton"');
             } else {
                 $form->addElement('submit', 'submit', _SAVE . ' ' . _JOURNAL_ENTRY, 'class="flatButton"');
             }
             if (isset($_GET['edit_entry']) && $_GET['edit_entry'] != '-1') {
                 $editEntry = $entries[$_GET['edit_entry']];
                 $form->setDefaults($editEntry);
                 if (!in_array($_GET['edit_entry'], array_keys($entries))) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS) . $popup_);
                 }
                 $object = eF_getTableData("module_journal_entries", "lessons_ID, users_LOGIN, entry_date", "id=" . $_GET['edit_entry']);
                 if ($object[0]['users_LOGIN'] != $_SESSION['s_login']) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS) . $popup_);
                 }
             }
             if (isset($_GET['show_left']) && $_GET['show_left'] == '1' && isset($_GET['edit']) && isset($_GET['edit_entry'])) {
                 if (isset($_SESSION['module_journal_hide_left_entry'])) {
                     $form->setDefaults(array("entry_body" => $_SESSION['module_journal_hide_left_entry']));
                     unset($_SESSION['module_journal_hide_left_entry']);
                 }
             }
             if (isset($_GET['show_right']) && $_GET['show_right'] == '1' && isset($_GET['edit']) && isset($_GET['edit_entry'])) {
                 if (isset($_SESSION['module_journal_show_right_entry'])) {
                     $form->setDefaults(array("entry_body" => $_SESSION['module_journal_show_right_entry']));
                     unset($_SESSION['module_journal_show_right_entry']);
                 }
             }
             if (isset($_GET['hide_right']) && $_GET['hide_right'] == '1' && isset($_GET['edit']) && isset($_GET['edit_entry'])) {
                 if (isset($_SESSION['module_journal_hide_right_entry'])) {
                     $form->setDefaults(array("entry_body" => $_SESSION['module_journal_hide_right_entry']));
                     unset($_SESSION['module_journal_hide_right_entry']);
                 }
             }
             if ($form->isSubmitted() && $form->validate()) {
                 $values = $form->exportValues();
                 isset($_GET['add_entry']) ? $lessonID = $currentLessonID : ($lessonID = $object[0]['lessons_ID']);
                 if (isset($_GET['add_entry'])) {
                     $date = date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i') . ':' . date('s');
                 } else {
                     $date = $object[0]['entry_date'];
                 }
                 $fields = array("entry_body" => $values['entry_body'], "entry_date" => $date, "lessons_ID" => $lessonID, "users_LOGIN" => $currentUser->user['login']);
                 if ($values['entry_body'] == '') {
                     $message = _JOURNAL_EMPTY_ENTRY_BODY;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure" . $popup_);
                 }
                 if (isset($_GET['add_entry'])) {
                     if (eF_insertTableData("module_journal_entries", $fields)) {
                         if (isset($_SESSION['module_journal_autosave_entry'])) {
                             $this->deleteAutoSaveEntry();
                         }
                         $message = _JOURNAL_ENTRY_SUCCESSFULLY_ADDED;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success" . $popup_);
                     } else {
                         $message = _JOURNAL_ENTRY_ADD_PROBLEM;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure" . $popup_);
                     }
                 } else {
                     if (eF_updateTableData("module_journal_entries", $fields, "id=" . $_GET['edit_entry'])) {
                         $message = _JOURNAL_ENTRY_SUCCESSFULLY_EDITED;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success" . $popup_);
                     } else {
                         $message = _JOURNAL_ENTRY_EDIT_PROBLEM;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure" . $popup_);
                     }
                 }
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
             $form->setRequiredNote(_REQUIREDNOTE);
             $form->accept($renderer);
             $smarty->assign('T_JOURNAL_ADD_ENTRY_FORM', $renderer->toArray());
             if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
                 $popupInfo[] = array('text' => _JOURNAL_POPUP_INFO, 'image' => $this->moduleBaseLink . 'images/info.png', 'href' => $this->moduleBaseUrl . '&popup_info=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _JOURNAL_POPUP_INFO . "', 2)", 'target' => 'POPUP_FRAME', 'id' => 'popup_info');
                 $smarty->assign("T_JOURNAL_POPUP_INFO", $popupInfo);
             }
         }
     }
     if ($currentUser->getType() == 'administrator') {
         return $this->moduleBaseDir . "module_journal_admin.tpl";
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
             if (isset($_GET['hide_left']) && $_GET['hide_left'] == '1') {
                 return $this->moduleBaseDir . "module_journal_user_right.tpl";
             }
             if (isset($_GET['hide_right']) && $_GET['hide_right'] == '1') {
                 return $this->moduleBaseDir . "module_journal_user_left.tpl";
             }
             return $this->moduleBaseDir . "module_journal_user.tpl";
         }
     }
 }
                    $message .= "<BR><hr><BR>";
                }
                $message .= $failures . " " . _FAILEDIMPORTS;
                $message .= ": <BR>";
            }
            $message .= "&nbsp;&nbsp;&nbsp;" . implode("<BR>&nbsp;&nbsp;&nbsp;", $log['failure']);
        }
    } catch (Exception $e) {
        $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
        $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
        $message_type = 'failure';
    }
}
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$importForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
$importForm->setRequiredNote(_REQUIREDNOTE);
$importForm->accept($renderer);
$smarty->assign('T_IMPORT_FORM', $renderer->toArray());
// ******************************************* Export form *******************************************
$exportForm = new HTML_QuickForm("export_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=import_export&op=export&tab=export", "", null, true);
unset($import_export_types['anything']);
$exportForm->addElement('select', 'export_type', _DATATYPE, $import_export_types, 'class = "inputCheckbox"', array(0, 1));
$exportForm->addElement("select", "date_format", _DATEFORMAT, array("DD/MM/YYYY" => "DD/MM/YYYY", "MM/DD/YYYY" => "MM/DD/YYYY", "YYYY/MM/DD" => "YYYY/MM/DD"));
$exportForm->addElement('radio', 'export_separator', _KEEPEXISTINGUSERS, null, 'csvA');
$exportForm->addElement('radio', 'export_separator', _KEEPEXISTINGUSERS, null, 'csvB');
$exportForm->setDefaults(array('export_separator' => "csvA"));
$exportForm->addElement('submit', 'submit_export', _EXPORTDATA, 'class = "flatButton"');
if ($exportForm->isSubmitted() && $exportForm->validate()) {
    $exportForm->exportValue('export_separator') == 'csvA' ? $separator = ',' : ($separator = ';');
    try {
        $options = array("separator" => $separator, "date_format" => $exportForm->exportValue('date_format'));
Example #23
0
                        $user->user['password'] = $newPassword;
                        $user->user['need_pwd_change'] = 0;
                        $user->persist();
                        unset($_SESSION['s_index_comply']);
                        if ($GLOBALS['configuration']['show_license_note'] && $user->user['viewed_license'] == 0) {
                            eF_redirect("index.php?ctg=agreement");
                        } else {
                            EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_VISITED, "users_LOGIN" => $user->user['login'], "users_name" => $user->user['name'], "users_surname" => $user->user['surname']));
                            loginRedirect($user->user['user_type']);
                        }
                    }
                }
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            $changePasswordForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
            $changePasswordForm->setRequiredNote(_REQUIREDNOTE);
            $changePasswordForm->accept($renderer);
            $smarty->assign('T_CHANGE_PASSWORD_FORM', $changePasswordForm->toArray());
        } catch (Exception $e) {
            eF_redirect("index.php?message=" . urlencode($e->getMessage() . " (" . $e->getCode() . ")") . "&message_type=failure");
        }
    }
}
/* ---------------------------------------------------------Activation by email part--------------------------------------------------------- */
if (isset($_GET['account']) && isset($_GET['key']) && eF_checkParameter($_GET['account'], 'login') && eF_checkParameter($_GET['key'], 'timestamp')) {
    if ($configuration['activation'] == 0 && $configuration['mail_activation'] == 1 || $configuration['supervisor_mail_activation'] == 1) {
        $result = eF_getTableData("users", "timestamp, active", "login='******'account'] . "'");
        if ($result[0]['active'] == 0 && $result[0]['timestamp'] == $_GET['key']) {
            try {
                $user = EfrontUserFactory::factory($_GET['account']);
                //new EfrontUser($_GET['login']);
Example #24
0
      div.element label { display: inline; float: none; }
      select { margin-right: 0.5em; }
      span.required { display: none; }
    </style>
  </head>
  <body>
    <h1>Contact Us</h1>
<?php 
require_once "HTML/QuickForm.php";
require_once "HTML/QuickForm/Renderer/Tableless.php";
define("OWNER_FIRST_NAME", "Michael");
define("OWNER_LAST_NAME", "Brown");
define("OWNER_EMAIL_ADDRESS", "*****@*****.**");
$form = new HTML_QuickForm("form", "post", "contact.php", "", array("style" => "width: 30em;"), true);
$form->removeAttribute("name");
$form->setRequiredNote("");
$form->addElement("text", "firstName", "First name");
$form->addElement("text", "lastName", "Last name");
$form->addElement("text", "emailAddress", "Email address");
$form->addElement("text", "subject", "Message subject");
$form->addElement("textarea", "message", "Message", array("rows" => 10, "cols" => 50));
$form->addElement("submit", "sendButton", "Send Message");
$form->addRule("firstName", "Please enter your first name", "required");
$form->addRule("firstName", "The First Name field can contain only letters, digits, spaces, apostrophes, and hyphens", "regex", "/^[ \\'\\-a-zA-Z0-9]+\$/");
$form->addRule("lastName", "Please enter your last name", "required");
$form->addRule("lastName", "The Last Name field can contain only letters, digits, spaces, apostrophes, and hyphens", "regex", "/^[ \\'\\-a-zA-Z0-9]+\$/");
$form->addRule("emailAddress", "Please enter an email address", "required");
$form->addRule("emailAddress", "Please enter a valid email address", "email");
$form->addRule("subject", "Please enter a message subject", "required");
$form->addRule("subject", "Your subject can contain only letters, digits, spaces, apostrophes, commas, periods, and hyphens", "regex", "/^[ \\'\\,\\.\\-a-zA-Z0-9]+\$/");
$form->addRule("message", "Please enter your message", "required");
Example #25
0
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $currentLesson = $this->getCurrentLesson();
     $currentUser = $this->getCurrentUser();
     try {
         $currentContent = new EfrontContentTree($_SESSION['s_lessons_ID']);
         //Initialize content
     } catch (Exception $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _ERRORLOADINGCONTENT . ": " . $_SESSION['s_lessons_ID'] . ": " . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
     }
     //pr($currentUser);exit;
     $roles = EfrontUser::getRoles();
     //pr($roles);
     if ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "professor") {
         if (isset($_GET['view_list']) && eF_checkParameter($_GET['view_list'], 'id')) {
             $list = $currentContent->seekNode($_GET['view_list']);
             $questions = $list->getQuestions(true);
             $crosslists = array();
             $possibleCrosslistsIds = array();
             foreach ($questions as $key => $value) {
                 if ($value->question['type'] == 'empty_spaces') {
                     $crosslists[] = $value;
                     $possibleCrosslistsIds[] = $value->question['id'];
                 }
             }
             $questions = $crosslists;
             //pr($questions);
             foreach ($questions as $qid => $question) {
                 $questions[$qid]->question['text'] = str_replace('#', '_', strip_tags($question->question['text']));
                 //If we ommit this line, then the questions list is html formatted, images are displayed etc, which is *not* the intended behaviour
                 //$questions[$qid]->question['answer']           = unserialize($question->question['answer']);
             }
             $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']);
             $resCrosslists = unserialize($res[0]['crosslists']);
             $smarty->assign("T_CROSSWORD_LIST_WORDS", $resCrosslists);
             $post_target = $this->moduleBaseUrl . '&view_list=' . $_GET['view_list'] . "&tab=options";
             //Create form elements
             $form = new HTML_QuickForm("list_options", "post", $post_target, "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             $form->addElement('advcheckbox', 'active', _CROSSWORD_ACTIVE, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement("text", "max_word", _LOW, 'size = "5"');
             $form->addRule('max_word', _INVALIDFIELDDATA . ":" . _LOW, 'checkParameter', 'id');
             $form->addElement('advcheckbox', 'reveal_answer', _CROSSWORD_SHOWANSWERFIRST, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'save_pdf', _CROSSWORD_SAVEPDF, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('submit', 'submit_options', _SAVECHANGES, 'onclick ="return optionSubmit();" class = "flatButton"');
             //The submit content button
             $options = unserialize($res[0]['options']);
             $form->setDefaults(array('active' => $options['active'], 'reveal_answer' => $options['reveal_answer'], 'save_pdf' => $options['save_pdf'], 'max_word' => $options['max_word']));
             if ($form->isSubmitted() && $form->validate()) {
                 //If the form is submitted and validated
                 $values = $form->exportValues();
                 unset($values['submit_options']);
                 $options = serialize($values);
                 if (sizeof($res) != 0) {
                     $ok = eF_updateTableData("module_crossword_words", array('options' => $options), "content_ID=" . $_GET['view_list']);
                 } else {
                     $fields = array('content_ID' => $_GET['view_list'], 'options' => $options);
                     $ok = eF_insertTableData("module_crossword_words", $fields);
                 }
                 if ($ok !== false) {
                     $message = _CROSSWORD_SUCCESSFULLY;
                     $message_type = 'success';
                 } else {
                     $message = _CROSSWORD_PROBLEMOCCURED;
                     $message_type = 'failure';
                 }
                 eF_redirect("" . $this->moduleBaseUrl . "&view_list=" . $_GET['view_list'] . "&tab=options&message=" . urlencode($message) . "&message_type=" . $message_type);
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             //Create a smarty renderer
             $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
             //Set javascript error messages
             $form->setRequiredNote(_REQUIREDNOTE);
             $form->accept($renderer);
             //Assign this form to the renderer, so that corresponding template code is created
             $smarty->assign('T_CROSSWORD_OPTIONS', $renderer->toArray());
             //Assign the form to the template
             if (isset($_GET['postAjaxRequest'])) {
                 try {
                     $result = eF_getTableData("module_crossword_words", "crosslists", "content_ID=" . $_GET['view_list']);
                     //pr($result);exit;
                     $crosslistsArray = unserialize($result[0]['crosslists']);
                     if (isset($_GET['id']) && eF_checkParameter($_GET['id'], 'id')) {
                         if (!in_array($_GET['id'], array_values($crosslistsArray))) {
                             $crosslistsArray[] = $_GET['id'];
                             $crosslists = serialize($crosslistsArray);
                             if (sizeof($result) != 0) {
                                 $fields = array('crosslists' => $crosslists);
                                 eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']);
                             } else {
                                 $fields = array('content_ID' => $_GET['view_list'], 'crosslists' => $crosslists);
                                 eF_insertTableData("module_crossword_words", $fields);
                             }
                         } elseif (in_array($_GET['id'], array_values($crosslistsArray))) {
                             unset($crosslistsArray[array_search($_GET['id'], $crosslistsArray)]);
                             if (!empty($crosslistsArray)) {
                                 $crosslists = serialize($crosslistsArray);
                                 $fields = array('crosslists' => $crosslists);
                                 eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']);
                             } else {
                                 eF_deleteTableData("module_crossword_words", "content_ID=" . $_GET['view_list']);
                             }
                         }
                     } else {
                         if (isset($_GET['addAll'])) {
                             $crosslists = serialize($possibleCrosslistsIds);
                             if (sizeof($result) != 0) {
                                 $fields = array('crosslists' => $crosslists);
                                 eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']);
                             } else {
                                 $fields = array('content_ID' => $_GET['view_list'], 'crosslists' => $crosslists);
                                 eF_insertTableData("module_crossword_words", $fields);
                             }
                         } else {
                             if (isset($_GET['removeAll'])) {
                                 $fields = array('crosslists' => "");
                                 eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']);
                             }
                         }
                     }
                 } catch (Exception $e) {
                     header("HTTP/1.0 500 ");
                     echo $e->getMessage() . ' (' . $e->getCode() . ')';
                 }
                 exit;
             }
             $smarty->assign("T_CROSSWORD_CROSSLISTS", $crosslists);
             $smarty->assign("T_CROSSWORD_CROSSLISTS_SIZE", sizeof($crosslists));
         } else {
             $listsArray = array();
             $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST)));
             foreach ($iterator as $key => $value) {
                 $questions = $value->getQuestions(true);
                 $crosslists = array();
                 foreach ($questions as $key2 => $value2) {
                     if ($value2->question['type'] == 'empty_spaces') {
                         $crosslists[] = $value2;
                     }
                 }
                 if (sizeof($crosslists) > 0) {
                     $listsArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name'], 'questions' => sizeof($crosslists));
                 }
             }
             if (!empty($listsArray)) {
                 $str = implode(",", array_keys($listsArray));
                 $lists = eF_getTableDataFlat("module_crossword_words", "*", "content_ID IN (" . $str . ")");
                 $listsTemp = array_combine(array_values($lists['content_ID']), array_values($lists['options']));
                 $listsTemp2 = array_combine(array_values($lists['content_ID']), array_values($lists['crosslists']));
                 foreach ($listsArray as $key => $value) {
                     $listsArray[$value['id']]['options'] = unserialize($listsTemp[$key]);
                     $crosslistsTemp = unserialize($listsTemp2[$key]);
                     $listsArray[$value['id']]['num_crosslists'] = empty($crosslistsTemp) ? 0 : sizeof($crosslistsTemp);
                 }
             }
             $smarty->assign("T_CROSSWORD_WORDS", $listsArray);
         }
     } elseif ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "student") {
         if (isset($_GET['restart_list']) && eF_checkParameter($_GET['restart_list'], 'id')) {
             eF_deleteTableData("module_crossword_users", "users_LOGIN='******'s_login'] . "' AND content_ID=" . $_GET['restart_list']);
         }
         if (isset($_GET['restart_lists'])) {
             eF_deleteTableData("module_crossword_users", "users_LOGIN='******'s_login'] . "'");
         }
         if ($_GET['answer'] == "true") {
             $resUserCard = eF_getTableData("module_crossword_users", "*", "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             if (sizeof($resUserCard) == 0) {
                 $fields = array('users_LOGIN' => $_SESSION['s_login'], 'content_ID' => $_GET['view_list'], 'crosslists_ID' => $_GET['view_card'], 'success' => '1');
                 eF_insertTableData("module_crossword_users", $fields);
             } else {
                 $success = $resUserCard[0]['success'] + 1;
                 eF_updateTableData("module_crossword_users", array('success' => $success), "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             }
         } elseif ($_GET['answer'] == "false") {
             $resUserCard = eF_getTableData("module_crossword_users", "*", "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             $currentListTemp = eF_getTableData("module_crossword_words", "options", "content_ID=" . $_GET['view_list']);
             $listTemp = unserialize($currentListTemp[0]['options']);
             if ($listTemp['wrong'] == 1 && sizeof($resUserCard) != 0 && $resUserCard[0]['success'] != 0) {
                 $success = $resUserCard[0]['success'] - 1;
                 eF_updateTableData("module_crossword_users", array('success' => $success), "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'");
             }
         }
         $listsArray = array();
         $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST)));
         foreach ($iterator as $key => $value) {
             $listsArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name']);
         }
         if (empty($listsArray)) {
             $smarty->assign("T_CROSSWORD_WORDSNAMES", $listsArray);
             return true;
         }
         $str = implode(",", array_keys($listsArray));
         $lists = eF_getTableData("module_crossword_words", "*", "content_ID IN (" . $str . ")");
         $mastery = eF_getTableDataFlat("module_crossword_users", "*", "content_ID IN (" . $str . ")");
         $masteryArray = array_combine(array_values($mastery['crosslists_ID']), array_values($mastery['success']));
         $questionsDiff = eF_getTableDataFlat("questions", "*", "content_ID IN (" . $str . ")");
         $questionsDiffArray = array_combine(array_values($questionsDiff['id']), array_values($questionsDiff['difficulty']));
         $validLists = array();
         foreach ($lists as $key => $value) {
             $opt = unserialize($value['options']);
             $crosslists = unserialize($value['crosslists']);
             if ($opt['active'] == 1 && !empty($crosslists)) {
                 $value['number_crosslists'] = empty($crosslists) ? 0 : sizeof($crosslists);
                 $validLists[$value['content_ID']] = $value;
                 $validLists[$value['content_ID']]['options'] = $opt;
                 $finishedCrosslists = 0;
                 foreach ($crosslists as $index => $item) {
                     if ($masteryArray[$item] == $opt[$questionsDiffArray[$item]]) {
                         $finishedCrosslists++;
                     }
                 }
                 $conid = $validLists[$value['content_ID']]['content_ID'];
                 $validLists[$value['content_ID']]['non_finished'] = $value['number_crosslists'] - $finishedCrosslists;
                 $validLists[$value['content_ID']]['mastery'] = (double) $finishedCrosslists / sizeof($crosslists) * 100;
                 $respoints = eF_getTableDataFlat("module_crossword_users", "*", "content_ID = '{$conid}' and users_LOGIN='******'s_login'] . "'");
                 $validLists[$value['content_ID']]['points'] = round($respoints['points'][0] / $respoints['totallength'][0] * 100);
                 $validLists[$value['content_ID']]['crosstime'] = $respoints['wordtime'][0];
             }
         }
         //print_r($validLists);
         $smarty->assign("T_CROSSWORD_WORDS", $validLists);
         $smarty->assign("T_CROSSWORD_WORDSNAMES", $listsArray);
         if (isset($_GET['view_list']) && !isset($_GET['pdf'])) {
             $resunit = eF_getTableData("content", "name", "id=" . $_GET['view_list']);
             $smarty->assign("T_CROSSWORD_UNITNAME", $resunit[0]['name']);
             $_SESSION['contentid'] = $_GET['view_list'];
             if (isset($_POST) && !empty($_POST['crosstime'])) {
                 $userlist = eF_getTableData("module_crossword_users", "*", "users_LOGIN='******'s_login'] . "' and content_ID=" . $_GET['view_list'] . "");
                 if (count($userlist) == 0) {
                     $fields = array('users_LOGIN' => $_SESSION['s_login'], 'content_ID' => $_GET['view_list'], 'points' => $_POST['points'], 'totallength' => $_SESSION['WORDLEN'], 'wordtime' => $_POST['crosstime']);
                     eF_insertTableData("module_crossword_users", $fields);
                 } else {
                     $fields = array('points' => $_POST['points'], 'totallength' => $_SESSION['WORDLEN'], 'wordtime' => $_POST['crosstime']);
                     eF_updateTableData("module_crossword_users", $fields, "content_ID=" . $_GET['view_list'] . " and users_LOGIN='******'s_login'] . "'");
                 }
                 $message_type = 'success';
                 $message = _CROSSWORD_GAME_SUCCESSFULLY;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type);
             }
             $contentid = $_GET['view_list'];
             $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']);
             $reswords = unserialize($res[0]['crosslists']);
             $maxwords = unserialize($res[0]['options']);
             $maxwords1 = $maxwords['max_word'];
             $smarty->assign("T_CROSSWORD_REVEALANSWER", $maxwords['reveal_answer']);
             $smarty->assign("T_CROSSWORD_MAXWORD", $maxwords1 + 1);
             $_SESSION['CROSSWORD_MAXWORD'] = $maxwords1;
             require_once 'init.php';
             $rowquesans = "";
             foreach ($reswords as $rowques) {
                 $rowquesans .= $rowques . ",";
             }
             $quesids = mb_substr($rowquesans, 0, -1);
             $quesans = eF_getTableData("questions", "text,answer", "id IN({$quesids}) order by rand() limit {$maxwords1}");
             $value = array();
             foreach ($quesans as $row) {
                 $answer = unserialize($row['answer']);
                 $answer1 = explode("|", $answer['0']);
                 $value[] = array('ANSWER' => $answer1['0'], 'QUESTION' => $row['text']);
             }
             if (!empty($value)) {
                 //pr($value);exit;
                 $success = $pc->generateFromWords($value);
                 if (!$success) {
                     $message_type = 'failure';
                     $message = _CROSSWORD_UNABLEGENERATECROSSWORD;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                 } else {
                     $words = $pc->getWords();
                     $wordlen = "";
                     foreach ($words as $rowwords) {
                         $wordlen = $wordlen + $rowwords['wordlength'];
                     }
                     $_SESSION['WORDLEN'] = $wordlen;
                     $smarty->assign("T_CROSSWORD_LENGTH", $_SESSION['WORDLEN']);
                     //vd($words);
                     //because of #1599
                     foreach ($words as $key => $word) {
                         $words[$key]['question'] = str_replace(array("\r\n", "\n"), '<br/>', $word['question']);
                     }
                     //vd($words);
                     $smarty->assign("T_CROSSWORD_ANSWERS", $words);
                 }
             }
             $post_target = $this->moduleBaseUrl . "&view_list=" . $_GET['view_list'] . "";
             $form = new HTML_QuickForm("crossword_game", "post", $post_target, "", null, true);
             $form->addElement('submit', 'submit_crossword', 'SUBMIT', 'class = "flatButton"');
             //The submit content button
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             //Create a smarty renderer
             $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
             //Set javascript error messages
             $form->setRequiredNote(_REQUIREDNOTE);
             $form->accept($renderer);
             //Assign this form to the renderer, so that corresponding template code is created
             $smarty->assign('T_CROSSWORD_SUBMIT', $renderer->toArray());
             //Assign the form to the template
             $message = "";
             //$message_type = 'success';
             // eF_redirect("".$this -> moduleBaseUrl."&popup=1&finish=1&message=".$message."&message_type=".$message_type);
         } else {
             if (isset($_GET['view_list']) && isset($_GET['pdf']) && $_GET['pdf'] == 'cross') {
                 $resunit = eF_getTableData("content", "name,lessons_ID", "id=" . $_GET['view_list']);
                 $reslesson = eF_getTableData("lessons", "name", "id=" . $resunit[0]['lessons_ID']);
                 $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']);
                 $reswords = unserialize($res[0]['crosslists']);
                 $maxwords = unserialize($res[0]['options']);
                 $maxwords1 = $maxwords['max_word'];
                 $_SESSION['CROSSWORD_MAXWORD'] = $maxwords1;
                 require_once 'init.php';
                 $rowquesans = "";
                 foreach ($reswords as $rowques) {
                     $rowquesans .= $rowques . ",";
                 }
                 $quesids = mb_substr($rowquesans, 0, -1);
                 $quesans = eF_getTableData("questions", "text,answer", "id IN({$quesids}) order by rand() limit {$maxwords1}");
                 $value = array();
                 foreach ($quesans as $row) {
                     $answer = unserialize($row['answer']);
                     $answer1 = explode("|", $answer['0']);
                     $value[] = array('ANSWER' => $answer1['0'], 'QUESTION' => $row['text']);
                 }
                 $success = $pc->generateFromWords($value);
                 if (!$success) {
                     $message_type = 'failure';
                     $message = _CROSSWORD_UNABLEGENERATECROSSWORD;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                 } else {
                     $currentlesson = $reslesson[0]['name'];
                     $words = $pc->getWords();
                     $answor = array();
                     $html1 = array();
                     $html2 = array();
                     $html1[] = $currentlesson;
                     $html1[] .= $resunit[0]['name'];
                     $html1[] .= _CROSSWORD_ACROSS;
                     $html2[] = _CROSSWORD_DOWN;
                     $k = 1;
                     //pr($words);
                     foreach ($words as $row) {
                         if ($row['axis'] == 1) {
                             $html1[] .= $k . '. ' . $row['question'];
                         } else {
                             $html2[] .= $k . '. ' . $row['question'];
                         }
                         $k++;
                     }
                     //pr($html1);
                     //pr($html2);
                     //exit;
                     $answor[] = array_merge($html1, $html2);
                     //pr($answor); exit;
                     $dd = $pc->getHTML($answor);
                     exit;
                 }
             }
         }
     }
     return true;
 }
Example #26
0
/*
$Id: base_new_from_file.php,v 1.28 2007/05/09 20:31:34 develop Exp $
*/
require_once 'DB.php';
function cleanup_phone($phone)
{
    $phone = str_replace(' ', '', $phone);
    $phone = str_replace('(', '', $phone);
    $phone = str_replace(')', '', $phone);
    $phone = str_replace('-', '', $phone);
    $phone = str_replace('.', '', $phone);
    return $phone;
}
require_once 'HTML/QuickForm.php';
$uploadForm = new HTML_QuickForm('upload_form', 'post');
$uploadForm->setRequiredNote('<span style="color:#ff0000;">*</span> = campos requeridos.');
$uploadForm->addElement('header', 'MyHeader', 'Importar alumnos desde una planilla');
$uploadForm->addElement('hidden', 'action', 'alumno_import');
$file =& $uploadForm->addElement('file', 'filename', 'Archivo:');
$uploadForm->setMaxFileSize(5120000);
$uploadForm->addRule('filename', 'Debe seleccionar un archivo', 'uploadedfile');
$uploadForm->addElement('submit', 'btnUpload', 'Cargar Base');
$field_names_ok = array('legajo', 'nombre', 'doc_nro', 'email', 'telefono', 'orientacion', 'notas');
if ($uploadForm->validate()) {
    unset($params);
    $params['time0'] = time();
    $uploaded_file = $_FILES['filename']['tmp_name'];
    $handle = fopen($uploaded_file, 'r');
    if (!$handle) {
        die('Error al abrir el archivo ' . $uploaded_file);
    }
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     // Always show the preview of the data
     if ($_POST['preview'] || $_POST['submit']) {
         if ($_POST['questions_format'] == "gift") {
             $questions = $this->scanGIFT($_POST['imported_data']);
         } else {
             $questions = $this->scanAIKEN(str_replace('\\"', '"', str_replace("\\'", "'", $_POST['imported_data'])));
         }
         if (sizeof($questions)) {
             $smarty->assign("T_PREVIEW_DIV", $this->createPreviewHTML($questions));
         }
     }
     // Submit the data the data
     if ($_POST['submit']) {
         if ($_POST['select_unit'] == -1 || $_POST['select_unit'] == -2) {
             $content_ID = 0;
         } else {
             $content_ID = $_POST['select_unit'];
         }
         $currentLesson = $this->getCurrentLesson();
         $lessons_ID = $currentLesson->lesson['id'];
         $count = 0;
         foreach ($questions as $key => $question) {
             if ($question['type'] != "same" && $question['type'] != "error" && $question['type'] != "no_answer_error") {
                 $question['content_ID'] = $content_ID;
                 $question['lessons_ID'] = $lessons_ID;
                 $question['difficulty'] = "medium";
                 if (sizeof($question['options'])) {
                     $question['options'] = serialize($question['options']);
                     //$question['options'] = str_replace("'", "&#39;", $question['options']);
                     //$question['options'] = str_replace("\r", "", $question['options']);
                 }
                 if (sizeof($question['answer'])) {
                     // Different accounting for answers of multiple many type
                     if ($question['type'] == "multiple_many") {
                         $answers = array();
                         foreach ($question['answer'] as $answer) {
                             $answers[$answer] = "1";
                         }
                         $question['answer'] = $answers;
                     }
                     $question['answer'] = serialize($question['answer']);
                     //$question['answer'] = str_replace("'", "&#39;", $question['answer']);
                     //$question['answer'] = str_replace("\r", "", $question['answer']);
                 }
                 //$question['text'] = str_replace("'", "&#39;", $question['text']);
                 if (isset($question['explanation'])) {
                     //$question['explanation'] = str_replace("'", "&#39;", $question['explanation']);
                     //$question['explanation'] = str_replace("\r", "", $question['explanation']);
                 }
                 if (Question::createQuestion($question)) {
                     $count++;
                 }
             }
         }
         if ($count) {
             $this->setMessageVar($count . " " . _GIFTAIKEN_QUESTIONSIMPORTEDSUCCESSFULLY, "success");
         } else {
             $this->setMessageVar(_GIFTAIKEN_NOQUESTIONCOULDBEIMPORTED, "failure");
         }
     }
     $pos = strpos($_SERVER['REQUEST_URI'], "&message");
     if ($pos) {
         $postUrl = substr($_SERVER['REQUEST_URI'], 0, $pos);
     } else {
         $postUrl = $_SERVER['REQUEST_URI'];
     }
     $importForm = new HTML_QuickForm("import_users_form", "post", $postUrl, "", null, true);
     $importForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
     //Register this rule for checking user input with our function, eF_checkParameter
     $importForm->addElement('radio', 'questions_format', _GIFTAIKEN_GIFT, null, 'gift', 'id="gift_selection"');
     $importForm->addElement('radio', 'questions_format', _GIFTAIKEN_AIKEN, null, 'aiken', 'id="aiken_selection"');
     $currentLesson = $this->getCurrentLesson();
     $currentContent = new EfrontContentTree($currentLesson->lesson['id']);
     $smarty->assign("T_UNITS", $currentContent->toHTMLSelectOptions());
     $importForm->addElement('textarea', 'imported_data', _GIFTAIKEN_QUESTIONDATATOIMPORT, 'class = "inputProjectTextarea" id="imported_data"');
     $importForm->addElement('submit', 'preview', _PREVIEW, 'class=flatButton onclick="$(\'import_users_form\').action += \'&preview=1\'"');
     $importForm->addElement('submit', 'submit', _SUBMIT, 'class=flatButton');
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     $importForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     $importForm->setRequiredNote(_REQUIREDNOTE);
     $importForm->accept($renderer);
     $smarty->assign('T_GIFTAIKENQUESTIONS_FORM', $renderer->toArray());
     return true;
 }
Example #28
0
                } elseif ($pathParts['extension'] == 'js') {
                    //do not create unit for js files
                } else {
                    if (file_exists(G_THEMESPATH . 'default/images/file_types/' . $pathParts['extension'] . '.png')) {
                        $fields['data'] = '<a href = "view_file.php?file=' . $file['id'] . '&action=download"><img src="images/file_types/' . $pathParts['extension'] . '.png" style="vertical-align:middle" />' . eFront_basename($file['name']) . '</a>';
                    } else {
                        $fields['data'] = '<a href = "view_file.php?file=' . $file['id'] . '&action=download">' . eFront_basename($file['name']) . '</a>';
                    }
                    $unit = $currentContent->insertNode($fields);
                }
            }
        }
        $message = _FILESIMPORTEDSUCCESSFULLY;
        $message_type = 'success';
    } catch (Exception $e) {
        handleNormalFlowExceptions($e);
    }
}
$form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
$form->setRequiredNote(_REQUIREDNOTE);
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$renderer->setRequiredTemplate('{$html}{if $required}
            &nbsp;<span class = "formRequired">*</span>
        {/if}');
$renderer->setErrorTemplate('{$html}{if $error}
            <span class = "formError">{$error}</span>
        {/if}');
$form->accept($renderer);
$smarty->assign("T_MAX_FILE_SIZE", FileSystemTree::getUploadMaxSize());
$smarty->assign('T_ENTITY_FORM', $renderer->toArray());
#cpp#endif
        $pourcentage = round($total / $max * 100);
        if ($pourcentage > 100) {
            $pourcentage = 100;
        }
        $res .= '<div class="jauge" style="font:10px verdana;">Remplissage :
	<img src="tools/preinscription/presentation/compteur.php?pc=' . $pourcentage . '" />
	</div>';
        $res .= '<p style="font:10px verdana;">A 100% de remplissage, un mail sera envoy&eacute; &agrave l\'ensemble des pr&eacute;-inscrits pour fixer la date de la formation.</p>';
    }
    $form_contact = new HTML_QuickForm('preinscription', 'post', $this->config['base_url'] . $page . '/preinscription');
    $squelette =& $form_contact->defaultRenderer();
    $squelette->setFormTemplate("\n" . '<form {attributes}>' . "\n" . '{content}' . "\n" . '</form>' . "\n");
    $squelette->setElementTemplate('<label style="display:block;float:left;clear:both;width:75px;text-align:right;margin:2px;font:10px verdana;">{label}&nbsp;</label>' . "\n" . '{element}' . "\n" . '<!-- BEGIN required --><span style="color:red;font:10px verdana;">*</span><!-- END required -->' . "\n" . '<br />' . "\n");
    $squelette->setRequiredNoteTemplate("\n" . '<span style="color:red;font:10px verdana;float:right;">* {requiredNote}</span>' . "\n");
    $option = array('style' => 'width:100px;border:1px solid black;font:10px verdana;margin:2px;', 'maxlength' => 100);
    $form_contact->setRequiredNote('champs obligatoire');
    $form_contact->setJsWarnings('erreur de saisie', 'corrigez les erreurs suivantes');
    $form_contact->addElement('hidden', 'mailadmin', $mailadmin);
    $form_contact->addElement('hidden', 'pagerenvoi', $this->tag);
    $form_contact->addElement('text', 'Prenom', 'Pr&eacute;nom', $option);
    $form_contact->addRule('Prenom', 'Prenom requis', 'required', '', 'client');
    $form_contact->addElement('text', 'Nom', 'Nom', $option);
    $form_contact->addRule('Nom', 'Nom requis', 'required', '', 'client');
    $form_contact->addElement('text', 'Expediteur', 'Adresse mail', $option);
    $form_contact->addRule('Expediteur', 'Adresse mail requise', 'required', '', 'client');
    $form_contact->addRule('Expediteur', 'L\'adresse mail doit etre de la forme nom@domaine.ext', 'email', '', 'client');
    $tarifs = array('100' => '100 euros (OPCA)', '25' => '25 euros (ch&ocirc;meurs, étudiants)');
    $form_contact->addElement('select', 'Tarif', 'Tarif', $tarifs, $option);
    //sécurité: il faut que javascript soit activé (passage par le template
    $option = array('class' => 'bouton_antispam');
    $form_contact->addElement('hidden', 'jsenabled', 'N', $option);