public static function setSourceModeOnContentPage($criteria, $changeVersion) { global $objUpdate, $_CONFIG; if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], $changeVersion)) { $em = \Env::get('em'); $pages = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findBy($criteria, true); foreach ($pages as $page) { if ($page) { if (!checkMemoryLimit()) { throw new UpdateException(); } try { // set source mode to content page $page->setSourceMode(true); $page->setUpdatedAtToNow(); $em->persist($page); } catch (\Exception $e) { \DBG::log("Setting source mode to page failed: " . $e->getMessage()); throw new UpdateException('Bei der Migration einer Inhaltsseite trat ein Fehler auf! ' . $e->getMessage()); } } } $em->flush(); } }
/** * Handles database errors * * Also migrates old Shop Customers to the User accounts and adds * all new settings * @return boolean false Always! * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Customer $table_name_old = DBPREFIX . "module_shop_customers"; // If the old Customer table is missing, the migration has completed // successfully already if (!\Cx\Lib\UpdateUtil::table_exist($table_name_old)) { return false; } // Ensure that the ShopSettings (including \Cx\Core\Setting) and Order tables // are ready first! //DBG::log("Customer::errorHandler(): Adding settings"); ShopSettings::errorHandler(); // \Cx\Core\Country\Controller\Country::errorHandler(); // Called by Order::errorHandler(); Order::errorHandler(); Discount::errorHandler(); \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); $objUser = \FWUser::getFWUserObject()->objUser; // Create new User_Profile_Attributes $index_notes = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes', 'Shop'); if (!$index_notes) { //DBG::log("Customer::errorHandler(): Adding notes attribute..."); // $objProfileAttribute = new \User_Profile_Attribute(); $objProfileAttribute = $objUser->objAttribute->getById(0); //DBG::log("Customer::errorHandler(): NEW notes attribute: ".var_export($objProfileAttribute, true)); $objProfileAttribute->setNames(array(1 => 'Notizen', 2 => 'Notes', 3 => 'Notes', 4 => 'Notes', 5 => 'Notes', 6 => 'Notes')); $objProfileAttribute->setType('text'); $objProfileAttribute->setMultiline(true); $objProfileAttribute->setParent(0); $objProfileAttribute->setProtection(array(1)); //DBG::log("Customer::errorHandler(): Made notes attribute: ".var_export($objProfileAttribute, true)); if (!$objProfileAttribute->store()) { throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'"); } //Re initialize shop setting \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); //DBG::log("Customer::errorHandler(): Stored notes attribute, ID ".$objProfileAttribute->getId()); if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_notes', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_notes'))) { throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'notes' setting"); } //DBG::log("Customer::errorHandler(): Stored notes attribute ID setting"); } $index_group = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_group_id', 'Shop'); if (!$index_group) { // $objProfileAttribute = new \User_Profile_Attribute(); $objProfileAttribute = $objUser->objAttribute->getById(0); $objProfileAttribute->setNames(array(1 => 'Kundenrabattgruppe', 2 => 'Discount group', 3 => 'Kundenrabattgruppe', 4 => 'Kundenrabattgruppe', 5 => 'Kundenrabattgruppe', 6 => 'Kundenrabattgruppe')); $objProfileAttribute->setType('text'); $objProfileAttribute->setParent(0); $objProfileAttribute->setProtection(array(1)); if (!$objProfileAttribute->store()) { throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'"); } //Re initialize shop setting \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_customer_group_id', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_customer_group_id'))) { throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'customer_group_id' setting"); } } // For the migration, a temporary flag is needed in the orders table // in order to prevent mixing up old and new customer_id values. $table_order_name = DBPREFIX . "module_shop_orders"; if (!\Cx\Lib\UpdateUtil::column_exist($table_order_name, 'migrated')) { $query = "\n ALTER TABLE `{$table_order_name}`\n ADD `migrated` TINYINT(1) unsigned NOT NULL default 0"; \Cx\Lib\UpdateUtil::sql($query); } // Create missing UserGroups for customers and resellers $objGroup = null; $group_id_customer = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); if ($group_id_customer) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_customer); } if (!$objGroup || $objGroup->EOF) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Endkunden')); } if (!$objGroup || $objGroup->EOF) { $objGroup = new \UserGroup(); $objGroup->setActiveStatus(true); $objGroup->setDescription('Online Shop Endkunden'); $objGroup->setName('Shop Endkunden'); $objGroup->setType('frontend'); } //DBG::log("Group: ".var_export($objGroup, true)); if (!$objGroup) { throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for customers"); } //DBG::log("Customer::errorHandler(): Made customer usergroup: ".var_export($objGroup, true)); if (!$objGroup->store() || !$objGroup->getId()) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for customers"); } //DBG::log("Customer::errorHandler(): Stored customer usergroup, ID ".$objGroup->getId()); \Cx\Core\Setting\Controller\Setting::set('usergroup_id_customer', $objGroup->getId()); if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_customer')) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for customers"); } $group_id_customer = $objGroup->getId(); $objGroup = null; $group_id_reseller = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); if ($group_id_reseller) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_reseller); } if (!$objGroup || $objGroup->EOF) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Wiederverkäufer')); } if (!$objGroup || $objGroup->EOF) { $objGroup = new \UserGroup(); $objGroup->setActiveStatus(true); $objGroup->setDescription('Online Shop Wiederverkäufer'); $objGroup->setName('Shop Wiederverkäufer'); $objGroup->setType('frontend'); } if (!$objGroup) { throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for resellers"); } //DBG::log("Customer::errorHandler(): Made reseller usergroup: ".var_export($objGroup, true)); if (!$objGroup->store() || !$objGroup->getId()) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for resellers"); } \Cx\Core\Setting\Controller\Setting::set('usergroup_id_reseller', $objGroup->getId()); if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_reseller')) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for resellers"); } $group_id_reseller = $objGroup->getId(); $default_lang_id = \FWLanguage::getDefaultLangId(); $query = "\n SELECT `customer`.`customerid`,\n `customer`.`prefix`, `customer`.`firstname`,\n `customer`.`lastname`,\n `customer`.`company`, `customer`.`address`,\n `customer`.`city`, `customer`.`zip`,\n `customer`.`country_id`,\n `customer`.`phone`, `customer`.`fax`,\n `customer`.`email`,\n `customer`.`username`, `customer`.`password`,\n `customer`.`company_note`,\n `customer`.`is_reseller`,\n `customer`.`customer_status`, `customer`.`register_date`,\n `customer`.`group_id`\n FROM `{$table_name_old}` AS `customer`\n ORDER BY `customer`.`customerid` ASC"; $objResult = \Cx\Lib\UpdateUtil::sql($query); while (!$objResult->EOF) { $old_customer_id = $objResult->fields['customerid']; if (empty($objResult->fields['email'])) { $objResult->fields['email'] = $objResult->fields['username']; } $email = $objResult->fields['email']; $objUser = \FWUser::getFWUserObject()->objUser->getUsers(array('email' => array(0 => $email))); // TODO: See whether a User with that username (but different e-mail address) exists! $objUser_name = \FWUser::getFWUserObject()->objUser->getUsers(array('username' => array(0 => $objResult->fields['username']))); if ($objUser && $objUser_name) { $objUser = $objUser_name; } $objCustomer = null; if ($objUser) { $objCustomer = self::getById($objUser->getId()); } if (!$objCustomer) { $lang_id = Order::getLanguageIdByCustomerId($old_customer_id); $lang_id = \FWLanguage::getLangIdByIso639_1($lang_id); if (!$lang_id) { $lang_id = $default_lang_id; } $objCustomer = new Customer(); if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['prefix'])) { $objCustomer->gender('gender_female'); } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['prefix'])) { $objCustomer->gender('gender_male'); // } else { // Other "genders", like "family", "thing", or "it" won't be matched // and are left on "gender_unknown". //DBG::log("*** Prefix {$objResult->fields['prefix']}, UNKNOWN GENDER!"); } //DBG::log("Prefix {$objResult->fields['prefix']}, made gender ".$objCustomer->gender()); $objCustomer->company($objResult->fields['company']); $objCustomer->firstname($objResult->fields['firstname']); $objCustomer->lastname($objResult->fields['lastname']); $objCustomer->address($objResult->fields['address']); $objCustomer->city($objResult->fields['city']); $objCustomer->zip($objResult->fields['zip']); $objCustomer->country_id($objResult->fields['country_id']); $objCustomer->phone($objResult->fields['phone']); $objCustomer->fax($objResult->fields['fax']); $objCustomer->email($objResult->fields['email']); $objCustomer->companynote($objResult->fields['company_note']); $objCustomer->active($objResult->fields['customer_status']); // Handled by a UserGroup now, see below //$objCustomer->setResellerStatus($objResult->fields['is_reseller']); $objCustomer->register_date($objResult->fields['register_date']); $objCustomer->group_id($objResult->fields['group_id']); // NOTE: Mind that the User class has been modified to accept e-mail addresses // as usernames! $objCustomer->username($objResult->fields['username']); // Copy the md5 hash of the password! $objCustomer->password = $objResult->fields['password']; $objCustomer->setFrontendLanguage($lang_id); } if ($objResult->fields['is_reseller']) { $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_reseller)); //DBG::log("Customer::errorHandler(): Added reseller: ".$objCustomer->id()); } else { $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_customer)); //DBG::log("Customer::errorHandler(): Added customer: ".$objCustomer->id()); } if (!$objCustomer->store()) { //DBG::log(var_export($objCustomer, true)); throw new \Cx\Lib\Update_DatabaseException("Failed to migrate existing Customer ID " . $old_customer_id . " to Users (Messages: " . join(', ', $objCustomer->error_msg) . ")"); } // Update the Orders table with the new Customer ID. // Note that we use the ambiguous old customer ID that may // coincide with a new User ID, so to prevent inconsistencies, // migrated Orders are marked as such. $query = "\n UPDATE `{$table_order_name}`\n SET `customer_id`=" . $objCustomer->id() . ",\n `migrated`=1\n WHERE `customer_id`={$old_customer_id}\n AND `migrated`=0"; \Cx\Lib\UpdateUtil::sql($query); // Drop migrated $query = "\n DELETE FROM `{$table_name_old}`\n WHERE `customerid`={$old_customer_id}"; \Cx\Lib\UpdateUtil::sql($query); $objResult->MoveNext(); if (!checkMemoryLimit() || !checkTimeoutLimit()) { return false; } } // Remove the flag, it's no longer needed. // (You could also verify that all records have been migrated by // querying them with "[...] WHERE `migrated`=0", which *MUST* result // in an empty recordset. This is left as an exercise for the reader.) $query = "\n ALTER TABLE `{$table_order_name}`\n DROP `migrated`"; \Cx\Lib\UpdateUtil::sql($query); \Cx\Lib\UpdateUtil::drop_table($table_name_old); //DBG::log("Updated Customer table and related stuff"); // Always return false; }
/** * migrate old events to new events table */ protected function migrateEvents() { $eventId = null; $mailTemplateId = null; try { // migration old events to new event table // migrate entries $where = ''; if (!empty($_SESSION['contrexx_update']['calendar']['events'])) { $where = ' WHERE `id` > ' . $_SESSION['contrexx_update']['calendar']['events']; } $result = \Cx\Lib\UpdateUtil::sql("SELECT * FROM `" . CALENDAR_OLD_EVENT_TABLE . "`" . $where . " ORDER BY `id`"); while (!$result->EOF) { $langId = null; $registrationFormId = null; $mailTemplateId = null; $eventId = null; $langId = $this->categoryLanguages[$result->fields['catid']]; $name = $result->fields['name']; // added event name to mail title $mailTemplateId = $this->addMailTemplate($result->fields['mailTitle'] . ' (' . $name . ')', $result->fields['mailContent'], $langId); // insert event \Cx\Lib\UpdateUtil::sql("\r\n INSERT IGNORE INTO `" . CALENDAR_NEW_EVENT_TABLE . "` (\r\n `status`,\r\n `catid`,\r\n `startdate`,\r\n `enddate`,\r\n `priority`,\r\n `access`,\r\n `place`,\r\n `link`,\r\n `pic`,\r\n `attach`,\r\n `place_street`,\r\n `place_zip`,\r\n `place_city`,\r\n `place_link`,\r\n `place_map`,\r\n `org_name`,\r\n `org_street`,\r\n `org_zip`,\r\n `org_city`,\r\n `org_email`,\r\n `org_link`,\r\n `registration_num`,\r\n `registration`,\r\n `invited_groups`,\r\n `registration_notification`,\r\n `invited_mails`,\r\n `invitation_email_template`,\r\n `series_status`,\r\n `series_type`,\r\n `series_pattern_count`,\r\n `series_pattern_weekday`,\r\n `series_pattern_day`,\r\n `series_pattern_week`,\r\n `series_pattern_month`,\r\n `series_pattern_type`,\r\n `series_pattern_dourance_type`,\r\n `series_pattern_end`,\r\n `series_pattern_begin`,\r\n `series_pattern_exceptions`,\r\n\r\n `use_custom_date_display`,\r\n `showStartDateList`,\r\n `showEndDateList`,\r\n `showStartTimeList`,\r\n `showEndTimeList`,\r\n `showTimeTypeList`,\r\n `showStartDateDetail`,\r\n `showEndDateDetail`,\r\n `showStartTimeDetail`,\r\n `showEndTimeDetail`,\r\n `showTimeTypeDetail`,\r\n `google`,\r\n `price`,\r\n `place_mediadir_id`,\r\n `show_in`,\r\n `invitation_sent`,\r\n `ticket_sales`,\r\n `num_seating`,\r\n `confirmed`,\r\n `author`,\r\n `all_day`,\r\n `place_id`,\r\n `place_country`,\r\n `registration_form`,\r\n `email_template`\r\n ) VALUES (\r\n '" . contrexx_raw2db($result->fields['active']) . "',\r\n '" . contrexx_raw2db($result->fields['catid']) . "',\r\n '" . contrexx_raw2db($result->fields['startdate']) . "',\r\n '" . contrexx_raw2db($result->fields['enddate']) . "',\r\n '" . contrexx_raw2db($result->fields['priority']) . "',\r\n '" . contrexx_raw2db($result->fields['access']) . "',\r\n '" . contrexx_raw2db($result->fields['placeName']) . "',\r\n '" . contrexx_raw2db($result->fields['link']) . "',\r\n '" . contrexx_raw2db($result->fields['pic']) . "',\r\n '" . contrexx_raw2db($result->fields['attachment']) . "',\r\n '" . contrexx_raw2db($result->fields['placeStreet']) . "',\r\n '" . contrexx_raw2db($result->fields['placeZip']) . "',\r\n '" . contrexx_raw2db($result->fields['placeCity']) . "',\r\n '" . contrexx_raw2db($result->fields['placeLink']) . "',\r\n '" . contrexx_raw2db($result->fields['placeMap']) . "',\r\n '" . contrexx_raw2db($result->fields['organizerName']) . "',\r\n '" . contrexx_raw2db($result->fields['organizerStreet']) . "',\r\n '" . contrexx_raw2db($result->fields['organizerZip']) . "',\r\n '" . contrexx_raw2db($result->fields['organizerPlace']) . "',\r\n '" . contrexx_raw2db($result->fields['organizerMail']) . "',\r\n '" . contrexx_raw2db($result->fields['organizerLink']) . "',\r\n '" . contrexx_raw2db($result->fields['num']) . "',\r\n '" . contrexx_raw2db($result->fields['registration']) . "',\r\n '" . contrexx_raw2db($result->fields['groups']) . "',\r\n " . ($result->fields['notification'] ? "'" . contrexx_raw2db($result->fields['notification_address']) . "'" : "''") . ",\r\n '',\r\n " . $mailTemplateId . ",\r\n '" . contrexx_raw2db($result->fields['series_status']) . "',\r\n '" . contrexx_raw2db($result->fields['series_type']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_count']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_weekday']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_day']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_week']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_month']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_type']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_dourance_type']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_end']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_begin']) . "',\r\n '" . contrexx_raw2db($result->fields['series_pattern_exceptions']) . "',\r\n 0,\r\n 1,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1,\r\n 1,\r\n 1,\r\n 1,\r\n 1,\r\n 0,\r\n 0,\r\n 0,\r\n " . $langId . ",\r\n 1,\r\n 0,\r\n '',\r\n 1,\r\n " . $_SESSION['contrexx_update']['user_id'] . ",\r\n 0,\r\n 0,\r\n '',\r\n 0,\r\n 0\r\n )\r\n "); $eventId = $this->db->Insert_ID(); // add language fields for event \Cx\Lib\UpdateUtil::sql("\r\n INSERT IGNORE INTO `" . CALENDAR_NEW_EVENT_FIELD_TABLE . "` (`event_id`, `lang_id`, `title`, `description`, `redirect`)\r\n VALUES (\r\n " . $eventId . ",\r\n " . $langId . ",\r\n '" . contrexx_raw2db($name) . "',\r\n '" . contrexx_raw2db($result->fields['comment']) . "',\r\n ''\r\n )\r\n "); // add registration form fields $resultFormFields = \Cx\Lib\UpdateUtil::sql("\r\n SELECT `id` FROM `" . CALENDAR_OLD_FORM_FIELD_TABLE . "`\r\n WHERE `note_id` = " . $result->fields['id'] . "\r\n "); if ($resultFormFields->RecordCount() > 0) { // add registration form $registrationFormId = $this->addRegistrationFormForEvent($name); $formFieldsMap = $this->addRegistrationFormFields($registrationFormId, $result->fields['id'], $langId); \Cx\Lib\UpdateUtil::sql("UPDATE `" . CALENDAR_NEW_EVENT_TABLE . "` SET `registration_form` = " . $registrationFormId . " WHERE `id` = " . $eventId); // add registration data $this->addRegistrationData($result->fields['id'], $eventId, $langId, $formFieldsMap); } $_SESSION['contrexx_update']['calendar']['events'] = intval($result->fields['id']); if (!checkMemoryLimit() || !checkTimeoutLimit()) { return 'timeout'; } // take next event $result->MoveNext(); } } catch (\Cx\Lib\UpdateException $e) { // remove already inserted data from failed event if ($eventId) { \Cx\Lib\UpdateUtil::sql("DELETE FROM `" . CALENDAR_NEW_EVENT_TABLE . "` WHERE `id` = " . $eventId); \Cx\Lib\UpdateUtil::sql("DELETE FROM `" . CALENDAR_NEW_EVENT_FIELD_TABLE . "` WHERE `event_id` = " . $eventId); } if ($mailTemplateId) { \Cx\Lib\UpdateUtil::sql("DELETE FROM `" . CALENDAR_NEW_MAIL_TABLE . "` WHERE `id` = " . $mailTemplateId); } return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
public function pageGrouping() { // Fetch all pages if ((!isset($_POST['doGroup']) || isset($_POST['doGroup']) && !$_POST['doGroup']) && empty($_SESSION['contrexx_update']['do_group'])) { self::$em->clear(); return $this->getTreeCode(); } $_SESSION['contrexx_update']['do_group'] = true; if (empty($_SESSION['contrexx_update']['similar_pages'])) { $_SESSION['contrexx_update']['similar_pages'] = $_POST['similarPages']; } if (empty($_SESSION['contrexx_update']['remove_pages'])) { $_SESSION['contrexx_update']['remove_pages'] = $_POST['removePages']; } $arrSimilarPages = $_SESSION['contrexx_update']['similar_pages']; $pageRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $nodeRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node'); $nodeToRemove = array(); if (empty($_SESSION['contrexx_update']['node_to_remove'])) { $_SESSION['contrexx_update']['node_to_remove'] = array(); } foreach ($arrSimilarPages as $nodeId => $arrPageIds) { if (!checkMemoryLimit() || !checkTimeoutLimit()) { $_SESSION['contrexx_update']['node_to_remove'] = array_merge(\ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['node_to_remove']), $nodeToRemove); return 'timeout'; } foreach ($arrPageIds as $pageId) { $page = $pageRepo->find($pageId); if ($page && $page->getNode()->getId() != $nodeId) { $nodeToRemove[] = $page->getNode()->getId(); $node = $nodeRepo->find($nodeId); $aliases = $page->getAliases(); foreach ($aliases as $alias) { $alias->setTarget('[[NODE_' . $node->getId() . '_' . $page->getLang() . ']]'); self::$em->persist($alias); } $page->setNode($node); $page->setNodeIdShadowed($node->getId()); self::$em->persist($node); } } self::$em->flush(); unset($_SESSION['contrexx_update']['similar_pages'][$nodeId]); } $arrRemovePages = $_SESSION['contrexx_update']['remove_pages']; $pageToRemove = array(); if (empty($_SESSION['contrexx_update']['page_to_remove'])) { $_SESSION['contrexx_update']['page_to_remove'] = array(); } foreach ($arrRemovePages as $pageId) { if (!checkMemoryLimit() || !checkTimeoutLimit()) { $_SESSION['contrexx_update']['page_to_remove'] = array_merge(\ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['page_to_remove']), $pageToRemove); $_SESSION['contrexx_update']['node_to_remove'] = array_merge(\ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['node_to_remove']), $nodeToRemove); return 'timeout'; } $page = $pageRepo->find($pageId); if ($page) { $pageToRemove[] = $pageId; $nodeToRemove[] = $page->getNode()->getId(); } unset($_SESSION['contrexx_update']['remove_pages'][$pageId]); } $_SESSION['contrexx_update']['page_to_remove'] = array_merge(\ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['page_to_remove']), $pageToRemove); $_SESSION['contrexx_update']['node_to_remove'] = array_merge(\ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['node_to_remove']), $nodeToRemove); $pageToRemove = $_SESSION['contrexx_update']['page_to_remove']; $nodeToRemove = $_SESSION['contrexx_update']['node_to_remove']; // Prevent the system from trying to remove the same node more than once $pageToRemove = array_unique($pageToRemove); foreach ($pageToRemove as $index => $pageId) { if (!checkMemoryLimit() || !checkTimeoutLimit()) { return 'timeout'; } $page = $pageRepo->find($pageId); self::$em->remove($page); unset($_SESSION['contrexx_update']['page_to_remove'][$index]); } self::$em->flush(); self::$em->clear(); $nodeToRemove = array_unique($nodeToRemove); foreach ($nodeToRemove as $index => $nodeId) { if (!checkMemoryLimit() || !checkTimeoutLimit()) { return 'timeout'; } $node = $nodeRepo->find($nodeId); $nodeRepo->removeFromTree($node); // Reset node cache - this is required for the tree to reload its new structure after a node had been removed self::$em->clear(); unset($_SESSION['contrexx_update']['node_to_remove'][$index]); } return true; }
function copyCxFilesToRoot($src, $dst) { static $copiedCxFilesIndex = 0; $src = str_replace('\\', '/', $src); $dst = str_replace('\\', '/', $dst); $dir = opendir($src); $arrCurrentFolderStructure = array(); while ($file = readdir($dir)) { if (!in_array($file, array('.', '..'))) { $arrCurrentFolderStructure[] = $file; } } sort($arrCurrentFolderStructure); if (!isset($_SESSION['contrexx_update']['copiedCxFilesTotal'])) { $_SESSION['contrexx_update']['copiedCxFilesTotal'] = 0; } foreach ($arrCurrentFolderStructure as $file) { if (!checkMemoryLimit() || !checkTimeoutLimit()) { $_SESSION['contrexx_update']['copiedCxFilesIndex'] = $copiedCxFilesIndex; return 'timeout'; } $srcPath = $src . '/' . $file; $dstPath = $dst . '/' . $file; if (is_dir($srcPath)) { \Cx\Lib\FileSystem\FileSystem::make_folder($dstPath); $status = copyCxFilesToRoot($srcPath, $dstPath); if ($status !== true) { return $status; } } else { $copiedCxFilesIndex++; if (isset($_SESSION['contrexx_update']['copiedCxFilesIndex']) && $copiedCxFilesIndex <= $_SESSION['contrexx_update']['copiedCxFilesIndex']) { continue; } $_SESSION['contrexx_update']['copiedCxFilesTotal'] = $_SESSION['contrexx_update']['copiedCxFilesTotal'] + 1; try { // rename the file if its exists on customizing if (!renameCustomizingFile($dstPath)) { return false; } if (!verifyMd5SumOfFile($dstPath, $srcPath)) { if (!backupModifiedFile($dstPath)) { return false; } } $objFile = new \Cx\Lib\FileSystem\File($srcPath); $objFile->copy($dstPath, true); } catch (\Exception $e) { $copiedCxFilesIndex--; $_SESSION['contrexx_update']['copiedCxFilesIndex'] = $copiedCxFilesIndex; $_SESSION['contrexx_update']['copiedCxFilesTotal'] = $_SESSION['contrexx_update']['copiedCxFilesTotal'] - 1; setUpdateMsg('Folgende Datei konnte nicht installiert werden:<br />' . $dstPath); setUpdateMsg('Fehler: ' . $e->getMessage()); setUpdateMsg('<br />Häufigste Ursache dieses Problems ist, dass zur Ausführung dieses Vorgangs die benötigten Schreibrechte nicht vorhanden sind. Prüfen Sie daher, ob die FTP-Konfiguration in der Datei <strong>config/configuration.php</strong> korrekt eingerichtet ist.'); return false; } } } closedir($dir); return true; }