Commit 76c077a0 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1973249: Show error if archiving failed



- Shows need to retrigger archiving for fail on the page if admin/institution
admin
- Shows need to retrigger archiving for fail on the Admin current
submissions list (at admin/groups/archives.php?current=1)

- Also now shows a message on page for the owner when they have
submitted the page

Change-Id: I2d79f17eefadb4cb6fed602858bc4dcc547411c8
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent af740948
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -36,16 +36,19 @@ else {
}

if ($USER->get('admin') && param_exists('releaseids')) {
    $releaseids = array_map('intval', (array) param_variable('releaseids'));
    $releaseids = param_variable('releaseids');
    $releaseaction = param_variable('action');
    $returntouser = false;
    // Release the locked items.
    foreach ($releaseids as $releaseid) {
        $view = new View($releaseid);
        $collection = $view->get_collection();
        if ($collection === false) {
            $releasecollection = false;
    foreach ($releaseids as $releaseid => $releasetype) {
        $view = $collection = false;
        if ($releasetype === 'collection') {
            $collection = new Collection($releaseid);
            $releasecollection = true;
        }
        else {
            $releasecollection = true;
            $view = new View($releaseid);
            $releasecollection = false;
        }

        if (is_plugin_active('submissions', 'module')) {
+16 −0
Original line number Diff line number Diff line
@@ -1047,6 +1047,22 @@ function is_content_in_export_queue($thing, $id) {
    return (bool) count_records('export_queue_items', $thing, $id);
}

/**
 * Check if an export_queue item has failed to export
 *
 * @param string $type     Either 'view' or 'collection'
 * @param string $id       The id for the $type
 * @param string $ownerid  The id of the owner
 *
 * @return boolean  True if the thing is in the export queue and failed to export.
 */
function has_export_failed($type, $id, $ownerid) {
    return (bool) record_exists_sql("
        SELECT starttime FROM {export_queue} e
        JOIN {export_queue_items} ei ON ei.exportqueueid = e.id
        WHERE e.starttime IS NOT NULL AND e.usr = ? AND ei." . $type . " = ?", array($ownerid, $id));
}

class PluginExportAll extends PluginExport {

    protected $htmlexporter;
+4 −3
Original line number Diff line number Diff line
@@ -88,9 +88,10 @@ var CurrentSubmissionsRelease = (function($) {
          console.log($('#searchresults input.selectcontentrelease').length);
          $('#searchresults input.selectcontentrelease').each(function() {
              var value = $(this).val();
              var releasetype = $(this).data('releasetype');
              $(this).on('change', function() {
                  if ($(this).prop('checked')) {
                      self.selectcontentrelease[value] = 1;
                      self.selectcontentrelease[value] = releasetype;
                  }
                  else {
                      delete self.selectcontentrelease[value];
@@ -103,7 +104,7 @@ var CurrentSubmissionsRelease = (function($) {
          if ($('#selectallrelease').length) {
              $('#selectallrelease').on("click", function() {
                  $('#searchresults input.selectcontentrelease').each(function() {
                      self.selectcontentrelease[$(this).val()] = 1;
                      self.selectcontentrelease[$(this).val()] = $(this).data('releasetype');
                      $(this).prop('checked', true);
                  });
                  return false;
@@ -126,7 +127,7 @@ var CurrentSubmissionsRelease = (function($) {
                      $('#' + formid).append($('<input>', {
                          'type': 'checkbox',
                          'name': 'releaseids[' + j + ']',
                          'value': j,
                          'value': self.selectcontentrelease[j],
                          'class': 'd-none',
                          'checked': 'checked'
                      }));
+1 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ $string['collectionsubmittedtogroupgrade'] = 'This collection was submitted to t
$string['collectionsubmittedtohost'] = 'This collection has been submitted for assessment.';
$string['collectionsubmittedtohoston'] = 'This collection was submitted on %s.';
$string['submittedpendingrelease'] = 'Pending release after archiving.';
$string['submittedpendingreleasefailed'] = 'Release failed to archive.<br>Go to <a href="%s">Export queue</a> to re-queue.';
$string['nobodycanseethisview2'] = 'Only you can see this page.';
$string['noviews1'] = 'No pages or collections.';
$string['youhavenoviews1'] = 'You don\'t have any pages or collections.';
+8 −0
Original line number Diff line number Diff line
@@ -864,6 +864,9 @@ function build_admin_archived_submissions_results($search, $offset, $limit) {
        if ($search['type'] == 'current') {
            // Format the date nicely.
            $results['data'][$key]['submittedtime'] = format_date(strtotime($data['submittedtime']));
            // If the archiving started but failed
            require_once(get_config('docroot') . 'export/lib.php');
            $results['data'][$key]['needrequeue'] = has_export_failed($data['releasetype'], $data['releaseid'], $data['id']);
        }
    }

@@ -963,6 +966,11 @@ function build_admin_archived_submissions_results($search, $offset, $limit) {
    if ($results['data']) {
        foreach ($results['data'] as &$result) {
            $result['canedituser'] = $USER->can_masquerade_as((object)$result, array('supportadmin'));
            if (isset($result['releasetype']) && $result['releasetype'] == 'collection') {
                // we need to find the first true page for the link
                $collection = new Collection($result['releaseid']);
                $result['url'] = $collection->get_url();
            }
        }
    }

Loading