Beispiel #1
0
                    $linepref = 'none';
                }
                $preferences['message_provider_' . $provider->component . '_' . $provider->name . '_' . $state] = $linepref;
            }
        }
    }
    /// Set all the processor options as well
    $processors = get_message_processors(true);
    foreach ($processors as $processor) {
        $processor->object->process_form($form, $preferences);
    }
    //process general messaging preferences
    $preferences['message_blocknoncontacts'] = !empty($form->blocknoncontacts) ? 1 : 0;
    $preferences['message_beepnewmessage'] = !empty($form->beepnewmessage) ? 1 : 0;
    // Save all the new preferences to the database
    if (!set_user_preferences($preferences, $user->id)) {
        print_error('cannotupdateusermsgpref');
    }
    if (isset($form->mailformat)) {
        $user->mailformat = clean_param($form->mailformat, PARAM_INT);
    }
    user_update_user($user, false, false);
    $redirect = new moodle_url("/user/preferences.php", array('userid' => $userid));
    redirect($redirect);
}
/// Load preferences
$preferences = new stdClass();
$preferences->userdefaultemail = $user->email;
//may be displayed by the email processor
/// Get providers preferences
foreach ($providers as $provider) {
/**
 * Set default message preferences.
 * @param $user - User to set message preferences
 */
function tm_message_set_default_message_preferences($user) {
    global $DB;

    $defaultonlineprocessor = 'email';
    $defaultofflineprocessor = 'email';
    $offlineprocessortouse = $onlineprocessortouse = null;

    //look for the pre-2.0 preference if it exists
    $oldpreference = get_user_preferences('message_showmessagewindow', -1, $user->id);
    //if they elected to see popups or the preference didnt exist
    $usepopups = (intval($oldpreference)==1 || intval($oldpreference)==-1);

    if ($usepopups) {
        $defaultonlineprocessor = 'popup';
    }

    $providers = $DB->get_records('message_providers');
    $preferences = array();
    if (!$providers) {
        $providers = array();
    }

    foreach ($providers as $providerid => $provider) {

        //force some specific defaults for some types of message
        if ($provider->name == 'instantmessage') {
            //if old popup preference was set to 1 or is missing use popups for IMs
            if ($usepopups) {
                $onlineprocessortouse = 'popup';
                $offlineprocessortouse = 'email,popup';
            }
        }
        else if ($provider->name == 'posts') {
            //forum posts
            $offlineprocessortouse = $onlineprocessortouse = 'email';
        }
        else if ($provider->name == 'alert') {
            // alert
            $offlineprocessortouse = $onlineprocessortouse = 'alert,email';
        }
        else if ($provider->name == 'task') {
            // task
            $offlineprocessortouse = $onlineprocessortouse = 'task,email';
        }
        else {
            $onlineprocessortouse = $defaultonlineprocessor;
            $offlineprocessortouse = $defaultofflineprocessor;
        }

        $preferences['message_provider_'.$provider->component.'_'.$provider->name.'_loggedin'] = $onlineprocessortouse;
        $preferences['message_provider_'.$provider->component.'_'.$provider->name.'_loggedoff'] = $offlineprocessortouse;
    }

    return set_user_preferences($preferences, $user->id);
}
 /**
  * Gets the content for this block by grabbing it from $this->page
  *
  * @return object $this->content
  */
 function get_content()
 {
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return $this->content;
     }
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     // Navcount is used to allow us to have multiple trees although I dont' know why
     // you would want two trees the same
     block_navigation::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_globalnav' . block_navigation::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_globalnav' . block_navigation::$navcount);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_globalnav' . block_navigation::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $trimmode = self::TRIM_LEFT;
     $trimlength = 50;
     if (!empty($this->config->trimmode)) {
         $trimmode = (int) $this->config->trimmode;
     }
     if (!empty($this->config->trimlength)) {
         $trimlength = (int) $this->config->trimlength;
     }
     // Get the navigation object or don't display the block if none provided.
     if (!($navigation = $this->get_navigation())) {
         return null;
     }
     $expansionlimit = null;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
         $navigation->set_expansion_limit($this->config->expansionlimit);
     }
     $this->trim($navigation, $trimmode, $trimlength, ceil($trimlength / 2));
     // Get the expandable items so we can pass them to JS
     $expandable = array();
     $navigation->find_expandable($expandable);
     if ($expansionlimit) {
         foreach ($expandable as $key => $node) {
             if ($node['type'] > $expansionlimit && !($expansionlimit == navigation_node::TYPE_COURSE && $node['type'] == $expansionlimit && $node['branchid'] == SITEID)) {
                 unset($expandable[$key]);
             }
         }
     }
     $this->page->requires->data_for_js('navtreeexpansions' . $this->instance->id, $expandable);
     $options = array();
     $options['linkcategories'] = !empty($this->config->linkcategories) && $this->config->linkcategories == 'yes';
     // Grab the items to display
     $renderer = $this->page->get_renderer($this->blockname);
     $this->content = new stdClass();
     $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);
     // Set content generated to true so that we know it has been done
     $this->contentgenerated = true;
     global $PAGE, $CFG;
     //sujets link
     if (has_capability('moodle/course:create', $PAGE->context)) {
         $this->content->text .= '<ul class="block_tree list><li class=" type_setting="" depth_1="" item_with_icon"="">';
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/local/template_course/index.php">';
         $this->content->text .= '<img alt="" class="smallicon navicon" title="" src="' . $CFG->wwwroot . '/theme/image.php/formfactor/core/1404983571/i/navigationitem"/>';
         $this->content->text .= 'Matières</a></li></ul>';
     }
     return $this->content;
 }
