本文整理汇总了PHP中json_reply函数的典型用法代码示例。如果您正苦于以下问题:PHP json_reply函数的具体用法?PHP json_reply怎么用?PHP json_reply使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了json_reply函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
* @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)));
示例2: define
<?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));
示例3: define
* @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);
示例4: define
<?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'));
示例5: json_reply
$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));
}
示例6: define
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));
示例7: define
/**
* 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));
示例8: array
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));
示例9: stdClass
}
$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'));
}
示例10: define
* @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();
示例11: safe_require
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));
示例12: json_reply
// 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'));
示例13: define
* @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)));
示例14: BlockInstance
$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));
示例15: define
* 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));