mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Freebusy Tools
This commit is contained in:
Executable
+243
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 FH Technikum-Wien
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
*/
|
||||
/*
|
||||
* GUI fuer die FreeBusy Verwaltung
|
||||
*
|
||||
* Mit diesem Tool koennen FreeBusy URLs aus verschiedenen Quellen zu einer
|
||||
* FreeBusy URL zusammengefasst werden
|
||||
*/
|
||||
require_once('../../../config/cis.config.inc.php');
|
||||
require_once('../../../include/basis_db.class.php');
|
||||
require_once('../../../include/functions.inc.php');
|
||||
require_once('../../../include/freebusy.class.php');
|
||||
require_once('../../../include/phrasen.class.php');
|
||||
|
||||
if (!$db = new basis_db())
|
||||
die('Fehler beim Oeffnen der Datenbankverbindung');
|
||||
|
||||
$user=get_uid();
|
||||
$sprache = getSprache();
|
||||
$p = new phrasen($sprache);
|
||||
|
||||
$action = (isset($_REQUEST['action'])?$_REQUEST['action']:'');
|
||||
$id = (isset($_REQUEST['id'])?$_REQUEST['id']:'');
|
||||
|
||||
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="../../../skin/tablesort.css" type="text/css">
|
||||
<link rel="stylesheet" href="../../../skin/jquery.css" type="text/css">
|
||||
<link rel="stylesheet" href="../../../skin/style.css.php" type="text/css">
|
||||
<title>'.$p->t('freebusy/titel').'</title>
|
||||
|
||||
<script type="text/javascript" src="../../../include/js/jquery.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
$("#myTable").tablesorter(
|
||||
{
|
||||
sortList: [[0,1]],
|
||||
widgets: [\'zebra\']
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>'.$p->t('freebusy/titel').'</h1>';
|
||||
|
||||
echo $p->t('freebusy/beschreibungstext1').'<br />';
|
||||
echo '<br /><span style="font-weight:bold">'.$p->t('freebusy/PfadZuFreebusyUrl').'</span> '.APP_ROOT.'cis/public/freebusy.php/'.$user;
|
||||
|
||||
echo '<br /><br />';
|
||||
if($action=='delete')
|
||||
{
|
||||
//Loeschen von Eintraegen
|
||||
$fb = new freebusy();
|
||||
if($fb->load($id))
|
||||
{
|
||||
//Nur Loeschen wenn es der eigene Eintrag ist
|
||||
if($fb->uid==$user)
|
||||
{
|
||||
if(!$fb->delete($id))
|
||||
echo '<span class="error">'.$p->t('global/fehlerBeimLoeschenDesEintrags').'</span>';
|
||||
else
|
||||
echo '<span class="ok">'.$p->t('global/eintragWurdeGeloescht').'</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
die($p->t('global/keineBerechtigungZumAendernDesDatensatzes'));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo '<span class="error">'.$p->t('global/fehlerBeimLadenDesDatensatzes').'</span>';
|
||||
}
|
||||
elseif($action=='save')
|
||||
{
|
||||
//Speichern von Eintraegen
|
||||
|
||||
$id = (isset($_POST['id'])?$_POST['id']:'');
|
||||
$aktiv = isset($_POST['aktiv']);
|
||||
|
||||
if(isset($_POST['bezeichnung']))
|
||||
$bezeichnung = $_POST['bezeichnung'];
|
||||
else
|
||||
die($p->t('global/fehlerBeiDerParameteruebergabe'));
|
||||
|
||||
if(isset($_POST['typ']))
|
||||
$typ = $_POST['typ'];
|
||||
else
|
||||
die($p->t('global/fehlerBeiDerParameteruebergabe'));
|
||||
|
||||
if(isset($_POST['url']))
|
||||
$url = $_POST['url'];
|
||||
else
|
||||
die($p->t('global/fehlerBeiDerParameteruebergabe'));
|
||||
|
||||
$fb = new freebusy();
|
||||
if($id!='')
|
||||
{
|
||||
if(!$fb->load($id))
|
||||
die($p->t('global/fehleraufgetreten'));
|
||||
if($fb->uid!=$user)
|
||||
die($p->t('global/keineBerechtigungZumAendernDesDatensatzes'));
|
||||
|
||||
|
||||
$fb->new=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$fb->new=true;
|
||||
$fb->insertamum = date('Y-m-d H:i:s');
|
||||
$fb->insertvon = $user;
|
||||
$fb->uid = $user;
|
||||
}
|
||||
|
||||
$fb->updateamum = date('Y-m-d H:i:s');
|
||||
$fb->updatevon = $user;
|
||||
$fb->bezeichnung = $bezeichnung;
|
||||
$fb->url = $url;
|
||||
$fb->freebusytyp_kurzbz = $typ;
|
||||
$fb->aktiv = $aktiv;
|
||||
|
||||
if($fb->save())
|
||||
echo '<span class="ok">'.$p->t('global/erfolgreichgespeichert').'</span>';
|
||||
else
|
||||
echo '<span class="error">'.$p->t('global/fehleraufgetreten').'</span>';
|
||||
|
||||
}
|
||||
|
||||
//Tabelle mit den vorhandenen Eintraegen anzeigen
|
||||
$fb = new freebusy();
|
||||
$fb->getFreeBusy($user);
|
||||
|
||||
echo '<table id="myTable" class="tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$p->t('global/bezeichnung').'</th>
|
||||
<th>'.$p->t('freebusy/typ').'</th>
|
||||
<th>'.$p->t('freebusy/url').'</th>
|
||||
<th>'.$p->t('freebusy/aktiv').'</th>
|
||||
<th colspan="2">'.$p->t('global/aktion').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>'.$p->t('freebusy/LVPlanBezeichnung').'</td>';
|
||||
echo '<td>'.$p->t('freebusy/LVPlanTyp').'</td>';
|
||||
echo '<td></td>';
|
||||
echo '<td>'.$p->t('global/ja').'</td>';
|
||||
echo '<td></td>';
|
||||
echo '<td></td>';
|
||||
echo '</tr>';
|
||||
|
||||
foreach($fb->result as $row)
|
||||
{
|
||||
$typ = new freebusy();
|
||||
$typ->loadTyp($row->freebusytyp_kurzbz);
|
||||
echo '<tr>';
|
||||
echo '<td>'.$db->convert_html_chars($row->bezeichnung).'</td>';
|
||||
echo '<td>'.$db->convert_html_chars($typ->bezeichnung).'</td>';
|
||||
echo '<td>'.$db->convert_html_chars($row->url).'</td>';
|
||||
echo '<td>'.($row->aktiv?$p->t('global/ja'):$p->t('global/nein')).'</td>';
|
||||
echo '<td><a href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$row->freebusy_id.'">'.$p->t('global/bearbeiten').'</a></td>';
|
||||
echo '<td><a href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$row->freebusy_id.'">'.$p->t('global/löschen').'</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody>
|
||||
</table>';
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'?action=neu">'.$p->t('freebusy/neuerEintrag').'</a>';
|
||||
|
||||
//Formular zum Anlegen und Editieren anzeigen
|
||||
if($action=='edit' || $action=='neu')
|
||||
{
|
||||
$fb = new freebusy();
|
||||
|
||||
if($action=='neu')
|
||||
{
|
||||
$new = true;
|
||||
echo '<hr><h3>'.$p->t('global/neu').'</h3>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$new=false;
|
||||
echo '<hr><h3>'.$p->t('global/editieren').'</h3>';
|
||||
if(!$fb->load($id))
|
||||
die($p->t('global/fehlerBeimLadenDesDatensatzes'));
|
||||
}
|
||||
|
||||
echo '<form action="'.$_SERVER['PHP_SELF'].'?action=save" method="POST">';
|
||||
echo '<input type="hidden" name="id" value="'.$fb->freebusy_id.'" />';
|
||||
echo '<table>
|
||||
<tr>
|
||||
<th>'.$p->t('global/bezeichnung').'</th>
|
||||
<th>'.$p->t('freebusy/typ').'</th>
|
||||
<th>'.$p->t('freebusy/url').'</th>
|
||||
<th>'.$p->t('freebusy/aktiv').'</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="bezeichnung" size="20" maxlength="256" value="'.$db->convert_html_chars($fb->bezeichnung).'"/></td>
|
||||
<td>
|
||||
<select name="typ">';
|
||||
$fbtyp = new freebusy();
|
||||
$fbtyp->getTyp();
|
||||
foreach($fbtyp->result as $row)
|
||||
{
|
||||
if($row->freebusytyp_kurzbz==$fb->freebusytyp_kurzbz)
|
||||
$selected='selected';
|
||||
else
|
||||
$selected='';
|
||||
echo '<OPTION value="'.$row->freebusytyp_kurzbz.'" '.$selected.'>'.$row->bezeichnung,'</OPTION>';
|
||||
}
|
||||
echo '
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="text" name="url" size="60" maxlength="1024" value="'.$db->convert_html_chars($fb->url).'"/></td>
|
||||
<td><input type="checkbox" name="aktiv" '.($fb->aktiv?'checked="checked"':'').' /></td>
|
||||
<td><input type="submit" value="'.$p->t('global/speichern').'" /></td>
|
||||
</tr>
|
||||
</table>';
|
||||
echo '</form>';
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -281,7 +281,8 @@ $nr_mg=$db->db_num_rows($erg_mg);
|
||||
{
|
||||
echo '
|
||||
<A class="Item" href="zeitwunsch.php?uid='.$uid.'">'.$p->t('profil/zeitwuensche').'</A><BR>
|
||||
<A class="Item" href="lva_liste.php?uid='.$uid.'">'.$p->t('lvaliste/lehrveranstaltungen').'</A>';
|
||||
<A class="Item" href="lva_liste.php?uid='.$uid.'">'.$p->t('lvaliste/lehrveranstaltungen').'</A><br>
|
||||
<A class="Item" href="freebusy.php">'.$p->t('freebusy/titel').'</A>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+37
-16
@@ -53,25 +53,46 @@ $ical = new ical();
|
||||
|
||||
foreach($freebusy->result as $row)
|
||||
{
|
||||
|
||||
$fp = fopen($row->url,'r');
|
||||
if (!$fp)
|
||||
if($row->aktiv)
|
||||
{
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$doc = '';
|
||||
while (!feof($fp))
|
||||
{
|
||||
$line = fgets($fp);
|
||||
$doc.=$line;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$ical->importFreeBusy($doc, $row->freebusytyp_kurzbz);
|
||||
$fp = fopen($row->url,'r');
|
||||
if (!$fp)
|
||||
{
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$doc = '';
|
||||
while (!feof($fp))
|
||||
{
|
||||
$line = fgets($fp);
|
||||
$doc.=$line;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$ical->importFreeBusy($doc, $row->freebusytyp_kurzbz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Pers. LVplan
|
||||
$fp = fopen(APP_ROOT.'cis/public/freebusy_lvplan.php/'.$uid,'r');
|
||||
if (!$fp)
|
||||
{
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$doc = '';
|
||||
while (!feof($fp))
|
||||
{
|
||||
$line = fgets($fp);
|
||||
$doc.=$line;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$ical->importFreeBusy($doc, $row->freebusytyp_kurzbz);
|
||||
}
|
||||
echo $ical->getFreeBusy();
|
||||
echo "\nEND:VCALENDAR";
|
||||
?>
|
||||
+135
-7
@@ -32,7 +32,7 @@ class freebusy extends basis_db
|
||||
public $uid;
|
||||
public $freebusytyp_kurzbz;
|
||||
public $url;
|
||||
public $aktiv;
|
||||
public $aktiv=true;
|
||||
public $bezeichnung;
|
||||
public $insertamum;
|
||||
public $insertvon;
|
||||
@@ -68,7 +68,7 @@ class freebusy extends basis_db
|
||||
}
|
||||
|
||||
//Daten aus der Datenbank lesen
|
||||
$qry = "SELECT * FROM campus.tbl_freebusy WHERE freebusy_id='".addslashes($freebusy_id)."'";
|
||||
$qry = "SELECT * FROM campus.tbl_freebusy WHERE freebusy_id=".$this->db_add_param($freebusy_id,FHC_INTEGER);
|
||||
|
||||
if(!$this->db_query($qry))
|
||||
{
|
||||
@@ -82,7 +82,7 @@ class freebusy extends basis_db
|
||||
$this->uid = $row->uid;
|
||||
$this->freebusytyp_kurzbz = $row->freebusytyp_kurzbz;
|
||||
$this->url = $row->url;
|
||||
$this->aktiv = ($row->aktiv=='t'?true:false);
|
||||
$this->aktiv = $this->db_parse_bool($row->aktiv);
|
||||
$this->bezeichnung = $row->bezeichnung;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
@@ -105,7 +105,7 @@ class freebusy extends basis_db
|
||||
*/
|
||||
public function getFreeBusy($uid)
|
||||
{
|
||||
$qry = "SELECT * FROM campus.tbl_freebusy WHERE uid='".addslashes($uid)."' ORDER BY freebusy_id";
|
||||
$qry = "SELECT * FROM campus.tbl_freebusy WHERE uid=".$this->db_add_param($uid)." ORDER BY freebusy_id";
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
@@ -117,7 +117,7 @@ class freebusy extends basis_db
|
||||
$obj->uid = $row->uid;
|
||||
$obj->freebusytyp_kurzbz = $row->freebusytyp_kurzbz;
|
||||
$obj->url = $row->url;
|
||||
$obj->aktiv = ($row->aktiv=='t'?true:false);
|
||||
$obj->aktiv = $this->db_parse_bool($row->aktiv);
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->insertamum = $row->insertamum;
|
||||
$obj->insertvon = $row->insertvon;
|
||||
@@ -135,6 +135,37 @@ class freebusy extends basis_db
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt einen Freebusytyp
|
||||
*
|
||||
* @param $freebusytyp_kurzbz
|
||||
* @return boolean
|
||||
*/
|
||||
public function loadTyp($freebusytyp_kurzbz)
|
||||
{
|
||||
$qry = "SELECT * FROM campus.tbl_freebusytyp WHERE freebusytyp_kurzbz=".$this->db_add_param($freebusytyp_kurzbz);
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$this->freebusytyp_kurzbz = $row->freebusytyp_kurzbz;
|
||||
$this->bezeichnung = $row->bezeichnung;
|
||||
$this->beschreibung = $row->beschreibung;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Laedt die FreeBusyTypen
|
||||
*
|
||||
@@ -149,13 +180,13 @@ class freebusy extends basis_db
|
||||
{
|
||||
$obj = new freebusy();
|
||||
|
||||
$obj->freebusytyp_kurbz = $row->freebusytyp_kurzbz;
|
||||
$obj->freebusytyp_kurzbz = $row->freebusytyp_kurzbz;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -163,5 +194,102 @@ class freebusy extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entfernt einen Eintrag aus der Datenbank
|
||||
*
|
||||
* @param $freebusy_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($freebusy_id)
|
||||
{
|
||||
$qry = "DELETE FROM campus.tbl_freebusy WHERE freebusy_id=".$this->db_add_param($freebusy_id, FHC_INTEGER, false);
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Löschen des Eintrages';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert die Daten die in die Datenbank
|
||||
*
|
||||
* @param $new boolean
|
||||
* @return boolean
|
||||
*/
|
||||
public function save($new=null)
|
||||
{
|
||||
if(is_null($new))
|
||||
$new = $this->new;
|
||||
|
||||
if($new)
|
||||
{
|
||||
$qry = 'BEGIN; INSERT INTO campus.tbl_freebusy(uid, freebusytyp_kurzbz, url, aktiv, bezeichnung,
|
||||
insertamum, insertvon, updateamum, updatevon) VALUES('.
|
||||
$this->db_add_param($this->uid).','.
|
||||
$this->db_add_param($this->freebusytyp_kurzbz).','.
|
||||
$this->db_add_param($this->url).','.
|
||||
$this->db_add_param($this->aktiv,FHC_BOOLEAN).','.
|
||||
$this->db_add_param($this->bezeichnung).','.
|
||||
$this->db_add_param($this->insertamum).','.
|
||||
$this->db_add_param($this->insertvon).','.
|
||||
$this->db_add_param($this->updateamum).','.
|
||||
$this->db_add_param($this->updatevon).');';
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = 'UPDATE campus.tbl_freebusy SET '.
|
||||
' uid='.$this->db_add_param($this->uid).','.
|
||||
' freebusytyp_kurzbz='.$this->db_add_param($this->freebusytyp_kurzbz).','.
|
||||
' url='.$this->db_add_param($this->url).','.
|
||||
' aktiv='.$this->db_add_param($this->aktiv, FHC_BOOLEAN).','.
|
||||
' bezeichnung='.$this->db_add_param($this->bezeichnung).','.
|
||||
' updateamum='.$this->db_add_param($this->updateamum).','.
|
||||
' updatevon='.$this->db_add_param($this->updatevon).' '.
|
||||
' WHERE freebusy_id='.$this->db_add_param($this->freebusy_id, FHC_INTEGER, false);
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($new)
|
||||
{
|
||||
$qry = "SELECT currval('campus.seq_freebusy_freebusy_id') as id";
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$this->freebusy_id = $row->id;
|
||||
$this->db_query('COMMIT;');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$this->phrasen['freebusy/titel']='FreeBusy Verwaltung';
|
||||
$this->phrasen['freebusy/typ']='Typ';
|
||||
$this->phrasen['freebusy/url']='URL';
|
||||
$this->phrasen['freebusy/aktiv']='Aktiv';
|
||||
$this->phrasen['freebusy/PfadZuFreebusyUrl']='Ihre Freebusy URL ist unter folgendem Link erreichbar:';
|
||||
$this->phrasen['freebusy/LVPlanBezeichnung']='Persönlicher LVPlan';
|
||||
$this->phrasen['freebusy/LVPlanTyp']='LVPlan';
|
||||
$this->phrasen['freebusy/neuerEintrag']='Neuen Eintrag hinzufügen';
|
||||
$this->phrasen['freebusy/beschreibungstext1']='Auf dieser Seite können Sie verschiedene externe FreeBusy Informationen zu einer FreeBusy URL zusammenfassen.';
|
||||
?>
|
||||
Reference in New Issue
Block a user