Example #1
0
require dirname(dirname(__FILE__)) . '/init.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'group.php';
require_once 'pieforms/pieform.php';
//@todo: group menu; group sideblock
$limit = param_integer('limit', 5);
$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)));
Example #2
0
 */
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', ''));
$views->offset = param_integer('viewoffset', 0);
$views->limit = param_integer('viewlimit', 10);
Example #3
0
 /**
  * Creates a new View for the given user, based on the given information
  * about the view.
  *
  * Validation of the view data is performed, then the View is created. If
  * the View is to be owned by a group, that group is given access to it.
  *
  * @param array $viewdata Data about the view. You can pass in most fields
  *                        that appear in the view table.
  *
  *                        Note that you set who owns the View by setting
  *                        either the owner, group or institution field as
  *                        approriate.
  *
  *                        Currently, you cannot pass in access data. Use
  *                        $view->set_access() after retrieving the $view
  *                        object.
  *
  * @param int $userid The user who has issued the command to create the
  *                    View (note: this is different from the "owner" of the
  *                    View - a group or institution could be the "owner",
  *                    but it's a _user_ who requests a View is created for it)
  * @return View The created View
  * @throws SystemException if the View data is invalid - mostly this is due
  *                         to owner information being specified incorrectly.
  */
 private static function _create(&$viewdata, $userid)
 {
     // If no owner information is provided, assume that the view is being
     // created by the user for themself
     if (!isset($viewdata['owner']) && !isset($viewdata['group']) && !isset($viewdata['institution'])) {
         $viewdata['owner'] = $userid;
     }
     if (isset($viewdata['owner'])) {
         if ($viewdata['owner'] != $userid) {
             $userobj = new User();
             $userobj->find_by_id($userid);
             if (!$userobj->is_admin_for_user($viewdata['owner'])) {
                 throw new SystemException("View::_create: User {$userid} is not allowed to create a view for owner {$viewdata['owner']}");
             }
         }
         // Users can only have one view of each non-portfolio type
         if (isset($viewdata['type']) && $viewdata['type'] != 'portfolio' && get_record('view', 'owner', $viewdata['owner'], 'type', $viewdata['type'])) {
             $viewdata['type'] = 'portfolio';
         }
         // Try to create the view with the owner's default theme if that theme is set by an
         // institution (i.e. if it's different from the site theme)
         //
         // This needs to be modified if users are ever allowed to change their own theme
         // preference.  Currently it's okay because users' themes are forced on them by
         // the site or institution default, but if some users are allowed to change their
         // own theme pref, we should create those users' views without a theme.
         if (!get_config('userscanchooseviewthemes') && !isset($viewdata['theme']) && (!isset($viewdata['type']) || $viewdata['type'] != 'dashboard')) {
             global $USER;
             if ($viewdata['owner'] == $USER->get('id')) {
                 $owner = $USER;
             } else {
                 $owner = new User();
                 $owner->find_by_id($viewdata['owner']);
             }
             $ownerthemedata = $owner->get('institutiontheme');
             $ownertheme = isset($ownerthemedata->basename) ? $ownerthemedata->basename : null;
             if ($ownertheme && $ownertheme != get_config('theme') && $ownertheme != 'custom') {
                 $viewdata['theme'] = $ownertheme;
             }
         }
     }
     if (isset($viewdata['group'])) {
         require_once 'group.php';
         if (!group_user_can_edit_views($viewdata['group'], $userid)) {
             throw new SystemException("View::_create: User {$userid} is not permitted to create a view for group {$viewdata['group']}");
         }
     }
     if (isset($viewdata['institution'])) {
         $user = new User();
         $user->find_by_id($userid);
         if (!$user->can_edit_institution($viewdata['institution'])) {
             throw new SystemException("View::_create: User {$userid} is not permitted to create a view for institution {$viewdata['institution']}");
         }
     }
     // Create the view
     $defaultdata = array('numcolumns' => 2, 'numrows' => 1, 'columnsperrow' => self::default_columnsperrow(), 'template' => 0, 'type' => 'portfolio', 'title' => array_key_exists('title', $viewdata) ? $viewdata['title'] : self::new_title(get_string('Untitled', 'view'), (object) $viewdata), 'anonymise' => 0);
     $data = (object) array_merge($defaultdata, $viewdata);
     if ($data->type == 'portfolio' && (!isset($data->url) || is_null($data->url) || !strlen($data->url))) {
         $data->urlid = generate_urlid($data->title, get_config('cleanurlviewdefault'), 3, 100);
         $data->urlid = self::new_urlid($data->urlid, $data);
     }
     $view = new View(0, $data);
     $view->commit();
     if (isset($viewdata['group']) && (empty($viewdata['type']) || !empty($viewdata['type']) && $viewdata['type'] != 'grouphomepage')) {
         require_once 'activity.php';
         // Although group views are owned by the group, the view creator is treated as owner here.
         // So we need to ignore them from the activity_occured email.
         $beforeusers[$userid] = get_record('usr', 'id', $userid);
         // By default, group views should be visible to the group
         insert_record('view_access', (object) array('view' => $view->get('id'), 'group' => $viewdata['group'], 'ctime' => db_format_timestamp(time())));
         // Notify group members
         $accessdata = new StdClass();
         $accessdata->view = $view->get('id');
         $accessdata->oldusers = $beforeusers;
         activity_occurred('viewaccess', $accessdata);
     }
     if (isset($viewdata['layout'])) {
         // e.g. importing via LEAP2A
         $layoutsrowscols = get_records_select_array('view_layout_rows_columns', 'viewlayout = ?', array($viewdata['layout']));
         if ($layoutsrowscols) {
             delete_records('view_rows_columns', 'view', $view->get('id'));
             foreach ($layoutsrowscols as $layoutrow) {
                 insert_record('view_rows_columns', (object) array('view' => $view->get('id'), 'row' => $layoutrow->row, 'columns' => self::$layoutcolumns[$layoutrow->columns]->columns));
             }
         }
     }
     return new View($view->get('id'));
     // Reread to ensure defaults are set
 }
 /**
  * Creates a new View for the given user, based on the given information 
  * about the view.
  *
  * Validation of the view data is performed, then the View is created. If 
  * the View is to be owned by a group, that group is given access to it.
  *
  * @param array $viewdata Data about the view. You can pass in most fields 
  *                        that appear in the view table.
  *
  *                        Note that you set who owns the View by setting 
  *                        either the owner, group or institution field as 
  *                        approriate.
  *
  *                        Currently, you cannot pass in access data. Use 
  *                        $view->set_access() after retrieving the $view 
  *                        object.
  *
  * @param int $userid The user who has issued the command to create the 
  *                    View (note: this is different from the "owner" of the 
  *                    View - a group or institution could be the "owner",
  *                    but it's a _user_ who requests a View is created for it)
  * @return View The created View
  * @throws SystemException if the View data is invalid - mostly this is due 
  *                         to owner information being specified incorrectly.
  */
 private static function _create(&$viewdata, $userid)
 {
     // If no owner information is provided, assume that the view is being
     // created by the user for themself
     if (!isset($viewdata['owner']) && !isset($viewdata['group']) && !isset($viewdata['institution'])) {
         $viewdata['owner'] = $userid;
     }
     if (isset($viewdata['owner'])) {
         if ($viewdata['owner'] != $userid) {
             $userobj = new User();
             $userobj->find_by_id($userid);
             if (!$userobj->is_admin_for_user($viewdata['owner'])) {
                 throw new SystemException("View::_create: User {$userid} is not allowed to create a view for owner {$viewdata['owner']}");
             }
         }
         // Users can only have one view of each non-portfolio type
         if (isset($viewdata['type']) && $viewdata['type'] != 'portfolio' && get_record('view', 'owner', $viewdata['owner'], 'type', $viewdata['type'])) {
             $viewdata['type'] = 'portfolio';
         }
         // Try to create the view with the owner's default theme if that theme is set by an
         // institution (i.e. if it's different from the site theme)
         //
         // This needs to be modified if users are ever allowed to change their own theme
         // preference.  Currently it's okay because users' themes are forced on them by
         // the site or institution default, but if some users are allowed to change their
         // own theme pref, we should create those users' views without a theme.
         if (!get_config('userscanchooseviewthemes') && !isset($viewdata['theme']) && (!isset($viewdata['type']) || $viewdata['type'] != 'dashboard')) {
             global $USER;
             if ($viewdata['owner'] == $USER->get('id')) {
                 $owner = $USER;
             } else {
                 $owner = new User();
                 $owner->find_by_id($viewdata['owner']);
             }
             $ownertheme = $owner->get('theme');
             if ($ownertheme && $ownertheme != get_config('theme')) {
                 $viewdata['theme'] = $ownertheme;
             }
         }
     }
     if (isset($viewdata['group'])) {
         require_once 'group.php';
         if (!group_user_can_edit_views($viewdata['group'], $userid)) {
             throw new SystemException("View::_create: User {$userid} is not permitted to create a view for group {$viewdata['group']}");
         }
     }
     if (isset($viewdata['institution'])) {
         $user = new User();
         $user->find_by_id($userid);
         if (!$user->can_edit_institution($viewdata['institution'])) {
             throw new SystemException("View::_create: User {$userid} is not permitted to create a view for institution {$viewdata['institution']}");
         }
     }
     // Create the view
     $defaultdata = array('numcolumns' => 3, 'template' => 0, 'type' => 'portfolio', 'title' => self::new_title(get_string('Untitled', 'view'), (object) $viewdata));
     $data = (object) array_merge($defaultdata, $viewdata);
     $view = new View(0, $data);
     $view->commit();
     if (isset($viewdata['group'])) {
         // By default, group views should be visible to the group
         insert_record('view_access', (object) array('view' => $view->get('id'), 'group' => $viewdata['group']));
     }
     return new View($view->get('id'));
     // Reread to ensure defaults are set
 }
