function get_content() {
        global $USER,$DB;
        if ($this->content !== NULL) {
            return $this->content;
        }
	$this->content = new stdClass();
	$this->content->items = array();
	$is_manager = $DB->record_exists_sql("select cp.* from {local_costcenter_permissions} as cp 
                             JOIN {role_assignments} as ra ON ra.userid=cp.userid and cp.userid=$USER->id
                             JOIN {role} as r ON r.id=ra.roleid
                             where r.archetype='manager'");
	$is_teammanager = $DB->record_exists('local_teammanager_employee', array('teammanagerid'=>$USER->id));
	if($is_manager || is_siteadmin())
	$link = array(html_writer::link(new moodle_url('/local/users/index.php'),get_string('pluginname','local_users')));
	if(is_siteadmin())
	$link[] =  html_writer::link(new moodle_url('/local/costcenter/index.php'),get_string('pluginname','local_costcenter'));
        
	if($is_manager || is_siteadmin())
	$link[] =  html_writer::link(new moodle_url('/local/teammanager/index.php'),get_string('pluginname', 'local_teammanager'));
	if($is_teammanager && !is_siteadmin())
	$link[] =  html_writer::link(new moodle_url('/local/teammanager/myteam.php'),get_string('viewmyteam', 'local_teammanager'));
	if($is_manager || is_siteadmin())
	$link[] = html_writer::link(new moodle_url('/local/costcenter/courses.php'),get_string('course'));
	$this->content->items =  $link;
	$this->content->icons = '';
        $this->content->footer = '';
        return $this->content;
    }
Example #2
1
/**
 * Adds module specific settings to the settings block.
 *
 * @param settings_navigation $settings The settings navigation object
 * @param stdClass $context The node context
 */
function local_loginas_extends_settings_navigation(settings_navigation $settings, $context)
{
    global $DB, $CFG, $PAGE, $USER;
    // Course id and context.
    $courseid = !empty($PAGE->course->id) ? $PAGE->course->id : SITEID;
    $coursecontext = context_course::instance($courseid);
    // Must have the loginas capability.
    if (!has_capability('moodle/user:loginas', $coursecontext)) {
        return;
    }
    // Set the settings category.
    $loginas = $settings->add(get_string('loginas'));
    // Login as list by admin setting.
    if (is_siteadmin($USER)) {
        // Admin settings page.
        $url = new moodle_url('/admin/settings.php', array('section' => 'localsettingloginas'));
        $loginas->add(get_string('settings'), $url, $settings::TYPE_SETTING);
        // Users list.
        $loginasusers = array();
        // Since 2.6, use all the required fields.
        $ufields = 'id, ' . get_all_user_name_fields(true);
        // Get users by id.
        if ($configuserids = get_config('local_loginas', 'loginasusers')) {
            $userids = explode(',', $configuserids);
            if ($users = $DB->get_records_list('user', 'id', $userids, '', $ufields)) {
                $loginasusers = $users;
            }
        }
        // Get users by username.
        if ($configusernames = get_config('local_loginas', 'loginasusernames')) {
            $usernames = explode(',', $configusernames);
            if ($users = $DB->get_records_list('user', 'username', $usernames, '', $ufields)) {
                $loginasusers = $loginasusers + $users;
            }
        }
        // Add action links for specified users.
        if ($loginasusers) {
            $params = array('id' => $courseid, 'sesskey' => sesskey());
            foreach ($loginasusers as $userid => $lauser) {
                $url = new moodle_url('/course/loginas.php', $params);
                $url->param('user', $userid);
                $loginas->add(fullname($lauser, true), $url, $settings::TYPE_SETTING);
            }
        }
    }
    // Course users login as.
    if (!($configcourseusers = get_config('local_loginas', 'courseusers'))) {
        return;
    }
    $loggedinas = \core\session\manager::is_loggedinas();
    if (!$loggedinas) {
        // Ajax link.
        $node = $loginas->add(get_string('courseusers', 'local_loginas'), 'javascript:void();', $settings::TYPE_SETTING);
        $node->add_class('local_loginas_setting_link');
        local_loginas_require_js($PAGE);
    }
}
Example #3
0
    public function get_content() {
    global $CFG,$USER;    
    
    if ($this->content !== null) {
      return $this->content;
    }   
    if(!isloggedin()){
        return $this->content;
    }
    
    $this->content =  new stdClass;
    $systemcontext = context_system::instance();

    $usercontext = context_user::instance($USER->id);
      

    if(has_capability('local/gradeletter:manage', $usercontext) || is_siteadmin() ){		 
    $this->content->text=array();
    $icon = html_writer::empty_tag('img',array('src'=>$CFG->wwwroot.'/pix/i/navigationitem.png'));
    $this->content->text[]=html_writer::tag('a',$icon.get_string('addbatch','block_managebatches'),array('href' =>$CFG->wwwroot.'/local/batches/index.php'));
    //$this->content->text[]=html_writer::empty_tag('br');
    $this->content->text[]=html_writer::tag('a',$icon.get_string('assignbatch','block_managebatches'), array('href' =>$CFG->wwwroot.'/local/batches/bulk_enroll.php?mode=new'));
    //$this->content->text[]=html_writer::empty_tag('br');
    $this->content->text[]=html_writer::tag('a',$icon.get_string('enrolbatch','block_managebatches'), array('href' => $CFG->wwwroot.'/local/batches/bulk_enroll.php?mode=exists')); 
    //$this->content->text[]=html_writer::empty_tag('br');
 //   $this->content->text[]=html_writer::tag('a',$icon.get_string('reports','block_managebatches') , array('href' => $CFG->wwwroot.'/admin/index.php?cache=1')); 
    
    $this->content->text=implode('',$this->content->text);
     return $this->content;
    }    
    
    else
     return $this->content;    
   
  }
Example #4
0
 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     global $CFG, $COURSE, $USER;
     $this->content = new stdClass();
     $this->content->icons = array();
     $this->content->items = array();
     $this->content->footer = '';
     list($source, $cap) = $this->permissions($COURSE);
     if (!$cap) {
         return $this->content;
     }
     //We're in a global section, so we change our links
     $global = $source == 'system';
     $cps_user = CoursePrefsUser::findByUnique($USER->username);
     // If the cps user is valid, and they are in the teaching role in their course
     $can_report = ($cps_user and $cps_user->getSectionsForMoodleCourse($COURSE) or is_siteadmin($USER->id));
     if (!$global and $can_report) {
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/email.gif"/>';
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_reporting/select.php?id=' . $COURSE->id . '">' . get_string('select', 'block_student_reporting') . '</a>';
     }
     $this->content->icons[] = '';
     $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/analysis.php' . ($global ? '' : '?id=' . $COURSE->id) . '">' . get_string('analysis', 'block_student_gradeviewer') . '</a>';
     if (!empty($CFG->cas_email) and $cps_user and $cps_user->getSectionsInfoAsTeacher()) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/options.php?id=' . $COURSE->id . '">' . get_string('options', 'block_student_gradeviewer') . '</a>';
     }
     return $this->content;
 }
    public function definition() {
        global $USER, $CFG, $DB;
        $mform = $this->_form;
        $enrol = $this->_customdata['enrolid'];
        if(is_siteadmin())
        $costcenterid = $DB->get_field_sql('select costcenter from {course} as  c join  {enrol} as e ON c.id=e.courseid  where e.id='.$enrol.'');
        
        if(!is_siteadmin())
        $costcenterid = $DB->get_field('local_userdata','costcenterid',array('userid'=>$USER->id));
        
        $sql = 'select distinct(lp.id) as position_key,lp.fullname as position_value from {local_positions} as lp JOIN {local_userdata} as ud ON lp.id=ud.position where ud.position!="" AND ud.costcenterid='.$costcenterid.'';
        $position_list = $DB->get_records_sql_menu($sql);
        $mform->addElement('select', 'position', get_string('positions', 'local_costcenter'),  $position_list, array('multiple' => 'multiple','class'=>'filter_drop'));
        $mform->setType('position', PARAM_RAW);

        $batch_list = $DB->get_records_sql_menu('select id as name_key,name as name_value from {cohort} where id in(select batchid from {local_costcenter_batch} where costcenterid='.$costcenterid.')');
        $mform->addElement('select', 'batch', get_string('batch', 'local_costcenter'),  $batch_list, array('multiple' => 'multiple','class'=>'filter_drop'));
        $mform->setType('batch', PARAM_INT);
        
         $skillset_list = $DB->get_records_sql_menu('select distinct(skillset) as skillset_key,skillset as skillset_value from {local_userdata} where skillset!="" and costcenterid='.$costcenterid.'');
         $mform->addElement('select', 'skillset', get_string('skillset', 'local_costcenter'),  $skillset_list, array('multiple' => 'multiple','class'=>'filter_drop'));
        $mform->setType('skillset', PARAM_RAW);

        $sub_skillset_list = $DB->get_records_sql_menu('select distinct(subskillset) as sub_skillset_key,subskillset as sub_skillset_value from {local_userdata} where subskillset!="" and costcenterid='.$costcenterid.'');
        $mform->addElement('select', 'sub_skillset', get_string('subskillset', 'local_costcenter'), $sub_skillset_list, array('multiple' => 'multiple','class'=>'filter_drop'));
        $mform->setType('sub_skillset', PARAM_RAW);

        $mform->addElement('hidden','enrolid');
        $mform->setType('enrolid',PARAM_INT);
        $mform->setDefault('enrolid',$enrol);
        $this->add_action_buttons('true', 'Filter');
    }
