Пример #1
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     require_once 'view.php';
     $configdata = $instance->get('configdata');
     $nviews = isset($configdata['limit']) ? intval($configdata['limit']) : 5;
     $sort = array(array('column' => 'mtime', 'desc' => true));
     $views = View::view_search(null, null, null, null, $nviews, 0, true, $sort, array('portfolio'), null, null, null, null, null, true);
     $smarty = smarty_core();
     $smarty->assign('loggedin', $USER->is_logged_in());
     $smarty->assign('views', $views->data);
     return $smarty->fetch('blocktype:newviews:newviews.tpl');
 }
Пример #2
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $userid = $instance->get_view()->get('owner');
     if (!$userid) {
         return '';
     }
     $smarty = smarty_core();
     // Get viewable views
     $views = View::view_search(null, null, (object) array('owner' => $userid), null, null, 0, true, null, array('portfolio'));
     $views = $views->count ? $views->data : array();
     $smarty->assign('VIEWS', $views);
     return $smarty->fetch('blocktype:myviews:myviews.tpl');
 }
Пример #3
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $userid = $instance->get_view()->get('owner');
     if (!$userid) {
         return '';
     }
     $smarty = smarty_core();
     // Get viewable views
     $views = View::view_search(null, null, (object) array('owner' => $userid), null, 10, 0, true, null, array('portfolio'), null, null, null, null, null, true);
     $views = (array) $views;
     $viewid = $instance->get_view()->get('id');
     $baseurl = $instance->get_view()->get_url();
     $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'view=' . $viewid . '&editing=' . $editing;
     $pagination = array('baseurl' => $baseurl, 'id' => 'myviews_pagination', 'datatable' => 'myviewlist', 'jsonscript' => 'blocktype/myviews/myviews.json.php', 'resultcounttextsingular' => get_string('result'), 'resultcounttextplural' => get_string('results'));
     self::render_items($views, 'blocktype:myviews:myviewspaginator.tpl', array(), $pagination);
     $smarty->assign('myviews', $views);
     return $smarty->fetch('blocktype:myviews:myviews.tpl');
 }
Пример #4
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');
}
Пример #5
0
function get_views_for_user($username, $query = null)
{
    global $REMOTEWWWROOT, $USER;
    list($user, $authinstance) = find_remote_user($username, $REMOTEWWWROOT);
    if (!$user) {
        return false;
    }
    $USER->reanimate($user->id, $authinstance->instanceid);
    require_once 'view.php';
    $data = View::view_search($query, null, (object) array('owner' => $USER->get('id')));
    $data->displayname = display_name($user);
    if ($data->count) {
        foreach ($data->data as &$v) {
            $v['url'] = '/view/view.php?id=' . $v['id'];
            $v['fullurl'] = get_config('wwwroot') . 'view/view.php?id=' . $v['id'];
        }
    }
    return $data;
}
Пример #6
0
function get_views_for_user($username, $query = null)
{
    global $REMOTEWWWROOT, $USER;
    list($user, $authinstance) = find_remote_user($username, $REMOTEWWWROOT);
    if (!$user) {
        return false;
    }
    $USER->reanimate($user->id, $authinstance->instanceid);
    require_once 'view.php';
    $data = View::view_search($query, null, (object) array('owner' => $USER->get('id')), null, null, 0, true, null, null, true);
    require_once 'collection.php';
    $data->collections = Collection::get_mycollections_data(0, 0, $USER->get('id'));
    foreach ($data->collections->data as $c) {
        $cobj = new Collection($c->id);
        if ($c->numviews > 0) {
            $c->url = $cobj->get_url();
        } else {
            $c->url = '';
        }
    }
    $data->displayname = display_name($user);
    return $data;
}
Пример #7
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;
 }
Пример #8
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);
     $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;
 }
