Select Git revision
ForumEntry.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Elmar Ludwig authored
Merge request studip/studip!440
Elmar Ludwig authoredMerge request studip/studip!440
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
AutoInsert.class.php 12.77 KiB
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Nico Müller <nico.mueller@uni-oldenburg.de>
* @author Michael Riehemann <michael.riehemann@uni-oldenburg.de>
* @author Jan Hendrik Willms <jan.hendrik.willms@uni-oldenburg.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @since 2.1
*/
/**
* AutoInsert.class.php
* Provides functions required by StEP00216:
* - Assign seminars for automatic registration of certain user types
* - Maintenance of registration rules
*
* Example of use:
* @code
*
* # show all auto insert seminars
* $auto_sems = AutoInsert::getAllSeminars();
*
* # Save a new auto insert seminar with the user status
* AutoInsert::saveSeminar($sem_id, $rechte);
*
* @endcode
*/
class AutoInsert
{
private static $instance = null;
protected static $seminar_cache = null;
private $settings = [];
public static function instance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
public function __construct()
{
$this->loadSettings();
}
private function loadSettings()
{
$query = "SELECT a.seminar_id, GROUP_CONCAT(a.status,IF(LENGTH(a.domain_id)=0,':keine',CONCAT(':',a.domain_id))) AS domain_status, s.Name, s.Schreibzugriff, s.start_time ";
$query .= "FROM auto_insert_sem a ";
$query .= "JOIN seminare AS s USING (Seminar_id) ";
$query .= "GROUP BY s.seminar_id ";
$query .= "ORDER BY s.Name";
$statement = DBManager::get()->query($query);
$results = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($results as $result) {
if ($result['Schreibzugriff'] < 3) {
$domains = explode(',', $result['domain_status']);
foreach ($domains as $domain) {
$array = explode(':', $domain);
$key = $array[1] . '.' . $array[0];
$this->settings[$key][$result['seminar_id']] = ['Seminar_id' => $result['seminar_id'],
'name' => $result['Name'],