Example #1
0
 public static function instance_config_form($instance, $istemplate)
 {
     global $USER;
     safe_require('artefact', 'blog');
     $configdata = $instance->get('configdata');
     if (!empty($configdata['artefactid'])) {
         $blog = $instance->get_artefact_instance($configdata['artefactid']);
     }
     $elements = array();
     // If the blog in this block is owned by the owner of the View, then
     // the block can be configured. Otherwise, the blog was copied in from
     // another View. We won't confuse users by asking them to choose a blog
     // to put in this block, when the one that is currently in it isn't
     // choosable.
     //
     // Note: the owner check will have to change when we do group/site
     // blogs
     if (empty($configdata['artefactid']) || $blog->get('owner') == $USER->get('id')) {
         $elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null, $istemplate);
         if ($istemplate) {
             $elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blog');
         }
     } else {
         $elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="message">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('blog', 'artefact.blog')) . '</div>');
     }
     return $elements;
 }
Example #2
0
 public static function instance_config_form($instance, $istemplate)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null), 'showdescription' => array('type' => 'checkbox', 'title' => get_string('showdescription', 'blocktype.file/image'), 'defaultvalue' => $configdata['showdescription']), 'width' => array('type' => 'text', 'title' => get_string('width', 'blocktype.file/image'), 'size' => 3, 'description' => get_string('widthdescription', 'blocktype.file/image'), 'rules' => array('minvalue' => 16, 'maxvalue' => get_config('imagemaxwidth')), 'defaultvalue' => isset($configdata['width']) ? $configdata['width'] : ''));
 }
Example #3
0
 public static function instance_config_form($instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null));
 }
Example #4
0
 public static function instance_config_form($instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null), 'width' => array('type' => 'text', 'title' => get_string('width'), 'size' => 3, 'defaultvalue' => isset($configdata['width']) ? $configdata['width'] : '', 'rules' => array('minvalue' => 1, 'maxvalue' => 2000)), 'height' => array('type' => 'text', 'title' => get_string('height'), 'size' => 3, 'defaultvalue' => isset($configdata['height']) ? $configdata['height'] : '', 'rules' => array('minvalue' => 1, 'maxvalue' => 2000)));
 }
Example #5
0
 /**
  * Sets the specified site settings.
  * A table with | Setting label | value | is expected.
  *
  * @Given /^the following site settings are set:$/
  * @param TableNode $table
  * @throws SystemException
  */
 public function site_settings_set(TableNode $table)
 {
     $settings = array();
     foreach ($table->getHash() as $sitesetting) {
         $settings[$sitesetting['field']] = $sitesetting['value'];
     }
     // Validate the settings
     $allowsettings = array('sitename', 'lang', 'country', 'theme', 'dropdownmenu', 'homepageinfo', 'userscanchooseviewthemes', 'remoteavatars', 'userscanhiderealnames', 'searchusernames', 'searchuserspublic', 'anonymouscomments', 'loggedinprofileviewaccess', 'staffreports', 'staffstats', 'userscandisabledevicedetection', 'masqueradingreasonrequired', 'masqueradingnotified', 'showprogressbar', 'exporttoqueue', 'defaultmultipleblogs', 'searchplugin', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap', 'showselfsearchsideblock', 'showtagssideblock', 'tagssideblockmaxtags', 'viewmicroheaders', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers', 'licensemetadata', 'licenseallowcustom', 'allowmobileuploads', 'wysiwyg', 'sitefilesaccess', 'watchlistnotification_delay', 'skins');
     // if public views are disabled, sitemap generation must also be disabled.
     if (empty($settings['allowpublicviews'])) {
         $settings['generatesitemap'] = false;
     } else {
         // Ensure allowpublicprofiles is set as well
         $settings['allowpublicprofiles'] = 1;
     }
     // Update site settings
     $oldsearchplugin = get_config('searchplugin');
     $oldlanguage = get_config('lang');
     $oldtheme = get_config('theme');
     foreach ($allowsettings as $setting) {
         if (isset($settings[$setting]) && !set_config($setting, $settings[$setting])) {
             throw new SystemException("Can not set the option \"{$setting}\" to \"{$settings[$setting]}\"");
         }
     }
     if (isset($settings['lang']) && $oldlanguage != $settings['lang']) {
         safe_require('artefact', 'file');
         ArtefactTypeFolder::change_public_folder_name($oldlanguage, $settings['lang']);
     }
 }
