Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for Bug #1603 - Shortening URLs in Wiki pages

- Renamed wikipage in page (URL and variable)
- When groupid or userid is 0, it is not shown anymore (I hope I have changed all places)
  • Loading branch information...
commit 087fef3ed47a1d49c7289c146ad48715232d7368 1 parent 658724d
skaldrom authored
View
18 mod/wiki/admin.php
@@ -11,11 +11,11 @@
optional_variable($id); // Course Module ID, or
- optional_variable($wikipage); // Pagename
+ optional_variable($page, false); // Pagename
optional_variable($confirm, "");
optional_variable($action,""); // Admin Action
- optional_variable($userid); // User wiki.
- optional_variable($groupid); // Group wiki.
+ optional_variable($userid, 0); // User wiki.
+ optional_variable($groupid, 0); // Group wiki.
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
@@ -44,9 +44,9 @@
/// Build the ewsiki script constant
$ewbase = 'view.php?id='.$id;
- if (isset($userid)) $ewbase .= '&userid='.$userid;
- if (isset($groupid)) $ewbase .= '&groupid='.$groupid;
- $ewscript = $ewbase.'&wikipage=';
+ if (isset($userid) && $userid!=0) $ewbase .= '&userid='.$userid;
+ if (isset($groupid) && $groupid!=0) $ewbase .= '&groupid='.$groupid;
+ $ewscript = $ewbase.'&page=';
define("EWIKI_SCRIPT", $ewscript);
if($wiki->ewikiacceptbinary) {
define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
@@ -148,7 +148,7 @@
break;
}
add_to_log($course->id, "wiki", $action, "admin.php?action=$action&userid=$userid&groupid=$groupid&id=$id", $wiki->name.($addloginfo?": ".$addloginfo:""));
- $link="admin.php?action=$action&userid=$userid&groupid=$groupid&id=$id&wikipage=$wikipage";
+ $link="admin.php?action=$action".($userid?"&userid=".$userid:"").($groupid?"&groupid=".$groupid:"")."&id=$id&page=$page";
switch($action) {
case "removepages":
if($form->proceed) {
@@ -219,7 +219,7 @@
}
/// Actions which need a confirmation. If confirmed, do the action
- $redirect="view.php?userid=$userid&groupid=$groupid&id=$id&wikipage=$wikipage";
+ $redirect="view.php?".($groupid?"&groupid=".$groupid:"").($userid?"&userid=".$userid:"")."&id=$id&page=$page";
if($confirm && !$err) {
switch($action) {
case "removepages":
@@ -317,7 +317,7 @@
/// Administrative Links
echo '<td align="center">';
- wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $wikipage, $wiki->htmlmode!=2, $course);
+ wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $page, $wiki->htmlmode!=2, $course);
echo '</td>';
# if($wiki->htmlmode!=2) {
View
2  mod/wiki/filter.php
@@ -1 +1 @@
-<?PHP // $Id$
+<?PHP // $Id$
View
50 mod/wiki/lib.php
@@ -433,7 +433,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&userid='.$student->id.'&wikipage='.$pagename;
+ $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
$wikis[$key] = fullname($student).':'.$pagename;
}
}
@@ -451,7 +451,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&userid='.$student->id.'&wikipage='.$pagename;
+ $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
$wikis[$key] = fullname($student).':'.$pagename;
}
}
@@ -468,7 +468,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
else {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&userid='.$student->id.'&wikipage='.$pagename;
+ $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
$wikis[$key] = fullname($student).':'.$pagename;
}
}
@@ -480,7 +480,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$wiki_entries = get_records_sql($sql);
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
- $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&wikipage='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
$wikis[$key] = fullname($wiki_entry).':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
@@ -512,7 +512,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
if (($viewall === true) or ismember($viewall, $wiki_entry->userid)) {
- $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&wikipage='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
$wikis[$key] = fullname($wiki_entry).':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
@@ -543,7 +543,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&groupid='.$group->id.'&wikipage='.$pagename;
+ $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
$wikis[$key] = $group->name.':'.$pagename;
}
}
@@ -557,7 +557,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$wiki_entries = get_records_sql($sql);
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
- $key = $ME.'?id='.$id.'&groupid='.$wiki_entry->groupid.'&wikipage='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
$wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
@@ -583,7 +583,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&groupid='.$group->id.'&wikipage='.$pagename;
+ $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
$wikis[$key] = $group->name.':'.$pagename;
}
}
@@ -597,7 +597,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$wiki_entries = get_records_sql($sql);
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
- $key = $ME.'?id='.$id.'&groupid='.$wiki_entry->groupid.'&wikipage='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
$wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
@@ -626,7 +626,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
if (($viewall === true) or $viewall == $wiki_entry->groupid) {
- $key = $ME.'?id='.$id.'&groupid='.$wiki_entry->groupid.'&wikipage='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
$wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
@@ -924,7 +924,7 @@ function wiki_print_search_form($cmid, $search="", $userid, $groupid, $return=fa
$output = $output.($userid?"<input name=\"userid\" type=\"hidden\" value=\"$userid\">":"");
$output .= "<input name=\"q\" type=\"text\" size=\"20\" value=\"$search\">".' ';
$output .= "</font>";
- $output .= "<input name=\"wikipage\" type=\"hidden\" value=\"SearchPages\">";
+ $output .= "<input name=\"page\" type=\"hidden\" value=\"SearchPages\">";
$output .= "</form>";
if ($return) {
@@ -934,7 +934,7 @@ function wiki_print_search_form($cmid, $search="", $userid, $groupid, $return=fa
}
function wiki_print_wikilinks_block($cmid, $binary=false, $return=false) {
-/// Prints a lin-list of special wiki-pages
+/// Prints a link-list of special wiki-pages
global $CFG, $ewiki_title;
$links=array();
@@ -954,41 +954,41 @@ function wiki_print_wikilinks_block($cmid, $binary=false, $return=false) {
popup_form(EWIKI_SCRIPT, $links, "wikilinks", "", get_string("choosewikilinks", "wiki"), "", "", $return);
}
-function wiki_print_page_actions($cmid, $specialpages, $wikipage, $action, $binary=false, $canedit=true) {
+function wiki_print_page_actions($cmid, $specialpages, $page, $action, $binary=false, $canedit=true) {
/// Displays actions which can be performed on the page
$page=array();
// Edit this Page
if (in_array($action, array("edit", "links", "info", "attachments"))) {
- $page["view/$wikipage"]=get_string("viewpage","wiki");
+ $page["view/$page"]=get_string("viewpage","wiki");
}
- if ($canedit && !in_array($wikipage, $specialpages) && $action != "edit") {
- $page["edit/$wikipage"]=get_string("editthispage","wiki");
+ if ($canedit && !in_array($page, $specialpages) && $action != "edit") {
+ $page["edit/$page"]=get_string("editthispage","wiki");
}
if ($action != "links") {
- $page["links/$wikipage"]=get_string("backlinks","wiki");
+ $page["links/$page"]=get_string("backlinks","wiki");
}
- if ($canedit && !in_array($wikipage, $specialpages) && $action!="info") {
- $page["info/$wikipage"]=get_string("pageinfo","wiki");
+ if ($canedit && !in_array($page, $specialpages) && $action!="info") {
+ $page["info/$page"]=get_string("pageinfo","wiki");
}
- if($canedit && $binary && !in_array($wikipage, $specialpages) && $action != "attachments") {
- $page["attachments/$wikipage"]=get_string("attachments","wiki");
+ if($canedit && $binary && !in_array($page, $specialpages) && $action != "attachments") {
+ $page["attachments/$page"]=get_string("attachments","wiki");
}
popup_form(EWIKI_SCRIPT, $page, "wikiactions", "", get_string("action", "wiki"), "", "", false);
}
-function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $wikipage, $noeditor, $course) {
+function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $page, $noeditor, $course) {
/// Displays actions which can be performed on the page
global $ME;
/// Create the URL
$ewscript = 'admin.php?id='.$cmid;
- if (isset($userid)) $ewscript .= '&userid='.$userid;
- if (isset($groupid)) $ewscript .= '&groupid='.$groupid;
- if (isset($wikipage)) $ewscript .= '&wikipage='.$wikipage;
+ if (isset($userid) && $userid!=0) $ewscript .= '&userid='.$userid;
+ if (isset($groupid) && $groupid!=0) $ewscript .= '&groupid='.$groupid;
+ if (isset($page)) $ewscript .= '&page='.$page;
$ewscript.="&action=";
View
32 mod/wiki/view.php
@@ -11,13 +11,13 @@
optional_variable($ewiki_action,""); // Action on Wiki-Page
optional_variable($id); // Course Module ID, or
optional_variable($wid); // Wiki ID
- optional_variable($wikipage, false); // Wiki Page Name
+ optional_variable($page, false); // Wiki Page Name
optional_variable($q,""); // Search Context
- optional_variable($userid); // User wiki.
- optional_variable($groupid); // Group wiki.
+ optional_variable($userid, 0); // User wiki.
+ optional_variable($groupid, 0); // Group wiki.
optional_variable($canceledit,""); // Editing has been cancelled
if($canceledit) {
- @$wikipage=$ewiki_id;
+ @$page=$ewiki_id;
}
if ($id) {
@@ -71,9 +71,9 @@
define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
/// If the page has a ' in it, it may have slashes added to it. Remove them if it does.
- $wikipage = ($wikipage === false) ? stripslashes(EWIKI_PAGE_INDEX) : stripslashes($wikipage);
+ $page = ($page === false) ? stripslashes(EWIKI_PAGE_INDEX) : stripslashes($page);
-/// ### Prevent ewiki getting id as PageID...
+/// # Prevent ewiki getting id as PageID...
unset($_REQUEST["id"]);
unset($_GET["id"]);
unset($_POST["id"]);
@@ -97,9 +97,9 @@
/// Build the ewsiki script constant
/// ewbase will also be needed by EWIKI_SCRIPT_BINARY
$ewbase = $ME.'?id='.$moodleID;
- if (isset($userid)) $ewbase .= '&userid='.$userid;
- if (isset($groupid)) $ewbase .= '&groupid='.$groupid;
- $ewscript = $ewbase.'&wikipage=';
+ if (isset($userid) && $userid!=0) $ewbase .= '&userid='.$userid;
+ if (isset($groupid) && $groupid!=0) $ewbase .= '&groupid='.$groupid;
+ $ewscript = $ewbase.'&page=';
define("EWIKI_SCRIPT", $ewscript);
define("EWIKI_SCRIPT_URL", $ewscript);
@@ -193,7 +193,7 @@
global $ewiki_author, $USER;
$ewiki_author=fullname($USER);
- $content=ewiki_page($wikipage);
+ $content=ewiki_page($page);
$content2='';
### RESTORE ID from Moodle
@@ -207,13 +207,13 @@
}
- # Group wiki, ...: No wikipage and no ewiki_title
+ # Group wiki, ...: No page and no ewiki_title
if(!isset($ewiki_title)) {
$ewiki_title="";
}
/// Moodle Log
- add_to_log($course->id, "wiki", $ewiki_action, "view.php?id=$cm->id&groupid=$groupid&userid=$userid&wikipage=$wikipage", $wiki->name." ".$ewiki_title);
+ add_to_log($course->id, "wiki", $ewiki_action, "view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$page", $wiki->name." ".$ewiki_title);
/// Print the page header
@@ -309,9 +309,9 @@
}
foreach ($tabs as $tab) {
$tabname = get_string("tab$tab", 'wiki');
- if ($ewiki_action != "$tab" && !in_array($wikipage, $specialpages)) {
+ if ($ewiki_action != "$tab" && !in_array($page, $specialpages)) {
echo '<td class="generaltab" '.$tabstyle.' bgcolor="'.$THEME->cellheading.'">';
- echo '<a href="'.$ewbase.'&wikipage='.$tab.'/'.$ewiki_id.'">'.$tabname.'</a>';
+ echo '<a href="'.$ewbase.'&page='.$tab.'/'.$ewiki_id.'">'.$tabname.'</a>';
echo '</td>';
} else {
echo '<td class="generaltabselected" '.$tabstyle.' bgcolor="'.$THEME->cellcontent.'">'.$tabname.'</td>';
@@ -325,9 +325,9 @@
/// Don't filter any pages containing wiki actions (except view). A wiki page containing
/// actions will have the form [action]/[pagename]. If the '/' isn't there, or the action
/// is 'view', filter it. Also, if the page doesn't exist, it will default to 'edit'.
- $actions = explode('/', $wikipage);
+ $actions = explode('/', $page);
if ($ewiki_action == "edit" || ($actions !== false && count($actions) > 1 && $actions[0] != 'view') ||
- (count($actions) == 1 && !record_exists('wiki_pages', 'pagename', $wikipage, 'wiki', $wiki_entry->id))) {
+ (count($actions) == 1 && !record_exists('wiki_pages', 'pagename', $page, 'wiki', $wiki_entry->id))) {
print $content;
}
else {
Please sign in to comment.
Something went wrong with that request. Please try again.