function insert_analytics_tracking()
{
    global $PAGE, $OUTPUT;
    $trackadmin = false;
    $cleanurl = false;
    if (isset($PAGE->theme->settings->analyticstrackingid)) {
        $trackingid = $PAGE->theme->settings->analyticstrackingid;
    }
    if (isset($PAGE->theme->settings->analyticstrackadmin)) {
        $trackadmin = $PAGE->theme->settings->analyticstrackadmin;
    }
    if (isset($PAGE->theme->settings->analyticscleanurl)) {
        $cleanurl = $PAGE->theme->settings->analyticscleanurl;
    }
    $tracking = '';
    if ($cleanurl) {
        $addition = "{'hitType' : 'pageview',\n            'page' : " . analytics_trackurl() . ",\n            'title' : '" . addslashes($PAGE->heading) . "'\n            }";
    } else {
        $addition = "'pageview'";
    }
    if (!is_siteadmin() || $trackadmin) {
        $tracking = "\n            <script>\n            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n            })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n            ga('create', '" . $trackingid . "', {'siteSpeedSampleRate': 50});\n            ga('send', " . $addition . ");\n\n            </script>";
    }
    return $tracking;
}
Example #7
0
 /**
  * Check whether the filter matches the specified tour and/or context.
  *
  * @param   tour        $tour       The tour to check
  * @param   context     $context    The context to check
  * @return  boolean
  */
 public static function filter_matches(tour $tour, context $context)
 {
     global $USER;
     $values = $tour->get_filter_values(self::get_filter_name());
     if (empty($values)) {
         // There are no values configured.
         // No values means all.
         return true;
     }
     if (is_siteadmin()) {
         return true;
     }
     // Presence within the array is sufficient. Ignore any value.
     $values = array_flip($values);
     $cache = \cache::make_from_params(\cache_store::MODE_REQUEST, 'tool_usertours', 'filter_role');
     $cachekey = "{$USER->id}_{$context->id}";
     $userroles = $cache->get($cachekey);
     if ($userroles === false) {
         $userroles = get_user_roles_with_special($context);
         $cache->set($cachekey, $userroles);
     }
     foreach ($userroles as $role) {
         if (isset($values[$role->roleid])) {
             return true;
         }
     }
     return false;
 }