Example #6
0
function pieform_element_wysiwyg_get_headdata()
{
    global $_PIEFORM_WYSIWYGS;
    if (is_html_editor_enabled() && !empty($_PIEFORM_WYSIWYGS)) {
        $result = '<script type="application/javascript">' . "\nvar editor_to_focus;" . "\nPieformManager.connect('onsubmit', null, tinyMCE.triggerSave);" . "\nPieformManager.connect('onload', null, function() {\n";
        foreach ($_PIEFORM_WYSIWYGS as $editor) {
            $result .= "    tinyMCE.execCommand('mceAddEditor', false, '{$editor}');\n";
            $result .= "    \$('{$editor}').focus = function() {\n";
            $result .= "        editor_to_focus = '{$editor}';\n";
            $result .= "    };\n";
        }
        $result .= "});\nPieformManager.connect('onreply', null, function() {\n";
        foreach ($_PIEFORM_WYSIWYGS as $editor) {
            $result .= "    tinyMCE.execCommand('mceRemoveEditor', false, '{$editor}');\n";
        }
        $result .= "});</script>";
        safe_require('artefact', 'file');
        $strings = PluginArtefactFile::jsstrings('filebrowser');
        $jsstrings = '';
        foreach ($strings as $section => $sectionstrings) {
            foreach ($sectionstrings as $s) {
                $jsstrings .= "strings.{$s}=" . json_encode(get_raw_string($s, $section)) . ';';
            }
        }
        $headdata = '<script type="application/javascript">' . $jsstrings . '</script>';
        return array('tinymce', $result, $headdata);
    }
    return array();
}
Example #7
0
function siteoptions_submit(Pieform $form, $values)
{
    $fields = array('sitename', 'lang', 'theme', 'pathtoclam', 'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn', 'allowpublicviews', 'allowpublicprofiles', 'createpublicgroups', 'searchplugin', 'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend');
    $oldlanguage = get_config('lang');
    $oldtheme = get_config('theme');
    foreach ($fields as $field) {
        if (!set_config($field, $values[$field])) {
            siteoptions_fail($form, $field);
        }
    }
    if ($oldlanguage != $values['lang']) {
        safe_require('artefact', 'file');
        ArtefactTypeFolder::change_public_folder_name($oldlanguage, $values['lang']);
    }
    // submitted sessionlifetime is in minutes; db entry session_timeout is in seconds
    if (!set_config('session_timeout', $values['sessionlifetime'] * 60)) {
        siteoptions_fail($form, 'sessionlifetime');
    }
    // Submitted value is on/off; database entry should be 1/0
    foreach (array('viruschecking', 'usersallowedmultipleinstitutions') as $checkbox) {
        if (!set_config($checkbox, (int) ($values[$checkbox] == 'on'))) {
            siteoptions_fail($form, $checkbox);
        }
    }
    $message = get_string('siteoptionsset', 'admin');
    if ($oldtheme != $values['theme']) {
        $message .= '  ' . get_string('usersseenewthemeonlogin', 'admin');
    }
    $form->reply(PIEFORM_OK, array('message' => $message, 'goto' => '/admin/site/options.php'));
}
 public static function instance_config_form($instance)
 {
     safe_require('artefact', 'blog');
     $configdata = $instance->get('configdata');
     $elements = array(self::artefactchooser_element(isset($configdata['artefactids']) ? $configdata['artefactids'] : null), 'count' => array('type' => 'text', 'title' => get_string('itemstoshow', 'blocktype.blog/recentposts'), 'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 10, 'size' => 3));
     return $elements;
 }
Example #9
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('Files', 'blocktype.file/filedownload'), 'class' => 'last with-formgroup', 'elements' => array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null))));
 }
