Ejemplo n.º 1
0
*/
if (!defined("PARENT_INCLUDED")) {
    exit;
} elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) {
    header("Location: " . ENTRADA_URL);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed("communityadmin", "read", false)) {
    $ERROR++;
    $ERRORSTR[] = "Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance.";
    echo display_error();
    application_log("error", "Group [" . $GROUP . "] and role [" . $ROLE . "] does not have access to this module [" . $MODULE . "]");
} else {
    define("IN_COMMUNITIES", true);
    $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/communities", "title" => "Manage Communities");
    if ($router && $router->initRoute()) {
        $PREFERENCES = preferences_load($MODULE);
        $module_file = $router->getRoute();
        if ($module_file) {
            require_once $module_file;
        }
        /**
         * Check if preferences need to be updated on the server at this point.
         */
        preferences_update($MODULE, $PREFERENCES);
    } else {
        $url = ENTRADA_URL . "/admin/" . $MODULE;
        application_log("error", "The Entrada_Router failed to load a request. The user was redirected to [" . $url . "].");
        header("Location: " . $url);
        exit;
    }
}
Ejemplo n.º 2
0
/**
 * Used to load the requested page from POST or GET
 * @global type $input
 */
function load_page()
{
    global $input;
    $action = $input['action'];
    $redraw = false;
    //
    // Actions
    //
    // Controller goes here
    switch ($action) {
        // The user clicked on an album, we display its content to them
        // Display the help page
        case 'view_help':
            view_help();
            break;
        case 'view_settings':
            view_settings();
            break;
            // In case we want to log out
        // In case we want to log out
        case 'logout':
            user_logout();
            break;
            // The only case when we could possibly arrive here with a session created
            // and a "login" action is when the user refreshed the page. In that case,
            // we redraw the page with the last information saved in the session variables.
        // The only case when we could possibly arrive here with a session created
        // and a "login" action is when the user refreshed the page. In that case,
        // we redraw the page with the last information saved in the session variables.
        case 'login':
            redraw_page();
            break;
        case 'anonymous_login':
            anonymous_login();
            break;
        case 'admin_mode_update':
            admin_mode_update();
            break;
        case 'view_album_assets':
            view_album_assets();
            break;
        case 'view_asset_details':
            view_asset_details();
            break;
        case 'view_asset_bookmark':
            view_asset_bookmark();
            break;
        case 'search_bookmark':
            bookmarks_search();
            break;
        case 'sort_asset_bookmark':
            bookmarks_sort();
            break;
        case 'add_asset_bookmark':
            bookmark_add();
            break;
        case 'add_asset_thread':
            thread_add();
            break;
        case 'add_thread_comment':
            comment_add();
            break;
        case 'add_thread_comment_answer':
            comment_add_reply();
            break;
        case 'update_thread_comment':
            comment_edit();
            break;
        case 'update_asset_thread':
            thread_edit();
            break;
        case 'thread_details_view':
            thread_details_update();
            break;
        case 'delete_asset_thread':
            thread_delete();
            break;
        case 'delete_thread_comment':
            comment_delete();
            break;
        case 'edit_settings':
            preferences_update();
            break;
        case 'edit_asset_meta':
            asset_edit_meta();
            break;
        case 'vote':
            vote_add();
            break;
        case 'approve':
            comment_edit_approval();
            break;
        case 'threads_list_view':
            threads_list_update();
            break;
        case 'copy_bookmark':
            bookmark_copy();
            break;
        case 'share_popup':
            share_popup();
            break;
        case 'bookmark_popup':
            bookmark_popup();
            break;
        case 'bookmarks_popup':
            bookmarks_popup();
            break;
        case 'remove_asset_bookmark':
            bookmark_delete();
            break;
        case 'remove_asset_bookmarks':
            bookmarks_delete_all();
            break;
        case 'view_import':
            view_import();
            break;
        case 'upload_bookmarks':
            bookmarks_upload();
            break;
        case 'import_bookmarks':
            bookmarks_import();
            break;
        case 'export_bookmarks':
            bookmarks_export();
            break;
        case 'export_album_bookmarks':
            bookmarks_export_all();
            break;
        case 'export_asset_bookmarks':
            bookmarks_export_all(true);
            break;
        case 'delete_bookmarks':
            bookmarks_delete();
            break;
        case 'move_album_token':
            album_token_move();
            break;
        case 'delete_album_token':
            album_token_delete();
            break;
        case 'client_trace':
            client_trace();
            break;
            // No action selected: we choose to display the homepage again
        // No action selected: we choose to display the homepage again
        default:
            // TODO: check session var here
            view_main();
    }
}
Ejemplo n.º 3
0
                    if ($PROCESSED["start_date"] >= $PROCESSED["finish_date"]) {
                        add_error("The<strong> Start Date</strong> must come before the <strong>Finish Date</strong>.");
                    }
                }
                if (!$ERROR) {
                    $teachers = $course->getTeachersByDates($PROCESSED["start_date"], $PROCESSED["finish_date"]);
                    if (!$teachers) {
                        add_notice("No Teachers found between " . date("Y-m-d", $PROCESSED["start_date"]) . " and " . date("Y-m-d", $PROCESSED["finish_date"]) . "");
                    } else {
                        if (has_notice()) {
                            clear_notice();
                        }
                    }
                    $_SESSION[APPLICATION_IDENTIFIER]["courses"]["teacher_report_start"] = $PROCESSED["start_date"];
                    $_SESSION[APPLICATION_IDENTIFIER]["courses"]["teacher_report_finish"] = $PROCESSED["finish_date"];
                    preferences_update("courses", $original_preferences);
                }
                break;
        }
        //Display content
        if ($ERROR) {
            echo display_error();
        }
        if ($NOTICE) {
            echo display_notice();
        }
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function() {

                var course_id = "<?php 
Ejemplo n.º 4
0
/**
 * Load the active organisation for the user including their permissions,
 * template, system groups, etc.
 *
 * @global type $ENTRADA_USER
 * @global type $ENTRADA_TEMPLATE
 * @global type $SYSTEM_GROUPS
 * @global object $db
 * @param type $organisation_id
 * @param type $user_access_id
 */
function load_active_organisation($organisation_id = 0, $user_access_id = 0)
{
    global $ENTRADA_USER, $ENTRADA_TEMPLATE, $SYSTEM_GROUPS, $db;
    $allow_organisation_id_set = false;
    $allow_access_id_set = false;
    $change_organisations = true;
    $organisation_id = (int) $organisation_id;
    $user_access_id = (int) $user_access_id;
    if ($ENTRADA_USER && $ENTRADA_TEMPLATE) {
        $_SESSION["permissions"] = permissions_load();
        /**
         * Load active organisation from preferences if one exists.
         */
        $active_organisation = preferences_load("organisation_switcher");
        /**
         * Check whether we are trying to set a new org and access_id or use one
         * from user preferences, or the default.
         */
        if (!$organisation_id || !$user_access_id) {
            if (isset($active_organisation["organisation_id"]) && isset($active_organisation["access_id"])) {
                $organisation_id = (int) $active_organisation["organisation_id"];
                $user_access_id = (int) $active_organisation["access_id"];
            } else {
                $organisation_id = $ENTRADA_USER->getActiveOrganisation();
                $user_access_id = $ENTRADA_USER->getAccessId();
            }
        }
        /**
         * Interate through existing permissions to ensure
         */
        foreach ($_SESSION["permissions"] as $access_id => $permission) {
            if ($permission["organisation_id"] == $organisation_id) {
                $allow_organisation_id_set = true;
                if ($access_id == $user_access_id) {
                    $allow_access_id_set = true;
                }
            }
        }
        if ($allow_organisation_id_set && $allow_access_id_set) {
            $ENTRADA_USER->setActiveOrganisation($organisation_id);
            $ENTRADA_USER->setAccessId($user_access_id);
            $_SESSION[APPLICATION_IDENTIFIER]["organisation_switcher"]["organisation_id"] = $organisation_id;
            $_SESSION[APPLICATION_IDENTIFIER]["organisation_switcher"]["access_id"] = $user_access_id;
            application_log("success", "User [" . $ENTRADA_USER->getId() . "] loaded organisation [" . $organisation_id . "] and access_id [" . $user_access_id . "] successfully.");
        } else {
            application_log("error", "User [" . $ENTRADA_USER->getId() . "] attempted to change to organisation [" . $organisation_id . "] and access_id [" . $user_access_id . "] but was unsuccessful.");
        }
        /**
         * Returns all of the system groups and roles associated with this user
         * within the active organisation.
         */
        $query = "SELECT a.*\n                  FROM `" . AUTH_DATABASE . "`.`system_groups` AS a,\n                  `" . AUTH_DATABASE . "`.`system_group_organisation` AS c\n                  WHERE a.`id` = c.`groups_id`\n                  AND c.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\n                  ORDER BY a.`group_name` ASC";
        $results = $db->GetAll($query);
        if ($results) {
            foreach ($results as $result) {
                $SYSTEM_GROUPS[$result["group_name"]] = array();
                $query = "SELECT a.*\n                            FROM `" . AUTH_DATABASE . "`.`system_roles` a\n                            WHERE a.`groups_id` = " . $result["id"] . "\n                            ORDER BY a.`role_name` ASC";
                $roles = $db->GetAll($query);
                if ($roles) {
                    foreach ($roles as $role) {
                        $SYSTEM_GROUPS[$result["group_name"]][] = $role["role_name"];
                    }
                }
            }
        }
        preferences_update("organisation_switcher", $active_organisation);
        $ENTRADA_TEMPLATE->setActiveTemplate($ENTRADA_USER->getActiveOrganisation());
    }
}
Ejemplo n.º 5
0
                        }
                    }
                }
                //Find all the non removable urls from the default feeds
                $non_removable_feed_urls = array();
                foreach ($default_feeds as $key => $array) {
                    if (isset($array["removable"]) && !$array["removable"]) {
                        $non_removable_feed_urls[] = $array["url"];
                    }
                }
                //Ensure all the non removable urls have their removable status preserved
                foreach ($new_feeds as $key => &$array) {
                    if (in_array($array["url"], $non_removable_feed_urls)) {
                        $array["removable"] = false;
                    } else {
                        $array["removable"] = true;
                    }
                }
                $_SESSION[APPLICATION_IDENTIFIER][$MODULE]["feeds"] = $new_feeds;
                preferences_update($MODULE);
                break;
            case "reset":
                $_SESSION[APPLICATION_IDENTIFIER][$MODULE]["feeds"] = null;
                $_SESSION[APPLICATION_IDENTIFIER][$MODULE]["feed_break"] = -1;
                break;
            default:
                continue;
                break;
        }
    }
}