Example #8
0
 /**
  * Form definition.
  *
  * @return void
  */
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->disable_form_change_checker();
     $mform->addElement('header', 'search', get_string('search', 'search'));
     // Help info depends on the selected search engine.
     $mform->addElement('text', 'q', get_string('enteryoursearchquery', 'search'));
     $mform->addHelpButton('q', 'searchinfo', $this->_customdata['searchengine']);
     $mform->setType('q', PARAM_TEXT);
     $mform->addRule('q', get_string('required'), 'required', null, 'client');
     $mform->addElement('header', 'filtersection', get_string('filterheader', 'search'));
     $mform->setExpanded('filtersection', false);
     $mform->addElement('text', 'title', get_string('title', 'search'));
     $mform->setType('title', PARAM_TEXT);
     $search = \core_search\manager::instance();
     $searchareas = \core_search\manager::get_search_areas_list(true);
     $areanames = array();
     foreach ($searchareas as $areaid => $searcharea) {
         $areanames[$areaid] = $searcharea->get_visible_name();
     }
     // Sort the array by the text.
     \core_collator::asort($areanames);
     $options = array('multiple' => true, 'noselectionstring' => get_string('allareas', 'search'));
     $mform->addElement('autocomplete', 'areaids', get_string('searcharea', 'search'), $areanames, $options);
     $options = array('multiple' => true, 'limittoenrolled' => !is_siteadmin(), 'noselectionstring' => get_string('allcourses', 'search'));
     $mform->addElement('course', 'courseids', get_string('courses', 'core'), $options);
     $mform->setType('courseids', PARAM_INT);
     $mform->addElement('date_time_selector', 'timestart', get_string('fromtime', 'search'), array('optional' => true));
     $mform->setDefault('timestart', 0);
     $mform->addElement('date_time_selector', 'timeend', get_string('totime', 'search'), array('optional' => true));
     $mform->setDefault('timeend', 0);
     $this->add_action_buttons(false, get_string('search', 'search'));
 }
Example #9
0
function insert_analytics_tracking() {
    global $CFG;
    $enabled = get_config('local_analytics', 'enabled');
    $siteid = get_config('local_analytics', 'siteid');
    $trackadmin = get_config('local_analytics', 'trackadmin');
    $cleanurl = get_config('local_analytics', 'cleanurl');
    $location = "additionalhtml" . get_config('local_analytics', 'location');

    if ($enabled && (!is_siteadmin() || $trackadmin)) {
        $CFG->$location .= "
            <script type='text/javascript' name='localga'>
              var _gaq = _gaq || [];
              _gaq.push(['_setAccount', '" . $siteid . "']);
              _gaq.push(['_trackPageview'," . ($cleanurl ? analytics_trackurl() : '') . "]);
              _gaq.push(['_setSiteSpeedSampleRate', 50]);

              (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; 
                ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
              })();
            </script>
			";
    }
}
Example #10
0
 public function search($q, $courseID = 0, $removeHiddenResults = false)
 {
     if (strlen($q) < 2) {
         return array('error' => get_string('error_query_too_short', 'block_search', 2));
     }
     raise_memory_limit(MEMORY_UNLIMITED);
     //Check if user cached results exist
     $userCacheValidFor = (int) get_config('block_search', 'cache_results_per_user');
     $useUserCache = $userCacheValidFor > 0;
     if (is_siteadmin()) {
         $useUserCache = false;
     }
     if ($useUserCache) {
         $cacheKey = md5(json_encode(array($q, $courseID, $removeHiddenResults)));
         $userCache = cache::make('block_search', 'user_searches');
         if ($results = $userCache->get($cacheKey)) {
             if ($results['filtered'] > time() - (int) $userCacheValidFor) {
                 $results['userCached'] = true;
                 return $results;
             }
         }
     }
     $search = new Search($q, $courseID);
     $search->filterResults($removeHiddenResults);
     $results = $search->getResults();
     if ($useUserCache) {
         $userCache->set($cacheKey, $results);
     }
     return $results;
 }