Example #10
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('file', 'artefact.file'), 'class' => 'last select-file mtl', 'elements' => array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null))));
 }
Example #11
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();
     $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;
     }
     $tasks = ArtefactTypeTask::get_alltasks($blockid, $offset, $limit);
     $template = 'artefact:plans:alltaskrows.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' => '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('tasks', $tasks);
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:alltasks:content.tpl');
 }
Example #12
0
 public static function instance_config_form($instance)
 {
     safe_require('artefact', 'blog');
     $configdata = $instance->get('configdata');
     $elements = array(self::artefactchooser_element(isset($configdata['artefactids']) ? $configdata['artefactids'] : null), 'count' => array('type' => 'text', 'title' => get_string('itemstoshow', 'blocktype.blog/recentposts'), 'description' => get_string('betweenxandy', 'mahara', 1, 100), 'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 10, 'size' => 3, 'rules' => array('integer' => true, 'minvalue' => 1, 'maxvalue' => 100)));
     return $elements;
 }
Example #13
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     $filebrowser = self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null);
     return array('artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('image'), 'class' => 'last select-file mtl', 'elements' => array('artefactid' => $filebrowser)), 'showdescription' => array('type' => 'switchbox', 'title' => get_string('showdescription', 'blocktype.file/image'), 'defaultvalue' => !empty($configdata['showdescription']) ? true : false), 'width' => array('type' => 'text', 'title' => get_string('width', 'blocktype.file/image'), 'size' => 3, 'description' => get_string('widthdescription1', 'blocktype.file/image'), 'rules' => array('minvalue' => 16, 'maxvalue' => get_config('imagemaxwidth')), 'defaultvalue' => isset($configdata['width']) ? $configdata['width'] : ''));
 }
Example #14
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $text = isset($configdata['text']) ? $configdata['text'] : '';
     safe_require('artefact', 'file');
     $text = ArtefactTypeFolder::append_view_url($text, $instance->get('view'));
     return clean_html($text);
 }
Example #15
0
 public static function instance_config_form($instance)
 {
     global $USER;
     safe_require('artefact', 'survey');
     $configdata = $instance->get('configdata');
     log_debug($configdata);
     $options = getoptions_available_surveys();
     return array('userid' => array('type' => 'hidden', 'value' => $USER->get('id')), 'survey' => array('type' => $options ? 'select' : 'html', 'labelhtml' => get_string('surveytitle', 'artefact.survey'), 'defaultvalue' => isset($configdata['survey']) ? $configdata['survey'] : null, 'value' => $options ? null : '<div id="artefactchooser-body"><p class="noartefacts">' . get_string('noartefactstochoosefrom', 'view') . '</p></div>', 'options' => $options), 'steps' => array('type' => 'select', 'labelhtml' => get_string('surveyhistorysteps', 'blocktype.survey/surveyhistory'), 'defaultvalue' => isset($configdata['steps']) ? $configdata['steps'] : 5, 'options' => array(2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9)), 'showchart' => array('type' => 'checkbox', 'title' => get_string('showchart', 'blocktype.survey/surveyhistory'), 'defaultvalue' => isset($configdata['showchart']) ? $configdata['showchart'] : true), 'chartoptions' => array('type' => 'fieldset', 'legend' => get_string('chartoptions', 'artefact.survey'), 'collapsible' => true, 'collapsed' => true, 'elements' => ArtefactTypeSurvey::get_chart_options_elements($configdata)));
 }
Example #16
0
 public static function class_from_format($format)
 {
     $format = trim($format);
     if ($format == 'files') {
         $format = 'file';
     }
     safe_require('import', $format);
     return generate_class_name('import', $format);
 }
/**
 * Dwoo {survey_name} function plugin
 *
 * Type:     function<br>
 * Name:     survey_title<br>
 * Date:     June 22, 2006<br>
 * Purpose:  Get the survey title from XML
 * @author   Gregor Anzelj
 * @version  1.0
 * @return Survey title instead of survey filename
 */
