You are here

function PclZip::merge in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/lib/pclzip/pclzip.lib.php \PclZip::merge()

File

includes/moodle/lib/pclzip/pclzip.lib.php, line 1232

Class

PclZip

Code

function merge($p_archive_to_add) {

  //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
  $v_result = 1;

  // ----- Reset the error handler
  $this
    ->privErrorReset();

  // ----- Check archive
  if (!$this
    ->privCheckFormat()) {

    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    return 0;
  }

  // ----- Look if the $p_archive_to_add is a PclZip object
  if (is_object($p_archive_to_add) && get_class($p_archive_to_add) == 'pclzip') {

    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");

    // ----- Merge the archive
    $v_result = $this
      ->privMerge($p_archive_to_add);
  }
  else {
    if (is_string($p_archive_to_add)) {

      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");

      // ----- Create a temporary archive
      $v_object_archive = new PclZip($p_archive_to_add);

      // ----- Merge the archive
      $v_result = $this
        ->privMerge($v_object_archive);
    }
    else {

      // ----- Error log
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
    }
  }

  // ----- Return

  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  return $v_result;
}