Beispiel #1
0
 /**
  * Get the blog entries that will be displayed by this block.
  * (This list will change depending when new blog entries are created, published, etc
  *
  * @param BlockInstance $instance
  * @return array of objects
  */
 public static function get_blog_posts_in_block(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     $limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
     $mostrecent = array();
     if (!empty($configdata['artefactids'])) {
         $before = 'TRUE';
         if ($instance->get_view()->is_submitted()) {
             if ($submittedtime = $instance->get_view()->get('submittedtime')) {
                 // Don't display posts added after the submitted date.
                 $before = "a.ctime < '{$submittedtime}'";
             }
         }
         $blogids = $configdata['artefactids'];
         $artefactids = implode(', ', array_map('db_quote', $blogids));
         $mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
                 FROM {artefact} a
                 JOIN {artefact} p ON a.parent = p.id
                 JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
                 WHERE a.artefacttype = \'blogpost\'
                 AND a.parent IN ( ' . $artefactids . ' )
                 AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
                 AND ' . $before . '
                 ORDER BY a.ctime DESC, a.id DESC
                 LIMIT ' . $limit, array($instance->get('view')));
         if (!$mostrecent) {
             $mostrecent = array();
         }
     }
     return $mostrecent;
 }
Beispiel #2
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     if (!isset($configdata['showgroupviews'])) {
         // If not set, use default
         $configdata['showgroupviews'] = 1;
     }
     if (!isset($configdata['showsharedviews'])) {
         $configdata['showsharedviews'] = 1;
     }
     if (!isset($configdata['showsharedcollections'])) {
         $configdata['showsharedcollections'] = 1;
     }
     if (!isset($configdata['showsubmitted'])) {
         $configdata['showsubmitted'] = 1;
     }
     $groupid = $instance->get_view()->get('group');
     if (!$groupid) {
         return '';
     }
     $data = self::get_data($groupid, $editing);
     $dwoo = smarty_core();
     $dwoo->assign('group', $data['group']);
     $dwoo->assign('groupid', $data['group']->id);
     $baseurl = $instance->get_view()->get_url();
     $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid;
     if (!empty($configdata['showgroupviews']) && isset($data['groupviews'])) {
         $groupviews = (array) $data['groupviews'];
         $pagination = array('baseurl' => $baseurl, 'id' => 'groupviews_pagination', 'datatable' => 'groupviewlist', 'jsonscript' => 'blocktype/groupviews/groupviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'));
         self::render_items($groupviews, 'blocktype:groupviews:groupviewssection.tpl', $configdata, $pagination);
         $dwoo->assign('groupviews', $groupviews);
     }
     if (!empty($configdata['showsharedviews']) && isset($data['sharedviews'])) {
         $sharedviews = (array) $data['sharedviews'];
         $pagination = array('baseurl' => $baseurl, 'id' => 'sharedviews_pagination', 'datatable' => 'sharedviewlist', 'jsonscript' => 'blocktype/groupviews/sharedviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'));
         self::render_items($sharedviews, 'blocktype:groupviews:sharedviews.tpl', $configdata, $pagination);
         $dwoo->assign('sharedviews', $sharedviews);
     }
     if (!empty($configdata['showsharedcollections']) && isset($data['sharedcollections'])) {
         $sharedcollections = (array) $data['sharedcollections'];
         $pagination = array('baseurl' => $baseurl, 'id' => 'sharedcollections_pagination', 'datatable' => 'sharedcollectionlist', 'jsonscript' => 'blocktype/groupviews/sharedcollections.json.php', 'resultcounttextsingular' => get_string('collection', 'collection'), 'resultcounttextplural' => get_string('collections', 'collection'));
         self::render_items($sharedcollections, 'blocktype:groupviews:sharedcollections.tpl', $configdata, $pagination);
         $dwoo->assign('sharedcollections', $sharedcollections);
     }
     if (!empty($configdata['showsubmitted']) && isset($data['allsubmitted'])) {
         $allsubmitted = $data['allsubmitted'];
         $pagination = array('baseurl' => $baseurl, 'id' => 'allsubmitted_pagination', 'datatable' => 'allsubmissionlist', 'jsonscript' => 'blocktype/groupviews/allsubmissions.json.php', 'resultcounttextsingular' => get_string('vieworcollection', 'view'), 'resultcounttextplural' => get_string('viewsandcollections', 'view'));
         self::render_items($allsubmitted, 'blocktype:groupviews:allsubmissions.tpl', $configdata, $pagination);
         $dwoo->assign('allsubmitted', $allsubmitted);
     }
     if (isset($data['mysubmitted'])) {
         $dwoo->assign('mysubmitted', $data['mysubmitted']);
     }
     if (!$editing && isset($data['group_view_submission_form'])) {
         $dwoo->assign('group_view_submission_form', $data['group_view_submission_form']);
     }
     return $dwoo->fetch('blocktype:groupviews:groupviews.tpl');
 }