function Dwoo_Plugin_survey_title(Dwoo $dwoo, $survey, $lang = null)
{
    safe_require('artefact', 'survey');
    $return = ArtefactTypeSurvey::get_survey_title_from_xml($survey);
    if ($lang != null) {
        $return .= ' (' . substr($lang, 0, 2) . ')';
    }
    return $return;
}
Example #18
0
 public static function instance_config_form($instance, $istemplate)
 {
     if ($istemplate) {
         // No configuration when this block is in a template
         return array();
     }
     safe_require('artefact', 'blog');
     $configdata = $instance->get('configdata');
     return array(self::artefactchooser_element(isset($configdata['artefactids']) ? $configdata['artefactids'] : null, $istemplate), PluginArtefactBlog::block_advanced_options_element($configdata, 'blog'));
 }
Example #19
0
 public static function get_link(BlockInstance $instance)
 {
     safe_require('module', 'multirecipientnotification');
     if (PluginModuleMultirecipientnotification::is_active()) {
         $data = get_config('wwwroot') . 'module/multirecipientnotification/inbox.php';
     } else {
         $data = get_config('wwwroot') . 'account/activity/index.php';
     }
     return sanitize_url($data);
 }
Example #20
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER, $THEME;
     $configdata = $instance->get('configdata');
     $desiredtypes = array();
     foreach ($configdata as $k => $v) {
         if (!empty($v) && $k != 'maxitems') {
             $type = preg_replace('/[^a-z]+/', '', $k);
             $desiredtypes[$type] = $type;
         }
     }
     if ($USER->get('admin') && !empty($desiredtypes['adminmessages'])) {
         unset($desiredtypes['adminmessages']);
         $desiredtypes += get_column('activity_type', 'name', 'admin', 1);
     }
     $maxitems = isset($configdata['maxitems']) ? $configdata['maxitems'] : 5;
     // check if multirecipientnotification plugin is active or if we proceed here
     if (record_exists('artefact_installed', 'name', 'multirecipientnotification', 'active', '1') && safe_require_plugin('artefact', 'multirecipientnotification')) {
         global $USER;
         $userid = $USER->get('id');
         safe_require('artefact', 'multirecipientnotification');
         $activitylist = activityblocklistin(join(',', $desiredtypes), $maxitems);
         $records = $activitylist->records;
         $showmore = $activitylist->count > $maxitems;
         // use a different template
         $smartytemplate = 'blocktype:inbox:inboxmr.tpl';
     } else {
         $records = array();
         if ($desiredtypes) {
             $sql = "\n                    SELECT n.id, n.subject, n.message, n.url, n.urltext, n.read, t.name AS type\n                    FROM {notification_internal_activity} n JOIN {activity_type} t ON n.type = t.id\n                    WHERE n.usr = ?\n                    AND t.name IN (" . join(',', array_map('db_quote', $desiredtypes)) . ")\n                    ORDER BY n.ctime DESC\n                    LIMIT ?;";
             $records = get_records_sql_array($sql, array($USER->get('id'), $maxitems + 1));
         }
         // Hack to decide whether to show the More... link
         if ($showmore = count($records) > $maxitems) {
             unset($records[$maxitems]);
         }
         $smartytemplate = 'blocktype:inbox:inbox.tpl';
     }
     if ($records) {
         require_once 'activity.php';
         foreach ($records as &$r) {
             $section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}";
             $r->strtype = get_string('type' . $r->type, $section);
             $r->message = format_notification_whitespace($r->message, $r->type);
         }
     }
     $smarty = smarty_core();
     if ($showmore) {
         $smarty->assign('desiredtypes', implode(',', $desiredtypes));
     }
     $smarty->assign('blockid', 'blockinstance_' . $instance->get('id'));
     $smarty->assign('items', $records);
     $smarty->assign('readicon', $THEME->get_url('images/readusermessage.png'));
     return $smarty->fetch($smartytemplate);
 }
