Merge branch 'master' into permissions

This commit is contained in:
Paolo
2018-06-26 13:38:12 +02:00
20 changed files with 288 additions and 286 deletions
+14 -14
View File
@@ -17,10 +17,10 @@ if (! defined('BASEPATH'))
class AmpelMail extends FHC_Controller
{
const CIS_AMPELVERWALTUNG_URL =
CIS_ROOT. "index.php?sprache=German&content_id=&menu=".
CIS_ROOT. "menu.php?content_id=&content=".
CIS_ROOT. "private/tools/ampelverwaltung.php";
CIS_ROOT. "cis/index.php?menu=".
CIS_ROOT. "cis/menu.php?content_id=&content=".
CIS_ROOT. "cis/private/tools/ampelverwaltung.php";
/**
* Constructor
*/
@@ -39,11 +39,11 @@ class AmpelMail extends FHC_Controller
echo "Jobs must be run from the CLI";
exit;
}
// Load models
$this->load->model('content/Ampel_model', 'AmpelModel');
$this->load->model('person/Person_model', 'PersonModel');
// Load helpers
$this->load->helper('sancho');
}
@@ -60,7 +60,7 @@ class AmpelMail extends FHC_Controller
echo $result. PHP_EOL;
}
/**
* Generates mail content for new and overdue Ampeln, which
* 1. are not confirmed by the user yet and
@@ -81,7 +81,7 @@ class AmpelMail extends FHC_Controller
if (hasData($result_active_ampeln))
{
$ampel_arr = $result_active_ampeln->retval;
// Loop through ampeln
foreach ($ampel_arr as $ampel)
{
@@ -95,11 +95,11 @@ class AmpelMail extends FHC_Controller
// get all user, who get this ampel
$result_ampel_user = $this->AmpelModel->execBenutzerSelect($qry_all_ampel_user);
if (hasData($result_ampel_user))
{
$ampel_user_arr = $result_ampel_user->retval;
// loop through all user, who get this ampel
foreach ($ampel_user_arr as $ampel_user)
{
@@ -131,7 +131,7 @@ class AmpelMail extends FHC_Controller
$html_text = '
<p><strong>'. strtoupper($ampel->kurzbz). '</strong><br>
<small>
<i style="color: #65696E;">Die Deadline für die Bestätigung war am
<i style="color: #65696E;">Die Deadline für die Bestätigung war am
<span style="color: #FF0000;">'. date_format($deadline, 'Y-m-d'). '</span>
</i>
</small></p><br>';
@@ -177,7 +177,7 @@ class AmpelMail extends FHC_Controller
);
};
}
// ------------------------------------------------------------------------
// Private methods
/**
@@ -190,10 +190,10 @@ class AmpelMail extends FHC_Controller
private function _getAmpelContentData($uid, $html_text, $ampel_data_arr)
{
$firstName = $this->PersonModel->getByUid($uid)->retval[0]->vorname;
// check if user already exists in the array
$key_position = array_search($uid, array_column($ampel_data_arr, 'uid'));
// If user already exists in the array, add only new ampel data to users ampel list
if ($key_position !== false)
{
+1 -1
View File
@@ -178,7 +178,7 @@ class Filters extends FHC_Controller
}
else
{
$this->outputJsonError('Wrong parameter');
$this->outputJsonError('An error occurred while saving a custom filter');
}
}
@@ -1199,14 +1199,16 @@ class InfoCenter extends Auth_Controller
$notizenBewerbung = $this->NotizModel->getNotizByTitel($person_id, 'Anmerkung zur Bewerbung')->retval;
$notizentext = '';
$lastElement = end($notizenBewerbung);
$notizentext = '<ul style="padding-left: 20px; margin-left: 0;">';
foreach ($notizenBewerbung as $notiz)
{
$notizentext .= $notiz->text;
if ($notiz != $lastElement)
$notizentext .= ' | ';
// For applicant-notices the user is not shown
if ($notiz->insertvon != 'online_notiz')
$notizentext .= '<li>'.$notiz->text.' ('.$notiz->insertvon.')</li>';
else
$notizentext .= '<li>'.$notiz->text.'</li>';
}
$notizentext .= '</ul>';
$mailadresse = '';
foreach ($person->kontakte as $kontakt)
+65 -101
View File
@@ -47,114 +47,23 @@ class NavigationLib
// Public methods
/**
* Creates the left Menu for each Page
* @param navigation_widget_called GET Parameter witch holds the currently called Page
* Creates the left menu for each Page
* @param navigationPage GET Parameter witch holds the currently called Page
* @return array with the Menu Entries
*/
public function getMenuArray($navigationPage)
{
$menuArray = array();
if (isset($navigationPage))
{
// Get Menu Entries of the Core
$navigationMenuArray = $this->_ci->config->item(self::CONFIG_MENU_NAME);
$menuArray = $this->_wildcardsearch($navigationMenuArray, $navigationPage);
// Load Menu Entries of Extensions
$extensions = $this->_ci->extensionslib->getInstalledExtensions();
if(hasData($extensions))
{
$json_extension = array();
foreach($extensions->retval as $ext)
{
$filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_NAVIGATION_FILENAME;
if (file_exists($filename))
{
unset($config);
include($filename);
if(isset($config[self::CONFIG_MENU_NAME]) && is_array($config[self::CONFIG_MENU_NAME]))
{
$json_extension = array_merge_recursive(
$json_extension,
$this->_wildcardsearch($config[self::CONFIG_MENU_NAME],
$navigationPage)
);
}
}
}
// Merge Extension Menuentries with the Core Entries
$menuArray = array_merge_recursive($menuArray, $json_extension);
}
// Load dynamic Menu Entries from Session
if (($navigationMenuSessionArray = $this->getSessionMenu()) != null)
{
if (isset($navigationMenuSessionArray) && is_array($navigationMenuSessionArray))
{
$menuArray = array_merge_recursive($menuArray, $navigationMenuSessionArray);
}
}
}
$this->_sortArray($menuArray);
return $menuArray;
return $this->_getNavigationArray($navigationPage, self::CONFIG_MENU_NAME, $this->getSessionMenu());
}
/**
* Creates the Top Menu for each Page
* @param navigation_widget_called GET Parameter witch holds the currently called Page
* Creates the header menu for each Page
* @param navigationPage GET Parameter witch holds the currently called Page
* @return array with the Menu Entries
*/
public function getHeaderArray($navigationPage)
{
$headerArray = array();
if (isset($navigationPage))
{
// Load Header Entries of Core
$navigationHeaderArray = $this->_ci->config->item(self::CONFIG_HEADER_NAME);
$headerArray = $this->_wildcardsearch($navigationHeaderArray, $navigationPage);
// Load Header Entries of Extensions
$extensions = $this->_ci->extensionslib->getInstalledExtensions();
if(hasData($extensions))
{
$headerArray_extension = array();
foreach($extensions->retval as $ext)
{
$filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_NAVIGATION_FILENAME;
if (file_exists($filename))
{
unset($config);
include($filename);
if(isset($config[self::CONFIG_HEADER_NAME]) && is_array($config[self::CONFIG_HEADER_NAME]))
{
$headerArray_extension = array_merge_recursive(
$json_extension,
$this->_wildcardsearch($config[self::CONFIG_HEADER_NAME],
$navigationPage)
);
}
}
}
$headerArray = array_merge_recursive($headerArray, $headerArray_extension);
}
// Load dynamic Header Entries from Session
if (($navigationHeaderSessionArray = $this->getSessionHeader()) != null)
{
if (isset($navigationHeaderSessionArray) && is_array($navigationHeaderSessionArray))
{
$headerArray = array_merge_recursive($headerArray, $navigationHeaderSessionArray);
}
}
}
$this->_sortArray($headerArray);
return $headerArray;
return $this->_getNavigationArray($navigationPage, self::CONFIG_HEADER_NAME, $this->getSessionHeader());
}
/**
@@ -292,6 +201,61 @@ class NavigationLib
//------------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Build the array needed by the NavigationWidget to render the left menu or the header
* menu depending on the given parameters
* @param navigationPage GET Parameter witch holds the currently called Page
* @param configName the name of the navigation config entry
* @param sessionArray array present in the session that could contains other menu entries
* @return array with the Menu Entries
*/
private function _getNavigationArray($navigationPage, $configName, $sessionArray)
{
$navigationArray = array();
if (isset($navigationPage))
{
// Load Header Entries of Core
$configArray = $this->_ci->config->item($configName);
$navigationArray = $this->_wildcardsearch($configArray, $navigationPage);
// Load Header Entries of Extensions
$extensions = $this->_ci->extensionslib->getInstalledExtensions();
if (hasData($extensions))
{
$extensionArray = array();
foreach ($extensions->retval as $ext)
{
$filename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_NAVIGATION_FILENAME;
if (file_exists($filename))
{
unset($config);
include($filename);
if (isset($config[$configName]) && is_array($config[$configName]))
{
$extensionArray = array_merge_recursive(
$json_extension,
$this->_wildcardsearch($config[$configName],
$navigationPage)
);
}
}
}
$navigationArray = array_merge_recursive($navigationArray, $extensionArray);
}
// Load dynamic header entries from session
if ($sessionArray != null && is_array($sessionArray))
{
$navigationArray = array_merge_recursive($navigationArray, $sessionArray);
}
}
$this->_sortArray($navigationArray);
return $navigationArray;
}
/**
* Searches a Menuentry. If there is no exact entry it searches for Wildcard Entries with a Star
* Example:
@@ -311,20 +275,20 @@ class NavigationLib
krsort($navigationArray);
// 100% match found
if(isset($navigationArray[$navigationPage]))
if (isset($navigationArray[$navigationPage]))
{
return $navigationArray[$navigationPage];
}
else
{
foreach($navigationArray as $key=>$row)
foreach ($navigationArray as $key=>$row)
{
// Search for * Entries
if(mb_strpos($key, '*') === 0 || mb_strpos($key, '*') === mb_strlen($key) - 1)
if (mb_strpos($key, '*') === 0 || mb_strpos($key, '*') === mb_strlen($key) - 1)
{
// Take * Entry if Matches
$search = mb_substr($key, 0, -1);
if($search == '' || mb_strpos($navigationPage, $search) === 0)
if ($search == '' || mb_strpos($navigationPage, $search) === 0)
{
return $row;
}
+13 -13
View File
@@ -10,7 +10,7 @@ class Ampel_model extends DB_Model
$this->dbTable = 'public.tbl_ampel';
$this->pk = 'ampel_id';
}
/**
* Returns all active Ampeln, that are actually:
* 1. not after the deadline date
@@ -25,24 +25,24 @@ class Ampel_model extends DB_Model
SELECT *
FROM public.tbl_ampel
WHERE';
if ($email === true)
{
$parametersArray['email'] = $email;
$query .= ' email = ? AND';
}
$query .= '
(NOW()<(deadline+(verfallszeit || \' days\')::interval)::date)
OR (verfallszeit IS NULL AND NOW() < deadline)
AND (NOW()>(deadline-(vorlaufzeit || \' days\')::interval)::date)
OR (vorlaufzeit IS NULL AND NOW() > deadline)';
(NOW()<(deadline+(COALESCE(verfallszeit,0) || \' days\')::interval)::date)
OR (verfallszeit IS NULL)
AND (NOW()>(deadline-(COALESCE(vorlaufzeit,0) || \' days\')::interval)::date)
OR (vorlaufzeit IS NULL AND NOW() < deadline)';
$query .= ' ORDER BY deadline DESC';
return $this->execQuery($query, $parametersArray);
}
/**
* Returns all Ampel-receiver of a specific Ampel.
* @param string $benutzer_select SQL Statement which defines the Ampel-receiver.
@@ -55,7 +55,7 @@ class Ampel_model extends DB_Model
return $this->execQuery($benutzer_select);
}
}
/**
* Checks if Ampel was confirmed by the user.
* @param int $ampel_id Ampel-ID
@@ -75,7 +75,7 @@ class Ampel_model extends DB_Model
{
$result = $this->execQuery($query, array($ampel_id, $uid));
}
if ($result)
{
if (count($result->retval) > 0)
@@ -87,7 +87,7 @@ class Ampel_model extends DB_Model
return false;
}
}
else
else
return $result; //will contain the error-msg from execQuery
}
}