Example #5
0
 /**
  * Creates a new View for the given user, based on the given information 
  * about the view.
  *
  * Validation of the view data is performed, then the View is created. If 
  * the View is to be owned by a group, that group is given access to it.
  *
  * @param array $viewdata Data about the view. You can pass in most fields 
  *                        that appear in the view table.
  *
  *                        Note that you set who owns the View by setting 
  *                        either the owner, group or institution field as 
  *                        approriate.
  *
  *                        Currently, you cannot pass in access data. Use 
  *                        $view->set_access() after retrieving the $view 
  *                        object.
  *
  * @param int $userid The user who has issued the command to create the 
  *                    View (note: this is different from the "owner" of the 
  *                    View - a group or institution could be the "owner",
  *                    but it's a _user_ who requests a View is created for it)
  * @return View The created View
  * @throws SystemException if the View data is invalid - mostly this is due 
  *                         to owner information being specified incorrectly.
  */
 private static function _create(&$viewdata, $userid)
 {
     // If no owner information is provided, assume that the view is being
     // created by the user for themself
     if (!isset($viewdata['owner']) && !isset($viewdata['group']) && !isset($viewdata['institution'])) {
         $viewdata['owner'] = $userid;
     }
     if (isset($viewdata['owner'])) {
         if ($viewdata['owner'] != $userid) {
             $userobj = new User();
             $userobj->find_by_id($userid);
             if (!$userobj->is_admin_for_user($viewdata['owner'])) {
                 throw new SystemException("View::_create: User {$userid} is not allowed to create a view for owner {$viewdata['owner']}");
             }
         }
     }
     if (isset($viewdata['group'])) {
         require_once 'group.php';
         if (!group_user_can_edit_views($viewdata['group'], $userid)) {
             throw new SystemException("View::_create: User {$userid} is not permitted to create a view for group {$viewdata['group']}");
         }
     }
     if (isset($viewdata['institution'])) {
         $user = new User();
         $user->find_by_id($userid);
         if (!$user->can_edit_institution($viewdata['institution'])) {
             throw new SystemException("View::_create: User {$userid} is not permitted to create a view for institution {$viewdata['institution']}");
         }
     }
     // Create the view
     $defaultdata = array('numcolumns' => 3, 'template' => 0, 'type' => 'portfolio', 'title' => self::new_title(get_string('Untitled', 'view'), (object) $viewdata));
     $data = (object) array_merge($defaultdata, $viewdata);
     $view = new View(0, $data);
     $view->commit();
     if (isset($viewdata['group'])) {
         // By default, group views should be visible to the group
         $view->set_access(array(array('type' => 'group', 'id' => $viewdata['group'], 'startdate' => null, 'stopdate' => null, 'role' => null)));
     }
     return $view;
 }