Example #11
0
function insert_analytics_tracking() {
    global $CFG, $PAGE;
    $enabled = get_config('local_analytics', 'enabled');
    $siteid = get_config('local_analytics', 'siteid');
    $trackadmin = get_config('local_analytics', 'trackadmin');
    $cleanurl = get_config('local_analytics', 'cleanurl');
    $location = "additionalhtml" . get_config('local_analytics', 'location');

    if ($cleanurl) {
        $addition = "{'hitType' : 'pageview',
            'page' : " . analytics_trackurl() . ",
            'title' : '" . addslashes($PAGE->heading) . "'
            }";
    } else {
        $addition = "'pageview'";
    }


    if ($enabled && (!is_siteadmin() || $trackadmin)) {
        $CFG->$location .= "   
            <script>
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
            ga('create', '" . $siteid . "', {'siteSpeedSampleRate': 50});
            ga('send', " . $addition . ");
			
            </script>
			";
    }
}
Example #12
0
 /**
  * Observe the events, and dispatch them if necessary.
  *
  * @param \core\event\base $event The event.
  * @return void
  */
 public static function observer(\core\event\base $event)
 {
     if ($event->component === 'block_xp') {
         // Skip own events.
     } else {
         if (!$event->userid || isguestuser($event->userid) || is_siteadmin($event->userid)) {
             // Skip non-logged in users and guests.
         } else {
             if ($event->contextlevel !== CONTEXT_COURSE && $event->contextlevel !== CONTEXT_MODULE) {
                 // Ignore events outside a course.
             } else {
                 if ($event->edulevel !== \core\event\base::LEVEL_PARTICIPATING) {
                     // Ignore events that are not participating.
                 } else {
                     if (!has_capability('block/xp:earnxp', $event->get_context(), $event->userid)) {
                         // Skip the events if the user does not have the capability to earn XP, or if it is the admin.
                     } else {
                         // Keep the event, and proceed.
                         $manager = block_xp_manager::get($event->courseid);
                         $manager->capture_event($event);
                     }
                 }
             }
         }
     }
 }
Example #13
0
 function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (!isloggedin()) {
         return $this->content;
     }
     if (is_siteadmin()) {
         return $this->content;
     }
     //this block is for students
     $usercontext = context_user::instance($USER->id);
     if (!has_capability('local/clclasses:enrollclass', $usercontext)) {
         return $this->content;
     }
     // Prep the content
     $this->content = new stdClass();
     require_once 'academic_status.php';
     //$id=optional_param('id',5,PARAM_INT);
     $events = get_semslist();
     $this->content->text = $events;
     return $this->content;
     // Prepare the footer for this block
     // No footer to display
     $this->content->footer = '';
     // Return the content object
     return $this->content;
 }
Example #14
0
function theme_essential_insert_analytics_tracking()
{
    $siteurl = \theme_essential\toolbox::get_setting('analyticssiteurl');
    $tracking = '';
    if (!empty($siteurl)) {
        $imagetrack = \theme_essential\toolbox::get_setting('analyticsimagetrack');
        $siteid = \theme_essential\toolbox::get_setting('analyticssiteid');
        $trackadmin = \theme_essential\toolbox::get_setting('analyticstrackadmin');
        $cleanurl = \theme_essential\toolbox::get_setting('analyticscleanurl');
        if ($imagetrack) {
            $addition = '<noscript><p><img src="//' . $siteurl . '/piwik.php?idsite=' . $siteid . '" style="border:0" alt="" /></p></noscript>';
        } else {
            $addition = '';
        }
        if ($cleanurl) {
            $doctitle = "_paq.push(['setDocumentTitle', " . theme_essential_analytics_trackurl() . "]);";
        } else {
            $doctitle = "";
        }
        if (!is_siteadmin() || $trackadmin) {
            $tracking = "<script type='text/javascript'>\n                    var _paq = _paq || [];\n                    " . $doctitle . "\n                    _paq.push(['enableLinkTracking']);\n                    _paq.push(['trackPageView']);\n                    (function(){\n                        var u=(('https:' == document.location.protocol) ? 'https' : 'http') + '://" . $siteurl . "/';\n                        _paq.push(['setSiteId', " . $siteid . "]);\n                        _paq.push(['setTrackerUrl', u+'piwik.php']);\n                        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';\n                        s.parentNode.insertBefore(g,s);\n                    })();\n                </script>\n                " . $addition;
        }
    }
    return $tracking;
}
 /**
  * Triggered via the user_loggedin event, when a user logs in.
  *
  * @param stdClass $event
  */
 public static function user_loggedin($event)
 {
     global $DB;
     $eventdata = $event->get_data();
     if (!enrol_is_enabled('auto')) {
         return;
     }
     if (is_siteadmin($eventdata['userid'])) {
         // Don't enrol site admins
         return;
     }
     // Get all courses that have an auto enrol plugin, set to auto enrol on login, where the user isn't enrolled yet
     $sql = "SELECT e.courseid\n            FROM {enrol} e\n            LEFT JOIN {user_enrolments} ue ON e.id = ue.enrolid AND ue.userid = ?\n            WHERE e.enrol = 'auto'\n            AND e.status = ?\n            AND e.customint3 = ?\n            AND ue.id IS NULL";
     if (!($courses = $DB->get_records_sql($sql, array($eventdata['userid'], ENROL_INSTANCE_ENABLED, ENROL_AUTO_LOGIN)))) {
         return;
     }
     $autoplugin = enrol_get_plugin('auto');
     foreach ($courses as $course) {
         if (!($instance = $autoplugin->get_instance_for_course($course->courseid))) {
             continue;
         }
         $autoplugin->enrol_user($instance, $eventdata['userid'], $instance->roleid);
         // Send welcome message.
         if ($instance->customint2) {
             $autoplugin = enrol_get_plugin('auto');
             $autoplugin->email_welcome_message($instance, $DB->get_record('user', array('id' => $eventdata['userid'])));
         }
     }
 }