Beispiel #4
0
/**
 * Set default message preferences.
 * @param $user - User to set message preferences
 */
function message_set_default_message_preferences($user) {
    global $DB;

    //check for the pre 2.0 disable email setting
    $useemail = empty($user->emailstop);

    //look for the pre-2.0 preference if it exists
    $oldpreference = get_user_preferences('message_showmessagewindow', -1, $user->id);
    //if they elected to see popups or the preference didnt exist
    $usepopups = (intval($oldpreference)==1 || intval($oldpreference)==-1);

    $defaultonlineprocessor = 'none';
    $defaultofflineprocessor = 'none';
    
    if ($useemail) {
        $defaultonlineprocessor = 'email';
        $defaultofflineprocessor = 'email';
    } else if ($usepopups) {
        $defaultonlineprocessor = 'popup';
        $defaultofflineprocessor = 'popup';
    }

    $offlineprocessortouse = $onlineprocessortouse = null;

    $providers = $DB->get_records('message_providers');
    $preferences = array();

    foreach ($providers as $providerid => $provider) {

        //force some specific defaults for IMs
        if ($provider->name=='instantmessage' && $usepopups && $useemail) {
            $onlineprocessortouse = 'popup';
            $offlineprocessortouse = 'email,popup';
        } else {
            $onlineprocessortouse = $defaultonlineprocessor;
            $offlineprocessortouse = $defaultofflineprocessor;
        }
        
        $preferences['message_provider_'.$provider->component.'_'.$provider->name.'_loggedin'] = $onlineprocessortouse;
        $preferences['message_provider_'.$provider->component.'_'.$provider->name.'_loggedoff'] = $offlineprocessortouse;
    }
    return set_user_preferences($preferences, $user->id);
}
Beispiel #5
0
function message_print_settings()
{
    global $USER;
    if ($frm = data_submitted()) {
        $pref = array();
        $pref['message_showmessagewindow'] = isset($frm->showmessagewindow) ? '1' : '0';
        $pref['message_beepnewmessage'] = isset($frm->beepnewmessage) ? '1' : '0';
        $pref['message_blocknoncontacts'] = isset($frm->blocknoncontacts) ? '1' : '0';
        $pref['message_usehtmleditor'] = isset($frm->usehtmleditor) ? '1' : '0';
        $pref['message_noframesjs'] = isset($frm->noframesjs) ? '1' : '0';
        $pref['message_emailmessages'] = isset($frm->emailmessages) ? '1' : '0';
        $pref['message_emailtimenosee'] = (int) $frm->emailtimenosee > 0 ? (int) $frm->emailtimenosee : '10';
        $pref['message_emailaddress'] = !empty($frm->emailaddress) ? $frm->emailaddress : $USER->email;
        $pref['message_emailformat'] = isset($frm->emailformat) ? $frm->emailformat : FORMAT_PLAIN;
        set_user_preferences($pref);
        redirect('index.php', get_string('settingssaved', 'message'), 1);
    }
    $cbshowmessagewindow = get_user_preferences('message_showmessagewindow', 1) == '1' ? 'checked="checked"' : '';
    $cbbeepnewmessage = get_user_preferences('message_beepnewmessage', 0) == '1' ? 'checked="checked"' : '';
    $cbblocknoncontacts = get_user_preferences('message_blocknoncontacts', 0) == '1' ? 'checked="checked"' : '';
    $cbusehtmleditor = get_user_preferences('message_usehtmleditor', 0) == '1' ? 'checked="checked"' : '';
    $cbnoframesjs = get_user_preferences('message_noframesjs', 0) == '1' ? 'checked="checked"' : '';
    $cbemailmessages = get_user_preferences('message_emailmessages', 1) == '1' ? 'checked="checked"' : '';
    $txemailaddress = get_user_preferences('message_emailaddress', $USER->email);
    $txemailtimenosee = get_user_preferences('message_emailtimenosee', 10);
    $format_select = choose_from_menu(array(FORMAT_PLAIN => get_string('formatplain'), FORMAT_HTML => get_string('formathtml')), 'emailformat', get_user_preferences('message_emailformat', FORMAT_PLAIN), false, '', '0', true);
    include 'settings.html';
}
Beispiel #6
0
/**
 * Sets user preferences, in temporary or presistent storage
 *
 * @param  array    $preferences  Preference mapping to save
 * @param  boolean  $temporary    If true, save in temporary storage, otherwise save in persistent storage
 */
