/**
 * Returns users preferred editor for given format
 *
 * @param int $format text format or null of none
 * @return texteditor object
 */
function editors_get_preferred_editor($format = NULL)
{
    global $USER;
    $enabled = editors_get_enabled();
    $preference = get_user_preferences('htmleditor', '', $USER);
    if (isset($enabled[$preference])) {
        // Edit the list of editors so the users preferred editor is first in the list.
        $editor = $enabled[$preference];
        unset($enabled[$preference]);
        array_unshift($enabled, $editor);
    }
    // now find some plugin that supports format and is available
    $editor = false;
    foreach ($enabled as $e) {
        if (!$e->supported_by_browser()) {
            // bad luck, this editor is not compatible
            continue;
        }
        if (!($supports = $e->get_supported_formats())) {
            // buggy editor!
            continue;
        }
        if (is_null($format) || in_array($format, $supports)) {
            // editor supports this format, yay!
            $editor = $e;
            break;
        }
    }
    if (!$editor) {
        $editor = get_texteditor('textarea');
        // must exist and can edit anything
    }
    return $editor;
}
예제 #2
0
 /**
  * Constructor
  */
 public function __construct($gtree, $moving = false, $gpr)
 {
     global $USER, $OUTPUT, $COURSE;
     $systemdefault = get_config('moodle', 'grade_report_showcalculations');
     $this->show_calculations = get_user_preferences('grade_report_showcalculations', $systemdefault);
     $this->gtree = $gtree;
     $this->moving = $moving;
     $this->gpr = $gpr;
     $this->deepest_level = $this->get_deepest_level($this->gtree->top_element);
     $this->columns = array(grade_edit_tree_column::factory('name', array('deepest_level' => $this->deepest_level)));
     if ($this->uses_weight) {
         $this->columns[] = grade_edit_tree_column::factory('weight', array('adv' => 'weight'));
     }
     $this->columns[] = grade_edit_tree_column::factory('range');
     // This is not a setting... How do we deal with it?
     $this->columns[] = grade_edit_tree_column::factory('actions');
     if ($this->deepest_level > 1) {
         $this->columns[] = grade_edit_tree_column::factory('select');
     }
     $this->table = new html_table();
     $this->table->id = "grade_edit_tree_table";
     $this->table->attributes['class'] = 'generaltable simple setup-grades';
     if ($this->moving) {
         $this->table->attributes['class'] .= ' moving';
     }
     foreach ($this->columns as $column) {
         if (!($this->moving && $column->hide_when_moving)) {
             $this->table->head[] = $column->get_header_cell();
         }
     }
     $rowcount = 0;
     $this->table->data = $this->build_html_tree($this->gtree->top_element, true, array(), 0, $rowcount);
 }
예제 #3
0
    /**
     *
     * @param int $repositoryid
     * @param object $context
     * @param array $options
     */
    public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
        global $SESSION, $CFG;
        $options['page']    = optional_param('p', 1, PARAM_INT);
        parent::__construct($repositoryid, $context, $options);

        $this->setting = 'flickr_';

        $this->api_key = $this->get_option('api_key');
        $this->secret  = $this->get_option('secret');

        $this->token = get_user_preferences($this->setting, '');
        $this->nsid  = get_user_preferences($this->setting.'_nsid', '');

        $this->flickr = new phpFlickr($this->api_key, $this->secret, $this->token);

        $frob  = optional_param('frob', '', PARAM_RAW);
        if (empty($this->token) && !empty($frob)) {
            $auth_info = $this->flickr->auth_getToken($frob);
            $this->token = $auth_info['token'];
            $this->nsid  = $auth_info['user']['nsid'];
            set_user_preference($this->setting, $auth_info['token']);
            set_user_preference($this->setting.'_nsid', $auth_info['user']['nsid']);
        }

    }
예제 #4
0
 public function __create($bookmarkurl, $title, $tokenval)
 {
     global $CFG, $DB;
     $response = new CliniqueServiceResponce();
     $token_val = array('token' => $tokenval);
     $userId = array_values($DB->get_records_sql('SELECT userid FROM {external_tokens} et WHERE et.token=?', $token_val));
     if ($userId) {
         $user_id = array('id' => $userId[0]->userid);
         //if(confirm_sesskey()){
         $user = array_values($DB->get_records_sql('SELECT * FROM {user} u WHERE u.id=?', $user_id));
         Favorites::__fav_user_login($user['0']);
         if (get_user_preferences('user_bookmarks')) {
             $bookmarks = explode(',', get_user_preferences('user_bookmarks'));
             if (in_array($bookmarkurl . ";" . $title, $bookmarks)) {
                 $response->response(true, 'You have already bookmarked');
                 die;
             }
         } else {
             $bookmarks = array();
         }
         //adds the bookmark at end of array
         $bookmarks[] = $bookmarkurl . ";" . $title;
         $bookmarks = implode(',', $bookmarks);
         //adds to preferences table
         set_user_preference('user_bookmarks', $bookmarks);
         global $CFG;
         //header("Location: " . $CFG->wwwroot . "/");
         //print "Added Favourite Successfully";
         $response->response(false, 'Added Favourite Successfully');
         die;
     } else {
         $response->response(false, 'Invalid user');
         die;
     }
 }