Example #6
0
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'internal');
require_once 'view.php';
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'internal');
define('SECTION_PAGE', 'notes');
define('TITLE', get_string('Notes', 'artefact.internal'));
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
$baseurl = get_config('wwwroot') . 'artefact/internal/notes.php';
$params = array();
if ($group = param_integer('group', null)) {
    define('MENUITEM', 'groups');
    define('GROUP', $group);
    require_once 'group.php';
    if (!group_user_can_edit_views($group, $USER->get('id'))) {
        throw new AccessDeniedException(get_string('accessdenied', 'error'));
    }
    $groupobj = group_current_group();
    $pageheading = get_string('notesfor', 'artefact.internal', $groupobj->name);
    $where = '"group" = ?';
    $values = array($group);
    $params['group'] = $group;
} else {
    if ($institution = param_alpha('institution', null)) {
        if ($institution == 'mahara') {
            define('ADMIN', 1);
            define('MENUITEM', 'configsite');
            $pageheading = get_string('Notes', 'artefact.internal');
        } else {
            define('INSTITUTIONALADMIN', 1);
Example #7
0
<?php

/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @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';
define('TITLE', get_string('share', 'view'));
define('MENUITEM', 'groups/share');
define('GROUP', param_integer('group'));
$group = group_current_group();
if (!group_user_can_edit_views($group)) {
    throw new AccessDeniedException();
}
$accesslists = View::get_accesslists(null, $group->id);
$smarty = smarty();
$smarty->assign('heading', $group->name);
$smarty->assign('subsectionheading', TITLE);
$smarty->assign('headingclass', 'page-header');
$smarty->assign('accesslists', $accesslists);
$smarty->display('view/share.tpl');
 * @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 {
    if ($institution) {
        $views->institution = $institution;