Skip to content

Commit

Permalink
deprecate(discussion): Deprecates the elgg:discussion library
Browse files Browse the repository at this point in the history
Moves the function into start.php

Fixes Elgg#8760
  • Loading branch information
mrclay committed Jul 30, 2015
1 parent eacaee4 commit bf74181
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 44 deletions.
42 changes: 1 addition & 41 deletions mod/discussions/lib/discussion.php
@@ -1,43 +1,3 @@
<?php
/**
* Discussion function library
*/

/**
* Prepare discussion topic form variables
*
* @param ElggObject $topic Topic object if editing
* @return array
*/
function discussion_prepare_form_vars($topic = NULL) {
// input names => defaults
$values = array(
'title' => '',
'description' => '',
'status' => '',
'access_id' => ACCESS_DEFAULT,
'tags' => '',
'container_guid' => elgg_get_page_owner_guid(),
'guid' => null,
'topic' => $topic,
);

if ($topic) {
foreach (array_keys($values) as $field) {
if (isset($topic->$field)) {
$values[$field] = $topic->$field;
}
}
}

if (elgg_is_sticky_form('topic')) {
$sticky_values = elgg_get_sticky_values('topic');
foreach ($sticky_values as $key => $value) {
$values[$key] = $value;
}
}

elgg_clear_sticky_form('topic');

return $values;
}
elgg_deprecated_notice("The library 'elgg:discussion' is unneeded and will be removed.", "2.0");
41 changes: 39 additions & 2 deletions mod/discussions/start.php
Expand Up @@ -82,8 +82,6 @@ function discussion_init() {
*/
function discussion_page_handler($page) {

elgg_load_library('elgg:discussion');

if (!isset($page[0])) {
$page[0] = 'all';
}
Expand Down Expand Up @@ -581,3 +579,42 @@ function discussion_search_discussion($hook, $type, $value, $params) {
// trigger the 'normal' object search as it can handle the added options
return elgg_trigger_plugin_hook('search', 'object', $params, array());
}

/**
* Prepare discussion topic form variables
*
* @param ElggObject $topic Topic object if editing
* @return array
*/
function discussion_prepare_form_vars($topic = NULL) {
// input names => defaults
$values = array(
'title' => '',
'description' => '',
'status' => '',
'access_id' => ACCESS_DEFAULT,
'tags' => '',
'container_guid' => elgg_get_page_owner_guid(),
'guid' => null,
'topic' => $topic,
);

if ($topic) {
foreach (array_keys($values) as $field) {
if (isset($topic->$field)) {
$values[$field] = $topic->$field;
}
}
}

if (elgg_is_sticky_form('topic')) {
$sticky_values = elgg_get_sticky_values('topic');
foreach ($sticky_values as $key => $value) {
$values[$key] = $value;
}
}

elgg_clear_sticky_form('topic');

return $values;
}
2 changes: 1 addition & 1 deletion mod/discussions/views/default/resources/discussion/add.php
Expand Up @@ -13,7 +13,7 @@

$title = elgg_echo('discussion:addtopic');

elgg_push_breadcrumb($group->name, "discussion/owner/$group->guid");
elgg_push_breadcrumb($container->getDisplayName(), "discussion/owner/{$container->guid}");
elgg_push_breadcrumb($title);

$body_vars = discussion_prepare_form_vars();
Expand Down

0 comments on commit bf74181

Please sign in to comment.