diff options
Diffstat (limited to 'pages/tasks')
-rw-r--r-- | pages/tasks/edit_task.php | 62 | ||||
-rw-r--r-- | pages/tasks/friends.php | 33 | ||||
-rw-r--r-- | pages/tasks/new_task.php | 48 | ||||
-rw-r--r-- | pages/tasks/owner.php | 58 | ||||
-rw-r--r-- | pages/tasks/view.php | 71 | ||||
-rw-r--r-- | pages/tasks/world.php | 41 |
6 files changed, 313 insertions, 0 deletions
diff --git a/pages/tasks/edit_task.php b/pages/tasks/edit_task.php new file mode 100644 index 000000000..646418761 --- /dev/null +++ b/pages/tasks/edit_task.php @@ -0,0 +1,62 @@ +<?php +/** + * Edit a task + * + * @package ElggTasks + */ + +gatekeeper(); + +$task_guid = (int)get_input('guid'); +$task = get_entity($task_guid); +if (!$task) { + +} + +$container = $task->getContainerEntity(); +if (!$container) { + +} + +$list = get_entity($task->list_guid); +if (!$list) { + +} + +elgg_set_page_owner_guid($container->getGUID()); + +if (elgg_instanceof($container, 'user')) { + elgg_push_breadcrumb($container->name, "tasks/owner/$container->username/"); +} elseif (elgg_instanceof($container, 'group')) { + elgg_push_breadcrumb($container->name, "tasks/group/$container->guid/all"); +} +if($list) { + elgg_push_breadcrumb($list->title, "tasks/view/$list->guid/$list->title"); +} +elgg_push_breadcrumb($task->title, $task->getURL()); +elgg_push_breadcrumb(elgg_echo('edit')); + +$title = elgg_echo("tasks:edit"); + +if ($task->canEdit()) { + $vars = array( + 'guid' => $task_guid, + 'container_guid' => $container->guid, + ); + + foreach(array_keys(elgg_get_config('tasks')) as $variable){ + $vars[$variable] = $task->$variable; + } + + $content = elgg_view_form('tasks/edit', array(), $vars); +} else { + $content = elgg_echo("tasks:noaccess"); +} + +$body = elgg_view_layout('content', array( + 'filter' => '', + 'content' => $content, + 'title' => $title, +)); + +echo elgg_view_page($title, $body); diff --git a/pages/tasks/friends.php b/pages/tasks/friends.php new file mode 100644 index 000000000..cda0d6788 --- /dev/null +++ b/pages/tasks/friends.php @@ -0,0 +1,33 @@ +<?php +/** + * List a user's friends' tasks + * + * @package ElggTasks + */ + +$owner = elgg_get_page_owner_entity(); +if (!elgg_instanceof($owner, 'user')) { + forward('tasks/all'); +} + +elgg_register_title_button('tasks', 'add'); + +elgg_push_breadcrumb($owner->name, "tasks/owner/$owner->username"); +elgg_push_breadcrumb(elgg_echo('friends')); + +$title = elgg_echo('tasks:friends'); + +$content = list_user_friends_objects($owner->guid, 'task', 10, false); +if (!$content) { + $content = elgg_echo('tasks:none'); +} + +$params = array( + 'filter_context' => 'friends', + 'content' => $content, + 'title' => $title, +); + +$body = elgg_view_layout('content', $params); + +echo elgg_view_page($title, $body); diff --git a/pages/tasks/new_task.php b/pages/tasks/new_task.php new file mode 100644 index 000000000..06a98466d --- /dev/null +++ b/pages/tasks/new_task.php @@ -0,0 +1,48 @@ +<?php +/** + * Create a new task + * + * @package ElggTasks + */ + +gatekeeper(); + +$list_guid = (int) get_input('guid'); +$list = get_entity($list_guid); +if (!$list) { +} + +if (elgg_instanceof($list, 'object', 'task') || elgg_instanceof($list, 'object', 'tasklist')) { + $container = $list->getContainerEntity(); + if (!$container) { + $container = elgg_get_logged_in_user_guid(); + } +} elseif (elgg_instanceof($list, 'user') || elgg_instanceof($list, 'group')) { + $container = $list; + // not a real list + $list_guid = null; +} + +elgg_set_page_owner_guid($container->getGUID()); + +if (elgg_instanceof($container, 'user')) { + elgg_push_breadcrumb($container->name, "tasks/owner/$container->username/"); +} elseif (elgg_instanceof($container, 'group')) { + elgg_push_breadcrumb($container->name, "tasks/group/$container->guid/all"); +} + +$title = elgg_echo('tasks:add'); +elgg_push_breadcrumb($title); + + +$vars = task_prepare_form_vars(null, $list_guid); + +$content = elgg_view_form('tasks/edit', array(), $vars); + +$body = elgg_view_layout('content', array( + 'filter' => '', + 'content' => $content, + 'title' => $title, +)); + +echo elgg_view_page($title, $body); diff --git a/pages/tasks/owner.php b/pages/tasks/owner.php new file mode 100644 index 000000000..801c00be9 --- /dev/null +++ b/pages/tasks/owner.php @@ -0,0 +1,58 @@ +<?php +/** + * List a user's or group's tasks + * + * @package ElggTasks + */ + +$owner = elgg_get_page_owner_entity(); +if (!$owner) { + forward('tasks/all'); +} + +// access check for closed groups +group_gatekeeper(); + +$title = elgg_echo('tasks:lists:owner', array($owner->name)); + +elgg_push_breadcrumb($owner->name); + +elgg_register_title_button('tasks', 'add'); + +$options = array( + 'type' => 'object', + 'subtypes' => 'task', + 'container_guid' => elgg_get_page_owner_guid(), + 'full_view' => false, + 'metadata_name' => 'list_guid', + 'metadata_value' => 0, +); + +$content = elgg_list_entities_from_metadata($options); + +if (!$content) { + $content = '<p>' . elgg_echo('tasks:none') . '</p>'; +} + +$filter_context = ''; +if (elgg_get_page_owner_guid() == elgg_get_logged_in_user_guid()) { + $filter_context = 'mine'; +} + +$sidebar = elgg_view('tasks/sidebar/navigation'); +$sidebar .= elgg_view('tasks/sidebar'); + +$params = array( + 'filter_context' => $filter_context, + 'content' => $content, + 'title' => $title, + 'sidebar' => $sidebar, +); + +if (elgg_instanceof($owner, 'group')) { + $params['filter'] = ''; +} + +$body = elgg_view_layout('content', $params); + +echo elgg_view_page($title, $body); diff --git a/pages/tasks/view.php b/pages/tasks/view.php new file mode 100644 index 000000000..51759dda1 --- /dev/null +++ b/pages/tasks/view.php @@ -0,0 +1,71 @@ +<?php +/** + * View a single task + * + * @package ElggTasks + */ + +$guid = get_input('guid'); +$entity = get_entity($guid); +if (!$entity) { + forward(); +} + +$container = $entity->getContainerEntity(); +$list = get_entity($entity->list_guid); + +elgg_set_page_owner_guid($container->guid); + +group_gatekeeper(); + +if (!$container) { +} + +$title = $entity->title; + +// bread crumbs +if (elgg_instanceof($container, 'user')) { + elgg_push_breadcrumb($container->name, "tasks/owner/$container->username/"); +} elseif (elgg_instanceof($container, 'group')) { + elgg_push_breadcrumb($container->name, "tasks/group/$container->guid/all"); +} + +$crumbs = array(); +while($list && !($list instanceof ElggUser || $list instanceof ElggGroup)) { + array_unshift($crumbs, $list); + $list = get_entity($list->list_guid); +} +foreach($crumbs as $crumb) { + elgg_push_breadcrumb($crumb->title, $crumb->getURL()); +} +elgg_push_breadcrumb($title); + +// content +$content = elgg_view_entity($entity, array('full_view' => true)); + +//if (!elgg_instanceof($entity, 'object', 'task') && $container->canWriteToContainer(0, 'object', 'task')) { +if ($container->canWriteToContainer(0, 'object', 'task')) { + elgg_load_js('elgg.tasks'); + + $url = "tasks/add/$entity->guid"; + elgg_register_menu_item('title', array( + 'name' => 'subtask', + 'href' => $url, + 'text' => elgg_echo('tasks:newchild'), + 'link_class' => 'elgg-button elgg-button-action', + )); + + $can_comment = $entity->canEdit(); + $content .= elgg_view_comments($entity, $can_comment); +} +/*} elseif (elgg_instanceof($entity, 'object', 'task')) { +}*/ + +$body = elgg_view_layout('content', array( + 'filter' => '', + 'content' => $content, + 'title' => $title, + 'sidebar' => elgg_view('tasks/sidebar/navigation', array('entity' => $entity)), +)); + +echo elgg_view_page($title, $body); diff --git a/pages/tasks/world.php b/pages/tasks/world.php new file mode 100644 index 000000000..93dcb2762 --- /dev/null +++ b/pages/tasks/world.php @@ -0,0 +1,41 @@ +<?php +/** + * List all tasks + * + * @package ElggTasks + */ + +$title = elgg_echo('tasks:all'); + +elgg_pop_breadcrumb(); +elgg_push_breadcrumb(elgg_echo('tasks')); + +$lists = elgg_get_entities_from_metadata(array( + 'type' => 'object', + 'subtype' => 'task', + 'count' => true, + 'metadata_name' => 'list_guid', + 'metadata_value' => 0, +)); + +elgg_register_title_button('tasks', 'add'); + +$content = elgg_list_entities_from_metadata(array( + 'type' => 'object', + 'subtype' => 'task', + 'full_view' => false, + 'metadata_name' => 'list_guid', + 'metadata_value' => 0, +)); +if (!$content) { + $content = '<p>' . elgg_echo('tasks:none') . '</p>'; +} + +$body = elgg_view_layout('content', array( + 'filter_context' => 'all', + 'content' => $content, + 'title' => $title, + 'sidebar' => elgg_view('tasks/sidebar'), +)); + +echo elgg_view_page($title, $body); |