public function get_content()
 {
     global $USER, $CFG, $DB, $OUTPUT, $SESSION;
     // Only display if you have the correct capability.
     if (!iomad::has_capability('block/iomad_company_admin:company_add', context_system::instance())) {
         return;
     }
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     if (!isloggedin()) {
         $this->content->text = get_string('pleaselogin', 'block_iomad_company_selector');
         return $this->content;
     }
     //  Check users session and profile settings to get the current editing company.
     if (!empty($SESSION->currenteditingcompany)) {
         $selectedcompany = $SESSION->currenteditingcompany;
     } else {
         if (!empty($USER->profile->company)) {
             $usercompany = company::by_userid($USER->id);
             $selectedcompany = $usercompany->id;
         } else {
             $selectedcompany = "";
         }
     }
     // Get the company name if set.
     if (!empty($selectedcompany)) {
         $companyname = company::get_companyname_byid($selectedcompany);
     } else {
         $companyname = "";
     }
     // Get a list of companies.
     $companylist = company::get_companies_select();
     $select = new single_select(new moodle_url('/local/iomad_dashboard/index.php'), 'company', $companylist, $selectedcompany);
     $select->label = get_string('selectacompany', 'block_iomad_company_selector');
     $select->formid = 'choosecompany';
     $fwselectoutput = html_writer::tag('div', $OUTPUT->render($select), array('id' => 'iomad_company_selector'));
     $this->content->text = $OUTPUT->container_start('companyselect');
     if (!empty($SESSION->currenteditingcompany)) {
         $this->content->text .= '<h3>' . get_string('currentcompany', 'block_iomad_company_selector') . ' - ' . $companyname . '</h3>';
     } else {
         $this->content->text .= '<h3>' . get_string('nocurrentcompany', 'block_iomad_company_selector') . '</h3>';
     }
     $this->content->text .= $fwselectoutput;
     $this->content->text .= $OUTPUT->container_end();
     return $this->content;
 }
 /**
  * Form tweaks that depend on current data.
  */
 public function definition_after_data()
 {
     global $USER, $SESSION;
     $mform =& $this->_form;
     $columns =& $this->_customdata;
     foreach ($columns as $column) {
         if ($mform->elementExists($column)) {
             $mform->removeElement($column);
         }
     }
     // Set the companyid to bypass the company select form if possible.
     if (!empty($SESSION->currenteditingcompany)) {
         $companyid = $SESSION->currenteditingcompany;
     } else {
         $companyid = company_user::companyid();
     }
     // Get the department list.
     $parentlevel = company::get_company_parentnode($companyid);
     if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', context_system::instance())) {
         $userhierarchylevel = $parentlevel->id;
     } else {
         $userlevel = company::get_userlevel($USER);
         $userhierarchylevel = $userlevel->id;
     }
     $this->departmentid = $userhierarchylevel;
     $subhierarchieslist = company::get_all_subdepartments($userhierarchylevel);
     //  Department drop down.
     $mform->insertElementBefore($mform->createElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $subhierarchieslist, $userhierarchylevel), 'uutypelabel');
     $this->courseselector = $this->add_course_selector();
     $this->add_action_buttons(true, get_string('uploadusers', 'tool_uploaduser'));
 }
