Example #1
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     if ($editing) {
         $smarty = smarty_core();
         $smarty->assign('editing', get_string('ineditordescription1', 'blocktype.comment/comment'));
         $html = $smarty->fetch('blocktype:comment:comment.tpl');
         return $html;
     }
     // Feedback list pagination requires limit/offset params
     $limit = param_integer('limit', 10);
     $offset = param_integer('offset', 0);
     $showcomment = param_integer('showcomment', null);
     // Create the "make feedback private form" now if it's been submitted
     if (param_variable('make_public_submit', null)) {
         pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
     } else {
         if (param_exists('delete_comment_submit')) {
             pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
         }
     }
     $view = new View($instance->get('view'));
     $submittedgroup = (int) $view->get('submittedgroup');
     if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
         $releaseform = true;
     } else {
         $releaseform = false;
     }
     // If the view has comments turned off, tutors can still leave
     // comments if the view is submitted to their group.
     if (!empty($releaseform) || $view->user_comments_allowed($USER)) {
         $addfeedbackpopup = true;
     }
     safe_require('artefact', 'comment');
     $commentoptions = ArtefactTypeComment::get_comment_options();
     $commentoptions->limit = $limit;
     $commentoptions->offset = $offset;
     $commentoptions->showcomment = $showcomment;
     $commentoptions->view = $instance->get_view();
     $feedback = ArtefactTypeComment::get_comments($commentoptions);
     $smarty = smarty_core();
     $smarty->assign('feedback', $feedback);
     if (isset($addfeedbackpopup)) {
         $smarty->assign('enablecomments', 1);
         $smarty->assign('addfeedbackpopup', $addfeedbackpopup);
     }
     $html = $smarty->fetch('blocktype:comment:comment.tpl');
     return $html;
 }
Example #2
0
function add_annotation_feedback_form_submit(Pieform $form, $values)
{
    global $USER;
    $data = (object) array('title' => get_string('Annotation', 'artefact.annotation'), 'description' => $values['message'], 'onannotation' => $values['annotationid']);
    // hidden fields.
    $artefactid = $values['artefactid'];
    $viewid = $values['viewid'];
    $blockid = $values['blockid'];
    if ($artefactid) {
        $artefact = artefact_instance_from_id($artefactid);
        $data->artefact = $artefactid;
        $data->owner = $artefact->get('owner');
        $data->group = $artefact->get('group');
        $data->institution = $artefact->get('institution');
    } else {
        if ($viewid) {
            $view = new View($viewid);
            $data->view = $viewid;
            $data->owner = $view->get('owner');
            $data->group = $view->get('group');
            $data->institution = $view->get('institution');
        }
    }
    if ($author = $USER->get('id')) {
        $anonymous = false;
        $data->author = $author;
    } else {
        $anonymous = true;
        $data->authorname = $values['authorname'];
    }
    if (isset($values['moderate']) && $values['ispublic'] && !$USER->can_edit_view($view)) {
        $data->private = 1;
        $data->requestpublic = 'author';
        $moderated = true;
    } else {
        $data->private = (int) (!$values['ispublic']);
        $moderated = false;
    }
    $private = $data->private;
    $annotationfeedback = new ArtefactTypeAnnotationfeedback(0, $data);
    $annotation = new ArtefactTypeAnnotation($values['annotationid']);
    db_begin();
    $annotationfeedback->commit();
    $url = $annotation->get_view_url($view->get('id'), true, false);
    $goto = get_config('wwwroot') . $url;
    if (isset($data->requestpublic) && $data->requestpublic === 'author' && $data->owner) {
        $arg = $author ? display_name($USER, null, true) : $data->authorname;
        $moderatemsg = (object) array('subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'makepublicrequestsubject', 'section' => 'artefact.annotation', 'args' => array()), 'message' => (object) array('key' => 'makepublicrequestbyauthormessage', 'section' => 'artefact.annotation', 'args' => array(hsc($arg))), 'urltext' => (object) array('key' => 'Annotation', 'section' => 'artefact.annotation')), 'users' => array($data->owner), 'url' => $url);
    }
    require_once 'activity.php';
    $data = (object) array('annotationfeedbackid' => $annotationfeedback->get('id'), 'annotationid' => $values['annotationid'], 'viewid' => $viewid, 'artefactid' => $artefactid);
    activity_occurred('annotationfeedback', $data, 'artefact', 'annotation');
    if (isset($moderatemsg)) {
        activity_occurred('maharamessage', $moderatemsg);
    }
    db_commit();
    if (param_exists('offset')) {
        $options = ArtefactTypeAnnotationfeedback::get_annotation_feedback_options();
        $options->showcomment = 'last';
        $options->artefact = $artefactid;
        $options->view = $viewid;
        $options->annotation = $values['annotationid'];
        $options->block = $blockid;
        $newlist = ArtefactTypeAnnotationfeedback::get_annotation_feedback($options);
    } else {
        $newlist = null;
    }
    // If you're anonymous and your message is moderated or private, then you won't
    // be able to tell what happened to it. So we'll provide some more explanation in
    // the feedback message.
    if ($anonymous && $moderated) {
        $message = get_string('annotationfeedbacksubmittedmoderatedanon', 'artefact.annotation');
    } else {
        if ($anonymous && $private) {
            $message = get_string('annotationfeedbacksubmittedprivateanon', 'artefact.annotation');
        } else {
            $message = get_string('annotationfeedbacksubmitted', 'artefact.annotation');
        }
    }
    $form->reply(PIEFORM_OK, array('message' => $message, 'goto' => $goto, 'data' => $newlist));
}
Example #3
0
 * @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(dirname(__FILE__))) . '/init.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'pieforms/pieform.php';
