function eventVCardImport(EventControler $evtcl) { $msg = ""; $goto = $evtcl->getParam("goto"); $uploaded_file = $_FILES['fields']['name']['contact_vcard']; if ($uploaded_file) { $target_path = 'files/' . $uploaded_file; if (!move_uploaded_file($_FILES['fields']['tmp_name']['contact_vcard'], $target_path)) { $msg = "There was an error uploading the file, please try again!"; } else { chmod($target_path, 0755); $_SESSION['vcard_file'] = $uploaded_file; $_SESSION['import_tag'] = trim($evtcl->fields['import_tag']); $retVal = $this->print_vcard_address_book($target_path, 'ofuz vCard Import', '', '', ''); if ($retVal) { $msg = "Your vCard contacts have been imported successfully."; } else { $msg = $this->errMsg; } } } else { $msg = "Please select a file to be imported."; } $disp = new Display($goto); $disp->addParam("msg", $msg); if ($evtcl->getParam("fromReg") == 'Yes') { //if importing while registration $_SESSION["page_from"] = 'reg'; } $evtcl->setDisplayNext($disp); }
public function parse($data, $file, $filters = array(), $content_var = 'the_content') { $display = new Display((array) $filters); $display->meta = $this->meta; $display->meta[$content_var] = $data; return $display->render('layouts/' . $file); }
/** * Event method sharing the contacts with the Co-Workers * @param object $evtcl */ function eventShareContactsMultiple(EventControler $evtcl) { $contacts = $evtcl->getParam("idcontacts"); $co_workers = $evtcl->getParam("cwid"); $count = 0; $no_coworker = 0; if (is_array($contacts) && is_array($co_workers)) { $do_tag = new Tag(); foreach ($co_workers as $co) { foreach ($contacts as $cont) { if (!$this->checkCoWorkerContactRel($cont, $co)) { $this->addContactSharings($cont, $co); $do_tag->addTagOnContactSharing($cont, $co); $count++; } } } } if ($count) { $msg = 'Sharing Updated succesfully'; } else { $msg = 'No Data updated,you may be trying to duplicate some contact access'; } $goto = $evtcl->goto; $dispError = new Display($goto); $dispError->addParam("message", $msg); $evtcl->setDisplayNext($dispError); }
/** * Event function to update the group * Also updates the related member information of the group * @param object $evctl * @see modules/Settings/group_edit.php */ public function eventEditGroup(EventControler $evctl) { $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false; if (true === $permission) { if ($evctl->idgroup != '' && $evctl->group_name) { $qry = "\n\t\t\t\tUPDATE `" . $this->getTable() . "` \n\t\t\t\tset `group_name` = ?,\n\t\t\t\t`description` = ?\n\t\t\t\twhere `idgroup` = ? LIMIT 1"; $this->query($qry, array(CommonUtils::purify_input($evctl->group_name), CommonUtils::purify_input($evctl->description), $evctl->idgroup)); if (is_array($evctl->select_to) && count($evctl->select_to) > 0) { $do_group_user_rel = new GroupUserRelation(); $do_group_user_rel->update_group_related_to_user($evctl->select_to, $evctl->idgroup); } $_SESSION["do_crm_messages"]->set_message('success', _('Group has been updated successfully !')); $dis = new Display($evctl->next_page); $dis->addParam("sqrecord", $evctl->idgroup); $evctl->setDisplayNext($dis); } else { $_SESSION["do_crm_messages"]->set_message('error', _('Unable to update the group, either group name or id is missing !')); $dis = new Display($evctl->error_page); $evctl->setDisplayNext($dis); } } else { $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to edit record !')); $next_page = NavigationControl::getNavigationLink("Settings", "index"); $dis = new Display($next_page); $evctl->setDisplayNext($dis); } }
function eventChangeGoto(Eventcontroler $evtcl) { $fields = $evtcl->fields; $dispError = new Display("settings_auto_responder_email.php"); $dispError->addParam("id", $fields["idautoresponder"]); $evtcl->setDisplayNext($dispError); }
function get() { $profile_uid = intval($_GET['p']); if (!$profile_uid) { $profile_uid = -1; } $load = argc() > 1 && argv(1) == 'load' ? 1 : 0; header("Content-type: text/html"); echo "<!DOCTYPE html><html><body>\r\n"; echo $_GET['msie'] == 1 ? '<div>' : '<section>'; $mod = new Display(); $text = $mod->get($profile_uid, $load); $pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; $replace = "<img\${1} dst=\"\${2}\""; // $text = preg_replace($pattern, $replace, $text); /* if(! $load) { $replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $text = preg_replace($pattern, $replace, $text); } */ echo str_replace("\t", ' ', $text); echo $_GET['msie'] == 1 ? '</div>' : '</section>'; echo "</body></html>\r\n"; // logger('update_display: ' . $text); killme(); }
public function main() { $db = new Database(); $field1 = 'first_name,second_name,login,reg_password,mail,b_day,telephone'; $user_attr = $db->selectFields($field1, 'login', $_SESSION['login'][0]); $display = new Display(); $display->view(null, 'registration', $user_attr); }
public function main() { $db = new Database(); // подключаем класс работы с базой $fetchAll = $db->selectAll('contacts'); $display = new Display(); // подключаем класс отвечающий за структуру вывода на экран $display->view($fetchAll, 'contacts', null); }
public function main() { $error_id = 'Вы разлогинелись...'; unset($_SESSION['login']); session_destroy(); $display = new Display(); // подключаем класс отвечающий за структуру вывода на экран $display->alert($error_id); $display->view(null, 'enter', null); }
function eventCheckEmptyFields(Eventcontroler $evtcl) { $field_selected = $evtcl->field_selected; if (empty($field_selected)) { $_SESSION['in_page_message'] = _("Please select some labels"); $evtcl->doSave = 'no'; $evtcl->goto = 'settings_wf.php'; $dispError = new Display("settings_wf.php"); $dispError->addParam("e", 'yes'); $evtcl->setDisplayNext($dispError); } }
/** * event function to add a custom view * @param object $evctl * @return void */ public function eventAddRecord(EventControler $evctl) { if (trim($evctl->cvname) == '') { $_SESSION["do_crm_messages"]->set_message('error', _('Please add a custom view name before saving !')); $next_page = NavigationControl::getNavigationLink("CustomView", "add"); $dis = new Display($next_page); $dis->addParam("target_module_id", (int) $evctl->target_module_id); $evctl->setDisplayNext($dis); } elseif ((int) $evctl->target_module_id == 0) { $_SESSION["do_crm_messages"]->set_message('error', _('Missing target module for custom view !')); $next_page = NavigationControl::getNavigationLink("CustomView", "add"); $dis = new Display($next_page); $evctl->setDisplayNext($dis); } elseif (false === $_SESSION["do_crm_action_permission"]->action_permitted('add', 17)) { $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to add record !')); $next_page = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$evctl->target_module_id]["name"], "list"); $dis = new Display($next_page); $evctl->setDisplayNext($dis); } else { $this->addNew(); $this->name = $evctl->cvname; $this->iduser = $_SESSION["do_user"]->iduser; $this->is_default = $evctl->is_default == 'on' ? 1 : 0; if ($_SESSION["do_user"]->is_admin == 1) { $this->is_public = $evctl->is_public == 'on' ? 1 : 0; } $this->idmodule = (int) $evctl->target_module_id; $this->is_editable = 1; $this->add(); $idcustom_view = $this->getInsertId(); //reset default custom view if is_default is set if ($evctl->is_default == 'on') { $this->reset_default_custom_view($idcustom_view, $evctl->target_module_id); } //add custom view fields $do_custom_view_fields = new CustomViewFields(); $do_custom_view_fields->add_custom_view_fields($idcustom_view, $evctl->cv_fields); //add custom view filter $do_custom_view_filter = new CustomViewFilter(); $do_custom_view_filter->add_custom_view_date_filter($idcustom_view, $evctl->cv_date_field, $evctl->cv_date_field_type, $evctl->cv_date_start, $evctl->cv_date_end); //add advanced filter $adv_filter_data = array("cv_adv_fields_1" => $evctl->cv_adv_fields_1, "cv_adv_fields_type_1" => $evctl->cv_adv_fields_type_1, "cv_adv_fields_val_1" => $_POST["cv_adv_fields_val_1"], "cv_adv_fields_2" => $evctl->cv_adv_fields_2, "cv_adv_fields_type_2" => $evctl->cv_adv_fields_type_2, "cv_adv_fields_val_2" => $_POST["cv_adv_fields_val_2"], "cv_adv_fields_3" => $evctl->cv_adv_fields_3, "cv_adv_fields_type_3" => $evctl->cv_adv_fields_type_3, "cv_adv_fields_val_3" => $_POST["cv_adv_fields_val_3"], "cv_adv_fields_4" => $evctl->cv_adv_fields_4, "cv_adv_fields_type_4" => $evctl->cv_adv_fields_type_4, "cv_adv_fields_val_4" => $_POST["cv_adv_fields_val_4"], "cv_adv_fields_5" => $evctl->cv_adv_fields_5, "cv_adv_fields_type_5" => $evctl->cv_adv_fields_type_5, "cv_adv_fields_val_5" => $_POST["cv_adv_fields_val_5"]); $do_custom_view_filter->add_custom_view_adv_filter($idcustom_view, $adv_filter_data); //redirect after adding the custom view $next_page = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$evctl->target_module_id]["name"], "list", '', '&custom_view_id=' . $idcustom_view); $dis = new Display($next_page); $evctl->setDisplayNext($dis); } }
public function display() { $disp = Display::current(); require_once 'packages/magpierss/rss_fetch.inc'; $rss = fetch_rss('http://shortsoup.net.au/?feed=rss2&p=11'); $disp->setValue('comments', $rss->items); $disp->setValue('add_comment', $rss->channel['link']); print_r($rss->items); // Include the javascript for the page JsRegister::current()->registerScript('home'); // if(Application::current()->user()->authorise('SeeingsystemSetup')) $disp->setValue('logged_in', true); // else // { // $disp->setValue('login_error',$this->login_error); // $login_form = Form::load('seeingsystem.views.Login'); // $disp->addForm($login_form); // } $disp->setTitle('SeeingSystem - A Flickr Slideshow of Ordinary Beautiful Things'); $disp->addView('page_content', 'seeingsystem.views.Home'); /* echo "<br />DEBUG: Home::display()<br />\n"; exit; */ $disp->displaySiteTemplate(); }
function __construct() { parent::__construct(); parent::init(); acl_helper::acl_redirect(steamauth_helper::get_role(), 'admin'); Display::instance()->set_template('template-admin'); }
/** * Get the necessary javascript for this datepicker * @return string */ private function getElementJS() { $js = null; $id = $this->getAttribute('id'); $js .= "<script>\n \$(function() {\n /*\$('#{$id}').hide().datepicker({\n defaultDate: '" . $this->getValue() . "',\n dateFormat: 'yy-mm-dd',\n altField: '#{$id}_alt',\n altFormat: \"" . get_lang('DateFormatLongNoDayJS') . "\",\n showOn: 'both',\n buttonImage: '" . Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true) . "',\n buttonImageOnly: true,\n buttonText: '" . get_lang('SelectDate') . "',\n changeMonth: true,\n changeYear: true,\n yearRange: 'c-60y:c+5y'\n });*/\n\n \$('#{$id}').datetimepicker({\n defaultDate: '" . $this->getValue() . "',\n format: 'YYYY-MM-DD'\n });\n\n });\n </script>"; return $js; }
static function instance() { if (!self::$_display) { self::$_display = new Display(); } return self::$_display; }
/** * Get smarty object for templating. Uses Singleton pattern * * @return Smarty */ public static function getSmarty() { if (!self::$smarty instanceof Smarty) { self::$smarty = new Smarty(); } return self::$smarty; }
function edit_filter($id, $url_params, $row) { global $charset; $return = '<a href="specific_fields_add.php?action=edit&field_id=' . $row[0] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>'; $return .= ' <a href="' . api_get_self() . '?action=delete&field_id=' . $row[0] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a>'; return $return; }
/** * Displays the title + grid */ public function display() { // action links $content = Display::actions(array(array('url' => 'event_type.php', 'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)))); $content .= Display::grid_html('event_email_template'); return $content; }
public function registerJavascript($disp) { $root_params = array('file', 'width', 'height', 'version', 'background', 'id'); if (!JsRegister::current()->isRegistered('swfobject')) { JsRegister::current()->setPluginPath('ext/js/'); JsRegister::current()->registerScript('swfobject'); } if (!JsRegister::current()->isRegistered('swf_object')) { JsRegister::current()->setPluginPath('packages/sys/display/rsml/meta/'); JsRegister::current()->registerScript('swf_object'); } if (is_object($disp)) { $object_params = array(); $swf_params = array(); foreach ($this->attributeNames() as $name) { if ($name != 'class' && $name != 'name') { if ($this->dynamic_attributes->isDynamic($name)) { $val = Display::rsmlValue($disp->variables(), $this->dynamic_attributes->attribute($name)); } else { $val = $this->attribute($name, RsmlNode::CTX_PLAIN); } if (in_array($name, $root_params)) { $object_params[DynamicAttributes::realName($name)] = $val; } else { $swf_params[DynamicAttributes::realName($name)] = $val; } } } if (count($swf_params)) { $object_params['params'] = $swf_params; } JsRegister::current()->appendArgument('swf_object', 'objects', array($object_params)); } }
/** * @Route("/edit/{tool}") * @Method({"GET"}) * * @param string $tool * @return Response */ public function editAction($tool) { $message = null; // @todo use proper functions not api functions. $courseId = api_get_course_int_id(); $sessionId = api_get_session_id(); $tool = \Database::escape_string($tool); $TBL_INTRODUCTION = \Database::get_course_table(TABLE_TOOL_INTRO); $url = $this->generateUrl('introduction.controller:editAction', array('tool' => $tool, 'course' => api_get_course_id())); $form = $this->getForm($url, $tool); if ($form->validate()) { $values = $form->exportValues(); $content = $values['content']; $sql = "REPLACE {$TBL_INTRODUCTION}\n SET c_id = {$courseId},\n id = '{$tool}',\n intro_text='" . \Database::escape_string($content) . "',\n session_id='" . intval($sessionId) . "'"; \Database::query($sql); $message = \Display::return_message(get_lang('IntroductionTextUpdated'), 'confirmation', false); } else { $sql = "SELECT intro_text FROM {$TBL_INTRODUCTION}\n WHERE c_id = {$courseId} AND id='" . $tool . "' AND session_id = '" . intval($sessionId) . "'"; $result = \Database::query($sql); $content = null; if (\Database::num_rows($result) > 0) { $row = \Database::fetch_array($result); $content = $row['intro_text']; } $form->setDefaults(array('content' => $content)); } $this->getTemplate()->assign('content', $form->return_form()); $this->getTemplate()->assign('message', $message); $response = $this->getTemplate()->renderLayout('layout_1_col.tpl'); return new Response($response, 200, array()); }
/** * This method return content html containing information about teachers and its position for showing it inside dashboard interface * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ public function get_block() { global $charset; $column = 1; $data = array(); $teacher_information_graph = $this->get_teachers_information_graph(); $html = ' <li class="widget color-blue" id="intro"> <div class="widget-head"> <h3>'.get_lang('TeachersInformationsGraph').'</h3> <div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div> </div> <div class="widget-content" align="center"> <div style="padding:10px;"><strong>'.get_lang('TimeSpentOnThePlatformLastWeekByDay').'</strong></div> '.$teacher_information_graph.' </div> </li> '; $data['column'] = $column; $data['content_html'] = $html; return $data; }
/** * * @param array $breadcrumbs */ protected function setBreadcrumb($breadcrumbs) { $course = $this->getCourse(); //$session = $this->getSession(); // Adding course breadcrumb. if (!empty($course)) { $courseBreadcrumb = array('name' => \Display::return_icon('home.png') . ' ' . $course->getTitle(), 'url' => array('route' => 'course', 'routeParameters' => array('cidReq' => $course->getCode(), 'id_session' => api_get_session_id()))); array_unshift($breadcrumbs, $courseBreadcrumb); } $app = $this->app; $app['main_breadcrumb'] = function ($app) use($breadcrumbs) { /** @var \Knp\Menu\MenuItem $menu */ $menu = $app['knp_menu.factory']->createItem('root', array('childrenAttributes' => array('class' => 'breadcrumb', 'currentClass' => 'active'))); if (!empty($breadcrumbs)) { foreach ($breadcrumbs as $item) { if (empty($item['url'])) { $item['url'] = array(); } $menu->addChild($item['name'], $item['url']); } } return $menu; }; $matcher = new Matcher(); $voter = new \Knp\Menu\Silex\Voter\RouteVoter(); $voter->setRequest($this->getRequest()); $matcher->addVoter($voter); $renderer = new \Knp\Menu\Renderer\TwigRenderer($this->get('twig'), 'bread.tpl', $matcher); $bread = $renderer->render($this->get('main_breadcrumb'), array('template' => 'default/layout/bread.tpl')); $app['breadcrumbs'] = $bread; }
function prepare_skill_box($skill, $position, $class) { $block_id = $skill['id']; $extra_class = 'third_window'; if ($skill['parent_id'] == 0) { $extra_class = 'second_window'; } $this->html .= '<div id="block_' . $block_id . '" class = "open_block window ' . $extra_class . ' ' . $class . '" style = "top:' . $position['y'] . 'px; left:' . $position['x'] . 'px;">'; /*$gradebook_string = ''; if (!empty($skill['gradebooks'])) { foreach ($skill['gradebooks'] as $gradebook) { //uncomment this to show the gradebook tags $gradebook_string .= Display::span($gradebook['name'], array('class'=>'label_tag gradebook','style'=>'width:50px')).'<br />'; } } */ $content = $skill['name']; $content .= '<div class="btn-group">'; $content .= Display::url(get_lang('Edit'), '#', array('id' => 'edit_block_' . $block_id, 'class' => 'edit_block btn')); $content .= Display::url('+', '#', array('id' => 'edit_block_' . $block_id, 'class' => 'edit_block btn')); $content .= '</div>'; $this->html .= $content . ' ' . $gradebook_string; if ($this->type == 'edit' && $skill['parent_id'] != 0) { //$this->html .= Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block')); //$this->html .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block')); //$this->html .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block')); //$this->html .= Display::url(Display::return_icon('up.png', get_lang('Close'), array(), ICON_SIZE_SMALL), '#', array('id'=>'close_block_'.$block_id,'class'=>'close_block')); //$this->html .= Display::url(Display::return_icon('down.png', get_lang('Open'), array(), ICON_SIZE_SMALL), '#', array('id'=>'open_block_'.$block_id,'class'=>'open_block')); } $this->html .= '</div>'; }
/** * Display contact form */ function indexAction() { Display::set("adPage", "contact"); if (!Config::get("contactPageEnabled")) { return $this->return404(); } }
function openid_form() { $form = new FormValidator('openid_login', 'post', null, null, array('class' => 'form-vertical form_login')); $form->addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input')); $form->addElement('button', 'submit', get_lang('Login')); return $form->return_form(); }
function lp_upload_quiz_main() { // variable initialisation $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : null; $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data')); $form->addElement('header', get_lang('ImportExcelQuiz')); $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload')); $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')) . get_lang('DownloadExcelTemplate') . '</a>'; $form->addElement('label', '', $link); $table = new HTML_Table(array('class' => 'table')); $tableList = array(UNIQUE_ANSWER => get_lang('UniqueSelect'), MULTIPLE_ANSWER => get_lang('MultipleSelect'), FILL_IN_BLANKS => get_lang('FillBlanks'), MATCHING => get_lang('Matching'), FREE_ANSWER => get_lang('FreeAnswer'), GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer')); $table->setHeaderContents(0, 0, get_lang('QuestionType')); $table->setHeaderContents(0, 1, '#'); $row = 1; foreach ($tableList as $key => $label) { $table->setCellContents($row, 0, $label); $table->setCellContents($row, 1, $key); $row++; } $table = $table->toHtml(); $form->addElement('label', get_lang('QuestionType'), $table); $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id' => 'user_custom_score')); $form->addElement('html', '<div id="options" style="display:none">'); $form->addElement('text', 'correct_score', get_lang('CorrectScore')); $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore')); $form->addElement('html', '</div>'); $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required'); $form->add_progress_bar(); $form->addButtonUpload(get_lang('Upload'), 'submit_upload_quiz'); // Display the upload field $form->display(); }
/** * This method return content html containing information about courses and its position for showing it inside dashboard interface * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ public function get_block() { global $charset; $column = 2; $data = array(); $content = $this->get_content_html(); $html = ' <li class="widget color-green" id="intro"> <div class="widget-head"> <h3>' . get_lang('CoursesInformation') . '</h3> <div class="widget-actions"><a onclick="javascript:if(!confirm(\'' . addslashes( api_htmlentities( get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset ) ) . '\')) return false;" href="index.php?action=disable_block&path=' . $this->path . '">' . Display::return_icon( 'close.gif', get_lang('Close') ) . '</a></div> </div> <div class="widget-content"> ' . $content . ' </div> </li> '; $data['column'] = $column; $data['content_html'] = $html; return $data; }
/** * @package chamilo.survey * @author Arnaud Ligot <*****@*****.**> * @version $Id: $ * * A small peace of code to enable user to access images included into survey * which are accessible by non authenticated users. This file is included * by document/download.php */ function check_download_survey($course, $invitation, $doc_url) { require_once 'survey.lib.php'; // Getting all the course information $_course = CourseManager::get_course_information($course); $course_id = $_course['real_id']; // Database table definitions $table_survey = Database::get_course_table(TABLE_SURVEY); $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION); $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); // Now we check if the invitationcode is valid $sql = "SELECT * FROM {$table_survey_invitation}\n\t WHERE\n\t c_id = {$course_id} AND\n\t invitation_code = '" . Database::escape_string($invitation) . "'"; $result = Database::query($sql); if (Database::num_rows($result) < 1) { Display::display_error_message(get_lang('WrongInvitationCode'), false); Display::display_footer(); exit; } $survey_invitation = Database::fetch_assoc($result); // Now we check if the user already filled the survey if ($survey_invitation['answered'] == 1) { Display::display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false); Display::display_footer(); exit; } // Very basic security check: check if a text field from a survey/answer/option contains the name of the document requested // Fetch survey ID // If this is the case there will be a language choice $sql = "SELECT * FROM {$table_survey}\n\t WHERE\n\t c_id = {$course_id} AND\n\t code='" . Database::escape_string($survey_invitation['survey_code']) . "'"; $result = Database::query($sql); if (Database::num_rows($result) > 1) { if ($_POST['language']) { $survey_invitation['survey_id'] = $_POST['language']; } else { echo '<form id="language" name="language" method="POST" action="' . api_get_self() . '?course=' . $_GET['course'] . '&invitationcode=' . $_GET['invitationcode'] . '">'; echo ' <select name="language">'; while ($row = Database::fetch_assoc($result)) { echo '<option value="' . $row['survey_id'] . '">' . $row['lang'] . '</option>'; } echo '</select>'; echo ' <input type="submit" name="Submit" value="' . get_lang('Ok') . '" />'; echo '</form>'; display::display_footer(); exit; } } else { $row = Database::fetch_assoc($result); $survey_invitation['survey_id'] = $row['survey_id']; } $sql = "SELECT count(*)\n\t FROM {$table_survey}\n\t WHERE\n\t c_id = {$course_id} AND\n\t survey_id = " . $survey_invitation['survey_id'] . " AND (\n title LIKE '%{$doc_url}%'\n or subtitle LIKE '%{$doc_url}%'\n or intro LIKE '%{$doc_url}%'\n or surveythanks LIKE '%{$doc_url}%'\n )\n\t\t UNION\n\t\t SELECT count(*)\n\t\t FROM {$table_survey_question}\n\t\t WHERE\n\t\t c_id = {$course_id} AND\n\t\t survey_id = " . $survey_invitation['survey_id'] . " AND (\n survey_question LIKE '%{$doc_url}%'\n or survey_question_comment LIKE '%{$doc_url}%'\n )\n\t\t UNION\n\t\t SELECT count(*)\n\t\t FROM {$table_survey_question_option}\n\t\t WHERE\n\t\t c_id = {$course_id} AND\n\t\t survey_id = " . $survey_invitation['survey_id'] . " AND (\n option_text LIKE '%{$doc_url}%'\n )"; $result = Database::query($sql); if (Database::num_rows($result) == 0) { Display::display_error_message(get_lang('WrongInvitationCode'), false); Display::display_footer(); exit; } return $_course; }
public function main($title) { $db = new Loginform(); $db->updateStatus('offline', $_SESSION['login'][0]['login']); unset($_SESSION['login']); session_destroy(); Display::view('login', $title, null); }
public function display() { $disp = Display::current(); $disp->setValue('page_heading', 'RocketSled Support'); $disp->setValue('page_subheading', 'Where to get help using RocketSled'); $disp->addView('page_content', 'sys.views.RocketSledSupport'); $disp->displaySiteTemplate(); }