示例#1
0
$institution = $view->get('institution');
View::set_nav($group, $institution, true);
if (!$USER->can_edit_view($view) || $view->get('owner') == "0") {
    throw new AccessDeniedException();
}
if ($group && !group_within_edit_window($group)) {
    throw new AccessDeniedException();
}
$form = array('name' => 'editaccess', 'renderer' => 'div', 'plugintype' => 'core', 'pluginname' => 'view', 'viewid' => $view->get('id'), 'userview' => (int) $view->get('owner'), 'elements' => array('id' => array('type' => 'hidden', 'value' => $view->get('id'))));
// Create checkboxes to allow the user to apply these access rules to
// any of their views/collections.
// For institution views, force edit access of one view at a time for now.  Editing multiple
// institution views requires doing some tricky stuff with the 'copy for new users/groups'
// options, and there's not much room for the 'Share' tab in the admin area anyway
if ($view->get('type') != 'profile') {
    list($collections, $views) = View::get_views_and_collections($view->get('owner'), $group, $institution, $view->get('accessconf'), false);
}
if (!empty($collections)) {
    foreach ($collections as &$c) {
        $c = array('title' => $c['name'], 'value' => $c['id'], 'defaultvalue' => $collectionid == $c['id'] || !empty($c['match']), 'views' => $c['views']);
    }
    $form['elements']['collections'] = array('type' => 'checkboxes', 'title' => get_string('Collections', 'collection'), 'elements' => $collections);
}
if (!empty($views)) {
    foreach ($views as &$v) {
        $v = array('title' => $v['name'], 'value' => $v['id'], 'defaultvalue' => $viewid == $v['id'] || !empty($v['match']));
    }
    $form['elements']['views'] = array('type' => 'checkboxes', 'title' => get_string('views'), 'elements' => $views);
}
if ($view->get('type') == 'profile') {
    // Make sure all the user's institutions have access to profile view
示例#2
0
文件: group.php 项目: vohung96/mahara
/**
 * Form for submitting views to a group
 */
function group_view_submission_form($groupid)
{
    global $USER;
    list($collections, $views) = View::get_views_and_collections($USER->get('id'));
    $viewoptions = $collectionoptions = array();
    foreach ($collections as $c) {
        if (empty($c['submittedgroup']) && empty($c['submittedhost'])) {
            $collectionoptions['c:' . $c['id']] = $c['name'];
        }
    }
    foreach ($views as $v) {
        if ($v['type'] != 'profile' && empty($v['submittedgroup']) && empty($v['submittedhost'])) {
            $viewoptions['v:' . $v['id']] = $v['name'];
        }
    }
    $options = $optgroups = null;
    if (!empty($collectionoptions) && !empty($viewoptions)) {
        $optgroups = array('collections' => array('label' => get_string('Collections', 'collection'), 'options' => $collectionoptions), 'views' => array('label' => get_string('Views', 'view'), 'options' => $viewoptions));
    } else {
        if (!empty($collectionoptions)) {
            $options = $collectionoptions;
        } else {
            if (!empty($viewoptions)) {
                $options = $viewoptions;
            } else {
                return;
            }
        }
    }
    return pieform(array('name' => 'group_view_submission_form_' . $groupid, 'method' => 'post', 'renderer' => 'oneline', 'autofocus' => false, 'successcallback' => 'group_view_submission_form_submit', 'elements' => array('text1' => array('type' => 'html', 'value' => get_string('submit', 'group') . ' '), 'options' => array('type' => 'select', 'collapseifoneoption' => false, 'optgroups' => $optgroups, 'options' => $options), 'text2' => array('type' => 'html', 'value' => get_string('forassessment', 'view')), 'submit' => array('type' => 'submit', 'value' => get_string('submit')), 'group' => array('type' => 'hidden', 'value' => $groupid))));
}
示例#3
0
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('blocktype', 'groupviews');
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'group.php';
require_once get_config('libroot') . 'pieforms/pieform.php';
$offset = param_integer('offset', 0);
$groupid = param_integer('group');
$editing = param_boolean('editing', false);
$group_homepage_view = group_get_homepage_view($groupid);
$bi = group_get_homepage_view_groupview_block($groupid);
if (!can_view_view($group_homepage_view) || !group_user_can_assess_submitted_views($groupid, $USER->get('id'))) {
    json_reply(true, get_string('accessdenied', 'error'));
}
$configdata = $bi->get('configdata');
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = $limit > 0 ? $limit : 5;
if (!isset($configdata['sortsubmittedby']) || $configdata['sortsubmittedby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) {
    $sortsubmittedby = 'c.name, v.title';
} else {
    $sortsubmittedby = 'c.submittedtime DESC, v.submittedtime DESC';
}
list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $groupid, $sortsubmittedby);
$allsubmitted = array_merge(array_values($collections), array_values($views));
$allsubmitted = array('data' => array_slice($allsubmitted, $offset, $limit), 'count' => count($allsubmitted), 'limit' => $limit, 'offset' => $offset);
if (!empty($configdata['showsubmitted'])) {
    $baseurl = $group_homepage_view->get_url();
    $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid . '&editing=' . $editing;
    $pagination = array('baseurl' => $baseurl, 'id' => 'allsubmitted_pagination', 'datatable' => 'allsubmissionlist', 'jsonscript' => 'blocktype/groupviews/allsubmissions.json.php', 'resultcounttextsingular' => get_string('vieworcollection', 'view'), 'resultcounttextplural' => get_string('viewsandcollections', 'view'));
    PluginBlocktypeGroupViews::render_items($allsubmitted, 'blocktype:groupviews:allsubmissions.tpl', $configdata, $pagination);
}
json_reply(false, array('data' => $allsubmitted));
示例#4
0
 protected static function get_data($groupid, $editing = false)
 {
     global $USER;
     if (!defined('GROUP')) {
         define('GROUP', $groupid);
     }
     // get the currently requested group
     $group = group_current_group();
     $role = group_user_access($group->id);
     if ($role) {
         $bi = group_get_homepage_view_groupview_block($group->id);
         $configdata = $bi->get('configdata');
         $limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
         $limit = $limit > 0 ? $limit : 5;
         // Get all views created in the group
         $sort = array(array('column' => 'type=\'grouphomepage\'', 'desc' => true));
         $data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, 0, true, $sort);
         foreach ($data['groupviews']->data as &$view) {
             if (!$editing && isset($view['template']) && $view['template']) {
                 $view['form'] = pieform(create_view_form(null, null, $view['id']));
             }
         }
         // For group members, display a list of views that others have
         // shared to the group
         $data['sharedviews'] = View::get_sharedviews_data($limit, 0, $group->id);
         foreach ($data['sharedviews']->data as &$view) {
             if (!$editing && isset($view['template']) && $view['template']) {
                 $view['form'] = pieform(create_view_form($group, null, $view->id));
             }
         }
         $data['sharedcollections'] = View::get_sharedcollections_data($limit, 0, $group->id);
         if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) {
             // Display a list of views submitted to the group
             list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $group->id);
             $allsubmitted = array_merge(array_values($collections), array_values($views));
             $data['allsubmitted'] = array('data' => array_slice($allsubmitted, 0, $limit), 'count' => count($allsubmitted), 'limit' => $limit, 'offset' => 0);
         }
     }
     if ($group->submittableto) {
         require_once 'pieforms/pieform.php';
         // A user can submit more than one view to the same group, but no view can be
         // submitted to more than one group.
         // Display a list of views this user has submitted to this group, and a submission
         // form containing drop-down of their unsubmitted views.
         list($collections, $views) = View::get_views_and_collections($USER->get('id'), null, null, null, false, $group->id);
         $data['mysubmitted'] = array_merge(array_values($collections), array_values($views));
         // Only render the submission form in viewing mode
         if (!$editing) {
             $data['group_view_submission_form'] = group_view_submission_form($group->id);
         }
     }
     $data['group'] = $group;
     return $data;
 }