function php_report_filtering_set_user_preferences($preferences, $temporary, $report_name)
{
    global $SESSION, $_SESSION;
    // Ugly form dependency check and preference modification code
    // Note: this can be removed once MDL-27045 is resolved and 'checkbox' in local/eliscore/lib/filtering/date.php can be changed to 'advcheckbox'
    //       (or until someone can implement a cleaner way to handle this)
    //see if the current report is cached
    if (isset($_SESSION['SESSION']->php_reports[$report_name])) {
        $report_container = $_SESSION['SESSION']->php_reports[$report_name];
        //obtain the filter's main form;
        if (isset($report_container->inner_report->filter->_addform)) {
            $filter_form = $report_container->inner_report->filter->_addform;
        }
    }
    // End ugly form dependency check and preference modification
    if (!$temporary) {
        //standard API call for persistent storage
        set_user_preferences($preferences);
        return;
    }
    //temporary storage
    if (!isset($SESSION->php_report_default_params)) {
        //make sure storage is set up
        $SESSION->php_report_default_params = array();
    }
    if (!empty($preferences)) {
        // Old session data from a given report needs to be removed
        $params = $SESSION->php_report_default_params;
        $prefix = 'php_report_' . $report_name . '/';
        foreach ($params as $key => $val) {
            if (strpos($key, $prefix) === 0) {
                $field_name = substr($key, strlen($prefix));
                unset($SESSION->php_report_default_params[$key]);
            }
        }
        // Add the new data from a given report to the session
        foreach ($preferences as $key => $value) {
            $SESSION->php_report_default_params[$key] = $value;
        }
    }
}
Beispiel #7
0
 /**
  * Gets the content for this block by grabbing it from $this->page
  */
 function get_content()
 {
     global $CFG, $OUTPUT;
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return true;
     }
     $this->page->requires->yui2_lib('dom');
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     block_settings::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_settingsnav' . block_settings::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_settingsnav' . block_settings::$navcount, 0);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_settingsnav' . block_settings::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $renderer = $this->page->get_renderer('block_settings');
     $this->content->text = $renderer->settings_tree($this->page->settingsnav);
     // only do search if you have moodle/site:config
     if (!empty($this->content->text)) {
         if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
             $this->content->footer = $renderer->search_form(new moodle_url("{$CFG->wwwroot}/{$CFG->admin}/search.php"), optional_param('query', '', PARAM_RAW));
         } else {
             $this->content->footer = '';
         }
         if (!empty($this->config->enabledock) && $this->config->enabledock == 'yes') {
             user_preference_allow_ajax_update('nav_in_tab_panel_settingsnav' . block_settings::$navcount, PARAM_INT);
         }
     }
     $this->contentgenerated = true;
     return true;
 }
