aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-30 14:31:34 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-30 14:31:34 +0000
commite82f9f21b5094e303d70b33d380c2ee1e68e8b66 (patch)
treedb6722f2c61132fec6d55361a032f32ffcda5b2b
parent5c13b26a250c5bd8cc18790d5b39fc46c86020f8 (diff)
downloadelgg-e82f9f21b5094e303d70b33d380c2ee1e68e8b66.tar.gz
elgg-e82f9f21b5094e303d70b33d380c2ee1e68e8b66.tar.bz2
Added friends picker callback
git-svn-id: https://code.elgg.org/elgg/trunk@1602 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--friends/pickercallback.php51
-rw-r--r--views/default/friends/picker.php42
-rw-r--r--views/default/friends/tablelist.php2
3 files changed, 88 insertions, 7 deletions
diff --git a/friends/pickercallback.php b/friends/pickercallback.php
new file mode 100644
index 000000000..b6e8c3d49
--- /dev/null
+++ b/friends/pickercallback.php
@@ -0,0 +1,51 @@
+<?php
+
+ /**
+ * Elgg friends picker callback
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+ // Get callback type (list or picker)
+ $type = get_input('type','picker');
+
+ // Get list of members if applicable
+ $members = get_input('members','');
+ if (!empty($members)) {
+ $members = explode(',',$members);
+ } else {
+ $members = array();
+ }
+
+ // Get page owner (bomb out if there isn't one)
+ $pageowner = page_owner_entity();
+ if (!$pageowner) { forward(); exit; }
+
+ // Depending on the view type, launch a different view
+ switch($type) {
+
+ case 'list':
+ $content = elgg_view('friends/tablelist',array('entities' => $members));
+ break;
+ default: $friends = $pageowner->getFriends('',9999);
+ $content = elgg_view('friends/picker',array(
+ 'entities' => $friends,
+ 'value' => $members,
+ 'callback' => true
+ ));
+ break;
+
+ }
+
+ // Output the content
+ echo $content;
+
+?> \ No newline at end of file
diff --git a/views/default/friends/picker.php b/views/default/friends/picker.php
index a17575f05..ca95c22bd 100644
--- a/views/default/friends/picker.php
+++ b/views/default/friends/picker.php
@@ -30,7 +30,14 @@
$vars['value'] = array($vars['value']);
}
}
-
+
+ // Initialise whether we're calling back or not
+ if (isset($vars['callback'])) {
+ $callback = $vars['callback'];
+ } else {
+ $callback = false;
+ }
+
// We need to count the number of friends pickers on the page.
global $friendspicker;
if (!isset($friendspicker)) $friendspicker = 0;
@@ -53,7 +60,9 @@
$users[$letter][$user->name] = $user;
}
-
+
+ if (!$callback) {
+
?>
<div class="friends_picker">
@@ -62,13 +71,19 @@
if (isset($vars['content'])) echo $vars['content'];
+
+?>
+
+ <div class="friends_picker_placeholder<?php echo $friendspicker; ?>">
+
+<?php
+
+ }
+
?>
-
-
-
<div class="friendsPicker_wrapper">
<div id="friendsPicker<?php echo $friendspicker; ?>">
<div class="friendsPicker_container">
@@ -152,8 +167,23 @@
?>
</div>
</div>
+ </div>
+
+<?php
+
+ if (!$callback) {
+
+?>
+
</div>
-</div>
+</div>
+
+
+<?php
+
+ }
+
+?>
<script type="text/javascript">
$(document).ready(function () {
diff --git a/views/default/friends/tablelist.php b/views/default/friends/tablelist.php
index a304e8fda..38f577a2d 100644
--- a/views/default/friends/tablelist.php
+++ b/views/default/friends/tablelist.php
@@ -25,7 +25,7 @@
$column = 0;
foreach($vars['entities'] as $entity) {
if (!($entity instanceof ElggEntity)) $entity = get_entity($entity);
- if ($entity) {
+ if ($entity instanceof ElggEntity) {
?>
<td style="width:25px">