Пример #9
0
 /**
  * Generate sitemap(s) and an index
  *
  * @return bool
  */
 public function generate()
 {
     // check that the sitemaps directory exists and create it if it doesn't
     check_dir_exists($this->directory, true);
     // this is used by PluginInteractionForum::get_active_topics
     $USER = new User();
     // create a new sitemap
     $this->create_sitemap();
     // get a list of public groups
     $publicgroups = get_records_select_array('group', 'public = 1 AND deleted = 0');
     if (!empty($publicgroups)) {
         foreach ($publicgroups as $group) {
             if (isset($group->mtime) && $this->check_date($group->mtime)) {
                 // each group gets a url entry
                 $groupurl = group_homepage_url($group);
                 $groupurl = utf8_encode(htmlspecialchars($groupurl, ENT_QUOTES, 'UTF-8'));
                 $grouplastmod = format_date(strtotime($group->mtime), 'strftimew3cdate');
                 $this->add_url($groupurl, $grouplastmod);
             }
             // build a list of forums in each public group
             $forums = get_forum_list($group->id);
             $forumids = array();
             foreach ($forums as $forum) {
                 $forumids[] = $forum->id;
             }
             // active topics within the specified forums (public only)
             $activetopics = PluginInteractionForum::get_active_topics(0, 0, 0, $forumids);
             foreach ($activetopics['data'] as $topic) {
                 if (isset($topic->mtime) && $this->check_date($topic->mtime) || isset($topic->ctime) && $this->check_date($topic->ctime)) {
                     $forumurl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topic->id;
                     $forumurl = utf8_encode(htmlspecialchars($forumurl, ENT_QUOTES, 'UTF-8'));
                     // mtime will be set if the last post has been edited
                     if (isset($topic->mtime) && strtotime($topic->mtime) !== FALSE) {
                         $forumlastmod = format_date(strtotime($topic->mtime), 'strftimew3cdate');
                     } else {
                         $forumlastmod = format_date(strtotime($topic->ctime), 'strftimew3cdate');
                     }
                     $this->add_url($forumurl, $forumlastmod);
                 }
             }
         }
     }
     // views shared with the public
     // grouphomepage type views are handled above
     $types = array('portfolio');
     $views = View::view_search(null, null, null, null, null, 0, true, null, $types);
     if (!empty($views->data)) {
         foreach ($views->data as $view) {
             if (isset($view['mtime']) && $this->check_date($view['mtime'])) {
                 $viewurl = utf8_encode(htmlspecialchars($view['fullurl'], ENT_QUOTES, 'UTF-8'));
                 $viewlastmod = format_date(strtotime($view['mtime']), 'strftimew3cdate');
                 $this->add_url($viewurl, $viewlastmod);
             }
         }
     }
     // add the urlset and print the xml out
     // only if the urlset has any children
     if ($this->currenturlset->hasChildNodes()) {
         $this->save_sitemap(true);
     }
     return true;
 }
Пример #10
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));
Пример #11
0
 *
 * @package    mahara
 * @subpackage blocktype/groupviews
 * @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.
 *
 */
/**
 * returns shared views in a given group id
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('blocktype', 'myviews');
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'pieforms/pieform.php';
$offset = param_integer('offset', 0);
$viewid = param_integer('view');
$editing = param_boolean('editing', false);
$dashboard = new View($viewid);
if (!can_view_view($dashboard)) {
    json_reply(true, get_string('accessdenied', 'error'));
}
$views = View::view_search(null, null, (object) array('owner' => $userid), null, 10, $offset, true, null, array('portfolio'), null, null, null, null, null, true);
$views = (array) $views;
$baseurl = $dashboard->get_url();
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'view=' . $viewid . '&editing=' . $editing;
$pagination = array('baseurl' => $baseurl, 'id' => 'myviews_pagination', 'datatable' => 'myviewlist', 'jsonscript' => 'blocktype/myviews/myviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'));
PluginBlocktypeMyViews::render_items($views, 'blocktype:myviews:myviewspaginator.tpl', array(), $pagination);
json_reply(false, array('data' => $views));