Beispiel #3
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $result = '';
     $limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
     if (!empty($configdata['artefactids'])) {
         $before = 'TRUE';
         if ($instance->get_view()->is_submitted()) {
             if ($submittedtime = $instance->get_view()->get('submittedtime')) {
                 // Don't display posts added after the submitted date.
                 $before = "a.ctime < '{$submittedtime}'";
             }
         }
         $artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
         if (!($mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
             FROM {artefact} a
             JOIN {artefact} p ON a.parent = p.id
             JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
             WHERE a.artefacttype = \'blogpost\'
             AND a.parent IN ( ' . $artefactids . ' )
             AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
             AND ' . $before . '
             ORDER BY a.ctime DESC, a.id DESC
             LIMIT ' . $limit, array($instance->get('view'))))) {
             $mostrecent = array();
         }
         // format the dates
         foreach ($mostrecent as &$data) {
             $data->displaydate = format_date($data->ctime);
         }
         $smarty = smarty_core();
         $smarty->assign('mostrecent', $mostrecent);
         $smarty->assign('view', $instance->get('view'));
         $smarty->assign('blockid', $instance->get('id'));
         $smarty->assign('editing', $editing);
         if ($editing) {
             // Get id and title of configued blogs
             $recentpostconfigdata = $instance->get('configdata');
             $wherestm = ' WHERE id IN (' . join(',', array_fill(0, count($recentpostconfigdata['artefactids']), '?')) . ')';
             if (!($selectedblogs = get_records_sql_array('SELECT id, title FROM {artefact}' . $wherestm, $recentpostconfigdata['artefactids']))) {
                 $selectedblogs = array();
             }
             $smarty->assign('blogs', $selectedblogs);
         }
         $result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
     }
     return $result;
 }
Beispiel #4
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'cpds');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (isset($configdata['artefactid'])) {
         $cpd = artefact_instance_from_id($configdata['artefactid']);
         $activities = ArtefactTypeActivity::get_activities($configdata['artefactid']);
         $template = 'artefact:cpds:activityrows.tpl';
         $blockid = $instance->get('id');
         if ($exporter) {
             $pagination = false;
         } else {
             $pagination = array('baseurl' => $instance->get_view()->get_url() . '&block=' . $blockid, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'activitytable_' . $blockid, 'jsonscript' => 'artefact/cpds/viewactivities.json.php');
         }
         ArtefactTypeActivity::render_activities($activities, $template, $configdata, $pagination);
         if ($exporter && $activities['count'] > $activities['limit']) {
             $artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&amp;view=' . $instance->get('view');
             $activities['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allactivities', 'artefact.cpds') . '</a>';
         }
         $smarty->assign('description', $cpd->get('description'));
         $smarty->assign('activities', $activities);
         $smarty->assign('owner', $cpd->get('owner'));
         $smarty->assign('tags', $cpd->get('tags'));
     } else {
         $smarty->assign('nocpds', 'blocktype.cpds/cpds');
     }
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:cpds:content.tpl');
 }
Beispiel #5
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'calendar');
     $smarty = smarty_core();
     $blockid = param_integer('block', '');
     $this_instance_id = $instance->get('id');
     if (!$blockid or $blockid and $blockid == $this_instance_id) {
         $offset = param_integer('offset', 0);
         $limit = param_integer('limit', 3);
     } else {
         $offset = 0;
         $limit = 3;
         $blockid = $this_instance_id;
     }
     $events = ArtefactTypeEvent::get_all_events($blockid, $offset, $limit);
     $template = 'artefact:calendar:eventrows.tpl';
     if ($exporter) {
         $pagination = false;
     } else {
         $baseurl = $instance->get_view()->get_url();
         $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid;
         $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'eventtable_' . $blockid, 'jsonscript' => 'artefact/calendar/viewevents.json.php');
     }
     ArtefactTypeEvent::render_events($events, $template, $pagination);
     if ($exporter && $events['count'] > $events['limit']) {
         $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $blockid . '&view=' . $instance->get('view');
         $events['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allevents', 'artefact.calendar') . '</a>';
     }
     $smarty->assign('events', $events);
     $smarty->assign('blockid', $blockid);
     return $smarty->fetch('blocktype:events:content.tpl');
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'ilps');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (isset($configdata['artefactid'])) {
         $units = ArtefactTypeunit::get_units($configdata['artefactid']);
         $template = 'artefact:ilps:unitrows.tpl';
         $blockid = $instance->get('id');
         if ($exporter) {
             $pagination = false;
         } else {
             $pagination = array('baseurl' => $instance->get_view()->get_url() . '&block=' . $blockid, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'unittable_' . $blockid, 'jsonscript' => 'artefact/ilps/viewunits.json.php');
         }
         ArtefactTypeUnit::render_units($units, $template, $configdata, $pagination);
         if ($exporter && $units['count'] > $units['limit']) {
             $artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&amp;view=' . $instance->get('view');
             $units['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allunits', 'artefact.ilps') . '</a>';
         }
         $smarty->assign('units', $units);
     } else {
         $smarty->assign('noilps', 'blocktype.ilps/ilps');
     }
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:ilps:content.tpl');
 }