Example #16
0
 function definition()
 {
     global $DB, $CFG, $USER;
     $mform = $this->_form;
     $instance = $this->_customdata;
     $examid = $instance['examid'];
     $debug = $instance['debug'];
     // Exam totalpages goes hidden as well
     $mform->addElement('hidden', 'exam', $examid);
     $mform->setType('exam', PARAM_INT);
     // Exam totalpages goes hidden as well
     $mform->addElement('hidden', 'debug', $debug);
     $mform->setType('debug', PARAM_BOOL);
     $mform->addElement('header', 'selectprinter', get_string('selectprinter', 'mod_emarking'));
     if (is_siteadmin($USER)) {
         $sqlprinters = "SELECT p.id, p.name\n\t\t\t\t\tFROM {emarking_printers} as p";
         $printersarray = $DB->get_records_sql($sqlprinters);
     } else {
         $sqlprinters = "SELECT p.id, p.name\n\t\t\t\t\tFROM {emarking_printers} as p \n\t\t\t\t\tINNER JOIN {emarking_users_printers} as up ON (p.id = up.id_printer)\n\t\t\t\t\tWHERE up.id_user = ?";
         $printersarray = $DB->get_records_sql($sqlprinters, array($USER->id));
     }
     $selectprinters = array();
     foreach ($printersarray as $printer) {
         $selectprinters[$printer->id] = $printer->name;
     }
     // Extra sheets per student
     $mform->addElement('select', 'printername', get_string('printername', 'mod_emarking'), $selectprinters, null);
     $mform->addHelpButton('printername', 'printername', 'mod_emarking');
     // buttons
     $this->add_action_buttons(true, get_string('submit'));
 }
