Minor - Fixing comments, fixing PHP warnings.

1.9.x
Julio Montoya 12 years ago
parent ea9f20b0c9
commit 20ecb6d390
  1. 14
      main/exercice/tests_category.php
  2. 10
      main/forum/forumfunction.inc.php
  3. 74
      main/glossary/index.php
  4. 4
      main/gradebook/lib/scoredisplay.class.php
  5. 98
      main/inc/lib/gradebook.lib.php
  6. 2
      main/inc/lib/promotion.lib.php
  7. 2
      main/inc/lib/timeline.lib.php
  8. 4
      main/notebook/index.php
  9. 4
      main/survey/create_new_survey.php
  10. 182
      main/wiki/diff.inc.php
  11. 813
      main/wiki/index.php
  12. 139
      main/wiki/wiki.inc.php

@ -63,27 +63,27 @@ function edit_category_form($in_action) {
$category_id = Security::remove_XSS($_GET['category_id']); $category_id = Security::remove_XSS($_GET['category_id']);
$objcat = new Testcategory($category_id); $objcat = new Testcategory($category_id);
// initiate the object // initiate the object
$form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action . '&category_id=' . $category_id); $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action . '&category_id=' . $category_id);
// settting the form elements // settting the form elements
$form->addElement('header', get_lang('EditCategory')); $form->addElement('header', get_lang('EditCategory'));
$form->addElement('hidden', 'category_id'); $form->addElement('hidden', 'category_id');
$form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95')); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
$form->addElement('style_submit_button', 'SubmitNote', get_lang('ModifyCategory'), 'class="add"'); $form->addElement('style_submit_button', 'SubmitNote', get_lang('ModifyCategory'), 'class="add"');
// setting the defaults // setting the defaults
$defaults = array(); $defaults = array();
$defaults["category_id"] = $objcat->id; $defaults["category_id"] = $objcat->id;
$defaults["category_name"] = $objcat->name; $defaults["category_name"] = $objcat->name;
$defaults["category_description"] = $objcat->description; $defaults["category_description"] = $objcat->description;
$form->setDefaults($defaults); $form->setDefaults($defaults);
// setting the rules // setting the rules
$form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
// The validation or display // The validation or display
if ($form->validate()) { if ($form->validate()) {
$check = Security::check_token('post'); $check = Security::check_token('post');
if ($check) { if ($check) {
@ -138,7 +138,7 @@ function add_category_form($in_action) {
$in_action = Security::remove_XSS($in_action); $in_action = Security::remove_XSS($in_action);
// initiate the object // initiate the object
$form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action); $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action);
// settting the form elements // Setting the form elements
$form->addElement('header', get_lang('AddACategory')); $form->addElement('header', get_lang('AddACategory'));
$form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95')); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
@ -227,4 +227,4 @@ function protectJSDialogQuote($in_txt) {
$res = str_replace("'", "\'", $res); $res = str_replace("'", "\'", $res);
$res = str_replace('"', "\'\'", $res); // super astuce pour afficher les " dans les boite de dialogue $res = str_replace('"', "\'\'", $res); // super astuce pour afficher les " dans les boite de dialogue
return $res; return $res;
} }

@ -149,7 +149,7 @@ function show_add_forumcategory_form($inputvalues = array(), $lp_id)
// hidden field if from learning path // hidden field if from learning path
$form->addElement('hidden', 'lp_id', $lp_id); $form->addElement('hidden', 'lp_id', $lp_id);
// Settting the form elements. // Setting the form elements.
$form->addElement('header', '', get_lang('AddForumCategory')); $form->addElement('header', '', get_lang('AddForumCategory'));
$form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles" id="category_title"'); $form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles" id="category_title"');
@ -404,7 +404,7 @@ function show_edit_forumcategory_form($inputvalues = array())
$gradebook = Security::remove_XSS($_GET['gradebook']); $gradebook = Security::remove_XSS($_GET['gradebook']);
$form = new FormValidator('forumcategory', 'post', 'index.php?&gradebook='.$gradebook.''); $form = new FormValidator('forumcategory', 'post', 'index.php?&gradebook='.$gradebook.'');
// Settting the form elements. // Setting the form elements.
$form->addElement('header', '', get_lang('EditForumCategory')); $form->addElement('header', '', get_lang('EditForumCategory'));
$form->addElement('hidden', 'forum_category_id'); $form->addElement('hidden', 'forum_category_id');
$form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles"'); $form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles"');
@ -2154,7 +2154,7 @@ function show_add_post_form($action = '', $id = '', $form_values = '')
$form->addElement('header', $text); $form->addElement('header', $text);
// Settting the form elements. // Setting the form elements.
$form->addElement('hidden', 'forum_id', intval($my_forum)); $form->addElement('hidden', 'forum_id', intval($my_forum));
$form->addElement('hidden', 'thread_id', intval($my_thread)); $form->addElement('hidden', 'thread_id', intval($my_thread));
$form->addElement('hidden', 'gradebook', $my_gradebook); $form->addElement('hidden', 'gradebook', $my_gradebook);
@ -2602,7 +2602,7 @@ function show_edit_post_form($current_post, $current_thread, $current_forum, $fo
// Initialize the object. // Initialize the object.
$form = new FormValidator('edit_post', 'post', api_get_self().'?forum='.Security::remove_XSS($_GET['forum']).'&gradebook='.$gradebook.'&origin='.$origin.'&thread='.Security::remove_XSS($_GET['thread']).'&post='.Security::remove_XSS($_GET['post'])); $form = new FormValidator('edit_post', 'post', api_get_self().'?forum='.Security::remove_XSS($_GET['forum']).'&gradebook='.$gradebook.'&origin='.$origin.'&thread='.Security::remove_XSS($_GET['thread']).'&post='.Security::remove_XSS($_GET['post']));
$form->addElement('header', get_lang('EditPost')); $form->addElement('header', get_lang('EditPost'));
// Settting the form elements. // Setting the form elements.
$form->addElement('hidden', 'post_id', $current_post['post_id']); $form->addElement('hidden', 'post_id', $current_post['post_id']);
$form->addElement('hidden', 'thread_id', $current_thread['thread_id']); $form->addElement('hidden', 'thread_id', $current_thread['thread_id']);
$form->addElement('hidden', 'id_attach', $id_attach); $form->addElement('hidden', 'id_attach', $id_attach);
@ -3554,7 +3554,7 @@ function forum_search()
// Initialize the object. // Initialize the object.
$form = new FormValidator('forumsearch', 'post', 'forumsearch.php?origin='.$origin.''); $form = new FormValidator('forumsearch', 'post', 'forumsearch.php?origin='.$origin.'');
// Settting the form elements. // Setting the form elements.
$form->addElement('header', '', get_lang('ForumSearch')); $form->addElement('header', '', get_lang('ForumSearch'));
$form->addElement('text', 'search_term', get_lang('SearchTerm'), 'class="input_titles" id="search_title"'); $form->addElement('text', 'search_term', get_lang('SearchTerm'), 'class="input_titles" id="search_title"');
$form->applyFilter('search_term', 'html_filter'); $form->applyFilter('search_term', 'html_filter');

@ -50,39 +50,39 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
$tool = 'GlossaryManagement'; $tool = 'GlossaryManagement';
$interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('Glossary')); $interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('Glossary'));
if (!empty($action)) { if (!empty($action)) {
} }
switch ($action) { switch ($action) {
case 'addglossary': case 'addglossary':
$tool_name = get_lang('Add'); $tool_name = get_lang('Add');
break; break;
case 'edit_glossary': case 'edit_glossary':
$tool_name = get_lang('Edit'); $tool_name = get_lang('Edit');
break; break;
case 'import': case 'import':
$tool_name = get_lang('ImportGlossary'); $tool_name = get_lang('ImportGlossary');
break; break;
case 'changeview': case 'changeview':
$tool_name = get_lang('List'); $tool_name = get_lang('List');
break; break;
} }
if (isset($_GET['action']) && $_GET['action'] == 'export') { if (isset($_GET['action']) && $_GET['action'] == 'export') {
$data = GlossaryManager::get_glossary_data(0, GlossaryManager::get_number_glossary_terms (api_get_session_id()), 0, 'ASC'); $data = GlossaryManager::get_glossary_data(0, GlossaryManager::get_number_glossary_terms (api_get_session_id()), 0, 'ASC');
usort($data, "sorter"); usort($data, "sorter");
$list = array(); $list = array();
$list[] = array('term','definition'); $list[] = array('term','definition');
foreach($data as $line) { foreach($data as $line) {
$list[] = array ($line[0], $line[1]); $list[] = array ($line[0], $line[1]);
} }
$filename = 'glossary_course_'.api_get_course_id(); $filename = 'glossary_course_'.api_get_course_id();
Export::export_table_csv_utf8($list, $filename); Export::export_table_csv_utf8($list, $filename);
} }
if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') { if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') {
GlossaryManager::export_to_pdf(); GlossaryManager::export_to_pdf();
} }
@ -100,11 +100,11 @@ if (isset($_GET['action']) && $_GET['action'] == 'changeview' AND in_array($_GET
} }
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
switch ($action) { switch ($action) {
case 'addglossary': case 'addglossary':
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action'])); $form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// settting the form elements // Setting the form elements
$form->addElement('header', '', get_lang('TermAddNew')); $form->addElement('header', '', get_lang('TermAddNew'));
$form->addElement('text', 'glossary_title', get_lang('TermName'), array('size'=>'80', 'id'=>'glossary_title')); $form->addElement('text', 'glossary_title', get_lang('TermName'), array('size'=>'80', 'id'=>'glossary_title'));
//$form->applyFilter('glossary_title', 'html_filter'); //$form->applyFilter('glossary_title', 'html_filter');
@ -125,23 +125,23 @@ if (api_is_allowed_to_edit(null, true)) {
$token = Security::get_token(); $token = Security::get_token();
$form->addElement('hidden','sec_token'); $form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token)); $form->setConstants(array('sec_token' => $token));
$form->display(); $form->display();
} }
break; break;
case 'edit_glossary': case 'edit_glossary':
if (is_numeric($_GET['glossary_id'])) { if (is_numeric($_GET['glossary_id'])) {
// initiate the object // initiate the object
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&glossary_id='.Security::remove_XSS($_GET['glossary_id'])); $form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&glossary_id='.Security::remove_XSS($_GET['glossary_id']));
// settting the form elements // Setting the form elements
$form->addElement('header', '', get_lang('TermEdit')); $form->addElement('header', '', get_lang('TermEdit'));
$form->addElement('hidden', 'glossary_id'); $form->addElement('hidden', 'glossary_id');
$form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'80')); $form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'80'));
//$form->applyFilter('glossary_title', 'html_filter'); //$form->applyFilter('glossary_title', 'html_filter');
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300')); $form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300'));
$element = $form->addElement('text', 'insert_date', get_lang('CreationDate'),array('size'=>'100')); $element = $form->addElement('text', 'insert_date', get_lang('CreationDate'),array('size'=>'100'));
$element ->freeze(); $element ->freeze();
$element = $form->addElement('text', 'update_date', get_lang('UpdateDate'),array('size'=>'100')); $element = $form->addElement('text', 'update_date', get_lang('UpdateDate'),array('size'=>'100'));
$element ->freeze(); $element ->freeze();
$form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"'); $form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"');
// setting the defaults // setting the defaults
@ -179,7 +179,7 @@ if (api_is_allowed_to_edit(null, true)) {
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token)); $form->setConstants(array('sec_token' => $token));
$form->display(); $form->display();
} }
} }
break; break;
case 'delete_glossary': case 'delete_glossary':
@ -196,18 +196,18 @@ if (api_is_allowed_to_edit(null, true)) {
break; break;
case 'import': case 'import':
$form = new FormValidator('glossary','post', api_get_self().'?action=import'); $form = new FormValidator('glossary','post', api_get_self().'?action=import');
$form->addElement('header', '', get_lang('ImportGlossary')); $form->addElement('header', '', get_lang('ImportGlossary'));
$form->addElement('file', 'file', get_lang('ImportCSVFileLocation')); $form->addElement('file', 'file', get_lang('ImportCSVFileLocation'));
$form->addElement('checkbox', 'replace', null, get_lang('DeleteAllGlossaryTerms')); $form->addElement('checkbox', 'replace', null, get_lang('DeleteAllGlossaryTerms'));
$form->addElement('style_submit_button', 'SubmitImport', get_lang('Import'), 'class="save"'); $form->addElement('style_submit_button', 'SubmitImport', get_lang('Import'), 'class="save"');
$form->display(); $form->display();
echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')';
echo '<pre> echo '<pre>
<strong>term</strong>;<strong>definition</strong>; <strong>term</strong>;<strong>definition</strong>;
"Hello";"Hola"; "Hello";"Hola";
"Good";"Bueno";</pre>'; "Good";"Bueno";</pre>';
if ($form->validate()) { if ($form->validate()) {
//this is a bad idea //jm //this is a bad idea //jm
if (isset($_POST['replace']) && $_POST['replace']) { if (isset($_POST['replace']) && $_POST['replace']) {
@ -216,33 +216,33 @@ if (api_is_allowed_to_edit(null, true)) {
Display::display_error_message (get_lang ("CannotDeleteGlossary") . ':' . $term['id']); Display::display_error_message (get_lang ("CannotDeleteGlossary") . ':' . $term['id']);
} }
} }
} }
//$data = Import::csv_to_array($_FILES['file']['tmp_name']); //$data = Import::csv_to_array($_FILES['file']['tmp_name']);
$data = Import::csv_reader($_FILES['file']['tmp_name']); $data = Import::csv_reader($_FILES['file']['tmp_name']);
$good = 0; $good = 0;
$bad = 0; $bad = 0;
foreach ($data as $item) { foreach ($data as $item) {
if (GlossaryManager::save_glossary(array('glossary_title' => $item['term'], 'glossary_comment' => $item['definition']), false)) if (GlossaryManager::save_glossary(array('glossary_title' => $item['term'], 'glossary_comment' => $item['definition']), false))
$good++; $good++;
else else
$bad++; $bad++;
} }
Display::display_confirmation_message (get_lang ("TermsImported") . ':' . $good); Display::display_confirmation_message (get_lang ("TermsImported") . ':' . $good);
if ($bad) if ($bad)
Display::display_error_message (get_lang ("TermsNotImported") . ':' . $bad); Display::display_error_message (get_lang ("TermsNotImported") . ':' . $bad);
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} }
break; break;
default: default:
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
break; break;
} }
} else { } else {
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} }
// Footer // Footer
Display::display_footer(); Display::display_footer();

