Files
FHC-Core/application/models/system/Phrase_model.php
T
bison-paolo 8e0ca12deb - All permission functionalities now are in the library PermissionLib
- All return messages functions are in the message helper and it is loaded by the core classes
- Added the missing constant FHC_NOPK
- Updated all the interested classes with the new permission method
- Updated all the interested classes with the new return message functions
2016-10-13 17:53:12 +02:00

69 lines
1.6 KiB
PHP

<?php
class Phrase_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'system.tbl_phrase';
$this->pk = 'phrase_id';
}
/**
*
*/
public function getPhrases($app, $sprache, $phrase = null, $orgeinheit_kurzbz = null, $orgform_kurzbz = null)
{
// Checks if the operation is permitted by the API caller
if (($chkRights = $this->isEntitled('system.tbl_phrase', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
return $chkRights;
if (($chkRights = $this->isEntitled('system.tbl_phrasentext', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
return $chkRights;
$parametersArray = array('app' => $app, 'sprache' => $sprache);
$query = 'SELECT phrase,
sprache,
orgeinheit_kurzbz,
orgform_kurzbz,
text
FROM system.tbl_phrase JOIN system.tbl_phrasentext USING (phrase_id)
WHERE app = ? AND sprache = ?';
if (isset($phrase))
{
$parametersArray['phrase'] = $phrase;
if (is_array($phrase))
{
$query .= ' AND phrase IN ?';
}
else
{
$query .= ' AND phrase = ?';
}
}
if (isset($orgeinheit_kurzbz))
{
$parametersArray['orgeinheit_kurzbz'] = $orgeinheit_kurzbz;
$query .= ' AND orgeinheit_kurzbz = ?';
}
if (isset($orgform_kurzbz))
{
$parametersArray['orgform_kurzbz'] = $orgform_kurzbz;
$query .= ' AND orgform_kurzbz = ?';
}
$result = $this->db->query($query, $parametersArray);
if (is_object($result))
return success($result->result());
else
return error($this->db->error(), FHC_DB_ERROR);
}
}