Beispiel #7
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'plans');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (isset($configdata['artefactid'])) {
         $plan = artefact_instance_from_id($configdata['artefactid']);
         $tasks = ArtefactTypeTask::get_tasks($configdata['artefactid']);
         $template = 'artefact:plans:taskrows.tpl';
         $blockid = $instance->get('id');
         if ($exporter) {
             $pagination = false;
         } else {
             $baseurl = $instance->get_view()->get_url();
             $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid;
             $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'tasktable_' . $blockid, 'jsonscript' => 'artefact/plans/viewtasks.json.php');
         }
         ArtefactTypeTask::render_tasks($tasks, $template, $configdata, $pagination);
         if ($exporter && $tasks['count'] > $tasks['limit']) {
             $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view');
             $tasks['pagination'] = '<a href="' . $artefacturl . '">' . get_string('alltasks', 'artefact.plans') . '</a>';
         }
         $smarty->assign('owner', $plan->get('owner'));
         $smarty->assign('tags', $plan->get('tags'));
         $smarty->assign('tasks', $tasks);
     } else {
         $smarty->assign('noplans', 'blocktype.plans/plans');
     }
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:plans:content.tpl');
 }
Beispiel #8
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $THEME;
     $configdata = $instance->get('configdata');
     if (!isset($configdata['license'])) {
         return '';
     }
     $licensetype = reset(preg_grep('/^([a-z\\-]+)$/', array($configdata['license'])));
     if (isset($configdata['version'])) {
         $licenseversion = get_string('version' . $configdata['version'], 'blocktype.creativecommons');
     } else {
         $licenseversion = get_string('version30', 'blocktype.creativecommons');
     }
     $licenseurl = "http://creativecommons.org/licenses/{$licensetype}/{$licenseversion}/";
     $view = $instance->get_view();
     $workname = '<span rel="dc:type" href="http://purl.org/dc/dcmitype/Text" property="dc:title">' . $view->display_title(true, false, false) . '</span>';
     $authorurl = $view->owner_link();
     $authorname = hsc($view->formatted_owner());
     $licensename = get_string('cclicensename', 'blocktype.creativecommons', get_string($licensetype, 'blocktype.creativecommons'), $licenseversion);
     $licenselink = '<a rel="license" href="' . $licenseurl . '">' . $licensename . '</a>';
     $attributionlink = '<a rel="cc:attributionURL" property="cc:attributionName" href="' . $authorurl . '">' . $authorname . '</a>';
     $licensestatement = get_string('cclicensestatement', 'blocktype.creativecommons', $workname, $attributionlink, $licenselink);
     $permissionlink = '<a rel="cc:morePermissions" href="' . $authorurl . '">' . $authorname . '</a>';
     $otherpermissions = get_string('otherpermissions', 'blocktype.creativecommons', $permissionlink);
     $smarty = smarty_core();
     $smarty->assign('licenseurl', $licenseurl);
     $smarty->assign('licenselogo', $THEME->get_image_url($licensetype . '-3_0', 'blocktype/creativecommons'));
     $smarty->assign('licensestatement', $licensestatement);
     $smarty->assign('otherpermissions', $otherpermissions);
     return $smarty->fetch('blocktype:creativecommons:statement.tpl');
 }
Beispiel #9
0
 public static function override_instance_title(BlockInstance $instance)
 {
     global $USER;
     $ownerid = $instance->get_view()->get('owner');
     if ($ownerid === null || $ownerid == $USER->get('id')) {
         return get_string('title', 'blocktype.myviews');
     }
     return get_string('otherusertitle', 'blocktype.myviews', display_name($ownerid, null, true));
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $type = isset($configdata['linkedindata']) ? $configdata['linkedindata'] : 'basicprofile';
     $owner = $instance->get_view()->get('owner');
     $profile = self::get_user_profile($type, $owner);
     $smarty = smarty_core();
     $smarty->assign('profile', $profile);
     return $smarty->fetch('blocktype:linkedinprofile:' . $type . '.tpl');
 }
Beispiel #11
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $groupid = $instance->get_view()->get('group');
     if (!$groupid) {
         return '';
     }
     $data = self::get_data($groupid);
     $dwoo = smarty_core();
     $dwoo->assign('group', $data);
     $dwoo->assign('editwindow', group_format_editwindow($data));
     return $dwoo->fetch('blocktype:groupinfo:groupinfo.tpl');
 }
Beispiel #12
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $statusoptions = self::get_allowed_status();
     $configdata = $instance->get('configdata');
     $view = $instance->get_view();
     $status = 0;
     if (isset($configdata['status']) && isset($statusoptions[$configdata['status']])) {
         $status = $configdata['status'];
     }
     $elements = array('status' => array('type' => 'select', 'options' => $statusoptions, 'title' => get_string('pagestatus', 'blocktype.pagestatus'), 'defaultvalue' => $status));
     return $elements;
 }
Beispiel #13
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_variable('delete_comment_submit_x', null)) {
             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;
 }
