Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-1031

Certificate doesn't open in new window

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: None
    • Component/s: Module: Certificate
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      Hi Dan,

      I was looking through the 1.9 branch certificate today – I like what you've done to clean up the code--thanks. There is a problem with the view.php file code, however. As you have it, the certificate opens in the same window and all headers and navigation are lost. This forces the user to have to use the back button. For fpdf you need to use get and a form. If you could change the code to this for getting the cert:

      if (empty($action) & !isset($_GET['certificate'])) {
      view_header($course, $certificate, $cm);
      if ($certificate->delivery == 0)

      { echo '<p align="center">'.get_string('openwindow', 'certificate').'</p>'; }

      elseif ($certificate->delivery == 1)

      { echo '<p align="center">'.get_string('opendownload', 'certificate').'</p>'; }

      elseif ($certificate->delivery == 2)

      { echo '<p align="center">'.get_string('openemail', 'certificate').'</p>'; }

      $opt = new stdclass();
      $opt->id = $cm->id;
      $opt->action = 'get';
      echo '<center>';
      echo '<form action="" method="get" name="form1" target="_blank">';
      echo print_single_button('view.php', $opt, $strgetcertificate, 'get', '_blank');
      echo '</form>';
      echo '</center>';
      add_to_log($course->id, 'certificate', 'received', "view.php?id=$cm->id", $certificate->id, $cm->id);
      print_footer(NULL, $course);
      exit;
      }

      And for review, I had it opening in an iframe directly in the page just for ease of usability-- so if you could change the review code to this

      if (empty($action) & !isset($_GET['certificate']))

      { view_header($course, $certificate, $cm); echo '<p align="center">'.get_string('viewed', 'certificate').'<br />'.userdate($certrecord->certdate).'</p>'; echo '<center>'; $opt = new stdclass(); $opt->id = $cm->id; $opt->action = 'review'; echo '<form action="" method="get" name="form1" target="certframe">'; echo print_single_button('', $opt, $strreviewcertificate, 'get', 'certframe'); echo '</form>'; //TODO: not sure why this iframe is used - in FF it seems to operate the same as the create certificate below. - might be able to be removed? echo '<iframe name="certframe" id="certframe" frameborder="NO" border="0" style="width:90%;height:500px;border:0px;"></iframe>'; echo '</center>'; print_footer(NULL, $course); exit; }

      Also, while you are at it, I found a couple of minor issues if you could clean them up in cvs that would be great:

      1. in the type files, the code to get teachers is also getting the admins, could you change the line to:
      if ($teachers = get_users_by_capability($context, 'mod/certificate:printteacher', '', $sort='u.lastname ASC', '', '', '', '', '')) {

      2. the lang file got some erroneous code in it and should be deleted at the very bottom where it says custom fields--I fixed in 1.9 but not in head.

      Also, I think that for 2.0 all of Mike's activity locking code should be deleted--no sense in having excess code if it isn't necessary.

      Thanks so much.

      Chardelle

        Attachments

        There are no Sub-Tasks for this issue.

          Activity

            People

            Assignee:
            danmarsden Dan Marsden
            Reporter:
            me Chardelle Busch
            Participants:
            Component watchers:
            Mark Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: