* @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); define('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require_once get_config('libroot') . 'view.php'; $group = param_integer('group', null); $institution = param_alphanum('institution', null); $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->group = param_integer('group', null); $views->institution = param_alphanum('institution', null); $views->copyableby = (object) array('group' => $group, 'institution' => $institution); if (!($group || $institution)) { $views->copyableby->owner = $USER->get('id'); } $searchcollection = param_integer('searchcollection', null); $sort[] = array('column' => 'title', 'desc' => 0); if ($searchcollection) { array_unshift($sort, array('column' => 'collection', 'desc' => 0, 'tablealias' => 'cv')); $views->collection = $searchcollection; } $views->sort = (object) $sort; View::get_templatesearch_data($views); json_reply(false, array('message' => null, 'data' => array('table' => $views->html, 'pagination' => $views->pagination['html'], 'count' => $views->count)));
<?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); define('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'searchlib.php'; $tag = param_variable('tag', null); $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $sort = param_alpha('sort', 'name'); $type = param_alpha('type', null); $owner = (object) array('type' => 'user', 'id' => $USER->get('id')); $data = get_portfolio_items_by_tag($tag, $owner, $limit, $offset, $sort, $type); build_portfolio_search_html($data); $data->tagdisplay = is_null($tag) ? get_string('alltags') : hsc(str_shorten_text($tag, 50)); $data->tagurl = urlencode($tag); json_reply(false, array('data' => $data));
* @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; $result = get_records_sql_array('SELECT a.id, a.title, a.note, (u.profileicon = a.id) AS isdefault, COUNT (DISTINCT aa.artefact) AS attachcount, COUNT(DISTINCT va.view) AS viewcount, COUNT(DISTINCT s.id) AS skincount FROM {artefact} a LEFT OUTER JOIN {view_artefact} va ON va.artefact = a.id LEFT OUTER JOIN {artefact_attachment} aa ON aa.attachment = a.id LEFT OUTER JOIN {skin} s ON (s.bodybgimg = a.id OR s.viewbgimg = a.id) LEFT OUTER JOIN {usr} u ON (u.id = a.owner) WHERE artefacttype = \'profileicon\' AND a.owner = ? GROUP BY a.id, a.title, a.note, isdefault ORDER BY a.id', array($USER->get('id'))); $lastrow = array('id' => 0, 'isdefault' => 't', 'title' => get_string('standardavatartitle', 'artefact.file'), 'note' => get_string('standardavatarnote', 'artefact.file')); $usersdefaulticon = record_exists_select('usr', 'profileicon IS NULL AND id = ?', array($USER->get('id'))); if (!$usersdefaulticon) { $lastrow['isdefault'] = 'f'; } if (!$result) { $result = array(); } $result[] = $lastrow; $data['error'] = false; $data['data'] = $result; $data['count'] = $result ? count($result) : 0; json_reply(false, $data);
<?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); define('JSON', 1); define('NOSESSKEY', 1); require 'init.php'; json_reply(false, $USER->get('sesskey'));
$extradata->blockid = $blockid; } if (empty($extradata->view) || empty($extradata->annotation) || empty($extradata->blockid)) { json_reply('local', get_string('annotationinformationerror', 'artefact.annotation')); } if (!can_view_view($extradata->view)) { json_reply('local', get_string('noaccesstoview', 'view')); } if (!artefact_in_view($extradata->annotation, $extradata->view)) { json_reply('local', get_string('accessdenied', 'error')); } if (!empty($extradata->artefact) && !artefact_in_view($extradata->artefact, $extradata->view)) { json_reply('local', get_string('accessdenied', 'error')); } if ($ispagination) { // This is not really working yet. Need to do more work on artefact/artefact.php $options = ArtefactTypeAnnotationfeedback::get_annotation_feedback_options(); $options->limit = $limit; $options->offset = $offset; $options->view = $extradata->view; $options->annotation = $extradata->annotation; $options->artefact = $extradata->artefact; $options->block = $extradata->blockid; $annotationfeedback = ArtefactTypeAnnotationfeedback::get_annotation_feedback($options); json_reply(false, array('data' => $annotationfeedback)); } else { $view = new View($extradata->view); $annotationartefact = artefact_instance_from_id($extradata->annotation); list($feedbackcount, $annotationfeedback) = ArtefactTypeAnnotationfeedback::get_annotation_feedback_for_view($annotationartefact, $view, $extradata->blockid); json_reply(false, array('data' => $annotationfeedback)); }
define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; json_headers(); $name = param_variable('name'); $itemid = param_variable('itemid'); $data = new StdClass(); $data->title = $name; if ($itemid == 'new') { try { $displayorders = get_records_array('group_category', '', '', '', 'displayorder'); $max = 0; if ($displayorders) { foreach ($displayorders as $r) { $max = $r->displayorder >= $max ? $r->displayorder + 1 : $max; } } $data->displayorder = $max; $itemid = insert_record('group_category', $data, 'id', true); } catch (Exception $e) { json_reply('local', get_string('savefailed', 'admin')); } } else { $data->id = (int) $itemid; try { update_record('group_category', $data, 'id'); } catch (Exception $e) { json_reply('local', get_string('savefailed', 'admin')); } } json_reply(false, array('id' => (int) $itemid));
/** * returns shared collections in 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['showsharedcollections'])) { $configdata['showsharedcollections'] = 1; } $limit = isset($configdata['count']) ? intval($configdata['count']) : 5; $limit = $limit > 0 ? $limit : 5; $sharedcollections = (array) View::get_sharedcollections_data($limit, $offset, $groupid); if (!empty($configdata['showsharedcollections']) && isset($sharedcollections)) { $baseurl = $group_homepage_view->get_url(); $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid; $pagination = array('baseurl' => $baseurl, 'id' => 'sharedcollections_pagination', 'datatable' => 'sharedcollectionlist', 'jsonscript' => 'blocktype/groupviews/sharedcollections.json.php', 'resultcounttextsingular' => get_string('collection', 'collection'), 'resultcounttextplural' => get_string('collections', 'collection')); PluginBlocktypeGroupViews::render_items($sharedcollections, 'blocktype:groupviews:sharedcollections.tpl', $configdata, $pagination); } json_reply(false, array('data' => $sharedcollections));
GROUP BY u.id, u.firstname, u.lastname, u.studentid, u.suspendedctime, u.suspendedreason, ua.firstname, ua.lastname, u.expiry ORDER BY ' . ($type == 'expired' ? 'u.expiry' : 'u.suspendedctime') . ', u.id LIMIT ? OFFSET ?', array($limit, $offset)); if (!$data) { $data = array(); } else { $institutions = get_records_sql_array(' SELECT ui.usr, ui.studentid, i.displayname FROM {usr_institution} ui INNER JOIN {institution} i ON ui.institution = i.name WHERE ui.usr IN (' . join(',', array_keys($data)) . ')', null); if ($institutions) { foreach ($institutions as &$i) { $data[$i->usr]->institutions[] = $i->displayname; $data[$i->usr]->institutionids[] = $i->studentid; } } $data = array_values($data); foreach ($data as &$record) { $record->name = full_name($record); $record->firstname = $record->cusrfirstname; $record->lastname = $record->cusrlastname; $record->cusrname = full_name($record); $record->expiry = $record->expiry ? format_date($record->expiry, 'strftimew3cdate') : '-'; unset($record->firstname, $record->lastname); } } json_reply(false, array('count' => $count, 'limit' => $limit, 'offset' => $offset, 'data' => $data));
} $authinstance = new stdClass(); // Get the auth instance with the highest priority number (which is // the instance with the lowest priority). // TODO: rethink 'priority' as a fieldname... it's backwards!! $lastinstance = get_records_array('auth_instance', 'institution', $institution, 'priority DESC', '*', '0', '1'); if ($lastinstance == false) { $authinstance->priority = 0; } else { $authinstance->priority = $lastinstance[0]->priority + 1; } $authinstance->instancename = $plugin; $authinstance->institution = $institution; $authinstance->authname = $plugin; $authinstance->id = insert_record('auth_instance', $authinstance, 'id', true); json_reply(false, array('id' => $authinstance->id, 'name' => ucfirst($authinstance->authname), 'authname' => $authinstance->authname)); exit; } $authclass = new $classname(); $form = $authclass->get_instance_config_options($institution, $instanceid); $form['name'] = 'auth_config'; $form['plugintype'] = 'auth'; $form['pluginname'] = strtolower($plugin); $form['elements']['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('submit'), get_string('cancel')), 'goto' => 'addauthority.php?c=1'); $form = pieform($form); $smarty = smarty(); if ($add) { $smarty->assign('PAGETITLE', get_string('addauthority', 'auth')); } else { $smarty->assign('PAGETITLE', get_string('editauthority', 'auth')); }
* @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('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require 'searchlib.php'; safe_require('search', 'internal'); try { $query = param_variable('query'); } catch (ParameterException $e) { json_reply('missingparameter', 'Missing parameter \'query\''); } $type = param_variable('type', 'user'); $limit = param_integer('limit', 20); $offset = param_integer('offset', 0); switch ($type) { case 'group': $data = search_group($query, $limit, $offset, 'all'); $data['type'] = 'group'; break; default: $data = search_user($query, $limit, $offset); $data['type'] = 'user'; break; } json_headers();
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));
// Bad menu item type json_reply('local', get_string('badmenuitemtype', 'admin')); } } $data->title = $name; if ($itemid == 'new') { $data->public = $public; // set displayorder to be after all the existing menu items try { $displayorders = get_records_array('site_menu', 'public', $data->public, '', 'displayorder'); $max = 0; if ($displayorders) { foreach ($displayorders as $r) { $max = $r->displayorder >= $max ? $r->displayorder + 1 : $max; } } $data->displayorder = $max; insert_record('site_menu', $data); } catch (Exception $e) { json_reply('local', get_string('savefailed', 'admin')); } } else { $data->id = $itemid; try { update_record('site_menu', $data, 'id'); } catch (Exception $e) { json_reply('local', get_string('savefailed', 'admin')); } } json_reply(false, get_string('menuitemsaved', 'admin'));
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz * */ define('PUBLIC', 1); define('INTERNAL', 1); define('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'group.php'; require_once 'searchlib.php'; $id = param_integer('id'); $query = trim(param_variable('query', '')); $offset = param_integer('offset', 0); $limit = param_integer('limit', 10); define('GROUP', $id); $group = group_current_group(); if (!is_logged_in() && !$group->public) { throw new AccessDeniedException(get_string('accessdenied', 'error')); } $membershiptype = param_variable('membershiptype', ''); if (!empty($membershiptype)) { if (group_user_access($id) != 'admin') { json_reply('local', get_string('accessdenied', 'error')); } } $results = get_group_user_search_results($group->id, $query, $offset, $limit, $membershiptype); if (!param_integer('html', 1)) { json_reply(false, $results); } list($html, $pagination, $count, $offset, $membershiptype) = group_get_membersearch_data($results, $id, $query, $membershiptype); json_reply(false, array('message' => null, 'data' => array('tablerows' => $html, 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript'], 'count' => $count, 'results' => $count . ' ' . ($count == 1 ? get_string('result') : get_string('results')), 'offset' => $offset, 'membershiptype' => $membershiptype)));
$bi = new BlockInstance($blockid); if (!can_view_view($bi->get('view'))) { json_reply(true, get_string('accessdenied', 'error')); } $configdata = $bi->get('configdata'); $limit = isset($configdata['count']) ? $configdata['count'] : 5; $configdata['countcomments'] = true; $configdata['viewid'] = $bi->get('view'); $posts = ArtefactTypeBlogpost::get_posts($configdata['artefactid'], $limit, $offset, $configdata); $template = 'artefact:blog:viewposts.tpl'; $baseurl = $bi->get_view()->get_url(); $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $blockid; $pagination = array('baseurl' => $baseurl, 'id' => 'blogpost_pagination_' . $blockid, 'datatable' => 'postlist_' . $blockid, 'jsonscript' => 'artefact/blog/posts.json.php'); ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination); } else { // No block, we're just rendering the blog by itself. $limit = param_integer('limit', ArtefactTypeBlog::pagination); $blogid = param_integer('artefact'); $viewid = param_integer('view'); if (!can_view_view($viewid)) { json_reply(true, get_string('accessdenied', 'error')); } $options = array('viewid' => $viewid, 'countcomments' => true); $posts = ArtefactTypeBlogpost::get_posts($blogid, $limit, $offset, $options); $template = 'artefact:blog:viewposts.tpl'; $baseurl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $blogid . '&view=' . $viewid; $pagination = array('baseurl' => $baseurl, 'id' => 'blogpost_pagination', 'datatable' => 'postlist', 'jsonscript' => 'artefact/blog/posts.json.php'); ArtefactTypeBlogpost::render_posts($posts, $template, $options, $pagination); } json_reply(false, array('data' => $posts));
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @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('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require_once get_config('libroot') . 'view.php'; if (!($data = View::new_token(param_integer('view')))) { json_reply(true, get_string('createviewtokenfailed', 'view')); } json_reply(false, array('message' => null, 'data' => $data));
* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package mahara * @subpackage admin * @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('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; json_headers(); $itemid = param_integer('itemid'); if (!delete_records('site_menu', 'id', $itemid)) { json_reply('local', get_string('deletefailed', 'admin')); } json_reply(false, get_string('menuitemdeleted', 'admin'));
if ('artefact_multirecipient_notification' === $table) { delete_messages_mr($idspertable, $USER->get('id')); } else { if ('notification_internal_activity' === $table) { $strids = join(',', array_map('db_quote', $idspertable)); $userid = $USER->get('id'); // Remove parent pointers to messages we're about to delete // Use temp table in subselect for Mysql compat. execute_sql("\n UPDATE {notification_internal_activity}\n SET parent = NULL\n WHERE parent IN (\n SELECT id FROM (\n SELECT id FROM {notification_internal_activity} WHERE id IN ({$strids}) AND usr = ?\n ) AS temp\n )", array($userid)); delete_records_select('notification_internal_activity', "id IN ({$strids}) AND usr = ?", array($userid)); if ($deleteunread) { $newunread = $USER->add_unread(-$deleteunread); } } } $countdeleted += count($idspertable); } db_commit(); $message = get_string('deletednotifications1', 'activity', $countdeleted); } } // ------------ Change ------------ // use the new function to show from - and to user $newhtml = activitylistin_html($type, $limit, $offset); // --------- End Change ----------- if (isset($newunread)) { $newhtml['newunreadcount'] = $newunread; $newhtml['newimage'] = $THEME->get_url($newunread ? 'images/newmail.png' : 'images/message.png'); } json_reply(false, (object) array('message' => $message, 'data' => $newhtml));
// Check that we can actually access the view and not just hacking the viewid passed in if (!can_view_view($view)) { $result->message = get_string('updatewatchlistfailed', 'view'); json_reply('local', $result); } $title = hsc($view->get('title')); if (get_record('usr_watchlist_view', 'usr', $data->usr, 'view', $viewid)) { if (!delete_records('usr_watchlist_view', 'usr', $data->usr, 'view', $viewid)) { $result->message = get_string('updatewatchlistfailed', 'view'); json_reply('local', $result); } $result->message = get_string('removedfromwatchlist', 'view'); if ($artefact) { $result->newtext = get_string('addtowatchlistartefact', 'view', $title); } else { $result->newtext = get_string('addtowatchlist', 'view'); } json_reply(false, $result); } if (!insert_record('usr_watchlist_view', $data)) { $result->message = get_string('updatewatchlistfailed', 'view'); json_reply('local', $result); } $result->message = get_string('addedtowatchlist', 'view'); if ($artefact) { $result->newtext = get_string('removefromwatchlistartefact', 'view', $title); } else { $result->newtext = get_string('removefromwatchlist', 'view'); } json_reply(false, $result);
$type = 'users'; } if ($type == 'historical') { $field = isset($extradata->field) ? $extradata->field : 'count_usr'; } if ($type == 'institutions') { $sort = isset($extradata->sort) ? $extradata->sort : 'displayname'; $sortdesc = isset($extradata->sortdesc) ? $extradata->sortdesc : false; } switch ($type) { case 'institutions': $data = institution_comparison_stats_table($limit, $offset, $sort, $sortdesc); break; case 'historical': $data = historical_stats_table($limit, $offset, $field); break; case 'content': $data = content_stats_table($limit, $offset); break; case 'groups': $data = group_stats_table($limit, $offset); break; case 'views': $data = view_stats_table($limit, $offset); break; case 'users': default: $data = user_stats_table($limit, $offset); } json_reply(false, (object) array('message' => false, 'data' => $data));
<?php /** * * @package mahara * @subpackage artefact-flexifact * @author EdICT Training 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); define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; safe_require('artefact', 'flexifact'); $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $flexifact = ArtefactTypeFlexifact::get_flexifact($offset, $limit); ArtefactTypeTarget::build_flexifact_list_html($flexifact); json_reply(FALSE, (object) array('message' => FALSE, 'data' => $flexifact));
$changebrowsetab = param_integer('imgbrowserconf_artefactid_changeowner', 0); // Folder value is 0 when returning to Home folder $changefolder = param_exists('imgbrowserconf_artefactid_changefolder') ? true : false; $uploadimg = param_integer('imgbrowserconf_artefactid_upload', 0); $formsubmit = param_exists('action_submitimage') ? true : false; $formcancel = param_exists('cancel_action_submitimage') ? true : false; if ($forumpostid && !$groupid) { $sql = "SELECT g.id\n FROM {group} g\n INNER JOIN {interaction_instance} ii ON ii.group = g.id\n INNER JOIN {interaction_forum_topic} ift ON ift.forum = ii.id\n INNER JOIN {interaction_forum_post} ifp ON ifp.topic = ift.id\n WHERE ifp.id = ?\n AND ifp.deleted = 0"; $groupid = get_field_sql($sql, array($forumpostid)); } if ($blogid) { safe_require('artefact', 'blog'); $blogobj = new ArtefactTypeBlog($blogid); $institution = $blogobj->get('institution'); } // Create new image browser if ($change) { $ib = new ImageBrowser(array('view' => $viewid, 'post' => $forumpostid, 'group' => $groupid, 'institution' => $institution)); try { $returndata = $ib->render_image_browser(); json_reply(false, array('data' => $returndata)); } catch (Exception $e) { json_reply(true, $e->getMessage()); } } // If an image browser was already created and updated somehow, rebuild or submit the form now // TODO why are other values true when submitting form? if ($changebrowsetab || $changefolder || $uploadimg || $formsubmit || $formcancel) { $ib = new ImageBrowser(array('view' => $viewid, 'post' => $forumpostid, 'group' => $groupid, 'institution' => $institution)); $ib->render_image_browser(); }
$blockid = param_integer('block'); $view = new View($id); if (!can_view_view($view)) { json_reply(true, get_string('accessdenied', 'error')); } $bi = new Blockinstance($blockid); $configdata = $bi->get('configdata'); $sort = !empty($configdata['sort']) ? $configdata['sort'] : null; $limit = !empty($configdata['limitto']) ? $configdata['limitto'] : null; $baseurl = $bi->get_view()->get_url(); $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $bi->get('id'); $userid = $bi->get_view()->get('owner'); if (!$userid) { json_reply(true, get_string('accessdenied', 'error')); } $smarty = smarty_core(); // Group stuff if (!empty($limit)) { list($usergroups, $count) = group_get_user_groups($userid, null, $sort, $limit, $offset); } else { $usergroups = group_get_user_groups($userid, null, $sort); $count = count($usergroups); } foreach ($usergroups as $group) { $group->roledisplay = get_string($group->role, 'grouptype.' . $group->grouptype); } $groups = array('data' => $usergroups, 'count' => $count, 'limit' => $limit, 'offset' => $offset); $pagination = array('baseurl' => $baseurl, 'id' => 'mygroups_pagination', 'datatable' => 'usergroupstable', 'jsonscript' => 'blocktype/mygroups/mygroups.json.php', 'resultcounttextsingular' => get_string('group', 'group'), 'resultcounttextplural' => get_string('groups', 'group')); PluginBlocktypeMygroups::render_items($groups, 'blocktype:mygroups:mygroupslist.tpl', $configdata, $pagination); json_reply(false, array('data' => $groups));
<?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); define('JSON', 1); define('PUBLIC', 1); define('NOSESSKEY', 1); require dirname(dirname(__FILE__)) . '/init.php'; json_headers(); $plugintype = param_alpha('plugintype'); $pluginname = param_alpha('pluginname'); $page = param_alphanumext('page', null); $section = param_alphanumext('section', null); $form = param_alphanumext('form', null); $element = param_alphanumext('element', null); $data = get_helpfile($plugintype, $pluginname, $form, $element, $page, $section); if (empty($data)) { json_reply('local', get_string('nohelpfound')); } $json = array('error' => false, 'content' => $data); json_reply(false, $json);
* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package mahara * @subpackage artefact-blog * @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('JSON', 1); require dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php'; safe_require('artefact', 'blog'); json_headers(); $id = param_integer('id'); $blogpost = new ArtefactTypeBlogPost($id); $blogpost->check_permission(); $blogpost->delete(); json_reply(false, get_string('blogpostdeleted', 'artefact.blog'));
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));
public function updateEvent() { $event = $this->_uses['SODespatchEvent']; $event->load($this->_data['id']); $data = $event->_data; // I'm sure there's a better way to format these dates... switch ($this->_data['type']) { case "drop": $data['start_time'] = un_fix_date(date('o-m-d H:i:s', strtotime("+" . $this->_data['day'] . " day", strtotime("+" . $this->_data['minute'] . " minute", strtotime($data['start_time'])))), true); $data['end_time'] = un_fix_date(date('o-m-d H:i:s', strtotime("+" . $this->_data['day'] . " day", strtotime("+" . $this->_data['minute'] . " minute", strtotime($data['end_time'])))), true); break; case "resize": $data['start_time'] = un_fix_date($data['start_time'], true); $data['end_time'] = un_fix_date(date('o-m-d H:i:s', strtotime("+" . $this->_data['day'] . " day", strtotime("+" . $this->_data['minute'] . " minute", strtotime($data['end_time'])))), true); break; } $errors = array(); if (parent::save('SODespatchEvent', $data, $errors)) { json_reply(array('success' => TRUE)); } else { json_reply(array('success' => FALSE)); } }
/** * Handles authentication by setting up a session for a user if they are logged * in. * * This function combined with the Session class is smart - if the user is not * logged in then they do not get a session, which prevents simple curl hits * or search engine crawls to a page from getting sessions they won't use. * * Once the user has a session, they keep it even if the log out, so it can * be reused. The session does expire, but the expiry time is typically a week * or more. * * If the user is not authenticated for this page, then this function will * exit, printing the login page. Therefore, after including init.php, you can * be sure that the user is logged in, or has a valid guest key. However, no * testing is done to make sure the user has the required permissions to see * the page. * */ function auth_setup() { global $SESSION, $USER; // If the system is not installed, let the user through in the hope that // they can fix this little problem :) if (!get_config('installed')) { $USER->logout(); return; } // Lock the site until core upgrades are done require get_config('libroot') . 'version.php'; $siteclosed = $config->version > get_config('version'); $disablelogin = $config->disablelogin; if (!$siteclosed && get_config('forcelocalupgrades')) { require get_config('docroot') . 'local/version.php'; $siteclosed = $config->version > get_config('localversion'); } $cfgsiteclosed = get_config('siteclosed'); if ($siteclosed && !$cfgsiteclosed || !$siteclosed && $cfgsiteclosed) { // If the admin closed the site manually, open it automatically // when an upgrade is successful. if ($cfgsiteclosed && get_config('siteclosedbyadmin')) { set_config('siteclosedbyadmin', false); } set_config('siteclosed', $siteclosed); set_config('disablelogin', $disablelogin); } // Check the time that the session is set to log out. If the user does // not have a session, this time will be 0. $sessionlogouttime = $USER->get('logout_time'); // Need to doublecheck that the User's sessionid still has a match the usr_session table // It can disappear if the current user has hacked the real user's account and the real user has // reset the password clearing the session from usr_session. $sessionexists = get_record('usr_session', 'usr', $USER->id, 'session', $USER->get('sessionid')); $parentuser = $USER->get('parentuser'); if ($sessionlogouttime && isset($_GET['logout']) || $sessionexists === false && $USER->get('sessionid') != '' && empty($parentuser)) { // Call the authinstance' logout hook $authinstance = $SESSION->get('authinstance'); if ($authinstance) { $authobj = AuthFactory::create($authinstance); $authobj->logout(); } else { log_debug("Strange: user " . $USER->get('username') . " had no authinstance set in their session"); } if (function_exists('local_logout')) { local_logout(); } $USER->logout(); $SESSION->add_ok_msg(get_string('loggedoutok')); redirect(); } if ($sessionlogouttime > time()) { // The session is still active, so continue it. // Make sure that if a user's admin status has changed, they're kicked // out of the admin section if (in_admin_section()) { // Reload site admin/staff permissions $realuser = get_record('usr', 'id', $USER->id, null, null, null, null, 'admin,staff'); if (!$USER->get('admin') && $realuser->admin) { // The user has been made into an admin $USER->admin = 1; } else { if ($USER->get('admin') && !$realuser->admin) { // The user's admin rights have been taken away $USER->admin = 0; } } if (!$USER->get('staff') && $realuser->staff) { $USER->staff = 1; } else { if ($USER->get('staff') && !$realuser->staff) { $USER->staff = 0; } } // Reload institutional admin/staff permissions $USER->reset_institutions(); auth_check_admin_section(); } $USER->renew(); auth_check_required_fields(); } else { if ($sessionlogouttime > 0) { // The session timed out $authinstance = $SESSION->get('authinstance'); if ($authinstance) { $authobj = AuthFactory::create($authinstance); $mnetuser = 0; if ($SESSION->get('mnetuser') && $authobj->parent) { // We wish to remember that the user is an MNET user - even though // they're using the local login form $mnetuser = $USER->get('id'); } $authobj->logout(); $USER->logout(); if ($mnetuser != 0) { $SESSION->set('mnetuser', $mnetuser); $SESSION->set('authinstance', $authinstance); } } else { log_debug("Strange: user " . $USER->get('username') . " had no authinstance set in their session"); } if (defined('JSON')) { json_reply('global', get_string('sessiontimedoutreload'), 1); } if (defined('IFRAME')) { header('Content-type: text/html'); print_auth_frame(); exit; } // If the page the user is viewing is public, inform them that they can // log in again if (defined('PUBLIC')) { // @todo this links to ?login - later it should do magic to make // sure that whatever GET string is made it includes the old data // correctly $loginurl = $_SERVER['REQUEST_URI']; $loginurl .= false === strpos($loginurl, '?') ? '?' : '&'; $loginurl .= 'login'; $SESSION->add_info_msg(get_string('sessiontimedoutpublic', 'mahara', hsc($loginurl)), false); return; } auth_draw_login_page(get_string('sessiontimedout')); } else { // There is no session, so we check to see if one needs to be started. // Build login form. If the form is submitted it will be handled here, // and set $USER for us (this will happen when users hit a page and // specify login data immediately require_once 'pieforms/pieform.php'; $form = new Pieform(auth_get_login_form()); $SESSION->loginform = $form; if ($USER->is_logged_in()) { return; } // Check if the page is public or the site is configured to be public. if (defined('PUBLIC') && !isset($_GET['login'])) { if ($lang = param_alphanumext('lang', null)) { $SESSION->set('lang', $lang); } return; } // No session and a json request if (defined('JSON')) { json_reply('global', get_string('nosessionreload'), 1); } auth_draw_login_page(null, $form); exit; } } }
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL * */ define('INTERNAL', 1); define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; safe_require('artefact', 'cpds'); require_once get_config('docroot') . 'blocktype/lib.php'; require_once get_config('docroot') . 'artefact/cpds/blocktype/cpds/lib.php'; $offset = param_integer('offset', 0); $limit = param_integer('limit', 10); if ($blockid = param_integer('block', null)) { $bi = new BlockInstance($blockid); $options = $configdata = $bi->get('configdata'); $activities = ArtefactTypeActivity::get_activities($configdata['artefactid'], $offset, $limit); $template = 'artefact:cpds:activityrows.tpl'; $baseurl = $bi->get_view()->get_url(); $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid; $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'activitytable_' . $blockid, 'jsonscript' => 'artefact/cpds/viewactivities.json.php'); } else { $cpdid = param_integer('artefact'); $viewid = param_integer('view'); $options = array('viewid' => $viewid); $activities = ArtefactTypeActivity::get_activities($cpdid, $offset, $limit); $template = 'artefact:cpds:activityrows.tpl'; $baseurl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $cpdid . '&view=' . $options['viewid']; $pagination = array('baseurl' => $baseurl, 'id' => 'activity_pagination', 'datatable' => 'activitylist', 'jsonscript' => 'artefact/cpds/viewactivities.json.php'); } ArtefactTypeActivity::render_activities($activities, $template, $options, $pagination); json_reply(false, (object) array('message' => false, 'data' => $activities));
* @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('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; json_headers(); $data = new StdClass(); $data->view = param_integer('view'); $data->artefact = param_integer('artefact', null); $data->message = param_variable('message'); $data->public = param_boolean('public') ? 1 : 0; $data->attachment = param_integer('attachment', null); $data->author = $USER->get('id'); $data->ctime = db_format_timestamp(time()); if ($data->artefact) { $table = 'artefact_feedback'; } else { $table = 'view_feedback'; } if (!insert_record($table, $data, 'id', true)) { json_reply('local', get_string('addfeedbackfailed', 'view')); } require_once 'activity.php'; activity_occurred('feedback', $data); json_reply(false, get_string('feedbacksubmitted', 'view'));
* http://wiki.mahara.org/Contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package mahara * @subpackage artefact-blog * @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); define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; safe_require('artefact', 'blog'); $blogs = (object) array('offset' => param_integer('offset', 0), 'limit' => param_integer('limit', 10)); list($blogs->count, $blogs->data) = ArtefactTypeBlog::get_blog_list($blogs->limit, $blogs->offset); ArtefactTypeBlog::build_blog_list_html($blogs); json_reply(false, array('data' => $blogs));