Beispiel #14
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     if ($instance->get_view()->get('owner') == "0") {
         return '';
     }
     $configdata = $instance->get('configdata');
     $rows = isset($configdata['rows']) ? $configdata['rows'] : 1;
     $columns = isset($configdata['columns']) ? $configdata['columns'] : 6;
     $order = isset($configdata['order']) ? $configdata['order'] : 'latest';
     $numtoshow = isset($configdata['numtoshow']) ? $configdata['numtoshow'] : $rows * $columns;
     $groupid = $instance->get_view()->get('group');
     // If the group has hidden membership, display nothing
     $usergroups = $USER->get('grouproles');
     $group = defined('GROUP') && $groupid == GROUP ? group_current_group() : get_record('group', 'id', $groupid);
     if ($group->hidemembersfrommembers && (!isset($usergroups[$groupid]) || $usergroups[$groupid] != 'admin')) {
         return '';
     }
     if ($group->hidemembers && !isset($usergroups[$groupid])) {
         return '';
     }
     require_once 'searchlib.php';
     $groupmembers = get_group_user_search_results($groupid, '', 0, $numtoshow, '', $order);
     if ($groupmembers['count']) {
         $smarty = smarty_core();
         $smarty->assign_by_ref('groupmembers', $groupmembers['data']);
         $groupmembers['tablerows'] = $smarty->fetch('blocktype:groupmembers:row.tpl');
     } else {
         $groupmembers = false;
     }
     $show_all = array('url' => get_config('wwwroot') . 'group/members.php?id=' . $groupid, 'message' => get_string('show_all', 'blocktype.groupmembers'));
     $smarty = smarty_core();
     $smarty->assign('groupmembers', $groupmembers);
     $smarty->assign('show_all', $show_all);
     return $smarty->fetch('blocktype:groupmembers:groupmembers.tpl');
 }
Beispiel #15
0
 public static function instance_config_form(BlockInstance $instance)
 {
     require_once 'license.php';
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     $view = $instance->get_view();
     $text = '';
     if (array_key_exists('text', $configdata)) {
         $text = $configdata['text'];
     }
     $elements = array('text' => array('type' => 'wysiwyg', 'title' => get_string('blockcontent', 'blocktype.text'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)));
     return $elements;
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $groupid = $instance->get_view()->get('group');
     if (!$groupid) {
         return '';
     }
     $data = self::get_data($groupid);
     $dwoo = smarty_core();
     $dwoo->assign('group', $data['group']);
     $dwoo->assign('groupid', $data['group']->id);
     $dwoo->assign('membercount', count_records('group_member', 'group', $data['group']->id));
     $dwoo->assign('viewcount', count_records('view', 'group', $data['group']->id));
     $dwoo->assign('filecount', $data['filecounts']->files);
     $dwoo->assign('foldercount', $data['filecounts']->folders);
     return $dwoo->fetch('blocktype:groupinfo:groupinfo.tpl');
 }