예제 #5
0
 /**
  * get_field
  *
  * @param xxx $fieldname
  * @param xxx $advanced
  * @return xxx
  */
 function get_field($fieldname, $advanced)
 {
     // hotpot version of standard function
     $default = get_user_preferences('hotpot_' . $fieldname, '');
     $rawdata = data_submitted();
     if ($rawdata && isset($rawdata->{$fieldname}) && !is_array($rawdata->{$fieldname})) {
         $default = optional_param($fieldname, $default, PARAM_ALPHANUM);
     }
     unset($rawdata);
     switch ($fieldname) {
         case 'group':
         case 'grouping':
             return new hotpot_filter_group($fieldname, $advanced, $default);
         case 'grade':
             $label = get_string('grade');
             return new hotpot_filter_grade($fieldname, $label, $advanced, $default);
         case 'timemodified':
             $label = get_string('time', 'quiz');
             return new user_filter_date($fieldname, $label, $advanced, $fieldname);
         case 'status':
             return new hotpot_filter_status($fieldname, $advanced, $default);
         case 'duration':
             $label = get_string('duration', 'mod_hotpot');
             return new hotpot_filter_duration($fieldname, $label, $advanced, $default);
         case 'penalties':
             $label = get_string('penalties', 'mod_hotpot');
             return new hotpot_filter_number($fieldname, $label, $advanced, $default);
         case 'score':
             $label = get_string('score', 'quiz');
             return new hotpot_filter_number($fieldname, $label, $advanced, $default);
         default:
             // other fields (e.g. from user record)
             return parent::get_field($fieldname, $advanced);
     }
 }
예제 #6
0
    public function setup_from_user_preferences() {
        parent::setup_from_user_preferences();

        $this->showqtext     = get_user_preferences('quiz_report_responses_qtext', $this->showqtext);
        $this->showresponses = get_user_preferences('quiz_report_responses_resp',  $this->showresponses);
        $this->showright     = get_user_preferences('quiz_report_responses_right', $this->showright);
    }
 function definition()
 {
     global $USER;
     $mform =& $this->_form;
     $mform->addElement('header', '', get_string('changepassword'), '');
     // visible elements
     $mform->addElement('static', 'username', get_string('username'), $USER->username);
     $mform->addElement('password', 'password', get_string('oldpassword'));
     $mform->addRule('password', get_string('required'), 'required', null, 'client');
     $mform->setType('password', PARAM_RAW);
     $mform->addElement('password', 'newpassword1', get_string('newpassword'));
     $mform->addRule('newpassword1', get_string('required'), 'required', null, 'client');
     $mform->setType('newpassword1', PARAM_RAW);
     $mform->addElement('password', 'newpassword2', get_string('newpassword') . ' (' . get_String('again') . ')');
     $mform->addRule('newpassword2', get_string('required'), 'required', null, 'client');
     $mform->setType('newpassword2', PARAM_RAW);
     // hidden optional params
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
     // buttons
     if (get_user_preferences('auth_forcepasswordchange')) {
         $this->add_action_buttons(false);
     } else {
         $this->add_action_buttons(true);
     }
 }
예제 #8
0
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     $options['page'] = optional_param('p', 1, PARAM_INT);
     parent::__construct($repositoryid, $context, $options);
     // if moodle is telling us what kind of mimetypes it wants, we check to see if it happens to be just ZIP.
     // If that's the case, we know we're on a SCORM page, because in all other cases supported_filetypes() will return web_image
     // this allows us to override our own type and act like a SCORM supplier.
     if (isset($options['mimetypes'])) {
         if (in_array(".zip", $options['mimetypes'])) {
             $this->fileTypes = "zipscorm";
             $this->fileExtension = ".zip";
         }
     }
     $this->setting = 'elevator_';
     $elevatorURL = get_config('elevator', 'elevatorURL');
     $apiKey = get_config('elevator', 'apiKey');
     $apiSecret = get_config('elevator', 'apiSecret');
     if (isset($options['userId'])) {
         $this->userId = $options['userId'];
     } else {
         $this->userId = get_user_preferences($this->setting . '_userId', '');
     }
     $this->repositoryId = $repositoryid;
     // initiate an instance of the elevator API, which handles all the backend communication.
     $this->elevatorAPI = new elevatorAPI($elevatorURL, $apiKey, $apiSecret, $this->userId);
     $this->elevatorAPI->fileTypes = $this->fileTypes;
     if ($this->userId) {
         $this->loggedIn = $this->testUserId();
         $this->manageURL = $this->elevatorAPI->getManageURL();
     }
 }
