mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 10:22:18 +00:00
Merge origin/ci into ci
This commit is contained in:
@@ -155,8 +155,10 @@ $config['fhc_acl'] = array
|
|||||||
'public.tbl_lehrverband' => 'basis/lehrverband',
|
'public.tbl_lehrverband' => 'basis/lehrverband',
|
||||||
'public.tbl_log' => 'basis/log',
|
'public.tbl_log' => 'basis/log',
|
||||||
'public.tbl_mitarbeiter' => 'basis/mitarbeiter',
|
'public.tbl_mitarbeiter' => 'basis/mitarbeiter',
|
||||||
'public.tbl_msg_message' => 'basis/msg_message',
|
'public.tbl_msg_message' => 'basis/message',
|
||||||
'public.tbl_msg_thread' => 'basis/msg_thread',
|
'public.tbl_msg_recipient' => 'basis/message',
|
||||||
|
'public.tbl_msg_status' => 'basis/message',
|
||||||
|
'public.tbl_msg_attachment' => 'basis/message',
|
||||||
'public.tbl_notiz' => 'basis/notiz',
|
'public.tbl_notiz' => 'basis/notiz',
|
||||||
'public.tbl_notizzuordnung' => 'basis/notizzuordnung',
|
'public.tbl_notizzuordnung' => 'basis/notizzuordnung',
|
||||||
'public.tbl_organisationseinheit' => 'basis/organisationseinheit',
|
'public.tbl_organisationseinheit' => 'basis/organisationseinheit',
|
||||||
@@ -228,7 +230,5 @@ $config['fhc_acl'] = array
|
|||||||
'wawi.tbl_rechnungstyp' => 'basis/rechnungstyp',
|
'wawi.tbl_rechnungstyp' => 'basis/rechnungstyp',
|
||||||
'wawi.tbl_zahlungstyp' => 'basis/zahlungstyp',
|
'wawi.tbl_zahlungstyp' => 'basis/zahlungstyp',
|
||||||
|
|
||||||
'public.tbl_sprache' => 'admin',
|
'public.tbl_sprache' => 'admin'
|
||||||
'public.tbl_msg_thread' => 'admin',
|
|
||||||
'public.tbl_msg_message' => 'admin'
|
|
||||||
);
|
);
|
||||||
@@ -55,7 +55,8 @@ $config['migration_type'] = 'sequential';
|
|||||||
| will migrate up. This must be set.
|
| will migrate up. This must be set.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
$config['migration_table'] = 'system.ci_migrations';
|
//$config['migration_table'] = 'system.ci_migrations'; // A missing feature or a bug cannot use another schema than public. Bug: tableExists only looks in the public schema.
|
||||||
|
$config['migration_table'] = 'ci_migrations';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
| 'cache_ttl' = the time all partials should be cache in seconds, 0 means no global caching
|
| 'cache_ttl' = the time all partials should be cache in seconds, 0 means no global caching
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['parser'] = FALSE;
|
$config['parser'] = TRUE;
|
||||||
$config['template'] = 'template';
|
$config['template'] = 'templates/vilesci';
|
||||||
$config['cache_ttl'] = 0;
|
$config['cache_ttl'] = 0;
|
||||||
@@ -91,16 +91,16 @@ class DBTools extends FHC_Controller
|
|||||||
*/
|
*/
|
||||||
public function migrate($version = 'latest')
|
public function migrate($version = 'latest')
|
||||||
{
|
{
|
||||||
if ($this->cli && $this->migration->current() === false)
|
echo 'DB-Migration';
|
||||||
{
|
if ($version != 'latest' && $version != 'current')
|
||||||
show_error($this->migration->error_string());
|
|
||||||
}
|
|
||||||
elseif ($version != 'latest' && $version != 'current')
|
|
||||||
{
|
{
|
||||||
$this->__failed('Migration version must be either latest or current');
|
$this->__failed('Migration version must be either latest or current');
|
||||||
}
|
}
|
||||||
|
elseif ($this->cli && !$this->migration->$version())
|
||||||
if (!$this->migration->$version())
|
{
|
||||||
|
show_error($this->migration->error_string());
|
||||||
|
}
|
||||||
|
elseif (!$this->migration->$version())
|
||||||
{
|
{
|
||||||
$this->__failed();
|
$this->__failed();
|
||||||
}
|
}
|
||||||
@@ -181,6 +181,8 @@ class DBTools extends FHC_Controller
|
|||||||
|
|
||||||
$method = 'seed';
|
$method = 'seed';
|
||||||
$pending = array();
|
$pending = array();
|
||||||
|
|
||||||
|
|
||||||
foreach ($seeds as $number => $file)
|
foreach ($seeds as $number => $file)
|
||||||
{
|
{
|
||||||
include_once($file);
|
include_once($file);
|
||||||
@@ -203,13 +205,24 @@ class DBTools extends FHC_Controller
|
|||||||
|
|
||||||
$pending[$number] = array($class, $method);
|
$pending[$number] = array($class, $method);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now just run the necessary seeds
|
// Now just run the necessary seeds
|
||||||
foreach ($pending as $number => $seed)
|
foreach ($pending as $number => $seed)
|
||||||
{
|
{
|
||||||
log_message('debug', 'Seeding '.$method);
|
if (is_null($name))
|
||||||
|
{
|
||||||
|
log_message('debug', 'Seeding '.$method);
|
||||||
|
|
||||||
$seed[0] = new $seed[0];
|
$seed[0] = new $seed[0];
|
||||||
call_user_func($seed);
|
call_user_func($seed);
|
||||||
|
}
|
||||||
|
elseif ($seed[0] == 'Seed_'.$name)
|
||||||
|
{
|
||||||
|
log_message('debug', 'Seeding '.$method);
|
||||||
|
|
||||||
|
$seed[0] = new $seed[0];
|
||||||
|
call_user_func($seed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class Adresse extends APIv1_Controller
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
// Load model PersonModel
|
// Load model PersonModel
|
||||||
$this->load->model('person/adresse_model', 'AdresseModel');
|
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||||
// Load set the uid of the model to let to check the permissions
|
// Load set the uid of the model to let to check the permissions
|
||||||
$this->AdresseModel->setUID($this->_getUID());
|
$this->AdresseModel->setUID($this->_getUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('BASEPATH'))
|
||||||
|
exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class TblStudiengang extends FHC_Controller
|
||||||
|
{
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->load->model('organisation/studiengang_model');
|
||||||
|
$this->load->library('form_validation');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$keyword = '';
|
||||||
|
$this->load->library('pagination');
|
||||||
|
|
||||||
|
$config['base_url'] = base_url() . 'studiengang/index/';
|
||||||
|
$config['total_rows'] = $this->studiengang_model->total_rows();
|
||||||
|
$config['per_page'] = 10;
|
||||||
|
$config['uri_segment'] = 3;
|
||||||
|
$config['suffix'] = '.html';
|
||||||
|
$config['first_url'] = base_url() . 'studiengang.html';
|
||||||
|
$this->pagination->initialize($config);
|
||||||
|
|
||||||
|
$start = $this->uri->segment(3, 0);
|
||||||
|
$studiengang = $this->studiengang_model->index_limit($config['per_page'], $start);
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'studiengang_data' => $studiengang,
|
||||||
|
'keyword' => $keyword,
|
||||||
|
'pagination' => $this->pagination->create_links(),
|
||||||
|
'total_rows' => $config['total_rows'],
|
||||||
|
'start' => $start,
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->load->view('tbl_studiengang_list', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function search()
|
||||||
|
{
|
||||||
|
$keyword = $this->uri->segment(3, $this->input->post('keyword', TRUE));
|
||||||
|
$this->load->library('pagination');
|
||||||
|
|
||||||
|
if ($this->uri->segment(2)=='search') {
|
||||||
|
$config['base_url'] = base_url() . 'studiengang/search/' . $keyword;
|
||||||
|
} else {
|
||||||
|
$config['base_url'] = base_url() . 'studiengang/index/';
|
||||||
|
}
|
||||||
|
|
||||||
|
$config['total_rows'] = $this->studiengang_model->search_total_rows($keyword);
|
||||||
|
$config['per_page'] = 10;
|
||||||
|
$config['uri_segment'] = 4;
|
||||||
|
$config['suffix'] = '.html';
|
||||||
|
$config['first_url'] = base_url() . 'studiengang/search/'.$keyword.'.html';
|
||||||
|
$this->pagination->initialize($config);
|
||||||
|
|
||||||
|
$start = $this->uri->segment(4, 0);
|
||||||
|
$studiengang = $this->studiengang_model->search_index_limit($config['per_page'], $start, $keyword);
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'studiengang_data' => $studiengang,
|
||||||
|
'keyword' => $keyword,
|
||||||
|
'pagination' => $this->pagination->create_links(),
|
||||||
|
'total_rows' => $config['total_rows'],
|
||||||
|
'start' => $start,
|
||||||
|
);
|
||||||
|
$this->load->view('tbl_studiengang_list', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function read($id)
|
||||||
|
{
|
||||||
|
$row = $this->studiengang_model->get_by_id($id);
|
||||||
|
if ($row) {
|
||||||
|
$data = array(
|
||||||
|
);
|
||||||
|
$this->load->view('tbl_studiengang_read', $data);
|
||||||
|
} else {
|
||||||
|
$this->session->set_flashdata('message', 'Record Not Found');
|
||||||
|
redirect(site_url('studiengang'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$data = array(
|
||||||
|
'button' => 'Create',
|
||||||
|
'action' => site_url('studiengang/create_action'),
|
||||||
|
);
|
||||||
|
$this->load->view('tbl_studiengang_form', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create_action()
|
||||||
|
{
|
||||||
|
$this->_rules();
|
||||||
|
|
||||||
|
if ($this->form_validation->run() == FALSE) {
|
||||||
|
$this->create();
|
||||||
|
} else {
|
||||||
|
$data = array(
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->studiengang_model->insert($data);
|
||||||
|
$this->session->set_flashdata('message', 'Create Record Success');
|
||||||
|
redirect(site_url('studiengang'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($id)
|
||||||
|
{
|
||||||
|
$row = $this->studiengang_model->get_by_id($id);
|
||||||
|
|
||||||
|
if ($row) {
|
||||||
|
$data = array(
|
||||||
|
'button' => 'Update',
|
||||||
|
'action' => site_url('studiengang/update_action'),
|
||||||
|
);
|
||||||
|
$this->load->view('tbl_studiengang_form', $data);
|
||||||
|
} else {
|
||||||
|
$this->session->set_flashdata('message', 'Record Not Found');
|
||||||
|
redirect(site_url('studiengang'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_action()
|
||||||
|
{
|
||||||
|
$this->_rules();
|
||||||
|
|
||||||
|
if ($this->form_validation->run() == FALSE) {
|
||||||
|
$this->update($this->input->post('', TRUE));
|
||||||
|
} else {
|
||||||
|
$data = array(
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->studiengang_model->update($this->input->post('', TRUE), $data);
|
||||||
|
$this->session->set_flashdata('message', 'Update Record Success');
|
||||||
|
redirect(site_url('studiengang'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
$row = $this->studiengang_model->get_by_id($id);
|
||||||
|
|
||||||
|
if ($row) {
|
||||||
|
$this->studiengang_model->delete($id);
|
||||||
|
$this->session->set_flashdata('message', 'Delete Record Success');
|
||||||
|
redirect(site_url('studiengang'));
|
||||||
|
} else {
|
||||||
|
$this->session->set_flashdata('message', 'Record Not Found');
|
||||||
|
redirect(site_url('studiengang'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function _rules()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->form_validation->set_rules('', '', 'trim');
|
||||||
|
$this->form_validation->set_error_delimiters('<span class="text-danger">', '</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* End of file Studiengang.php */
|
||||||
|
/* Location: ./application/controllers/Studiengang.php */
|
||||||
@@ -1,22 +1,62 @@
|
|||||||
<?php
|
<?php
|
||||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
class Message extends FHC_Controller {
|
class Message extends FHC_Controller
|
||||||
|
{
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
//$this->load->library('Messaging');
|
$this->load->library('messaging');
|
||||||
$this->load->model('message/Message_model');
|
//$this->load->model('person/Person_model');
|
||||||
$this->load->model('person/Person_model');
|
//$this->load->model('system/Message_model');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$person=$this->Person_model->getPersonFromBenutzerUID('pam');
|
//$messages = $this->Message_model->getMessages();
|
||||||
$msg_id=1;
|
$msg = $this->Message_model->load(1);
|
||||||
$msg = $this->Message_model->getMessage($msg_id, $person[0]->person_id);
|
if ($msg->error)
|
||||||
//$this->load->view('welcome_message');
|
show_error($msg->retval);
|
||||||
//$msg = $this->Message_model->send_new_message(1, $msg_id, 'test', 'This is a test!', 1);
|
|
||||||
|
$data = array
|
||||||
|
(
|
||||||
|
'message' => $msg->retval[0]
|
||||||
|
);
|
||||||
|
$v = $this->load->view('test.php', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view($msg_id)
|
||||||
|
{
|
||||||
|
$msg = $this->messaging->getMessage($msg_id);
|
||||||
|
//var_dump($msg);
|
||||||
|
if ($msg->error)
|
||||||
|
show_error($msg->retval);
|
||||||
|
if (count($msg->retval) != 1)
|
||||||
|
show_error('Nachricht nicht vorhanden! ID: '.$msg_id);
|
||||||
|
|
||||||
|
$data = array
|
||||||
|
(
|
||||||
|
'message' => $msg->retval[0]
|
||||||
|
);
|
||||||
|
var_dump($data['message']);
|
||||||
|
$v = $this->load->view('system/message', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function neu()
|
||||||
|
{
|
||||||
|
//$messages = $this->Message_model->getMessages();
|
||||||
|
$msg = $this->Message_model->load($id);
|
||||||
|
if ($msg->error)
|
||||||
|
show_error($msg->retval);
|
||||||
|
if (count($msg->retval) != 1)
|
||||||
|
show_error('Nachricht nicht vorhanden! ID: '.$id);
|
||||||
|
|
||||||
|
$data = array
|
||||||
|
(
|
||||||
|
'message' => $msg->retval[0]
|
||||||
|
);
|
||||||
|
var_dump($data);
|
||||||
|
$v = $this->load->view('system/message', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ class APIv1_Controller extends REST_Controller
|
|||||||
{
|
{
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
//$this->load->library('session'); // -> autoload
|
//$this->load->library('session'); // -> autoload
|
||||||
//$this->load->library('database'); -> autoload
|
//$this->load->library('database'); -> autoload
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ class DB_Model extends FHC_Model
|
|||||||
// True if this table has a primary key that uses a sequence
|
// True if this table has a primary key that uses a sequence
|
||||||
protected $acl; // Name of the PrimaryKey for DB-Update, Load, ...
|
protected $acl; // Name of the PrimaryKey for DB-Update, Load, ...
|
||||||
|
|
||||||
function __construct($dbTable = null, $pk = null)
|
function __construct($dbTable = null, $pk = null, $hasSequence = true)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->dbTable = $dbTable;
|
$this->dbTable = $dbTable;
|
||||||
$this->pk = $pk;
|
$this->pk = $pk;
|
||||||
$this->hasSequence = true;
|
$this->hasSequence = $hasSequence;
|
||||||
$this->load->database();
|
$this->load->database();
|
||||||
$this->acl = $this->config->item('fhc_acl');
|
$this->acl = $this->config->item('fhc_acl');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,20 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
|||||||
|
|
||||||
class FHC_Controller extends CI_Controller
|
class FHC_Controller extends CI_Controller
|
||||||
{
|
{
|
||||||
|
public $uid;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->load->library('template');
|
||||||
|
$this->load->library('session');
|
||||||
//$this->load->helper('language');
|
//$this->load->helper('language');
|
||||||
|
|
||||||
|
// look if User is logged in and set uid
|
||||||
|
if (isset($_SERVER['PHP_AUTH_USER']))
|
||||||
|
$this->uid = $_SERVER['PHP_AUTH_USER'];
|
||||||
|
if (isset($_SESSION['uid']))
|
||||||
|
$this->uid = $_SESSION['uid'];
|
||||||
|
$this->session->set_userdata('uid', 'pam');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,15 +14,11 @@ class FHC_Model extends CI_Model
|
|||||||
$uid = null;
|
$uid = null;
|
||||||
|
|
||||||
// Get UID from CI session
|
// Get UID from CI session
|
||||||
if(isset($this->session->uid))
|
if(isset($_SESSION['uid']))
|
||||||
{
|
|
||||||
$uid = $this->session->uid;
|
$uid = $this->session->uid;
|
||||||
}
|
|
||||||
// Get UID from the environment (HTTP authentication via authentication.class.php)
|
// Get UID from the environment (HTTP authentication via authentication.class.php)
|
||||||
else if(isset($_SERVER['PHP_AUTH_USER']))
|
elseif(isset($_SERVER['PHP_AUTH_USER']))
|
||||||
{
|
|
||||||
$uid = $_SERVER['PHP_AUTH_USER'];
|
$uid = $_SERVER['PHP_AUTH_USER'];
|
||||||
}
|
|
||||||
|
|
||||||
// After getting UID for the first time, it saves it in CI session
|
// After getting UID for the first time, it saves it in CI session
|
||||||
if (isset($uid) && !isset($this->session->uid))
|
if (isset($uid) && !isset($this->session->uid))
|
||||||
|
|||||||
@@ -1,170 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* FH-Complete
|
|
||||||
*
|
|
||||||
* @package FHC-Helper
|
|
||||||
* @author FHC-Team
|
|
||||||
* @copyright Copyright (c) 2016 fhcomplete.org
|
|
||||||
* @license GPLv3
|
|
||||||
* @link https://fhcomplete.org
|
|
||||||
* @since Version 1.0.0
|
|
||||||
* @filesource
|
|
||||||
*/
|
|
||||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FHC-Seed Library
|
|
||||||
*
|
|
||||||
* @package FH-Complete
|
|
||||||
* @subpackage DB
|
|
||||||
* @category Library
|
|
||||||
* @author FHC-Team
|
|
||||||
* @link http://fhcomplete.org/user_guide/libraries/fhc_seed.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class FHC_Seed
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Path to seed classes
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $_seed_path = NULL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Seed basename regex
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $_seed_regex = '/^\d{3}_(\w+)$/';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize Seed Class
|
|
||||||
*
|
|
||||||
* @param array $config
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct($config = array())
|
|
||||||
{
|
|
||||||
// Only run this constructor on main library load
|
|
||||||
if ( ! in_array(get_class($this), array('FHC_Seed', config_item('subclass_prefix').'Seed'), TRUE))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($config as $key => $val)
|
|
||||||
{
|
|
||||||
$this->{'_'.$key} = $val;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_message('info', 'Seed Class Initialized');
|
|
||||||
|
|
||||||
// If not set, set it
|
|
||||||
$this->_seed_path !== '' OR $this->_seed_path = APPPATH.'seeds/';
|
|
||||||
|
|
||||||
// Add trailing slash if not set
|
|
||||||
$this->_seed_path = rtrim($this->_seed_path, '/').'/';
|
|
||||||
|
|
||||||
// Load seed language
|
|
||||||
$this->lang->load('seed');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Seeds DB with Testdata
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function seed($name = null)
|
|
||||||
{
|
|
||||||
$seeds = $this->find_seeds();
|
|
||||||
|
|
||||||
if (empty($seeds))
|
|
||||||
{
|
|
||||||
$this->_error_string = $this->lang->line('seed_none_found');
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$method = 'seed';
|
|
||||||
$pending = array();
|
|
||||||
foreach ($seeds as $number => $file)
|
|
||||||
{
|
|
||||||
include_once($file);
|
|
||||||
$class = 'Seed_'.ucfirst(strtolower($this->_get_seed_name(basename($file, '.php'))));
|
|
||||||
|
|
||||||
// Validate the seed file structure
|
|
||||||
if ( ! class_exists($class, FALSE))
|
|
||||||
{
|
|
||||||
$this->_error_string = sprintf($this->lang->line('seed_class_doesnt_exist'), $class);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
// method_exists() returns true for non-public methods,
|
|
||||||
// while is_callable() can't be used without instantiating.
|
|
||||||
// Only get_class_methods() satisfies both conditions.
|
|
||||||
elseif ( ! in_array($method, array_map('strtolower', get_class_methods($class))))
|
|
||||||
{
|
|
||||||
$this->_error_string = sprintf($this->lang->line('seed_missing_'.$method.'_method'), $class);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pending[$number] = array($class, $method);
|
|
||||||
}
|
|
||||||
// Now just run the necessary seeds
|
|
||||||
foreach ($pending as $number => $seed)
|
|
||||||
{
|
|
||||||
log_message('debug', 'Seeding '.$method);
|
|
||||||
|
|
||||||
$seed[0] = new $seed[0];
|
|
||||||
call_user_func($seed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves list of available seed files
|
|
||||||
*
|
|
||||||
* @return array list of seed file paths sorted by version
|
|
||||||
*/
|
|
||||||
public function find_seeds()
|
|
||||||
{
|
|
||||||
$seeds = array();
|
|
||||||
|
|
||||||
// Load all *_*.php files in the seeds path
|
|
||||||
foreach (glob($this->_seed_path.'*_*.php') as $file)
|
|
||||||
{
|
|
||||||
$name = basename($file, '.php');
|
|
||||||
|
|
||||||
// Filter out non-seed files
|
|
||||||
if (preg_match($this->_seed_regex, $name))
|
|
||||||
{
|
|
||||||
$number = $this->_get_seed_number($name);
|
|
||||||
|
|
||||||
// There cannot be duplicate seed numbers
|
|
||||||
if (isset($seeds[$number]))
|
|
||||||
{
|
|
||||||
$this->_error_string = sprintf($this->lang->line('seed_multiple_version'), $number);
|
|
||||||
show_error($this->_error_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
$seeds[$number] = $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ksort($seeds);
|
|
||||||
return $seeds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts the seed number from a filename
|
|
||||||
*
|
|
||||||
* @param string $seed
|
|
||||||
* @return string Numeric portion of a seed filename
|
|
||||||
*/
|
|
||||||
protected function _get_seed_number($seed)
|
|
||||||
{
|
|
||||||
return sscanf($seed, '%[0-9]+', $number)
|
|
||||||
? $number : '0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,448 +0,0 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
||||||
/**
|
|
||||||
* Name: Messaging Library for CodeIgniter
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Messaging
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
require_once APPPATH.'config/message.php';
|
|
||||||
|
|
||||||
$this->ci =& get_instance();
|
|
||||||
$this->ci->load->model('message/message_model');
|
|
||||||
$this->ci->load->helper('language');
|
|
||||||
$this->ci->lang->load('message');
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get_message() - will return a single message, including the status for specified user.
|
|
||||||
*
|
|
||||||
* @param integer $msg_id EQUIRED
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_message($msg_id, $user_id)
|
|
||||||
{
|
|
||||||
if (empty($msg_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($message = $this->ci->message_model->get_message($msg_id, $user_id))
|
|
||||||
{
|
|
||||||
return $this->_success($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get_full_thread() - will return a entire thread, including the status for specified user.
|
|
||||||
*
|
|
||||||
* @param integer $thread_id REQUIRED
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @param boolean $full_thread OPTIONAL - If true, user will also see messages from thread posted BEFORE user became participant
|
|
||||||
* @param string $order_by OPTIONAL
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_full_thread($thread_id, $user_id, $full_thread = FALSE, $order_by = 'ASC')
|
|
||||||
{
|
|
||||||
if (empty($thread_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($message = $this->ci->message_model->get_full_thread($thread_id, $user_id, $full_thread, $order_by))
|
|
||||||
{
|
|
||||||
return $this->_success($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get_all_threads() - will return all threads for user, including the status for specified user.
|
|
||||||
*
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @param boolean $full_thread OPTIONAL - If true, user will also see messages from thread posted BEFORE user became participant
|
|
||||||
* @param string $order_by OPTIONAL
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_all_threads($user_id, $full_thread = FALSE, $order_by = 'ASC')
|
|
||||||
{
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = $this->ci->message_model->get_all_threads($user_id, $full_thread, $order_by);
|
|
||||||
if (is_array($message))
|
|
||||||
{
|
|
||||||
return $this->_success($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get_all_threads_grouped() - will return all threads for user, including the status for specified user.
|
|
||||||
* - messages are grouped in threads.
|
|
||||||
*
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @param boolean $full_thread OPTIONAL - If true, user will also see messages from thread posted BEFORE user became participant
|
|
||||||
* @param string $order_by OPTIONAL
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_all_threads_grouped($user_id, $full_thread = FALSE, $order_by = 'ASC')
|
|
||||||
{
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = $this->ci->message_model->get_all_threads($user_id, $full_thread, $order_by);
|
|
||||||
if (is_array($message))
|
|
||||||
{
|
|
||||||
$threads = array();
|
|
||||||
|
|
||||||
foreach ($message as $msg)
|
|
||||||
{
|
|
||||||
if ( ! isset($threads[$msg['thread_id']]))
|
|
||||||
{
|
|
||||||
$threads[$msg['thread_id']]['thread_id'] = $msg['thread_id'];
|
|
||||||
$threads[$msg['thread_id']]['messages'] = array($msg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$threads[$msg['thread_id']]['messages'][] = $msg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_success($threads);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update_message_status() - will change status on message for particular user
|
|
||||||
*
|
|
||||||
* @param integer $msg_id REQUIRED
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @param integer $status_id REQUIRED - should come from config/message.php list of constants
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function update_message_status($msg_id, $user_id, $status_id )
|
|
||||||
{
|
|
||||||
if (empty($msg_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($status_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_STATUS_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->ci->message_model->update_message_status($msg_id, $user_id, $status_id))
|
|
||||||
{
|
|
||||||
return $this->_success(NULL, MSG_STATUS_UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add_participant() - adds user to existing thread
|
|
||||||
*
|
|
||||||
* @param integer $thread_id REQUIRED
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function add_participant($thread_id, $user_id)
|
|
||||||
{
|
|
||||||
if (empty($thread_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->ci->message_model->valid_new_participant($thread_id, $user_id))
|
|
||||||
{
|
|
||||||
$this->_participant_error(MSG_ERR_PARTICIPANT_EXISTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->ci->message_model->application_user($user_id))
|
|
||||||
{
|
|
||||||
$this->_participant_error(MSG_ERR_PARTICIPANT_NONSYSTEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->ci->message_model->add_participant($thread_id, $user_id ))
|
|
||||||
{
|
|
||||||
return $this->_success(NULL, MSG_PARTICIPANT_ADDED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* remove_participant() - removes user from existing thread
|
|
||||||
*
|
|
||||||
* @param integer $thread_id REQUIRED
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function remove_participant($thread_id, $user_id)
|
|
||||||
{
|
|
||||||
if (empty($thread_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->ci->message_model->remove_participant($thread_id, $user_id))
|
|
||||||
{
|
|
||||||
return $this->_success(NULL, MSG_PARTICIPANT_REMOVED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* send_new_message() - sends new internal message. This function will create a new thread
|
|
||||||
*
|
|
||||||
* @param integer $sender_id REQUIRED
|
|
||||||
* @param mixed $recipients REQUIRED - a single integer or an array of integers, representing user_ids
|
|
||||||
* @param string $subject
|
|
||||||
* @param string $body
|
|
||||||
* @param integer $priority
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function send_new_message($sender_id, $recipients, $subject = '', $body = '', $priority = PRIORITY_NORMAL)
|
|
||||||
{
|
|
||||||
if (empty($sender_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_SENDER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($recipients))
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'err' => 1,
|
|
||||||
'code' => MSG_ERR_INVALID_RECIPIENTS,
|
|
||||||
'msg' => lang('mahana_'.MSG_ERR_INVALID_RECIPIENTS)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($thread_id = $this->ci->message_model->send_new_message($sender_id, $recipients, $subject, $body, $priority))
|
|
||||||
{
|
|
||||||
return $this->_success($thread_id, MSG_MESSAGE_SENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* reply_to_message() - replies to internal message. This function will NOT create a new thread or participant list
|
|
||||||
*
|
|
||||||
* @param integer $msg_id REQUIRED
|
|
||||||
* @param integer $sender_id REQUIRED
|
|
||||||
* @param string $subject
|
|
||||||
* @param string $body
|
|
||||||
* @param integer $priority
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function reply_to_message($msg_id, $sender_id, $subject = '', $body = '', $priority = PRIORITY_NORMAL)
|
|
||||||
{
|
|
||||||
if (empty($sender_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_SENDER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($msg_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($new_msg_id = $this->ci->message_model->reply_to_message($msg_id, $sender_id, $body, $priority))
|
|
||||||
{
|
|
||||||
return $this->_success($new_msg_id, MSG_MESSAGE_SENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get_participant_list() - returns list of participants on given thread. If sender_id set, sender_id will be left off list
|
|
||||||
*
|
|
||||||
* @param integer $thread_id REQUIRED
|
|
||||||
* @param integer $sender_id REQUIRED
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_participant_list($thread_id, $sender_id = 0)
|
|
||||||
{
|
|
||||||
if (empty($thread_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($participants = $this->ci->message_model-> get_participant_list($thread_id, $sender_id))
|
|
||||||
{
|
|
||||||
return $this->_success($participants);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get_msg_count() - returns integer with count of message for user, by status. defaults to new messages
|
|
||||||
*
|
|
||||||
* @param integer $user_id REQUIRED
|
|
||||||
* @param integer $status_id OPTIONAL - defaults to "Unread"
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_msg_count($user_id, $status_id = MSG_STATUS_UNREAD)
|
|
||||||
{
|
|
||||||
if (empty($user_id))
|
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_numeric($message = $this->ci->message_model->get_msg_count($user_id, $status_id)))
|
|
||||||
{
|
|
||||||
return $this->_success($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Error Occurred
|
|
||||||
return $this->_general_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Private Functions from here out!
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Success
|
|
||||||
*
|
|
||||||
* @param mixed $retval
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function _success($retval = '', $message = MSG_SUCCESS)
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'err' => 0,
|
|
||||||
'code' => MSG_SUCCESS,
|
|
||||||
'msg' => lang('mahana_' . $message),
|
|
||||||
'retval' => $retval
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invalid ID
|
|
||||||
*
|
|
||||||
* @param integer config.php error code numbers
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function _invalid_id($error = '')
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'err' => 1,
|
|
||||||
'code' => $error,
|
|
||||||
'msg' => lang('mahana_'.$error)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Error Particpant Exists
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function _participant_error($error = '')
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'err' => 1,
|
|
||||||
'code' => 1,
|
|
||||||
'msg' => lang('mahana_' . $error)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* General Error
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function _general_error()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'err' => 1,
|
|
||||||
'code' => MSG_ERR_GENERAL,
|
|
||||||
'msg' => lang('mahana_'.MSG_ERR_GENERAL)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,14 +8,25 @@ class Migration_Message extends CI_Migration {
|
|||||||
{
|
{
|
||||||
if (! $this->db->table_exists('public.tbl_msg_message'))
|
if (! $this->db->table_exists('public.tbl_msg_message'))
|
||||||
{
|
{
|
||||||
|
$this->db->insert('system.tbl_berechtigung', array(
|
||||||
|
'berechtigung_kurzbz' => 'basis/message',
|
||||||
|
'beschreibung' => 'Nachrichtensystem von FH-Complete'));
|
||||||
|
$this->db->insert('system.tbl_rolleberechtigung', array(
|
||||||
|
'berechtigung_kurzbz' => 'basis/message',
|
||||||
|
'rolle_kurzbz' => 'admin',
|
||||||
|
'art' => 'suid'));
|
||||||
|
|
||||||
$query= "
|
$query= "
|
||||||
CREATE TABLE public.tbl_msg_message (
|
CREATE TABLE public.tbl_msg_message (
|
||||||
message_id serial,
|
message_id serial,
|
||||||
thread_id bigint NOT NULL,
|
person_id bigint NOT NULL,
|
||||||
|
subject varchar(256) NOT NULL,
|
||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
priority smallint NOT NULL DEFAULT 0,
|
priority smallint NOT NULL DEFAULT 0,
|
||||||
person_id bigint NOT NULL,
|
relationmessage_id bigint,
|
||||||
cdate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
oe_kurzbz varchar(32),
|
||||||
|
insertamum timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
insertvon varchar(32),
|
||||||
PRIMARY KEY (message_id)
|
PRIMARY KEY (message_id)
|
||||||
);
|
);
|
||||||
COMMENT ON COLUMN public.tbl_msg_message.person_id IS 'Sender';
|
COMMENT ON COLUMN public.tbl_msg_message.person_id IS 'Sender';
|
||||||
@@ -27,37 +38,45 @@ class Migration_Message extends CI_Migration {
|
|||||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_message_message_id_seq TO admin;
|
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_message_message_id_seq TO admin;
|
||||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_message_message_id_seq TO vilesci;
|
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_message_message_id_seq TO vilesci;
|
||||||
|
|
||||||
CREATE TABLE public.tbl_msg_participant (
|
CREATE TABLE public.tbl_msg_recipient (
|
||||||
person_id bigint NOT NULL,
|
person_id bigint NOT NULL,
|
||||||
thread_id bigint NOT NULL,
|
message_id bigint NOT NULL,
|
||||||
cdate timestamp NOT NULL DEFAULT now(),
|
insertamum timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (person_id,thread_id)
|
insertvon varchar(32),
|
||||||
|
PRIMARY KEY (person_id,message_id)
|
||||||
);
|
);
|
||||||
GRANT SELECT ON TABLE public.tbl_msg_participant TO web;
|
GRANT SELECT ON TABLE public.tbl_msg_recipient TO web;
|
||||||
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_participant TO admin;
|
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_recipient TO admin;
|
||||||
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_participant TO vilesci;
|
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_recipient TO vilesci;
|
||||||
|
|
||||||
CREATE TABLE public.tbl_msg_status (
|
CREATE TABLE public.tbl_msg_status (
|
||||||
message_id bigint NOT NULL,
|
message_id bigint NOT NULL,
|
||||||
person_id bigint NOT NULL,
|
person_id bigint NOT NULL,
|
||||||
status smallint NOT NULL,
|
status smallint NOT NULL,
|
||||||
|
statusinfo text,
|
||||||
|
insertamum timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
insertvon varchar(32),
|
||||||
|
updateamum timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updatevon varchar(32),
|
||||||
PRIMARY KEY (message_id,person_id)
|
PRIMARY KEY (message_id,person_id)
|
||||||
);
|
);
|
||||||
GRANT SELECT ON TABLE public.tbl_msg_status TO web;
|
GRANT SELECT ON TABLE public.tbl_msg_status TO web;
|
||||||
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_status TO admin;
|
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_status TO admin;
|
||||||
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_status TO vilesci;
|
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_status TO vilesci;
|
||||||
|
|
||||||
CREATE TABLE public.tbl_msg_thread (
|
CREATE TABLE public.tbl_msg_attachment (
|
||||||
thread_id serial,
|
attachment_id serial,
|
||||||
subject text,
|
message_id bigint NOT NULL,
|
||||||
PRIMARY KEY (thread_id)
|
name text,
|
||||||
|
filename text,
|
||||||
|
PRIMARY KEY (message_id)
|
||||||
);
|
);
|
||||||
GRANT SELECT ON TABLE public.tbl_msg_thread TO web;
|
GRANT SELECT ON TABLE public.tbl_msg_attachment TO web;
|
||||||
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_thread TO admin;
|
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_attachment TO admin;
|
||||||
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_thread TO vilesci;
|
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tbl_msg_attachment TO vilesci;
|
||||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_thread_thread_id_seq TO web;
|
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_attachment_attachment_id_seq TO web;
|
||||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_thread_thread_id_seq TO admin;
|
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_attachment_attachment_id_seq TO admin;
|
||||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_thread_thread_id_seq TO vilesci;
|
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_msg_attachment_attachment_id_seq TO vilesci;
|
||||||
";
|
";
|
||||||
if (!$this->db->simple_query($query))
|
if (!$this->db->simple_query($query))
|
||||||
{
|
{
|
||||||
@@ -68,10 +87,21 @@ class Migration_Message extends CI_Migration {
|
|||||||
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->dbforge->drop_table('public.tbl_msg_message');
|
try
|
||||||
$this->dbforge->drop_table('public.tbl_msg_participant');
|
{
|
||||||
$this->dbforge->drop_table('public.tbl_msg_status');
|
$this->db->delete('system.tbl_rolleberechtigung', array('berechtigung_kurzbz' => 'basis/message'));
|
||||||
$this->dbforge->drop_table('public.tbl_msg_thread');
|
$this->db->delete('system.tbl_berechtigung', array('berechtigung_kurzbz' => 'basis/message'));
|
||||||
|
$this->dbforge->drop_table('public.tbl_msg_recipient');
|
||||||
|
$this->dbforge->drop_table('public.tbl_msg_status');
|
||||||
|
$this->dbforge->drop_table('public.tbl_msg_attachment');
|
||||||
|
$this->dbforge->drop_table('public.tbl_msg_message');
|
||||||
|
echo "Table public.tbl_msg_message, public.tbl_msg_status, public.tbl_msg_attachment and public.tbl_msg_recipient dropped!";
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
echo 'Exception abgefangen: ', $e->getMessage(), "\n";
|
||||||
|
echo $this->db->error();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,4 +10,31 @@ class Organisationseinheit_model extends DB_Model
|
|||||||
$this->dbTable = 'public.tbl_organisationseinheit';
|
$this->dbTable = 'public.tbl_organisationseinheit';
|
||||||
$this->pk = 'oe_kurzbz';
|
$this->pk = 'oe_kurzbz';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRecursiveList()
|
||||||
|
{
|
||||||
|
$qry = "WITH RECURSIVE tree (oe_kurzbz, bezeichnung,path) AS
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
oe_kurzbz,
|
||||||
|
bezeichnung||' ('||organisationseinheittyp_kurzbz||')' AS bezeichnung,
|
||||||
|
oe_kurzbz||'|' AS path
|
||||||
|
FROM tbl_organisationseinheit
|
||||||
|
WHERE oe_parent_kurzbz IS NULL AND aktiv
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
oe.oe_kurzbz,
|
||||||
|
oe.bezeichnung||' ('||oe.organisationseinheittyp_kurzbz||')' AS bezeichnung,
|
||||||
|
tree.path ||oe.oe_kurzbz||'|' AS path
|
||||||
|
FROM tree
|
||||||
|
JOIN tbl_organisationseinheit oe ON (tree.oe_kurzbz=oe.oe_parent_kurzbz)
|
||||||
|
)
|
||||||
|
SELECT oe_kurzbz AS value, substring(regexp_replace(path, '[A-z]+\|', '-','g')||bezeichnung,2) AS name, path FROM tree ORDER BY path;";
|
||||||
|
|
||||||
|
|
||||||
|
if ($res = $this->db->query($qry))
|
||||||
|
return $this->_success($res);
|
||||||
|
else
|
||||||
|
return $this->_error($this->db->error());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -23,29 +23,19 @@ class Message_model extends DB_Model
|
|||||||
* @param integer $person_id REQUIRED
|
* @param integer $person_id REQUIRED
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getMessage($msg_id, $person_id)
|
/*function getMessage($msg_id)
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (empty($msg_id))
|
if (empty($msg_id))
|
||||||
{
|
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
|
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
|
||||||
}
|
|
||||||
if (empty($person_id))
|
$sql = 'SELECT * FROM tbl_msg_message JOIN tbl_person USING (person_id) WHERE message_id=?' ;
|
||||||
{
|
$result = $this->db->query($sql, array($msg_id));
|
||||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
|
||||||
}
|
|
||||||
$sql = 'SELECT m.*, s.status, t.subject, ' . "CONCAT(vorname, ' ', nachname) as user_name" .
|
|
||||||
' FROM ' . $this->db->dbprefix . 'tbl_msg_message m ' .
|
|
||||||
' JOIN ' . $this->db->dbprefix . 'tbl_msg_thread t ON (m.thread_id = t.thread_id) ' .
|
|
||||||
' JOIN ' . $this->db->dbprefix . 'public.tbl_person' . ' ON (' . 'tbl_person.person_id' . ' = m.sender_id) '.
|
|
||||||
' JOIN ' . $this->db->dbprefix . 'tbl_msg_status s ON (s.message_id = m.message_id AND s.person_id = ? ) ' .
|
|
||||||
' WHERE m.message_id = ? ' ;
|
|
||||||
$result = $this->db->query($sql, array($person_id, $msg_id));
|
|
||||||
if ($result)
|
if ($result)
|
||||||
return $this->_success($result->result_array());
|
return $this->_success($result->result());
|
||||||
else
|
else
|
||||||
return $this->_general_error();
|
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||||
}
|
}*/
|
||||||
/** -----------------------------------------------------------------
|
/** -----------------------------------------------------------------
|
||||||
* Get a Full Thread
|
* Get a Full Thread
|
||||||
* get_full_thread() - will return a entire thread, including the status for specified user.
|
* get_full_thread() - will return a entire thread, including the status for specified user.
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
class Recipient_model extends DB_Model
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->dbTable = 'public.tbl_msg_recipient';
|
||||||
|
$this->pk = array('person_id', 'message_id');
|
||||||
|
$this->hasSequence = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
class Thread_model extends DB_Model
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->dbTable = 'public.tbl_msg_thread';
|
|
||||||
$this->pk = 'thread_id';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class Seed_Prestudent
|
||||||
|
{
|
||||||
|
|
||||||
|
public function seed($limit = 25)
|
||||||
|
{
|
||||||
|
echo "Seeding $limit prestudents ";
|
||||||
|
$this->fhc =& get_instance();
|
||||||
|
$this->fhc->load->model('crm/Prestudent_model');
|
||||||
|
|
||||||
|
for ($i = 0; $i < $limit; $i++)
|
||||||
|
{
|
||||||
|
echo ".";
|
||||||
|
$data = array(
|
||||||
|
'person_id' => $i+3, // start with person_id 3
|
||||||
|
'aufmerksamdurch_kurzbz' => 'k.A.',
|
||||||
|
'studiengang_kz' => $this->fhc->faker->firstName,
|
||||||
|
'nachname' => $this->fhc->faker->lastName,
|
||||||
|
//'address' => $this->faker->streetAddress,
|
||||||
|
'gebort' => $this->fhc->faker->city,
|
||||||
|
//'state' => $this->faker->state,
|
||||||
|
//'country' => $this->faker->country,
|
||||||
|
//'postcode' => $this->faker->postcode,
|
||||||
|
//'email' => $this->faker->email,
|
||||||
|
//'email_verified' => mt_rand(0, 1) ? '0' : '1',
|
||||||
|
//'phone' => $this->faker->phoneNumber,
|
||||||
|
'gebdatum' => $this->fhc->faker->dateTimeThisCentury->format('Y-m-d H:i:s'),
|
||||||
|
//'registration_date' => $this->faker->dateTimeThisYear->format('Y-m-d H:i:s'),
|
||||||
|
//'ip_address' => mt_rand(0, 1) ? $this->faker->ipv4 : $this->faker->ipv6,
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->fhc->Prestudent_model->insert($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo PHP_EOL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function truncate()
|
||||||
|
{
|
||||||
|
//$this->db->query('EMPTY TABLE public.person;');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class Seed_Message
|
||||||
|
{
|
||||||
|
|
||||||
|
public function seed($limit = 25)
|
||||||
|
{
|
||||||
|
echo "Seeding $limit messages ";
|
||||||
|
$this->fhc =& get_instance();
|
||||||
|
$this->fhc->load->model('system/Recipient_model');
|
||||||
|
$this->fhc->Recipient_model->setUid('admin');
|
||||||
|
$this->fhc->load->model('system/Message_model');
|
||||||
|
|
||||||
|
for ($i = 0; $i < $limit; $i++)
|
||||||
|
{
|
||||||
|
echo ".";
|
||||||
|
|
||||||
|
$data = array
|
||||||
|
(
|
||||||
|
'subject' => $this->fhc->faker->sentence(4, true),
|
||||||
|
'body' => $this->fhc->faker->text(400),
|
||||||
|
'person_id' => $i%5+1
|
||||||
|
);
|
||||||
|
$message = $this->fhc->Message_model->insert($data);
|
||||||
|
|
||||||
|
$data = array
|
||||||
|
(
|
||||||
|
'message_id' => $message->retval,
|
||||||
|
'person_id' => $i%5+2,
|
||||||
|
'insertvon' => 'seed'
|
||||||
|
);
|
||||||
|
$recipient = $this->fhc->Recipient_model->insert($data);
|
||||||
|
if ($recipient->error)
|
||||||
|
show_error($recipient->retval);
|
||||||
|
//for ($j=1; $j<10; $j++)
|
||||||
|
// $this->fhc->Message_model->addRecipient($thread->retval, $i+$j+5);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo PHP_EOL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function truncate()
|
||||||
|
{
|
||||||
|
//$this->db->query('EMPTY TABLE public.person;');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="span4">
|
||||||
|
<h2>Nachricht <?php echo $message->message_id; ?></h2>
|
||||||
|
|
||||||
|
Absender: <?php echo $message->person_id; ?><br/>
|
||||||
|
Betreff: <?php echo $message->subject; ?><br/>
|
||||||
|
Text: <?php echo $message->body; ?><br/>
|
||||||
|
<?php
|
||||||
|
// This is an example to show that you can load stuff from inside the template file
|
||||||
|
echo $this->template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
|
||||||
|
?>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title><?php echo $this->template->title->default("Default title"); ?></title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="description" content="<?php echo $this->template->description; ?>">
|
||||||
|
<meta name="author" content="">
|
||||||
|
<?php echo $this->template->meta; ?>
|
||||||
|
<?php echo $this->template->stylesheet; ?>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// This is an example to show that you can load stuff from inside the template file
|
||||||
|
echo $this->template->widget("navigation", array('title' => 'Project name'));
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container" style="margin-top: 60px;">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// This is the main content partial
|
||||||
|
echo $this->template->content;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
// Show the footer partial, and prepend copyright message
|
||||||
|
echo $this->template->footer->prepend("© Special Company 2012 - ");
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="//code.jquery.com/jquery-latest.min.js"></script>
|
||||||
|
<?php echo $this->template->javascript; ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="navbar-inner">
|
||||||
|
<div class="container">
|
||||||
|
<a class="brand" href="#"><?php echo $title; ?></a>
|
||||||
|
<ul class="nav">
|
||||||
|
<?php foreach($items as $item): ?>
|
||||||
|
<li><a href="#<?php echo $item; ?>"><?php echo $item; ?></a></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php echo $title; ?>
|
||||||
|
<select name="organisationseinheit">
|
||||||
|
<?php foreach($items as $item): ?>
|
||||||
|
<option value="<?php echo $item['value']; ?>" <?php if ($item['selected']) echo 'selected'?>>
|
||||||
|
<?php echo $item['name']; ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Demo widget
|
||||||
|
*/
|
||||||
|
class Navigation extends Widget {
|
||||||
|
|
||||||
|
public function display($data) {
|
||||||
|
|
||||||
|
if (!isset($data['items'])) {
|
||||||
|
$data['items'] = array('Home', 'About', 'Contact');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view('widgets/navigation', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OE widget
|
||||||
|
*/
|
||||||
|
class organisationseinheit_widget extends Widget
|
||||||
|
{
|
||||||
|
public function display($data)
|
||||||
|
{
|
||||||
|
$this->load->model('organisation/Organisationseinheit_model');
|
||||||
|
$res = $this->Organisationseinheit_model->getRecursiveList();
|
||||||
|
var_dump($res);
|
||||||
|
foreach ($res->retval->result() as $obj)
|
||||||
|
{
|
||||||
|
$item = array('name' => $obj->name, 'value' => $obj->value);
|
||||||
|
if (isset($data['oe_kurzbz']) && $obj->value == $data['oe_kurzbz'])
|
||||||
|
$item['selected'] = true;
|
||||||
|
else
|
||||||
|
$item['selected'] = false;
|
||||||
|
$data['items'][] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view('widgets/organisationseinheit', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user