mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
Merge branch 'master' into feature-5491/UDFWidget_add_new_features
This commit is contained in:
@@ -11,7 +11,7 @@ class Benutzerrolle_model extends DB_Model
|
||||
$this->dbTable = 'system.tbl_benutzerrolle';
|
||||
$this->pk = 'benutzerberechtigung_id';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the given user is an admin
|
||||
*/
|
||||
@@ -19,9 +19,9 @@ class Benutzerrolle_model extends DB_Model
|
||||
{
|
||||
// Join with the table tbl_benutzer
|
||||
$this->addJoin('public.tbl_benutzer', 'uid');
|
||||
|
||||
|
||||
$result = $this->loadWhere(array('person_id' => $person_id, 'rolle_kurzbz' => 'admin'));
|
||||
|
||||
|
||||
if (!isError($result))
|
||||
{
|
||||
if (hasData($result))
|
||||
@@ -33,25 +33,35 @@ class Benutzerrolle_model extends DB_Model
|
||||
$result = success(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user who are authorized with berechtigung and, if given, authorized for the specific organisational unit.
|
||||
* @param $berechtigung_kurzbz
|
||||
* @param null $oe_kurzbz
|
||||
* @return array
|
||||
*/
|
||||
public function getBenutzerByBerechtigung($berechtigung_kurzbz, $oe_kurzbz = null){
|
||||
/**
|
||||
* Get user who are authorized with berechtigung and, if given, authorized for the specific organisational unit.
|
||||
* @param $berechtigung_kurzbz
|
||||
* @param null $oe_kurzbz
|
||||
* @return array
|
||||
*/
|
||||
public function getBenutzerByBerechtigung($berechtigung_kurzbz, $oe_kurzbz = null)
|
||||
{
|
||||
$params = array();
|
||||
$query = '
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
system.vw_berechtigung_nichtrekursiv
|
||||
WHERE
|
||||
berechtigung_kurzbz = ?';
|
||||
|
||||
$condition = array('berechtigung_kurzbz' => $berechtigung_kurzbz);
|
||||
$params[] = $berechtigung_kurzbz;
|
||||
|
||||
if (is_string($oe_kurzbz))
|
||||
{
|
||||
$condition['oe_kurzbz'] = $oe_kurzbz;
|
||||
}
|
||||
if (!is_null($oe_kurzbz))
|
||||
{
|
||||
$query .= ' AND oe_kurzbz = ?';
|
||||
$params[] = $oe_kurzbz;
|
||||
}
|
||||
|
||||
return $this->loadWhere($condition);
|
||||
}
|
||||
}
|
||||
return $this->execQuery($query, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,17 +37,7 @@ class MessageToken_model extends DB_Model
|
||||
WHERE r.token = ?
|
||||
LIMIT 1';
|
||||
|
||||
$result = $this->db->query($sql, array(MSG_STATUS_DELETED, $token));
|
||||
|
||||
// If no errors occurred
|
||||
if ($result)
|
||||
{
|
||||
return success($result->result());
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
return $this->execQuery($sql, array(MSG_STATUS_DELETED, $token));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,25 +64,24 @@ class MessageToken_model extends DB_Model
|
||||
WHERE r.token = ?
|
||||
LIMIT 1';
|
||||
|
||||
$msgs = $this->db->query($sql, array(MSG_STATUS_ARCHIVED, $token));
|
||||
$msgsResult = $this->execQuery($sql, array(MSG_STATUS_ARCHIVED, $token));
|
||||
|
||||
// If no errors occurred
|
||||
if ($msgs)
|
||||
if (isSuccess($msgsResult))
|
||||
{
|
||||
$msgs_result = $msgs->result();
|
||||
// If at least a record is present
|
||||
if (count($msgs_result) > 0)
|
||||
if (hasData($msgsResult))
|
||||
{
|
||||
$msg = $msgs_result[0];
|
||||
$msg = getData($msgsResult)[0];
|
||||
$msgStatusResult = error();
|
||||
|
||||
$msgStatusResult = false; // pessimistic expectation
|
||||
$this->load->model('system/MsgStatus_model', 'MsgStatusModel');
|
||||
|
||||
// If the status of the message is unread
|
||||
if ($msg->status == MSG_STATUS_UNREAD)
|
||||
{
|
||||
// Insert the read status
|
||||
$msgStatusResult = $this->db->insert(
|
||||
'public.tbl_msg_status',
|
||||
$msgStatusResult = $this->MsgStatusModel->insert(
|
||||
array(
|
||||
'message_id' => $msg->message_id,
|
||||
'person_id' => $msg->receiver_id,
|
||||
@@ -108,31 +97,23 @@ class MessageToken_model extends DB_Model
|
||||
// If the status of the message is read
|
||||
else if ($msg->status == MSG_STATUS_READ)
|
||||
{
|
||||
// Update updateamum to current date
|
||||
$this->db->set('updateamum', 'NOW()');
|
||||
|
||||
$this->db->where('message_id', $msg->message_id);
|
||||
$this->db->where('person_id', $msg->receiver_id);
|
||||
$this->db->where('status', MSG_STATUS_READ);
|
||||
|
||||
$msgStatusResult = $this->db->update('public.tbl_msg_status');
|
||||
$msgStatusResult = $this->MsgStatusModel->update(
|
||||
array(
|
||||
'message_id' => $msg->message_id,
|
||||
'person_id' => $msg->receiver_id,
|
||||
'status' => MSG_STATUS_READ
|
||||
),
|
||||
array('updateamum' => 'NOW()')
|
||||
);
|
||||
}
|
||||
|
||||
// If some of the previous DB manipulation (update or insert) has failed
|
||||
if (!$msgStatusResult)
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
return $msgStatusResult;
|
||||
}
|
||||
|
||||
return success($msgs_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
return $msgsResult;
|
||||
}
|
||||
|
||||
return success($result->result());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,17 +133,7 @@ class MessageToken_model extends DB_Model
|
||||
LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
|
||||
WHERE p.person_id = ?';
|
||||
|
||||
$result = $this->db->query($sql, array($person_id));
|
||||
|
||||
// If no errors occurred
|
||||
if ($result)
|
||||
{
|
||||
return success($result->result());
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
return $this->execQuery($sql, array($person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,17 +151,7 @@ class MessageToken_model extends DB_Model
|
||||
FROM public.tbl_person
|
||||
WHERE person_id %s ?';
|
||||
|
||||
$result = $this->db->query(sprintf($sql, is_array($person_id) ? 'IN' : '='), array($person_id));
|
||||
|
||||
// If no errors occurred
|
||||
if ($result)
|
||||
{
|
||||
return success($result->result());
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
return $this->execQuery(sprintf($sql, is_array($person_id) ? 'IN' : '='), array($person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,35 +161,12 @@ class MessageToken_model extends DB_Model
|
||||
{
|
||||
$sql = 'SELECT m.mitarbeiter_uid
|
||||
FROM public.tbl_person p
|
||||
LEFT JOIN public.tbl_benutzer b USING(person_id)
|
||||
LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
|
||||
JOIN public.tbl_benutzer b USING(person_id)
|
||||
JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
|
||||
WHERE p.person_id = ?
|
||||
AND b.aktiv = TRUE';
|
||||
|
||||
$result = $this->db->query($sql, array($person_id));
|
||||
|
||||
// If no errors occurred
|
||||
if ($result)
|
||||
{
|
||||
// If data are present
|
||||
if (is_array($result->result()) && count($result->result()) > 0)
|
||||
{
|
||||
$personresults = $result->result();
|
||||
$person = $personresults[0];
|
||||
|
||||
// If it is an employee
|
||||
if ($person->mitarbeiter_uid != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
return $this->execQuery($sql, array($person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,28 +192,6 @@ class MessageToken_model extends DB_Model
|
||||
LIMIT 1
|
||||
';
|
||||
|
||||
$result = $this->db->query($sql, array($oe_kurzbz));
|
||||
if ($result) // If no errors occurred
|
||||
{
|
||||
$result_arr = $result->result();
|
||||
// If data are present
|
||||
if (is_array($result_arr)
|
||||
&& count($result_arr) > 0
|
||||
&& is_object($result_arr[0])
|
||||
&& isset($result_arr[0]->oe_kurzbz))
|
||||
{
|
||||
return success($result_arr[0]->oe_kurzbz);
|
||||
}
|
||||
else
|
||||
{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->execQuery($sql, array($oe_kurzbz));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ class PersonLock_model extends DB_Model
|
||||
|
||||
$result = $this->loadWhere($lockdata);
|
||||
|
||||
if ($result->error)
|
||||
return error($result->retval);
|
||||
if ($result->error) return $result;
|
||||
|
||||
if (count($result->retval) > 0)
|
||||
return success($result->retval);
|
||||
@@ -49,8 +48,7 @@ class PersonLock_model extends DB_Model
|
||||
{
|
||||
$locked = $this->checkIfLocked($person_id, $app);
|
||||
|
||||
if ($locked->error)
|
||||
return error($locked->retval);
|
||||
if ($locked->error) return $locked;
|
||||
|
||||
//insert only if not already locked
|
||||
if ($locked->retval === null)
|
||||
@@ -77,8 +75,7 @@ class PersonLock_model extends DB_Model
|
||||
foreach ($locks->retval as $lock)
|
||||
{
|
||||
$result = $this->delete($lock->lock_id);
|
||||
if ($result->error)
|
||||
return error($result->retval);
|
||||
if ($result->error) return $result;
|
||||
|
||||
$deleted[] = $lock;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Variablenname_model extends DB_Model
|
||||
/**
|
||||
* Gets defaults for user variables.
|
||||
* If no default value present in table, SQL can be executed for retrieving the value.
|
||||
* @param null $names optionally get only defaults for certain variables
|
||||
* @param $names optionally get only defaults for certain variables
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaults($names = null)
|
||||
@@ -36,13 +36,13 @@ class Variablenname_model extends DB_Model
|
||||
|
||||
$qry = "SELECT name, defaultwert FROM public.tbl_variablenname";
|
||||
|
||||
if (isset($names) && is_array($names))
|
||||
if (!isEmptyArray($names))
|
||||
{
|
||||
$qry .= " WHERE name IN ('".implode(',', $names)."')";
|
||||
$qry .= " WHERE name IN ?";
|
||||
}
|
||||
$qry .= ";";
|
||||
|
||||
$defaultsres = $this->execQuery($qry);
|
||||
$defaultsres = $this->execQuery($qry, array('name' => $names));
|
||||
|
||||
if (hasData($defaultsres))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user