当前位置: 首页>>代码示例>>PHP>>正文


PHP Pieform::json_reply方法代码示例

本文整理汇总了PHP中Pieform::json_reply方法的典型用法代码示例。如果您正苦于以下问题:PHP Pieform::json_reply方法的具体用法?PHP Pieform::json_reply怎么用?PHP Pieform::json_reply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pieform的用法示例。


在下文中一共展示了Pieform::json_reply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: personalinformation_submit

function personalinformation_submit(Pieform $form, $values)
{
    global $personalinformation, $USER;
    $userid = $USER->get('id');
    $errors = array();
    try {
        if (empty($personalinformation)) {
            $personalinformation = new ArtefactTypePersonalinformation(0, array('owner' => $userid, 'title' => get_string('personalinformation', 'artefact.resume')));
        }
        foreach (array_keys(ArtefactTypePersonalInformation::get_composite_fields()) as $field) {
            $personalinformation->set_composite($field, $values[$field]);
        }
        $personalinformation->commit();
    } catch (Exception $e) {
        $errors['personalinformation'] = true;
    }
    if (empty($errors)) {
        $form->json_reply(PIEFORM_OK, get_string('resumesaved', 'artefact.resume'));
    } else {
        $message = '';
        foreach (array_keys($errors) as $key) {
            $message .= get_string('resumesavefailed', 'artefact.resume') . "\n";
        }
        $form->json_reply(PIEFORM_ERR, $message);
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:26,代码来源:index.php

示例2: interests_submit

function interests_submit(Pieform $form, $values)
{
    global $coverletter, $personalinformation, $interest, $USER;
    $userid = $USER->get('id');
    $errors = array();
    try {
        if (empty($interest) && !empty($values['interest'])) {
            $interest = new ArtefactTypeInterest(0, array('owner' => $userid, 'description' => $values['interest']));
            $interest->commit();
        } else {
            if (!empty($interest) && !empty($values['interest'])) {
                $interest->set('description', $values['interest']);
                $interest->commit();
            } else {
                if (!empty($interest) && empty($values['interest'])) {
                    $interest->delete();
                }
            }
        }
    } catch (Exception $e) {
        $errors['interest'] = true;
    }
    if (empty($errors)) {
        $form->json_reply(PIEFORM_OK, get_string('resumesaved', 'artefact.resume'));
    } else {
        $message = '';
        foreach (array_keys($errors) as $key) {
            $message .= get_string('resumesavefailed', 'artefact.resume') . "\n";
        }
        $form->json_reply(PIEFORM_ERR, $message);
    }
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:32,代码来源:interests.php

示例3: activityprefs_submit

function activityprefs_submit(Pieform $form, $values)
{
    global $activitytypes, $admintypes, $USER;
    $userid = $USER->get('id');
    foreach ($activitytypes as $type) {
        if ($values['activity_' . $type->id] == 'none') {
            $USER->set_activity_preference($type->id, null);
        } else {
            $USER->set_activity_preference($type->id, $values['activity_' . $type->id]);
        }
    }
    $form->json_reply(PIEFORM_OK, get_string('prefssaved', 'account'));
}
开发者ID:Br3nda,项目名称:mahara,代码行数:13,代码来源:index.php

示例4: 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);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:20,代码来源:license.php

示例5: 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);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:46,代码来源:editgoalsandskills.php

示例6: editpost_submit

function editpost_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $blogpost, $blog;
    require_once 'embeddedimage.php';
    db_begin();
    $postobj = new ArtefactTypeBlogPost($blogpost, null);
    $postobj->set('title', $values['title']);
    $postobj->set('description', $values['description']);
    $postobj->set('tags', $values['tags']);
    if (get_config('licensemetadata')) {
        $postobj->set('license', $values['license']);
        $postobj->set('licensor', $values['licensor']);
        $postobj->set('licensorurl', $values['licensorurl']);
    }
    $postobj->set('published', !$values['draft']);
    $postobj->set('allowcomments', (int) $values['allowcomments']);
    if (!$blogpost) {
        $postobj->set('parent', $blog);
        $blogobj = new ArtefactTypeBlog($blog);
        if ($blogobj->get('institution')) {
            $postobj->set('institution', $blogobj->get('institution'));
        } else {
            if ($blogobj->get('group')) {
                $postobj->set('group', $blogobj->get('group'));
            } else {
                $postobj->set('owner', $USER->id);
            }
        }
    }
    $postobj->commit();
    $blogpost = $postobj->get('id');
    // Need to wait until post is saved in case we are a new blogpost before we can sort out embedded images as we need an id
    $postobj->set('description', EmbeddedImage::prepare_embedded_images($values['description'], '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();
    // 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 {
                    $postobj->detach($o);
                } catch (ArtefactNotFoundException $e) {
                }
            }
        }
        foreach ($new as $n) {
            if (!in_array($n, $old)) {
                try {
                    $postobj->attach($n);
                } catch (ArtefactNotFoundException $e) {
                }
            }
        }
    }
    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);
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:71,代码来源:post.php

