当前位置: 首页>>代码示例>>PHP>>正文


PHP set_user_preferences函数代码示例

本文整理汇总了PHP中set_user_preferences函数的典型用法代码示例。如果您正苦于以下问题:PHP set_user_preferences函数的具体用法?PHP set_user_preferences怎么用?PHP set_user_preferences使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_user_preferences函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_message_processors

                    $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) {
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:edit.php

示例2: tm_message_set_default_message_preferences

/**
 * 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);
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:59,代码来源:messagelib.php

示例3: get_content

 /**
  * 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;
 }
开发者ID:helenagarcia90,项目名称:moodle-esi,代码行数:81,代码来源:block_navigation.php

示例4: message_set_default_message_preferences

/**
 * 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);
}
开发者ID:nuckey,项目名称:moodle,代码行数:47,代码来源:messagelib.php

示例5: message_print_settings

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';
}
开发者ID:r007,项目名称:PMoodle,代码行数:28,代码来源:lib.php

示例6: php_report_filtering_set_user_preferences

/**
 * 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;
        }
    }
}
开发者ID:jamesmcq,项目名称:elis,代码行数:47,代码来源:filtering.php

示例7: get_content

 /**
  * 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;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:48,代码来源:block_settings.php

示例8: message_print_settings

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';
}
开发者ID:vuchannguyen,项目名称:web,代码行数:14,代码来源:lib.php

示例9: message_processor_config_form

 /**
  * 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);
     }
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:36,代码来源:externallib.php

示例10: hotpot_process_formdata


//.........这里部分代码省略.........
        $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);
}
开发者ID:hapaxapah,项目名称:moodle-mod_hotpot,代码行数:101,代码来源:lib.php

示例11: setup_user_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');
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:24,代码来源:mailunittest.php

示例12: theme_leaf_get_zoom

/**
 * 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', '');
}
开发者ID:bmbrands,项目名称:moodle-theme_leaf,代码行数:11,代码来源:lib.php

示例13: php_report_filtering_set_user_preferences

/**
 * 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;
        }
    }
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:41,代码来源:filtering.php

示例14: get_content

 /**
  * 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;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:76,代码来源:block_navigation.php

示例15: get_content

 /**
  * 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;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:73,代码来源:block_navigation.php


注:本文中的set_user_preferences函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。