first api
This commit is contained in:
parent
124cf64d4f
commit
a041e0efbb
|
@ -1,5 +1,63 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns Shift id array
|
||||||
|
*/
|
||||||
|
function mShiftList() {
|
||||||
|
global $_REQUEST;
|
||||||
|
$filter = "";
|
||||||
|
|
||||||
|
// filterRoom (Array of integer) - Array of Room IDs (optional, for list request)
|
||||||
|
if (isset($_REQUEST['filterRoom']) && is_array($_REQUEST['filterRoom']) ) {
|
||||||
|
foreach ( $_REQUEST['filterRoom'] as $key => $value ) {
|
||||||
|
$filter .= ", `RID`=" . sql_escape($value) . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//filterTask (Array of integer) - Array if Task (optional, for list request)
|
||||||
|
if (isset($_REQUEST['filterTask']) && is_array($_REQUEST['filterTask']) ) {
|
||||||
|
foreach ( $_REQUEST['filterTask'] as $key => $value ) {
|
||||||
|
// TODO $filter .= ", `RID`=" . sql_escape($value) . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// filterOccupancy (integer) - Occupancy state: (optional, for list request)
|
||||||
|
// 1 occupied, 2 free, 3 occupied and free
|
||||||
|
if (isset($_REQUEST['filterOccupancy']) && is_array($_REQUEST['filterOccupancy']) ) {
|
||||||
|
foreach ( $_REQUEST['filterOccupancy'] as $key => $value ) {
|
||||||
|
// TODO $filter .= ", `RID`=" . sql_escape($value) . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// format filter
|
||||||
|
if( $filter != "" ) {
|
||||||
|
$filter = ' WHERE '. substr($filter, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// real request
|
||||||
|
$shifts_source = sql_select("SELECT `SID` FROM `Shifts`". $filter);
|
||||||
|
if ($shifts_source === false)
|
||||||
|
return false;
|
||||||
|
if (count($shifts_source) > 0) {
|
||||||
|
return $shifts_source;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns Shift by id.
|
||||||
|
*
|
||||||
|
* @param $id Shift ID
|
||||||
|
*/
|
||||||
|
function mShift($id) {
|
||||||
|
$shifts_source = sql_select("SELECT * FROM `Shifts` WHERE `SID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
|
if ($shifts_source === false)
|
||||||
|
return false;
|
||||||
|
if (count($shifts_source) > 0)
|
||||||
|
return $shifts_source[0];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns User id array
|
||||||
|
*/
|
||||||
|
function mUserList() {
|
||||||
|
$user_source = sql_select("SELECT `UID` FROM `User`");
|
||||||
|
if ($user_source === false)
|
||||||
|
return false;
|
||||||
|
if (count($user_source) > 0)
|
||||||
|
return $user_source;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip unwanted characters from a users nick.
|
* Strip unwanted characters from a users nick.
|
||||||
* @param string $nick
|
* @param string $nick
|
||||||
|
@ -22,6 +34,20 @@ function User($id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns user by id (limit informations.
|
||||||
|
*
|
||||||
|
* @param $id UID
|
||||||
|
*/
|
||||||
|
function mUser_Limit($id) {
|
||||||
|
$user_source = sql_select("SELECT `UID`, `Nick`, `Name`, `Vorname`, `Telefon`, `DECT`, `Handy`, `email`, `ICQ`, `jabber`, `Avatar` FROM `User` WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
|
if ($user_source === false)
|
||||||
|
return false;
|
||||||
|
if (count($user_source) > 0)
|
||||||
|
return $user_source[0];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns User by api_key.
|
* Returns User by api_key.
|
||||||
*
|
*
|
||||||
|
@ -95,4 +121,4 @@ function User_generate_password_recovery_token(&$user) {
|
||||||
return $user['password_recovery_token'];
|
return $user['password_recovery_token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -15,6 +15,9 @@ require_once ('includes/model/NeededAngelTypes_model.php');
|
||||||
require_once ('includes/model/ShiftEntry_model.php');
|
require_once ('includes/model/ShiftEntry_model.php');
|
||||||
require_once ('includes/model/Shifts_model.php');
|
require_once ('includes/model/Shifts_model.php');
|
||||||
require_once ('includes/model/User_model.php');
|
require_once ('includes/model/User_model.php');
|
||||||
|
require_once ('includes/model/Room_model.php');
|
||||||
|
require_once ('includes/model/Message_model.php');
|
||||||
|
require_once ('includes/model/AngelType_model.php');
|
||||||
|
|
||||||
require_once ('includes/view/Questions_view.php');
|
require_once ('includes/view/Questions_view.php');
|
||||||
require_once ('includes/view/Shifts_view.php');
|
require_once ('includes/view/Shifts_view.php');
|
||||||
|
@ -66,7 +69,8 @@ if (isset($_REQUEST['auth']))
|
||||||
$free_pages = array(
|
$free_pages = array(
|
||||||
'stats',
|
'stats',
|
||||||
'shifts_json_export_all',
|
'shifts_json_export_all',
|
||||||
'user_password_recovery'
|
'user_password_recovery',
|
||||||
|
'api'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Gewünschte Seite/Funktion
|
// Gewünschte Seite/Funktion
|
||||||
|
@ -78,7 +82,10 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i
|
||||||
$title = $p;
|
$title = $p;
|
||||||
$content = "";
|
$content = "";
|
||||||
|
|
||||||
if ($p == "ical") {
|
if ($p == "api") {
|
||||||
|
require_once ('includes/controller/api.php');
|
||||||
|
api_controller();
|
||||||
|
} elseif ($p == "ical") {
|
||||||
require_once ('includes/pages/user_ical.php');
|
require_once ('includes/pages/user_ical.php');
|
||||||
user_ical();
|
user_ical();
|
||||||
} elseif ($p == "atom") {
|
} elseif ($p == "atom") {
|
||||||
|
|
Loading…
Reference in New Issue