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


PHP Pieform::submitted_by_js方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

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

示例5: 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

示例6: 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

示例7: instance_config_store

 public function instance_config_store(Pieform $form, $values)
 {
     global $SESSION;
     // 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 (is_callable(array(generate_class_name('blocktype', $this->get('blocktype')), 'instance_config_save'))) {
         $values = call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'instance_config_save', $values);
     }
     $title = isset($values['title']) ? $values['title'] : '';
     unset($values['title']);
     $this->set('configdata', $values);
     $blocktypeclass = generate_class_name('blocktype', $this->get('blocktype'));
     if (!$title && $title !== '0' && method_exists($blocktypeclass, 'get_instance_title')) {
         // Get the default title for the block if one isn't set
         $title = call_static_method($blocktypeclass, 'get_instance_title', $this);
     }
     $this->set('title', $title);
     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));
     }
     $this->commit();
     $result = array('error' => false, 'message' => get_string('blockinstanceconfiguredsuccessfully', 'view'), 'data' => $rendered, 'blockid' => $this->get('id'), 'viewid' => $this->get('view'));
     $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['goto'] = $redirect;
     $form->reply(PIEFORM_OK, $result);
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:41,代码来源:lib.php


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