Example #21
0
 public static function instance_config_form($instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     $elements = array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null), 'sortorder' => array('type' => 'select', 'labelhtml' => get_string('sortorder'), 'defaultvalue' => isset($configdata['sortorder']) ? $configdata['sortorder'] : get_config_plugin('blocktype', 'folder', 'sortorder'), 'options' => array('asc' => get_string('ascending'), 'desc' => get_string('descending'))));
     if (get_config_plugin('blocktype', 'folder', 'folderdownloadzip')) {
         $elements['folderdownloadzip'] = array('type' => 'checkbox', 'labelhtml' => get_string('downloadfolderzipblock', 'artefact.file'), 'description' => get_string('downloadfolderzipdescriptionblock', 'artefact.file'), 'defaultvalue' => get_config_plugin('blocktype', 'folder', 'folderdownloadzip') ? isset($configdata['folderdownloadzip']) ? $configdata['folderdownloadzip'] : 0 : 0);
     }
     return $elements;
 }
Example #22
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $CFG;
     safe_require('artefact', 'courses');
     $configdata = $instance->get('configdata');
     $list_size = isset($configdata['maxcourses']) ? $configdata['maxcourses'] : 8;
     $smarty = smarty_core();
     $smarty->assign('list_size', $list_size);
     $smarty->assign('view', $instance->get('view'));
     return $smarty->fetch('blocktype:mycourses:mycourses.tpl');
 }
Example #23
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $userid = $instance->get_view()->get('owner');
     if (!$userid) {
         return '';
     }
     $smarty = smarty_core();
     // Get viewable views
     $views = array();
     if ($allviews = get_records_select_array('view', "\"owner\" = ? AND type NOT IN ('profile', 'dashboard')", array($userid))) {
         foreach ($allviews as $view) {
             if (can_view_view($view->id)) {
                 $views[$view->id] = $view;
                 $view->artefacts = array();
             }
         }
     }
     if ($views) {
         $viewidlist = implode(', ', array_map(create_function('$a', 'return (int)$a->id;'), $views));
         $artefacts = get_records_sql_array('SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
             FROM {view_artefact} va
             INNER JOIN {artefact} a ON va.artefact = a.id
             INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
             WHERE va.view IN (' . $viewidlist . ')
             GROUP BY 1, 2, 3, 4, 5
             ORDER BY a.title, va.artefact', '');
         if ($artefacts) {
             foreach ($artefacts as $artefactrec) {
                 safe_require('artefact', $artefactrec->plugin);
                 // Perhaps I shouldn't have to construct the entire
                 // artefact object to render the name properly.
                 $classname = generate_artefact_class_name($artefactrec->artefacttype);
                 $artefactobj = new $classname(0, array('title' => $artefactrec->title));
                 $artefactobj->set('dirty', false);
                 if (!$artefactobj->in_view_list()) {
                     continue;
                 }
                 $artname = $artefactobj->display_title(30);
                 if (strlen($artname)) {
                     $views[$artefactrec->view]->artefacts[] = array('id' => $artefactrec->artefact, 'title' => $artname);
                 }
             }
         }
         $tags = get_records_select_array('view_tag', 'view IN (' . $viewidlist . ')');
         if ($tags) {
             foreach ($tags as &$tag) {
                 $views[$tag->view]->tags[] = $tag->tag;
             }
         }
     }
     $smarty->assign('VIEWS', $views);
     return $smarty->fetch('blocktype:myviews:myviews.tpl');
 }
Example #24
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     safe_require('artefact', 'file');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (array_key_exists('text', $configdata)) {
         $newtext = ArtefactTypeFolder::append_view_url($configdata['text'], $instance->get('view'));
         $smarty->assign('text', $newtext);
     } else {
         $smarty->assign('text', '');
     }
     return $smarty->fetch('blocktype:text:content.tpl');
 }
