Example #1
0
// Feedback
$javascript = <<<EOF
feedbacklist.view = {$viewid};
feedbacklist.statevars.push('view');
feedbacklist.updateOnLoad();
EOF;
$smarty = smarty(array('mahara', 'tablerenderer', 'feedbacklist', 'artefact/resume/resumeshowhide.js'), array('<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'theme/views.css">'), array(), array('stylesheets' => array('style/views.css')));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('new', $new);
$smarty->assign('viewid', $viewid);
$smarty->assign('viewtitle', $view->get('title'));
$owner = $view->get('owner');
if ($owner) {
    $smarty->assign('ownerlink', 'user/view.php?id=' . $owner);
    if ($USER->get('id') == $owner) {
        $smarty->assign('can_edit', !$submittedgroup && !$view->is_submitted());
    }
} else {
    if ($group) {
        $smarty->assign('ownerlink', 'group/view.php?id=' . $group);
    }
}
// Provide a link for roaming teachers to return
if ($mnetviewlist = $SESSION->get('mnetviewaccess')) {
    if (isset($mnetviewlist[$view->get('id')])) {
        $returnurl = $SESSION->get('mnetuserfrom');
        require_once get_config('docroot') . 'api/xmlrpc/lib.php';
        if ($peer = get_peer_from_instanceid($SESSION->get('authinstance'))) {
            $smarty->assign('mnethost', array('name' => $peer->name, 'url' => $returnurl ? $returnurl : $peer->wwwroot));
        }
    }
Example #2
0
/**
 * Submits a view or collection for assessment by a remote service
 *
 * @param string $username
 * @param int $id The ID of the view or collection to be submitted
 * @param boolean $iscollection Indicates whether it's a view or a collection
 * @return array An array of data for the web service to consume
 */
function submit_view_for_assessment($username, $id, $iscollection = false)
{
    global $REMOTEWWWROOT;
    list($user, $authinstance) = find_remote_user($username, $REMOTEWWWROOT);
    if (!$user) {
        return false;
    }
    $id = (int) $id;
    if (!$id) {
        return false;
    }
    require_once 'view.php';
    $remotehost = $authinstance->config['wwwroot'];
    $userid = $user->get('id');
    db_begin();
    if ($iscollection) {
        require_once 'collection.php';
        $collection = new Collection($id);
        $title = $collection->get('name');
        $description = $collection->get('description');
        // Check whether the collection is already submitted
        if ($collection->is_submitted()) {
            // If this is already submitted to something else, throw an exception
            if ($collection->get('submittedgroup') || $collection->get('submittedhost') !== $REMOTEWWWROOT) {
                throw new CollectionSubmissionException(get_string('collectionalreadysubmitted', 'view'));
            }
            // It may have been submitted to a different assignment in the same remote
            // site, but there's no way we can tell. So we'll just send the access token
            // back.
            $access = $collection->get_invisible_token();
        } else {
            $collection->submit(null, $remotehost, $userid);
            $access = $collection->new_token(false);
        }
        // If the collection is empty, $access will be false
        if (!$access) {
            throw new CollectionSubmissionException(get_string('cantsubmitemptycollection', 'view'));
        }
    } else {
        $view = new View($id);
        $title = $view->get('title');
        $description = $view->get('description');
        if ($view->is_submitted()) {
            // If this is already submitted to something else, throw an exception
            if ($view->get('submittedgroup') || $view->get('submittedhost') !== $REMOTEWWWROOT) {
                throw new ViewSubmissionException(get_string('viewalreadysubmitted', 'view'));
            }
            // It may have been submitted to a different assignment in the same remote
            // site, but there's no way we can tell. So we'll just send the access token
            // back.
            $access = View::get_invisible_token($id);
        } else {
            View::_db_submit(array($id), null, $remotehost, $userid);
            $access = View::new_token($id, false);
        }
    }
    $data = array('id' => $id, 'title' => $title, 'description' => $description, 'fullurl' => get_config('wwwroot') . 'view/view.php?mt=' . $access->token, 'url' => '/view/view.php?mt=' . $access->token, 'accesskey' => $access->token);
    // Provide each artefact plugin the opportunity to handle the remote submission and
    // provide return data for the webservice caller
    foreach (plugins_installed('artefact') as $plugin) {
        safe_require('artefact', $plugin->name);
        $classname = generate_class_name('artefact', $plugin->name);
        if (is_callable($classname . '::view_submit_external_data')) {
            $data[$plugin->name] = call_static_method($classname, 'view_submit_external_data', $id, $iscollection);
        }
    }
    db_commit();
    return $data;
}
       INNER JOIN {group} g ON (u.group = g.id AND g.deleted = 0)
       WHERE u.member = ?
       AND g.id = ?
       AND g.submittableto = 1', array($USER->get('id'), $groupid));
if (!$group || !group_within_edit_window($group)) {
    throw new AccessDeniedException(get_string('cantsubmittogroup', 'view'));
}
if ($collectionid = param_integer('collection', null)) {
    $collection = new Collection($collectionid);
    if (!$collection || $collection->is_submitted() || $collection->get('owner') !== $USER->get('id')) {
        throw new AccessDeniedException(get_string('cantsubmitcollectiontogroup', 'view'));
    }
    $submissionname = $collection->get('name');
} else {
    $view = new View(param_integer('id'));
    if (!$view || $view->is_submitted() || $view->get('owner') !== $USER->get('id')) {
        throw new AccessDeniedException(get_string('cantsubmitviewtogroup', 'view'));
    }
    $submissionname = $view->get('title');
}
define('TITLE', get_string('submitviewtogroup', 'view', $submissionname, $group->name));
$form = pieform(array('name' => 'submitview', 'renderer' => 'div', 'autofocus' => false, 'method' => 'post', 'elements' => array('submit' => array('type' => 'submitcancel', 'value' => array(get_string('yes'), get_string('no')), 'goto' => get_config('wwwroot') . returnto()))));
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('message', get_string('submitconfirm', 'view', $submissionname, $group->name));
$smarty->assign('form', $form);
$smarty->display('view/submit.tpl');
function submitview_submit(Pieform $form, $values)
{
    global $SESSION, $USER, $view, $collection, $group;
    if (!empty($collection)) {
 * @package    mahara
 * @subpackage core
 * @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(__FILE__)) . '/init.php';
require_once 'view.php';
$view = new View(param_integer('id'));
$change = param_boolean('change', false);
$action = param_alphanumext('action', '');
// If the view has been submitted, disallow editing
if ($view->is_submitted()) {
    $submittedto = $view->submitted_to();
    throw new AccessDeniedException(get_string('canteditsubmitted', 'view', $submittedto['name']));
}
// we actually ned to process stuff
if ($change) {
    try {
        $returndata = $view->process_changes();
        json_reply(false, $returndata);
    } catch (Exception $e) {
        json_reply(true, $e->getMessage());
    }
}
// else we're just reading data...
switch ($action) {
    case 'blocktype_list':