Merge remote-tracking branch 'origin/master'

This commit is contained in:
alex
2018-04-18 14:49:46 +02:00
14 changed files with 1194 additions and 621 deletions
@@ -213,4 +213,37 @@ class Person_model extends DB_Model
return $this->loadWhere(array('uid' => $uid));
}
/**
* Retrives the language of the user by the UID
* Gets all the persons related to the given UID and starting from the most recent person in DB
* tries to find a valid language (!= null), if found is returned, otherwise is returned the
* default global language of the system
*/
public function getLanguage($uid)
{
$language = DEFAULT_LANGUAGE;
$this->addJoin('public.tbl_benutzer', 'person_id');
$this->addOrder('public.tbl_person.updateamum', 'DESC');
$this->addOrder('public.tbl_person.insertvon', 'DESC');
$persons = $this->loadWhere(array('uid' => $uid));
if (hasData($persons))
{
for ($i = 0; $i < count($persons->retval); $i++)
{
$person = $persons->retval[$i];
if (!empty($person->sprache))
{
$language = $person->sprache;
break;
}
}
}
return $language;
}
}
+20 -3
View File
@@ -22,7 +22,7 @@ class Phrase_model extends DB_Model
return $ent;
if (isError($ent = $this->isEntitled('system.tbl_phrasentext', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
$parametersArray = array('app' => $app, 'sprache' => $sprache);
$query = 'SELECT phrase,
@@ -36,7 +36,7 @@ class Phrase_model extends DB_Model
if (isset($phrase))
{
$parametersArray['phrase'] = $phrase;
if (is_array($phrase))
{
$query .= ' AND phrase IN ?';
@@ -57,7 +57,24 @@ class Phrase_model extends DB_Model
$parametersArray['orgform_kurzbz'] = $orgform_kurzbz;
$query .= ' AND orgform_kurzbz = ?';
}
return $this->execQuery($query, $parametersArray);
}
/**
* Loads phrases using category(s) and language as keys
* The retrived fields are category, phrase, orgeinheit_kurzbz, orgform_kurzbz and text
* They are ordered by p.category, p.phrase, pt.orgeinheit_kurzbz DESC and pt.orgform_kurzbz DESC'
*/
public function getPhrasesByCategoryAndLanguage($categories, $language)
{
$query = 'SELECT p.category, p.phrase, pt.orgeinheit_kurzbz, pt.orgform_kurzbz, pt.text
FROM system.tbl_phrase p
INNER JOIN system.tbl_phrasentext pt USING(phrase_id)
WHERE p.category IN ?
AND pt.sprache = ?
ORDER BY p.category, p.phrase, pt.orgeinheit_kurzbz DESC, pt.orgform_kurzbz DESC';
return $this->execQuery($query, array($categories, $language));
}
}