示例7: accountprefs_submit

function accountprefs_submit(Pieform $form, $values)
{
    global $USER;
    $authobj = AuthFactory::create($USER->authinstance);
    db_begin();
    if (isset($values['password1']) && $values['password1'] !== '') {
        global $authclass;
        $password = $authobj->change_password($USER, $values['password1']);
        $USER->password = $password;
        $USER->passwordchange = 0;
        $USER->commit();
    }
    // use this as looping through values is not safe.
    $expectedprefs = expected_account_preferences();
    foreach (array_keys($expectedprefs) as $pref) {
        if (isset($values[$pref])) {
            $USER->set_account_preference($pref, $values[$pref]);
        }
    }
    $returndata = array();
    if (isset($values['username']) && $values['username'] != $USER->get('username')) {
        $USER->username = $values['username'];
        $USER->commit();
        $returndata['username'] = $values['username'];
    }
    db_commit();
    $returndata['message'] = get_string('prefssaved', 'account');
    $form->json_reply(PIEFORM_OK, $returndata);
}
开发者ID:Br3nda,项目名称:mahara,代码行数:29,代码来源:index.php

示例8: activityprefs_submit

function activityprefs_submit(Pieform $form, $values)
{
    global $USER;
    save_notification_settings($values, $USER);
    $form->json_reply(PIEFORM_OK, get_string('prefssaved', 'account'));
}
开发者ID:patkira,项目名称:mahara,代码行数:6,代码来源:index.php

示例9: goalandskillform_submit

function goalandskillform_submit(Pieform $form, $values)
{
    foreach ($values as $key => $value) {
        if (!in_array($key, ArtefactTypeResumeGoalAndSkill::get_goalandskill_artefact_types())) {
            continue;
        }
        try {
            $a = artefact_instance_from_type($key);
            $a->set('description', $value);
        } catch (Exception $e) {
            global $USER;
            $classname = generate_artefact_class_name($key);
            $a = new $classname(0, array('owner' => $USER->get('id'), 'title' => get_string($key), 'description' => $value));
        }
        $a->commit();
    }
    $form->json_reply(PIEFORM_OK, get_string('goalandskillsaved', 'artefact.resume'));
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:18,代码来源:lib.php

示例10: 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);
}
开发者ID:Br3nda,项目名称:mahara,代码行数:40,代码来源:post.php

示例11: 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);
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:62,代码来源:editnote.php

示例12: config_success

 public static function config_success(Pieform $form, $values)
 {
     $result = array();
     $form->json_reply(PIEFORM_OK, $result, false);
 }
开发者ID:kienv,项目名称:mahara,代码行数:5,代码来源:imagebrowser.php

示例13: upload_submit