Example #17
0
function block_queries_display_view($USER,$instructorlogin,$registrarlogin,$studentlogin){
     global $CFG, $USER, $PAGE, $DB;
     $blockqueries_returncontent = array();
           $sql ="SELECT * FROM {block_queries} WHERE userid = $USER->id";
     if(is_siteadmin($USER->id)){
          $sql .=" AND userrole = 'admin' ORDER BY id DESC LIMIT 3";
          $blockqueries_returncontent[]=blockqueries_tablecontent($sql);
          $blockqueries_returncontent = implode('',$blockqueries_returncontent);
     }
     elseif(!empty($instructorlogin) ){
        $sql .=" AND userrole = 'instructor' ORDER BY id DESC LIMIT 3";
        $blockqueries_returncontent[]=blockqueries_tablecontent($sql);
        $blockqueries_returncontent = implode('',$blockqueries_returncontent);
     }
     elseif(!empty($registrarlogin)){
        $sql .=" AND userrole = 'registrar' ORDER BY id DESC LIMIT 3";
        $blockqueries_returncontent[]=blockqueries_tablecontent($sql);
        $blockqueries_returncontent = implode('',$blockqueries_returncontent);
     }
     elseif(!empty($studentlogin)){
        $formdata = new stdClass();
        $actionpage = $CFG->wwwroot.'/blocks/queries/sendingemail.php';
        $mform= new block_queries_form($actionpage);
        $blockqueries_returncontent[] = $mform->render();  //to display form in block
        $blockqueries_returncontent = implode('',$blockqueries_returncontent);
   }
     else {
          $blockqueries_returncontent[] = html_writer:: tag('p',get_string('noprevioussubjects','block_queries'),array());  
     }
     return $blockqueries_returncontent;
} // end of function 
 public function call_success()
 {
     global $USER, $COURSE, $CFG;
     if (empty($this->_xmlresponse)) {
         if (is_siteadmin($USER->id)) {
             notice(get_string('adminemptyxml', 'adobeconnect'), $CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
         } else {
             notice(get_string('emptyxml', 'adobeconnect'), '', $COURSE);
         }
     }
     $dom = new DomDocument();
     $dom->loadXML($this->_xmlresponse);
     $domnodelist = $dom->getElementsByTagName('status');
     if ($domnodelist->item(0)->hasAttributes()) {
         $domnode = $domnodelist->item(0)->attributes->getNamedItem('code');
         if (!is_null($domnode)) {
             if (0 == strcmp('ok', $domnode->nodeValue)) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function definition() {
     global $USER,$DB;
     $mform = & $this->_form;
      $id = $this->_customdata['id'];
     if (!isset($errors))
         $errors = array();
      /*
      * EA_NK23-02-2015
      * Added cost center field
      */
     $costcenters = array();
     $is_manager = $DB->record_exists_sql("SELECT ra.userid
                                             FROM {role_assignments} as ra
                                             JOIN {role} as r ON ra.roleid=r.id
                                            WHERE r.archetype='manager' AND ra.userid={$USER->id}");
         if($id>0){
          $batchname = $DB->get_field_sql("SELECT c.fullname FROM {local_costcenter} as c JOIN {learning_learningplan} as lp ON c.id=lp.costcenter AND lp.id=$id");
          $mform->addElement('static', 'costcenterid', get_string('pluginname', 'local_costcenter'), $batchname);
     }if(is_siteadmin()){
     $costcenters = $DB->get_records_select_menu('local_costcenter','',null,'id','id,fullname');
     $mform->addElement('select', 'costcenter', get_string('pluginname', 'local_costcenter'), $costcenters);        
     }elseif ($is_manager) {
        /* code for training manager capable of handling one or more departments - code added by sreenivas*/
         $costcenterslists = $DB->get_records_sql("SELECT cc.* FROM {local_costcenter_permissions} ccp JOIN {local_costcenter} cc ON ccp.costcenterid=cc.id WHERE ccp.userid={$USER->id}");
         if (!$costcenterslists)
         print_error('notassignedcostcenter', 'local_costcenter'); // code by sreenivas 27/10/2015
         $costarray = array();
         foreach ($costcenterslists as $costcenterslist) {
             $costarray[$costcenterslist->id] = $costcenterslist->fullname;
         }
          $mform->addElement('select', 'costcenter', get_string('pluginname', 'local_costcenter'), $costarray);
          /*end of code - sreenivas*/
     //$costcenter = $DB->get_record_sql("SELECT cc.* FROM {local_costcenter_permissions} ccp JOIN {local_costcenter} cc ON ccp.costcenterid=cc.id WHERE ccp.userid={$USER->id}");
     //$mform->addElement('hidden','costcenter');
     //$mform->setDefault('costcenter',$costcenter->id);
     //$mform->addElement('static', 'costcenterid', get_string('pluginname', 'local_costcenter'), $costcenter->fullname);
     }else{
     $costcenters = $DB->get_records_sql_menu("SELECT cc.id,cc.fullname FROM {local_userdata} ud JOIN {local_costcenter} cc ON ud.costcenterid=cc.id WHERE ud.userid={$USER->id}");
     $mform->addElement('hidden','costcenter');
     $mform->setDefault('costcenter',$costcenter->id);
     $mform->addElement('static', 'costcenterid', get_string('pluginname', 'local_costcenter'), $costcenter->fullname);
     }
     $mform->setType('costcenter', PARAM_RAW);
     $mform->addElement('text', 'learning_plan', get_string('fullnamelp', 'block_learning_plan'));
     $mform->addRule('learning_plan', null, 'required', null, 'server');
     $mform->setType('learning_plan', PARAM_TEXT);
     $mform->addElement('text', 'shortname', get_string('shortnamelp','block_learning_plan'), 'maxlength="100" size="20"');
     //$mform->addHelpButton('shortname', 'shortnamelp');
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_TEXT);
     $attributes = array('rows' => '8', 'cols' => '40');
     $mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes);
     $mform->setType('description', PARAM_TEXT);
      $mform->addElement('date_selector', 'startdate', get_string('startdate','block_learning_plan'),array('optional'=>true));
     $mform->addElement('date_selector', 'enddate', get_string('enddate','block_learning_plan'),array('optional'=>true));
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $this->add_action_buttons();
 }
 public function test_set_admin_user()
 {
     global $USER;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $this->assertEquals($USER->id, 2);
     $this->assertTrue(is_siteadmin());
 }
function report_ktreeuserdedicationreport_extends_navigation(global_navigation $navigation)
{
    $url6 = '/report/ktreeuserdedicationreport/adminreport.php';
    if (is_siteadmin()) {
        $nodeForm3 = $navigation->add('Ktree\'s User Dedication');
        $nodeForm = $nodeForm3->add('Dedication Report', $url6);
    }
}
Example #22
0
 function hash()
 {
     $cap = "mod/filter:censor";
     if (is_siteadmin()) {
         //TODO: add proper access control
         $cap = "mod/filter:seecensor";
     }
     return $cap;
 }
    function get_content() {
        global $CFG, $OUTPUT, $USER, $COURSE,$DB;
        
        require_once($CFG->dirroot.'/message/lib.php');
		require_once($CFG->dirroot.'/blocks/userinfo/lib.php');
        
        if ($this->content !== NULL) {
            return $this->content;
        }

        $this->content = new stdClass;
        $this->content->text = '';
		if(is_siteadmin()){
			$this->content->text.= '<div class="userinfoblock">';
			$this->content->text.= '<div class="userinfo_details">';
			$this->content->text.= "<a>".fullname($USER,true)."</a>";
			$this->content->text.="<br>";
            $this->content->text.= $OUTPUT->user_picture($USER, array('size' => 100, 'class' => 'userinfoblockimg'));
			
//            $this->content->text.= $OUTPUT->user_picture($USER, array('size' => 100, 'class' => 'userinfoblockimg'));
//			$this->content->text.= "<br/><a href=\"$CFG->wwwroot/user/profile.php?id=$USER->id\">".fullname($USER,true)."</a>";
//            //$this->content->text.= "<br/><a href=\"$CFG->wwwroot/user/profile.php?id=$USER->id\">".fullname($USER,true)."</a>&nbsp;"
//            //        ."(<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
			$user = $DB->get_record_sql("SELECT * FROM {user} WHERE id = $USER->id");
		    $this->content->text.= html_writer::tag('p',$user->email,array());
			$this->content->text.= '</div>';
			
			$this->content->text.=  html_writer::start_tag('div',array('class'=>'profile_icon'));
			$this->content->text.=  html_writer::start_tag('div',array('class'=>'profile_row_left'));
			$icon = html_writer::empty_tag('img', array('title' => 'Upload picture', 'alt' => 'Upload picture', 'src' => $CFG->wwwroot.'/blocks/userinfo/pix/upload_image.png'));
			$this->content->text.= html_writer::tag('a',$icon,array('href'=> $CFG->wwwroot.'/local/upload_picture/index.php?id='.$USER->id));
			//$this->content->text.=  html_writer::tag('a',get_string('edit_picture','block_userinfo'),array('href'=> $CFG->wwwroot.'/user/edit.php?id='.$USER->id));
			
			$this->content->text.=  html_writer::end_tag('div',array('class'=>'profile_row_left'));
			$this->content->text.=  html_writer::start_tag('div',array('class'=>'profile_row_center'));
			$icon = html_writer::empty_tag('img', array('title' => 'Message', 'alt' => 'Message', 'src' => $CFG->wwwroot.'/blocks/userinfo/pix/message.png'));
			$this->content->text.= html_writer::tag('a',$icon,array('href'=> $CFG->wwwroot.'/local/mail/view.php?t='));
			//$this->content->text.=  html_writer::tag('a',get_string('messages','block_userinfo'),array('href'=> $CFG->wwwroot.'/local/mail/view.php?t='));
			$this->content->text.=  html_writer::end_tag('div',array('class'=>'profile_row_center'));
			
			$this->content->text.= html_writer::start_tag('div',array('class'=>'profile_row_right'));
			$icon = html_writer::empty_tag('img', array('title' => 'My private files', 'alt' => 'My private files', 'src' => $CFG->wwwroot.'/blocks/userinfo/pix/myprivatefiles.png'));
			$this->content->text.= html_writer::tag('a',$icon,array('href'=> $CFG->wwwroot.'/user/files.php'));
			$this->content->text.= html_writer::end_tag('div',array('class'=>'profile_row_right'));
			
			$this->content->text.=  html_writer::end_tag('div',array('class'=>'profile_icon'));
			$this->content->text.= '</div>';
		} else{
			$this->content->text.= '<div class="userinfoblock">';
			$data =  block_profile_view();
			$this->content->text.= $data;
			$this->content->text.= '</div>';
		}
        $this->content->footer = '';
        return $this->content;
    }
Example #24
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;
        global $hierarchy;
        $mform = $this->_form;
        $PAGE->requires->yui_module('moodle-local_cobaltcourses-equivalent', 'M.local_cobaltcourses.init_equivalent', array(array('formid' => $mform->getAttribute('id'))));
        /* ---the schools which are assigned to the registrar--- */
        $school = $hierarchy->get_assignedschools();
        if (is_siteadmin())
            $school = $hierarchy->get_school_items();
        $parents = $hierarchy->get_school_parent($school);
        $count = count($school);

        $mform->addElement('header', 'settingsheader', get_string('precourse', 'local_cobaltcourses'));
        $mform->addElement('hidden', 'count', $count);
        $mform->setType('count', PARAM_INT);
        if ($count == 1) {
            /* ---if only one school is assigned show the school as static--- */
            foreach ($school as $scl) {
                $key = $scl->id;
                $value = $scl->fullname;
            }
            $mform->addElement('static', 'schools', get_string('schoolid', 'local_collegestructure'), $value);
            $mform->addElement('hidden', 'schoolid', $key);
            $mform->setType('schoolid', PARAM_INT);
            $department = $hierarchy->get_departments_forschool($key);
            $mform->addElement('select', 'departmentid', get_string('selectdepartment', 'local_cobaltcourses'), $department);
            $mform->addRule('departmentid', get_string('missingdepartment', 'local_cobaltcourses'), 'required', null, 'client');

            $mform->addElement('hidden', 'addcourselisthere1');
            $mform->setType('addcourselisthere1', PARAM_RAW);
            $mform->addElement('select', 'predeptid', get_string('predept', 'local_cobaltcourses'), $department);
            $mform->addRule('predeptid', get_string('missingdepartment', 'local_cobaltcourses'), 'required', null, 'client');

            $mform->addElement('hidden', 'addcourselisthere2');
            $mform->setType('addcourselisthere2', PARAM_RAW);
        } else {
            $mform->addElement('select', 'schoolid', get_string('select', 'local_collegestructure'), $parents);
            $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', 0, 'client');
        }

        $mform->addElement('hidden', 'addcourselisthere3');
        $mform->setType('addcourselisthere3', PARAM_RAW);
        $mform->addElement('hidden', 'addcourselisthere4');
        $mform->setType('addcourselisthere4', PARAM_RAW);

        $mform->registerNoSubmitButton('updatecourseformat');
        $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));

        $mform->addElement('hidden', 'addcourselisthere5');
        $mform->setType('addcourselisthere5', PARAM_RAW);
        $mform->addElement('hidden', 'addcourselisthere6');
        $mform->setType('addcourselisthere6', PARAM_RAW);

        $submitlable = get_string('precourse', 'local_cobaltcourses');
        $this->add_action_buttons($cancel = true, $submitlable);
    }