@ -91,12 +91,12 @@ class ScoreDisplay
$this->category_id = $category_id; $this->category_id = $category_id;
} }
//Loading portal settings + using standard functions // Loading portal settings + using standard functions.
$value = api_get_setting('gradebook_score_display_coloring'); $value = api_get_setting('gradebook_score_display_coloring');
$value = $value['my_display_coloring']; $value = $value['my_display_coloring'];
//Settting coloring // Setting coloring.
$this->coloring_enabled = $value == 'true' ? true : false; $this->coloring_enabled = $value == 'true' ? true : false;
if ($this->coloring_enabled) { if ($this->coloring_enabled) {

@ -8,47 +8,47 @@
/** /**
* Code * Code
*/ */
class Gradebook extends Model { class Gradebook extends Model {
public $columns = array('id', 'name', 'description', 'course_code', 'parent_id', 'grade_model_id', 'session_id', 'weight', 'user_id'); public $columns = array('id', 'name', 'description', 'course_code', 'parent_id', 'grade_model_id', 'session_id', 'weight', 'user_id');
public function __construct() { public function __construct() {
$this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$this->table_skill = Database::get_main_table(TABLE_MAIN_SKILL); $this->table_skill = Database::get_main_table(TABLE_MAIN_SKILL);
$this->table_skill_rel_gradebook = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK); $this->table_skill_rel_gradebook = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK);
} }
/** /**
* Returns true if the gradebook is active and visible in a course, false * Returns true if the gradebook is active and visible in a course, false
* otherwise. * otherwise.
* *
* @param int $c_id Course integer id, defaults to the current course * @param int $c_id Course integer id, defaults to the current course
* @return boolean * @return boolean
*/ */
public static function is_active($c_id = null) { public static function is_active($c_id = null) {
$name = 'gradebook'; $name = 'gradebook';
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$sql = "SELECT * from $table WHERE variable='course_hide_tools' AND subkey='$name'"; $sql = "SELECT * from $table WHERE variable='course_hide_tools' AND subkey='$name'";
$setting = ResultSet::create($sql)->first(); $setting = ResultSet::create($sql)->first();
$setting = $setting ? $setting : array(); $setting = $setting ? $setting : array();
$inactive = isset($setting['selected_value']) && $setting['selected_value'] == 'true'; $inactive = isset($setting['selected_value']) && $setting['selected_value'] == 'true';
if ($inactive) { if ($inactive) {
return false; return false;
} }
$c_id = $c_id ? intval($c_id) : api_get_course_int_id(); $c_id = $c_id ? intval($c_id) : api_get_course_int_id();
$table = Database::get_course_table(TABLE_TOOL_LIST); $table = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT * from $table WHERE c_id = $c_id and name='$name'"; $sql = "SELECT * from $table WHERE c_id = $c_id and name='$name'";
$item = ResultSet::create($sql)->first(); $item = ResultSet::create($sql)->first();
if (empty($item)) { if (empty($item)) {
return true; return true;
} }
return $item['visibility'] == '1'; return $item['visibility'] == '1';
} }
public function get_all($options = array()) { public function get_all($options = array()) {
$gradebooks = parent::get_all($options); $gradebooks = parent::get_all($options);
foreach($gradebooks as &$gradebook) { foreach($gradebooks as &$gradebook) {
@ -57,78 +57,78 @@ class Gradebook extends Model {
} }
//$gradebook['name'] = $gradebook['course_code'] .' > '.$gradebook['name']; //$gradebook['name'] = $gradebook['course_code'] .' > '.$gradebook['name'];
} }
return $gradebooks; return $gradebooks;
} }
public function update($params) { public function update($params) {
return parent::update($params); return parent::update($params);
} }
public function update_skills_to_gradebook($gradebook_id, $skill_list) { public function update_skills_to_gradebook($gradebook_id, $skill_list) {
if (!empty($skill_list)) { if (!empty($skill_list)) {
//Cleaning skills //Cleaning skills
$skill_list = array_map('intval', $skill_list); $skill_list = array_map('intval', $skill_list);
$skill_list = array_filter($skill_list); $skill_list = array_filter($skill_list);
$skill_gradebook = new SkillRelGradebook(); $skill_gradebook = new SkillRelGradebook();
$skill_gradebooks_source = $skill_gradebook->get_all(array('where'=>array('gradebook_id = ?' =>$gradebook_id))); $skill_gradebooks_source = $skill_gradebook->get_all(array('where'=>array('gradebook_id = ?' =>$gradebook_id)));
$clean_gradebook = array(); $clean_gradebook = array();
if (!empty($skill_gradebooks_source)) { if (!empty($skill_gradebooks_source)) {
foreach($skill_gradebooks_source as $source) { foreach($skill_gradebooks_source as $source) {
$clean_gradebook[]= $source['skill_id']; $clean_gradebook[]= $source['skill_id'];
} }
} }
if (!empty($clean_gradebook)) { if (!empty($clean_gradebook)) {
$skill_to_remove = array_diff($clean_gradebook, $skill_list); $skill_to_remove = array_diff($clean_gradebook, $skill_list);
} }
foreach ($skill_list as $skill_id) { foreach ($skill_list as $skill_id) {
$params = array(); $params = array();
$params['gradebook_id'] = $gradebook_id; $params['gradebook_id'] = $gradebook_id;
$params['skill_id'] = $skill_id; $params['skill_id'] = $skill_id;
if (!$skill_gradebook->exists_gradebook_skill($gradebook_id, $skill_id)) { if (!$skill_gradebook->exists_gradebook_skill($gradebook_id, $skill_id)) {
$skill_gradebook->save($params); $skill_gradebook->save($params);
} }
} }
if (!empty($skill_to_remove)) { if (!empty($skill_to_remove)) {
foreach($skill_to_remove as $remove) { foreach($skill_to_remove as $remove) {
$skill_item = $skill_gradebook->get_skill_info($remove, $gradebook_id); $skill_item = $skill_gradebook->get_skill_info($remove, $gradebook_id);
$skill_gradebook->delete($skill_item['id']); $skill_gradebook->delete($skill_item['id']);
} }
} }
return true; return true;
} }
return false; return false;
} }
/** /**
* Returns a Form validator Obj * Returns a Form validator Obj
* @todo the form should be auto generated * @todo the form should be auto generated
* @param string url * @param string url
* @param string action add, edit * @param string action add, edit
* @return obj form validator obj * @return obj form validator obj
*/ */
public function show_skill_form($gradebook_id, $url, $header = null) { public function show_skill_form($gradebook_id, $url, $header = null) {
$form = new FormValidator('gradebook_add_skill', 'POST', $url); $form = new FormValidator('gradebook_add_skill', 'POST', $url);
// Settting the form elements // Setting the form elements
if (!isset($header)) { if (!isset($header)) {
$header = get_lang('Add'); $header = get_lang('Add');
} }
$form->addElement('header', '', $header); $form->addElement('header', '', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : ''; $id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id); $form->addElement('hidden', 'id', $id);
$skill = new Skill(); $skill = new Skill();
$skills = $skill->get_all(); $skills = $skill->get_all();
$clean_skill_list = array(); $clean_skill_list = array();
foreach ($skills as $skill) { foreach ($skills as $skill) {
$clean_skill_list[$skill['id']] = $skill['name']; $clean_skill_list[$skill['id']] = $skill['name'];
} }
$form->addElement('select', 'skill', get_lang('Skills'), $clean_skill_list, array('width'=>'450px', 'class'=>'chzn-select','multiple' => 'multiple')); $form->addElement('select', 'skill', get_lang('Skills'), $clean_skill_list, array('width'=>'450px', 'class'=>'chzn-select','multiple' => 'multiple'));
$selected_skills = self::get_skills_by_gradebook($gradebook_id); $selected_skills = self::get_skills_by_gradebook($gradebook_id);
$clean_selected_skills = array(); $clean_selected_skills = array();
if (!empty($selected_skills)) { if (!empty($selected_skills)) {
@ -136,29 +136,29 @@ class Gradebook extends Model {
$clean_selected_skills[] = $skill['id']; $clean_selected_skills[] = $skill['id'];
} }
} }
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"'); $form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
$form->setDefaults(array('skill'=>$clean_selected_skills)); $form->setDefaults(array('skill'=>$clean_selected_skills));
return $form; return $form;
} }
function get_skills_by_gradebook($gradebook_id) { function get_skills_by_gradebook($gradebook_id) {
$gradebook_id = intval($gradebook_id); $gradebook_id = intval($gradebook_id);
$sql = "SELECT skill.id, skill.name FROM {$this->table_skill} skill INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook $sql = "SELECT skill.id, skill.name FROM {$this->table_skill} skill INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook
ON skill.id = skill_rel_gradebook.skill_id ON skill.id = skill_rel_gradebook.skill_id
WHERE skill_rel_gradebook.gradebook_id = $gradebook_id"; WHERE skill_rel_gradebook.gradebook_id = $gradebook_id";
$result = Database::query($sql); $result = Database::query($sql);
$result = Database::store_result($result,'ASSOC'); $result = Database::store_result($result,'ASSOC');
return $result; return $result;
} }
/** /**
* Displays the title + grid * Displays the title + grid
*/ */
public function display() { public function display() {
// action links // action links
echo Display::grid_html('gradebooks'); echo Display::grid_html('gradebooks');
} }
} }

