Skip to content

Commit

Permalink
Remove symlink feature. This was mainly kept around for ragnaroek com…
Browse files Browse the repository at this point in the history
…pat, but has never seen any actual use
  • Loading branch information
flack committed Jan 5, 2017
1 parent 6f3817c commit 9ba0d38
Show file tree
Hide file tree
Showing 60 changed files with 95 additions and 1,120 deletions.
3 changes: 1 addition & 2 deletions lib/midcom/admin/folder/config/config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
'schemadbs_folder' => array
(
'default' => 'file:/midcom/admin/folder/config/schemadb_folder.inc',
'link' => 'file:/midcom/admin/folder/config/schemadb_link.inc',
),

//false means the parent topic's component will be suggested by default,
//false means the parent topic's component will be suggested by default,
//otherwise enter any component name
'default_component' => false
1 change: 0 additions & 1 deletion lib/midcom/admin/folder/config/manifest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
(
'topic_management' => MIDCOM_PRIVILEGE_DENY,
'template_management' => MIDCOM_PRIVILEGE_DENY,
'symlinks' => MIDCOM_PRIVILEGE_DENY,
),
'description' => 'Management of MidCOM site folders',
26 changes: 0 additions & 26 deletions lib/midcom/admin/folder/config/schemadb_link.inc

This file was deleted.

33 changes: 0 additions & 33 deletions lib/midcom/admin/folder/handler/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ class midcom_admin_folder_handler_delete extends midcom_baseclasses_components_h
*/
public function _handler_delete($handler_id, array $args, array &$data)
{
// Symlink support requires that we use actual URL topic object here
$urltopics = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_URLTOPICS);
if ($urltopic = end($urltopics)) {
$this->_topic = $urltopic;
}

$this->_topic->require_do('midgard:delete');
$this->_topic->require_do('midcom.admin.folder:topic_management');

Expand All @@ -41,33 +35,6 @@ public function _handler_delete($handler_id, array $args, array &$data)
'recursive' => true,
'success_url' => $upper_node[MIDCOM_NAV_ABSOLUTEURL]
));
if ($workflow->get_state() === delete::CONFIRMED) {
$this->check_symlinks();
}
return $workflow->run();
}

/**
* Deletes the folder and _midcom_db_article_ objects stored in it.
*/
private function check_symlinks()
{
if (midcom::get()->config->get('symlinks')) {
midcom::get()->auth->request_sudo('midcom.admin.folder');
$qb_topic = midcom_db_topic::new_query_builder();
$qb_topic->add_constraint('symlink', '=', $this->_topic->id);
$symlinks = $qb_topic->execute();
if (!empty($symlinks)) {
$msg = 'Refusing to delete Folder because it has symlinks:';
$nap = new midcom_helper_nav();
foreach ($symlinks as $symlink) {
$node = $nap->get_node($symlink->id);
$msg .= ' ' . $node[MIDCOM_NAV_FULLURL];
}

throw new midcom_error($msg);
}
midcom::get()->auth->drop_sudo();
}
}
}
90 changes: 1 addition & 89 deletions lib/midcom/admin/folder/handler/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ private function _load_controller()
// Get the configured schemas
$schemadbs = $this->_config->get('schemadbs_folder');

if ($this->_handler_id === 'createlink') {
$schemadb = 'link';
}
// Check if a custom schema exists
elseif (array_key_exists($this->_topic->component, $schemadbs)) {
if (array_key_exists($this->_topic->component, $schemadbs)) {
$schemadb = $this->_topic->component;
} else {
$schemadb = 'default';
Expand Down Expand Up @@ -85,13 +82,6 @@ private function _load_controller()
);
break;

case 'createlink':
$this->_controller = midcom_helper_datamanager2_controller::create('create');
$this->_controller->schemadb =& $schemadb;
$this->_controller->schemaname = 'link';
$this->_controller->callback_object =& $this;
break;

default:
throw new midcom_error('Unable to process the request, unknown handler id');
}
Expand Down Expand Up @@ -136,10 +126,6 @@ public function _handler_edit($handler_id, array $args, array &$data)
} else {
$this->_topic->require_do('midgard:create');
$title = $this->_l10n->get('create folder');
if ($this->_handler_id == 'createlink') {
$this->_topic->require_do('midcom.admin.folder:symlinks');
$title = $this->_l10n->get('create folder link');
}
}
midcom::get()->head->set_pagetitle($title);