Beispiel #8
0
function message_print_settings()
{
    global $USER, $OUTPUT, $PAGE;
    if ($frm = data_submitted() and confirm_sesskey()) {
        $pref = array();
        $pref['message_beepnewmessage'] = isset($frm->beepnewmessage) ? '1' : '0';
        $pref['message_blocknoncontacts'] = isset($frm->blocknoncontacts) ? '1' : '0';
        set_user_preferences($pref);
        redirect(message_remove_url_params($PAGE->url), get_string('settingssaved', 'message'), 1);
    }
    $cbbeepnewmessage = get_user_preferences('message_beepnewmessage', 0) == '1' ? 'checked="checked"' : '';
    $cbblocknoncontacts = get_user_preferences('message_blocknoncontacts', 0) == '1' ? 'checked="checked"' : '';
    include 'settings.html';
}
Beispiel #9
0
 /**
  * Processes a message processor config form.
  *
  * @param  int $userid the user id
  * @param  string $name the name of the processor
  * @param  array $formvalues the form values
  * @return external_description
  * @throws moodle_exception
  * @since 3.2
  */
 public static function message_processor_config_form($userid, $name, $formvalues)
 {
     global $USER, $CFG;
     // Check if messaging is enabled.
     if (empty($CFG->messaging)) {
         throw new moodle_exception('disabled', 'message');
     }
     $params = self::validate_parameters(self::message_processor_config_form_parameters(), array('userid' => $userid, 'name' => $name, 'formvalues' => $formvalues));
     if (empty($params['userid'])) {
         $params['userid'] = $USER->id;
     }
     $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
     core_user::require_active_user($user);
     $processor = get_message_processor($name);
     $preferences = [];
     $form = new stdClass();
     foreach ($formvalues as $formvalue) {
         // Curly braces to ensure interpretation is consistent between
         // php 5 and php 7.
         $form->{$formvalue['name']} = $formvalue['value'];
     }
     $processor->process_form($form, $preferences);
     if (!empty($preferences)) {
         set_user_preferences($preferences, $userid);
     }
 }
Beispiel #10
0
/**
 * Set secondary fields (i.e. fields derived from the form fields)
 * for this HotPot acitivity
 *
 * @param stdclass $data (passed by reference)
 * @param moodle_form $mform
 */