Esempio n. 3
1
 /**
  * Checks that a two user id's are in the same company.
  *
  * Parameters - 
  *              $userid = int;
  *
  * Returns boolean.
  *
  * */
 public static function check_can_manage($userid)
 {
     global $DB, $USER;
     $context = context_system::instance();
     // Set the companyid
     $companyid = iomad::get_my_companyid($context);
     // Get the list of users.
     $myusers = self::get_my_users($companyid);
     // If the user is in the list, return true.
     if (!empty($myusers[$userid])) {
         return true;
     }
     // Return a false by default.
     return false;
 }
 public function __construct($actionurl, $context, $companyid, $departmentid, $licenseid, $courses = array())
 {
     global $USER;
     $this->selectedcompany = $companyid;
     $this->context = $context;
     $this->departmentid = $departmentid;
     $this->licenseid = $licenseid;
     $this->selectedcourses = $courses;
     $company = new company($this->selectedcompany);
     $parentlevel = company::get_company_parentnode($company->id);
     $this->companydepartment = $parentlevel->id;
     if (iomad::has_capability('block/iomad_company_admin:edit_licenses', context_system::instance())) {
         $userhierarchylevel = $parentlevel->id;
     } else {
         $userlevel = company::get_userlevel($USER);
         $userhierarchylevel = $userlevel->id;
     }
     $this->subhierarchieslist = company::get_all_subdepartments($userhierarchylevel);
     if ($this->departmentid == 0) {
         $departmentid = $userhierarchylevel;
     } else {
         $departmentid = $this->departmentid;
     }
     $options = array('context' => $this->context, 'multiselect' => true, 'companyid' => $this->selectedcompany, 'departmentid' => $departmentid, 'subdepartments' => $this->subhierarchieslist, 'parentdepartmentid' => $parentlevel, 'selected' => $this->selectedcourses, 'license' => true);
     $this->currentcourses = new all_department_course_selector('currentcourselicense', $options);
     parent::moodleform($actionurl);
 }
 public function __construct($actionurl, $context, $companyid, $departmentid, $userid, $licenseid)
 {
     global $USER, $DB;
     $this->selectedcompany = $companyid;
     $this->context = $context;
     $company = new company($this->selectedcompany);
     $this->parentlevel = company::get_company_parentnode($company->id);
     $this->companydepartment = $this->parentlevel->id;
     $this->licenseid = $licenseid;
     if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', context_system::instance())) {
         $userhierarchylevel = $this->parentlevel->id;
     } else {
         $userlevel = company::get_userlevel($USER);
         $userhierarchylevel = $userlevel->id;
     }
     $this->subhierarchieslist = company::get_all_subdepartments($userhierarchylevel);
     if ($departmentid == 0) {
         $this->departmentid = $userhierarchylevel;
     } else {
         $this->departmentid = $departmentid;
     }
     $this->userid = $userid;
     $this->user = $DB->get_record('user', array('id' => $this->userid));
     parent::__construct($actionurl);
 }
    public function definition_after_data()
    {
        global $USER;
        $mform =& $this->_form;
        // Adding the elements in the definition_after_data function rather than in the definition function
        // so that when the currentmanagers or potentialmanagers get changed in the process function, the
        // changes get displayed, rather than the lists as they are before processing.
        $company = new company($this->selectedcompany);
        $managertypes = $company->get_managertypes();
        $mform->addElement('header', 'header', get_string('company_managers_for', 'block_iomad_company_admin', $company->get_name()));
        $mform->addElement('select', 'deptid', get_string('department', 'block_iomad_company_admin'), $this->subhierarchieslist);
        $mform->addHelpButton('deptid', 'department', 'block_iomad_company_admin');
        $mform->addElement('select', 'managertype', get_string('managertype', 'block_iomad_company_admin'), $managertypes);
        $mform->addHelpButton('managertype', 'managertype', 'block_iomad_company_admin');
        if (iomad::has_capability('block/iomad_company_admin:company_add', context_system::instance())) {
            // This user can add other managers to this company.
            $mform->addElement('selectyesno', 'showothermanagers', get_string('showothermanagers', 'block_iomad_company_admin'));
            $mform->disabledIf('showothermanagers', 'managertype', 'neq', '1');
            $mform->addHelpButton('showothermanagers', 'showothermanagers', 'block_iomad_company_admin');
        } else {
            $mform->addElement('hidden', 'showothermanagers', 0);
        }
        $mform->addElement('submit', 'updateselection', get_string('updatedepartmentusersselection', 'block_iomad_company_admin'));
        if (count($this->potentialusers->find_users('')) || count($this->currentusers->find_users(''))) {
            $mform->addElement('html', '<table summary=""
                                        class="companymanagertable addremovetable generaltable generalbox boxaligncenter"
                                        cellspacing="0">
                <tr>
                  <td id="existingcell">');
            $mform->addElement('html', $this->currentusers->display(true));
            $mform->addElement('html', '
                  </td>
                  <td id="buttonscell">
                      <div id="addcontrols">
                          <input name="add" id="add" type="submit" value="&#x25C4;&nbsp;' . get_string('add') . '" title="Add" /><br />

                      </div>

                      <div id="removecontrols">
                          <input name="remove" id="remove" type="submit" value="' . get_string('remove') . '&nbsp;&#x25BA;" title="Remove" />
                      </div>
                  </td>
                  <td id="potentialcell">');
            $mform->addElement('html', $this->potentialusers->display(true));
            $mform->addElement('html', '
                  </td>
                </tr>
              </table>');
        } else {
            $mform->addElement('html', get_string('nousers', 'block_iomad_company_admin') . ' <a href="' . new moodle_url('/blocks/iomad_company_admin/company_user_create_form.php?companyid=' . $this->selectedcompany) . '">Create one now</a>');
        }
    }
Esempio n. 7
0
function theme_gourmet_get_html_for_settings(renderer_base $output, moodle_page $page)
{
    global $CFG, $USER, $DB;
    $return = new stdClass();
    $return->navbarclass = '';
    if (!empty($page->theme->settings->invert)) {
        $return->navbarclass .= ' navbar-inverse';
    }
    // get logos
    $theme = $page->theme;
    $logo = $theme->setting_file_url('logo', 'logo');
    if (empty($logo)) {
        $logo = $CFG->wwwroot . '/theme/gourmet/pix/gourmet_logo.png';
    }
    $clientlogo = '';
    $companycss = '';
    if ($companyid = iomad::is_company_user()) {
        $context = context_system::instance();
        if ($files = $DB->get_records('files', array('contextid' => $context->id, 'component' => 'theme_gourmet', 'filearea' => 'companylogo', 'itemid' => $companyid))) {
            // print_object($files);
            foreach ($files as $file) {
                if ($file->filename != '.') {
                    $clientlogo = $CFG->wwwroot . "/pluginfile.php/{$context->id}/theme_gourmet/companylogo/{$companyid}/{$file->filename}";
                }
            }
        }
        company_user::load_company();
        $companycss = ".header, .navbar { background: [[company:bgcolor_header]]; }\n                       .block .content { background: [[company:bgcolor_content]]; }";
        foreach ($USER->company as $key => $value) {
            if (isset($value)) {
                $companycss = preg_replace("/\\[\\[company:{$key}\\]\\]/", $value, $companycss);
            }
        }
    }
    /*
        $return->heading = '<div id="sitelogo">' . 
            '<a href="' . $CFG->wwwroot . '" ><img src="' . $logo . '" /></a></div>';
        $return->heading .= '<div id="siteheading">' . $output->page_heading() . '</div>';
    */
    if ($clientlogo) {
        $return->heading .= '<div id="clientlogo">' . '<a href="' . $CFG->wwwroot . '" ><img src="' . $clientlogo . '" /></a></div>';
    }
    $return->footnote = '';
    if (!empty($page->theme->settings->footnote)) {
        $return->footnote = '<div class="footnote text-center">' . $page->theme->settings->footnote . '</div>';
    }
    $return->companycss = $companycss;
    return $return;
}
 public function get_content()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     // Only display if you have the correct capability.
     if (!iomad::has_capability('block/iomad_link:view', context_system::instance())) {
         return;
     }
     if ($this->content !== null) {
         return $this->content;
     }
     $strlink = get_string('link', 'block_iomad_link');
     $this->content = new stdClass();
     $this->content->text = "<center><a href=\"{$CFG->wwwroot}/local/iomad_dashboard/index.php\">\n                                <img src=\"{$CFG->wwwroot}/blocks/iomad_link/image/iomad_logo.png\" /></a></center>";
     $this->content->text .= "<center><b><a href=\"{$CFG->wwwroot}/local/iomad_dashboard/index.php\">{$strlink}</a></b></center>";
     $this->content->footer = '';
     return $this->content;
 }
 public function get_content()
 {
     global $SITE, $CFG, $OUTPUT;
     if ($this->content !== null) {
         return $this->content;
     }
     if (!iomad::has_capability('block/iomad_reports:view', $this->context)) {
         return $this->content;
     }
     // Title.
     $this->content = new stdClass();
     $this->content->text = '<h3>' . get_string('pluginname', 'block_iomad_reports') . "</h3>\n";
     // Get all local/report_*.
     $reports = $this->getreportpaths();
     // Loop over reports.
     $this->content->text .= '<div class="iomadlink_container clearfix">';
     foreach ($reports as $report) {
         if (iomad::has_capability("local/{$report}:view", $this->context)) {
             $imgsrc = $OUTPUT->pix_url('logo', "local_{$report}");
             $url = new moodle_url("/local/{$report}/index.php");
             $name = get_string('pluginname', "local_{$report}");
             $icon = '<img src="' . $imgsrc . '" alt="' . $name . '" /><br />';
             // Report link html.
             // $this->content->text .= '<div class="iomadlink">';
             // $this->content->text .= "<a href=\"$url\">" . $icon . $name. "</a>";
             // $this->content->text .= '</div>';
             // Put together link.
             $this->content->text .= "<a href=\"{$url}\">";
             $this->content->text .= '<div class="iomadlink">';
             if ($CFG->theme == 'bootstrap') {
                 $this->content->text .= '<div class="iomadicon"><div class="fa fa-topic fa-bar-chart-o"> </div>';
             } else {
                 $this->content->text .= '<div class="iomadicon">' . $icon;
             }
             $this->content->text .= '<div class="actiondescription">' . $name . "</div>";
             $this->content->text .= '</div>';
             $this->content->text .= '</a>';
             $this->content->text .= '</div>';
         }
     }
     $this->content->text .= '</div>';
     // A clearfix for the floated linked.
     $this->content->text .= '<div class="clearfix"></div>';
     return $this->content;
 }
 public function __construct($actionurl, $companyid, $departmentid)
 {
     global $CFG, $USER;
     $this->selectedcompany = $companyid;
     $this->context = context_coursecat::instance($CFG->defaultrequestcategory);
     $syscontext = context_system::instance();
     $company = new company($this->selectedcompany);
     $parentlevel = company::get_company_parentnode($company->id);
     $this->companydepartment = $parentlevel->id;
     if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', $syscontext)) {
         $userhierarchylevel = $parentlevel->id;
     } else {
         $userlevel = company::get_userlevel($USER);
         $userhierarchylevel = $userlevel->id;
     }
     $this->departmentid = $userhierarchylevel;
     parent::moodleform($actionurl);
 }
 public function get_content()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     // Only display if you have the correct capability.
     if (!iomad::has_capability('block/iomad_report_scheduler:view', context_system::instance())) {
         return;
     }
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '<div id="iomad_report_scheduler" style="width: 100%; height: 200px; position:relative;
                             margin: 0 auto; overflow: hidden">';
     $this->content->text .= '<div id="iomad_report_scheduler_main1" style="width: 100%; height: 200px; position:relative;
                             margin: 0 auto; ">
                             <h3>Iomad Report Scheduler</h3></br>';
     $this->content->text .= '<a id="ELDMSRS" href="' . new moodle_url('/blocks/iomad_report_scheduler/reports_view.php') . '"><img src="' . new moodle_url('/blocks/iomad_report_scheduler/images/report.png') . '"></br>View Reports</a>';
     return $this->content;
 }
 public function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     // Then show the fields about where this block appears.
     //
     // code by sumit
     $returnurl = optional_param('returnurl', '', PARAM_LOCALURL);
     $mform->addElement('hidden', 'companyid', $this->selectedcompany);
     $mform->setType('companyid', PARAM_INT);
     $mform->addElement('hidden', 'returnurl', $returnurl);
     $mform->setType('returnurl', PARAM_LOCALURL);
     // code by sumit end
     $mform->addElement('header', 'header', get_string('companycourse', 'block_iomad_company_admin'));
     $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
     $mform->addHelpButton('fullname', 'fullnamecourse');
     $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_MULTILANG);
     $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
     $mform->addHelpButton('shortname', 'shortnamecourse');
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_MULTILANG);
     // Create course as self enrolable.
     if (iomad::has_capability('block/iomad_company_admin:edit_licenses', context_system::instance())) {
         $selectarray = array(get_string('selfenrolled', 'block_iomad_company_admin'), get_string('enrolled', 'block_iomad_company_admin'), get_string('licensedcourse', 'block_iomad_company_admin'));
     } else {
         $selectarray = array(get_string('selfenrolled', 'block_iomad_company_admin'), get_string('enrolled', 'block_iomad_company_admin'));
     }
     $select =& $mform->addElement('select', 'selfenrol', get_string('enrolcoursetype', 'block_iomad_company_admin'), $selectarray);
     $mform->addHelpButton('selfenrol', 'enrolcourse', 'block_iomad_company_admin');
     $select->setSelected('no');
     $mform->addElement('editor', 'summary_editor', get_string('coursesummary'), null, $this->editoroptions);
     $mform->addHelpButton('summary_editor', 'coursesummary');
     $mform->setType('summary_editor', PARAM_RAW);
     // Add action buttons.
     $buttonarray = array();
     $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('createcourse', 'block_iomad_company_admin'));
     $buttonarray[] =& $mform->createElement('submit', 'submitandviewbutton', get_string('createandvisitcourse', 'block_iomad_company_admin'));
     $buttonarray[] =& $mform->createElement('cancel');
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     $mform->closeHeaderBefore('buttonar');
 }
 public function __construct($actionurl, $companyid, $departmentid)
 {
     global $CFG, $USER;
     $this->selectedcompany = $companyid;
     $this->context = context_coursecat::instance($CFG->defaultrequestcategory);
     $syscontext = context_system::instance();
     $company = new company($this->selectedcompany);
     $parentlevel = company::get_company_parentnode($company->id);
     $this->companydepartment = $parentlevel->id;
     if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', $syscontext)) {
         $userhierarchylevel = $parentlevel->id;
     } else {
         $userlevel = company::get_userlevel($USER);
         $userhierarchylevel = $userlevel->id;
     }
     $this->departmentid = $userhierarchylevel;
     $region = company::get_my_region($userhierarchylevel);
     $mylocationlist = company::get_my_location($userhierarchylevel);
     if ($region || $mylocationlist || $userhierarchylevel == $parentlevel->id) {
         redirect(new moodle_url('/blocks/iomad_company_admin/company_department_create_form.php'));
     }
     parent::moodleform($actionurl);
 }
