mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-10 08:39:28 +00:00
Merge branch 'ci' of https://github.com/FH-Complete/FHC-Core into ci
Conflicts: application/core/FHC_Controller.php
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class DmsFS_model extends FS_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->filepath = DMS_PATH;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
class DmsVersion_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'campus.tbl_dms_version';
|
||||
$this->pk = array('dms_id', 'version');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function filterFields($dms, $dms_id = null, $fileName = null)
|
||||
{
|
||||
$fieldsArray = array(
|
||||
'version',
|
||||
'mimetype',
|
||||
'name',
|
||||
'beschreibung',
|
||||
'letzterzugriff',
|
||||
'insertamum',
|
||||
'insertvon',
|
||||
'updateamum',
|
||||
'updatevon'
|
||||
);
|
||||
$returnArray = array();
|
||||
|
||||
foreach ($fieldsArray as $value)
|
||||
{
|
||||
if (isset($dms[$value]))
|
||||
{
|
||||
$returnArray[$value] = $dms[$value];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($dms_id))
|
||||
{
|
||||
$returnArray['dms_id'] = $dms_id;
|
||||
}
|
||||
if (isset($fileName))
|
||||
{
|
||||
$returnArray['filename'] = $fileName;
|
||||
}
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
}
|
||||
@@ -12,39 +12,22 @@ class Dms_model extends DB_Model
|
||||
$this->pk = 'dms_id';
|
||||
}
|
||||
|
||||
public function insertDmsVersion($data)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function filterFields($dms)
|
||||
{
|
||||
$tableName = 'campus.tbl_dms_version';
|
||||
$fieldsArray = array('oe_kurzbz', 'dokument_kurzbz', 'kategorie_kurzbz');
|
||||
$returnArray = array();
|
||||
|
||||
// Check rights
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl[$tableName], 'i'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$tableName], FHC_MODEL_ERROR);
|
||||
|
||||
// DB-INSERT
|
||||
if ($this->db->insert($tableName, $data))
|
||||
return $this->_success($this->db->insert_id());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
|
||||
public function updateDmsVersion($id, $data)
|
||||
{
|
||||
$tableName = 'campus.tbl_dms_version';
|
||||
foreach ($fieldsArray as $value)
|
||||
{
|
||||
if (isset($dms[$value]))
|
||||
{
|
||||
$returnArray[$value] = $dms[$value];
|
||||
}
|
||||
}
|
||||
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->pk))
|
||||
return $this->_error(lang('fhc_'.FHC_NOPK), FHC_MODEL_ERROR);
|
||||
|
||||
// Check rights
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl[$tableName], 'u'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$tableName], FHC_MODEL_ERROR);
|
||||
|
||||
// DB-UPDATE
|
||||
$this->db->where('dms_id', $id);
|
||||
|
||||
if ($this->db->update($tableName, $data))
|
||||
return $this->_success($id);
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
return $returnArray;
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,86 @@ class Message_model extends DB_Model
|
||||
$this->pk = 'message_id';
|
||||
}
|
||||
|
||||
public function getMessagesByUID($uid, $all)
|
||||
{
|
||||
// Check wrights
|
||||
// @ToDo: Define the special wright for reading own messages "basis/message:own"
|
||||
// if same user
|
||||
if ($uid === $this->getUID())
|
||||
{
|
||||
if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> system/message', FHC_MODEL_ERROR);
|
||||
}
|
||||
// if different user, for reading messages from other users
|
||||
else
|
||||
{
|
||||
if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> system/message:all', FHC_MODEL_ERROR);
|
||||
}
|
||||
|
||||
// get Data
|
||||
$sql = 'SELECT uid, person_id, message_id, subject, priority, relationmessage_id, oe_kurzbz, m.insertamum, anrede, titelpost, titelpre, nachname, vorname, vornamen,
|
||||
status, statusinfo, s.insertamum AS statusamum
|
||||
FROM public.tbl_msg_message m
|
||||
JOIN public.tbl_person USING (person_id)
|
||||
JOIN public.tbl_benutzer USING (person_id)
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT message_id, person_id, status, statusinfo, tbl_msg_status.insertamum
|
||||
FROM public.tbl_msg_status
|
||||
INNER JOIN
|
||||
(
|
||||
SELECT message_id, person_id, max(insertamum) AS insertamum
|
||||
FROM public.tbl_msg_status
|
||||
GROUP BY message_id, person_id
|
||||
) status
|
||||
USING (message_id, person_id)
|
||||
WHERE tbl_msg_status.insertamum=status.insertamum
|
||||
) s
|
||||
USING (message_id, person_id)
|
||||
WHERE uid = ?';
|
||||
if (! $all)
|
||||
$sql .= ' AND status<2';
|
||||
$result = $this->db->query($sql, array($uid));
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
|
||||
public function getMessagesByPerson($person_id, $all)
|
||||
{
|
||||
// Check wrights
|
||||
if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> system/message', FHC_MODEL_ERROR);
|
||||
|
||||
// get Data
|
||||
$sql = 'SELECT person_id, message_id, subject, priority, relationmessage_id, oe_kurzbz, m.insertamum, anrede, titelpost, titelpre, nachname, vorname, vornamen,
|
||||
status, statusinfo, s.insertamum AS statusamum
|
||||
FROM public.tbl_msg_message m
|
||||
JOIN public.tbl_person USING (person_id)
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT message_id, person_id, status, statusinfo, tbl_msg_status.insertamum
|
||||
FROM public.tbl_msg_status
|
||||
INNER JOIN
|
||||
(
|
||||
SELECT message_id, person_id, max(insertamum) AS insertamum
|
||||
FROM public.tbl_msg_status
|
||||
GROUP BY message_id, person_id
|
||||
) status
|
||||
USING (message_id, person_id)
|
||||
WHERE tbl_msg_status.insertamum=status.insertamum
|
||||
) s
|
||||
USING (message_id, person_id)
|
||||
WHERE person_id = ?';
|
||||
if (! $all)
|
||||
$sql .= ' AND status<2';
|
||||
$result = $this->db->query($sql, array($person_id));
|
||||
//var_dump($result);
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
/* end of file Message_model.php */
|
||||
|
||||
Reference in New Issue
Block a user