Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-21994

NWIKI / DFWIKI new wiki_print_recent_activity() function

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: None
    • Component/s: Wiki (2.x)
    • Labels:
      None
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      implementation of wiki_print_recent_activity() function for the NWiki (dfwiki) module
      used by "recent activity" block.

      /**

      • Given a course and a time, this module should find recent activity
      • that has occurred in newmodule activities and print it out.
      • Return true if there was output, or false is there was none.
        *
      • @param object $course
      • @param bool $isteacher
      • @param int $timestart
      • @return boolean true on success, false on failure.
        **/
        function wiki_print_recent_activity($course, $isteacher, $timestart) {
        /// Given a course and a time, this module should find recent activity
        /// that has occurred in dfwiki activities and print it out.
        /// Return true if there was output, or false is there was none.

      global $CFG, $WS;

      // get all wiki instances used in the course
      if (!$dfwikis = get_all_instances_in_course('wiki',$course))

      { return false; }

      $ead = wiki_manager_get_instance();
      $allpages = array();
      // get all new pages (10 pages , no date search) for those wikis
      foreach($dfwikis as $dfwiki)

      { $allpages[$dfwiki->id] = array($dfwiki , $ead->get_wiki_most_uptodate_pages(10,$dfwiki) ); }

      foreach($allpages as $instance) {
      $dfwiki = $instance[0];
      $pages = $instance[1];
      $dir = $CFG->wwwroot.'/mod/wiki/view.php?id='.$dfwiki->coursemodule;

      $text = "<h3>{$dfwiki->name}</h3>";
      if (count($pages)!=0){
      $text .= '<table border="0" cellpadding="0" cellspacing="0">';
      $i = 1;
      foreach ($pages as $page)

      { //$pageinfo = wiki_page_last_version ($page); $pageinfo = $ead->get_wiki_page_by_pagename ($dfwiki,$page); $brs = '';//(strlen($page)>12)? '<br />   ' : ''; $text.= '<tr> <td class="nwikipagesupdates"> '.$i.'- <a href="'.$dir.'&page='.urlencode($page).'" title="'.$page.'">'.ltrim($page,20).'</a>'.$brs.'  - <small>('.strftime('%d %b %y',$pageinfo->lastmodified).')</small><br/>   '.wiki_get_user_info($pageinfo->author).' </td> </tr>'; $i++; }

      $text.='</table>';
      } else

      { $text = get_string('nopages','wiki'); }

      echo $text;
      }

      return true; // True if anything was printed, otherwise false
      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: