]> git.mjollnir.org Git - moodle.git/commitdiff
Export mechanism and Administration restriction.
authorskaldrom <skaldrom>
Sun, 6 Jun 2004 12:07:28 +0000 (12:07 +0000)
committerskaldrom <skaldrom>
Sun, 6 Jun 2004 12:07:28 +0000 (12:07 +0000)
mod/wiki/admin.php
mod/wiki/ewiki/ewiki.php
mod/wiki/ewiki/plugins/aview/backlinks.php
mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php
mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php [new file with mode: 0644]
mod/wiki/ewiki/plugins/moodle/sitemap.php
mod/wiki/ewikimoodlelib.php
mod/wiki/lib.php
mod/wiki/view.php

index 7ba5831b76322fa9b111459ca6d989a54aa2c60a..23644417352be8a9af350f4a6222a379e0fa26ec 100644 (file)
     if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false || wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course) === false) {
       error(get_string("notadministratewiki","wiki"));
     }
-        
+
+    # Check for dangerous events (hacking) !
+    if(in_array($action,array("removepages","strippages","revertpages"))) {
+      if($wiki->wtype!="student" || !isteacher($course->id)) {
+        error("Hack attack detected !");
+      }          
+    }
+            
     /// The wiki_entry->pagename is set to the specified value of the wiki,
     /// or the default value in the 'lang' file if the specified value was empty.
     define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
     
         /// Administrative Links       
         echo '<td align="center">';          
-        wiki_print_administration_actions($cm->id, $userid, $groupid, $wikipage, $wiki->htmlmode!=2);
+        wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $wikipage, $wiki->htmlmode!=2, $course);
         echo '</td>';
         
 #        if($wiki->htmlmode!=2) {
index 717d5062d9686a202dfd2be9d240c7437e20f9f6..631e6c11ea5fc86ae17f95f0562641657ae884ef 100644 (file)
        #-- init stuff, autostarted parts
        ksort($ewiki_plugins["init"]);
        if ($pf_a = $ewiki_plugins["init"]) foreach ($pf_a as $pf) {
+           // Binary Handling starts here
+           if(headers_sent($file,$line)) {
+             print $file.":".$line."<br>";
+           }
            $pf($GLOBALS);
         }
        unset($ewiki_plugins["init"]);
@@ -886,7 +890,7 @@ function ewiki_script_url() {
       return(NULL);   #-- could not guess it
    }
  
-   $url = "http://" . $_SERVER["SERVER_NAME"] . $url;
+   #$url = "http://" . $_SERVER["SERVER_NAME"] . $url;
    return($url);
 }
 
