Exemplo n.º 1
0
 public static function get_templatesearch_data(&$search)
 {
     require_once get_config('libroot') . 'pieforms/pieform.php';
     $search->sort = isset($search->sort) ? $search->sort : null;
     // for backwards compatibility
     $results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true, $search->sort, null, true);
     $oldcollid = null;
     foreach ($results->data as &$r) {
         if (!empty($search->sort)) {
             $collid = $r['collid'] == $oldcollid ? null : $r['collid'];
         } else {
             $collid = $r['collid'];
         }
         $r['form'] = pieform(create_view_form($search->copyableby->group, $search->copyableby->institution, $r['id'], $collid));
         $oldcollid = $r['collid'];
     }
     $params = array();
     if (isset($search->query) && $search->query != '') {
         $params['viewquery'] = $search->query;
     }
     if (isset($search->ownerquery) && $search->ownerquery != '') {
         $params['ownerquery'] = $search->ownerquery;
     }
     if (!empty($search->group)) {
         $params['group'] = $search->group;
     }
     if (!empty($search->institution)) {
         $params['institution'] = $search->institution;
     }
     if (!empty($search->collection)) {
         $params['searchcollection'] = $search->collection;
     }
     $params['viewlimit'] = $search->limit;
     $smarty = smarty_core();
     $smarty->assign_by_ref('results', $results->data);
     $search->html = $smarty->fetch('view/templatesearchresults.tpl');
     $search->count = $results->count;
     $search->pagination = build_pagination(array('id' => 'templatesearch_pagination', 'class' => 'center', 'url' => get_config('wwwroot') . 'view/choosetemplate.php' . (!empty($params) ? '?' . http_build_query($params) : ''), 'count' => $results->count, 'limit' => $search->limit, 'offset' => $search->offset, 'jumplinks' => 6, 'numbersincludeprevnext' => 2, 'offsetname' => 'viewoffset', 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
 }
Exemplo n.º 2
0
define('SECTION_PLUGINNAME', 'admin');
require dirname(dirname(__FILE__)) . '/init.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'institution.php';
require_once 'pieforms/pieform.php';
$limit = param_integer('limit', 5);
$offset = param_integer('offset', 0);
$institution = param_alpha('institution', false);
if ($institution == 'mahara') {
    redirect('/admin/site/views.php');
}
$s = institution_selector_for_page($institution, get_config('wwwroot') . 'view/institutionviews.php');
$institution = $s['institution'];
$smarty = smarty();
if ($institution === false) {
    $smarty->display('admin/users/noinstitutions.tpl');
    exit;
}
$title = get_string('institutionviews', 'view');
define('TITLE', $title);
$smarty->assign('heading', $title);
$data = View::get_myviews_data($limit, $offset, null, $institution);
$pagination = build_pagination(array('url' => get_config('wwwroot') . 'view/institutionviews.php?institution=' . $institution, 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs']);
$smarty->assign('views', $data->data);
$smarty->assign('institution', $institution);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('createviewform', pieform(create_view_form(null, $institution)));
$smarty->assign('createtemplateform', pieform(create_template_form(null, $institution)));
$smarty->display('view/index.tpl');
Exemplo n.º 3
0
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configsite/siteviews');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'siteviews');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once get_config('libroot') . 'view.php';
require_once 'pieforms/pieform.php';
$limit = param_integer('limit', 5);
$offset = param_integer('offset', 0);
$title = get_string('siteviews', 'admin');
define('TITLE', $title);
$smarty = smarty();
$smarty->assign('heading', $title);
$data = View::get_myviews_data($limit, $offset, null, 'mahara');
$pagination = build_pagination(array('url' => get_config('wwwroot') . 'admin/site/views.php', 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
$smarty->assign('views', $data->data);
$smarty->assign('institution', 'mahara');
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('createviewform', pieform(create_view_form(null, 'mahara')));
$smarty->assign('createtemplateform', pieform(create_template_form(null, 'mahara')));
$smarty->display('view/index.tpl');
Exemplo n.º 4
0
$js = <<<EOF
addLoadEvent(function () {
    p = {$pagination['javascript']}
EOF;
if ($offset > 0) {
    $js .= <<<EOF
    if (\$('myviews')) {
        getFirstElementByTagAndClassName('a', null, 'myviews').focus();
    }
EOF;
} else {
    $js .= <<<EOF
    if (\$('searchresultsheading')) {
        addElementClass('searchresultsheading', 'hidefocus');
        setNodeAttribute('searchresultsheading', 'tabIndex', -1);
        \$('searchresultsheading').focus();
    }
EOF;
}
$js .= '});';
$createviewform = pieform(create_view_form());
$smarty = smarty(array('paginator'));
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $data->data);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('query', param_variable('query', null));
$smarty->assign('querystring', get_querystring());
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
Exemplo n.º 5
0
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
require dirname(dirname(__FILE__)) . '/init.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'group.php';
$owner = param_integer('owner', 0);
$groupid = param_integer('group', null);
$institution = param_alphanum('institution', null);
$searchcollection = param_integer('searchcollection', false);
View::set_nav($groupid, $institution, false, $searchcollection);
if ($usetemplate = param_integer('usetemplate', null)) {
    // If a form has been submitted, build it now and pieforms will
    // call the submit function straight away
    pieform(create_view_form($groupid, $institution, $usetemplate, param_integer('copycollection', null)));
}
if ($groupid && (!group_user_can_edit_views($groupid) || !group_within_edit_window($groupid)) || $institution && !$USER->can_edit_institution($institution)) {
    throw new AccessDeniedException();
}
if (!empty($groupid)) {
    $group = group_current_group();
    define('TITLE', $group->name);
} else {
    $owner = $USER->get('id');
    define('TITLE', get_string('copyvieworcollection', 'view'));
}
define('SUBTITLE', get_string('copyvieworcollection', 'view'));
$views = new StdClass();
$views->query = trim(param_variable('viewquery', ''));
$views->ownerquery = trim(param_variable('ownerquery', ''));
Exemplo n.º 6
0
        getFirstElementByTagAndClassName('a', null, 'myviews').focus();
    }
EOF;
} else {
    $js .= <<<EOF
    if (\$('searchresultsheading')) {
        addElementClass('searchresultsheading', 'hidefocus');
        setNodeAttribute('searchresultsheading', 'tabIndex', -1);
        \$('searchresultsheading').focus();
    }
EOF;
}
$js .= <<<EOF
});

{$s['institutionselectorjs']}
EOF;
$createviewform = pieform(create_view_form(null, $institution));
$smarty = smarty(array('paginator'));
setpageicon($smarty, 'icon-university');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $data->data);
$smarty->assign('institution', $institution);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('query', param_variable('query', null));
$smarty->assign('querystring', get_querystring());
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
Exemplo n.º 7
0
 public static function get_templatesearch_data(&$search)
 {
     require_once get_config('libroot') . 'pieforms/pieform.php';
     $results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true);
     foreach ($results->data as &$r) {
         $r['form'] = pieform(create_view_form($search->copyableby->group, $search->copyableby->institution, $r['id']));
     }
     $params = array();
     if (!empty($search->query)) {
         $params[] = 'viewquery=' . $search->query;
     }
     if (!empty($search->ownerquery)) {
         $params[] = 'ownerquery=' . $search->query;
     }
     if (!empty($search->group)) {
         $params[] = 'group=' . $search->group;
     }
     if (!empty($search->institution)) {
         $params[] = 'institution=' . $search->institution;
     }
     $params[] = 'viewlimit=' . $search->limit;
     $smarty = smarty_core();
     $smarty->assign_by_ref('results', $results->data);
     $search->html = $smarty->fetch('view/templatesearchresults.tpl');
     $search->count = $results->count;
     $search->pagination = build_pagination(array('id' => 'templatesearch_pagination', 'class' => 'center', 'url' => get_config('wwwroot') . 'view/choosetemplate.php?' . join('&amp;', $params), 'count' => $results->count, 'limit' => $search->limit, 'offset' => $search->offset, 'offsetname' => 'viewoffset', 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
 }
Exemplo n.º 8
0
Arquivo: lib.php Projeto: 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;
 }
Exemplo n.º 9
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;
 }
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['showgroupviews'])) {
    $configdata['showgroupviews'] = 1;
}
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = $limit > 0 ? $limit : 5;
$sort = array(array('column' => 'type=\'grouphomepage\'', 'desc' => true));
$groupviews = (array) View::view_search(null, null, (object) array('group' => $groupid), null, $limit, $offset, true, $sort);
foreach ($groupviews['data'] as &$view) {
    if (isset($view['template']) && $view['template']) {
        $view['form'] = pieform(create_view_form($group_homepage_view, null, $view->id));
    }
}
if (!empty($configdata['showgroupviews']) && isset($groupviews)) {
    $baseurl = $group_homepage_view->get_url();
    $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid;
    $pagination = array('baseurl' => $baseurl, 'id' => 'groupviews_pagination', 'datatable' => 'groupviewlist', 'jsonscript' => 'blocktype/groupviews/groupviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'));
    PluginBlocktypeGroupViews::render_items($groupviews, 'blocktype:groupviews:groupviewssection.tpl', $configdata, $pagination);
}
json_reply(false, array('data' => $groupviews));
Exemplo n.º 11
0
$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['showgroupviews'])) {
    $configdata['showgroupviews'] = 1;
}
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = $limit > 0 ? $limit : 5;
// 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);
}
$groupviews = (array) View::view_search(null, null, (object) array('group' => $groupid), null, $limit, $offset, true, $sort);
foreach ($groupviews['data'] as &$view) {
    if (isset($view['template']) && $view['template']) {
        $view['form'] = pieform(create_view_form(null, null, $view['id']));
    }
}
if (!empty($configdata['showgroupviews']) && isset($groupviews)) {
    $baseurl = $group_homepage_view->get_url();
    $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid;
    $pagination = array('baseurl' => $baseurl, 'id' => 'groupviews_pagination', 'datatable' => 'groupviewlist', 'jsonscript' => 'blocktype/groupviews/groupviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'));
    PluginBlocktypeGroupViews::render_items($groupviews, 'blocktype:groupviews:groupviewssection.tpl', $configdata, $pagination);
}
json_reply(false, array('data' => $groupviews));
Exemplo n.º 12
0
       INNER JOIN {grouptype} t ON t.name = g.grouptype
       WHERE u.member = ?
       AND t.submittableto = 1
       ORDER BY g.name', array($userid)))) {
    $tutorgroupdata = array();
} else {
    $options = array();
    foreach ($tutorgroupdata as $group) {
        $options[$group->id] = $group->name;
    }
    $i = 0;
    foreach ($data->data as &$view) {
        if (empty($view['submittedto'])) {
            // This form sucks from a language string point of view. It should
            // use pieforms' form template feature
            $view['submitto'] = pieform(array('name' => 'submitto' . $i++, 'method' => 'post', 'renderer' => 'oneline', 'autofocus' => false, 'successcallback' => 'submitto_submit', 'elements' => array('text1' => array('type' => 'html', 'value' => get_string('submitthisviewto', 'view') . ' '), 'options' => array('type' => 'select', 'collapseifoneoption' => false, 'options' => $options), 'text2' => array('type' => 'html', 'value' => get_string('forassessment', 'view')), 'submit' => array('type' => 'submit', 'value' => get_string('submit')), 'view' => array('type' => 'hidden', 'value' => $view['id']))));
        }
    }
}
$pagination = build_pagination(array('url' => get_config('wwwroot') . 'view/', 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
function submitto_submit(Pieform $form, $values)
{
    redirect('/view/submit.php?id=' . $values['view'] . '&group=' . $values['options']);
}
$smarty = smarty();
$smarty->assign('views', $data->data);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('heading', get_string('myviews'));
$smarty->assign('createviewform', pieform(create_view_form()));
$smarty->assign('createtemplateform', pieform(create_template_form()));
$smarty->display('view/index.tpl');
Exemplo n.º 13
0
        $USER->set_account_preference('viewsperpage', $limit);
    } else {
        $limit = $userlimit;
    }
    $offset = param_integer('offset', 0);
    $data = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, $offset);
    // Add a copy view form for all templates in the list
    foreach ($data->data as &$v) {
        if ($v['template']) {
            $v['copyform'] = pieform(create_view_form(null, null, $v['id']));
        }
    }
    $pagination = build_pagination(array('url' => get_config('wwwroot') . 'view/groupviews.php?group=' . $group->id, 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'setlimit' => $setlimit, 'jumplinks' => 6, 'numbersincludeprevnext' => 2));
} else {
    list($searchform, $data, $pagination) = View::views_by_owner($group->id);
    $createviewform = pieform(create_view_form($group->id));
}
$js = <<<EOF
addLoadEvent(function () {
    p = {$pagination['javascript']}
EOF;
if ($offset > 0) {
    $js .= <<<EOF
    if (\$('groupviews')) {
        getFirstElementByTagAndClassName('a', null, 'groupviews').focus();
    }
    if (\$('myviews')) {
        getFirstElementByTagAndClassName('a', null, 'myviews').focus();
    }
EOF;
} else {
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
require dirname(dirname(__FILE__)) . '/init.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'group.php';
$group = param_integer('group', null);
$institution = param_alphanum('institution', null);
View::set_nav($group, $institution);
if ($usetemplate = param_integer('usetemplate', null)) {
    // If a form has been submitted, build it now and pieforms will
    // call the submit function straight away
    pieform(create_view_form($group, $institution, $usetemplate));
}
if ($group && !group_user_can_edit_views($group) || $institution && !$USER->can_edit_institution($institution)) {
    throw new AccessDeniedException();
}
define('TITLE', get_string('copyaview', 'view'));
$views = new StdClass();
$views->query = trim(param_variable('viewquery', ''));
$views->ownerquery = trim(param_variable('ownerquery', ''));
$views->offset = param_integer('viewoffset', 0);
$views->limit = param_integer('viewlimit', 10);
$views->copyableby = (object) array('group' => $group, 'institution' => $institution, 'owner' => null);
if ($group) {
    $views->group = $group;
    $helptext = get_string('choosetemplategrouppagedescription', 'view');
} else {
Exemplo n.º 15
0
$offset = param_integer('offset', 0);
define('GROUP', param_integer('group'));
$group = group_current_group();
if (!is_logged_in() && !$group->public) {
    throw new AccessDeniedException();
}
define('TITLE', $group->name . ' - ' . get_string('groupviews', 'view'));
$member = group_user_access($group->id);
$shared = param_boolean('shared', 0) && $member;
$can_edit = group_user_can_edit_views($group->id);
$smarty = smarty();
$smarty->assign('heading', $group->name);
if ($can_edit) {
    $data = View::get_myviews_data($limit, $offset, $group->id);
} else {
    $data = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, $offset);
}
$userid = $USER->get('id');
$pagination = build_pagination(array('url' => get_config('wwwroot') . 'view/groupviews.php?group=' . $group->id, 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
$smarty->assign('groupviews', 1);
$smarty->assign('member', $member);
$smarty->assign('views', $data->data);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('createviewform', pieform(create_view_form($group->id)));
$smarty->assign('createtemplateform', pieform(create_template_form($group->id)));
if ($can_edit) {
    // && !$shared) {
    $smarty->display('view/index.tpl');
} else {
    $smarty->display('view/sharedviews.tpl');
}
Exemplo n.º 16
0
addLoadEvent(function () {
    p = {$pagination['javascript']}
EOF;
if ($offset > 0) {
    $js .= <<<EOF
    if (\$('myviews')) {
        getFirstElementByTagAndClassName('a', null, 'myviews'). focus();
    }
EOF;
} else {
    $js .= <<<EOF
    if (\$('searchresultsheading')) {
        addElementClass('searchresultsheading', 'hidefocus');
        setNodeAttribute('searchresultsheading', 'tabIndex', -1);
        \$('searchresultsheading').focus();
    }
EOF;
}
$js .= '});';
$createviewform = pieform(create_view_form(null, 'mahara'));
$smarty = smarty(array('paginator'));
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $views);
$smarty->assign('institution', 'mahara');
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('query', param_variable('query', null));
$smarty->assign('querystring', get_querystring());
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
Exemplo n.º 17
0
$configdata = $bi->get('configdata');
if (!isset($configdata['showsharedviews'])) {
    $configdata['showsharedviews'] = 1;
}
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = $limit > 0 ? $limit : 5;
// Find out what order to sort them by (default is titles)
if (!isset($configdata['sortsharedviewsby']) || $configdata['sortsharedviewsby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) {
    $sortsharedviewsby = 'v.title';
} else {
    $sortsharedviewsby = 'v.mtime DESC';
}
// For group members, display a list of views that others have
// shared to the group
if (empty($configdata['showsharedviews'])) {
    $sharedviews = array('data' => array(), 'count' => 0, 'limit' => $limit, 'offset' => 0);
} else {
    $sharedviews = (array) View::get_sharedviews_data($limit, $offset, $groupid, $configdata['showsharedviews'] == 2 ? false : true, $sortsharedviewsby);
    foreach ($sharedviews['data'] as &$view) {
        if (!$editing && isset($view['template']) && $view['template']) {
            $view['form'] = pieform(create_view_form($group, null, $view->id));
        }
    }
}
if (!empty($configdata['showsharedviews'])) {
    $baseurl = $group_homepage_view->get_url();
    $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid . '&editing=' . $editing;
    $pagination = array('baseurl' => $baseurl, 'id' => 'sharedviews_pagination', 'datatable' => 'sharedviewlist', 'jsonscript' => 'blocktype/groupviews/sharedviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'));
    PluginBlocktypeGroupViews::render_items($sharedviews, 'blocktype:groupviews:sharedviews.tpl', $configdata, $pagination);
}
json_reply(false, array('data' => $sharedviews));
$group = group_current_group();
if (!is_logged_in() && !$group->public) {
    throw new AccessDeniedException();
}
define('TITLE', $group->name . ' - ' . get_string('groupviews', 'view'));
$can_edit = group_user_can_edit_views($group->id);
// If the user can edit group views, show a page similar to the my views
// page, otherwise just show a list of the views owned by this group that
// are visible to the user.
if ($can_edit) {
    $data = View::get_myviews_data($limit, $offset, $group->id);
    $createviewform = pieform(create_view_form($group->id));
} else {
    $data = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, $offset);
    // Add a copy view form for all templates in the list
    foreach ($data->data as &$v) {
        if ($v['template']) {
            $v['copyform'] = pieform(create_view_form(null, null, $v['id']));
        }
    }
}
$pagination = build_pagination(array('url' => get_config('wwwroot') . 'view/groupviews.php?group=' . $group->id, 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
$smarty = smarty();
$smarty->assign('views', $data->data);
$smarty->assign('pagination', $pagination['html']);
if ($can_edit) {
    $smarty->assign('createviewform', $createviewform);
    $smarty->display('view/index.tpl');
} else {
    $smarty->display('view/groupviews.tpl');
}