本文整理汇总了PHP中Pieform::reply方法的典型用法代码示例。如果您正苦于以下问题:PHP Pieform::reply方法的具体用法?PHP Pieform::reply怎么用?PHP Pieform::reply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pieform
的用法示例。
在下文中一共展示了Pieform::reply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editsitepage_submit
function editsitepage_submit(Pieform $form, $values)
{
global $USER;
$data = new StdClass();
$data->name = $values['pagename'];
$data->content = $values['pagetext'];
$data->mtime = db_format_timestamp(time());
$data->mauthor = $USER->get('id');
try {
update_record('site_content', $data, 'name');
} catch (SQLException $e) {
$form->reply(PIEFORM_ERR, get_string('savefailed', 'admin'));
}
$form->reply(PIEFORM_OK, get_string('pagesaved', 'admin'));
}
示例2: networkingform_submit
function networkingform_submit(Pieform $form, $values)
{
$reply = '';
if ($form->get_submitvalue() === 'deletekey') {
global $SESSION;
$openssl = OpenSslRepo::singleton();
$openssl->get_keypair(true);
$SESSION->add_info_msg(get_string('keydeleted', 'admin'));
// Using cancel here as a hack to get it to redirect so it shows the new keys
$form->reply(PIEFORM_CANCEL, array('location' => get_config('wwwroot') . 'admin/site/networking.php'));
}
if (get_config('enablenetworking') != $values['enablenetworking']) {
if (!set_config('enablenetworking', $values['enablenetworking'])) {
networkingform_fail($form);
} else {
if (empty($values['enablenetworking'])) {
$reply .= get_string('networkingdisabled', 'admin');
} else {
$reply .= get_string('networkingenabled', 'admin');
}
}
}
if (get_config('promiscuousmode') != $values['promiscuousmode']) {
if (!set_config('promiscuousmode', $values['promiscuousmode'])) {
networkingform_fail($form);
} else {
if (empty($values['promiscuousmode'])) {
$reply .= get_string('promiscuousmodedisabled', 'admin');
} else {
$reply .= get_string('promiscuousmodeenabled', 'admin');
}
}
}
$form->reply(PIEFORM_OK, array('message' => $reply == '' ? get_string('networkingunchanged', 'admin') : $reply, 'goto' => '/admin/site/networking.php'));
}
示例3: resumelicense_submit
function resumelicense_submit(Pieform $form, $values)
{
global $personalinformation, $USER;
$userid = $USER->get('id');
if (empty($personalinformation)) {
$personalinformation = new ArtefactTypePersonalinformation(0, array('owner' => $userid, 'title' => get_string('personalinformation', 'artefact.resume')));
}
if (get_config('licensemetadata')) {
$personalinformation->set('license', $values['license']);
$personalinformation->set('licensor', $values['licensor']);
$personalinformation->set('licensorurl', $values['licensorurl']);
}
$personalinformation->commit();
$result = array('error' => false, 'message' => get_string('resumesaved', 'artefact.resume'), 'goto' => get_config('wwwroot') . 'artefact/resume/license.php');
if ($form->submitted_by_js()) {
$SESSION->add_ok_msg($result['message']);
$form->json_reply(PIEFORM_OK, $result, false);
}
$form->reply(PIEFORM_OK, $result);
}
示例4: add_feedback_form_cancel_submit
function add_feedback_form_cancel_submit(Pieform $form)
{
global $view;
$form->reply(PIEFORM_OK, array('goto' => '/' . $view->get_url(false)));
}
示例5: instance_config_store
public function instance_config_store(Pieform $form, $values)
{
global $SESSION, $USER;
// Destroy form values we don't care about
unset($values['sesskey']);
unset($values['blockinstance']);
unset($values['action_configureblockinstance_id_' . $this->get('id')]);
unset($values['blockconfig']);
unset($values['id']);
unset($values['change']);
unset($values['new']);
if (isset($values['retractable'])) {
switch ($values['retractable']) {
case BlockInstance::RETRACTABLE_YES:
$values['retractable'] = 1;
$values['retractedonload'] = 0;
break;
case BlockInstance::RETRACTABLE_RETRACTED:
$values['retractable'] = 1;
$values['retractedonload'] = 1;
break;
case BlockInstance::RETRACTABLE_NO:
default:
$values['retractable'] = 0;
$values['retractedonload'] = 0;
break;
}
}
// make sure that user is allowed to publish artefact. This is to stop
// hacking of form value to attach other users private data.
$badattachment = false;
if (!empty($values['artefactid'])) {
$badattachment = !$this->verify_attachment_permissions($values['artefactid']);
}
if (!empty($values['artefactids'])) {
$badattachment = !$this->verify_attachment_permissions($values['artefactids']);
}
if ($badattachment) {
$result['message'] = get_string('unrecoverableerror', 'error');
$form->set_error(null, $result['message']);
$form->reply(PIEFORM_ERR, $result);
exit;
}
$redirect = '/view/blocks.php?id=' . $this->get('view');
if (param_boolean('new', false)) {
$redirect .= '&new=1';
}
if ($category = param_alpha('c', '')) {
$redirect .= '&c=' . $category;
}
$result = array('goto' => $redirect);
if (is_callable(array(generate_class_name('blocktype', $this->get('blocktype')), 'instance_config_save'))) {
try {
$values = call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'instance_config_save', $values, $this);
} catch (MaharaException $e) {
$result['message'] = $e instanceof UserException ? $e->getMessage() : get_string('unrecoverableerror', 'error');
$form->set_error(null, $result['message']);
$form->reply(PIEFORM_ERR, $result);
}
}
$title = isset($values['title']) ? $values['title'] : '';
unset($values['title']);
// A block may return a list of other blocks that need to be
// redrawn after configuration of this block.
$torender = !empty($values['_redrawblocks']) && $form->submitted_by_js() ? $values['_redrawblocks'] : array();
unset($values['_redrawblocks']);
$this->set('configdata', $values);
$this->set('title', $title);
$this->commit();
try {
$rendered = $this->render_editing(false, false, $form->submitted_by_js());
} catch (HTMLPurifier_Exception $e) {
$message = get_string('blockconfigurationrenderingerror', 'view') . ' ' . $e->getMessage();
$form->reply(PIEFORM_ERR, array('message' => $message));
}
$result = array('error' => false, 'message' => get_string('blockinstanceconfiguredsuccessfully', 'view'), 'data' => $rendered, 'blockid' => $this->get('id'), 'viewid' => $this->get('view'), 'goto' => $redirect);
// Render all the other blocks in the torender list
$result['otherblocks'] = array();
foreach ($torender as $blockid) {
if ($blockid != $result['blockid']) {
$otherblock = new BlockInstance($blockid);
$result['otherblocks'][] = array('blockid' => $blockid, 'data' => $otherblock->render_editing(false, false, true));
}
}
$form->reply(PIEFORM_OK, $result);
}
示例6: editgoalsandskills_submit
function editgoalsandskills_submit(Pieform $form, array $values)
{
global $SESSION, $artefact, $USER;
require_once 'embeddedimage.php';
$newdescription = EmbeddedImage::prepare_embedded_images($values['description'], $values['artefacttype'], $USER->get('id'));
db_begin();
$artefact->set('title', get_string($values['artefacttype'], 'artefact.resume'));
$artefact->set('description', $newdescription);
$artefact->commit();
// Attachments
$old = $artefact->attachment_id_list();
$new = is_array($values['filebrowser']) ? $values['filebrowser'] : array();
// only allow the attaching of files that exist and are editable by user
foreach ($new as $key => $fileid) {
$file = artefact_instance_from_id($fileid);
if (!$file instanceof ArtefactTypeFile || !$USER->can_publish_artefact($file)) {
unset($new[$key]);
}
}
if (!empty($new) || !empty($old)) {
foreach ($old as $o) {
if (!in_array($o, $new)) {
try {
$artefact->detach($o);
} catch (ArtefactNotFoundException $e) {
}
}
}
foreach ($new as $n) {
if (!in_array($n, $old)) {
try {
$artefact->attach($n);
} catch (ArtefactNotFoundException $e) {
}
}
}
}
db_commit();
$result = array('error' => false, 'message' => get_string('goalandskillsaved', 'artefact.resume'), 'goto' => get_config('wwwroot') . 'artefact/resume/goalsandskills.php');
if ($form->submitted_by_js()) {
// Redirect back to the resume goals and skills page from within the iframe
$SESSION->add_ok_msg($result['message']);
$form->json_reply(PIEFORM_OK, $result, false);
}
$form->reply(PIEFORM_OK, $result);
}
示例7: delete_submit
function delete_submit(Pieform $form, $values)
{
$blogpost = new ArtefactTypeBlogPost((int) $values['delete']);
$blogpost->check_permission();
if ($blogpost->get('locked')) {
$form->reply(PIEFORM_ERR, get_string('submittedforassessment', 'view'));
}
$blogpost->delete();
$form->reply(PIEFORM_OK, array('message' => get_string('blogpostdeleted', 'artefact.blog'), 'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blogpost->get('parent'), 'id' => $values['delete']));
}
示例8: changeauth_submit
function changeauth_submit(Pieform $form, $values)
{
global $users, $SESSION, $authinstances, $USER;
$newauth = AuthFactory::create($values['authinstance']);
$needspassword = method_exists($newauth, 'change_password');
$updated = 0;
$needpassword = 0;
db_begin();
$newauthinst = get_records_select_assoc('auth_instance', 'id = ?', array($values['authinstance']));
if ($USER->get('admin') || $USER->is_institutional_admin($newauthinst[$values['authinstance']]->institution)) {
foreach ($users as $user) {
if ($user->authinstance != $values['authinstance']) {
// Authinstance can be changed by institutional admins if both the
// old and new authinstances belong to the admin's institutions
$authinst = get_field('auth_instance', 'institution', 'id', $user->authinstance);
if ($USER->get('admin') || $USER->is_institutional_admin($authinst)) {
// determine the current remoteusername
$current_remotename = get_field('auth_remote_user', 'remoteusername', 'authinstance', $user->authinstance, 'localusr', $user->id);
if (!$current_remotename) {
$current_remotename = $user->username;
}
// remove row if new authinstance row already exists to avoid doubleups
delete_records('auth_remote_user', 'authinstance', $values['authinstance'], 'localusr', $user->id);
insert_record('auth_remote_user', (object) array('authinstance' => $values['authinstance'], 'remoteusername' => $current_remotename, 'localusr' => $user->id));
}
if ($user->haspassword && !$needspassword) {
$user->password = '';
} else {
if ($needspassword && !$user->haspassword) {
$needpassword++;
}
}
$user->authinstance = $values['authinstance'];
update_record('usr', $user, 'id');
$updated++;
}
}
}
db_commit();
if ($needpassword) {
// Inform the user that they may need to reset passwords
$SESSION->add_info_msg(get_string('bulkchangeauthmethodresetpassword', 'admin', $needpassword));
}
$message = get_string('bulkchangeauthmethodsuccess', 'admin', $updated);
$form->reply(PIEFORM_OK, array('message' => $message));
}
示例9: siteoptions_fail
function siteoptions_fail(Pieform $form, $field)
{
$form->reply(PIEFORM_ERR, array('message' => get_string('setsiteoptionsfailed', 'admin', get_string($field, 'admin')), 'goto' => '/admin/site/options.php'));
}
示例10: objection_form_cancel_submit
function objection_form_cancel_submit(Pieform $form)
{
global $view;
$form->reply(PIEFORM_OK, array('goto' => '/view/view.php?id=' . $view->get('id')));
}
示例11: add_feedback_form_cancel_submit
function add_feedback_form_cancel_submit(Pieform $form)
{
global $view;
$form->reply(PIEFORM_CANCEL, array('location' => $view->get_url(true)));
}
示例12: instance_config_validate
public static function instance_config_validate(Pieform $form, $values)
{
global $USER;
if (!empty($values['images'])) {
foreach ($values['images'] as $id) {
$image = new ArtefactTypeImage($id);
if (!$image instanceof ArtefactTypeImage || !$USER->can_view_artefact($image)) {
$result['message'] = get_string('unrecoverableerror', 'error');
$form->set_error(null, $result['message']);
$form->reply(PIEFORM_ERR, $result);
}
}
}
if (!empty($values['folder'])) {
$folder = artefact_instance_from_id($values['folder']);
if (!$folder instanceof ArtefactTypeFolder || !$USER->can_view_artefact($folder)) {
$result['message'] = get_string('unrecoverableerror', 'error');
$form->set_error(null, $result['message']);
$form->reply(PIEFORM_ERR, $result);
}
}
}
示例13: editpost_submit
function editpost_submit(Pieform $form, $values)
{
global $USER, $SESSION, $blogpost, $blog;
db_begin();
$postobj = new ArtefactTypeBlogPost($blogpost, null);
$postobj->set('title', $values['title']);
$postobj->set('description', $values['description']);
$postobj->set('tags', $values['tags']);
$postobj->set('published', !$values['draft']);
if (!$blogpost) {
$postobj->set('parent', $blog);
$postobj->set('owner', $USER->id);
}
$postobj->commit();
$blogpost = $postobj->get('id');
// Attachments
$old = $postobj->attachment_id_list();
// $new = is_array($values['filebrowser']['selected']) ? $values['filebrowser']['selected'] : array();
$new = is_array($values['filebrowser']) ? $values['filebrowser'] : array();
if (!empty($new) || !empty($old)) {
foreach ($old as $o) {
if (!in_array($o, $new)) {
$postobj->detach($o);
}
}
foreach ($new as $n) {
if (!in_array($n, $old)) {
$postobj->attach($n);
}
}
}
db_commit();
$result = array('error' => false, 'message' => get_string('blogpostsaved', 'artefact.blog'), 'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog);
if ($form->submitted_by_js()) {
// Redirect back to the blog page from within the iframe
$SESSION->add_ok_msg($result['message']);
$form->json_reply(PIEFORM_OK, $result, false);
}
$form->reply(PIEFORM_OK, $result);
}
示例14: editnote_submit
function editnote_submit(Pieform $form, array $values)
{
global $SESSION, $artefact, $goto;
require_once 'embeddedimage.php';
db_begin();
$artefact->set('title', $values['title']);
$newdescription = EmbeddedImage::prepare_embedded_images($values['description'], 'textbox', $artefact->get('id'), $artefact->get('group'));
$artefact->set('description', $newdescription);
$artefact->set('tags', $values['tags']);
$artefact->set('allowcomments', (int) $values['allowcomments']);
if (isset($values['perms'])) {
$artefact->set('rolepermissions', $values['perms']);
$artefact->set('dirty', true);
}
if (get_config('licensemetadata')) {
$artefact->set('license', $values['license']);
$artefact->set('licensor', $values['licensor']);
$artefact->set('licensorurl', $values['licensorurl']);
}
$artefact->commit();
// Attachments
$old = $artefact->attachment_id_list();
$new = is_array($values['filebrowser']) ? $values['filebrowser'] : array();
if (!empty($new) || !empty($old)) {
foreach ($old as $o) {
if (!in_array($o, $new)) {
try {
$artefact->detach($o);
} catch (ArtefactNotFoundException $e) {
}
}
}
foreach ($new as $n) {
if (!in_array($n, $old)) {
try {
$artefact->attach($n);
} catch (ArtefactNotFoundException $e) {
}
}
}
}
// need to update the block_instances where this artefact is used - so they have
// the correct configuration artefactids
if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefact->get('id'))) {
require_once get_config('docroot') . 'blocktype/lib.php';
foreach ($blocks as $block) {
$bi = new BlockInstance($block);
$configdata = $bi->get('configdata');
$configdata['artefactids'] = $new;
$bi->set('configdata', $configdata);
$bi->commit();
}
}
db_commit();
$result = array('error' => false, 'message' => get_string('noteupdated', 'artefact.internal'), 'goto' => $goto);
if ($form->submitted_by_js()) {
// Redirect back to the note page from within the iframe
$SESSION->add_ok_msg($result['message']);
$form->json_reply(PIEFORM_OK, $result, false);
}
$form->reply(PIEFORM_OK, $result);
}
示例15: editsitepage_submit
function editsitepage_submit(Pieform $form, $values)
{
global $USER;
$data = new StdClass();
$data->name = $values['pagename'];
if (empty($values['pageusedefault'])) {
$data->content = $values['pagetext'];
}
$data->mtime = db_format_timestamp(time());
$data->mauthor = $USER->get('id');
$data->institution = $values['pageinstitution'];
// update the institution config if needed
if (isset($values['pageusedefault'])) {
$configdata = new StdClass();
$configdata->institution = $data->institution;
$configdata->field = 'sitepages_' . $data->name;
$whereobj = clone $configdata;
$configdata->value = !empty($values['pageusedefault']) ? 'mahara' : $data->institution;
ensure_record_exists('institution_config', $whereobj, $configdata);
}
if (get_record('site_content', 'name', $data->name, 'institution', $data->institution)) {
try {
update_record('site_content', $data, array('name', 'institution'));
} catch (SQLException $e) {
$form->reply(PIEFORM_ERR, get_string('savefailed', 'admin'));
}
} else {
// local site page doesn't exist for this institution so we shall add it
$data->ctime = db_format_timestamp(time());
try {
insert_record('site_content', $data);
} catch (SQLException $e) {
$form->reply(PIEFORM_ERR, get_string('savefailed', 'admin'));
}
}
$form->reply(PIEFORM_OK, get_string('pagesaved', 'admin'));
}