@@ -3469,4 +3473,4 @@ function ewiki_database_mysql($action, &$args, $sw1, $sw2) {
 
 
 
-</script>
+</script>
\ No newline at end of file
index 7f90f3a13d5d75ce51d31207c0494ce8aecc73f8..9977548f1b8ece6b3bfb72e1f482f1b895a18717 100755 (executable)
@@ -19,6 +19,4 @@ function ewiki_view_append_backlinks($id, $data, $action) {
     
     return($o);
 }
-
-
-?> 
\ No newline at end of file
+?>
\ No newline at end of file
index ab349b8c4bddf5b47e190d6b4e878c086b2cb12b..ec70c5d09ae9fc8d928fb50415d6c0a78898d296 100644 (file)
@@ -47,9 +47,9 @@ function moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid) {
     
     $dir=make_upload_directory("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/".$meta["section"]);
     if(substr($id, 0, strlen(EWIKI_IDF_INTERNAL))!=EWIKI_IDF_INTERNAL) {
-      error("Binary entry does not start with ".EWIKI_IDF_INTERNAL.":::".substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
+      error("Binary entry does not start with ".EWIKI_IDF_INTERNAL.substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
     }
-    $id = substr($id,11);
+    $id = substr($id,strlen(EWIKI_IDF_INTERNAL));
     $id = clean_filename($id);
   
     return "$dir/$id";
diff --git a/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php b/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php
new file mode 100644 (file)
index 0000000..0885e2e
--- /dev/null
@@ -0,0 +1,453 @@
+<?php
+# ToDo: Binary Content
+#       Binary Linking
+/*
+   Allows to download a tarball including all WikiPages and images that
+   currently are in the database.
+*/
+
+
+#-- text
+$ewiki_t["en"]["WIKIEXPORTCOMMENT"] = "Here you can tailor your WikiDump to your needs.  When you are ready, click the \"Download\" button.";
+$ewiki_t["en"]["DOWNLOAD_ARCHIVE"] = "Download";
+
+#define("EWIKI_WIKIDUMP_ARCNAME", "WikiDump_");
+#define("EWIKI_WIKIDUMP_DEFAULTTYPE", "TAR");
+#define("EWIKI_WIKIDUMP_MAXLEVEL", 1);
+define('EWIKI_DUMP_FILENAME_REGEX',"/\W/");
+
+#-- glue
+#if((function_exists(gzcompress) && EWIKI_WIKIDUMP_DEFAULTTYPE=="ZIP") || EWIKI_WIKIDUMP_DEFAULTTYPE=="TAR"){
+  $ewiki_plugins["page"]["WikiExport"] = "moodle_ewiki_page_wiki_dump";
+  #$ewiki_plugins["action"]['wikidump'] = "moodle_ewiki_page_wiki_dump";
+#}
+
+$ewiki_t["c"]["EWIKIDUMPCSS"] = '
+  <style  TYPE="text/css">
+  <!--
+  body {
+    background-color:#eeeeff;
+    padding:2px;
+  }    
+  
+  H2 {
+    background:#000000;
+    color:#ffffff;
+    border:1px solid #000000;
+  }
+  -->
+  </style>
+  ';  
+  
+
+function moodle_ewiki_page_wiki_dump($id=0, $data=0, $action=0) {
+  global $userid, $groupid, $cm, $wikipage, $wiki, $course, $CFG;
+  #-- return legacy page
+  $cont = true;
+  if (!empty($_REQUEST["wikiexport"])) {
+    $binaries=$_REQUEST["exportbinaries"];
+    if(!$wiki->ewikiacceptbinary) {
+      $binaries=0;
+    }
+    $exportformats=$_REQUEST["exportformats"];
+    if($wiki->htmlmode==2) {
+      $exportformats=1;
+    }
+    $cont=ewiki_page_wiki_dump_send($binaries, 
+                                $exportformats, 
+                                $_REQUEST["withvirtualpages"], 
+                                $_REQUEST["exportdestinations"]);
+  }  
+  if($cont===false) return;
+    
+  $url = ewiki_script("", "WikiExport");
+  $ret  = ewiki_make_title($id, $id, 2);
+  $ret .= ($cont&&$cont!==true)?$cont."<br><br>\n":"";
+  $ret .= get_string("wikiexportcomment","wiki");
+  $ret .= "<br><br>\n".
+    '<FORM name="form" method="post" action="'.$url.'">'."\n".
+    '<INPUT TYPE="HIDDEN" NAME="userid" VALUE="'.$userid.'">'."\n".
+    '<INPUT TYPE="HIDDEN" NAME="groupid" VALUE="'.$groupid.'">'."\n".
+    '<INPUT TYPE="HIDDEN" NAME="id" VALUE="'.$cm->id.'">'."\n".
+    '<INPUT TYPE="HIDDEN" NAME="wikipage" VALUE="'.$wikipage.'">'."\n".
+    "<CENTER>\n";
+  
+  // Export binaroes too ?
+  if(!$wiki->ewikiacceptbinary) {
+    $ret.='<INPUT TYPE="HIDDEN" NAME="exportbinaries" VALUE="0">'.$exportdestinations[0]."\n";
+  } else {
+    $ret.='<INPUT TYPE="HIDDEN" NAME="exportbinaries" VALUE="0">'."\n";
+  }
+  $ret.="<TABLE cellpadding=5>\n";
+  if($wiki->ewikiacceptbinary) {
+    $ret.="  <TR valign=top>\n".
+        '    <TD align=right>'.get_string("withbinaries","wiki").":</TD>\n".
+        "    <TD>\n".
+        '      <input type="checkbox" name="exportbinaries" value="1"'.($_REQUEST["exportbinaries"]==1?" checked":"").">\n".
+        "    </TD>\n".
+        "  </TR>\n";
+  }
+  $ret.="  <TR valign=top>\n".
+      '    <TD align=right>'.get_string("withvirtualpages","wiki").":</TD>\n".
+      "    <TD>\n".
+      '      <input type="checkbox" name="withvirtualpages" value="1"'.($_REQUEST["withvirtualpages"]==1?" checked":"").">\n".
+      "    </TD>\n".
+      "  </TR>\n";
+  $exportformats=array( "0" => get_string("plaintext","wiki") , "1" => get_string("html","wiki"));
+  /// Formats
+  $ret.="  <TR valign=top>\n".
+        '    <TD align=right>'.get_string("exportformats","wiki").":</TD>\n".
+        "    <TD>\n";
+  if($wiki->htmlmode!=2) {
+    $ret.= choose_from_menu($exportformats, "exportformats", $_REQUEST["exportformats"], "", "", "", true)."\n";
+  } else {
+    $ret.= '<INPUT TYPE="HIDDEN" NAME="exportformats" VALUE="1">'.
+           get_string("html","wiki");
+  }
+  $ret.="    </TD>\n".
+        "  </TR>\n";
+  /// Destination
+  $exportdestinations=array("0" => get_string("downloadaszip","wiki"));
+  if(isteacher($course->id)) {
+    // Get Directory List
+    $rawdirs = get_directory_list("$CFG->dataroot/$course->id", 'moddata', true, true, false);
+    
+    foreach ($rawdirs as $rawdir) {
+      $exportdestinations[$rawdir] = get_string("moduledirectory","wiki").": ".$rawdir;
+    }
+  }
+  
+  $ret.="  <TR valign=top>\n".
+        '    <TD align=right>'.get_string("exportto","wiki").":</TD>\n".
+        "    <TD>\n";
+  if(count($exportdestinations)==1) {
+    $ret.='<INPUT TYPE="HIDDEN" NAME="exportdestinations" VALUE="0">'.$exportdestinations[0]."\n";
+  } else {
+    $ret.=choose_from_menu($exportdestinations, "exportdestinations", $_REQUEST["exportdestinations"], "", "", "", true)."\n";
+  }
+  $ret.="    </TD>\n".
+      "  </TR>\n".      
+      "</TABLE>\n".
+      '  <input type="submit" name="wikiexport" value= "'.get_string("export","wiki").'">'."\n".
+      "</CENTER>\n";
+      "</FORM>\n";
+  return $ret;
+}
+
+function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvirtualpages=0, $exportdestinations=0) {
+  global $ewiki_config, $wiki, $ewiki_plugins, $wiki_entry, $course, $CFG, $ewiki_t, $userid, $groupid;
+  
+  $filestozip=array();
+  #-- disable protected email
+  foreach($ewiki_plugins["link_url"] as $key => $linkplugin){
+    if($linkplugin == "ewiki_email_protect_link"){
+      unset($ewiki_plugins["link_url"][$key]);
+    }
+  }
+
+  /// HTML-Export
+  if($exportformats==1) {
+    #-- if exportformats is html
+    $HTML_TEMPLATE = '<html>
+      <head>'.$ewiki_t["c"]["EWIKIDUMPCSS"].'
+      <title>$title</title>
+      </head>
+      <body bgcolor="#ffffff";>
+      <div id="PageText">
+      <h2>$title</h2>
+      $content
+      </div>
+      </body>
+      </html>';
+  
+    #-- reconfigure ewiki_format() to generate offline pages and files
+    $html_ext = ".html";
+    $ewiki_config["script"] = "%s$html_ext";
+    $ewiki_config["script_binary"] = "%s";
+  }
+  
+  // Export Virtual pages special
+  $a_virtual = array_keys($ewiki_plugins["page"]);
+
+  #-- get all pages / binary files
+  $a_validpages = ewiki_valid_pages(1, $withvirtualpages);
+  $a_pagelist = ewiki_sitemap_create($wiki_entry->pagename, $a_validpages, 100, 1);
+  
+  # Add linked binary files to pagelist
+  foreach($a_pagelist as $key => $value) {
+    if(is_array($a_validpages[$value]["refs"])){
+      foreach($a_validpages[$value]["refs"] as $refs){
+        if($a_validpages[$refs]["type"]=="image" || $a_validpages[$refs]["type"]=="file"){
+          $a_pagelist[]=$refs;
+        }
+      }
+    }
+  }
+
+  # Adjust links to binary files
+  foreach($a_pagelist as $key => $value){
+    if($a_validpages[$value]["type"]=="image"){
+      $a_images[]=urlencode($value);
+      $a_rimages[]=urlencode(preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", $value));
+      unset($a_validpages[$value]);
+    } 
+    if($a_validpages[$value]["type"]=="file") {
+      $a_images[]=urlencode($value);
+      $a_rimages[]=clean_filename(substr($value,strlen(EWIKI_IDF_INTERNAL)));
+      $a_images[]=$value;
+      $a_rimages[]=clean_filename(substr($value,strlen(EWIKI_IDF_INTERNAL)));
+      unset($a_validpages[$value]);
+    }
+  }
+
+  # Remove binaries from a_validpages and add to a_pagelist  
+  foreach($a_validpages as $key => $value){
+    if($a_validpages[$key]["type"]=="image" || $a_validpages[$key]["type"]=="file"){
+      $a_pagelist[]=$key;
+      unset($a_validpages[$key]);
+    }    
+  }  
+  
+  #print "<pre>"; print_r($a_validpages); print "</pre>";
+  #print "<hr><pre>"; print_r($a_pagelist); print "</pre>";
+
+  $a_sitemap = ewiki_sitemap_create($wiki_entry->pagename, $a_validpages, 99, 0);
+  if ($a_pagelist) {
+    #-- create new zip file
+    #if($arctype == "ZIP"){
+    #  $archivename=EWIKI_WIKIDUMP_ARCNAME."$rootid.zip";
+    #  $archive = new ewiki_virtual_zip();
+    #} elseif ($arctype == "TAR") {
+    #  $archivename=EWIKI_WIKIDUMP_ARCNAME."$rootid.tar";
+    #  $archive = new ewiki_virtual_tarball();
+    #} else {
+    #  die();
+    #}
+    
+    /// Create/Set Directory
+    $wname=clean_filename($wiki->name);
+    if($exportdestinations) {
+      if(isteacher($course->id)) {
+        $exportdir=$CFG->dataroot."/".$course->id."/".$exportdestinations;
+      } else {
+        die("Hack attack identified !!!");
+      }
+    } else {
+        $exportbasedir=tempnam("/tmp","WIKIEXPORT");
+        @unlink($exportbasedir);
+        @mkdir($exportbasedir);
+        /// maybe we need to check the name here...?
+        $exportdir=$exportbasedir."/".$wname;
+        @mkdir($exportdir);
+        if(!is_dir($exportdir)) {
+            error("Cannot create temporary directory $exportdir !");
+        }
+    }
+    
+    $a_pagelist = array_unique($a_pagelist);
+    
+    
+    #-- convert all pages
+    foreach($a_pagelist as $pagename){
+      
+      if ((!in_array($pagename, $a_virtual))) {
+        $id = $pagename;
+        #-- not a virtual page
+        $row = ewiki_database("GET", array("id"=>$pagename));
+        $content = "";
+      } elseif($withvirtualpages) {
+        $id = $pagename;
+        #-- is a virtual page
+        $pf = $ewiki_plugins["page"][$id];
+        $content = $pf($id, $content, "view");
+        if ($exportformats==1) {
+          $content = str_replace('$content', $content, str_replace('$title', $id, $HTML_TEMPLATE));
+        }
+        $fn = urlencode($id);
+        $fn = preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", $fn);
+        $fn = $fn.$html_ext;
+      } else {
+        continue;
+      }
+      
+      if (empty($content)){
+        switch ($row["flags"] & EWIKI_DB_F_TYPE) {
+          case (EWIKI_DB_F_TEXT):
+            #print "<pre>"; print_r($row[content]); print "\n-------------</pre>";
+            if($exportformats==1) {/// HTML-Export
+              $content = ewiki_format($row["content"]);
+            } else {
+              $content = $row["content"];
+            }
+            
+            # Binary files link adjustment when html
+            if($exportformats==1) {
+              $content = str_replace($a_images, $a_rimages, $content);
+            }
+            $fn = preg_replace(EWIKI_DUMP_FILENAME_REGEX, "",  urlencode($id));
+            $fn = $fn.$html_ext;
+            if($exportformats==1) {/// HTML-Export
+              $content =  str_replace('$content', $content, str_replace('$title', $id, $HTML_TEMPLATE));
+            }
+            break;
+          case (EWIKI_DB_F_BINARY):            
+            #print "Binary: $row[id]<br>";
+            if (($row["meta"]["class"]=="image" || $row["meta"]["class"]=="file") && ($exportbinaries)) {
+              # Copy files to the appropriate directory              
+              $fn= moodle_binary_get_path($id, $row["meta"], $course, $wiki, $userid, $groupid);
+              $destfn=clean_filename(substr($id,strlen(EWIKI_IDF_INTERNAL)));
+              $dest="$exportdir/".$destfn;
+              if(!copy($fn,$dest)) {
+                error("Cannot copy $fn to $dest.");
+              }
+                          
+              #$fn = urlencode(preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", $id));
+              #$content = &$row["content"];
+              $filestozip[]=$exportdir."/".$destfn;
+              continue (2);
+            }
+            else {
+              #-- php considers switch statements as loops so continue 2 is needed to 
+              #-- hit the end of the for loop 
+              continue(2);
+            }
+            break;
+          
+          default:
+            # don't want it
+            continue(2);
+        }
+      }
+  
+      # Do not translate links when wiki already in pure html - mode
+      if($wiki->htmlmode!=2) {
+          $content=preg_replace_callback(
+            '/(<a href=")(.*?)(\.html">)/',
+            create_function(
+            // single quotes are essential here,
+            // or alternative escape all $ as \$
+            '$matches',
+            'return($matches[1].preg_replace(EWIKI_DUMP_FILENAME_REGEX,"",$matches[2]).$matches[3]);'
+            ),
+            $content
+            );
+      }
+      #-- add file
+      // Let's make sure the file exists and is writable first.
+      if (!$handle = fopen($exportdir."/".$fn, 'w')) {
+        error("Cannot open file ($exportdir/$fn)");
+      }
+      
+      // Write $content to our opened file.
+      if (fwrite($handle, $content) === FALSE) {
+        error("Cannot write to file ($exportdir/$fn)");
+      }
+
+      fclose($handle);
+      $filestozip[]=$exportdir."/".$fn;
+      #$archive->add($content, $fn, array(
+      #  "mtime" => $row["lastmodified"],
+      #  "uname" => "ewiki",
+      #  "mode" => 0664 | (($row["flags"]&EWIKI_DB_F_WRITEABLE)?0002:0000),
+      #  ), $complevel);
+    }
+    
+    #-- create index page
+    /// HTML-Export
+    if($exportformats==1) {
+        $timer=array();
+        $level=-1;
+        $fordump=1;
+        $str_formatted="<ul>\n<li><a href=\"".($wiki_entry->pagename).$html_ext."\">".($wiki_entry->pagename)."</a></li>";
+        $fin_level=format_sitemap($a_sitemap, ($wiki_entry->pagename), $str_formatted, $level, $timer, $fordump);
+        $str_formatted.="</ul>".str_pad("", $fin_level*6, "</ul>\n");
+        $str_formatted=preg_replace_callback(
+            '/(<a href=")(.*?)(\.html">)/',
+            create_function(
+              // single quotes are essential here,
+              // or alternative escape all $ as \$
+              '$matches',
+              'return($matches[1].preg_replace(EWIKI_DUMP_FILENAME_REGEX,"",$matches[2]).$matches[3]);'
+            ),
+            $str_formatted
+          );
+        $str_formatted = str_replace('$content', $str_formatted, str_replace('$title', get_string("index","wiki"), $HTML_TEMPLATE));
+        #-- add file
+        // Let's make sure the file exists and is writable first.
+        $indexname="index".$html_ext;
+        if (!$handle = fopen($exportdir."/".$indexname, 'w')) {
+          error("Cannot open file ($exportdir/$indexname)");
+        }
+        
+        // Write $somecontent to our opened file.
+        if (fwrite($handle, $str_formatted) === FALSE) {
+          error("Cannot write to file ($exportdir/$indexname)");
+        }
+  
+        fclose($handle);
+        $filestozip[]=$exportdir."/".$indexname;
+  
+    #-- add index page
+#    $archive->add($str_formatted, "Index_$rootid".$html_ext, array(
+#      "mtime" => $row["lastmodified"],
+#      "uname" => "ewiki",
+#      "mode" => 0664 | (($row["flags"]&EWIKI_DB_F_WRITEABLE)?0002:0000),
+#      ), $complevel);
+    }     
+        
+    if(!$exportdestinations) {
+      $archivename=$wname.".zip";
+      if (empty($CFG->zip)) {    // Use built-in php-based zip function
+        include_once("$CFG->libdir/pclzip/pclzip.lib.php");
+        $archive = new PclZip("$exportbasedir/$archivename");
+        if (($list = $archive->create($filestozip,'',"$exportbasedir/")) == 0) {
+            error($archive->errorInfo(true));
+        }
+      } else {                   // Use external zip program
+        $files = "";
+        foreach ($filestozip as $file) {
+            $files .= $wname."/".basename($file);
+            $files .= " ";
+        }
+        $command = "cd $exportbasedir ; $CFG->zip -r $archivename $files";
+        Exec($command);
+      }
+
+      #-- Headers
+      Header("Content-type: application/zip");
+      Header("Content-disposition: attachment; filename=$archivename");
+      Header("Cache-control: private");
+      Header("Original-Filename: $archivename");    
+      
+      if(!@readfile("$exportbasedir/$archivename")) {
+        error("Cannot read $exportbasedir/$archivename");
+      }
+      if(!deldir($exportbasedir)) {
+        error("Cannot delete $exportbasedir");
+      }
+      return false;
+    } else {
+       return get_string("exportsuccessful","wiki")."<br>";      
+    }
+  }
+}
+
+function deldir($dir)
+{
+  $handle = opendir($dir);
+  while (false!==($FolderOrFile = readdir($handle)))
+  {
+     if($FolderOrFile != "." && $FolderOrFile != "..")
+     { 
+       if(is_dir("$dir/$FolderOrFile"))
+       { deldir("$dir/$FolderOrFile"); }  // recursive
+       else
+       { unlink("$dir/$FolderOrFile"); }
+     } 
+  }
+  closedir($handle);
+  if(rmdir($dir))
+  { $success = true; }
+  return $success; 
+}
+?>
\ No newline at end of file
index 8dc0df019da9209cecbef3b5b2f34a728d54ff31..730d88e0730b94535911acd1c15f321c0b9f03af 100644 (file)
@@ -100,15 +100,18 @@ function ewiki_valid_pages($bool_allowimages=0, $virtual_pages=0){
     if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $str_null, "view")) {
       continue;
     }   
-    if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT || ($bool_allowimages ? $row["meta"]["class"]=="image" : 0)) {
+    
+    $isbinary= ($row["meta"]["class"]=="image"||$row["meta"]["class"]=="file")?true:false;
+    
+    if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT || ($bool_allowimages ? $isbinary : 0)) {
       $temp_refs=explode("\n",$row["refs"]);
       foreach($temp_refs as $key => $value) {
         if(empty($value)) {
           unset($temp_refs[$key]);
         }
       }
-      if($row["meta"]["class"]=="image"){
-        $a_validpages[$row["id"]]=$temp_array=array("refs" => $temp_refs, "type" => "image", "touched" => FALSE);
+      if($isbinary){
+        $a_validpages[$row["id"]]=$temp_array=array("refs" => $temp_refs, "type" => $row["meta"]["class"], "touched" => FALSE);
       } else {
         $a_validpages[$row["id"]]=$temp_array=array("refs" => $temp_refs, "type" => "page", "touched" => FALSE);
       }
@@ -209,7 +212,7 @@ function ewiki_sitemap_create($str_rootid, $a_validpages, $i_maxdepth, $i_flatma
   //list all of the children of the root
   ewiki_page_listallchildren($str_rootid, $a_children, $a_sitemap, $a_validpages, $i_depth, $i_maxdepth, $i_flatmap);
   $i_depth++;    
-  
+    
   if($a_children){
     end($a_children);
     $str_nextlevel=key($a_children);
@@ -236,4 +239,4 @@ function ewiki_sitemap_create($str_rootid, $a_validpages, $i_maxdepth, $i_flatma
 
   return $a_sitemap;
 }
-?>
+?>
\ No newline at end of file
index 3f7a57adccecf548e45911068c8e8ea645ee89f0..4d5e54dff95e3f6509b2d0c54ea1465b57d7d2e9 100644 (file)
@@ -201,6 +201,9 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
          #   }
          #}
          #print "<pre>"; print_r($result); print "</pre>";
+         if(!$result) {
+           $result=array();
+         }
          while(list($key, $val) = each($result)) {
             $row=get_object_vars($val);
             $i = EWIKI_CASE_INSENSITIVE ? strtolower($row["id"]) : $row["id"];
index ac0f68b1a9938604c041d1a57c1e9262e903f2e1..2950b21b12bcbc667d3d1f7949abccca37ff7015 100644 (file)
@@ -868,7 +868,7 @@ function wiki_get_owner(&$wiki_entry) {
         $owner = $course->shortname;
     }
     else {
-        $owner = '- unknown -';
+        $owner = '- '.get_string("ownerunknown","wiki").' -';
     }
     return $owner;
 }
@@ -907,6 +907,7 @@ function wiki_print_wikilinks_block($cmid, $binary=false, $return=false) {
    $links["UpdatedPages"]=get_string("updatedpages", "wiki");
    $links["OrphanedPages"]=get_string("orphanedpages", "wiki");
    $links["WantedPages"]=get_string("wantedpages", "wiki");
+   $links["WikiExport"]=get_string("wikiexport", "wiki");
    if($binary) {
      $links["FileDownload"]=get_string("filedownload", "wiki");
    }
@@ -938,7 +939,7 @@ function wiki_print_page_actions($cmid, $specialpages, $wikipage, $action, $bina
   popup_form(EWIKI_SCRIPT, $page, "wikiactions", "", get_string("action", "wiki"), "", "", false);   
 }
 
-function wiki_print_administration_actions($cmid, $userid, $groupid, $wikipage, $noeditor) {
+function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $wikipage, $noeditor, $course) {
 /// Displays actions which can be performed on the page
   global $ME;        
 
@@ -952,12 +953,14 @@ function wiki_print_administration_actions($cmid, $userid, $groupid, $wikipage,
 
   
   $action=array(
-            "removepages"  => get_string("removepages", "wiki"),
-            "strippages"  => get_string("strippages", "wiki"),
             "setpageflags" => get_string("setpageflags", "wiki"),
-            "revertpages" => get_string("revertpages", "wiki"),
           );
   // We cannot do certain things if html is used !
+  if($wiki->wtype=="student" || isteacher($course->id)) {          
+    $action["removepages"]  = get_string("removepages", "wiki");
+    $action["strippages"]  = get_string("strippages", "wiki");
+    $action["revertpages"] = get_string("revertpages", "wiki");
+  }
   if($noeditor) {
     $action["checklinks"]=get_string("checklinks", "wiki");
   }
@@ -1258,7 +1261,7 @@ function wiki_admin_checklinks($pagetocheck) {
      $get = ewiki_database("GET", array("id" => $pagetocheck));
      $content = $get["content"];
      
-     preg_match_all('_(http://[^\s"\'<>#,;]+[^\s"\'<>#,;.])_', $content, $links);
+     preg_match_all('_(http.?://[^\s"\'<>#,;]+[^\s"\'<>#,;.])_', $content, $links);
      $badlinks = array();
      if(!$links[1]) {
        $ret = get_string("nolinksfound","wiki")."<br><br>";
index ab465748c4777ea880a3232f226e52105d8ca28f..84d93b8e540165c3394e79ded940fcf6844b9338 100644 (file)
         include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_highlight.php");
         include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/f_fixhtml.php");
         include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/sitemap.php");
+        include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php");
         include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/aview/backlinks.php");
         #include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/markup/css.php");
         include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/markup/footnotes.php");
     }
 
     if ($wiki_entry) {
-        $specialpages=array("SiteMap", "SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
+        $specialpages=array("WikiExport", "SiteMap", "SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
     /// Page Actions
         echo '<table border="0" width="100%">';
         echo '<tr>';
         /// Administrative Links
         if($canedit) {
           echo '<td align="center">';          
-          wiki_print_administration_actions($cm->id, $userid, $groupid, $ewiki_title, $wiki->htmlmode!=2);
+          wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $ewiki_title, $wiki->htmlmode!=2, $course);
           echo '</td>';
         }