function upload_submit(Pieform $form, $values)
{
    global $USER, $filesize;
    safe_require('artefact', 'file');
    try {
        $USER->quota_add($filesize);
    } catch (QuotaException $qe) {
        $form->json_reply(PIEFORM_ERR, array('message' => get_string('profileiconuploadexceedsquota', 'artefact.file', get_config('wwwroot'))));
    }
    // Entry in artefact table
    $data = new stdClass();
    $data->owner = $USER->id;
    $data->parent = ArtefactTypeFolder::get_folder_id(get_string('imagesdir', 'artefact.file'), get_string('imagesdirdesc', 'artefact.file'), null, true, $USER->id);
    $data->title = $values['title'] ? $values['title'] : $values['file']['name'];
    $data->title = ArtefactTypeFileBase::get_new_file_title($data->title, (int) $data->parent, $USER->id);
    // unique title
    $data->note = $values['file']['name'];
    $data->size = $filesize;
    $imageinfo = getimagesize($values['file']['tmp_name']);
    $data->width = $imageinfo[0];
    $data->height = $imageinfo[1];
    $data->filetype = $imageinfo['mime'];
    $data->description = get_string('uploadedprofileicon', 'artefact.file');
    $artefact = new ArtefactTypeProfileIcon(0, $data);
    if (preg_match("/\\.([^\\.]+)\$/", $values['file']['name'], $saved)) {
        $artefact->set('oldextension', $saved[1]);
    }
    $artefact->commit();
    $id = $artefact->get('id');
    // Move the file into the correct place.
    $directory = get_config('dataroot') . 'artefact/file/profileicons/originals/' . $id % 256 . '/';
    check_dir_exists($directory);
    move_uploaded_file($values['file']['tmp_name'], $directory . $id);
    $USER->commit();
    $form->json_reply(PIEFORM_OK, get_string('profileiconaddedtoimagesfolder', 'artefact.file', get_string('imagesdir', 'artefact.file')));
}
开发者ID:rboyatt,项目名称:mahara,代码行数:36,代码来源:profileicons.php

示例14: pluginconfig_submit

function pluginconfig_submit(Pieform $form, $values)
{
    $success = false;
    global $plugintype, $pluginname, $classname;
    try {
        call_static_method($classname, 'save_config_options', $values);
        $success = true;
    } catch (Exception $e) {
        $success = false;
    }
    if ($success) {
        $form->json_reply(PIEFORM_OK, get_string('settingssaved'));
    } else {
        $form->json_reply(PIEFORM_ERR, array('message' => get_string('settingssavefailed')));
    }
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:16,代码来源:pluginconfig.php

示例15: upload_submit

function upload_submit(Pieform $form, $values)
{
    global $USER, $filesize;
    // If there are no icons, we can set this one that is being uploaded to be
    // the default for the user
    $setasdefault = false;
    if (0 == get_field('artefact', 'COUNT(*)', 'artefacttype', 'profileicon', 'owner', $USER->id)) {
        $setasdefault = true;
    }
    try {
        $USER->quota_add($filesize);
    } catch (QuotaException $qe) {
        $form->json_reply(PIEFORM_ERR, array('message' => get_string('profileiconuploadexceedsquota', 'artefact.file', get_config('wwwroot'))));
    }
    // Entry in artefact table
    $data = (object) array('owner' => $USER->id, 'title' => $values['title'] ? $values['title'] : $values['file']['name'], 'note' => $values['file']['name'], 'size' => $filesize);
    $imageinfo = getimagesize($values['file']['tmp_name']);
    $data->width = $imageinfo[0];
    $data->height = $imageinfo[1];
    $data->filetype = $imageinfo['mime'];
    $artefact = new ArtefactTypeProfileIcon(0, $data);
    if (preg_match("/\\.([^\\.]+)\$/", $values['file']['name'], $saved)) {
        $artefact->set('oldextension', $saved[1]);
    }
    $artefact->commit();
    $id = $artefact->get('id');
    // Move the file into the correct place.
    $directory = get_config('dataroot') . 'artefact/file/profileicons/originals/' . $id % 256 . '/';
    check_dir_exists($directory);
    move_uploaded_file($values['file']['tmp_name'], $directory . $id);
    if ($setasdefault) {
        $USER->profileicon = $id;
    }
    $USER->commit();
    $form->json_reply(PIEFORM_OK, get_string('uploadedprofileiconsuccessfully', 'artefact.file'));
}
开发者ID:Br3nda,项目名称:mahara,代码行数:36,代码来源:profileicons.php


注:本文中的Pieform::json_reply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。