Example #25
0
 /**
  * Return generator for given plugin.
  * @param string $plugintype the plugin type, e.g. 'artefact' or 'blocktype'.
  * @param string $pluginname the plugin name, e.g. 'blog' or 'file'.
  * @return an instance of a plugin generator extending from CoreGenerator.
  */
 public function get_plugin_generator($plugintype, $pluginname)
 {
     $pluginfullname = "{$plugintype}.{$pluginname}";
     if (isset($this->generators[$pluginfullname])) {
         return $this->generators[$pluginfullname];
     }
     safe_require($plugintype, $pluginname, 'tests/generator/lib.php');
     $classname = generate_generator_class_name($plugintype, $pluginname);
     if (!class_exists($classname)) {
         throw new UndefinedException("The plugin {$pluginfullname} does not support " . "data generators yet. Class {$classname} not found.");
     }
     $this->generators[$pluginfullname] = new $classname($this);
     return $this->generators[$pluginfullname];
 }
Example #26
0
File: lib.php Project: kienv/mahara
 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;
 }
Example #27
0
function questionnaire_submit(Pieform $form, $values)
{
    safe_require('notification', 'internal');
    global $SESSION, $USER, $survey;
    $id = $values['id'];
    $show_results = $values['show_results'];
    // Keep user responses only!
    // Strip out: section_type, show_results, sesskey, submit and fs (if exists)
    $responses = array();
    foreach ($values as $key => $value) {
        if (!in_array($key, array('section_type', 'show_results', 'fs', 'sesskey', 'submit'))) {
            $responses = array_merge($responses, array($key => $value));
        }
    }
    try {
        $survey->set('description', serialize($responses));
        $survey->set('mtime', time());
        $survey->commit();
        $ownername = $USER->get('firstname') . ' ' . $USER->get('lastname') . ' (' . $USER->get('username') . ')';
        // Get users who are recipients - can get the results of user's survey
        $recipients = get_column('artefact_access_usr', 'usr', 'artefact', $id);
        // Get correct activity type
        $type = get_field('activity_type', 'id', 'name', 'feedback', 'plugintype', 'artefact', 'pluginname', 'survey');
        if (!empty($recipients)) {
            foreach ($recipients as $recipient) {
                $user = new StdClass();
                $user->id = $recipient;
                $data = new StdClass();
                $data->type = $type;
                $data->parent = null;
                $data->message = get_string('surveyaccessmessage', 'artefact.survey', $ownername);
                $data->subject = get_string('surveyaccesssubject', 'artefact.survey', $ownername);
                $data->url = get_config('wwwroot') . 'artefact/survey/results.php?id=' . $id;
                $data->urltext = get_string('surveyaccessurltext', 'artefact.survey');
                $data->fromuser = $USER->get('id');
                PluginNotificationInternal::notify_user($user, $data);
            }
        }
    } catch (Exception $e) {
        $SESSION->add_error_msg(get_string('surveysavefailed', 'artefact.survey'), false);
    }
    $SESSION->add_ok_msg(get_string('surveysaved', 'artefact.survey'));
    if ($show_results) {
        redirect('/artefact/survey/results.php?id=' . $survey->get('id'));
    } else {
        redirect('/artefact/survey/');
    }
}
Example #28
0
function import_submit(Pieform $form, $values)
{
    global $SESSION;
    $date = time();
    $nicedate = date('Y/m/d h:i:s', $date);
    $uploaddir = get_config('dataroot') . 'import/test-' . $date . '/';
    $filename = $uploaddir . $values['file']['name'];
    check_dir_exists($uploaddir);
    move_uploaded_file($values['file']['tmp_name'], $filename);
    if ($values['file']['type'] == 'application/zip') {
        // Unzip here
        $command = sprintf('%s %s %s %s', escapeshellcmd(get_config('pathtounzip')), escapeshellarg($filename), get_config('unzipdirarg'), escapeshellarg($uploaddir));
        $output = array();
        exec($command, $output, $returnvar);
        if ($returnvar != 0) {
            $SESSION->add_error_msg('Unable to unzip the file');
            redirect('/import/');
        }
        $filename = $uploaddir . 'leap2a.xml';
        if (!is_file($filename)) {
            $SESSION->add_error_msg('No leap2a.xml file detected - please check your export file again');
            redirect('/import/');
        }
    }
    // Create dummy user
    $user = (object) array('username' => 'import_' . $date, 'password' => 'import1', 'firstname' => 'Imported', 'lastname' => 'User (' . $nicedate . ')', 'email' => '*****@*****.**');
    $userid = create_user($user);
    // And we're good to go
    echo '<pre>';
    $filename = substr($filename, strlen(get_config('dataroot')));
    require_once dirname(dirname(__FILE__)) . '/import/lib.php';
    safe_require('import', 'leap');
    db_begin();
    $importer = PluginImport::create_importer(null, (object) array('token' => '', 'usr' => $userid, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'data' => array('filename' => $filename), 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_STDOUT, 'profile' => true));
    $importer->process();
    // Now done, delete the temporary e-mail address if there's a new one
    // A bit sucky, presumes only one email in the import
    $email = artefact_instance_from_id(get_field('artefact', 'id', 'title', '*****@*****.**', 'artefacttype', 'email', 'owner', $userid));
    $email->delete();
    execute_sql('UPDATE {artefact_internal_profile_email} SET principal = 1 WHERE "owner" = ?', array($userid));
    db_commit();
    echo "\n\n";
    echo 'Done. You can <a href="' . get_config('wwwroot') . '/admin/users/changeuser.php?id=' . $userid . '">change to this user</a> to inspect the result, ';
    echo 'or <a href="' . get_config('wwwroot') . 'import/">try importing again</a>';
    echo '</pre>';
    exit;
}
Example #29
0
 /**
  * Implement user searching with SQL
  *
  * NOTE: user with ID zero should never be returned
  *
  * @param string  The query string
  * @param integer How many results to return
  * @param integer What result to start at (0 == first result)
  * @param data    Filters the users searched by
  *                can contain:
  *             'group' => integer, // only users in this group
  *             'owner' => boolean  // include the group ownwer (only if group is set)
  *             'exclude'=> int     // excludes a user
  * @return array  A data structure containing results looking like ...
  *         $results = array(
  *               count   => integer, // total number of results
  *               limit   => integer, // how many results are returned
  *               offset  => integer, // starting from which result
  *               data    => array(   // the result records
  *                   array(
  *                       id            => integer,
  *                       username      => string,
  *                       institution   => string,
  *                       firstname     => string,
  *                       lastname      => string,
  *                       preferredname => string,
  *                       email         => string,
  *                   ),
  *                   array(
  *                       id            => integer,
  *                       username      => string,
  *                       institution   => string,
  *                       firstname     => string,
  *                       lastname      => string,
  *                       preferredname => string,
  *                       email         => string,
  *                   ),
  *                   array(...),
  *               ),
  *           );
  */
 public static function search_user($query_string, $limit, $offset = 0, $data = array())
 {
     safe_require('artefact', 'internal');
     $publicfields = array_keys(ArtefactTypeProfile::get_public_fields());
     if (empty($publicfields)) {
         $publicfields = array('preferredname');
     }
     if (is_postgres()) {
         return self::search_user_pg($query_string, $limit, $offset, $data, $publicfields);
     } else {
         if (is_mysql()) {
             return self::search_user_my($query_string, $limit, $offset, $data, $publicfields);
         } else {
             throw new SQLException('search_user() is not implemented for your database engine (' . get_config('dbtype') . ')');
         }
     }
 }
    /**
     *
     * @param HttpResource $asset 
     */
    public function render($asset)
    {
        $url = $asset->url();
        $group_id = self::get_group_id($url);
        if (empty($group_id))
        {
            return false;
        }

        $data = get_record('group', 'id', $group_id);

        $result = array();
        safe_require('blocktype', 'ple/group');
        $result[self::EMBED_SNIPPET] = PluginBlocktypeGroup::render_preview($group_id);
        $result[self::THUMBNAIL] = PluginBlocktypeGroup::get_thumbnail($group_id);
        $result[self::TITLE] = $data->name;
        $result[self::DESCRIPTION] = $data->description;

        return $result;
    }