예제 #9
0
    function process_feedback($formdata=null) {
        global $CFG, $USER, $DB;
        require_once($CFG->libdir.'/gradelib.php');

        if (!$feedback = data_submitted() or !confirm_sesskey()) {      // No incoming data?
            return false;
        }

        ///For save and next, we need to know the userid to save, and the userid to go
        ///We use a new hidden field in the form, and set it to -1. If it's set, we use this
        ///as the userid to store
        if ((int)$feedback->saveuserid !== -1){
            $feedback->userid = $feedback->saveuserid;
        }

        if (!empty($feedback->cancel)) {          // User hit cancel button
            return false;
        }

        $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $feedback->userid);

        // store outcomes if needed
        $this->process_outcomes($feedback->userid);

        $submission = $this->get_submission($feedback->userid, true);  // Get or make one

        if (!$grading_info->items[0]->grades[$feedback->userid]->locked and
            !$grading_info->items[0]->grades[$feedback->userid]->overridden) {

            $submission->grade      = $feedback->xgrade;
            $submission->submissioncomment    = $feedback->submissioncomment_editor['text'];
            $submission->teacher    = $USER->id;
            $mailinfo = get_user_preferences('assignment_mailinfo', 0);
            if (!$mailinfo) {
                $submission->mailed = 1;       // treat as already mailed
            } else {
                $submission->mailed = 0;       // Make sure mail goes out (again, even)
            }
            $submission->timemarked = time();

            unset($submission->data1);  // Don't need to update this.
            unset($submission->data2);  // Don't need to update this.

            if (empty($submission->timemodified)) {   // eg for offline assignments
                $submission->timemodified = time();
            }

            $DB->update_record('assignment_submissions', $submission);

            // trigger grade event
            $this->update_grade($submission);

            add_to_log($this->course->id, 'assignment', 'update grades',
                       'submissions.php?id='.$this->assignment->id.'&user='.$feedback->userid, $feedback->userid, $this->cm->id);
        }

        return $submission;

    }
예제 #10
0
 public function load_data(&$preferences, $userid)
 {
     $preferences->showmessagewindow = get_user_preferences('message_showmessagewindow', 1, $userid);
     $preferences->blocknoncontacts = get_user_preferences('message_blocknoncontacts', '', $userid);
     $preferences->beepnewmessage = get_user_preferences('message_beepnewmessage', '', $userid);
     $preferences->noframesjs = get_user_preferences('message_noframesjs', '', $userid);
     return true;
 }
예제 #11
0
function useredit_load_preferences(&$user)
{
    if (!empty($user->id) and $preferences = get_user_preferences(null, null, $user->id)) {
        foreach ($preferences as $name => $value) {
            $user->{'preference_' . $name} = $value;
        }
    }
}
 private function _add_column_select()
 {
     global $DB, $CFG;
     $mform = $this->_form;
     $data =& $this->_customdata;
     $params = array('slotid' => reset($data['slots']));
     $isgrouporganizer = $DB->get_field_sql("SELECT o.isgrouporganizer\n                FROM {organizer} o\n                INNER JOIN {organizer_slots} s ON o.id = s.organizerid\n                WHERE s.id = :slotid", $params);
     $identityfields = explode(',', $CFG->showuseridentity);
     if (array_search('idnumber', $identityfields) !== false) {
         $selcols = array('datetime', 'location', 'teacher', 'participant', 'idnumber', 'attended', 'grade', 'feedback');
     } else {
         $selcols = array('datetime', 'location', 'teacher', 'participant', 'attended', 'grade', 'feedback');
     }
     $this->_selcols = $selcols;
     if ($isgrouporganizer) {
         array_splice($selcols, 3, 0, 'groupname');
     }
     $mform->addElement('header', 'export_settings_header', get_string('exportsettings', 'organizer'));
     $exportformats = array('pdf' => get_string('format_pdf', 'organizer'), 'xlsx' => get_string('format_xlsx', 'organizer'), 'xls' => get_string('format_xls', 'organizer'), 'ods' => get_string('format_ods', 'organizer'), 'csv_tab' => get_string('format_csv_tab', 'organizer'), 'csv_comma' => get_string('format_csv_comma', 'organizer'));
     $mform->addElement('select', 'format', get_string('format', 'organizer'), $exportformats);
     $mform->addElement('static', 'pdf_settings', get_string('pdfsettings', 'organizer'));
     $entriesperpage = get_user_preferences('organizer_printperpage', 20);
     $printperpage_optimal = get_user_preferences('organizer_printperpage_optimal', 0);
     $textsize = get_user_preferences('organizer_textsize', 10);
     $pageorientation = get_user_preferences('organizer_pageorientation', 'P');
     $headerfooter = get_user_preferences('organizer_headerfooter', 1);
     // submissions per page
     $pppgroup = array();
     $pppgroup[] =& $mform->createElement('text', 'entriesperpage', get_string('numentries', 'organizer'), array('size' => '2'));
     $pppgroup[] =& $mform->createElement('advcheckbox', 'printperpage_optimal', get_string('stroptimal', 'organizer'), get_string('stroptimal', 'organizer'), array("group" => 1));
     $mform->addGroup($pppgroup, 'printperpagegrp', get_string('numentries', 'organizer'), array(' '), false);
     $mform->setType('entriesperpage', PARAM_INT);
     $mform->setDefault('entriesperpage', $entriesperpage);
     $mform->setDefault('printperpage_optimal', $printperpage_optimal);
     $mform->addHelpButton('printperpagegrp', 'numentries', 'organizer');
     $mform->disabledIf('entriesperpage', 'printperpage_optimal', 'checked');
     $mform->disabledIf('printperpagegrp', 'format', 'neq', 'pdf');
     $mform->addElement('select', 'textsize', get_string('textsize', 'organizer'), array('8' => get_string('font_small', 'organizer'), '10' => get_string('font_medium', 'organizer'), '12' => get_string('font_large', 'organizer')));
     $mform->setDefault('textsize', $textsize);
     $mform->disabledIf('textsize', 'format', 'neq', 'pdf');
     $mform->addElement('select', 'pageorientation', get_string('pageorientation', 'organizer'), array('P' => get_string('orientationportrait', 'organizer'), 'L' => get_string('orientationlandscape', 'organizer')));
     $mform->setDefault('pageorientation', $pageorientation);
     $mform->disabledIf('pageorientation', 'format', 'neq', 'pdf');
     $mform->addElement('advcheckbox', 'headerfooter', get_string('headerfooter', 'organizer'), null, null, array(0, 1));
     $mform->setType('headerfooter', PARAM_BOOL);
     $mform->setDefault('headerfooter', $headerfooter);
     $mform->addHelpButton('headerfooter', 'headerfooter', 'organizer');
     $mform->disabledIf('headerfooter', 'format', 'neq', 'pdf');
     $buttonarray = array();
     $buttonarray[] =& $mform->createElement('submit', 'downloadfile', get_string('downloadfile', 'organizer'));
     $buttonarray[] =& $mform->createElement('cancel', 'cancel', get_string('print_return', 'organizer'));
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     foreach ($selcols as $key => $selcol) {
         $mform->addElement('hidden', "cols[{$key}]", $selcol, array('id' => "col_{$selcol}"));
         $mform->setType("cols[{$key}]", PARAM_ALPHANUMEXT);
     }
 }