@ -171,7 +171,7 @@ class Promotion extends Model
$oFCKeditor->CreateHtml(); $oFCKeditor->CreateHtml();
$form = new FormValidator('promotion', 'post', $url); $form = new FormValidator('promotion', 'post', $url);
// Settting the form elements // Setting the form elements
$header = get_lang('Add'); $header = get_lang('Add');
if ($action == 'edit') { if ($action == 'edit') {
$header = get_lang('Modify'); $header = get_lang('Modify');

@ -123,7 +123,7 @@ class Timeline extends Model
{ {
$form = new FormValidator('item_form', 'post', $url); $form = new FormValidator('item_form', 'post', $url);
// Settting the form elements // Setting the form elements
$header = get_lang('Add'); $header = get_lang('Add');
if ($action == 'edit') { if ($action == 'edit') {
$header = get_lang('Modify'); $header = get_lang('Modify');

@ -72,7 +72,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
// Initiate the object // Initiate the object
$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action'])); $form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// Settting the form elements // Setting the form elements
$form->addElement('header', '', get_lang('NoteAddNew')); $form->addElement('header', '', get_lang('NoteAddNew'));
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '95', 'id' => 'note_title')); $form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '95', 'id' => 'note_title'));
//$form->applyFilter('note_title', 'html_filter'); //$form->applyFilter('note_title', 'html_filter');
@ -118,7 +118,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($_
// Initialize the object // Initialize the object
$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&notebook_id='.Security::remove_XSS($_GET['notebook_id'])); $form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&notebook_id='.Security::remove_XSS($_GET['notebook_id']));
// Settting the form elements // Setting the form elements
$form->addElement('header', '', get_lang('ModifyNote')); $form->addElement('header', '', get_lang('ModifyNote'));
$form->addElement('hidden', 'notebook_id'); $form->addElement('hidden', 'notebook_id');
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '100')); $form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '100'));