function hotpot_process_formdata(stdclass &$data, $mform)
{
    global $CFG;
    require_once $CFG->dirroot . '/mod/hotpot/locallib.php';
    if ($mform->is_add()) {
        $data->timecreated = time();
    } else {
        $data->timemodified = time();
    }
    // get context for this HotPot instance
    $context = hotpot_get_context(CONTEXT_MODULE, $data->coursemodule);
    $sourcefile = null;
    $data->sourcefile = '';
    $data->sourcetype = '';
    if ($data->sourceitemid) {
        $options = hotpot::sourcefile_options();
        file_save_draft_area_files($data->sourceitemid, $context->id, 'mod_hotpot', 'sourcefile', 0, $options);
        $fs = get_file_storage();
        $files = $fs->get_area_files($context->id, 'mod_hotpot', 'sourcefile');
        // do we need to remove the draft files ?
        // otherwise the "files" table seems to get full of "draft" records
        // $fs->delete_area_files($context->id, 'user', 'draft', $data->sourceitemid);
        foreach ($files as $hash => $file) {
            if ($file->get_sortorder() == 1) {
                $data->sourcefile = $file->get_filepath() . $file->get_filename();
                $data->sourcetype = hotpot::get_sourcetype($file);
                $sourcefile = $file;
                break;
            }
        }
        unset($fs, $files, $file, $hash, $options);
    }
    if (is_null($sourcefile) || $data->sourcefile == '' || $data->sourcetype == '') {
        // sourcefile was missing or not a recognized type - shouldn't happen !!
    }
    // process text fields that may come from source file
    $source = false;
    $textfields = array('name', 'entrytext', 'exittext');
    foreach ($textfields as $textfield) {
        $textsource = $textfield . 'source';
        if (!isset($data->{$textsource})) {
            $data->{$textsource} = hotpot::TEXTSOURCE_SPECIFIC;
        }
        switch ($data->{$textsource}) {
            case hotpot::TEXTSOURCE_FILE:
                if ($data->sourcetype && $sourcefile && empty($source)) {
                    $class = 'hotpot_source_' . $data->sourcetype;
                    $source = new $class($sourcefile, $data);
                }
                $method = 'get_' . $textfield;
                if ($source && method_exists($source, $method)) {
                    $data->{$textfield} = $source->{$method}();
                } else {
                    $data->{$textfield} = '';
                }
                break;
            case hotpot::TEXTSOURCE_FILENAME:
                $data->{$textfield} = basename($data->sourcefile);
                break;
            case hotpot::TEXTSOURCE_FILEPATH:
                $data->{$textfield} = str_replace(array('/', '\\'), ' ', $data->sourcefile);
                break;
            case hotpot::TEXTSOURCE_SPECIFIC:
            default:
                if (isset($data->{$textfield})) {
                    $data->{$textfield} = trim($data->{$textfield});
                } else {
                    $data->{$textfield} = $mform->get_original_value($textfield, '');
                }
        }
        // default activity name is simply "HotPot"
        if ($textfield == 'name' && $data->{$textfield} == '') {
            $data->{$textfield} = get_string('modulename', 'hotpot');
        }
    }
    // process entry/exit page settings
    foreach (hotpot::text_page_types() as $type) {
        // show page (boolean switch)
        $pagefield = $type . 'page';
        if (!isset($data->{$pagefield})) {
            $data->{$pagefield} = 0;
        }
        // set field names
        $textfield = $type . 'text';
        $formatfield = $type . 'format';
        $editorfield = $type . 'editor';
        $sourcefield = $type . 'textsource';
        $optionsfield = $type . 'options';
        // ensure text, format and option fields are set
        // (these fields can't be null in the database)
        if (!isset($data->{$textfield})) {
            $data->{$textfield} = $mform->get_original_value($textfield, '');
        }
        if (!isset($data->{$formatfield})) {
            $data->{$formatfield} = $mform->get_original_value($formatfield, FORMAT_HTML);
        }
        if (!isset($data->{$optionsfield})) {
            $data->{$optionsfield} = $mform->get_original_value($optionsfield, 0);
        }
        // set text and format fields
        if ($data->{$sourcefield} == hotpot::TEXTSOURCE_SPECIFIC) {
            // transfer wysiwyg editor text
            if ($itemid = $data->{$editorfield}['itemid']) {
                if (isset($data->{$editorfield}['text'])) {
                    // get the text that was sent from the browser
                    $editoroptions = hotpot::text_editors_options($context);
                    $text = file_save_draft_area_files($itemid, $context->id, 'mod_hotpot', $type, 0, $editoroptions, $data->{$editorfield}['text']);
                    // remove leading and trailing white space,
                    //  - empty html paragraphs (from IE)
                    //  - and blank lines (from Firefox)
                    $text = preg_replace('/^((<p>\\s*<\\/p>)|(<br[^>]*>)|\\s)+/is', '', $text);
                    $text = preg_replace('/((<p>\\s*<\\/p>)|(<br[^>]*>)|\\s)+$/is', '', $text);
                    $data->{$textfield} = $text;
                    $data->{$formatfield} = $data->{$editorfield}['format'];
                }
            }
        }
        // set entry/exit page options
        foreach (hotpot::text_page_options($type) as $name => $mask) {
            $optionfield = $type . '_' . $name;
            if ($data->{$pagefield}) {
                if (empty($data->{$optionfield})) {
                    // disable this option
                    $data->{$optionsfield} = $data->{$optionsfield} & ~$mask;
                } else {
                    // enable this option
                    $data->{$optionsfield} = $data->{$optionsfield} | $mask;
                }
            }
        }
        // don't show exit page if no content is specified
        if ($type == 'exit' && empty($data->{$optionsfield}) && empty($data->{$textfield})) {
            $data->{$pagefield} = 0;
        }
    }
    // timelimit
    if ($data->timelimit == hotpot::TIME_SPECIFIC) {
        $data->timelimit = $data->timelimitspecific;
    }
    // delay3
    if ($data->delay3 == hotpot::TIME_SPECIFIC) {
        $data->delay3 = $data->delay3specific;
    }
    // set stopbutton and stoptext
    if (empty($data->stopbutton_yesno)) {
        $data->stopbutton = hotpot::STOPBUTTON_NONE;
        $data->stoptext = $mform->get_original_value('stoptext', '');
    } else {
        if (!isset($data->stopbutton_type)) {
            $data->stopbutton_type = '';
        }
        if (!isset($data->stopbutton_text)) {
            $data->stopbutton_text = '';
        }
        if ($data->stopbutton_type == 'specific') {
            $data->stopbutton = hotpot::STOPBUTTON_SPECIFIC;
            $data->stoptext = $data->stopbutton_text;
        } else {
            $data->stopbutton = hotpot::STOPBUTTON_LANGPACK;
            $data->stoptext = $data->stopbutton_type;
        }
    }
    // set review options
    $data->reviewoptions = 0;
    list($times, $items) = hotpot::reviewoptions_times_items();
    foreach ($times as $timename => $timevalue) {
        foreach ($items as $itemname => $itemvalue) {
            $name = $timename . $itemname;
            // e.g. duringattemptresponses
            if (isset($data->{$name})) {
                if ($data->{$name}) {
                    $data->reviewoptions += $timevalue & $itemvalue;
                }
                unset($data->{$name});
            }
        }
    }
    // save these form settings as user preferences
    $preferences = array();
    foreach (hotpot::user_preferences_fieldnames() as $fieldname) {
        if (isset($data->{$fieldname})) {
            $preferences['hotpot_' . $fieldname] = $data->{$fieldname};
        }
    }
    set_user_preferences($preferences);
}
 /**
  * This function sets the user preferences (emailing & display) for the four
  * test users.
  *
  */
 protected function setup_user_preferences()
 {
     $this->setUser($this->craig);
     block_course_message_update_mail_preference('inbox', 'true');
     block_course_message_update_mail_preference('sent', 'true');
     block_course_message_update_display_preference('new_page');
     $this->setUser($this->friend);
     block_course_message_update_mail_preference('inbox', 'true');
     block_course_message_update_mail_preference('sent', 'false');
     block_course_message_update_display_preference('iframe');
     set_user_preferences(array('htmleditor' => 'tinymce'));
     $this->setUser($this->martha);
     block_course_message_update_mail_preference('inbox', 'false');
     block_course_message_update_mail_preference('sent', 'true');
     set_user_preferences(array('htmleditor' => 'atto'));
     $this->setUser($this->wade);
     block_course_message_update_mail_preference('inbox', 'false');
     block_course_message_update_mail_preference('sent', 'false');
 }