Example #25
0
 /**
  * Returns an array of available schools
  * @return array of availble schools
  */
 function get_school_list() {
     global $hierarchy;
     $schoollist = $hierarchy->get_assignedschools();
     if (is_siteadmin()) {
         $schoollist = $hierarchy->get_school_items();
     }
     $schoollist = $hierarchy->get_school_parent($schoollist, $selected = array(), $inctop = false, $all = false);
     $schools = array(0 => get_string('anyschool', 'local_collegestructure')) + $schoollist;
     return $schools;
 }
Example #26
0
/**
 * Test whether the id is that of an admin user
 *
 * @return bool true or false
 */
function ilp_is_siteadmin($userid)
{
    global $CFG;
    if (stripos($CFG->release, "2.") !== false) {
        return is_siteadmin($userid);
    } else {
        $sitecontext = get_context_instance(CONTEXT_SYSTEM);
        return has_capability('moodle/site:doanything', $sitecontext);
    }
}
Example #27
0
function forum_user_is_mod($fid)
{
    if (is_siteadmin()) {
        return true;
    }
    if (1 == db_result(db_query("SELECT COUNT(*) FROM prefix_forummods WHERE uid = " . $_SESSION['authid'] . " AND fid = " . $fid), 0)) {
        return true;
    }
    return false;
}
 /**
  * Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
  *
  * @param int|\stdClass $userorid ID of the user.
  * @return bool True if the user can view the event, false otherwise.
  */
 public function can_view($userorid = null)
 {
     global $USER;
     if (empty($userorid)) {
         $userorid = $USER;
     }
     if ($this->other['anonymous'] == FEEDBACK_ANONYMOUS_YES) {
         return is_siteadmin($userorid);
     } else {
         return has_capability('mod/feedback:viewreports', $this->context, $userorid);
     }
 }
 /**
  * Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
  *
  * @deprecated since 2.7
  *
  * @param int|\stdClass $userorid ID of the user.
  * @return bool True if the user can view the event, false otherwise.
  */
 public function can_view($userorid = null)
 {
     global $USER;
     debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER);
     if (empty($userorid)) {
         $userorid = $USER;
     }
     if ($this->anonymous) {
         return is_siteadmin($userorid);
     } else {
         return has_capability('mod/feedback:viewreports', $this->context, $userorid);
     }
 }
    function print_filter(&$mform) {
        global $DB, $CFG,$USER;

        $filter_trainers = optional_param('filter_trainers', '', PARAM_RAW);

        $reportclassname = 'report_' . $this->report->type;
        $reportclass = new $reportclassname($this->report);
  
        

        if ($this->report->type != 'sql') {
            if(is_siteadmin()){
				$category_user='';
			}else{
				$category_user=$DB->get_field('local_userdata','lms_category',array('userid'=>$USER->id));
			}
			 $sql="SELECT trainerid as id ,
					(select CONCAT(us.firstname,us.lastname) from {user} us where us.id=trainerid ) as username
					FROM {facetoface} where category='$category_user' group by trainerid";
            $trainerslist =$DB->get_records_sql($sql);
        } else {
			if(is_siteadmin()){
				$category_user='';
			}else{
				$category_user=$DB->get_field('local_userdata','lms_category',array('userid'=>$USER->id));
			}
			 $sql="SELECT trainerid as id ,
					(select CONCAT(us.firstname,us.lastname) from {user} us where us.id=trainerid ) as username
					FROM {facetoface} where category='$category_user' group by trainerid";
            $trainerslist =$DB->get_records_sql($sql);
        }

        $trainerslistoptions = array();
        $trainerslistoptions[0] = get_string('filter_all', 'block_cobalt_reports');

          if (!empty($trainerslist)) {
          //list($usql, $params) = $DB->get_in_or_equal($trainerslist);        
           
      //   if(is_siteadmin() || is_ast_nh()){
             //$trainers = $DB->get_records_select('user', "id $usql", $params);
			 //$trainerss = $DB->get_records_sql("select id,trainers_code, trainers from {local_userdata} group by trainers_code");
     //    }
	 //print_object($trainerslist);
			foreach ($trainerslist as $record) { 			
			$trainerslistoptions[$record->id] =$record->username;
            }
   }

        $mform->addElement('select', 'filter_trainers', get_string('filtertrainers', 'block_cobalt_reports'), $trainerslistoptions);
        $mform->setType('filter_trainers', PARAM_RAW);
    }