Beispiel #17
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     $view = $instance->get_view();
     $groupid = $view->get('group');
     $institutionid = $view->get('institution');
     $userid = $view->get('owner');
     $urlparams['new'] = 1;
     if (!empty($groupid)) {
         $where = 'c.group = ?';
         $values = array($groupid);
         $urlparams['group'] = $groupid;
     } else {
         if (!empty($institutionid)) {
             $where = 'c.institution = ?';
             $values = array($institutionid);
             $urlparams['institution'] = $institutionid;
         } else {
             $where = 'c.owner = ?';
             $values = array($userid);
         }
     }
     ($collections = get_records_sql_array("\n            SELECT c.id, c.name\n                FROM {collection} c\n            WHERE " . $where . "\n            ORDER BY c.name, c.ctime ASC", $values)) || ($collections = array());
     $default = false;
     $options = array();
     if (!empty($collections)) {
         foreach ($collections as $collection) {
             if (!$default) {
                 // need to have an initially selected item
                 $default = $collection->id;
             }
             $options[$collection->id] = $collection->name;
         }
         return array('collection' => array('type' => 'select', 'title' => get_string('collection', 'blocktype.navigation'), 'rules' => array('required' => true), 'options' => $options, 'defaultvalue' => !empty($configdata['collection']) ? $configdata['collection'] : $default));
     } else {
         $baseurl = get_config('wwwroot') . 'collection/edit.php';
         if ($urlparams) {
             $baseurl .= '?' . http_build_query($urlparams);
         }
         return array('nocollections' => array('type' => 'html', 'title' => get_string('collection', 'blocktype.navigation'), 'description' => get_string('nocollections1', 'blocktype.navigation', $baseurl), 'value' => ''));
     }
 }
    public static function render_instance(BlockInstance $instance, $editing = false)
    {
        //Default limit and offset. This was copied from Mike Kelly's code
        $offset = 0;
        $limit = 10;
        $groupid = $instance->get_view()->get('group');
        if (!$groupid) {
            return '';
        }
        //returns an array of all views for a group id. This uses the groupviews method that was copied acrossed
        $items = self::get_data($groupid, $offset, $limit);
        //calls Mike Kelly's method to build the objects to be displayed
        self::build_browse_list_html($items);
        if (empty($items) || !isset($items)) {
            //20150723 JW changed the return message so if there are no pages to display it says that rather you don't have access
            return "No pages to display";
        }
        //Not sure what this does
        $js = <<<EOF
addLoadEvent(function () {
    {$items['pagination_js']}
});
EOF;
        //neededJS and neededCSS are files required to render the page properly. They are done this way so it is easier to read
        $neededJS = array(get_config('wwwroot') . 'blocktype/groupviewsimage/js/chosen.jquery.js', get_config('wwwroot') . 'blocktype/groupviewsimage/js/browse.js');
        $neededCSS = array(get_config('wwwroot') . "blocktype/groupviewsimage/js/jquery-ui/css/custom-theme/jquery-ui-1.8.20.custom.css", get_config('wwwroot') . "blocktype/groupviewsimage/theme/raw/static/style/chosen.css", get_config('wwwroot') . "blocktype/groupviewsimage/theme/raw/static/style/style.css");
        //calls smarty and feeds the data to be render via the tpl file
        $dwoo = smarty_core();
        //adds the javascript and css files into the template to be rendered
        $dwoo->assign('JAVASCRIPT', $neededJS);
        $dwoo->assign('STYLESHEETLIST', $neededCSS);
        $dwoo->assign('INLINEJAVASCRIPT', $js);
        //????
        //20150723 JW added extra entry to check if jquery is loaded, if not then load the below jquery
        $dwoo->assign('JQUERYPATH', get_config('wwwroot') . 'blocktype/groupviewsimage/js/jquery-ui/js/jquery-ui-1.8.19.custom.min.js');
        //adds the items into the templated to be rendered
        $dwoo->assign_by_ref('items', $items);
        //returns the template as text so mahara can render the block
        return $dwoo->fetch('blocktype:groupviewsimage:index.tpl');
    }
 /**
  * This method is provided by the plugin class so it can be used by the
  * profileinfo and contactinfo blocktypes. See the blocktypes'
  * export_blockinstance_config_leap method for more information.
  *
  * Leap2A export doesn't export profile related artefacts as entries, so we
  * need to take that into account when exporting config for it.
  *
  * @param BlockInstance $bi The blockinstance to export the config for.
  * @return array The config for the blockinstance
  */
 public static function export_blockinstance_config_leap(BlockInstance $bi)
 {
     static $cache = array();
     $owner = $bi->get_view()->get('owner');
     // This blocktype is only allowed in personal views
     if (!$owner) {
         return array();
     }
     if (!isset($cache[$owner])) {
         $cache[$owner] = get_records_sql_assoc("SELECT id, artefacttype, title\n                FROM {artefact}\n                WHERE \"owner\" = ?\n                AND artefacttype IN (\n                    SELECT name\n                    FROM {artefact_installed_type}\n                    WHERE plugin = 'internal'\n            )", array($owner));
     }
     $configdata = $bi->get('configdata');
     $result = array();
     if (is_array($configdata)) {
         // Convert the actual profile artefact IDs to their field names
         if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
             $result['fields'] = array();
             foreach ($configdata['artefactids'] as $id) {
                 $result['fields'][] = $cache[$owner][$id]->artefacttype;
             }
             $result['fields'] = json_encode(array($result['fields']));
         }
         // Email addresses are not entries in Leap2A (they're elements on
         // the persondata element), so we export the actual address here
         // instead of an artefact ID.
         if (!empty($configdata['email']) && isset($cache[$owner][$configdata['email']])) {
             $result['email'] = json_encode(array($cache[$owner][$configdata['email']]->title));
         }
         if (!empty($configdata['profileicon'])) {
             $result['artefactid'] = json_encode(array(intval($configdata['profileicon'])));
         }
         if (isset($configdata['introtext'])) {
             $result['introtext'] = json_encode(array($configdata['introtext']));
         }
     }
     return $result;
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     $configdata = $instance->get('configdata');
     $rows = isset($configdata['rows']) ? $configdata['rows'] : 1;
     $columns = isset($configdata['columns']) ? $configdata['columns'] : 6;
     $order = isset($configdata['order']) ? $configdata['order'] : 'latest';
     $groupid = $instance->get_view()->get('group');
     require_once 'searchlib.php';
     $groupmembers = get_group_user_search_results($groupid, '', 0, $rows * $columns, '', $order);
     if ($groupmembers['count']) {
         $groupmembersarray = array_chunk($groupmembers['data'], $columns);
         $smarty = smarty_core();
         $smarty->assign_by_ref('groupmembers', $groupmembersarray);
         $groupmembers['tablerows'] = $smarty->fetch('blocktype:groupmembers:row.tpl');
     } else {
         $groupmembers = false;
     }
     $show_all = array('url' => get_config('wwwroot') . 'group/members.php?id=' . $groupid, 'message' => get_string('show_all', 'blocktype.groupmembers'));
     $smarty = smarty_core();
     $smarty->assign('groupmembers', $groupmembers);
     $smarty->assign('show_all', $show_all);
     return $smarty->fetch('blocktype:groupmembers:groupmembers.tpl');
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $groupid = $instance->get_view()->get('group');
     if (!$groupid) {
         return '';
     }
     $data = self::get_data($groupid);
     $dwoo = smarty_core();
     $dwoo->assign('group', $data['group']);
     $dwoo->assign('groupid', $data['group']->id);
     if (isset($data['sharedviews'])) {
         $dwoo->assign('sharedviews', $data['sharedviews']->data);
     }
     if (isset($data['allsubmittedviews'])) {
         $dwoo->assign('allsubmittedviews', $data['allsubmittedviews']);
     }
     if (isset($data['mysubmittedviews'])) {
         $dwoo->assign('mysubmittedviews', $data['mysubmittedviews']);
     }
     if (!$editing && isset($data['group_view_submission_form'])) {
         $dwoo->assign('group_view_submission_form', $data['group_view_submission_form']);
     }
     return $dwoo->fetch('blocktype:groupviews:groupviews.tpl');
 }
 public static function override_instance_title(BlockInstance $instance)
 {
     $groupid = $instance->get_view()->get('group');
     if (!$groupid) {
         $configdata = $instance->get('configdata');
         if (isset($configdata['groupid'])) {
             $groupid = intval($configdata['groupid']);
         }
     }
     if (!empty($groupid)) {
         return str_replace('<group>', get_field('group', 'name', 'id', $groupid), $instance->get('title'));
     } else {
         return $instance->get('title');
     }
 }
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'blog');
require_once get_config('docroot') . 'blocktype/lib.php';
require_once get_config('docroot') . 'artefact/blog/blocktype/blog/lib.php';
$offset = param_integer('offset', 0);
if ($blockid = param_integer('block', null)) {
    $bi = new BlockInstance($blockid);
    $configdata = $bi->get('configdata');
    $limit = isset($configdata['count']) ? $configdata['count'] : 5;
    $configdata['countcomments'] = true;
    $posts = ArtefactTypeBlogpost::get_posts($configdata['artefactid'], $limit, $offset, $configdata);
    $template = 'artefact:blog:viewposts.tpl';
    $pagination = array('baseurl' => $bi->get_view()->get_url() . '&block=' . $blockid, 'id' => 'blogpost_pagination_' . $blockid, 'datatable' => 'postlist_' . $blockid, 'jsonscript' => 'artefact/blog/posts.json.php');
    $configdata['viewid'] = $bi->get('view');
    ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination);
} else {
    // No block, we're just rendering the blog by itself on view/artefact.php
    $limit = param_integer('limit', ArtefactTypeBlog::pagination);
    $blogid = param_integer('artefact');
    $viewid = param_integer('view');
    $options = array('viewid' => $viewid);
    $posts = ArtefactTypeBlogpost::get_posts($blogid, $limit, $offset, $options);
    $template = 'artefact:blog:viewposts.tpl';
    $baseurl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $blogid . '&view=' . $viewid;
    $pagination = array('baseurl' => $baseurl, 'id' => 'blogpost_pagination', 'datatable' => 'postlist', 'jsonscript' => 'artefact/blog/posts.json.php');
    ArtefactTypeBlogpost::render_posts($posts, $template, $options, $pagination);
}
json_reply(false, array('data' => $posts));
Beispiel #24
0
 public static function instance_config_form(BlockInstance $instance)
 {
     global $USER;
     require_once 'license.php';
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'internal');
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     $otherblockcount = 0;
     $readonly = false;
     $text = '';
     $tags = '';
     $view = $instance->get_view();
     if (!empty($configdata['artefactid'])) {
         $artefactid = $configdata['artefactid'];
         try {
             $artefact = $instance->get_artefact_instance($artefactid);
             $readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
             $text = $artefact->get('description');
             $tags = $artefact->get('tags');
             if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) {
                 $blocks = array_unique($blocks);
                 $otherblockcount = count($blocks) - 1;
             }
         } catch (ArtefactNotFoundException $e) {
             unset($artefactid);
         }
     }
     $otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>';
     $otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg);
     $manageurl = get_config('wwwroot') . 'artefact/internal/notes.php';
     if ($group = $view->get('group')) {
         $manageurl .= '?group=' . $group;
     } else {
         if ($institution = $view->get('institution')) {
             $manageurl .= '?institution=' . $institution;
         }
     }
     // Update the attached files in block configdata as
     // it may change when attached files have been deleted
     $attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false;
     if ($attachmentids !== false && isset($configdata['artefactids']) && $configdata['artefactids'] != $attachmentids) {
         $configdata['artefactids'] = $attachmentids;
         $instance->set('configdata', $configdata);
         $instance->commit();
     }
     $elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . $otherblocksmsg . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . get_string('readonlymessage', 'blocktype.internal/textbox') . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'value' => '<div id="instconf_textreadonly_display" class="well text-midtone">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'value' => '<a id="chooseartefactlink" href="#" class="btn btn-default">' . get_string('usecontentfromanothertextbox1', 'blocktype.internal/textbox') . '</a>'), 'managenotes' => array('type' => 'html', 'class' => 'hidden text-right', 'value' => '<a href="' . $manageurl . '" target="_blank" class="pull-right">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' <span class="icon icon-arrow-right right"></span></a>'), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'license' => license_form_el_basic(isset($artefact) ? $artefact : null), 'license_advanced' => license_form_el_advanced(isset($artefact) ? $artefact : null), 'licensereadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('license'), 'value' => '<div id="instconf_licensereadonly_display">' . (isset($artefact) ? render_license($artefact) : get_string('licensenone')) . '</div>'), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'tags' => array('type' => 'tags', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $tags), 'tagsreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('tags'), 'value' => '<div id="instconf_tagsreadonly_display">' . (is_array($tags) ? hsc(join(', ', $tags)) : '') . '</div>'), 'artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('attachments', 'artefact.blog'), 'class' => 'last with-formgroup', 'elements' => array('artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null))));
     if ($readonly) {
         $elements['license']['class'] = 'hidden';
         $elements['license_advanced']['class'] = 'hidden';
     }
     return $elements;
 }
