private function import($zip) { if (!($xmlfile = $zip->getFromName($this->infoxmlfile))) { echo "file '" . $this->infoxmlfile . "' in the package not found"; exit; } else { $xml = new SimpleXMLElement($xmlfile); } $time_start = microtime(1); $this->log = "Start log....\n"; if (strcmp($this->packagetype, (string) $xml->packageinfo->packagetype) != 0) { echo "Package type error.\n Expected: '" . $this->packagetype . "', found: '" . (string) $xml->packageinfo->packagetype . "'."; exit; } else { $this->log .= "Package type: " . (string) $xml->packageinfo->packagetype . "\n"; } if (strcmp($this->version, (string) $xml->packageinfo->version) != 0) { echo "Package version error.\n Expected: '" . $this->version . "', found: '" . (string) $xml->packageinfo->version . "'."; exit; } else { $this->log .= "Package version: " . (string) $xml->packageinfo->version . "\n"; } if (strcmp("", (string) $xml->packageinfo->finalization) === 0) { echo "Package is not finalized"; exit; } $packid = (string) $xml->packageinfo->packid; $sql = "select P.STATUS, P.PACKAGEID, CT.TITLE, P.EXPORTDATE, \n\t\tP.IMPORTDATE, IIU.USERNAME as IMPORTUSERNAME, \n\t\tEIU.USERNAME as EXPORTUSERNAME from PACKAGES P \n\t\tleft join CONTENTTREE CT \n\t\ton (CT.NODEID = P.NODEID) \n\t\tleft join INFO_USERS IIU \n\t\ton (IIU.NODEID = P.IMPORTUSERID) \n\t\tleft join INFO_USERS EIU \n\t\ton (EIU.NODEID = P.EXPORTUSERID) \n\t\twhere P.PACKAGEID = ?"; $res = $this->_db->fetchRow($sql, $packid); if (!$res) { echo "Export of package not found. Package id = " . $packid; exit; } if (trim($res['STATUS']) == $this->db_status_import) { echo "Package was imported. \n\t\t\tInformation: \n \n\t\t\texport from: " . $res['EXPORTDATE'] . " By: '" . $res['EXPORTUSERNAME'] . "'\n. \n\t\t\tImport from: " . $res['IMPORTDATE'] . " \n\t\t\tBy: '" . $res['IMPORTUSERNAME'] . "'\n for node title: " . $res['TITLE'] . "\n. Package ID: " . $res['PACKAGEID']; exit; } else { $this->log .= " Information: \n export from: " . $res['EXPORTDATE'] . " By: '" . $res['EXPORTUSERNAME'] . "'.\n for node title: " . $res['TITLE'] . "\n"; } $this->_db->beginTransaction(); $sql = "select RDB\$SET_CONTEXT('USER_TRANSACTION', 'CURRENT_USERID', ?) from RDB\$DATABASE"; $this->_db->fetchCol($sql, $this->_acl->userid); $this->log .= "------------------------- begin\n"; $this->importLevel($zip, $xml->content->children()); $this->ImportLevelDel($zip, $xml->content->children()); $this->log .= "------------------------- end\n"; $time_end = microtime(1); $time = $time_end - $time_start; $this->log .= "-> Package load: " . $time . " sec"; // $AdminDbModel = new Admin_Model_Admin(); $AdminDbModel->importPackage($packid, (string) $xml->packageinfo->guid, $this->log, $this->db_status_import); $this->_db->commit(); echo $this->log; }