private function _move_object($target) { $move_to_topic = new midcom_db_topic(); $move_to_topic->get_by_id($target); if (!$move_to_topic->guid) { throw new midcom_error('Failed to move the topic. Could not get the target topic'); } $move_to_topic->require_do('midgard:create'); if (is_a($this->_object, 'midcom_db_topic')) { $name = $this->_object->name; $this->_object->name = ''; // Prevents problematic location to break the site, we set this back below... $up = $this->_object->up; $this->_object->up = $move_to_topic->id; if (!$this->_object->update()) { throw new midcom_error('Failed to move the topic, reason ' . midcom_connection::get_error_string()); } if (!midcom_admin_folder_management::is_child_listing_finite($this->_object)) { $this->_object->up = $up; $this->_object->name = $name; $this->_object->update(); throw new midcom_error("Refusing to move this folder because the move would have created an " . "infinite loop situation caused by the symlinks on this site. The " . "whole site would have been completely and irrevocably broken if this " . "move would have been allowed to take place. Infinite loops can not " . "be allowed. Sorry, but this was for your own good."); } // It was ok, so set name back now $this->_object->name = $name; $this->_object->update(); } else { $this->_object->topic = $move_to_topic->id; if (!$this->_object->update()) { throw new midcom_error('Failed to move the article, reason ' . midcom_connection::get_error_string()); } } }
private function _create_topic($prefix) { if (!empty($this->_new_topic->symlink)) { $name = $this->_new_topic->name; $topic = $this->_new_topic; while (!empty($topic->symlink)) { // Only direct symlinks are supported, but indirect symlinks are ok as we change them to direct ones here $this->_new_topic->symlink = $topic->symlink; try { $topic = new midcom_db_topic($topic->symlink); } catch (midcom_error $e) { debug_add("Could not get target for symlinked topic #{$this->_new_topic->id}: " . $e->getMessage(), MIDCOM_LOG_ERROR); $topic = $this->_new_topic; $this->_new_topic->purge(); throw new midcom_error("Refusing to create this symlink because its target folder was not found: " . $e->getMessage()); } $name = $topic->name; } if ($this->_new_topic->up == $topic->up) { $this->_new_topic->purge(); throw new midcom_error("Refusing to create this symlink because it is located in the same " . "folder as its target. You must have made a mistake. Sorry, but this " . "was for your own good."); } if ($this->_new_topic->up == $topic->id) { $this->_new_topic->purge(); throw new midcom_error("Refusing to create this symlink because its parent folder is the same " . "folder as its target. You must have made a mistake because this would " . "have created an infinite loop situation. The whole site would have " . "been completely and irrevocably broken if this symlink would have been " . "allowed to exist. Infinite loops can not be allowed. Sorry, but this " . "was for your own good."); } $this->_new_topic->update(); if (!midcom_admin_folder_management::is_child_listing_finite($topic)) { $this->_new_topic->purge(); throw new midcom_error("Refusing to create this symlink because it would have created an " . "infinite loop situation. The whole site would have been completely " . "and irrevocably broken if this symlink would have been allowed to " . "exist. Please redesign your usage of symlinks. Infinite loops can " . "not be allowed. Sorry, but this was for your own good."); } $this->_new_topic->name = $name; while (!$this->_new_topic->update() && midcom_connection::get_error() == MGD_ERR_DUPLICATE) { $this->_new_topic->name .= "-link"; } } midcom::get('uimessages')->add($this->_l10n->get('midcom.admin.folder'), $this->_l10n->get('folder created')); // Generate name if it is missing if (!$this->_new_topic->name) { $this->_new_topic->name = midcom_helper_misc::generate_urlname_from_string($this->_new_topic->extra); $this->_new_topic->update(); } // Get the relocation url $url = "{$prefix}{$this->_new_topic->name}/"; return $url; }