Beispiel #25
0
 public static function feed_url(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     if (!empty($configdata['artefactid']) && $instance->get_view()->is_public()) {
         return get_config('wwwroot') . 'artefact/blog/atom.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view');
     }
 }
 * @author     Geoffrey Rowland
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'cpds');
require_once get_config('docroot') . 'blocktype/lib.php';
require_once get_config('docroot') . 'artefact/cpds/blocktype/cpds/lib.php';
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
if ($blockid = param_integer('block', null)) {
    $bi = new BlockInstance($blockid);
    $options = $configdata = $bi->get('configdata');
    $activities = ArtefactTypeActivity::get_activities($configdata['artefactid'], $offset, $limit);
    $template = 'artefact:cpds:activityrows.tpl';
    $baseurl = $bi->get_view()->get_url();
    $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid;
    $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'activitytable_' . $blockid, 'jsonscript' => 'artefact/cpds/viewactivities.json.php');
} else {
    $cpdid = param_integer('artefact');
    $viewid = param_integer('view');
    $options = array('viewid' => $viewid);
    $activities = ArtefactTypeActivity::get_activities($cpdid, $offset, $limit);
    $template = 'artefact:cpds:activityrows.tpl';
    $baseurl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $cpdid . '&view=' . $options['viewid'];
    $pagination = array('baseurl' => $baseurl, 'id' => 'activity_pagination', 'datatable' => 'activitylist', 'jsonscript' => 'artefact/cpds/viewactivities.json.php');
}
ArtefactTypeActivity::render_activities($activities, $template, $options, $pagination);
json_reply(false, (object) array('message' => false, 'data' => $activities));
Beispiel #27
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     $configdata = $instance->get('configdata');
     $view = $instance->get('view');
     $limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
     $full = isset($configdata['full']) ? $configdata['full'] : false;
     $results = array();
     $smarty = smarty_core();
     $smarty->assign('view', $view);
     // Display all posts, from all blogs, owned by this user
     if (!empty($configdata['tagselect'])) {
         $tagselect = $configdata['tagselect'];
         $sql = 'SELECT a.title, p.title AS parenttitle, a.id, a.parent, a.owner, a.description, a.allowcomments, at.tag, a.ctime
             FROM {artefact} a
             JOIN {artefact} p ON a.parent = p.id
             JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
             JOIN {artefact_tag} at ON (at.artefact = a.id)
             WHERE a.artefacttype = \'blogpost\'
             AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
             AND at.tag = ?
             ORDER BY a.ctime DESC, a.id DESC
             LIMIT ?';
         $results = get_records_sql_array($sql, array($view, $tagselect, $limit));
         $smarty->assign('blockid', $instance->get('id'));
         $smarty->assign('editing', $editing);
         if ($editing) {
             // Get list of blogs owned by this user to create the "Add new post" shortcut while editing
             $viewowner = $instance->get_view()->get('owner');
             if (!$viewowner || !($blogs = get_records_select_array('artefact', 'artefacttype = \'blog\' AND owner = ?', array($viewowner), 'title ASC', 'id, title'))) {
                 $blogs = array();
             }
             $smarty->assign('tagselect', $tagselect);
             $smarty->assign('blogs', $blogs);
         }
         // if posts are not found with the selected tag, notify the user
         if (!$results) {
             $smarty->assign('badtag', $tagselect);
             return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
         }
         // update the view_artefact table so journal entries are accessible when this is the only block on the page
         // referencing this journal
         $dataobject = array('view' => $view, 'block' => $instance->get('id'));
         foreach ($results as $result) {
             $dataobject["artefact"] = $result->parent;
             ensure_record_exists('view_artefact', $dataobject, $dataobject);
             $result->postedbyon = get_string('postedbyon', 'artefact.blog', display_default_name($result->owner), format_date(strtotime($result->ctime)));
             $result->displaydate = format_date(strtotime($result->ctime));
             // get comment count for this post
             $result->commentcount = count_records_select('artefact_comment_comment', "onartefact = {$result->id} AND private = 0 AND deletedby IS NULL");
             // get all tags for this post
             $taglist = get_records_array('artefact_tag', 'artefact', $result->id, "tag DESC");
             foreach ($taglist as $t) {
                 $result->taglist[] = $t->tag;
             }
         }
         // check if the user viewing the page is the owner of the selected tag
         $owner = $results[0]->owner;
         if ($USER->id != $owner) {
             $viewowner = get_user_for_display($owner);
             $smarty->assign('viewowner', $viewowner);
         }
         $smarty->assign('tag', $tagselect);
     } else {
         // error if block configuration fails
         $smarty->assign('configerror', true);
         return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
     }
     $smarty->assign('full', $full);
     $smarty->assign('results', $results);
     return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
 }