예제 #13
0
 public function definition()
 {
     global $USER, $CFG;
     $mform =& $this->_form;
     $strpagesize = get_string('pagesize', 'blog');
     $mform->addElement('text', 'pagesize', $strpagesize);
     $mform->setDefault('pagesize', get_user_preferences('pagesize'));
     $this->add_action_buttons();
 }
예제 #14
0
 /**
  * Test user_update_password method.
  */
 public function test_user_update_password()
 {
     $user = $this->getDataGenerator()->create_user();
     $expectedtime = time();
     $passwordisupdated = $this->authplugin->user_update_password($user, 'MyNewPassword*');
     // Assert that the actual time should be equal or a little greater than the expected time.
     $this->assertGreaterThanOrEqual($expectedtime, get_user_preferences('auth_manual_passwordupdatetime', 0, $user->id));
     // Assert that the password was successfully updated.
     $this->assertTrue($passwordisupdated);
 }
 /**
  * Gets the content for this block
  */
 function get_content()
 {
     global $CFG;
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return $this->content;
     }
     $this->content = new stdClass();
     if (get_user_preferences('admin_bookmarks')) {
         require_once $CFG->libdir . '/adminlib.php';
         $adminroot = admin_get_root(false, false);
         // settings not required - only pages
         $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
         /// Accessibility: markup as a list.
         $contents = array();
         foreach ($bookmarks as $bookmark) {
             $temp = $adminroot->locate($bookmark);
             if ($temp instanceof admin_settingpage) {
                 $contenturl = new moodle_url('/admin/settings.php', array('section' => $bookmark));
                 $contentlink = html_writer::link($contenturl, $temp->visiblename);
                 $contents[] = html_writer::tag('li', $contentlink);
             } else {
                 if ($temp instanceof admin_externalpage) {
                     $contenturl = new moodle_url($temp->url);
                     $contentlink = html_writer::link($contenturl, $temp->visiblename);
                     $contents[] = html_writer::tag('li', $contentlink);
                 }
             }
         }
         $this->content->text = html_writer::tag('ol', implode('', $contents), array('class' => 'list'));
     } else {
         $bookmarks = array();
     }
     $this->content->footer = '';
     $this->page->settingsnav->initialise();
     $node = $this->page->settingsnav->get('root', navigation_node::TYPE_SITE_ADMIN);
     if (!$node || !$node->contains_active_node()) {
         return $this->content;
     }
     $section = $node->find_active_node()->key;
     if ($section == 'search' || empty($section)) {
         // the search page can't be properly bookmarked at present
         $this->content->footer = '';
     } else {
         if (in_array($section, $bookmarks)) {
             $deleteurl = new moodle_url('/blocks/admin_bookmarks/delete.php', array('section' => $section, 'sesskey' => sesskey()));
             $this->content->footer = html_writer::link($deleteurl, get_string('unbookmarkthispage', 'admin'));
         } else {
             $createurl = new moodle_url('/blocks/admin_bookmarks/create.php', array('section' => $section, 'sesskey' => sesskey()));
             $this->content->footer = html_writer::link($createurl, get_string('bookmarkthispage', 'admin'));
         }
     }
     return $this->content;
 }
예제 #16
0
/**
 * Find the rownum for a userid and assign mod to user for grading url
 *
 * @param stdClass $cm course module object
 * @param in $userid the id of the user whose rownum we are interested in
 *
 * @return int 
 */