Expand All @@ -148,14 +134,8 @@ public function _handler_edit($handler_id, array $args, array &$data)

// Store the old name before editing
$this->old_name = $this->_topic->name;
// Symlink support requires that we use actual URL topic object here
$urltopics = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_URLTOPICS);
if ($urltopic = end($urltopics)) {
$this->old_name = $urltopic->name;
}

$this->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.admin.folder/folder.css');

midcom::get()->head->set_pagetitle($title);

$workflow = $this->get_workflow('datamanager2', array(
Expand All @@ -176,12 +156,6 @@ public function save_callback(midcom_helper_datamanager2_controller $controller)

private function _update_topic($prefix, $old_name)
{
if ( !empty($this->_topic->symlink)
&& !empty($this->_topic->component)) {
$this->_topic->symlink = null;
$this->_topic->update();
}

if ($_REQUEST['style'] === '__create') {
$this->_topic->style = $this->_create_style($this->_topic->name);

Expand All @@ -198,20 +172,6 @@ private function _update_topic($prefix, $old_name)
}
}

midcom::get()->auth->request_sudo('midcom.admin.folder');
// Because edit from a symlink edits its target, it is best to keep name properties in sync to get the expected behavior
$qb_topic = midcom_db_topic::new_query_builder();
$qb_topic->add_constraint('symlink', '=', $this->_topic->id);
foreach ($qb_topic->execute() as $symlink_topic) {
if ($symlink_topic->name !== $this->_topic->name) {
$symlink_topic->name = $this->_topic->name;
// This might fail if the URL name is already taken,
// but in such case we can just ignore it silently which keeps the original value
$symlink_topic->update();
}
}
midcom::get()->auth->drop_sudo();

midcom::get()->uimessages->add($this->_l10n->get('midcom.admin.folder'), $this->_l10n->get('folder saved'));

// Get the relocation url
Expand All @@ -220,54 +180,6 @@ private function _update_topic($prefix, $old_name)

private function _create_topic($prefix)
{
if (!empty($this->_new_topic->symlink)) {
$name = $this->_new_topic->name;
$target = $this->_new_topic;
while (!empty($target->symlink)) {
// Only direct symlinks are supported, but indirect symlinks are ok as we change them to direct ones here
$this->_new_topic->symlink = $target->symlink;
try {
$target = new midcom_db_topic($target->symlink);
} catch (midcom_error $e) {
debug_add("Could not get target for symlinked topic #{$this->_new_topic->id}: " .
$e->getMessage(), MIDCOM_LOG_ERROR);

$this->_new_topic->purge();
throw new midcom_error(
"Refusing to create this symlink because its target folder was not found: " .
$e->getMessage()
);
}
$name = $target->name;
}
if ($this->_new_topic->up == $target->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"
);
}
if ($this->_new_topic->up == $target->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."
);
}
$this->_new_topic->update();
if (!midcom_admin_folder_management::is_child_listing_finite($target)) {
$this->_new_topic->purge();
throw new midcom_error(
"Refusing to create this symlink because it would have created an
infinite loop situation."
);
}
$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
Expand Down
9 changes: 0 additions & 9 deletions lib/midcom/admin/folder/handler/move.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,6 @@ private function _move_object($target)
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."
);
}
// It was ok, so set name back now
$this->_object->name = $name;
$this->_object->update();
Expand Down
21 changes: 0 additions & 21 deletions lib/midcom/admin/folder/locale/default.de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,3 @@ Stilvorlage
---STRING objects with no navigation entry are still accessible on-site if the url is known
Objekte ohne Navigationseintrag sind weiterhin verfügbar, insofern die URL bekannt ist
---STRINGEND