Beispiel #12
0
/**
 * Get the user preference for the zoom function.
 */
function theme_leaf_get_zoom()
{
    global $SESSION;
    if (isset($SESSION->justloggedin)) {
        set_user_preferences(array('theme_leaf_zoom' => 'nozoom'));
    }
    return get_user_preferences('theme_leaf_zoom', '');
}
/**
 * Sets user preferences, in temporary or presistent storage
 *
 * @param  array    $preferences  Preference mapping to save
 * @param  boolean  $temporary    If true, save in temporary storage, otherwise save in persistent storage
 */
function php_report_filtering_set_user_preferences($preferences, $temporary, $report_name)
{
    global $SESSION, $_SESSION;
    // Ugly form dependency check and preference modification code
    // Note: this can be removed once MDL-27045 is resolved and 'checkbox' in elis/core/lib/filtering/date.php can be changed to 'advcheckbox'
    //       (or until someone can implement a cleaner way to handle this)
    if (isset($_SESSION['SESSION']->php_reports[$report_name]->inner_report->filter->_addform->_form->_dependencies)) {
        $dependencies = array_keys($_SESSION['SESSION']->php_reports[$report_name]->inner_report->filter->_addform->_form->_dependencies);
        // Check each dependency to see if there is a related preference
        foreach ($dependencies as $dependency) {
            $check_pref = 'php_report_' . $report_name . '/' . $dependency;
            // If there is no related preference, it is probably because it's an unchecked checkbox so let's set it to 0
            if (!isset($preferences[$check_pref])) {
                $preferences[$check_pref] = 0;
            }
        }
    }
    // End ugly form dependency check and preference modification
    if (!$temporary) {
        //standard API call for persistent storage
        set_user_preferences($preferences);
        return;
    }
    //temporary storage
    if (!isset($SESSION->php_report_default_params)) {
        //make sure storage is set up
        $SESSION->php_report_default_params = array();
    }
    //store all preference values
    if (!empty($preferences)) {
        foreach ($preferences as $key => $value) {
            $SESSION->php_report_default_params[$key] = $value;
        }
    }
}
Beispiel #14
0
 /**
  * Gets the content for this block by grabbing it from $this->page
  */
 function get_content()
 {
     global $CFG, $OUTPUT;
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return $this->content;
     }
     $this->page->requires->yui2_lib('dom');
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     // Navcount is used to allow us to have multiple trees although I dont' know why
     // you would want to trees the same
     block_navigation::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_globalnav' . block_navigation::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_globalnav' . block_navigation::$navcount);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_globalnav' . block_navigation::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $trimmode = self::TRIM_LEFT;
     $trimlength = 50;
     if (!empty($this->config->trimmode)) {
         $trimmode = (int) $this->config->trimmode;
     }
     if (!empty($this->config->trimlength)) {
         $trimlength = (int) $this->config->trimlength;
     }
     // Initialise (only actually happens if it hasn't already been done yet
     $this->page->navigation->initialise();
     $navigation = clone $this->page->navigation;
     $expansionlimit = null;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
         $navigation->set_expansion_limit($this->config->expansionlimit);
     }
     $this->trim($navigation, $trimmode, $trimlength, ceil($trimlength / 2));
     // Get the expandable items so we can pass them to JS
     $expandable = array();
     $navigation->find_expandable($expandable);
     if ($expansionlimit) {
         foreach ($expandable as $key => $node) {
             if ($node['type'] > $expansionlimit && !($expansionlimit == navigation_node::TYPE_COURSE && $node['type'] == $expansionlimit && $node['branchid'] == SITEID)) {
                 unset($expandable[$key]);
             }
         }
     }
     // Initialise the JS tree object
     $module = array('name' => 'block_navigation', 'fullpath' => '/blocks/navigation/navigation.js', 'requires' => array('core_dock', 'io', 'node', 'dom', 'event-custom', 'json-parse'), 'strings' => array(array('viewallcourses', 'moodle')));
     $limit = 20;
     if (!empty($CFG->navcourselimit)) {
         $limit = $CFG->navcourselimit;
     }
     $arguments = array($this->instance->id, array('expansions' => $expandable, 'instance' => $this->instance->id, 'candock' => $this->instance_can_be_docked(), 'courselimit' => $limit));
     $this->page->requires->js_init_call('M.block_navigation.init_add_tree', $arguments, false, $module);
     // Grab the items to display
     $renderer = $this->page->get_renderer('block_navigation');
     $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit);
     // Set content generated to true so that we know it has been done
     $this->contentgenerated = true;
     return $this->content;
 }