示例#5
0
文件: lib.php 项目: kienv/mahara
 protected static function get_data($groupid, $editing = false)
 {
     global $USER;
     if (!defined('GROUP')) {
         define('GROUP', $groupid);
     }
     // get the currently requested group
     $group = group_current_group();
     $role = group_user_access($group->id);
     $bi = group_get_homepage_view_groupview_block($group->id);
     $configdata = $bi->get('configdata');
     if (!isset($configdata['sortsubmittedby']) || $configdata['sortsubmittedby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) {
         $sortsubmittedby = 'c.name, v.title';
     } else {
         $sortsubmittedby = 'c.submittedtime DESC, v.submittedtime DESC';
     }
     if ($role) {
         $limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
         $limit = $limit > 0 ? $limit : 5;
         // Get all views created in the group
         // Sortorder: Group homepage should be first, then sort by sortorder
         $sort = array(array('column' => "type='grouphomepage'", 'desc' => true));
         // Find out what order to sort them by (default is titles)
         if (!isset($configdata['sortgroupviewsby']) || $configdata['sortgroupviewsby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) {
             $sort[] = array('column' => 'title');
         } else {
             $sort[] = array('column' => 'mtime', 'desc' => true);
         }
         $data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, 0, true, $sort);
         foreach ($data['groupviews']->data as &$view) {
             if (!$editing && isset($view['template']) && $view['template']) {
                 $view['form'] = pieform(create_view_form(null, null, $view['id']));
             }
         }
         // Find out what order to sort them by (default is titles)
         if (!isset($configdata['sortsharedviewsby']) || $configdata['sortsharedviewsby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) {
             $sortsharedviewsby = 'v.title';
             $sortsharedcollectionsby = array(array('column' => 'c.name'));
         } else {
             $sortsharedviewsby = 'v.mtime DESC';
             $sortsharedcollectionsby = array(array('column' => 'GREATEST(c.mtime, (SELECT MAX(v.mtime) FROM {view} v INNER JOIN {collection_view} cv ON v.id=cv.view WHERE cv.collection=c.id))', 'desc' => true));
         }
         // For group members, display a list of views that others have
         // shared to the group
         if (empty($configdata['showsharedviews'])) {
             $data['sharedviews'] = (object) array('data' => array(), 'count' => 0, 'limit' => $limit, 'offset' => 0);
         } else {
             $data['sharedviews'] = View::get_sharedviews_data($limit, 0, $group->id, $configdata['showsharedviews'] == 2 ? false : true, $sortsharedviewsby);
             foreach ($data['sharedviews']->data as &$view) {
                 if (!$editing && isset($view['template']) && $view['template']) {
                     $view['form'] = pieform(create_view_form($group, null, $view->id));
                 }
             }
         }
         if (empty($configdata['showsharedcollections'])) {
             $data['sharedcollections'] = (object) array('data' => array(), 'count' => 0, 'limit' => $limit, 'offset' => 0);
         } else {
             $data['sharedcollections'] = View::get_sharedcollections_data($limit, 0, $group->id, $configdata['showsharedcollections'] == 2 ? false : true, $sortsharedcollectionsby);
         }
         if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) {
             // Display a list of views submitted to the group
             list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $group->id, $sortsubmittedby);
             $allsubmitted = array_merge(array_values($collections), array_values($views));
             $data['allsubmitted'] = array('data' => array_slice($allsubmitted, 0, $limit), 'count' => count($allsubmitted), 'limit' => $limit, 'offset' => 0);
         }
     }
     if ($group->submittableto) {
         require_once 'pieforms/pieform.php';
         // A user can submit more than one view to the same group, but no view can be
         // submitted to more than one group.
         // Display a list of views this user has submitted to this group, and a submission
         // form containing drop-down of their unsubmitted views.
         list($collections, $views) = View::get_views_and_collections($USER->get('id'), null, null, null, false, $group->id, $sortsubmittedby);
         $data['mysubmitted'] = array_merge(array_values($collections), array_values($views));
         // Only render the submission form in viewing mode
         if (!$editing) {
             $data['group_view_submission_form'] = group_view_submission_form($group->id);
         }
     }
     $data['group'] = $group;
     return $data;
 }
 * returns all submissions to a given group id
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('blocktype', 'groupviews');
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'group.php';
$offset = param_integer('offset', 0);
$groupid = param_integer('group');
$group_homepage_view = group_get_homepage_view($groupid);
$bi = group_get_homepage_view_groupview_block($groupid);
if (!can_view_view($group_homepage_view)) {
    json_reply(true, get_string('accessdenied', 'error'));
}
$configdata = $bi->get('configdata');
if (!isset($configdata['showsubmitted'])) {
    $configdata['showsubmitted'] = 1;
}
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = $limit > 0 ? $limit : 5;
list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $groupid);
$allsubmitted = array_merge(array_values($collections), array_values($views));
$allsubmitted = array('data' => array_slice($allsubmitted, $offset, $limit), 'count' => count($allsubmitted), 'limit' => $limit, 'offset' => $offset);
if (!empty($configdata['showsubmitted'])) {
    $baseurl = $group_homepage_view->get_url();
    $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid;
    $pagination = array('baseurl' => $baseurl, 'id' => 'allsubmitted_pagination', 'datatable' => 'allsubmissionlist', 'jsonscript' => 'blocktype/groupviews/allsubmissions.json.php', 'resultcounttextsingular' => get_string('vieworcollection', 'view'), 'resultcounttextplural' => get_string('viewsandcollections', 'view'));
    PluginBlocktypeGroupViews::render_items($allsubmitted, 'blocktype:groupviews:allsubmissions.tpl', $configdata, $pagination);
}
json_reply(false, array('data' => $allsubmitted));