Beispiel #28
0
 public static function override_instance_title(BlockInstance $instance)
 {
     global $USER;
     $ownerid = $instance->get_view()->get('owner');
     if ($ownerid === null || $ownerid == $USER->get('id')) {
         $title = get_string('title', 'blocktype.myfriends');
     } else {
         $title = get_string('otherusertitle', 'blocktype.myfriends', display_name($ownerid, null, true));
     }
     $numberoffriends = count_records_sql('SELECT COUNT(usr1) FROM {usr_friend}
         JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
         JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0)
         WHERE usr1 = ? OR usr2 = ?', array($ownerid, $ownerid));
     if ($numberoffriends > MAXFRIENDDISPLAY) {
         $title .= ' ' . get_string('numberoffriends', 'blocktype.myfriends', MAXFRIENDDISPLAY, $numberoffriends);
     }
     return $title;
 }
Beispiel #29
0
 public static function instance_config_form(BlockInstance $instance)
 {
     global $USER;
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'internal');
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     $otherblockcount = 0;
     $readonly = false;
     $text = '';
     $information = '';
     $literature = $configdata['literature'];
     $view = $instance->get_view();
     if (!empty($configdata['artefactid'])) {
         $artefactid = $configdata['artefactid'];
         try {
             $artefact = $instance->get_artefact_instance($artefactid);
             $readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
             $text = $artefact->get('note');
             $information = $artefact->get('description');
             if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) {
                 $blocks = array_unique($blocks);
                 $otherblockcount = count($blocks) - 1;
             }
         } catch (ArtefactNotFoundException $e) {
             unset($artefactid);
         }
     }
     $otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>';
     $otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg);
     $manageurl = get_config('wwwroot') . 'artefact/internal/notes.php';
     if ($group = $view->get('group')) {
         $manageurl .= '?group=' . $group;
     } else {
         if ($institution = $view->get('institution')) {
             $manageurl .= '?institution=' . $institution;
         }
     }
     // Update the attached files in block configdata as
     // it may change when attached files have been deleted
     $attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false;
     if ($attachmentids !== false && $configdata['artefactids'] != $attachmentids) {
         $configdata['artefactids'] = $attachmentids;
         $instance->set('configdata', $configdata);
         $instance->commit();
     }
     $elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => $otherblocksmsg, 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => get_string('readonlymessage', 'blocktype.internal/textbox'), 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('note', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('note', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'value' => '<div id="instconf_textreadonly_display">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'class' => 'nojs-hidden-block', 'value' => '<a id="chooseartefactlink" href=""></a>'), 'managenotes' => array('type' => 'html', 'class' => 'right hidden', 'value' => '<a href="' . $manageurl . '" target="_blank">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' &raquo;</a>'), 'selecttask' => array('type' => 'select', 'title' => get_string('selecttask', 'view'), 'description' => get_string('selecttaskdescription', 'view'), 'options' => PluginBlocktypeEselmagraduation::get_task(), 'defaultvalue' => $retractable + $retractedonload), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'literature' => array('type' => 'text', 'title' => get_string('literature'), 'defaultvalue' => $literature), 'information' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('information', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $information, 'rules' => array('maxlength' => 65536)), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null));
     return $elements;
 }
 * @subpackage artefact-plans
 * @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(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'plans');
