Example #1
0
 public function write_setting($data)
 {
     // your custom validation logic here
     //we have no special needs, but we clean empty lines and compare with the db
     $lines = explode("\n", $data);
     array_walk($lines, create_function('&$val', '$val = trim($val);'));
     $lines = array_filter($lines);
     //leere weg
     /*
         	echo "<textarea cols=50 rows=20>";
     		var_dump($lines);
     		echo "</textarea>";
     		
     * 
     */
     //ok, jetzt abgleich mit db
     ResopDB::synchDBDepartements($lines);
     //nur einfügen, alte nicht herausnehmen
     $data = implode("\n", $lines);
     return parent::write_setting($data);
 }
Example #2
0
    die('Invalid authentication');
}
$isBooker = checkIfBooker($resopInCourseId, $user);
if (!$isBooker && ($type == 'booker' || $type == 'class' && $requestedName == 'all')) {
    die('Access rights are not sufficient');
}
//now we have should done authentication stuff
if ($requestedName == 'all') {
    $requestedName = '%';
}
//get the data
if ($type == 'class') {
    $entries = ResopDB::getClassEntries($requestedName, $resopId);
} else {
    if ($type == 'booker') {
        $entries = ResopDB::getBookerEntries($requestedName);
    } else {
        die('Ivalid request');
    }
}
/*
echo "<textarea cols=50 rows=20>";
print_r($entries);
echo "</textarea>";
*/
//build the ical stuff
$ical = new iCalendar();
$ical->add_property('method', 'PUBLISH');
$hostaddress = str_replace('http://', '', $CFG->wwwroot);
$hostaddress = str_replace('https://', '', $hostaddress);
/* example for one entry, key in array is always id
Example #3
0
function showBookers($id, $name)
{
    global $DB, $USER, $CFG, $OUTPUT, $resop;
    //thought id and resop id are the same but they are not.
    //I don't understand why, so what resop->id is used in my internal db-tables and id is the id of an instance
    //inside of a course
    $authtoken = sha1($USER->id . $DB->get_field('user', 'password', array('id' => $USER->id)) . $CFG->resop_exportsalt);
    $urlExport = array('id' => $id, 'resopId' => $resop->id, 'userid' => $USER->id, 'authtoken' => $authtoken, 'type' => 'booker', 'name' => $name);
    $linkExport = $OUTPUT->action_link(new moodle_url('exportIcal.php', $urlExport), 'iCal', null, array('title' => get_string('iCal', 'resop'), 'class' => 'ical-link'));
    //$OUTPUT->action_link you find under lib/outputrenderers.php - but I don't understand action (set to null is default)
    //delete get's the old action and class to go back to this page
    echo $linkExport;
    echo $OUTPUT->help_icon('iCal', 'resop');
    $bookerEntries = ResopDB::getBookerEntries($name);
    showEntriesTable($id, $bookerEntries, array('name' => $name));
}
Example #4
0
 public static function tryUpdateExamResource($id, $editId, $fromform)
 {
     ResopDB::checkInsertUpdateExamResource($fromform);
     ResopDB::updateExamResource($id, $editId, $fromform);
 }
Example #5
0
File: lib.php Project: Roemke/resop
/**
 * Removes an instance of the resop from the database
 *
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @param int $id Id of the module instance
 * @return boolean Success/Failure
 */
function resop_delete_instance($id)
{
    global $DB;
    file_put_contents("/tmp/a", "call to delete instance\n", FILE_APPEND);
    if (!($resop = $DB->get_record('resop', array('id' => $id)))) {
        return false;
    }
    file_put_contents("/tmp/a", "call to delete instance in progress\n", FILE_APPEND);
    // Delete any dependent records here.
    ResopDB::deleteResop($resop->id);
    $DB->delete_records('resop', array('id' => $resop->id));
    //resop_grade_item_delete($resop);
    return true;
}
Example #6
0
 /**
  * Defines forms elements
  */
 public function definition()
 {
     global $CFG, $DB;
     $mform = $this->_form;
     // Adding the "general" fieldset, where all the common settings are showed.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Adding the standard "name" field.
     $mform->addElement('text', 'name', get_string('resopname', 'resop'), array('size' => '64'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEAN);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->addHelpButton('name', 'resopname', 'resop');
     // Adding the standard "intro" and "introformat" fields.
     //$this->add_intro_editor();//deprecated
     $this->standard_intro_elements();
     // Adding the rest of resop settings, spreading all them into this fieldset
     // ... or adding more fieldsets ('header' elements) if needed for better logic.
     //$mform->addElement('static', 'label1', 'resopsetting1', 'Your resop fields go here. Replace me!');
     $mform->addElement('header', 'resopfieldset', get_string('resopfieldset', 'resop'));
     //kr later take from db?
     //ressource-Type, nur klassenarbeit und andere bisher moeglich
     $RES_TYPES = array('typeall' => get_string('typeall', 'resop'), 'typeexam' => get_string('typeexam', 'resop'));
     if (empty($this->current->id)) {
         $restype = $mform->addElement('select', 'resop_type', get_string('resoptypestring', 'resop'), $RES_TYPES);
         $restype->setSelected('typeexam');
         //restype fuehrt zu name restype und id id_restype
         //-------------------------------------
         $departements = ResopDB::getDepartements();
         //
         $resdep = $mform->addElement('select', 'resop_departement', get_string('departement', 'resop'), $departements);
         //klappt, baut aus dem schluessel in $departements den value des select-feldes
         $depKeys = array_keys($departements);
         $resdep->setSelected($depKeys[0]);
     } else {
         $abt = $DB->get_record_select('resop_abt', "id={$this->current->id_abt}", $params = null, $fields = 'name');
         $mform->addElement('html', '<p style="font-weight: bold;">' . get_string('departement', 'resop') . ': ' . $abt->name . get_string('noteditable', 'resop') . '</p>');
         $type = get_string($this->current->type, 'resop');
         $mform->addElement('html', '<p style="font-weight: bold;">' . get_string('resoptypestring', 'resop') . ': ' . $type . get_string('noteditable', 'resop') . '</p>');
     }
     //Wer kann buchen
     $user = ResopDB::getUser();
     //
     //echo "Current is {$this->current->id} <br>";
     $userSelected = empty($this->current->id) ? '' : ResopDB::getUser($this->current->id);
     $usdep = $mform->addElement('select', 'resop_users', get_string('listofusers', 'resop'), $user, array('size' => 20));
     $usdep->setMultiple(true);
     if (!empty($userSelected)) {
         $usdep->setSelected(array_keys($userSelected));
     }
     $mform->addHelpButton('resop_users', 'listofusers', 'resop');
     //_help wird automatisch angehaengt
     $mform->addRule('resop_users', null, 'required');
     //Ressourcen selbst
     $mform->addElement('textarea', 'resop_resources', get_string("listofresources", "resop"), 'wrap="virtual" rows="15" cols="50"');
     $mform->addHelpButton('resop_resources', 'listofresources', 'resop');
     //_help wird automatisch angehaengt
     $mform->addRule('resop_resources', null, 'required');
     if (empty($this->current->id)) {
         $mform->setDefault('resop_resources', $CFG->resop_resources);
     } else {
         $mform->setDefault('resop_resources', implode("\n", ResopDB::getResources($this->current->id)));
     }
     // Add standard grading elements.
     //$this->standard_grading_coursemodule_elements();
     // Add standard elements, common to all modules.
     $this->standard_coursemodule_elements();
     // Add standard buttons, common to all modules.
     $this->add_action_buttons();
 }