---STRING createlink folder %s
Ordner-Link in "%s" anlegen
---STRINGEND

---STRING create folder link
Unterordner anlegen ("symlink")
---STRINGEND

---STRING privilege symlinks
Ordner-Link
---STRINGEND

---STRING this folder is a symlink to: <a href="%s">%s</a>
Dieser Ordner wurde von <a href="%s">%s</a> verlinkt.
---STRINGEND

---STRING symlinks are currently disabled
(Symlinks are currently disabled.)
---STRINGEND

21 changes: 0 additions & 21 deletions lib/midcom/admin/folder/locale/default.en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,3 @@ Style template
---STRING objects with no navigation entry are still accessible on-site if the url is known
Objects that are hidden from navigation are still accessible on-site if the URL is known
---STRINGEND

---STRING createlink folder %s
Create folder link under folder "%s"
---STRINGEND

---STRING create folder link
Create subfolder ("symlink")
---STRINGEND

---STRING privilege symlinks
Folder symlinks
---STRINGEND

---STRING this folder is a symlink to: <a href="%s">%s</a>
This folder is a symlink to: <a href="%s">%s</a>
---STRINGEND

---STRING symlinks are currently disabled
(Symlinks are currently disabled.)
---STRINGEND

21 changes: 0 additions & 21 deletions lib/midcom/admin/folder/locale/default.fi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,3 @@ Ulkoasupohja
---STRING style template
Ulkoasupohja
---STRINGEND

---STRING createlink folder %s
Luo kansiolinkki kansion "%s" alle
---STRINGEND

---STRING create folder link
Luo alikansio ("symlink")
---STRINGEND

---STRING privilege symlinks
Kansioiden symlinkit
---STRINGEND

---STRING this folder is a symlink to: <a href="%s">%s</a>
Tämä kansio on symlink kansioon: <a href="%s">%s</a>
---STRINGEND

---STRING symlinks are currently disabled
(Symlinkit on tällä hetkellä kytketty pois päältä.)
---STRINGEND

5 changes: 0 additions & 5 deletions lib/midcom/admin/folder/locale/default.hu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,3 @@ Mappák rendezése
---STRING sort pages
Oldalak rendezése
---STRINGEND

---STRING symlinks are currently disabled
(Symlinks are currently disabled.)
---STRINGEND

21 changes: 0 additions & 21 deletions lib/midcom/admin/folder/locale/default.pl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,3 @@ Szablon stylu
---STRING style template
Szablon stylu
---STRINGEND

---STRING createlink folder %s
Utwórz folder link w "%s"
---STRINGEND

---STRING create folder link
Utwórz folder ("symlink")
---STRINGEND

---STRING privilege symlinks
Folder link
---STRINGEND

---STRING this folder is a symlink to: <a href="%s">%s</a>
Ten folder jest linkiem do: <a href="%s">%s</a>
---STRINGEND

---STRING symlinks are currently disabled
(Symlinks are currently disabled.)
---STRINGEND

21 changes: 0 additions & 21 deletions lib/midcom/admin/folder/locale/default.sv.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,3 @@ Visa till (lämna tom för obegränsad visning)
---STRING schedule start
Publisera på (lämna tom för omedelbar publicering)
---STRINGEND

---STRING createlink folder %s
Skapa katalog länk under "%s"
---STRINGEND

---STRING create folder link
Skapa underkatalog ("symlink")
---STRINGEND

---STRING privilege symlinks
Katalog symlinkar
---STRINGEND

---STRING this folder is a symlink to: <a href="%s">%s</a>
Den här katalogen är en symlink till: <a href="%s">%s</a>
---STRINGEND

---STRING symlinks are currently disabled
(Symlinkar är inaktiva.)
---STRINGEND

Loading

0 comments on commit 9ba0d38

Please sign in to comment.