aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-08-22 16:22:19 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-08-22 16:22:19 +0000
commit613748b75a9cd1f1b1939ab05c22e63407237984 (patch)
tree6378a1ee590a0798afea7a0a2627289711a03360
parent8a73785aee3e51c26c65053a4de7c5d7f0ebb673 (diff)
downloadelgg-613748b75a9cd1f1b1939ab05c22e63407237984.tar.gz
elgg-613748b75a9cd1f1b1939ab05c22e63407237984.tar.bz2
Merged [6600],[6601],[6605],[6606],[6607],[6608],[6611] from 1.7 branch into trunk
git-svn-id: http://code.elgg.org/elgg/trunk@6843 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/entities.php5
-rw-r--r--engine/lib/export.php4
-rw-r--r--engine/lib/input.php5
-rw-r--r--engine/lib/metadata.php22
-rw-r--r--engine/tests/objects/metadata.php1
-rw-r--r--mod/groups/views/default/forms/forums/edittopic.php3
-rw-r--r--mod/groups/views/default/object/groupforumtopic.php19
-rw-r--r--mod/groups/views/default/river/object/group/create.php13
-rw-r--r--views/foaf/page_elements/title.php10
-rw-r--r--views/json/page_elements/title.php10
-rw-r--r--views/rss/navigation/pagination.php9
-rw-r--r--views/rss/page_elements/title.php10
12 files changed, 34 insertions, 77 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 0f718d162..c34aea550 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -334,7 +334,8 @@ abstract class ElggEntity implements
} else {
unset($this->temp_metadata[$name]);
if ((int) $this->guid > 0) {
- return create_metadata($this->getGUID(), $name, $value, $value_type, $this->getOwner(), $this->getAccessID(), $multiple);
+ $result = create_metadata($this->getGUID(), $name, $value, $value_type, $this->getOwner(), $this->getAccessID(), $multiple);
+ return (bool)$result;
} else {
if (($multiple) && (isset($this->temp_metadata[$name]))) {
if (!is_array($this->temp_metadata[$name])) {
@@ -2511,7 +2512,7 @@ function disable_entity($guid, $reason = "", $recursive = true) {
if (trigger_elgg_event('disable',$entity->type,$entity)) {
if ($entity->canEdit()) {
if ($reason) {
- create_metadata($guid, 'disable_reason', $reason,'', 0, ACCESS_PUBLIC);
+ create_metadata($guid, 'disable_reason', $reason, '', 0, ACCESS_PUBLIC);
}
if ($recursive) {
diff --git a/engine/lib/export.php b/engine/lib/export.php
index c541b583b..1b09016b0 100644
--- a/engine/lib/export.php
+++ b/engine/lib/export.php
@@ -135,12 +135,14 @@ function get_entity_from_uuid($uuid) {
*
* @param int $guid
* @param string $uuid
+ * @return bool
*/
function add_uuid_to_guid($guid, $uuid) {
$guid = (int)$guid;
$uuid = sanitise_string($uuid);
- return create_metadata($guid, "import_uuid", $uuid);
+ $result = create_metadata($guid, "import_uuid", $uuid);
+ return (bool)$result;
}
diff --git a/engine/lib/input.php b/engine/lib/input.php
index 2ddc0e643..7e650c8de 100644
--- a/engine/lib/input.php
+++ b/engine/lib/input.php
@@ -65,10 +65,7 @@ function set_input($variable, $value) {
}
if (is_array($value)) {
- foreach ($value as $key => $val) {
- $value[$key] = trim($val);
- }
-
+ array_walk_recursive($value, create_function('&$v, $k', '$v = trim($v);'));
$CONFIG->input[trim($variable)] = $value;
} else {
$CONFIG->input[trim($variable)] = trim($value);
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 6e849cdd9..3ad774ad2 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -190,12 +190,13 @@ function remove_metadata($entity_guid, $name, $value = "") {
* @param int $owner_guid GUID of entity that owns the metadata
* @param int $access_id Default is ACCESS_PRIVATE
* @param bool $allow_multiple Allow multiple values for one key. Default is FALSE
- * @return bool
+ * @return int/bool id of metadata or FALSE if failure
*/
function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false) {
global $CONFIG;
$entity_guid = (int)$entity_guid;
+ // name and value are encoded in add_metastring()
//$name = sanitise_string(trim($name));
//$value = sanitise_string(trim($value));
$value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
@@ -203,6 +204,10 @@ function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid,
$owner_guid = (int)$owner_guid;
$allow_multiple = (boolean)$allow_multiple;
+ if (!isset($value)) {
+ return FALSE;
+ }
+
if ($owner_guid==0) {
$owner_guid = get_loggedin_userid();
}
@@ -212,14 +217,14 @@ function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid,
$id = false;
$existing = get_data_row("SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name) . " limit 1");
- if (($existing) && (!$allow_multiple) && (isset($value))) {
- $id = $existing->id;
+ if ($existing && !$allow_multiple) {
+ $id = (int)$existing->id;
$result = update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id);
if (!$result) {
return false;
}
- } else if (isset($value)) {
+ } else {
// Support boolean types
if (is_bool($value)) {
if ($value) {
@@ -243,19 +248,14 @@ function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid,
// If ok then add it
$id = insert_data("INSERT into {$CONFIG->dbprefix}metadata (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid, '$name','$value','$value_type', $owner_guid, $time, $access_id)");
- if ($id!==false) {
+ if ($id !== false) {
$obj = get_metadata($id);
if (trigger_elgg_event('create', 'metadata', $obj)) {
- return true;
+ return $id;
} else {
delete_metadata($id);
}
}
-
- } else if ($existing) {
- // TODO: Check... are you sure you meant to do this Ben? :)
- $id = $existing->id;
- delete_metadata($id);
}
return $id;
diff --git a/engine/tests/objects/metadata.php b/engine/tests/objects/metadata.php
index bc6523279..3595331e4 100644
--- a/engine/tests/objects/metadata.php
+++ b/engine/tests/objects/metadata.php
@@ -59,6 +59,7 @@ class ElggCoreMetadataTest extends ElggCoreUnitTest {
$this->create_metastring('metaUnitTest');
$this->create_metastring('tested');
+ // create_metadata returns id of metadata on success
$this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
// check value with improper case
diff --git a/mod/groups/views/default/forms/forums/edittopic.php b/mod/groups/views/default/forms/forums/edittopic.php
index 00145edce..089ba9882 100644
--- a/mod/groups/views/default/forms/forums/edittopic.php
+++ b/mod/groups/views/default/forms/forums/edittopic.php
@@ -29,7 +29,6 @@
echo elgg_view_title(elgg_echo("groups:edittopic"));
?>
-
<!-- display the input form -->
<form id="group_edittopic" action="<?php echo $vars['url']; ?>action/groups/edittopic" method="post">
<?php echo elgg_view('input/securitytoken'); ?>
@@ -98,4 +97,4 @@
<input type="submit" class="submit_button" value="<?php echo elgg_echo('save'); ?>" />
</p>
- </form>
+ </form> \ No newline at end of file
diff --git a/mod/groups/views/default/object/groupforumtopic.php b/mod/groups/views/default/object/groupforumtopic.php
index 9ebf81642..8c95dd594 100644
--- a/mod/groups/views/default/object/groupforumtopic.php
+++ b/mod/groups/views/default/object/groupforumtopic.php
@@ -25,7 +25,7 @@ if ($last_post) {
$u = get_user($last_user);
//select the correct output depending on where you are
-if(get_context() == "search"){
+if (get_context() == "search") {
var_export($counter);
if($counter == 1){
$info = "<p class='entity_subtext groups'>" . sprintf(elgg_echo('groups:forum:created:single'), $forum_created, $counter) . "<br />";
@@ -42,7 +42,7 @@ if(get_context() == "search"){
$info .= "<p class='entity_title'><b>" . elgg_echo('group') . ":</b> <a href=\"{$group->getURL()}\">".htmlentities($group->name, ENT_QUOTES, 'UTF-8') ."</a></p>";
}
-}else{
+} else {
if($counter == 1){
$info = "<p class='entity_subtext groups'>" . sprintf(elgg_echo('groups:forum:created:single'), $forum_created, $counter) . "</p>";
}else{
@@ -52,11 +52,20 @@ if(get_context() == "search"){
if (groups_can_edit_discussion($vars['entity'], page_owner_entity()->owner_guid)) {
// display the delete link to those allowed to delete
- $info .= "<div class='delete_button'>" . elgg_view("output/confirmlink", array(
+ $info .= "<div class='entity_metadata'>";
+ $info .= '<span class="entity_edit">' . elgg_view("output/url", array(
+ 'href' => $vars['url'] . "mod/groups/edittopic.php?group={$vars['entity']->container_guid}&topic={$vars['entity']->guid}",
+ 'text' => elgg_echo('edit'),
+ ));
+ $info .= '</span>';
+
+ // display the delete link to those allowed to delete
+ $info .= '<span class="delete_button">' . elgg_view("output/confirmlink", array(
'href' => $vars['url'] . "action/groups/deletetopic?topic=" . $vars['entity']->guid . "&group=" . $vars['entity']->container_guid,
- 'text' => " ",
+ 'text' => elgg_echo('delete'),
'confirm' => elgg_echo('deleteconfirm'),
- )) . "</div>";
+ ));
+ $info .= "</span></div>";
}
diff --git a/mod/groups/views/default/river/object/group/create.php b/mod/groups/views/default/river/object/group/create.php
deleted file mode 100644
index 94903fd66..000000000
--- a/mod/groups/views/default/river/object/group/create.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
- $statement = $vars['statement'];
- $performed_by = $statement->getSubject();
- $object = $statement->getObject();
-
- $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
- $string = sprintf(elgg_echo("group:river:created"),$url) . " ";
- $string .= "<a href=\"" . $object->getURL() . "\">" . elgg_echo("group:river:create") . "</a>";
-
-?>
-
-<?php echo $string; ?> \ No newline at end of file
diff --git a/views/foaf/page_elements/title.php b/views/foaf/page_elements/title.php
deleted file mode 100644
index 041b15477..000000000
--- a/views/foaf/page_elements/title.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-/**
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
-
-// this viewtype needs empty title \ No newline at end of file
diff --git a/views/json/page_elements/title.php b/views/json/page_elements/title.php
deleted file mode 100644
index 041b15477..000000000
--- a/views/json/page_elements/title.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-/**
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
-
-// this viewtype needs empty title \ No newline at end of file
diff --git a/views/rss/navigation/pagination.php b/views/rss/navigation/pagination.php
deleted file mode 100644
index 8037c1a31..000000000
--- a/views/rss/navigation/pagination.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * View to output nothing in RSS pagination.
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
diff --git a/views/rss/page_elements/title.php b/views/rss/page_elements/title.php
deleted file mode 100644
index 041b15477..000000000
--- a/views/rss/page_elements/title.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-/**
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
-
-// this viewtype needs empty title \ No newline at end of file