function ungraded_assignments_get_rownum($cm, $userid)
{
    global $COURSE;
    $mod_context = context_module::instance($cm->id);
    $assign = new assign($mod_context, $cm, $COURSE);
    $filter = get_user_preferences('assign_filter', '');
    $table = new assign_grading_table($assign, 0, $filter, 0, false);
    $useridlist = $table->get_column_data('userid');
    $rownum = array_search($userid, $useridlist);
    return $rownum;
}
/**
* Parameter $local added by power-web.at 
* When local Time is needed the $local Param must be set to 1 
* @param int $date a timestamp
* @param int $local
* @todo check consistence
* @return string printable time
*/
function scheduler_usertime($date, $local = 0)
{
    if ($date == 0) {
        return '';
    } else {
        if (!($timeformat = get_user_preferences('calendar_timeformat'))) {
            $timeformat = get_string('strftimetime');
        }
        return userdate($date, $timeformat);
    }
}
예제 #18
0
파일: lib.php 프로젝트: njorth/marginalia
 public static function get_userid()
 {
     global $USER;
     // Get the users whose annotations are to be shown
     $annotationuser = get_user_preferences(AN_USER_PREF, null);
     if (null == $annotationuser) {
         $annotationuser = isguest() ? null : $USER->username;
         set_user_preference(AN_USER_PREF, $annotationuser);
     }
     return $annotationuser;
 }
 function get_content()
 {
     global $USER, $CFG, $SESSION;
     $cal_m = optional_param('cal_m', 0, PARAM_INT);
     $cal_y = optional_param('cal_y', 0, PARAM_INT);
     require_once $CFG->dirroot . '/calendar/lib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $filtercourse = array();
     if (empty($this->instance)) {
         // Overrides: use no course at all
         $courseshown = false;
         $this->content->footer = '';
     } else {
         $courseshown = $this->page->course->id;
         $this->content->footer = '<div class="gotocal"><a href="' . $CFG->wwwroot . '/calendar/view.php?view=upcoming&amp;course=' . $courseshown . '">' . get_string('gotocalendar', 'calendar') . '</a>...</div>';
         $context = context_course::instance($courseshown);
         if (has_any_capability(array('moodle/calendar:manageentries', 'moodle/calendar:manageownentries'), $context)) {
             $this->content->footer .= '<div class="newevent"><a href="' . $CFG->wwwroot . '/calendar/event.php?action=new&amp;course=' . $courseshown . '">' . get_string('newevent', 'calendar') . '</a>...</div>';
         }
         if ($courseshown == SITEID) {
             // Being displayed at site level. This will cause the filter to fall back to auto-detecting
             // the list of courses it will be grabbing events from.
             $filtercourse = calendar_get_default_courses();
         } else {
             // Forcibly filter events to include only those from the particular course we are in.
             $filtercourse = array($courseshown => $this->page->course);
         }
     }
     list($courses, $group, $user) = calendar_set_filters($filtercourse);
     $defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
     if (isset($CFG->calendar_lookahead)) {
         $defaultlookahead = intval($CFG->calendar_lookahead);
     }
     $lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
     $defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
     if (isset($CFG->calendar_maxevents)) {
         $defaultmaxevents = intval($CFG->calendar_maxevents);
     }
     $maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
     $events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents);
     if (!empty($this->instance)) {
         $this->content->text = calendar_get_block_upcoming($events, 'view.php?view=day&amp;course=' . $courseshown . '&amp;');
     }
     if (empty($this->content->text)) {
         $this->content->text = '<div class="post">' . get_string('noupcomingevents', 'calendar') . '</div>';
     }
     return $this->content;
 }
 function get_content()
 {
     global $USER, $CFG, $SESSION, $COURSE;
     $cal_m = optional_param('cal_m', 0, PARAM_INT);
     $cal_y = optional_param('cal_y', 0, PARAM_INT);
     require_once $CFG->dirroot . '/calendar/lib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     // Reset the session variables
     calendar_session_vars($COURSE);
     $this->content = new stdClass();
     $this->content->text = '';
     if (empty($this->instance)) {
         // Overrides: use no course at all
         $courseshown = false;
         $filtercourse = array();
         $this->content->footer = '';
     } else {
         $courseshown = $COURSE->id;
         $this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/calendar/view.php?view=upcoming&amp;course=' . $courseshown . '">' . get_string('gotocalendar', 'calendar') . '</a>...';
         $context = get_context_instance(CONTEXT_COURSE, $courseshown);
         if (has_capability('moodle/calendar:manageentries', $context) || has_capability('moodle/calendar:manageownentries', $context)) {
             $this->content->footer .= '<br /><a href="' . $CFG->wwwroot . '/calendar/event.php?action=new&amp;course=' . $courseshown . '">' . get_string('newevent', 'calendar') . '</a>...';
         }
         if ($courseshown == SITEID) {
             // Being displayed at site level. This will cause the filter to fall back to auto-detecting
             // the list of courses it will be grabbing events from.
             $filtercourse = NULL;
             $groupeventsfrom = NULL;
             $SESSION->cal_courses_shown = calendar_get_default_courses(true);
             calendar_set_referring_course(0);
         } else {
             // Forcibly filter events to include only those from the particular course we are in.
             $filtercourse = array($courseshown => $COURSE);
             $groupeventsfrom = array($courseshown => 1);
         }
     }
     // We 'll need this later
     calendar_set_referring_course($courseshown);
     // Be VERY careful with the format for default courses arguments!
     // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
     calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false);
     $events = calendar_get_upcoming($courses, $group, $user, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
     if (!empty($this->instance)) {
         $this->content->text = calendar_get_sideblock_upcoming($events, 'view.php?view=day&amp;course=' . $courseshown . '&amp;');
     }
     if (empty($this->content->text)) {
         $this->content->text = '<div class="post">' . get_string('noupcomingevents', 'calendar') . '</div>';
     }
     return $this->content;
 }
 /**
  * Checks if username is set
  * 
  * @return boolean
  */
 public function check_login()
 {
     $username = get_user_preferences(self::USERNAME, '');
     if (empty($username)) {
         $username = optional_param('bitbucket_username', '', PARAM_ALPHANUM);
     }
     if ($username) {
         set_user_preference(self::USERNAME, $username);
         $this->client = new bitbucket($username);
         return true;
     }
     return false;
 }
