summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2013-12-29 15:08:21 +0100
committerPhilip Häusler <msquare@notrademark.de>2013-12-29 15:08:21 +0100
commita041e0efbb9825a9c8d77cba989dcea27d0f825d (patch)
tree218552b88cc74b883b31729234d83a803ff3bf6b /includes
parent124cf64d4fc6a277838de491bc6f5bfd443e6019 (diff)
first api
Diffstat (limited to 'includes')
-rw-r--r--includes/model/Shifts_model.php58
-rw-r--r--includes/model/User_model.php28
2 files changed, 85 insertions, 1 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 5e8a2b54..224bfc0b 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -1,6 +1,64 @@
<?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.
*/
function Shifts() {
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index a69c288c..6b23f74b 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -1,6 +1,18 @@
<?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.
* @param string $nick
*/
@@ -23,6 +35,20 @@ function User($id) {
}
/**
+ * 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.
*
* @param string $api_key
@@ -95,4 +121,4 @@ function User_generate_password_recovery_token(&$user) {
return $user['password_recovery_token'];
}
-?> \ No newline at end of file
+?>