Beispiel #15
0
 /**
  * Gets the content for this block by grabbing it from $this->page
  *
  * @return object $this->content
  */
 function get_content()
 {
     global $CFG, $OUTPUT;
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return $this->content;
     }
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     // Navcount is used to allow us to have multiple trees although I dont' know why
     // you would want two trees the same
     block_navigation::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_globalnav' . block_navigation::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_globalnav' . block_navigation::$navcount);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_globalnav' . block_navigation::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $trimmode = self::TRIM_LEFT;
     $trimlength = 50;
     if (!empty($this->config->trimmode)) {
         $trimmode = (int) $this->config->trimmode;
     }
     if (!empty($this->config->trimlength)) {
         $trimlength = (int) $this->config->trimlength;
     }
     // Initialise (only actually happens if it hasn't already been done yet
     $this->page->navigation->initialise();
     $navigation = clone $this->page->navigation;
     $expansionlimit = null;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
         $navigation->set_expansion_limit($this->config->expansionlimit);
     }
     $this->trim($navigation, $trimmode, $trimlength, ceil($trimlength / 2));
     // Get the expandable items so we can pass them to JS
     $expandable = array();
     $navigation->find_expandable($expandable);
     if ($expansionlimit) {
         foreach ($expandable as $key => $node) {
             if ($node['type'] > $expansionlimit && !($expansionlimit == navigation_node::TYPE_COURSE && $node['type'] == $expansionlimit && $node['branchid'] == SITEID)) {
                 unset($expandable[$key]);
             }
         }
     }
     $this->page->requires->data_for_js('navtreeexpansions' . $this->instance->id, $expandable);
     $options = array();
     $options['linkcategories'] = !empty($this->config->linkcategories) && $this->config->linkcategories == 'yes';
     // Grab the items to display
     $renderer = $this->page->get_renderer('block_navigation');
     $this->content = new stdClass();
     $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);
     // Set content generated to true so that we know it has been done
     $this->contentgenerated = true;
     return $this->content;
 }