Esempio n. 14
0
 /**
  * Display capabilities for role
  */
 public function capabilities($capabilities, $roleid, $companyid)
 {
     global $DB;
     // get heading
     $company = $DB->get_record('company', array('id' => $companyid), '*', MUST_EXIST);
     $role = $DB->get_record('role', array('id' => $roleid), '*', MUST_EXIST);
     $out = '<h3>' . get_string('restrictcapabilitiesfor', 'block_iomad_company_admin', $company->name) . '</h3>';
     $out .= '<p><b>' . get_string('rolename', 'block_iomad_company_admin', $role->name) . '</b></p>';
     $out .= '<p>' . get_string('iomadcapabilities_boiler', 'block_iomad_company_admin') . '</p>';
     $table = new html_table();
     foreach ($capabilities as $capability) {
         $checked = '';
         if (!$capability->iomad_restriction) {
             $checked = 'checked="checked"';
         }
         $value = "{$companyid}.{$roleid}.{$capability->capability}";
         $caplink = '<a href="' . iomad::documentation_link() . $capability->capability . '">' . get_capability_string($capability->capability) . '</a>';
         $row = array($caplink . '<br /><small>' . $capability->capability . '</small>', '<input class="checkbox" type="checkbox" ' . $checked . ' value="' . $value . '" />' . get_string('allow'));
         $table->data[] = $row;
     }
     $out .= html_writer::table($table);
     return $out;
 }
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once '../../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->dirroot . '/blocks/iomad_company_admin/lib.php';
global $DB, $CFG, $PAGE, $OUTPUT, $SESSION;
$companyid = optional_param('companyid', 0, PARAM_INT);
$context = context_system::instance();
iomad::require_capability('block/iomad_company_admin:manageallcompany', $context);
$PAGE->set_context($context);
$PAGE->set_pagetype('my-index');
$PAGE->set_pagelayout('admin');
$PAGE->set_url(new moodle_url('/local/company_navigation/manage_company.php'));
require_login();
$linktext = get_string('managecompanies', 'block_iomad_company_admin');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_company_admin/editcompanies.php');
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
echo $OUTPUT->header();
$companyids = $DB->get_records_menu('company', array(), 'id, name');
//$companyids['none'] = get_string('nocompany', 'block_iomad_company_admin');
$companyids[''] = get_string('selectacompany', 'block_iomad_company_admin');
ksort($companyids);
$companyselect = new single_select(new moodle_url('/local/company_navigation/manage_company.php'), 'companyid', $companyids, $companyid);
$companyselect->label = get_string('company', 'block_iomad_company_admin');
$companyselect->formid = 'choosecompany';
 public function definition()
 {
     global $CFG, $PAGE, $DB;
     $context = context_system::instance();
     $mform =& $this->_form;
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'companyid', $this->companyid);
     $mform->setType('companyid', PARAM_INT);
     //GWL
     $mform->addElement('hidden', 'returnurl', $this->returnurl);
     $mform->setType('returnurl', PARAM_LOCALURL);
     // //
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'header', get_string('company', 'block_iomad_company_admin'));
     $mform->addElement('text', 'name', get_string('companyname', 'block_iomad_company_admin'), array('size' => 50));
     $mform->setType('name', PARAM_NOTAGS);
     $mform->addRule('name', $strrequired, 'required');
     $mform->addElement('text', 'shortname', get_string('companyshortname', 'block_iomad_company_admin'), array('size' => 25));
     $mform->setType('shortname', PARAM_NOTAGS);
     $mform->addRule('shortname', $strrequired, 'required');
     $mform->addElement('text', 'city', get_string('companycity', 'block_iomad_company_admin'), array('size' => 50));
     $mform->setType('city', PARAM_NOTAGS);
     $mform->addRule('city', $strrequired, 'required');
     /* copied from user/editlib.php */
     $choices = get_string_manager()->get_list_of_countries();
     $choices = array('' => get_string('selectacountry') . '...') + $choices;
     $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
     $mform->addRule('country', $strrequired, 'required', null, 'client');
     if (!empty($CFG->country)) {
         $mform->setDefault('country', $CFG->country);
     }
     $mform->addElement('text', 'companydomains', get_string('companydomains', 'block_iomad_company_admin'), array('display' => 'noofficial'));
     //GWL : Change textarea to text
     $mform->setType('companydomains', PARAM_NOTAGS);
     /* === User defaults === */
     /*GWL : Remove User Default */
     /*
     $mform->addElement('header', 'userdefaults', get_string('userdefaults', 'block_iomad_company_admin'));
     
     $choices = array();
     $choices['0'] = get_string('emaildisplayno');
     $choices['1'] = get_string('emaildisplayyes');
     $choices['2'] = get_string('emaildisplaycourse');
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     
     $choices = array();
     $choices['0'] = get_string('textformat');
     $choices['1'] = get_string('htmlformat');
     $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
     $mform->setDefault('mailformat', 1);
     
     $choices = array();
     $choices['0'] = get_string('emaildigestoff');
     $choices['1'] = get_string('emaildigestcomplete');
     $choices['2'] = get_string('emaildigestsubjects');
     $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
     $mform->setDefault('maildigest', 0);
     
     $choices = array();
     $choices['1'] = get_string('autosubscribeyes');
     $choices['0'] = get_string('autosubscribeno');
     $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
     $mform->setDefault('autosubscribe', 1);
     
     if (!empty($CFG->forum_trackreadposts)) {
         $choices = array();
         $choices['0'] = get_string('trackforumsno');
         $choices['1'] = get_string('trackforumsyes');
         $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
         $mform->setDefault('trackforums', 0);
     }
     
     $editors = editors_get_enabled();
     if (count($editors) > 1) {
         $choices = array();
         $choices['0'] = get_string('texteditor');
         $choices['1'] = get_string('htmleditor');
         $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
         $mform->setDefault('htmleditor', 1);
     } else {
         $mform->addElement('hidden', 'htmleditor');
         $mform->setDefault('htmleditor', 1);
         $mform->setType('htmleditor', PARAM_INT);
     }
     
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     if ($CFG->forcetimezone != 99) {
         $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
     } else {
         $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
         $mform->setDefault('timezone', '99');
     }
     
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
     $mform->setDefault('lang', $CFG->lang);
     */
     /*GWL : Remove User Default */
     /* === end user defaults === */
     // Only show the Appearence section if the theme is iomad or you have abilities
     // to change that.
     //GWL : To add company logo for each theme
     if (iomad::has_capability('block/iomad_company_admin:company_edit', $context)) {
         //||
         //$this->companyrecord->theme == 'iomad' || $this->companyrecord->theme == 'bootstrap') {
         $mform->addElement('header', 'appearance', get_string('appearance', 'block_iomad_company_admin'));
         // If has the edit all companies capability we want to add a theme selector.
         if (iomad::has_capability('block/iomad_company_admin:company_edit', $context)) {
             // Get the list of themes.
             $themes = get_plugin_list('theme');
             $themeselectarray = array();
             foreach ($themes as $themename => $themedir) {
                 // Load the theme config.
                 try {
                     $theme = theme_config::load($themename);
                 } catch (Exception $e) {
                     // Bad theme, just skip it for now.
                     continue;
                 }
                 if ($themename !== $theme->name) {
                     // Obsoleted or broken theme, just skip for now.
                     continue;
                 }
                 if (!$CFG->themedesignermode && $theme->hidefromselector) {
                     // The theme doesn't want to be shown in the theme selector and as theme
                     // designer mode is switched off we will respect that decision.
                     continue;
                 }
                 // Build the theme selection list.
                 $themeselectarray[$themename] = $themename;
             }
             $mform->addElement('select', 'theme', get_string('selectatheme', 'block_iomad_company_admin'), $themeselectarray);
             $mform->disabledIf('theme', '', 'neq', '1');
             /* GWL : Make Default Theme Field Disable */
         } else {
             $mform->addElement('hidden', 'theme', $this->companyrecord->theme);
             $mform->setType('theme', PARAM_TEXT);
         }
         // If theme is already set to a real theme, dont show this.
         if (!isset($this->companyrecord->theme)) {
             $this->companyrecord->theme = 'gourmet';
             /* GWL : Set Default theme Gourmet */
         }
         /* GWL : Remove Message while setuping Company */
         // if ($this->companyrecord->theme == 'iomad' || $this->companyrecord->theme == 'bootstrap') {
         /* $mform->addElement('HTML', get_string('theoptionsbelow',
             'block_iomad_company_admin'));
            */
         /* GWL : Remove Message while setuping Company */
         $mform->addElement('filemanager', 'companylogo', get_string('companylogo', 'block_iomad_company_admin'), null, array('subdirs' => 0, 'maxbytes' => 150 * 1024, 'maxfiles' => 1, 'accepted_types' => array('*.jpg', '*.gif', '*.png')));
         /* GWL : Remove Header Background Colour & Content Background Colour field while creating New Company */
         /*
          $this->add_colour_picker('bgcolor_header', array('selector' => '.header,.navbar',
          'style' => 'background'));
          $this->add_colour_picker('bgcolor_content', array('selector' => '.block .content',
          'style' => 'background'));
         */
         /* GWL : Remove Header Background Colour & Content Background Colour field while creating New Company */
         $mform->disabledIf('id_bgcolor_header', 'usedefaulttheme', 'checked');
         $mform->disabledIf('id_bgcolor_content', 'usedefaulttheme', 'checked');
         /* } else {
            $mform->addElement('hidden', 'id_companylogo', $this->companyrecord->companylogo);
            $mform->addElement('hidden', 'companylogo', $this->companyrecord->companylogo);
            $mform->addElement('hidden', 'id_bgcolor_header',
            $this->companyrecord->bgcolor_header);
            $mform->addElement('hidden', 'id_bgcolor_content',
            $this->companyrecord->bgcolor_content);
            $mform->setType('companylogo', PARAM_CLEAN);
            $mform->setType('id_companylogo', PARAM_CLEAN);
            $mform->setType('id_bgcolor_header', PARAM_CLEAN);
            $mform->setType('id_bgcolor_content', PARAM_CLEAN);
            } */
     } else {
         $mform->addElement('hidden', 'theme', $this->companyrecord->theme);
         $mform->setType('theme', PARAM_TEXT);
         $mform->addElement('hidden', 'companylogo', $this->companyrecord->companylogo);
         $mform->setType('companylogo', PARAM_CLEAN);
         $mform->addElement('hidden', 'bgcolor_header', $this->companyrecord->bgcolor_header);
         $mform->addElement('hidden', 'bgcolor_content', $this->companyrecord->bgcolor_content);
     }
     $mform->setType('bgcolor_header', PARAM_CLEAN);
     $mform->setType('bgcolor_content', PARAM_CLEAN);
     $submitlabel = null;
     // Default.
     if ($this->isadding) {
         $submitlabel = get_string('saveasnewcompany', 'block_iomad_company_admin');
         $mform->addElement('hidden', 'createnew', 1);
         $mform->setType('createnew', PARAM_INT);
     }
     $this->add_action_buttons(true, $submitlabel);
 }