예제 #22
0
 /**
  * Define the form.
  */
 public function definition()
 {
     global $COURSE;
     $mform = $this->_form;
     $mform->addElement('advcheckbox', 'enableactivitychooser', get_string('enableactivitychooser', 'admin'), get_string('configenableactivitychooser', 'admin'));
     $mform->setDefault('enableactivitychooser', get_user_preferences('usemodchooser', true, $this->_customdata['userid']));
     // Add some extra hidden fields.
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'course', $COURSE->id);
     $mform->setType('course', PARAM_INT);
     $this->add_action_buttons(true, get_string('savechanges'));
 }
예제 #23
0
 function definition()
 {
     global $USER, $CFG, $COURSE;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id', $USER->id);
     $mform->addElement('header', 'Editar', 'Editar Perfil');
     $mform->addElement('text', 'username', get_string('username'), array('readonly' => 'readonly'));
     $mform->setDefault('username', $USER->username);
     $mform->addRule('username', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('text', 'firstname', get_string('firstname'), array('readonly' => 'readonly'));
     $mform->setDefault('firstname', $USER->firstname);
     $mform->addRule('firstname', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('text', 'lastname', get_string('lastname'), array('readonly' => 'readonly'));
     $mform->setDefault('lastname', $USER->lastname);
     $mform->addRule('lastname', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('password', 'pass1', get_string('newpassword'));
     $mform->addElement('password', 'pass2', get_string('newpassword') . ' (' . get_String('again') . ')');
     if (get_user_preferences('auth_forcepasswordchange')) {
         $mform->addRule('pass1', get_string('required'), 'required', '', 'client', false, false);
         $mform->addRule('pass2', get_string('required'), 'required', '', 'client', false, false);
     }
     $mform->addElement('text', 'email', 'Correo Banco');
     $mform->setDefault('email', $USER->email);
     $mform->addRule('email', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('email', get_string('invalidemail'), 'email', '', 'client', false, false);
     $mform->addElement('text', 'msn', get_string('msnid'));
     $mform->setDefault('msn', $USER->msn);
     $mform->addRule('msn', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('msn', get_string('invalidemail'), 'email', '', 'client', false, false);
     $mform->addElement('date_selector', 'icq', get_string('icqnumber'), array('startyear' => 1920, 'stopyear' => 2020, 'timezone' => 99, 'step' => 5));
     $mform->setDefault('icq', $USER->icq);
     $mform->addRule('icq', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('text', 'phone1', get_string('phone'));
     $mform->setDefault('phone1', $USER->phone1);
     $mform->addRule('phone1', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('phone1', get_string('isnumber', 'report_user'), 'numeric', '', 'client', false, false);
     $mform->addElement('text', 'yahoo', get_string('yahooid'));
     $mform->setDefault('yahoo', $USER->yahoo);
     // $mform->addRule('yahoo', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('yahoo', get_string('isnumber', 'report_user'), 'numeric', '', 'client', false, false);
     $mform->addElement('text', 'phone2', get_string('phone2'));
     $mform->setDefault('phone2', $USER->phone2);
     //$mform->addRule('phone2', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('phone2', get_string('isnumber', 'report_user'), 'numeric', '', 'client', false, false);
     $mform->addElement('html', '<div><span class="msg-picture">Recuerda que esta imagen ser&aacute; vista por tus compa&ntilde;eros.</span></div>');
     $mform->addElement('file', 'picture', get_string('userpic'));
     $mform->addElement('submit', 'save', get_string('savechanges'));
     $mform->addElement('html', '<div style="color:#A00" align="right">En caso no cuente con correo BCP ingrese un correo personal**</div>');
 }
 function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     if (get_user_preferences('admin_bookmarks')) {
         // this is expensive! Only require when bookmakrs exist..
         require_once $CFG->libdir . '/adminlib.php';
         $adminroot = admin_get_root(false, false);
         // settings not required - only pages
         $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
         // hmm... just a liiitle (potentially) processor-intensive
         // (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here
         /// Accessibility: markup as a list.
         $this->content->text .= '<ol class="list">' . "\n";
         foreach ($bookmarks as $bookmark) {
             $temp = $adminroot->locate($bookmark);
             if ($temp instanceof admin_settingpage) {
                 $this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n";
             } else {
                 if ($temp instanceof admin_externalpage) {
                     $this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n";
                 }
             }
         }
         $this->content->text .= "</ol>\n";
     } else {
         $bookmarks = array();
     }
     // TODO
     if (isset($this->page->section) and $this->page->section == 'search') {
         // the search page can't be properly bookmarked at present
         $this->content->footer = '';
     } else {
         if (($section = isset($this->page->section) ? $this->page->section : '') && in_array($section, $bookmarks)) {
             $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&amp;sesskey=' . sesskey() . '">' . get_string('unbookmarkthispage', 'admin') . '</a>';
         } else {
             if ($section = isset($this->page->section) ? $this->page->section : '') {
                 $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&amp;sesskey=' . sesskey() . '">' . get_string('bookmarkthispage', 'admin') . '</a>';
             } else {
                 $this->content->footer = '';
             }
         }
     }
     return $this->content;
 }
function useredit_load_preferences(&$user, $reload = true)
{
    global $USER;
    if (!empty($user->id)) {
        if ($reload and $USER->id == $user->id) {
            // reload preferences in case it was changed in other session
            unset($USER->preference);
        }
        if ($preferences = get_user_preferences(null, null, $user->id)) {
            foreach ($preferences as $name => $value) {
                $user->{'preference_' . $name} = $value;
            }
        }
    }
}
예제 #26
0
 function definition()
 {
     global $USER, $CFG, $COURSE;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id', $USER->id);
     $mform->addElement('text', 'username', get_string('username'), array('readonly' => 'readonly'));
     $mform->setDefault('username', $USER->username);
     $mform->addRule('username', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('text', 'firstname', get_string('firstname'), array('readonly' => 'readonly'));
     $mform->setDefault('firstname', $USER->firstname);
     $mform->addRule('firstname', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('text', 'lastname', get_string('lastname'), array('readonly' => 'readonly'));
     $mform->setDefault('lastname', $USER->lastname);
     $mform->addRule('lastname', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('text', 'pass1', get_string('newpassword'));
     $mform->addElement('text', 'pass2', get_string('newpassword') . ' (' . get_String('again') . ')');
     if (get_user_preferences('auth_forcepasswordchange')) {
         $mform->addRule('pass1', get_string('required'), 'required', '', 'client', false, false);
         $mform->addRule('pass2', get_string('required'), 'required', '', 'client', false, false);
     }
     $mform->addElement('text', 'email', get_string('email'));
     $mform->setDefault('email', $USER->email);
     $mform->addRule('email', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('email', get_string('invalidemail'), 'email', '', 'client', false, false);
     $mform->addElement('text', 'msn', get_string('msnid'));
     $mform->setDefault('msn', $USER->msn);
     $mform->addRule('msn', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('msn', get_string('invalidemail'), 'email', '', 'client', false, false);
     $mform->addElement('date_selector', 'icq', get_string('icqnumber'), array('startyear' => 1920, 'stopyear' => 2020, 'timezone' => 99, 'step' => 5));
     $mform->setDefault('icq', $USER->icq);
     $mform->addRule('icq', get_string('required'), 'required', '', 'client', false, false);
     $mform->addElement('text', 'phone1', get_string('phone'));
     $mform->setDefault('phone1', $USER->phone1);
     $mform->addRule('phone1', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('phone1', get_string('isnumber', 'report_user'), 'numeric', '', 'client', false, false);
     $mform->addElement('text', 'yahoo', get_string('yahooid'));
     $mform->setDefault('yahoo', $USER->yahoo);
     // $mform->addRule('yahoo', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('yahoo', get_string('isnumber', 'report_user'), 'numeric', '', 'client', false, false);
     $mform->addElement('text', 'phone2', get_string('phone2'));
     $mform->setDefault('phone2', $USER->phone2);
     //$mform->addRule('phone2', get_string('required'), 'required', '', 'client', false, false);
     $mform->addRule('phone2', get_string('isnumber', 'report_user'), 'numeric', '', 'client', false, false);
     $mform->addElement('file', 'picture', get_string('userpic'));
     $mform->addElement('submit', 'save', get_string('savechanges'));
 }
예제 #27
0
/**
 * This functions parses all the events, and creates one iCal
 * (.ics) file per course, storing them in the folder specified in the
 * module's configuration.
 * ToDo: site's events.
 */
function ical_parse()
{
    global $CFG;
    // Retrieves all the courses
    $courses = get_records_sql('SELECT *, 1 FROM ' . $CFG->prefix . 'course');
    // First, we must check if the path to store the iCal files exists...
    if (empty($CFG->ical_path)) {
        set_config('ical_path', 'webdav');
    }
    $webdav_dir = $CFG->dirroot . '/' . $CFG->ical_path;
    if (is_dir($webdav_dir)) {
        // Now, for each course...
        foreach ($courses as $course) {
            $count = get_record_sql('SELECT *, 1 FROM ' . $CFG->prefix . 'event WHERE courseid=' . $course->id);
            if (!empty($count) && $course->id != 0 && ($fp = @fopen($webdav_dir . '/' . $course->shortname . '.ics', "w"))) {
                // Write the header
                $write = fwrite($fp, "BEGIN:VCALENDAR\nVERSION\n :2.0\nPRODID\n :-//Moodle.org//NONSGML iCal Module v0.1 beta//EN");
                // expect creating/modifying the course file
                $events = calendar_get_upcoming(array(0 => $course->id), $groups, $users, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
                // For all the events in the current course
                foreach ($events as $event) {
                    // If the event is visible
                    if ($event->visible) {
                        $write = fwrite($fp, "\nBEGIN:VEVENT\nUID\n :" . $event->id . "-" . $event->timestart . "\nSUMMARY\n :" . $event->name . "\nCATEGORIES\n :" . $course->fullname . "\nSTATUS\n :CONFIRMED\nCLASS\n :PUBLIC\nDESCRIPTION:" . $event->description);
                        // We check if it has a stablished duration
                        if ($event->timeduration != 0) {
                            // It does: we print the event time information, with the duration
                            $write = fwrite($fp, "\nDTSTART\n :" . gmdate("Ymd\\THis\\Z", $event->timestart) . "\nDTEND\n :" . gmdate("Ymd\\THis\\Z", $event->timestart + $event->timeduration));
                        } else {
                            // However, if it doesn't, we assume that the event lasts 24hrs
                            $write = fwrite($fp, "\nDTSTART\n ;VALUE=DATE\n :" . gmdate("Ymd", $event->timestart) . "\nDTEND\n ;VALUE=DATE\n :" . gmdate("Ymd", $event->timestart + 86400));
                        }
                        // And now for the timestamp and we finish this event
                        $write = fwrite($fp, "\nDTSTAMP\n :" . gmdate("Ymd\\THis\\Z", $event->timemodified) . "\nEND:VEVENT");
                    }
                }
                // This calendar file (course file) has ended :)
                $write = fwrite($fp, "\nEND:VCALENDAR");
                fclose($fp);
            }
        }
    } else {
        echo 'The directory ' . $webdav_dir . ' is not valid.';
    }
}
예제 #28
0
 /**
  * Format a time in the current user's timezone.
  * @param int $date a timestamp
  * @return string printable time
  */
 public static function usertime($date)
 {
     if ($date == 0) {
         return '';
     } else {
         $timeformat = get_user_preferences('calendar_timeformat');
         // Get user config.
         if (empty($timeformat)) {
             $timeformat = get_config(null, 'calendar_site_timeformat');
             // Get calendar config if above not exist.
         }
         if (empty($timeformat)) {
             $timeformat = get_string('strftimetime');
             //Get locale default format if both of the above do not exist.
         }
         return userdate($date, $timeformat);
     }
 }
예제 #29
0
 public function __remove($bookmarkurl, $title, $tokenval)
 {
     global $CFG, $DB;
     $bookmarkurl = htmlspecialchars_decode($bookmarkurl);
     $title = htmlspecialchars_decode($title);
     $response = new CliniqueServiceResponce();
     $token_val = array('token' => $tokenval);
     // Get user token
     /**
      * @get user id from external_tokens table
      *
      */
     $userId = array_values($DB->get_records_sql('SELECT userid FROM {external_tokens} et WHERE et.token=?', $token_val));
     if ($userId) {
         $user_id = array('id' => $userId[0]->userid);
         //if(confirm_sesskey()){
         $user = array_values($DB->get_records_sql('SELECT * FROM {user} u WHERE u.id=?', $user_id));
         Favorites::__fav_user_login($user['0']);
         $bookmarks = explode(',', get_user_preferences('user_bookmarks'));
         $bookmarkremoved = false;
         foreach ($bookmarks as $bookmark) {
             // check the bookmarkurl and title given values to delete from preference
             $tempBookmark = explode(';', $bookmark);
             if ($tempBookmark[0] == $bookmarkurl && $tempBookmark[1] == $title) {
                 $keyToRemove = array_search($bookmark, $bookmarks);
                 unset($bookmarks[$keyToRemove]);
                 $bookmarkremoved = true;
             }
         }
         if ($bookmarkremoved == false) {
             $response->response(true, 'The bookmark you requested does not exist');
             die;
         }
         $bookmarks = implode(',', $bookmarks);
         set_user_preference('user_bookmarks', $bookmarks);
         global $CFG;
         //header("Location: " . $CFG->wwwroot . $bookmarkurl);
         $response->response(false, 'Removed Favorite Successfully');
         die;
     } else {
         $response->response(true, 'Invalid user');
         die;
     }
 }
예제 #30
0
파일: lib.php 프로젝트: JP-Git/moodle
    /**
     * Constructor
     *
     * @param int $repositoryid
     * @param stdClass $context
     * @param array $options
     */
    public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
        parent::__construct($repositoryid, $context, $options);
        $this->api_key = $this->get_option('api_key');
        $this->setting_prefix = 'boxnet_';

        $this->auth_token = get_user_preferences($this->setting_prefix.'_auth_token', '');
        $this->logged = false;
        if (!empty($this->auth_token)) {
            $this->logged = true;
        }
        // already logged
        if(!empty($this->logged)) {
            if(empty($this->boxclient)) {
                $this->boxclient = new boxclient($this->api_key, $this->auth_token);
            }
        } else {
            $this->boxclient = new boxclient($this->api_key);
        }
    }