safe_require('artefact', 'annotation');
// Pagination is not really working here so extradata won't
// really be a parameter.
$extradata = json_decode(param_variable('extradata', null));
$ispagination = false;
if (param_exists('offset')) {
    $ispagination = true;
    $limit = param_integer('limit', 10);
    $offset = param_integer('offset');
}
if (!isset($extradata)) {
    $viewid = json_decode(param_variable('viewid'));
    $annotationid = json_decode(param_variable('annotationid'));
    $artefactid = json_decode(param_variable('artefactid', ''));
    $blockid = json_decode(param_variable('blockid'));
    $extradata = new stdClass();
    $extradata->view = $viewid;
    $extradata->artefact = $artefactid;
    $extradata->annotation = $annotationid;
    $extradata->blockid = $blockid;
}
Example #4
0
    $elements['grouptype'] = array('type' => 'select', 'title' => get_string('Roles', 'group'), 'options' => $grouptypeoptions, 'defaultvalue' => $group_data->grouptype, 'help' => true);
}
$elements['invitefriends'] = array('type' => 'switchbox', 'title' => get_string('friendinvitations', 'group'), 'description' => get_string('invitefriendsdescription1', 'group'), 'defaultvalue' => $group_data->invitefriends);
$elements['suggestfriends'] = array('type' => 'switchbox', 'title' => get_string('Recommendations', 'group'), 'description' => get_string('suggestfriendsdescription1', 'group'), 'defaultvalue' => $group_data->suggestfriends && ($group_data->open || $group_data->request), 'disabled' => !$group_data->open && !$group_data->request);
$elements['pages'] = array('type' => 'html', 'value' => '<h4>' . get_string('content') . '</h4>');
$elements['editroles'] = array('type' => 'select', 'options' => group_get_editroles_options(), 'title' => get_string('editroles1', 'group'), 'description' => get_string('editrolesdescription1', 'group'), 'defaultvalue' => $group_data->editroles, 'help' => true);
if ($cancreatecontrolled) {
    $elements['submittableto'] = array('type' => 'switchbox', 'title' => get_string('allowsubmissions', 'group'), 'description' => get_string('allowssubmissionsdescription1', 'group'), 'defaultvalue' => $group_data->submittableto);
    $elements['allowarchives'] = array('type' => 'switchbox', 'title' => get_string('allowsarchives', 'group'), 'description' => get_string('allowsarchivesdescription', 'group'), 'defaultvalue' => $group_data->allowarchives, 'disabled' => !$group_data->submittableto, 'help' => true);
} else {
    $form['elements']['submittableto'] = array('type' => 'hidden', 'value' => $group_data->submittableto);
    $form['elements']['allowarchives'] = array('type' => 'hidden', 'value' => $group_data->allowarchives);
}
$publicallowed = get_config('createpublicgroups') == 'all' || get_config('createpublicgroups') == 'admins' && $USER->get('admin');
$publicallowed = $publicallowed && !is_probationary_user();
if (!$id && !param_exists('pieform_editgroup')) {
    // If a 'public=0' parameter is passed on the first page load, hide the
    // public checkbox.  The only purpose of this is to allow custom create
    // group buttons/links which lead to a slightly simplified form.
    $publicparam = param_integer('public', null);
}
$ignorepublic = !$publicallowed || isset($publicparam) && $publicparam === 0;
if ($cancreatecontrolled || !$ignorepublic) {
    $elements['visibility'] = array('type' => 'html', 'value' => '<h4>' . get_string('Visibility') . '</h4>');
}
$elements['public'] = array('type' => 'switchbox', 'title' => get_string('publiclyviewablegroup', 'group'), 'description' => get_string('publiclyviewablegroupdescription1', 'group'), 'defaultvalue' => $group_data->public, 'help' => true, 'ignore' => $ignorepublic);
if ($cancreatecontrolled) {
    $elements['hidden'] = array('type' => 'switchbox', 'title' => get_string('hiddengroup', 'group'), 'description' => get_string('hiddengroupdescription1', 'group'), 'defaultvalue' => $group_data->hidden);
    $elements['hidemembers'] = array('type' => 'switchbox', 'title' => get_string('hidemembers', 'group'), 'description' => get_string('hidemembersdescription', 'group'), 'defaultvalue' => $group_data->hidemembers || $group_data->hidemembersfrommembers, 'disabled' => $group_data->hidemembersfrommembers);
    $elements['hidemembersfrommembers'] = array('type' => 'switchbox', 'title' => get_string('hidemembersfrommembers', 'group'), 'description' => get_string('hidemembersfrommembersdescription1', 'group'), 'defaultvalue' => $group_data->hidemembersfrommembers);
} else {
Example #5
0
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'imagebrowser.php';
$change = param_boolean('change', false);
$viewid = param_integer('id', 0);
$forumpostid = param_integer('post', 0);
$groupid = param_integer('group', 0);
$institution = param_alphanum('institution', 0);
$blogid = param_alphanum('blogid', 0);
$changebrowsetab = param_integer('imgbrowserconf_artefactid_changeowner', 0);
// Folder value is 0 when returning to Home folder
$changefolder = param_exists('imgbrowserconf_artefactid_changefolder') ? true : false;
$uploadimg = param_integer('imgbrowserconf_artefactid_upload', 0);
$formsubmit = param_exists('action_submitimage') ? true : false;
$formcancel = param_exists('cancel_action_submitimage') ? true : false;
if ($forumpostid && !$groupid) {
    $sql = "SELECT g.id\n                FROM {group} g\n                INNER JOIN {interaction_instance} ii ON ii.group = g.id\n                INNER JOIN {interaction_forum_topic} ift ON ift.forum = ii.id\n                INNER JOIN {interaction_forum_post} ifp ON ifp.topic = ift.id\n                WHERE ifp.id = ?\n                AND ifp.deleted = 0";
    $groupid = get_field_sql($sql, array($forumpostid));
}
if ($blogid) {
    safe_require('artefact', 'blog');
    $blogobj = new ArtefactTypeBlog($blogid);
    $institution = $blogobj->get('institution');
}
// Create new image browser
if ($change) {
    $ib = new ImageBrowser(array('view' => $viewid, 'post' => $forumpostid, 'group' => $groupid, 'institution' => $institution));
    try {
        $returndata = $ib->render_image_browser();
        json_reply(false, array('data' => $returndata));
Example #6
0
                $groupurl = group_homepage_url(get_record('group', 'id', $view->get('group')), false);
            }
            define('TITLE', $title);
        } else {
            if ($new) {
                define('TITLE', get_string('notitle', 'view'));
            } else {
                define('TITLE', $view->get('title'));
                $editabletitle = true;
            }
        }
    }
}
// Make the default category the first tab if none is set
$category = '';
if (param_exists('c')) {
    $category = param_variable('c');
}
if (empty($category)) {
    $category = $view->get_default_category();
}
$view->process_changes($category, $new);
$extraconfig = array('sidebars' => false);
// Set up theme
$viewtheme = $view->set_user_theme();
$allowedthemes = get_user_accessible_themes();
// Pull in cross-theme view stylesheet and file stylesheets
$stylesheets = array();
foreach (array_reverse($THEME->get_url('style/style.css', true, 'artefact/file')) as $sheet) {
    $stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number($sheet) . '">';
}
Example #7
0
}
// Feedback list pagination requires limit/offset params
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$showcomment = param_integer('showcomment', null);
if ($artefact && $viewid && $blockid) {
    // use the block instance title rather than the artefact title if it exists
    $title = artefact_title_for_view_and_block($artefact, $viewid, $blockid);
} else {
    $title = $artefact->display_title();
}
// Create the "make feedback private form" now if it's been submitted
if (param_variable('make_public_submit', null)) {
    pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
} else {
    if (param_exists('delete_comment_submit')) {
        pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
    }
}
define('TITLE', $title . ' ' . get_string('in', 'view') . ' ' . $view->get('title'));
// Render the artefact
$options = array('viewid' => $viewid, 'details' => true, 'metadata' => 1);
if ($artefact->get('artefacttype') == 'folder') {
    // Get folder block sort order - returns the first instance of folder on view unless $blockid is set.
    // TODO: get the clicking on a subfolder to carry the block id as well - that way we can get exact configdata.
    if ($block = get_records_sql_array('SELECT block FROM {view_artefact} WHERE view = ? AND artefact = ?', array($viewid, $baseobject->get('id')))) {
        require_once get_config('docroot') . 'blocktype/lib.php';
        $key = 0;
        // If we have a $blockid, then we will use block's configdata.
        if ($blockid) {
            foreach ($block as $k => $b) {