$linkurl = new moodle_url('/blocks/iomad_company_admin/user_bulk_download.php');
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'user_bulk_download_title');
$blockpage->setup();
// Set the companyid
$companyid = iomad::get_my_companyid($context);
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
// If company user override the companyid parameter - they can only download their own.
if (company_user::is_company_user()) {
    $companyid = company_user::companyid();
}
// Deal with the departments.
$parentlevel = company::get_company_parentnode($companyid);
$companydepartment = $parentlevel->id;
if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', context_system::instance())) {
    $userhierarchylevel = $parentlevel->id;
} else {
    $userlevel = company::get_userlevel($USER);
    $userhierarchylevel = $userlevel->id;
}
if ($format) {
    $fields = array('id' => 'id', 'username' => 'username', 'email' => 'email', 'firstname' => 'firstname', 'lastname' => 'lastname', 'idnumber' => 'idnumber', 'institution' => 'institution', 'department' => 'department', 'phone1' => 'phone1', 'phone2' => 'phone2', 'city' => 'city', 'url' => 'url', 'icq' => 'icq', 'skype' => 'skype', 'aim' => 'aim', 'yahoo' => 'yahoo', 'msn' => 'msn', 'country' => 'country');
    // Get company category.
    if ($category = $DB->get_record_sql('SELECT uic.id, uic.name
                                         FROM {user_info_category} uic, {company} c
                                         WHERE c.id = ' . $companyid . ' AND
                                         c.shortname=uic.name')) {
        if ($extrafields = $DB->get_records('user_info_field', array('categoryid' => $category->id))) {
            foreach ($extrafields as $n => $v) {
                $fields['profile_field_' . $v->shortname] = 'profile_field_' . $v->shortname;
 public function definition()
 {
     global $CFG, $DB;
     $mform =& $this->_form;
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'header', get_string('companyuser', 'block_iomad_company_admin'));
     $mform->addElement('hidden', 'companyid', $this->selectedcompany);
     $mform->setType('companyid', PARAM_INT);
     // Code added by sumit
     $mform->addElement('hidden', 'returnurl', $this->returnurl);
     $mform->setType('returnurl', PARAM_LOCALURL);
     // end of code
     /* copied from /user/editlib.php */
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'id', $this->userid);
     $mform->setType('id', PARAM_INT);
     // Deal with the name order sorting and required fields.
     $necessarynames = useredit_get_required_name_fields();
     foreach ($necessarynames as $necessaryname) {
         $mform->addElement('text', $necessaryname, get_string($necessaryname), 'maxlength="100" size="30"');
         $mform->addRule($necessaryname, $strrequired, 'required', null, 'client');
         $mform->setType($necessaryname, PARAM_NOTAGS);
     }
     // Do not show email field if change confirmation is pending.
     if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
         $notice = get_string('auth_emailchangepending', 'auth_email', $user);
         $notice .= '<br /><a href="edit.php?cancelemailchange=1&amp;id=' . $user->id . '">' . get_string('auth_emailchangecancel', 'auth_email') . '</a>';
         $mform->addElement('static', 'emailpending', get_string('email'), $notice);
     } else {
         $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
         $mform->addRule('email', $strrequired, 'required', null, 'client');
         $mform->setType('email', PARAM_EMAIL);
     }
     /* GWL : Add Field for Username while edit the user */
     $mform->addElement('text', 'username', get_string('phone'), 'size="20"');
     // GWL : Change get_string('username') to 'phone'
     $mform->addRule('username', $strrequired, 'required', null, 'client');
     $mform->setType('username', PARAM_RAW);
     /* GWL : Add Field for Username while edit the user  */
     /* /copied from /user/editlib.php */
     $mform->addElement('static', 'blankline', '', '');
     if (!empty($CFG->passwordpolicy)) {
         $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
     }
     $mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
     $mform->addHelpButton('newpassword', 'newpassword');
     $mform->setType('newpassword', PARAM_RAW);
     $mform->addElement('static', 'generatepassword', '', get_string('leavepasswordemptytogenerate', 'block_iomad_company_admin'));
     $mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
     $mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
     // $mform->setDefault('preference_auth_forcepasswordchange', 1);
     $mform->addElement('selectyesno', 'sendnewpasswordemails', get_string('sendnewpasswordemails', 'block_iomad_company_admin'));
     $mform->setDefault('sendnewpasswordemails', 1);
     $mform->disabledIf('sendnewpasswordemails', 'newpassword', 'eq', '');
     // Deal with company optional fields.
     $mform->addElement('header', 'category_id', format_string(get_string('companyprofilefields', 'block_iomad_company_admin')));
     // Department drop down.
     // $mform->addElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $this->subhierarchieslist, $this->userdepartment);
     // Add in company/department manager checkboxes.
     $departmentlist = company_department::get_department_list($this->selectedcompany);
     $titlelist = company_title::get_title_list($this->selectedcompany);
     if ($departmentlist) {
         $mform->addElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $departmentlist);
     }
     if ($titlelist) {
         $mform->addElement('select', 'usertitle', get_string('title', 'local_manage_company_dept_title'), $titlelist);
     }
     $managerarray = array();
     if (iomad::has_capability('block/iomad_company_admin:assign_department_manager', context_system::instance())) {
         $managerarray['0'] = get_string('user', 'block_iomad_company_admin');
         $managerarray['2'] = get_string('regionlocationmanager', 'block_iomad_company_admin');
     }
     if (iomad::has_capability('block/iomad_company_admin:assign_company_manager', context_system::instance())) {
         if (empty($managearray)) {
             $managerarray['0'] = get_string('user', 'block_iomad_company_admin');
         }
         $managerarray['1'] = get_string('companymanager', 'block_iomad_company_admin');
         $managerarray['3'] = get_string('companyinstructor', 'block_iomad_company_admin');
         //GWL : Add Instructor
     }
     if (!empty($managerarray)) {
         $mform->addElement('select', 'managertype', get_string('managertype', 'block_iomad_company_admin'), $managerarray, 0);
         $mform->addHelpButton('managertype', 'managertype', 'block_iomad_company_admin');
     } else {
         $mform->addElement('hidden', 'managertype', 0);
     }
     // get region list
     $regionslistobj = company::get_all_regions($this->selectedcompany);
     $regionlist = array('' => get_string('regionnotselect', 'block_iomad_company_admin'));
     foreach ($regionslistobj as $region) {
         $regionlist[$region->id] = $region->name;
     }
     // Code added by sumit display region and location drop downs list
     $locationlist = array('' => get_string('choose'));
     if (!empty($this->regionid)) {
         $locationlistarr = company::get_all_locations($this->regionid);
         foreach ($locationlistarr as $location) {
             $locationlist[$location->id] = $location->name;
         }
     }
     $mform->addElement('select', 'userregion', get_string('region', 'block_iomad_company_admin'), $regionlist, array('class' => 'companyregion'));
     $mform->addElement('select', 'userlocation', get_string('location', 'block_iomad_company_admin'), $locationlist, array('id' => 'id_locationid'));
     $mform->disabledIf('userregion', 'managertype', 'eq', 1);
     $mform->disabledIf('userlocation', 'managertype', 'eq', 1);
     $mform->disabledIf('userregion', 'managertype', 'eq', 3);
     //GWL : Add Instructor
     $mform->disabledIf('userlocation', 'managertype', 'eq', 3);
     //GWL : Add Instructor
     // End of Code
     // Get global fields.
     // Get company category.
     if ($companyinfo = $DB->get_record('company', array('id' => $this->selectedcompany))) {
         // Get fields from company category.
         if ($fields = $DB->get_records('user_info_field', array('categoryid' => $companyinfo->profileid))) {
             // Display the header and the fields.
             foreach ($fields as $field) {
                 require_once $CFG->dirroot . '/user/profile/field/' . $field->datatype . '/field.class.php';
                 $newfield = 'profile_field_' . $field->datatype;
                 $formfield = new $newfield($field->id);
                 $formfield->edit_field($mform);
                 $mform->setDefault($formfield->inputname, $formfield->field->defaultdata);
             }
         }
     }
     /*
      $mform->addElement('header', 'courses', get_string('courses', 'block_iomad_company_admin'));
      $mform->addElement('html', "<div class='fitem'><div class='fitemtitle'>" .
      get_string('selectenrolmentcourse', 'block_iomad_company_admin') .
      "</div><div class='felement'>");
      $mform->addElement('html', $this->currentcourses->display(true));
      $mform->addElement('html', "</div></div>");
     */
     // add action buttons
     $buttonarray = array();
     //$buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('createuseragain', 'block_iomad_company_admin'));
     $buttonarray[] =& $mform->createElement('submit', 'submitandback', get_string('createuserandback', 'block_iomad_company_admin'));
     $buttonarray[] =& $mform->createElement('cancel');
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     $mform->closeHeaderBefore('buttonar');
 }
// Set the companyid to bypass the company select form if possible.
if (!empty($SESSION->currenteditingcompany)) {
    $companyid = $SESSION->currenteditingcompany;
} else {
    if (!empty($USER->company)) {
        $companyid = company_user::companyid();
    } else {
        if (!iomad::has_capability('local/email:edit', context_system::instance())) {
            print_error('There has been a configuration error, please contact the site administrator');
        } else {
            $blockpage->display_header();
            redirect(new moodle_url('/local/iomad_dashboard/index.php'), 'Please select a company from the dropdown first');
        }
    }
}
iomad::require_capability('local/email:send', $context);
if ($templateid) {
    $templaterecord = $DB->get_record('email_template', array('id' => $templateid), '*', MUST_EXIST);
} else {
    if ($templatename) {
        if (!($templaterecord = $DB->get_record('email_template', array('companyid' => $companyid, 'name' => $templatename), '*'))) {
            $templaterecord = (object) $email[$templatename];
            $templaterecord->name = $templatename;
        }
    }
}
// Correct the navbar.
// Set the name for the page.
$linktext = get_string('send_emails', 'local_email');
// Set the url.
$linkurl = new moodle_url('/local/email/template_edit_form.php');
Esempio n. 20
0
$linkurl = new moodle_url('/local/manage_company_dept_title/manage_dept.php');
// Build the nav bar.
//company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
require_once $CFG->libdir . '/adminlib.php';
/* GWL : Add condition to provide access for Site admin */
if (!has_capability('block/iomad_company_admin:manageallcompany', context_system::instance())) {
    admin_externalpage_setup('managecompanydepartmentsetting');
}
/* GWL : Add condition to provide access for Site admin */
//$blockpage = new blockpage($PAGE, $OUTPUT, 'manage_company_dept_title', 'local', 'createdepartment_title');
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'createdepartment_title');
$blockpage->setup($urlparams);
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
// Set the companyid
$companyid = iomad::get_my_companyid($context);
// Check the department is valid.
if (!company_department::is_company_admin($companyid)) {
    print_error('invalidaccesstocompany', 'block_iomad_company_admin');
}
$mform = new user_department_display_form(null, $companyid, $departmentid);
$editform = new user_department_edit_form(null, $companyid, $departmentid);
if ($mform->is_cancelled()) {
    redirect($companylist);
} else {
    if ($data = $mform->get_data()) {
        if (isset($data->create)) {
            if (!empty($deleteids)) {
                $chosenid = $deleteids['0'];
            } else {
                $chosenid = 0;
Esempio n. 21
0
            if (iomad::has_capability('block/iomad_company_admin:createcourse', $context)) {
                $createcoursebutton = "<a href='" . new moodle_url('company_course_create_form.php', array("companyid" => $company->id)) . "'>{$strcreatecourse}</a>";
            } else {
                $createcoursebutton = "";
            }
            if (iomad::has_capability('block/iomad_company_admin:company_course_users', $context)) {
                $courseusersbutton = "<a href='" . new moodle_url('company_course_users_form.php', array("companyid" => $company->id)) . "'>{$strcourseusers}</a>";
            } else {
                $courseusersbutton = "";
            }
            if (iomad::has_capability('block/iomad_company_admin:user_upload', $context)) {
                $downloadbutton = "<a href='" . new moodle_url('user_bulk_download.php', array("companyid" => $company->id)) . "'>{$strusersdownload}</a>";
            } else {
                $downloadbutton = "";
            }
            $table->data[] = array("{$company->name}", "{$company->shortname}", "{$company->city}", $editbutton, $usersbutton, $newuserbutton, $managersbutton, $coursesbutton, $createcoursebutton, $courseusersbutton, $downloadbutton, $deletebutton);
        }
    }
    if (!empty($table)) {
        echo html_writer::table($table);
        echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl);
    }
    $companies->close();
}
if (iomad::has_capability('block/iomad_company_admin:company_add', $context)) {
    echo '<div class="buttons">';
    echo $OUTPUT->single_button(new moodle_url('company_edit_form.php'), get_string('addnewcompany', 'block_iomad_company_admin'), 'get');
    echo $OUTPUT->single_button(new moodle_url('/local/iomad_dashboard/index.php'), get_string('cancel'), 'get');
    echo '</div>';
}
echo $OUTPUT->footer();
Esempio n. 22
0
iomad::require_capability('block/iomad_commerce:admin_view', $context);
// Get the number of orders.
$objectcount = $DB->count_records_sql("SELECT COUNT(*) FROM {invoice} WHERE Status != '" . INVOICESTATUS_BASKET . "'");
echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl);
flush();
if ($orders = $DB->get_recordset_sql("SELECT\n                                        i.*,\n                                        (SELECT COUNT(*) FROM {invoiceitem} ii WHERE ii.invoiceid = i.id AND processed = 0)\n                                         AS unprocesseditems\n                                      FROM {invoice} i\n                                      WHERE i.Status != '" . INVOICESTATUS_BASKET . "'\n                                      ORDER BY i.Status DESC, i.id DESC", null, $page, $perpage)) {
    if (count($orders)) {
        $stredit = get_string('edit');
        $strhide = get_string('hide', 'block_iomad_commerce');
        $strshow = get_string('show', 'block_iomad_commerce');
        $table = new html_table();
        $table->head = array(get_string('reference', 'block_iomad_commerce'), get_string('paymentprovider', 'block_iomad_commerce'), get_string('status', 'block_iomad_commerce'), get_string('company', 'block_iomad_company_admin'), get_string('unprocesseditems', 'block_iomad_commerce'), '');
        $table->align = array("left", "center", "center", "center");
        $table->width = "95%";
        foreach ($orders as $order) {
            if (iomad::has_capability('block/iomad_commerce:admin_view', $context)) {
                $editbutton = "<a href='" . new moodle_url('edit_order_form.php', array("id" => $order->id)) . "'>{$stredit}</a>";
            } else {
                $editbutton = "";
            }
            $table->data[] = array($order->reference, get_string('pp_' . $order->checkout_method . '_name', 'block_iomad_commerce'), get_string('status_' . $order->status, 'block_iomad_commerce'), $order->company, $order->unprocesseditems > 0 ? $order->unprocesseditems : "", $editbutton);
        }
        if (!empty($table)) {
            echo html_writer::table($table);
            echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl);
        }
    } else {
        echo "<p>" . get_string('noinvoices', 'block_iomad_commerce') . "</p>";
    }
    $orders->close();
}
    $course = $DB->get_record('course', array('id' => $shopsettings->courseid), 'id, fullname, shortname', MUST_EXIST);
    $course->fullname = $course->fullname . " ({$course->shortname}))";
    if (!$_POST || !array_key_exists('block_start_1', $_POST)) {
        $priceblocks = $DB->get_records('course_shopblockprice', array('courseid' => $shopsettings->courseid), 'price_bracket_start');
    }
    $shopsettings->tags = get_course_tags($course->id);
    $shopsettings->short_summary_editor = array('text' => $shopsettings->short_description);
    $shopsettings->summary_editor = array('text' => $shopsettings->long_description);
    iomad::require_capability('block/iomad_commerce:edit_course', $context);
} else {
    $isadding = true;
    $shopsettingsid = 0;
    $shopsettings = new stdClass();
    $course = null;
    $priceblocks = null;
    iomad::require_capability('block/iomad_commerce:add_course', $context);
}
if (array_key_exists('blockPrices', $_POST)) {
    $priceblocks = array();
    $nblocks = intval($_POST['blockPrices']);
    for ($i = 0; $i < $nblocks; $i++) {
        $k = $i + 1;
        $price_bracket_start_key = "block_start_{$k}";
        if (array_key_exists($price_bracket_start_key, $_POST)) {
            $price_key = "block_price_{$k}";
            $validlength_key = "block_valid_{$k}";
            $shelflife_key = "block_shelflife_{$k}";
            $priceblocks[] = (object) array('price_bracket_start' => $_POST[$price_bracket_start_key], 'price' => $_POST[$price_key], 'validlength' => $_POST[$validlength_key], 'shelflife' => $_POST[$shelflife_key]);
        }
    }
}
Esempio n. 24
0
$url = new moodle_url('/local/report_scorm_overview/index.php', array('departmentid' => $departmentid, 'courseid' => $courseid));
$dashboardurl = new moodle_url('/local/iomad_dashboard/index.php');
// Page stuff:.
$strcompletion = get_string('pluginname', 'local_report_scorm_overview');
$PAGE->set_url($url);
$PAGE->set_pagelayout('report');
$PAGE->set_title($strcompletion);
$PAGE->set_heading($SITE->fullname);
$PAGE->requires->css("/local/report_scorm_overvew/styles.css");
// Set the companyid
$companyid = iomad::get_my_companyid($context);
// Get the associated department id.
$company = new company($companyid);
$parentlevel = company::get_company_parentnode($company->id);
$companydepartment = $parentlevel->id;
if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', $context) || !empty($SESSION->currenteditingcompany)) {
    $userhierarchylevel = $parentlevel->id;
} else {
    $userlevel = company::get_userlevel($USER);
    $userhierarchylevel = $userlevel->id;
}
if ($departmentid == 0) {
    $departmentid = $userhierarchylevel;
}
// Set the url.
//company_admin_fix_breadcrumb($PAGE, $strcompletion, $url);
require_once $CFG->libdir . '/adminlib.php';
admin_externalpage_setup('userreportsettings');
// Navigation and header.
if (empty($dodownload)) {
    echo $OUTPUT->header();
Esempio n. 25
0
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
require_once '../../config.php';
require_once $CFG->dirroot . '/blocks/iomad_company_admin/lib.php';
require_once 'lib.php';
// Check permissions.
require_login($SITE);
$context = context_system::instance();
iomad::require_capability('local/report_companies:view', $context);
// Url stuff.
$url = new moodle_url('/local/report_companies/index.php');
// Page stuff:.
$strcompletion = get_string('pluginname', 'local_report_companies');
$PAGE->set_url($url);
$PAGE->set_pagelayout('report');
$PAGE->set_title($strcompletion);
$PAGE->requires->css("/local/report_companies/styles.css");
// Set the url.
company_admin_fix_breadcrumb($PAGE, get_string('pluginname', 'local_report_companies'), $url);
// Navigation and header.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', 'local_report_companies'));
// Ajax odds and sods.
$PAGE->requires->js_init_call('M.local_report_companies.init');
Esempio n. 26
0
        echo $completiontypeselectoutput;
    }
}
if (empty($charttype)) {
    if (!empty($courseid)) {
        // Get the course completion information.
        if (empty($dodownload)) {
            if (empty($idlist['0'])) {
                // Only want the data for the page we are on.
                $coursedataobj = iomad::get_user_course_completion_data($searchinfo, $courseid, $page, $perpage, $completiontype);
                $coursedata = $coursedataobj->users;
                $totalcount = $coursedataobj->totalcount;
            }
        } else {
            if (empty($idlist['0'])) {
                $coursedataobj = iomad::get_user_course_completion_data($searchinfo, $courseid);
                $coursedata = $coursedataobj->users;
                $totalcount = $coursedataobj->totalcount;
            }
        }
        // Is there a global vantage number.
        if ($DB->get_record('user_info_field', array('shortname' => 'VANTAGE'))) {
            $vantage = true;
        } else {
            $vantage = false;
        }
        // Check if there is a certificate module.
        $hascertificate = false;
        if (empty($dodownload) && ($certmodule = $DB->get_record('modules', array('name' => 'iomadcertificate')))) {
            require_once $CFG->dirroot . '/mod/iomadcertificate/lib.php';
            if ($certificateinfo = $DB->get_record('iomadcertificate', array('course' => $courseid))) {
 public function get_content()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     if (!isloggedin()) {
         $this->content->text = get_string('pleaselogin', 'block_iomad_online_users');
         return $this->content;
     }
     $timetoshowusers = 300;
     // Seconds default.
     if (isset($CFG->block_iomad_online_users_timetosee)) {
         $timetoshowusers = $CFG->block_iomad_online_users_timetosee * 60;
     }
     $timefrom = 100 * floor((time() - $timetoshowusers) / 100);
     // Round to nearest 100 seconds for better query cache.
     $now = time();
     // Calculate if we are in separate groups.
     $isseparategroups = $this->page->course->groupmode == SEPARATEGROUPS && $this->page->course->groupmodeforce && !iomad::has_capability('moodle/site:accessallgroups', $this->page->context);
     // Get the user current group.
     $currentgroup = $isseparategroups ? groups_get_course_group($this->page->course) : null;
     $groupmembers = "";
     $groupselect = "";
     $rafrom = "";
     $rawhere = "";
     $params = array();
     $params['now'] = $now;
     $params['timefrom'] = $timefrom;
     // Add this to the SQL to show only group users.
     if ($currentgroup !== null) {
         $groupmembers = ", {groups_members} gm";
         $groupselect = "AND u.id = gm.userid AND gm.groupid = :currentgroup";
         $params['currentgroup'] = $currentgroup;
     }
     $companyselect = "";
     $companyusersjoin = "";
     if (company_user::is_company_user()) {
         company_user::load_company();
         $companyusersjoin = ", {user_info_data} muid, {user_info_field} muif";
         $companyselect = " AND muif.id = muid.fieldid\n                               AND u.id = muid.userid\n                               AND muif.shortname = 'company'\n                               AND muid.data = :companyshortname ";
         $params['companyshortname'] = $USER->company->shortname;
     }
     $userfields = user_picture::fields('u', array('username'));
     if ($this->page->course->id == SITEID) {
         // Site-level.
         $sql = "SELECT {$userfields}, MAX(u.lastaccess) AS lastaccess\n                      FROM {user} u {$groupmembers} {$companyusersjoin}\n                     WHERE u.lastaccess > {$timefrom}\n                           {$groupselect}\n                           {$companyselect}\n                  GROUP BY {$userfields}\n                  ORDER BY lastaccess DESC ";
         $csql = "SELECT COUNT(u.id), u.id\n                       FROM {user} u {$groupmembers} {$companyusersjoin}\n                      WHERE u.lastaccess > {$timefrom}\n                            {$groupselect}\n                            {$companyselect}\n                   GROUP BY u.id";
     } else {
         // Course level - show only enrolled users for now.
         // TODO: add a new capability for viewing of all users (guests+enrolled+viewing).
         list($esqljoin, $eparams) = get_enrolled_sql($this->page->context);
         $params = array_merge($params, $eparams);
         $sql = "SELECT {$userfields}, MAX(ul.timeaccess) AS lastaccess\n                      FROM {user_lastaccess} ul {$groupmembers}, {user} u\n                      JOIN ({$esqljoin}) euj ON euj.id = u.id\n                     WHERE ul.timeaccess > :timefrom\n                           AND u.id = ul.userid\n                           AND ul.courseid = :courseid\n                           AND ul.timeaccess <= :now\n                           AND u.deleted = 0\n                           {$groupselect}\n                  GROUP BY {$userfields}\n                  ORDER BY lastaccess DESC";
         $csql = "SELECT COUNT(u.id)\n                      FROM {user_lastaccess} ul {$groupmembers}, {user} u\n                      JOIN ({$esqljoin}) euj ON euj.id = u.id\n                     WHERE ul.timeaccess > :timefrom\n                           AND u.id = ul.userid\n                           AND ul.courseid = :courseid\n                           AND ul.timeaccess <= :now\n                           AND u.deleted = 0\n                           {$groupselect}";
         $params['courseid'] = $this->page->course->id;
     }
     // Calculate minutes.
     $minutes = floor($timetoshowusers / 60);
     // Verify if we can see the list of users, if not just print number of users.
     if (!iomad::has_capability('block/online_users:viewlist', $this->page->context)) {
         if (!($usercount = $DB->count_records_sql($csql, $params))) {
             $usercount = get_string("none");
         }
         $this->content->text = "<div class=\"info\">" . get_string("periodnminutes", "block_iomad_online_users", $minutes) . ": {$usercount}</div>";
         return $this->content;
     }
     if ($users = $DB->get_records_sql($sql, $params, 0, 50)) {
         // We'll just take the most recent 50 maximum.
         foreach ($users as $user) {
             $users[$user->id]->fullname = fullname($user);
         }
     } else {
         $users = array();
     }
     if (count($users) < 50) {
         $usercount = "";
     } else {
         $usercount = $DB->count_records_sql($csql, $params);
         $usercount = ": {$usercount}";
     }
     $this->content->text = "<h3>Recent Online Company Users</h3><div class=\"info\">(" . get_string("periodnminutes", "block_iomad_online_users", $minutes) . "{$usercount})</div>";
     // Now, we have in users, the list of users to show.
     // Because they are online.
     if (!empty($users)) {
         // Accessibility: Don't want 'Alt' text for the user picture; DO want it for the envelope/message link
         // (existing lang string).
         // Accessibility: Converted <div> to <ul>, inherit existing classes & styles.
         $this->content->text .= "<ul class='list'>\n";
         if (isloggedin() && iomad::has_capability('moodle/site:sendmessage', $this->page->context) && !empty($CFG->messaging) && !isguestuser()) {
             $canshowicon = true;
         } else {
             $canshowicon = false;
         }
         foreach ($users as $user) {
             $this->content->text .= '<li class="listentry">';
             $timeago = format_time(time() - $user->lastaccess);
             // Bruno to calculate correctly on frontpage.
             if (isguestuser($user)) {
                 $this->content->text .= '<div class="user">' . $OUTPUT->user_picture($user, array('size' => 16));
                 $this->content->text .= get_string('guestuser') . '</div>';
             } else {
                 $this->content->text .= '<div class="user">' . $OUTPUT->user_picture($user, array('size' => 16));
                 $this->content->text .= '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $this->page->course->id . '" title="' . $timeago . '">' . $user->fullname . '</a></div>';
             }
             if ($canshowicon and $USER->id != $user->id and !isguestuser($user)) {
                 // Only when logged in and messaging active etc.
                 $anchortagcontents = '<img class="iconsmall" src="' . $OUTPUT->pix_url('t/message') . '" alt="' . get_string('messageselectadd') . '" />';
                 $anchortag = '<a href="' . $CFG->wwwroot . '/message/index.php?id=' . $user->id . '" title="' . get_string('messageselectadd') . '">' . $anchortagcontents . '</a>';
                 $this->content->text .= '<div class="message">' . $anchortag . '</div>';
             }
             $this->content->text .= "</li>\n";
         }
         $this->content->text .= '</ul><div class="clearer"><!-- --></div>';
     } else {
         $this->content->text .= "<div class=\"info\">" . get_string("none") . "</div>";
     }
     return $this->content;
 }
Esempio n. 28
0
 public static function load_company()
 {
     iomad::load_company();
 }
Esempio n. 29
0
            $strlastaccess = format_time(time() - $user->lastaccess);
        } else {
            $strlastaccess = get_string('never');
        }
        $fullname = fullname($user, true);
        // Is this a suspended user?
        if (!empty($user->suspended)) {
            $fullname .= " (S)";
        }
        // Get the users department.
        $userdepartment = $DB->get_record_sql("SELECT d.name\n                                               FROM {department} d, {company_users} du\n                                               WHERE du.userid = " . $user->id . "\n                                               AND d.id = du.departmentid");
        $user->department = $userdepartment->name;
        $table->data[] = array("{$fullname}", "{$user->email}", "{$user->department}", $strlastaccess, $editbutton, $suspendbutton, $deletebutton, $enrolmentbutton);
    }
}
if (iomad::has_capability('block/iomad_company_admin:user_create', $systemcontext)) {
    $returnurl = new moodle_url('/blocks/iomad_company_admin/editusers.php');
    echo $OUTPUT->heading('<a class="anchor-1 pull-right" href="' . $CFG->wwwroot . '/blocks/iomad_company_admin/company_user_create_form.php?returnurl=' . $returnurl . '"> <i class="fa fa-plus"></i>' . get_string('createuser', 'block_iomad_company_admin') . '</a>');
    echo html_writer::start_tag('div', array('class' => 'clearfix'));
    echo html_writer::end_tag('div');
}
if (!empty($table)) {
    echo html_writer::table($table);
    echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl);
}
echo $OUTPUT->footer();
function iomad_get_users_listing($sort = 'lastaccess', $dir = 'ASC', $page = 0, $recordsperpage = 0, $search = '', $firstinitial = '', $lastinitial = '', $extraselect = '', array $extraparams = null)
{
    global $DB;
    $fullname = $DB->sql_fullname();
    $select = "u.deleted <> 1";
Esempio n. 30
0
/**
 * This function creates the dynamic HTML needed for the 
 * layout and then passes it back in an object so it can
 * be echo'd to the page.
 *
 * This keeps the logic out of the layout files.
 */
function theme_bootstrap_html_for_settings($PAGE)
{
    global $CFG, $DB, $USER, $SITE;
    $settings = $PAGE->theme->settings;
    $html = new stdClass();
    if ($settings->inversenavbar == true) {
        $html->navbarclass = 'navbar navbar-inverse';
    } else {
        $html->navbarclass = 'navbar navbar-default';
    }
    $fluid = !empty($PAGE->layout_options['fluid']);
    if ($fluid || $settings->fluidwidth == true) {
        $html->containerclass = 'container-fluid';
    } else {
        $html->containerclass = 'container';
    }
    $html->brandfontlink = theme_bootstrap_brand_font_link($settings);
    // get logos
    $theme = $PAGE->theme;
    $logo = $theme->setting_file_url('logo', 'logo');
    if (empty($logo)) {
        $logo = $CFG->wwwroot . '/theme/iomad/pix/iomad_logo.png';
    }
    $clientlogo = '';
    $companycss = '';
    if ($companyid = iomad::is_company_user()) {
        $context = context_system::instance();
        if ($files = $DB->get_records('files', array('contextid' => $context->id, 'component' => 'theme_iomad', 'filearea' => 'companylogo', 'itemid' => $companyid))) {
            foreach ($files as $file) {
                if ($file->filename != '.') {
                    $clientlogo = $CFG->wwwroot . "/pluginfile.php/{$context->id}/theme_iomad/companylogo/{$companyid}/{$file->filename}";
                }
            }
        }
        company_user::load_company();
        $companycss = ".header, .navbar { background: [[company:bgcolor_header]]; }\n                       .block .content { background: [[company:bgcolor_content]]; }";
        foreach ($USER->company as $key => $value) {
            if (isset($value)) {
                $companycss = preg_replace("/\\[\\[company:{$key}\\]\\]/", $value, $companycss);
            }
        }
    }
    $html->heading = '<div id="sitelogo">' . '<a href="' . $CFG->wwwroot . '" ><img src="' . $logo . '" /></a></div>';
    $html->heading .= '<div id="siteheading"><span>' . $SITE->fullname . '</span></div>';
    if ($clientlogo) {
        $html->heading .= '<div id="clientlogo">' . '<a href="' . $CFG->wwwroot . '" ><img src="' . $clientlogo . '" /></a></div>';
    }
    $html->footnote = '';
    if (!empty($page->theme->settings->footnote)) {
        $html->footnote = '<div class="footnote text-center">' . $PAGE->theme->settings->footnote . '</div>';
    }
    $html->companycss = $companycss;
    return $html;
}