function bookmarks_pagesetup()
{
    global $CONFIG;
    // Set up menu for logged in users
    //add submenu options
    if (get_context() == "bookmarks") {
        if (isloggedin()) {
            add_submenu_item(elgg_echo('bookmarks:inbox'), $CONFIG->wwwroot . "pg/bookmarks/" . $_SESSION['user']->username . "/inbox");
            if (page_owner()) {
                $page_owner = page_owner_entity();
                add_submenu_item(sprintf(elgg_echo('bookmarks:read'), $page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/" . $page_owner->username . "/items");
            }
            if (!$page_owner instanceof ElggGroup) {
                add_submenu_item(elgg_echo('bookmarks:friends'), $CONFIG->wwwroot . "pg/bookmarks/" . $_SESSION['user']->username . "/friends");
            }
        }
        //if(!$page_owner instanceof ElggGroup)
        //	add_submenu_item(elgg_echo('bookmarks:everyone'),$CONFIG->wwwroot."mod/bookmarks/everyone.php");
        // Bookmarklet
        if (isloggedin() && page_owner() && can_write_to_container(0, page_owner())) {
            $page_owner = page_owner_entity();
            $bmtext = elgg_echo('bookmarks:bookmarklet');
            if ($page_owner instanceof ElggGroup) {
                $bmtext = elgg_echo('bookmarks:bookmarklet:group');
            }
            add_submenu_item($bmtext, $CONFIG->wwwroot . "pg/bookmarks/{$page_owner->username}/bookmarklet");
        }
    }
    $page_owner = page_owner_entity();
    if ($page_owner instanceof ElggGroup && get_context() == 'groups') {
        if ($page_owner->bookmarks_enable != "no") {
            add_submenu_item(sprintf(elgg_echo("bookmarks:group"), $page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/" . $page_owner->username . '/items');
        }
    }
}
function blog_pagesetup()
{
    global $CONFIG;
    //add submenu options
    if (get_context() == "blog") {
        $page_owner = page_owner_entity();
        if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) {
            add_submenu_item(elgg_echo('blog:your'), $CONFIG->wwwroot . "pg/blog/" . $_SESSION['user']->username);
            add_submenu_item(elgg_echo('blog:friends'), $CONFIG->wwwroot . "pg/blog/" . $_SESSION['user']->username . "/friends/");
            add_submenu_item(elgg_echo('blog:everyone'), $CONFIG->wwwroot . "mod/blog/everyone.php");
        } else {
            if (page_owner()) {
                add_submenu_item(sprintf(elgg_echo('blog:user'), $page_owner->name), $CONFIG->wwwroot . "pg/blog/" . $page_owner->username);
                if ($page_owner instanceof ElggUser) {
                    // Sorry groups, this isn't for you.
                    add_submenu_item(sprintf(elgg_echo('blog:user:friends'), $page_owner->name), $CONFIG->wwwroot . "pg/blog/" . $page_owner->username . "/friends/");
                }
                add_submenu_item(elgg_echo('blog:everyone'), $CONFIG->wwwroot . "mod/blog/everyone.php");
            } else {
                add_submenu_item(elgg_echo('blog:everyone'), $CONFIG->wwwroot . "mod/blog/everyone.php");
            }
        }
        if (can_write_to_container(0, page_owner()) && isloggedin()) {
            add_submenu_item(elgg_echo('blog:addpost'), $CONFIG->wwwroot . "pg/blog/{$page_owner->username}/new/");
        }
        if (!defined('everyoneblog') && page_owner()) {
            if ($dates = get_entity_dates('object', 'blog', page_owner())) {
                foreach ($dates as $date) {
                    $timestamplow = mktime(0, 0, 0, substr($date, 4, 2), 1, substr($date, 0, 4));
                    $timestamphigh = mktime(0, 0, 0, (int) substr($date, 4, 2) + 1, 1, substr($date, 0, 4));
                    if (!isset($page_owner)) {
                        $page_owner = page_owner_entity();
                    }
                    $link = $CONFIG->wwwroot . 'pg/blog/' . $page_owner->username . '/archive/' . $timestamplow . '/' . $timestamphigh;
                    add_submenu_item(sprintf(elgg_echo('date:month:' . substr($date, 4, 2)), substr($date, 0, 4)), $link, 'filter');
                }
            }
        }
    }
    // Group submenu
    $page_owner = page_owner_entity();
    if ($page_owner instanceof ElggGroup && get_context() == 'groups') {
        if ($page_owner->blog_enable != "no") {
            add_submenu_item(sprintf(elgg_echo("blog:group"), $page_owner->name), $CONFIG->wwwroot . "pg/blog/" . $page_owner->username);
        }
    }
}
Example #3
0
function group_menus_izap_contest()
{
    global $CONFIG;
    $pageowner = elgg_get_page_owner_entity();
    // if the page owner is group and context is group
    if ($pageowner instanceof ElggGroup && (get_context() == 'groups' || get_context() == GLOBAL_IZAP_CONTEST_QUIZ_PAGEHANDLER || get_context() == GLOBAL_IZAP_CONTEST_CHALLENGE_PAGEHANDLER) && ($pageowner->izapchallenge_enable == 'yes' || empty($pageowner->izapchallenge_enable))) {
        if (can_write_to_container(elgg_get_logged_in_user_guid(), $pageowner->guid)) {
            //elgg_register_menu_item('page', new ElggMenuItem('izap-contest:challenge:group:add',
            //                elgg_echo('izap-contest:challenge:group:add'),
            //                izapbase::setHref(array(
            //                    'context' => GLOBAL_IZAP_CONTEST_CHALLENGE_PAGEHANDLER,
            //                    'action' => 'add',
            //                    'page_owner' => false,
            //                    'vars' => array($pageowner->username
            //                    )
            //                        )
            //                )
            //        )
            //);
        }
        elgg_register_menu_item('page', new ElggMenuItem('izap-contest:challenge:group:list', elgg_echo('izap-contest:challenge:group:list'), IzapBase::setHref(array('context' => GLOBAL_IZAP_CONTEST_CHALLENGE_PAGEHANDLER, 'action' => 'list', 'page_owner' => false, 'vars' => array($pageowner->guid, $pageowner->username)))));
    }
}
Example #4
0
$list_completed = (bool) elgg_extract('list_completed', $vars, true);
// only applies to full view
if (empty($entity) || !elgg_instanceof($entity, 'object', TodoList::SUBTYPE)) {
    return;
}
if (!$full) {
    echo '<div class="todos-list-item">';
    echo '<h3>' . elgg_view('output/url', array('text' => $entity->title, 'href' => $entity->getURL(), 'is_trusted' => true)) . '</h3>';
    echo elgg_view_menu('todolist', array('entity' => $entity, 'class' => 'elgg-menu-hz elgg-menu-todos', 'sort_by' => 'register'));
    echo '</div>';
}
$options = array('type' => 'object', 'subtype' => TodoItem::SUBTYPE, 'limit' => false, 'full_view' => false, 'pagination' => false, 'item_class' => 'todos-list-item', 'list_class' => 'todos-list todos-list-todoitem elgg-todo-' . $entity->guid, 'container_guid' => $entity->getGUID());
if (!$show_completed) {
    $options['order_by_metadata'] = array('name' => 'order', 'as' => 'integer');
}
if (can_write_to_container(null, $entity->getContainerGUID())) {
    $options['list_class'] .= ' todos-sortable';
}
$active_todos = elgg_list_entities_from_metadata($options);
echo $active_todos;
if ($entity->canWriteToContainer(0, 'object', TodoItem::SUBTYPE)) {
    elgg_load_js("lightbox");
    elgg_load_css("lightbox");
    elgg_load_js('elgg.userpicker');
    elgg_load_js('jquery.ui.autocomplete.html');
    if (empty($active_todos) && !$full) {
        // add an empty place to drop todos from other lists
        echo "<ul class='elgg-list todos-list todos-list-todoitem todos-sortable elgg-todo-{$entity->guid}'></ul>";
    }
    echo '<div>';
    echo elgg_view('output/url', array('text' => elgg_echo('todos:todoitem:add'), 'class' => 'elgg-lightbox mll', 'href' => 'ajax/view/todos/todoitem/form?container_guid=' . $entity->getGUID()));
Example #5
0
elgg_make_sticky_form('answer');
$guid = (int) get_input('guid');
$answer = new ElggAnswer($guid);
$adding = !$answer->guid;
$editing = !$adding;
if ($editing && !$answer->canEdit()) {
    register_error(elgg_echo('InvalidParameterException:NoEntityFound'));
    forward(REFERER);
}
$container_guid = (int) get_input('container_guid');
$description = get_input('description');
if (empty($container_guid) || empty($description)) {
    register_error(elgg_echo('questions:action:answer:save:error:body', [$container_guid, $description]));
    forward(REFERER);
}
if ($adding && !can_write_to_container(0, $container_guid, 'object', 'answer')) {
    register_error(elgg_echo('questions:action:answer:save:error:container'));
    forward(REFERER);
}
$question = get_entity($container_guid);
if (empty($question) || !$question instanceof ElggQuestion) {
    register_error(elgg_echo('ClassException:ClassnameNotClass', [$container_guid, elgg_echo('item:object:question')]));
    forward(REFERER);
}
if ($question->getStatus() != 'open') {
    elgg_clear_sticky_form('answer');
    register_error(elgg_echo('questions:action:answer:save:error:question_closed'));
    forward(REFERER);
}
$answer->description = $description;
$answer->access_id = $question->access_id;
Example #6
0
<?php

/**
 * Shows the overview page of the FFD Cafe
 *
 * @package theme_ffd
 */
elgg_push_context("cafe");
if (elgg_is_logged_in() && can_write_to_container()) {
    $add = elgg_view_form('theme_ffd/cafe', array('name' => 'cafe', 'action' => 'action/cafe/save'), array('collapsable' => true));
} else {
    $add = "";
}
$options = array('type' => 'object', 'subtype' => 'cafe', 'order_by' => 'last_action DESC', 'full_view' => false);
$owner = get_input('owner');
if ($owner) {
    $owner = get_user_by_username($owner);
}
if ($owner) {
    $options['owner_guid'] = $owner->guid;
    $filter_context = 'mine';
} else {
    $filter_context = 'all';
}
$purpose = get_input('purpose');
if (in_array($purpose, array('search', 'share', 'experience'))) {
    $options['metadata_name_value_pairs'] = array(array('name' => 'purpose', 'value' => $purpose));
    $getter = 'elgg_get_entities_from_metadata';
} else {
    $getter = 'elgg_get_entities';
}
Example #7
0
/**
 * Sets up submenus for the file system.  Triggered on pagesetup.
 *
 */
function file_submenus()
{
    global $CONFIG;
    $page_owner = page_owner_entity();
    // Group submenu option
    if ($page_owner instanceof ElggGroup && get_context() == "groups") {
        if ($page_owner->files_enable != "no") {
            add_submenu_item(sprintf(elgg_echo("file:group"), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
        }
    }
    // General submenu options
    if (get_context() == "file") {
        if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) {
            add_submenu_item(sprintf(elgg_echo("file:yours"), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
            add_submenu_item(sprintf(elgg_echo('file:yours:friends'), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username . "/friends/");
        } else {
            if (page_owner()) {
                add_submenu_item(sprintf(elgg_echo("file:user"), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
                if ($page_owner instanceof ElggUser) {
                    // This one's for users, not groups
                    add_submenu_item(sprintf(elgg_echo('file:friends'), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username . "/friends/");
                }
            }
        }
        add_submenu_item(elgg_echo('file:all'), $CONFIG->wwwroot . "mod/file/world.php");
        if (can_write_to_container($_SESSION['guid'], page_owner())) {
            add_submenu_item(elgg_echo('file:upload'), $CONFIG->wwwroot . "pg/file/" . $page_owner->username . "/new/");
        }
    }
}
Example #8
0
<?php

$page_owner = elgg_get_page_owner_entity();
if (empty($page_owner)) {
    forward(REFERER);
}
if ($page_owner instanceof ElggGroup) {
    poll_container_gatekeeper($page_owner);
    elgg_group_gatekeeper();
}
// breadcrumb
elgg_push_breadcrumb($page_owner->name);
if (poll_is_enabled_for_container($page_owner)) {
    // check if add button is allowed
    if (can_write_to_container(0, $page_owner->getGUID(), 'object', Poll::SUBTYPE)) {
        elgg_register_title_button();
    }
}
// build page elements
$title = elgg_echo('poll:owner:title', [$page_owner->name]);
$options = ['type' => 'object', 'subtype' => Poll::SUBTYPE, 'no_results' => elgg_echo('poll:none')];
if ($page_owner instanceof ElggUser) {
    $options['owner_guid'] = $page_owner->getGUID();
    $options['preload_containers'] = true;
} elseif ($page_owner instanceof ElggGroup) {
    $options['container_guid'] = $page_owner->getGUID();
    $options['preload_owners'] = true;
}
$contents = elgg_list_entities($options);
// build page
$page_data = elgg_view_layout('content', ['title' => $title, 'content' => $contents, 'filter' => $page_owner instanceof ElggGroup ? '' : null, 'filter_context' => $page_owner->getGUID === elgg_get_logged_in_user_guid() ? 'mine' : '']);
Example #9
0
 /**
  * Can a user add an entity to this container
  *
  * @param int    $user_guid The GUID of the user creating the entity (0 for logged in user).
  * @param string $type      The type of entity we're looking to write
  * @param string $subtype   The subtype of the entity we're looking to write
  *
  * @return bool
  * @see elgg_set_ignore_access()
  */
 public function canWriteToContainer($user_guid = 0, $type = 'all', $subtype = 'all')
 {
     return can_write_to_container($user_guid, $this->guid, $type, $subtype);
 }
Example #10
0
/**
 * Extend container permissions checking to extend can_write_to_container for write users.
 *
 * @param string $hook
 * @param string $entity_type
 * @param bool   $returnvalue
 * @param array  $params
 *
 * @return bool
 */
function pages_container_permission_check($hook, $entity_type, $returnvalue, $params)
{
    if (elgg_get_context() != "pages") {
        return null;
    }
    if (elgg_get_page_owner_guid() && can_write_to_container(elgg_get_logged_in_user_guid(), elgg_get_page_owner_guid())) {
        return true;
    }
    if ($page_guid = get_input('page_guid', 0)) {
        $entity = get_entity($page_guid);
    } elseif ($parent_guid = get_input('parent_guid', 0)) {
        $entity = get_entity($parent_guid);
    }
    if (isset($entity) && pages_is_page($entity)) {
        if (can_write_to_container(elgg_get_logged_in_user_guid(), $entity->container_guid) || in_array($entity->write_access_id, get_access_list())) {
            return true;
        }
    }
}
Example #11
0
}
$adding = !$question->guid;
$editing = !$adding;
$moving = false;
if ($editing && !$question->canEdit()) {
    register_error(elgg_echo('InvalidParameterException:NoEntityFound'));
    forward(REFERER);
}
$container_guid = (int) get_input('container_guid');
if (empty($container_guid)) {
    $container_guid = (int) $question->owner_guid;
}
if ($editing && $container_guid != $question->getContainerGUID()) {
    $moving = true;
}
if ($adding && !can_write_to_container(0, $container_guid, 'object', 'question')) {
    register_error(elgg_echo('questions:action:question:save:error:container'));
    forward(REFERER);
}
if (questions_limited_to_groups() && $container_guid == $question->owner_guid) {
    register_error(elgg_echo('questions:action:question:save:error:limited_to_groups'));
    forward(REFERER);
}
$title = get_input('title');
$description = get_input('description');
$tags = string_to_tag_array(get_input('tags', ''));
$access_id = (int) get_input('access_id');
if (empty($container_guid) || empty($title) || empty($description)) {
    register_error(elgg_echo('questions:action:question:save:error:body', array($container_guid, $title, $description)));
    forward(REFERER);
}
Example #12
0
     break;
 case 'summary':
     echo '<div class="summary">';
     echo elgg_trigger_plugin_hook('markdown_wiki_edit', 'summary', $vars['guid'], '');
     echo '<label>' . elgg_echo("markdown_wiki:{$name}") . '</label>';
     echo elgg_view("input/{$type}", array('name' => $name, 'value' => $vars[$name]));
     echo elgg_view("input/checkbox", array('name' => 'minorchange'));
     echo elgg_echo('markdown_wiki:minorchange');
     echo '</div>';
     break;
 case 'tags':
     break;
 case 'write_access_id':
     if ($user) {
         $entity = get_entity($vars['guid']);
         if (!$vars['guid'] && can_write_to_container($user, $vars['container_guid'], 'object', 'markdown_wiki') || $entity && $entity->canEdit($user_guid)) {
             $list = get_write_access_array();
             $list[0] = elgg_echo('markdown_wiki:access:private');
             unset($list[2]);
             // no public.
             echo '<div>';
             echo '<label>' . elgg_echo("markdown_wiki:{$name}") . '</label><br/>';
             echo elgg_view("input/{$type}", array('name' => $name, 'value' => $vars[$name], 'options_values' => $list));
             echo '</div>';
         }
     }
     break;
 case 'title':
     echo elgg_view("input/{$type}", array('name' => $name, 'value' => $vars[$name]));
     break;
 case 'guid':
Example #13
0
$question = new ElggQuestion($guid);
$adding = !$question->guid;
$editing = !$adding;
$moving = false;
if ($editing && !$question->canEdit()) {
    register_error(elgg_echo("InvalidParameterException:NoEntityFound"));
    forward(REFERER);
}
$container_guid = (int) get_input("container_guid");
if (empty($container_guid)) {
    $container_guid = (int) $question->owner_guid;
}
if ($editing && $container_guid != $question->getContainerGUID()) {
    $moving = true;
}
if ($adding && !can_write_to_container(0, $container_guid, "object", "question")) {
    register_error(elgg_echo("questions:action:question:save:error:container"));
    forward(REFERER);
}
if (questions_limited_to_groups() && $container_guid == $question->owner_guid) {
    register_error(elgg_echo("questions:action:question:save:error:limited_to_groups"));
    forward(REFERER);
}
$title = get_input("title");
$description = get_input("description");
$tags = string_to_tag_array(get_input("tags", ""));
$access_id = (int) get_input("access_id");
if (empty($container_guid) || empty($title) || empty($description)) {
    register_error(elgg_echo("questions:action:question:save:error:body", array($container_guid, $title, $description)));
    forward(REFERER);
}
Example #14
0
    // Otherwise, save the question
} else {
    $question = new ElggObject();
    $question->subtype = "question";
    //$question->access_id = $access;
    $question->access_id = ACCESS_PUBLIC;
    $question->title = $title;
    $question->description = $body;
    // check if user can add question to group
    if ($container_guid && $container_guid != $_SESSION['guid']) {
        $question->container_guid = $container_guid;
        $group = get_entity($container_guid);
        if (!$group instanceof ElggGroup) {
            forward();
        }
        if (!can_write_to_container($_SESSION['guid'], $container_guid)) {
            forward();
        }
        if ($group->content_access == ACCESS_PRIVATE) {
            $question->access_id = $group->group_acl;
        }
    }
    if (!$question->save()) {
        register_error(elgg_echo("answers:question:saveerror"));
        forward("mod/answers/add.php");
    }
    if (is_array($tagarray)) {
        $question->tags = $tagarray;
    }
    // Success message
    system_message(elgg_echo("answers:question:posted"));
function publication_pagesetup()
{
    global $CONFIG;
    //add submenu options
    if (get_context() == "publications") {
        $page_owner = page_owner_entity();
        if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) {
            add_submenu_item(elgg_echo('publication:everyone'), $CONFIG->wwwroot . "mod/publications/everyone.php");
        } else {
            if (page_owner()) {
                add_submenu_item(sprintf(elgg_echo('publication:user'), $page_owner->name), $CONFIG->wwwroot . "pg/publications/" . $page_owner->username);
                if ($page_owner instanceof ElggUser) {
                    if (get_loggedin_user() == $page_owner) {
                        add_submenu_item(sprintf(elgg_echo('publication:user:friends'), $page_owner->name), $CONFIG->wwwroot . "pg/publications/" . $page_owner->username . "/friends/");
                    }
                }
                add_submenu_item(elgg_echo('publication:everyone'), $CONFIG->wwwroot . "mod/publications/everyone.php");
            } else {
                add_submenu_item(elgg_echo('publication:everyone'), $CONFIG->wwwroot . "mod/publications/everyone.php");
            }
        }
        if (can_write_to_container(0, page_owner()) && isloggedin()) {
            add_submenu_item(elgg_echo('publication:add'), $CONFIG->wwwroot . "pg/publications/{$page_owner->username}/new/");
        }
    }
    // Group submenu
    $page_owner = page_owner_entity();
    if ($page_owner instanceof ElggGroup && get_context() == 'groups') {
        if ($page_owner->publication_enable != "no") {
            add_submenu_item(sprintf(elgg_echo("publication:group"), $page_owner->name), $CONFIG->wwwroot . "pg/publications/" . $page_owner->username);
        }
    }
}
 * 
 * @package ElggPages
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd
 * @copyright Curverider Ltd 2008-2010
 * @link http://elgg.com/
 */
require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php";
global $CONFIG;
// Add menus
$owner = page_owner_entity();
if (!$owner instanceof ElggGroup) {
    add_submenu_item(sprintf(elgg_echo("pages:user"), page_owner_entity()->name), $CONFIG->url . "pg/pages/owned/" . page_owner_entity()->username, 'pageslinksgeneral');
    add_submenu_item(elgg_echo('pages:all'), $CONFIG->wwwroot . "mod/pages/world.php", 'pageslinksgeneral');
}
if ($owner instanceof ElggEntity && can_write_to_container(0, $owner->guid)) {
    add_submenu_item(elgg_echo('pages:new'), $CONFIG->url . "pg/pages/new/?container_guid=" . page_owner(), 'pagesactions');
    if ($owner instanceof ElggUser) {
        add_submenu_item(elgg_echo('pages:welcome'), $CONFIG->url . "pg/pages/welcome/", 'pagesactions');
    }
}
if (is_callable('group_gatekeeper')) {
    group_gatekeeper();
}
$limit = get_input("limit", 10);
$offset = get_input("offset", 0);
if ($owner instanceof ElggGroup) {
    $title = sprintf(elgg_echo("pages:group"), $owner->name);
} else {
    $title = sprintf(elgg_echo("pages:user"), $owner->name);
}
Example #17
0
<?php

/**
 * Add comment form
 */
if (isset($vars['entity']) && elgg_is_logged_in()) {
    $container = get_entity($vars['entity']->container_guid);
    if (!$container instanceof ElggGroup || can_write_to_container(0, $container->getGUID())) {
        echo "<div class=\"answers_comment\">";
        echo "<div><a class=\"collapsibleboxlink\">" . elgg_echo('answers:comment:comment') . "</a></div>";
        echo "<div class=\"collapsible_box\">";
        $entity_guid = $vars['entity']->getGUID();
        $form_body = "<div class=\"answers_add_comment_wrapper\"><p class='longtext_editarea'>";
        $form_body .= elgg_view('input/longtext', array('name' => "comment_text{$entity_guid}")) . "</p>";
        $form_body .= "<p>" . elgg_view('input/hidden', array('name' => 'object_id', 'value' => $entity_guid));
        $form_body .= elgg_view('input/submit', array('value' => elgg_echo("answers:comment:save"))) . "</p></div>";
        echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$vars['url']}action/answers/comment/add"));
        echo "</div>";
        echo "</div>";
    }
}
Example #18
0
<?php

/**
 *	Elgg-markdown_wiki plugin
 *	@package elgg-markdown_wiki
 *	@author Emmanuel Salomon @ManUtopiK
 *	@license GNU Affero General Public License, version 3 or late
 *	@link https://github.com/ManUtopiK/elgg-markdown_wiki
 *
 *	Elgg-markdown_wiki sidebar
 **/
$container_guid = (int) get_input('container_guid', elgg_get_page_owner_guid());
$container = get_entity($container_guid);
if (!$container || !elgg_instanceof($container, 'group')) {
    $container_guid = 0;
}
// Search for article in group
$url = elgg_get_site_url() . 'wiki/search';
$body = elgg_view_form('markdown_wiki/search', array('action' => $url, 'method' => 'get', 'disable_security' => true), array('container_guid' => $container_guid));
if ($container && elgg_instanceof($container, 'group')) {
    if (can_write_to_container(elgg_get_logged_in_user_guid(), $container_guid, 'object', 'markdown_wiki')) {
        $createit = '<span class="elgg-subtext">' . elgg_echo('markdown_wiki:search_in_group:or_create') . '</span>';
    }
    echo elgg_view_module('aside', elgg_echo('markdown_wiki:search_in_group', array($createit)), $body);
} else {
    echo elgg_view_module('aside', elgg_echo('markdown_wiki:search_in_all_group'), $body);
}
echo elgg_view('markdown_wiki/sidebar_comments_block', array('subtypes' => array('markdown_wiki'), 'container_guid' => $container_guid));
echo elgg_view('markdown_wiki/sidebar_tagcloud_block', array('subtypes' => array('markdown_wiki'), 'container_guid' => $container_guid));
Example #19
0
        case 'tags':
            if ($value) {
                $values[$name] = string_to_tag_array($value);
            } else {
                unset($values[$name]);
            }
            break;
        case 'excerpt':
            if ($value) {
                $values[$name] = elgg_get_excerpt($value);
            }
            break;
        case 'container_guid':
            // this can't be empty or saving the base entity fails
            if (!empty($value)) {
                if (can_write_to_container($user->getGUID(), $value)) {
                    $values[$name] = $value;
                } else {
                    $error = elgg_echo("blog:error:cannot_write_to_container");
                }
            } else {
                unset($values[$name]);
            }
            break;
        default:
            $values[$name] = $value;
            break;
    }
}
// if preview, force status to be draft
if ($save == false) {
Example #20
0
/**
 * Return the write access for the current group if the user has write access to it.
 */
function groups_write_acl_plugin_hook($hook, $entity_type, $returnvalue, $params)
{
    $page_owner = page_owner_entity();
    if ($page_owner instanceof ElggGroup) {
        if (can_write_to_container()) {
            $returnvalue[$page_owner->group_acl] = elgg_echo('groups:group') . ": " . $page_owner->name;
            return $returnvalue;
        }
    }
}
Example #21
0
/**
 * Create a new entry in the entities table.
 *
 * Saves the base information in the entities table for the entity.  Saving
 * the type information is handled in the calling class method.
 *
 * @warning Plugin authors should never call this directly.  Always use entity objects.
 *
 * @warning Entities must have an entry in both the entities table and their type table
 * or they will throw an exception when loaded.
 *
 * @param string $type           The type of the entity (site, user, object, group).
 * @param string $subtype        The subtype of the entity.
 * @param int    $owner_guid     The GUID of the object's owner.
 * @param int    $access_id      The access control group to create the entity with.
 * @param int    $site_guid      The site to add this entity to. 0 for current.
 * @param int    $container_guid The container GUID
 *
 * @return int|false The new entity's GUID, or false on failure
 * @throws InvalidParameterException
 * @link http://docs.elgg.org/DataModel/Entities
 * @access private
 */
function create_entity($type, $subtype, $owner_guid, $access_id, $site_guid = 0, $container_guid = 0)
{
    global $CONFIG;
    $type = sanitise_string($type);
    $subtype_id = add_subtype($type, $subtype);
    $owner_guid = (int) $owner_guid;
    $access_id = (int) $access_id;
    $time = time();
    if ($site_guid == 0) {
        $site_guid = $CONFIG->site_guid;
    }
    $site_guid = (int) $site_guid;
    if ($container_guid == 0) {
        $container_guid = $owner_guid;
    }
    $user_guid = elgg_get_logged_in_user_guid();
    if (!can_write_to_container($user_guid, $owner_guid, $type, $subtype)) {
        return false;
    }
    if ($owner_guid != $container_guid) {
        if (!can_write_to_container($user_guid, $container_guid, $type, $subtype)) {
            return false;
        }
    }
    if ($type == "") {
        throw new InvalidParameterException(elgg_echo('InvalidParameterException:EntityTypeNotSet'));
    }
    return insert_data("INSERT into {$CONFIG->dbprefix}entities\n\t\t(type, subtype, owner_guid, site_guid, container_guid,\n\t\t\taccess_id, time_created, time_updated, last_action)\n\t\tvalues\n\t\t('{$type}',{$subtype_id}, {$owner_guid}, {$site_guid}, {$container_guid},\n\t\t\t{$access_id}, {$time}, {$time}, {$time})");
}
Example #22
0
/**
 * setups the submenus
 *
 * @global <type> $CONFIG
 */
function pageSetup_izap_videos()
{
    global $CONFIG;
    // get the page owner
    $pageowner = page_owner_entity();
    // if page owner is user and context is izap_videos
    if ($pageowner instanceof ElggUser && get_context() == 'videos') {
        if ($pageowner != get_loggedin_user()) {
            add_submenu_item(sprintf(elgg_echo('izap_videos:user'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/list/' . $pageowner->username, 'USER_IZAPVIDEOS');
            add_submenu_item(sprintf(elgg_echo('izap_videos:userfrnd'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/friends/' . $pageowner->username, 'USER_IZAPVIDEOS');
            add_submenu_item(sprintf(elgg_echo('izap_videos:user_favorites'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/favorites/' . $pageowner->username, 'USER_IZAPVIDEOS');
        }
        // for loggedin users only
        if (isloggedin()) {
            if ($pageowner instanceof ElggUser) {
                add_submenu_item(elgg_echo('izap_videos:add'), $CONFIG->wwwroot . 'pg/videos/add/' . get_loggedin_user()->username, 'IZAPVIDEOS');
            }
        }
    }
    // for all
    if (get_context() == GLOBAL_IZAP_VIDEOS_PAGEHANDLER) {
        if (isloggedin()) {
            add_submenu_item(sprintf(elgg_echo('izap_videos:videos'), get_loggedin_user()->name), $CONFIG->wwwroot . 'pg/videos/list/' . get_loggedin_user()->username, 'MY_IZAPVIDEOS');
            add_submenu_item(sprintf(elgg_echo('izap_videos:frnd'), get_loggedin_user()->name), $CONFIG->wwwroot . 'pg/videos/friends/' . get_loggedin_user()->username, 'MY_IZAPVIDEOS');
            add_submenu_item(elgg_echo('izap_videos:my_favorites'), $CONFIG->wwwroot . 'pg/videos/favorites/' . get_loggedin_user()->username, 'MY_IZAPVIDEOS');
        }
        add_submenu_item(elgg_echo('izap_videos:all'), $CONFIG->wwwroot . 'pg/videos/all', 'IZAPVIDEOS');
    }
    // if the page owner is group and context is group
    if ($pageowner instanceof ElggGroup && (get_context() == 'groups' || get_context() == 'videos') && ($pageowner->izap_videos_enable == 'yes' || empty($pageowner->izap_videos_enable))) {
        if (can_write_to_container(get_loggedin_userid(), $pageowner->guid, 'izap_videos')) {
            add_submenu_item(elgg_echo('izap_videos:addgroupVideo'), $CONFIG->wwwroot . 'pg/videos/add/' . $pageowner->username, 'IZAPVIDEOS');
        }
        add_submenu_item(sprintf(elgg_echo('izap_videos:user'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/list/' . $pageowner->username, 'IZAPVIDEOS');
    }
    // if the context is admin and is admin logged in
    if (get_context() == 'admin' && isadminloggedin()) {
        add_submenu_item(elgg_echo('izap_videos:adminSettings'), $CONFIG->wwwroot . 'pg/videos/adminSettings/' . get_loggedin_user()->username . '?option=settings', 'IZAPADMIN');
    }
}
Example #23
0
/**
 * Save a question action
 */
// Get input data
$title = get_input('title');
$description = get_input('description');
$tags = get_input('tags');
$container_guid = (int) get_input('container_guid');
$guid = (int) get_input('guid');
$access_id = get_input('access_id');
$user_guid = elgg_get_logged_in_user_guid();
if (is_null($access_id)) {
    $access_id = get_default_access($user_guid);
    $sysmsg = " failed to get access id";
}
if (!can_write_to_container($user_guid, $container_guid)) {
    register_error(elgg_echo('answers:error'));
    forward(REFERER);
}
elgg_make_sticky_form('question');
// Make sure the title / description aren't blank
if (empty($title)) {
    register_error(elgg_echo('answers:question:blank'));
    forward(REFERER);
}
// Otherwise, save the question
if ($guid) {
    $question = get_entity($guid);
    $new = false;
} else {
    $question = new ElggObject();
Example #24
0
 /**
  * Returns whether the given user (or current user) has the ability to write to this group.
  *
  * @param int $user_guid The user.
  * @return bool
  */
 public function canWriteToContainer($user_guid = 0)
 {
     return can_write_to_container($user_guid, $this->getGUID());
 }
Example #25
0
/**
 * Web service for posting a new topic to a group
 *
 * @param string $username       username of author
 * @param string $groupid        GUID of the group
 * @param string $title          Title of new topic
 * @param string $description    Content of the post
 * @param string $status         status of the post
 * @param string $access_id      Access ID of the post
 *
 * @return bool
 */
function group_forum_save_post($groupid, $title, $desc, $tags, $status, $access_id, $username)
{
    if (!$username) {
        $user = get_loggedin_user();
    } else {
        $user = get_user_by_username($username);
    }
    if (!$user) {
        throw new InvalidParameterException('registration:usernamenotvalid');
    }
    $group = get_entity($groupid);
    if (!$group) {
        throw new InvalidParameterException('group:notfound');
    }
    $return['success'] = false;
    // make sure user has permissions to write to container
    if (!can_write_to_container($user->guid, $groupid, "all", "all")) {
        $return['message'] = elgg_echo('groups:permissions:error');
    }
    $topic = new ElggObject();
    $topic->subtype = 'groupforumtopic';
    $topic->owner_guid = $user->guid;
    $topic->title = $title;
    $topic->description = $desc;
    $topic->status = $status;
    $topic->access_id = $access_id;
    $topic->container_guid = $groupid;
    $tags = explode(",", $tags);
    $topic->tags = $tags;
    $result = $topic->save();
    if (!$result) {
        $return['message'] = elgg_echo('discussion:error:notsaved');
    } else {
        $return['success'] = true;
        $return['message'] = elgg_echo('discussion:topic:created');
    }
    return $return;
}
Example #26
0
/**
 * Saves a blog
 *
 * @param array $info An array of name=>value pairs to save to the blog entity
 *
 * @return array('success' => BOOL, 'message' => string);
 */
function blog_save_blog($info)
{
    // store errors to pass along
    $error = FALSE;
    if ($info['guid']) {
        $entity = get_entity($info['guid']);
        if (elgg_instanceof($entity, 'object', 'blog') && $entity->canEdit()) {
            $blog = $entity;
        } else {
            $error = elgg_echo('blog:error:post_not_found');
        }
    } else {
        $blog = new ElggObject();
        $blog->subtype = 'blog';
    }
    // check required vars
    $required = array('title', 'description');
    // load from POST and do sanity and access checking
    foreach ($info as $name => $value) {
        if (in_array($name, $required) && empty($value)) {
            $error = elgg_echo("blog:error:missing:{$name}");
        }
        if ($error) {
            break;
        }
        switch ($name) {
            case 'tags':
                if ($value) {
                    $info[$name] = string_to_tag_array($value);
                } else {
                    unset($info[$name]);
                }
                break;
            case 'excerpt':
                // restrict to 300 chars
                if ($value) {
                    $value = substr(strip_tags($value), 0, 300);
                } else {
                    $value = substr(strip_tags($info['description']), 0, 300);
                }
                $info[$name] = $value;
                break;
            case 'container_guid':
                // this can't be empty.
                if (!empty($value)) {
                    if (can_write_to_container($user->getGUID(), $value)) {
                        $info[$name] = $value;
                    } else {
                        $error = elgg_echo("blog:error:cannot_write_to_container");
                    }
                } else {
                    unset($info[$name]);
                }
                break;
                // don't try to set the guid
            // don't try to set the guid
            case 'guid':
                unset($info['guid']);
                break;
            default:
                $info[$name] = $value;
                break;
        }
    }
    // assign values to the entity, stopping on error.
    if (!$error) {
        foreach ($info as $name => $value) {
            if (!($blog->{$name} = $value)) {
                $error = elgg_echo('blog:error:cannot_save');
                break;
            }
        }
    }
    // only try to save base entity if no errors
    if (!$error && !$blog->save()) {
        $error = elgg_echo('blog:error:cannot_save');
    }
    if ($error) {
        $return = array('success' => FALSE, 'message' => $error);
    } else {
        $return = array('success' => TRUE, 'message' => elgg_echo('blog:message:saved'));
    }
    return $return;
}
Example #27
0
    if ($name == 'title') {
        $input[$name] = strip_tags($input[$name]);
    }
    if ($type == 'tags') {
        $input[$name] = string_to_tag_array($input[$name]);
    }
    if ($name == 'description') {
        $input[$name] = get_markdown_input($_REQUEST[$name]);
    }
}
elgg_make_sticky_form('markdown_wiki');
if (!$input['container_guid']) {
    register_error(elgg_echo('markdown_wiki:error:no_group'));
    forward(elgg_get_site_url() . 'wiki/all');
}
if (!can_write_to_container($user_guid, $input['container_guid'], 'object', 'markdown_wiki')) {
    register_error(elgg_echo('markdown_wiki:error:no_access'));
    forward(REFERER);
}
if (!$input['title']) {
    register_error(elgg_echo('markdown_wiki:error:no_title'));
    forward(REFERER);
}
if (!$input['description']) {
    register_error(elgg_echo('markdown_wiki:error:no_description'));
    forward(REFERER);
}
if ($input['guid']) {
    $markdown_wiki = get_entity($input['guid']);
    if (!$markdown_wiki) {
        register_error(elgg_echo('markdown_wiki:error:no_entity'));
Example #28
0
         unset($values[$name]);
     }
     break;
 case 'excerpt':
     if ($value) {
         $values[$name] = elgg_get_excerpt($value);
     }
     break;
 case 'container_guid':
     //Custom Ongarde var to get the guid of page owner ||
     $container_guid = get_input($value, elgg_get_logged_in_user_guid());
     // this can't be empty or saving the base entity fails
     if (!empty($value)) {
         //if (can_write_to_container($user->getGUID(), $value)) {
         //$values[$name] = $value;
         if (can_write_to_container($user->getGUID(), $container_guid)) {
             $values[$name] = $container_guid;
         } else {
             $error = elgg_echo("blog:error:cannot_write_to_container");
         }
     } else {
         unset($values[$name]);
     }
     break;
     // don't try to set the guid
 // don't try to set the guid
 case 'guid':
     unset($values['guid']);
     break;
 default:
     $values[$name] = $value;
 function test_can_write_to_container()
 {
     $user = new \ElggUser();
     $user->username = '******' . rand();
     $user->name = 'test_user_name_' . rand();
     $user->email = '*****@*****.**';
     $user->container_guid = 0;
     $user->owner_guid = 0;
     $user->save();
     $object = new \ElggObject();
     $object->save();
     $group = new \ElggGroup();
     $group->save();
     // disable access overrides because we're admin.
     $ia = elgg_set_ignore_access(false);
     $this->assertFalse(can_write_to_container($user->guid, $object->guid));
     global $elgg_test_user;
     $elgg_test_user = $user;
     // register hook to allow access
     function can_write_to_container_test_hook($hook, $type, $value, $params)
     {
         global $elgg_test_user;
         if ($params['user']->getGUID() == $elgg_test_user->getGUID()) {
             return true;
         }
     }
     elgg_register_plugin_hook_handler('container_permissions_check', 'all', 'can_write_to_container_test_hook');
     $this->assertTrue(can_write_to_container($user->guid, $object->guid));
     elgg_unregister_plugin_hook_handler('container_permissions_check', 'all', 'can_write_to_container_test_hook');
     $this->assertFalse(can_write_to_container($user->guid, $group->guid));
     $group->join($user);
     $this->assertTrue(can_write_to_container($user->guid, $group->guid));
     elgg_set_ignore_access($ia);
     $user->delete();
     $object->delete();
     $group->delete();
 }
Example #30
0
/**
 * Extend container permissions checking to extend can_write_to_container for write users.
 *
 * @param unknown_type $hook
 * @param unknown_type $entity_type
 * @param unknown_type $returnvalue
 * @param unknown_type $params
 */
function tasks_container_permission_check($hook, $entity_type, $returnvalue, $params)
{
    if (elgg_get_context() == "tasks") {
        if (elgg_get_page_owner_guid()) {
            if (can_write_to_container(elgg_get_logged_in_user_guid(), elgg_get_page_owner_guid())) {
                return true;
            }
        }
        if ($task_guid = get_input('task_guid', 0)) {
            $entity = get_entity($task_guid);
        } else {
            if ($parent_guid = get_input('parent_guid', 0)) {
                $entity = get_entity($parent_guid);
            }
        }
        if ($entity instanceof ElggObject) {
            if (can_write_to_container(elgg_get_logged_in_user_guid(), $entity->container_guid) || in_array($entity->write_access_id, get_access_list())) {
                return true;
            }
        }
    }
}