/**
 * Set default message preferences.
 * @param $user - User to set message preferences
 */
function message_set_default_message_preferences($user)
{
    global $DB;
    $providers = $DB->get_records('message_providers');
    $preferences = array();
    foreach ($providers as $providerid => $provider) {
        $preferences['message_provider_' . $provider->component . '_' . $provider->name . '_loggedin'] = 'popup';
        $preferences['message_provider_' . $provider->component . '_' . $provider->name . '_loggedoff'] = 'email';
    }
    return set_user_preferences($preferences, $user->id);
}
Beispiel #17
0
    if ($USER->gradeediting[$course->id]) {
        $options['edit'] = 0;
        $string = get_string('turneditingoff');
    } else {
        $options['edit'] = 1;
        $string = get_string('turneditingon');
    }
    $buttons = new single_button(new moodle_url('index.php', $options), $string, 'get');
} else {
    $USER->gradeediting[$course->id] = 0;
    $buttons = '';
}
$gradeserror = array();
// Handle toggle change request
if (!is_null($toggle) && !empty($toggle_type)) {
    set_user_preferences(array('grade_report_show' . $toggle_type => $toggle));
}
//first make sure we have proper final grades - this must be done before constructing of the grade tree
grade_regrade_final_grades($courseid);
// Perform actions
if (!empty($target) && !empty($action) && confirm_sesskey()) {
    grade_report_grader::process_action($target, $action);
}
$reportname = get_string('pluginname', 'gradereport_grader');
/// Print header
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);
//Initialise the grader report object that produces the table
//the class grade_report_grader_ajax was removed as part of MDL-21562
$report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);
// make sure separate group does not prevent view
if ($report->currentgroup == -2) {
Beispiel #18
0
 /**
  * Gets the content for this block by grabbing it from $this->page
  *
  * @return object $this->content
  */
 function get_content()
 {
     global $CFG;
     $nav = new Navigation();
     $roleid = $nav->get_user_role();
     $userid = $nav->user->id;
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return $this->content;
     }
     if (($roleid == 5 || $roleid == 4) && $userid != 2 && $userid != 3) {
         return null;
     }
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     // Navcount is used to allow us to have multiple trees although I dont' know why
     // you would want two trees the same
     block_navigation::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_globalnav' . block_navigation::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_globalnav' . block_navigation::$navcount);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_globalnav' . block_navigation::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $trimmode = self::TRIM_RIGHT;
     $trimlength = 50;
     if (!empty($this->config->trimmode)) {
         $trimmode = (int) $this->config->trimmode;
     }
     if (!empty($this->config->trimlength)) {
         $trimlength = (int) $this->config->trimlength;
     }
     // Get the navigation object or don't display the block if none provided.
     if (!($navigation = $this->get_navigation())) {
         return null;
     }
     $expansionlimit = null;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
         $navigation->set_expansion_limit($this->config->expansionlimit);
     }
     $this->trim($navigation, $trimmode, $trimlength, ceil($trimlength / 2));
     // Get the expandable items so we can pass them to JS
     $expandable = array();
     $navigation->find_expandable($expandable);
     if ($expansionlimit) {
         foreach ($expandable as $key => $node) {
             if ($node['type'] > $expansionlimit && !($expansionlimit == navigation_node::TYPE_COURSE && $node['type'] == $expansionlimit && $node['branchid'] == SITEID)) {
                 unset($expandable[$key]);
             }
         }
     }
     $limit = 20;
     if (!empty($CFG->navcourselimit)) {
         $limit = $CFG->navcourselimit;
     }
     $expansionlimit = 0;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
     }
     $arguments = array('id' => $this->instance->id, 'instance' => $this->instance->id, 'candock' => $this->instance_can_be_docked(), 'courselimit' => $limit, 'expansionlimit' => $expansionlimit);
     $options = array();
     $options['linkcategories'] = !empty($this->config->linkcategories) && $this->config->linkcategories == 'yes';
     // Grab the items to display
     $renderer = $this->page->get_renderer($this->blockname);
     $this->content = new stdClass();
     $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);
     // Set content generated to true so that we know it has been done
     $this->contentgenerated = true;
     return $this->content;
 }