require_once get_config('docroot') . 'blocktype/lib.php';
require_once get_config('docroot') . 'artefact/plans/blocktype/plans/lib.php';
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
if ($blockid = param_integer('block', null)) {
    $bi = new BlockInstance($blockid);
    $options = $configdata = $bi->get('configdata');
    $tasks = ArtefactTypeTask::get_tasks($configdata['artefactid'], $offset, $limit);
    $template = 'artefact:plans:taskrows.tpl';
    $pagination = array('baseurl' => $bi->get_view()->get_url() . '&block=' . $blockid, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'tasktable_' . $blockid, 'jsonscript' => 'artefact/plans/viewtasks.json.php');
} else {
    $planid = param_integer('artefact');
    $viewid = param_integer('view');
    $options = array('viewid' => $viewid);
    $tasks = ArtefactTypeTask::get_tasks($planid, $offset, $limit);
    $template = 'artefact:plans:taskrows.tpl';
    $baseurl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $planid . '&view=' . $options['viewid'];
    $pagination = array('baseurl' => $baseurl, 'id' => 'task_pagination', 'datatable' => 'tasklist', 'jsonscript' => 'artefact/plans/viewtasks.json.php');
}
ArtefactTypeTask::render_tasks($tasks, $template, $options, $pagination);
json_reply(false, (object) array('message' => false, 'data' => $tasks));