@ -118,7 +118,7 @@ $form = new FormValidator('survey', 'post', api_get_self().'?action='.Security::
$form->addElement('header', '', $tool_name); $form->addElement('header', '', $tool_name);
// Settting the form elements // Setting the form elements
if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) { if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) {
$form->addElement('hidden', 'survey_id'); $form->addElement('hidden', 'survey_id');
} }
@ -320,4 +320,4 @@ if ($form->validate()) {
} }
// Footer // Footer
Display :: display_footer(); Display :: display_footer();

@ -18,10 +18,10 @@
/** /**
* Code * Code
*/ */
define( "DIFF_EQUAL", "=" ); define("DIFF_EQUAL", "=");
define( "DIFF_ADDED", "+" ); define("DIFF_ADDED", "+");
define( "DIFF_DELETED", "-" ); define("DIFF_DELETED", "-");
define( "DIFF_MOVED", "M" ); define("DIFF_MOVED", "M");
/** /**
* Get difference between two strings * Get difference between two strings
@ -33,32 +33,33 @@ define( "DIFF_MOVED", "M" );
* (default 'format_line') * (default 'format_line')
* @return string formated diff output * @return string formated diff output
*/ */
function diff( $old, $new, $show_equals = false, $format_line_function = 'format_line' ) function diff(
{ $old,
$oldArr = str_split_on_new_line( $old ); $new,
$newArr = str_split_on_new_line( $new ); $show_equals = false,
$format_line_function = 'format_line'
) {
$oldArr = str_split_on_new_line($old);
$newArr = str_split_on_new_line($new);
$oldCount = count ( $oldArr ); $oldCount = count($oldArr);
$newCount = count ( $newArr ); $newCount = count($newArr);
$max = max( $oldCount, $newCount ); $max = max($oldCount, $newCount);
//get added and deleted lines //get added and deleted lines
$deleted = array_diff_assoc( $oldArr, $newArr ); $deleted = array_diff_assoc($oldArr, $newArr);
$added = array_diff_assoc( $newArr, $oldArr ); $added = array_diff_assoc($newArr, $oldArr);
$moved = array(); $moved = array();
foreach ( $added as $key => $candidate ) foreach ($added as $key => $candidate) {
{ foreach ($deleted as $index => $content) {
foreach ( $deleted as $index => $content ) if ($candidate == $content) {
{
if ( $candidate == $content )
{
$moved[$key] = $candidate; $moved[$key] = $candidate;
unset( $added[$key] ); unset($added[$key]);
unset( $deleted[$index] ); unset($deleted[$index]);
break; break;
} }
} }
@ -66,41 +67,29 @@ function diff( $old, $new, $show_equals = false, $format_line_function = 'format
$output = ''; $output = '';
for ( $i = 0; $i < $max; $i++ ) for ($i = 0; $i < $max; $i++) {
{
// line changed // line changed
if ( isset ( $deleted[$i] ) && isset( $added[$i] ) ) if (isset ($deleted[$i]) && isset($added[$i])) {
{ $output .= $format_line_function($i, DIFF_DELETED, $deleted[$i]);
$output .= $format_line_function( $i, DIFF_DELETED, $deleted[$i] ); $output .= $format_line_function($i, DIFF_ADDED, $added[$i]);
$output .= $format_line_function( $i, DIFF_ADDED, $added[$i] );
} } // line deleted
// line deleted elseif (isset ($deleted[$i]) && !isset ($added[$i])) {
elseif ( isset ( $deleted[$i] ) && ! isset ( $added[$i] ) ) $output .= $format_line_function($i, DIFF_DELETED, $deleted[$i]);
{
$output .= $format_line_function( $i, DIFF_DELETED, $deleted[$i] );
} } // line added
// line added elseif (isset ($added[$i]) && !isset ($deleted[$i])) {
elseif ( isset ( $added[$i] ) && ! isset ( $deleted[$i] ) ) $output .= $format_line_function($i, DIFF_ADDED, $added[$i]);
{
$output .= $format_line_function( $i, DIFF_ADDED, $added[$i] );
} } // line moved
// line moved elseif (isset ($moved[$i])) {
elseif ( isset ( $moved[$i] ) ) $output .= $format_line_function($i, DIFF_MOVED, $newArr[$i]);
{
$output .= $format_line_function( $i, DIFF_MOVED, $newArr[$i] );
} } // line unchanged
// line unchanged elseif ($show_equals) {
elseif ( $show_equals ) $output .= $format_line_function($i, DIFF_EQUAL, $newArr[$i]);
{
$output .= $format_line_function( $i, DIFF_EQUAL, $newArr[$i] );
} } else {
else
{
// skip // skip
} }
} }
@ -111,24 +100,17 @@ function diff( $old, $new, $show_equals = false, $format_line_function = 'format
/** /**
* Split strings on new line * Split strings on new line
*/ */
function str_split_on_new_line( $str ) function str_split_on_new_line($str)
{ {
$content = array(); $content = array();
if ( api_strpos( $str, "\r\n" ) !== false ) if (api_strpos($str, "\r\n") !== false) {
{ $content = explode("\r\n", $str);
$content = explode("\r\n", $str ); } elseif (api_strpos($str, "\n") !== false) {
} $content = explode("\n", $str);
elseif ( api_strpos( $str, "\n" ) !== false ) } elseif (api_strpos($str, "\r") !== false) {
{ $content = explode("\r", $str);
$content = explode( "\n", $str ); } else {
}
elseif ( api_strpos( $str, "\r" ) !== false )
{
$content = explode( "\r", $str );
}
else
{
$content[] = $str; $content[] = $str;
} }
@ -144,45 +126,31 @@ function str_split_on_new_line( $str )
* @param boolean skip_empty skip empty lines (default false) * @param boolean skip_empty skip empty lines (default false)
* @return string formated diff line * @return string formated diff line
*/ */
function format_line( $line, $type, $value, $skip_empty = false ) function format_line($line, $type, $value, $skip_empty = false)
{ {
if ( trim( $value ) == "" && $skip_empty ) if (trim($value) == "" && $skip_empty) {
{
return ""; return "";
} } elseif (trim($value) == "") {
elseif ( trim( $value ) == "" )
{
$value = '&nbsp;'; $value = '&nbsp;';
} }
switch ( $type ) switch ($type) {
{
case DIFF_EQUAL: case DIFF_EQUAL:
{ // return $line. ' : ' . ' = <span class="diffEqual" >' . $value . '</span><br />' . "\n" ;
// return $line. ' : ' . ' = <span class="diffEqual" >' . $value . '</span><br />' . "\n" ; return '<span class="diffEqual" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
return '<span class="diffEqual" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color
break; break;
}
case DIFF_MOVED: case DIFF_MOVED:
{
//return $line. ' : ' . ' M <span class="diffMoved" >' . $value . '</span><br />' . "\n" ; //juan carlos ra<EFBFBD>a la sustitye la inverior //return $line. ' : ' . ' M <span class="diffMoved" >' . $value . '</span><br />' . "\n" ; //juan carlos ra<EFBFBD>a la sustitye la inverior
return '<span class="diffMoved" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color return '<span class="diffMoved" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
break; break;
}
case DIFF_ADDED: case DIFF_ADDED:
{
//return $line . ' : ' . ' + <span class="diffAdded" >' . $value . '</span><br />' . "\n" ; //return $line . ' : ' . ' + <span class="diffAdded" >' . $value . '</span><br />' . "\n" ;
return '<span class="diffAdded" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color return '<span class="diffAdded" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
break; break;
}
case DIFF_DELETED: case DIFF_DELETED:
{
//return $line . ' : ' . ' - <span class="diffDeleted" >' . $value . '</span><br />' . "\n" ; //juan carlos ra<EFBFBD>a la sustitye la inverior //return $line . ' : ' . ' - <span class="diffDeleted" >' . $value . '</span><br />' . "\n" ; //juan carlos ra<EFBFBD>a la sustitye la inverior
return '<span class="diffDeleted" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color return '<span class="diffDeleted" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
break; break;
}
} }
} }
@ -190,46 +158,30 @@ function format_line( $line, $type, $value, $skip_empty = false )
* Table format line function * Table format line function
* @see format_line * @see format_line
*/ */
function format_table_line( $line, $type, $value, $skip_empty = false ) function format_table_line($line, $type, $value, $skip_empty = false)
{ {
if ( trim( $value ) == "" && $skip_empty ) if (trim($value) == "" && $skip_empty) {
{
return ""; return "";
} } elseif (trim($value) == "") {
elseif ( trim( $value ) == "" )
{
$value = '&nbsp;'; $value = '&nbsp;';
} }
switch ( $type ) switch ($type) {
{
case DIFF_EQUAL: case DIFF_EQUAL:
{
//return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;=</td><td><span class="diffEqual" >' . $value . '</span></td></tr>' . "\n"; //juan carlos comentado //return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;=</td><td><span class="diffEqual" >' . $value . '</span></td></tr>' . "\n"; //juan carlos comentado
return '<tr><td></td><td bgcolor="#FFFFFF">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente. return '<tr><td></td><td bgcolor="#FFFFFF">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
break; break;
}
case DIFF_MOVED: case DIFF_MOVED:
{ // return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;M</td><td><span class="diffMoved" >' . $value . '</span></td></tr>' . "\n" //juan carlos comenta
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;M</td><td><span class="diffMoved" >' . $value . '</span></td></tr>' . "\n" //juan carlos comenta
;
return '<tr><td></td><td bgcolor="#FFFFAA">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
return '<tr><td></td><td bgcolor="#FFFFAA">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
break; break;
}
case DIFF_ADDED: case DIFF_ADDED:
{ // return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;+</td><td><span class="diffAdded" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;+</td><td><span class="diffAdded" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado return '<tr><td></td><td bgcolor="#CCFFCC">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
return '<tr><td></td><td bgcolor="#CCFFCC">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
break; break;
}
case DIFF_DELETED: case DIFF_DELETED:
{ // return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;-</td><td><span class="diffDeleted" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;-</td><td><span class="diffDeleted" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado return '<tr><td></td><td bgcolor="#FFAAAA">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
return '<tr><td></td><td bgcolor="#FFAAAA">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
}
} }
} }

File diff suppressed because it is too large Load Diff

@ -36,7 +36,8 @@ function createreflink($testvalue)
* @return bool False if title is already taken * @return bool False if title is already taken
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
**/ **/
function checktitle($paramwk) { function checktitle($paramwk)
{
global $tbl_wiki; global $tbl_wiki;
global $groupfilter; global $groupfilter;
global $condition_session; global $condition_session;
@ -53,9 +54,8 @@ function checktitle($paramwk) {
// the value has not been found and is this available // the value has not been found and is this available
if ($numberofresults==0) { if ($numberofresults==0) {
return true; return true;
} } else {
else // the value has been found // the value has been found
{
return false; return false;
} }
} }
@ -66,14 +66,15 @@ function checktitle($paramwk) {
**/ **/
function links_to($input) function links_to($input)
{ {
$input_array=preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE); $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
$all_links = array(); $all_links = array();
foreach ($input_array as $key=>$value) { foreach ($input_array as $key=>$value) {
if ($input_array[$key-1]=='[[' AND $input_array[$key+1]==']]') { if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' &&
isset($input_array[$key+1]) && $input_array[$key+1] == ']]'
) {
if (api_strpos($value, "|") !== false) { if (api_strpos($value, "|") !== false) {
$full_link_array=explode("|", $value); $full_link_array=explode("|", $value);
$link=trim($full_link_array[0]); $link=trim($full_link_array[0]);
$title=trim($full_link_array[1]); $title=trim($full_link_array[1]);
} else { } else {
@ -82,10 +83,11 @@ function links_to($input)
} }
unset($input_array[$key-1]); unset($input_array[$key-1]);
unset($input_array[$key+1]); unset($input_array[$key+1]);
$all_links[]= Database::escape_string(str_replace(' ','_',$link)).' '; //replace blank spaces by _ within the links. But to remove links at the end add a blank space //replace blank spaces by _ within the links. But to remove links at the end add a blank space
$all_links[]= Database::escape_string(str_replace(' ','_',$link)).' ';
} }
} }
$output=implode($all_links); $output = implode($all_links);
return $output; return $output;
} }
@ -168,35 +170,15 @@ function detect_irc_link($input) {
function make_wiki_link_clickable($input) function make_wiki_link_clickable($input)
{ {
$groupId = api_get_group_id(); $groupId = api_get_group_id();
$input_array=preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE); //now doubles brackets //now doubles brackets
$input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($input_array as $key=>$value) { foreach ($input_array as $key => $value) {
//now doubles brackets //now doubles brackets
if ($input_array[$key-1] == '[[' AND $input_array[$key+1]==']]') { if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' AND
/////////// TODO: metawiki $input_array[$key+1] == ']]'
/* ) {
if ($session_id==0) // now full wikilink
{
if ($groupId==0)
{
$titleg_ex='';
}
else
{
$group_properties = GroupManager :: get_group_properties($groupId);
$group_name= $group_properties['name'];
$titleg_ex='<sup><img src="css/wgroup.gif" alt="('.$group_name.')" title="Link to Wikigroup:'.$group_name.'"/></sup>';
}
}
else
{
TODO:logic for sessions
}
*/
/////////
//now full wikilink
if (api_strpos($value, "|") !== false){ if (api_strpos($value, "|") !== false){
$full_link_array=explode("|", $value); $full_link_array=explode("|", $value);
$link=trim(strip_tags($full_link_array[0])); $link=trim(strip_tags($full_link_array[0]));
@ -275,19 +257,21 @@ function save_wiki()
$_clean['fprogress3']=Database::escape_string($_POST['fprogress3']); $_clean['fprogress3']=Database::escape_string($_POST['fprogress3']);
} }
if (Security::remove_XSS($_POST['initstartdate']==1)) { if (isset($_POST['initstartdate']) && $_POST['initstartdate'] == 1) {
$_clean['startdate_assig']=Database::escape_string(get_date_from_select('startdate_assig')); $_clean['startdate_assig']=Database::escape_string(get_date_from_select('startdate_assig'));
} else { } else {
$_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']); $_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']);
} }
if (Security::remove_XSS($_POST['initenddate']==1)) { if (isset($_POST['initenddate']) && $_POST['initenddate']==1) {
$_clean['enddate_assig']=Database::escape_string(get_date_from_select('enddate_assig')); $_clean['enddate_assig'] = Database::escape_string(get_date_from_select('enddate_assig'));
} else { } else {
$_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']); $_clean['enddate_assig'] = Database::escape_string($_POST['enddate_assig']);
} }
$_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']); if (isset($_POST['delayedsubmit'])) {
$_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']);
}
if (!empty($_POST['max_text']) || !empty($_POST['max_version'])) { if (!empty($_POST['max_text']) || !empty($_POST['max_version'])) {
$_clean['max_text'] =Database::escape_string($_POST['max_text']); $_clean['max_text'] =Database::escape_string($_POST['max_text']);
@ -389,8 +373,13 @@ function save_new_wiki() {
global $tbl_wiki_conf; global $tbl_wiki_conf;
global $page; global $page;
$_clean = array();
// cleaning the variables // cleaning the variables
$_clean['assignment']=Database::escape_string($_POST['assignment']); $_clean['assignment'] = null;
if (isset($_POST['assignment'])) {
$_clean['assignment'] = Database::escape_string($_POST['assignment']);
}
// session_id // session_id
$session_id = api_get_session_id(); $session_id = api_get_session_id();
@ -414,7 +403,7 @@ function save_new_wiki() {
return false; return false;
} }
if($_clean['assignment']==2) {//config by default for individual assignment (students) if ($_clean['assignment']==2) {//config by default for individual assignment (students)
//Identifies the user as a creator, not the teacher who created //Identifies the user as a creator, not the teacher who created
$_clean['user_id']=(int)Database::escape_string($assig_user_id); $_clean['user_id']=(int)Database::escape_string($assig_user_id);
$_clean['visibility']=0; $_clean['visibility']=0;
@ -501,31 +490,32 @@ function save_new_wiki() {
* @return html code * @return html code
**/ **/
function display_new_wiki_form() { function display_new_wiki_form() {
global $page; global $page;
?> ?>
<script> <script>
function CheckSend() function CheckSend()
{ {
if(document.form1.title.value == "") if (document.form1.title.value == "") {
{
alert("<?php echo get_lang('NoWikiPageTitle');?>"); alert("<?php echo get_lang('NoWikiPageTitle');?>");
document.form1.title.focus(); document.form1.title.focus();
return false; return false;
} }
return true; return true;
} }
function setFocus(){ function setFocus(){
$("#wiki_title").focus(); $("#wiki_title").focus();
} }
$(document).ready(function () { $(document).ready(function () {
setFocus(); setFocus();
}); });
</script> </script>
<?php <?php
$title = isset($_GET['title']) ? Security::remove_XSS($_GET['title']) : null;
//form //form
echo '<form name="form1" method="post" onsubmit="return CheckSend()" action="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&amp;title='.api_htmlentities(urlencode(strtolower(str_replace(' ','_',$page)))).'&group_id='.api_htmlentities($_GET['group_id']).'">'; echo '<form name="form1" method="post" onsubmit="return CheckSend()" action="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&amp;title='.api_htmlentities(urlencode(strtolower(str_replace(' ','_',$page)))).'&group_id='.api_htmlentities($_GET['group_id']).'">';
echo '<div id="wikititle" style="min-height:30px;">'; echo '<div id="wikititle" style="min-height:30px;">';
echo '<div style="width:70%;float:left;"><span class="form_required">*</span> '.get_lang('Title').': <input type="text" id="wiki_title" name="title" value="'.api_htmlentities($_GET['title']).'" size="40"></div>'; echo '<div style="width:70%;float:left;">
<span class="form_required">*</span> '.get_lang('Title').': <input type="text" id="wiki_title" name="title" value="'.$title.'" size="40"></div>';
if(api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { if(api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
echo'<a href="javascript://" onclick="advanced_parameters()" ><span id="plus_minus" style="float:right">&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'</span></a>'; echo'<a href="javascript://" onclick="advanced_parameters()" ><span id="plus_minus" style="float:right">&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'</span></a>';
@ -685,7 +675,8 @@ return true;
* @author Juan Carlos Raña Trabado * @author Juan Carlos Raña Trabado
* @return html code * @return html code
**/ **/
function display_wiki_entry($newtitle) { function display_wiki_entry($newtitle)
{
global $tbl_wiki, $tbl_wiki_conf, $groupfilter, $condition_session, $page; global $tbl_wiki, $tbl_wiki_conf, $groupfilter, $condition_session, $page;
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if ($newtitle) { if ($newtitle) {
@ -694,12 +685,11 @@ function display_wiki_entry($newtitle) {
$pageMIX=$page;//display current page $pageMIX=$page;//display current page
} }
$session_id=api_get_session_id(); $session_id = api_get_session_id();
$filter = null;
if ($_GET['view']) { if (isset($_GET['view']) && $_GET['view']) {
$_clean['view']=(int)Database::escape_string($_GET['view']); $_clean['view']=(int)Database::escape_string($_GET['view']);
$filter =' AND w.id="'.$_clean['view'].'"';
$filter=' AND w.id="'.$_clean['view'].'"';
} }
//first, check page visibility in the first page version //first, check page visibility in the first page version
@ -713,21 +703,21 @@ function display_wiki_entry($newtitle) {
$KeyVisibility=$row['visibility']; $KeyVisibility=$row['visibility'];
// second, show the last version // second, show the last version
$sql='SELECT * FROM '.$tbl_wiki.' w , '.$tbl_wiki_conf.' wc $sql = 'SELECT * FROM '.$tbl_wiki.' w , '.$tbl_wiki_conf.' wc
WHERE wc.c_id = '.$course_id.' AND WHERE
w.c_id = '.$course_id.' AND wc.c_id = '.$course_id.' AND
wc.page_id = w.page_id AND w.c_id = '.$course_id.' AND
w.reflink = "'.Database::escape_string($pageMIX).'" AND wc.page_id = w.page_id AND
w.session_id = '.$session_id.' AND w.reflink = "'.Database::escape_string($pageMIX).'" AND
w.'.$groupfilter.' '.$filter.' w.session_id = '.$session_id.' AND
ORDER BY id DESC'; w.'.$groupfilter.' '.$filter.'
ORDER BY id DESC';
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version $row = Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
//log users access to wiki (page_id) //log users access to wiki (page_id)
if (!empty($row['page_id'])) if (!empty($row['page_id'])) {
{
event_system(LOG_WIKI_ACCESS, LOG_WIKI_PAGE_ID, $row['page_id']); event_system(LOG_WIKI_ACCESS, LOG_WIKI_PAGE_ID, $row['page_id']);
} }
//update visits //update visits
@ -754,14 +744,15 @@ function display_wiki_entry($newtitle) {
} }
//assignment mode: identify page type //assignment mode: identify page type
$icon_assignment = null;
if ($row['assignment']==1) { if ($row['assignment']==1) {
$icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
} elseif($row['assignment']==2) { } elseif($row['assignment']==2) {
$icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
} }
//task mode //task mode
$icon_task = null;
if (!empty($row['task'])) { if (!empty($row['task'])) {
$icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL); $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
} }

Loading…
Cancel
Save