This commit is contained in:
Stefan Puraner
2016-04-05 11:41:52 +02:00
48 changed files with 3171 additions and 852 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ $autoload['helper'] = array('url');
| config files. Otherwise, leave it blank.
|
*/
$autoload['config'] = array();
$autoload['config'] = array('fhcomplete');
/*
| -------------------------------------------------------------------
+1 -1
View File
@@ -29,7 +29,7 @@ $config['base_url'] = 'http://localhost/fhcomplete/';
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
$config['index_page'] = 'index.ci.php';
/*
|--------------------------------------------------------------------------
+8
View File
@@ -0,0 +1,8 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['fhc_version'] = '3.2';
// status return message codes
define('FHC_SUCCESS', 0);
define('FHC_ERR_GENERAL', 1);
+1 -1
View File
@@ -1,6 +1,6 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//For view all the languages go to the folder assets/grocery_crud/languages/
$config['grocery_crud_default_language'] = 'en_US';
$config['grocery_crud_default_language'] = 'english';
// There are only three choices: "uk-date" (dd/mm/yyyy), "us-date" (mm/dd/yyyy) or "sql-date" (yyyy-mm-dd)
$config['grocery_crud_date_format'] = 'uk-date';
+35
View File
@@ -0,0 +1,35 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// application's Users table - define your user table and columns here
define('USER_TABLE_TABLENAME', 'tbl_person p');
define('USER_TABLE_ID', 'p.person_id');
define('USER_TABLE_USERNAME', "CONCAT(p.vorname, ' ', p.nachname) as user_name");
// message statuses
define('MSG_STATUS_UNREAD', 0);
define('MSG_STATUS_READ', 1);
define('MSG_STATUS_ARCHIVED', 2);
// priority
define('PRIORITY_LOW', 1);
define('PRIORITY_NORMAL', 2);
define('PRIORITY_HIGH', 3);
define('PRIORITY_URGENT', 4);
// status return message codes
define('MSG_SUCCESS', 0);
define('MSG_ERR_GENERAL', 1);
define('MSG_ERR_INVALID_USER_ID', 2);
define('MSG_ERR_INVALID_MSG_ID', 3);
define('MSG_ERR_INVALID_THREAD_ID', 4);
define('MSG_ERR_INVALID_STATUS_ID', 5);
define('MSG_ERR_INVALID_SENDER_ID', 6);
define('MSG_ERR_INVALID_RECIPIENTS', 7);
define('MSG_MESSAGE_SENT', 8);
define('MSG_STATUS_UPDATE', 9);
define('MSG_PARTICIPANT_ADDED', 10);
define('MSG_ERR_PARTICIPANT_EXISTS', 11);
define('MSG_ERR_PARTICIPANT_NONSYSTEM', 12);
define('MSG_PARTICIPANT_REMOVED', 13);
+2 -2
View File
@@ -23,7 +23,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 20160101010103;
$config['migration_version'] = 008;
/*
|--------------------------------------------------------------------------
@@ -41,7 +41,7 @@ $config['migration_version'] = 20160101010103;
| defaults to 'sequential' for backward compatibility with CI2.
|
*/
$config['migration_type'] = 'timestamp';
$config['migration_type'] = 'sequential';
/*
|--------------------------------------------------------------------------
+295
View File
@@ -0,0 +1,295 @@
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Database Class
*
*/
class DBTools extends FHC_Controller
{
private $cli = false;
/**
* Path to seed classes
*
* @var string
*/
protected $_seed_path = APPPATH.'seeds/';
/**
* Seed basename regex
*
* @var string
*/
protected $_seed_regex = '/^\d{3}_(\w+)$/';
/**
* Initialize DB-Tools Class
*
* @return void
*/
function __construct()
{
parent::__construct();
if ($this->input->is_cli_request())
{
$cli=true;
}
else
{
//$this->output->set_status_header(403, 'Migrations must be run from the CLI');
//exit;
}
// can only be run in the development environment
if (ENVIRONMENT !== 'development') {
exit('Wowsers! You don\'t want to do that!');
}
$this->load->database('system'); //Use the system-Connection for DB-Manipulation
$this->load->library('migration');
// 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');
// initiate faker
$this->faker = Faker\Factory::create();
// load any required models
//$this->load->model('person/Person_model');
log_message('info', 'DB-Tools Controller Initialized');
}
public function index()
{
$result = "The following are the available command line interface commands\n\n";
$result .= "php index.ci.php DBTools migrate [\"version_number\"] Run all migrations. The version number is optional.\n";
$result .= "php index.ci.php DBTools seed \"file_name\" Run the specified seed file.\n";
echo $result . PHP_EOL;
}
/**
* Migrate to latest or current version
*
* @param string $version One of either "latest" or "current"
*/
public function migrate($version = 'latest')
{
if ($this->cli && $this->migration->current() === FALSE)
{
show_error($this->migration->error_string());
}
elseif ($version != 'latest' && $version != 'current')
{
$this->_failed('Migration version must be either latest or current');
}
if (!$this->migration->$version())
{
$this->_failed();
}
$this->_succeeded();
}
/**
* Migrate to a specific version
*/
public function version()
{
if ($version == 'latest' || $version == 'current')
{
$this->index($version);
exit;
}
if (!$this->migrate->version($version))
{
$this->_failed();
}
$this->_succeeded();
}
/**
* Roll-back to the last version before current
*
* @param int $version The migration to rollback to, defaults to previous
*/
public function rollback($version = null)
{
if (is_null($version))
{
$version = $this->_get_version() ?: 1;
$version--;
}
// Check it's definitely false, we could be rolling back to v0
if (false === $this->migration->version($version))
{
$this->_failed();
}
$this->_succeeded('rolled back');
}
/**
* ROLLBACK ALL THE THINGS!
*/
public function uninstall()
{
$this->rollback(0);
}
/**
* 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';
}
/**
* Extracts the seed class name from a filename
*
* @param string $seed
* @return string text portion of a migration filename
*/
protected function _get_seed_name($seed)
{
$parts = explode('_', $seed);
array_shift($parts);
return implode('_', $parts);
}
/**
* Yay, it worked! Tell the user.
*
* @param string $task What did we just do? We...
*/
private function _succeeded($task = 'migrated')
{
$version = $this->_get_version();
exit('Successfully '.$task.' to version '.$version);
}
/**
* Output an error message when it all goes tits up
*
* @param string $message Error to output (default to CI's migration error)
*/
private function _failed($message = null)
{
$message = $message ?: $this->migration->error_string();
show_error($message);
}
/**
* Carbon copy of parent::_get_version, but that's protected.
*
* @return int Currently installed migration number
*/
private function _get_version()
{
$row = $this->db->get('ci_migrations')->row();
return $row ? $row->version : 0;
}
}
+6 -6
View File
@@ -73,12 +73,12 @@ class Examples extends CI_Controller {
$crud = new grocery_CRUD();
$crud->set_table('customers');
$crud->columns('customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit');
$crud->display_as('salesRepEmployeeNumber','from Employeer')
->display_as('customerName','Name')
->display_as('contactLastName','Last Name');
$crud->columns('customername','contactlastname','phone','city','country','salesrepemployeenumber','creditlimit');
$crud->display_as('salesrepemployeenumber','from Employeer')
->display_as('customername','Name')
->display_as('contactlastname','Last Name');
$crud->set_subject('Customer');
$crud->set_relation('salesRepEmployeeNumber','employees','lastName');
$crud->set_relation('salesrepemployeenumber','employees','lastname');
$output = $crud->render();
@@ -245,4 +245,4 @@ class Examples extends CI_Controller {
}
}
}
}
+24 -3
View File
@@ -1,6 +1,6 @@
<?php
class Migrate extends CI_Controller
class Migrate extends FHC_Controller
{
private $class_version = '1.0';
private $cli = false;
@@ -20,14 +20,24 @@ class Migrate extends CI_Controller
}
$this->load->database('system'); //Use the system-Connection for DB-Manipulation
$this->load->library('migration');
$this->load->library('FHC_Seed');
}
public function help() {
$result = "The following are the available command line interface commands\n\n";
$result .= "php index.ci.php db migrate [\"version_number\"] Run all migrations. The version number is optional.\n";
$result .= "php index.ci.php db seed \"file_name\" Run the specified seed file. Filename is optional.\n";
echo $result . PHP_EOL;
}
/**
* Migrate to latest or current version
*
* @param string $version One of either "latest" or "current"
*/
public function index($version = 'latest')
public function migrate($version = 'latest')
{
if ($this->cli && $this->migration->current() === FALSE)
@@ -39,7 +49,7 @@ class Migrate extends CI_Controller
$this->_failed('Migration version must be either latest or current');
}
if (!$this->migration->$version())
if (!$this->migration->version())
{
$this->_failed();
}
@@ -97,6 +107,17 @@ class Migrate extends CI_Controller
$this->rollback(0);
}
/**
* Seed DB with TestData
*
* @param string $name Name of the SeedFile
*/
public function seed($name = null)
{
$this->fhc_seed->seed($name);
}
/**
* Yay, it worked! Tell the user.
*
+1 -1
View File
@@ -20,7 +20,7 @@ class Vilesci extends CI_Controller {
*/
public function index()
{
if ($this->dbupdate())
if (false)//$this->dbupdate())
echo 'System-DB needs update!';
else
{
+22
View File
@@ -0,0 +1,22 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Message extends FHC_Controller {
public function __construct()
{
parent::__construct();
//$this->load->library('Messaging');
$this->load->model('message/Message_model');
$this->load->model('person/Person_model');
}
public function index()
{
$person=$this->Person_model->getPersonFromBenutzerUID('pam');
$msg_id=1;
$msg = $this->Message_model->getMessage($msg_id, $person[0]->person_id);
//$this->load->view('welcome_message');
//$msg = $this->Message_model->send_new_message(1, $msg_id, 'test', 'This is a test!', 1);
}
}
@@ -1,167 +0,0 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Studiengang extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('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 */
+13
View File
@@ -6,6 +6,19 @@ class FHC_Controller extends CI_Controller
function __construct()
{
parent::__construct();
//$this->load->helper('language');
}
}
require_once APPPATH . '/libraries/REST_Controller.php';
class API_Controller extends REST_Controller
{
function __construct()
{
parent::__construct();
//$this->load->library('session'); -> autoload
//$this->load->library('database'); -> autoload
}
}
+63
View File
@@ -6,15 +6,52 @@ class FHC_Model extends CI_Model
function __construct()
{
parent::__construct();
$this->load->helper('language');
$this->lang->load('fhcomplete');
}
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval = '', $message = FHC_SUCCESS)
{
return array(
'err' => 0,
'code' => FHC_SUCCESS,
'msg' => lang('fhc_' . $message),
'retval' => $retval
);
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _general_error()
{
return array(
'err' => 1,
'code' => FHC_ERR_GENERAL,
'msg' => lang('fhc_'.FHC_ERR_GENERAL)
);
}
}
class DB_Model extends FHC_Model
{
protected $dbTable=null; // Name of the DB-Table for CI-Insert, -Update, ...
function __construct($uid=null)
{
parent::__construct();
$this->load->database();
$this->load->helper('language');
$this->lang->load('fhc_db');
// UID must be set in Production Mode
if (ENVIRONMENT=='production' && is_null($uid))
@@ -25,4 +62,30 @@ class DB_Model extends FHC_Model
// Loading Tools for Access Control (Benutzerberechtigungen)
$this->load->library('FHC_DB_ACL',array('uid' => $uid));
}
public function insert($data)
{
if (! is_null($this->dbTable))
{
$this->db->insert($this->dbTable, $data);
return true;
}
else
return false;
}
/** ---------------------------------------------------------------
* Invalid ID
*
* @param integer config.php error code numbers
* @return array
*/
protected function _invalid_id($error = '')
{
return array(
'err' => 1,
'code' => $error,
'msg' => lang('fhc_'.$error)
);
}
}
@@ -0,0 +1,2 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
@@ -0,0 +1,5 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Account Creation
$lang['fhc_'.FHC_SUCCESS] = 'Erfolgreich';
$lang['fhc_'.FHC_ERR_GENERAL] = 'Fehler';
@@ -0,0 +1,17 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Account Creation
$lang['mahana_'.MSG_SUCCESS] = 'Success';
$lang['mahana_'.MSG_ERR_GENERAL] = 'Error';
$lang['mahana_'.MSG_ERR_INVALID_USER_ID] = 'No user id specified';
$lang['mahana_'.MSG_ERR_INVALID_MSG_ID] = 'No message id specified';
$lang['mahana_'.MSG_ERR_INVALID_THREAD_ID] = 'No message thread id specified';
$lang['mahana_'.MSG_ERR_INVALID_STATUS_ID] = 'No status specified';
$lang['mahana_'.MSG_ERR_INVALID_SENDER_ID] = 'Not a valid sender';
$lang['mahana_'.MSG_ERR_INVALID_RECIPIENTS] = 'No valid recipients';
$lang['mahana_'.MSG_MESSAGE_SENT] = 'Message sent';
$lang['mahana_'.MSG_STATUS_UPDATE] = 'Status updated';
$lang['mahana_'.MSG_PARTICIPANT_ADDED] = 'Participant added';
$lang['mahana_'.MSG_ERR_PARTICIPANT_EXISTS] = 'User is already participating in this thread';
$lang['mahana_'.MSG_ERR_PARTICIPANT_NONSYSTEM] = 'This user id is not in the system';
$lang['mahana_'.MSG_PARTICIPANT_REMOVED] = 'Participant removed from thread';
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* FH-Complete
*
*/
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['seed_none_found'] = 'No seeds were found.';
$lang['seed_not_found'] = 'No seed could be found with the version number: %s.';
$lang['seed_sequence_gap'] = 'There is a gap in the seed sequence near version number: %s.';
$lang['seed_multiple_version'] = 'There are multiple seeds with the same version number: %s.';
$lang['seed_class_doesnt_exist'] = 'The seed class "%s" could not be found.';
$lang['seed_missing_up_method'] = 'The seed class "%s" is missing an "up" method.';
$lang['seed_missing_down_method'] = 'The seed class "%s" is missing a "down" method.';
$lang['seed_invalid_filename'] = 'Seed "%s" has an invalid filename.';
@@ -0,0 +1,2 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
@@ -0,0 +1,5 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Account Creation
$lang['fhc_'.FHC_SUCCESS] = 'Success';
$lang['fhc_'.FHC_ERR_GENERAL] = 'Error';
@@ -0,0 +1,17 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Account Creation
$lang['mahana_'.MSG_SUCCESS] = 'Success';
$lang['mahana_'.MSG_ERR_GENERAL] = 'Error';
$lang['mahana_'.MSG_ERR_INVALID_USER_ID] = 'No user id specified';
$lang['mahana_'.MSG_ERR_INVALID_MSG_ID] = 'No message id specified';
$lang['mahana_'.MSG_ERR_INVALID_THREAD_ID] = 'No message thread id specified';
$lang['mahana_'.MSG_ERR_INVALID_STATUS_ID] = 'No status specified';
$lang['mahana_'.MSG_ERR_INVALID_SENDER_ID] = 'Not a valid sender';
$lang['mahana_'.MSG_ERR_INVALID_RECIPIENTS] = 'No valid recipients';
$lang['mahana_'.MSG_MESSAGE_SENT] = 'Message sent';
$lang['mahana_'.MSG_STATUS_UPDATE] = 'Status updated';
$lang['mahana_'.MSG_PARTICIPANT_ADDED] = 'Participant added';
$lang['mahana_'.MSG_ERR_PARTICIPANT_EXISTS] = 'User is already participating in this thread';
$lang['mahana_'.MSG_ERR_PARTICIPANT_NONSYSTEM] = 'This user id is not in the system';
$lang['mahana_'.MSG_PARTICIPANT_REMOVED] = 'Participant removed from thread';
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* FH-Complete
*
*/
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['seed_none_found'] = 'No seeds were found.';
$lang['seed_not_found'] = 'No seed could be found with the version number: %s.';
$lang['seed_sequence_gap'] = 'There is a gap in the seed sequence near version number: %s.';
$lang['seed_multiple_version'] = 'There are multiple seeds with the same version number: %s.';
$lang['seed_class_doesnt_exist'] = 'The seed class "%s" could not be found.';
$lang['seed_missing_up_method'] = 'The seed class "%s" is missing an "up" method.';
$lang['seed_missing_down_method'] = 'The seed class "%s" is missing a "down" method.';
$lang['seed_invalid_filename'] = 'Seed "%s" has an invalid filename.';
+170
View File
@@ -0,0 +1,170 @@
<?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
*/
defined('BASEPATH') OR 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';
}
}
+27 -15
View File
@@ -16,7 +16,7 @@
* @package grocery CRUD
* @copyright Copyright (c) 2010 through 2014, John Skoumbourdis
* @license https://github.com/scoumbourdis/grocery-crud/blob/master/license-grocery-crud.txt
* @version 1.5.2
* @version 1.5.4
* @author John Skoumbourdis <scoumbourdisj@gmail.com>
*/
@@ -468,22 +468,22 @@ class grocery_CRUD_Field_Types
*
* @package grocery CRUD
* @author John Skoumbourdis <scoumbourdisj@gmail.com>
* @version 1.5.2
* @version 1.5.4
* @link http://www.grocerycrud.com/documentation
*/
class grocery_CRUD_Model_Driver extends grocery_CRUD_Field_Types
{
/**
* @var grocery_CRUD_Model
* @var Grocery_crud_model
*/
public $basic_model = null;
protected function set_default_Model()
{
$ci = &get_instance();
$ci->load->model('grocery_CRUD_Model');
$ci->load->model('Grocery_crud_model');
$this->basic_model = new grocery_CRUD_Model();
$this->basic_model = new Grocery_crud_model();
}
protected function get_total_results()
@@ -536,7 +536,7 @@ class grocery_CRUD_Model_Driver extends grocery_CRUD_Field_Types
public function set_model($model_name)
{
$ci = &get_instance();
$ci->load->model('grocery_CRUD_Model');
$ci->load->model('Grocery_crud_model');
$ci->load->model($model_name);
@@ -1383,7 +1383,7 @@ class grocery_CRUD_Model_Driver extends grocery_CRUD_Field_Types
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
$allowed_files = $this->config->file_upload_allow_file_types;
$reg_exp = '';
if(!empty($upload_info->allowed_file_types)){
$reg_exp = '/(\\.|\\/)('.$upload_info->allowed_file_types.')$/i';
@@ -1517,7 +1517,7 @@ class grocery_CRUD_Model_Driver extends grocery_CRUD_Field_Types
*
* @package grocery CRUD
* @author John Skoumbourdis <scoumbourdisj@gmail.com>
* @version 1.5.2
* @version 1.5.4
*/
class grocery_CRUD_Layout extends grocery_CRUD_Model_Driver
{
@@ -1534,6 +1534,8 @@ class grocery_CRUD_Layout extends grocery_CRUD_Model_Driver
protected function set_basic_Layout()
{
//var_dump($this->theme_path);
//var_dump($this->theme);
if(!file_exists($this->theme_path.$this->theme.'/views/list_template.php'))
{
throw new Exception('The template does not exist. Please check your files and try again.', 12);
@@ -2217,8 +2219,18 @@ class grocery_CRUD_Layout extends grocery_CRUD_Model_Driver
$value = !is_string($value) ? '' : str_replace('"',"&quot;",$value);
$extra_attributes = '';
if(!empty($field_info->db_max_length))
$extra_attributes .= "maxlength='{$field_info->db_max_length}'";
if (!empty($field_info->db_max_length)) {
if (in_array($field_info->type, array("decimal", "float"))) {
$decimal_lentgh = explode(",", $field_info->db_max_length);
$decimal_lentgh = ((int)$decimal_lentgh[0]) + 1;
$extra_attributes .= "maxlength='" . $decimal_lentgh . "'";
} else {
$extra_attributes .= "maxlength='{$field_info->db_max_length}'";
}
}
$input = "<input id='field-{$field_info->name}' class='form-control' name='{$field_info->name}' type='text' value=\"$value\" $extra_attributes />";
return $input;
}
@@ -2967,7 +2979,7 @@ class grocery_CRUD_Layout extends grocery_CRUD_Model_Driver
*
* @package grocery CRUD
* @author John Skoumbourdis <scoumbourdisj@gmail.com>
* @version 1.5.2
* @version 1.5.4
*/
class grocery_CRUD_States extends grocery_CRUD_Layout
{
@@ -3396,7 +3408,7 @@ class grocery_CRUD_States extends grocery_CRUD_Layout
* @package grocery CRUD
* @copyright Copyright (c) 2010 through 2014, John Skoumbourdis
* @license https://github.com/scoumbourdis/grocery-crud/blob/master/license-grocery-crud.txt
* @version 1.5.2
* @version 1.5.4
* @author John Skoumbourdis <scoumbourdisj@gmail.com>
*/
@@ -3419,7 +3431,7 @@ class Grocery_CRUD extends grocery_CRUD_States
*
* @var string
*/
const VERSION = "1.5.2";
const VERSION = "1.5.4";
const JQUERY = "jquery-1.11.1.min.js";
const JQUERY_UI_JS = "jquery-ui-1.10.3.custom.min.js";
@@ -3732,10 +3744,10 @@ class Grocery_CRUD extends grocery_CRUD_States
return $this;
}
/**
* Just an alias to unset_read
*
*
* @return void
* */
public function unset_view()
+448
View File
@@ -0,0 +1,448 @@
<?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)
);
}
}
+1 -1
View File
@@ -8,4 +8,4 @@
<p>Directory access is forbidden.</p>
</body>
</html>
</html>
@@ -38,9 +38,14 @@ class Migration_Add_apikey extends CI_Migration {
$this->dbforge->create_table('ci_apikey');
}
if (!$this->db->simple_query("INSERT INTO ci_apikey (key) VALUES ('aufnahme@fhcomplete.org');"))
if (!$this->db->simple_query('GRANT SELECT ON public.ci_apikey TO vilesci;'))
{
echo "Error DB-Insert!";
echo 'Error GRANT to vilesci!';
}
if (!$this->db->simple_query("INSERT INTO ci_apikey (key) VALUES ('testapikey@fhcomplete.org'); INSERT INTO ci_apikey (key) VALUES ('aufnahme@fhcomplete.org');"))
{
echo 'Error DB-Insert!';
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_fhc30 extends CI_Migration {
public function up()
{
//$this->load->helper('file');
require_once(FCPATH.'include/basis_db.class.php');
$db = new basis_db();
//$db = $this->db;
//$db->db_query = $this->db->simple_query;
require_once('./system/dbupdate_3.0.php');
}
public function down()
{
/*$this->db->simple_query('DROP SCHEMA bis;');
$this->db->simple_query('DROP SCHEMA campus;');
$this->db->simple_query('DROP SCHEMA fue;');
$this->db->simple_query('DROP SCHEMA kommune;');
$this->db->simple_query('DROP SCHEMA lehre;');
$this->db->simple_query('DROP SCHEMA sync;');
$this->db->simple_query('DROP SCHEMA system;');
$this->db->simple_query('DROP SCHEMA testtool;');
$this->db->simple_query('DROP SCHEMA wawi;');*/
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_fhc31 extends CI_Migration {
public function up()
{
//$this->load->database('system');
if (!$this->db->table_exists('tbl_person'))
{
$this->load->helper('file');
$sqlfile = read_file('./system/fhcomplete3.0.sql');
if (!$this->db->simple_query($sqlfile))
{
echo "Error creating Basis DB-Schema!";
}
}
}
public function down()
{
/*$this->db->simple_query('DROP SCHEMA bis;');
$this->db->simple_query('DROP SCHEMA campus;');
$this->db->simple_query('DROP SCHEMA fue;');
$this->db->simple_query('DROP SCHEMA kommune;');
$this->db->simple_query('DROP SCHEMA lehre;');
$this->db->simple_query('DROP SCHEMA sync;');
$this->db->simple_query('DROP SCHEMA system;');
$this->db->simple_query('DROP SCHEMA testtool;');
$this->db->simple_query('DROP SCHEMA wawi;');*/
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_fhc32 extends CI_Migration {
public function up()
{
//$this->load->database('system');
if (!$this->db->table_exists('tbl_person'))
{
$this->load->helper('file');
$sqlfile = read_file('./system/fhcomplete3.0.sql');
if (!$this->db->simple_query($sqlfile))
{
echo "Error creating Basis DB-Schema!";
}
}
}
public function down()
{
/*$this->db->simple_query('DROP SCHEMA bis;');
$this->db->simple_query('DROP SCHEMA campus;');
$this->db->simple_query('DROP SCHEMA fue;');
$this->db->simple_query('DROP SCHEMA kommune;');
$this->db->simple_query('DROP SCHEMA lehre;');
$this->db->simple_query('DROP SCHEMA sync;');
$this->db->simple_query('DROP SCHEMA system;');
$this->db->simple_query('DROP SCHEMA testtool;');
$this->db->simple_query('DROP SCHEMA wawi;');*/
}
}
+75
View File
@@ -0,0 +1,75 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_Message extends CI_Migration {
public function up()
{
if (!$this->db->table_exists('msg_messages'))
{
$query= '
CREATE TABLE msg_messages (
id serial,
thread_id bigint NOT NULL,
body text NOT NULL,
priority smallint NOT NULL DEFAULT 0,
sender_id bigint NOT NULL,
cdate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
GRANT SELECT ON TABLE msg_messages TO web;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_messages TO admin;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_messages TO vilesci;
GRANT SELECT, UPDATE ON SEQUENCE msg_messages_id_seq TO web;
GRANT SELECT, UPDATE ON SEQUENCE msg_messages_id_seq TO admin;
GRANT SELECT, UPDATE ON SEQUENCE msg_messages_id_seq TO vilesci;
CREATE TABLE msg_participants (
user_id bigint NOT NULL,
thread_id bigint NOT NULL,
cdate timestamp NOT NULL DEFAULT now(),
PRIMARY KEY (user_id,thread_id)
);
GRANT SELECT ON TABLE msg_participants TO web;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_participants TO admin;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_participants TO vilesci;
CREATE TABLE msg_status (
message_id bigint NOT NULL,
user_id bigint NOT NULL,
status smallint NOT NULL,
PRIMARY KEY (message_id,user_id)
);
GRANT SELECT ON TABLE msg_status TO web;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_status TO admin;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_status TO vilesci;
CREATE TABLE msg_threads (
id serial,
subject text,
PRIMARY KEY (id)
);
GRANT SELECT ON TABLE msg_threads TO web;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_threads TO admin;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE msg_threads TO vilesci;
GRANT SELECT, UPDATE ON SEQUENCE msg_threads_id_seq TO web;
GRANT SELECT, UPDATE ON SEQUENCE msg_threads_id_seq TO admin;
GRANT SELECT, UPDATE ON SEQUENCE msg_threads_id_seq TO vilesci;
';
if (!$this->db->simple_query($query))
{
echo "Error creating Basis DB-Schema!";
}
}
}
public function down()
{
$this->dbforge->drop_table('msg_messages');
$this->dbforge->drop_table('msg_participants');
$this->dbforge->drop_table('msg_status');
$this->dbforge->drop_table('msg_threads');
}
}
-582
View File
@@ -1,582 +0,0 @@
<?php
/**
* PHP grocery CRUD
*
* LICENSE
*
* Grocery CRUD is released with dual licensing, using the GPL v3 (license-gpl3.txt) and the MIT license (license-mit.txt).
* You don't have to do anything special to choose one license or the other and you don't have to notify anyone which license you are using.
* Please see the corresponding license file for details of these licenses.
* You are free to use, modify and distribute this software, but all copyright information must remain.
*
* @package grocery CRUD
* @copyright Copyright (c) 2010 through 2012, John Skoumbourdis
* @license https://github.com/scoumbourdis/grocery-crud/blob/master/license-grocery-crud.txt
* @version 1.4.2
* @author John Skoumbourdis <scoumbourdisj@gmail.com>
*/
// ------------------------------------------------------------------------
/**
* Grocery CRUD Model
*
*
* @package grocery CRUD
* @author John Skoumbourdis <scoumbourdisj@gmail.com>
* @version 1.5.2
* @link http://www.grocerycrud.com/documentation
*/
class grocery_CRUD_Model extends CI_Model {
protected $primary_key = null;
protected $table_name = null;
protected $relation = array();
protected $relation_n_n = array();
protected $primary_keys = array();
function __construct()
{
parent::__construct();
}
function db_table_exists($table_name = null)
{
return $this->db->table_exists($table_name);
}
function get_list()
{
if($this->table_name === null)
return false;
$select = "`{$this->table_name}`.*";
//set_relation special queries
if(!empty($this->relation))
{
foreach($this->relation as $relation)
{
list($field_name , $related_table , $related_field_title) = $relation;
$unique_join_name = $this->_unique_join_name($field_name);
$unique_field_name = $this->_unique_field_name($field_name);
if(strstr($related_field_title,'{'))
{
$related_field_title = str_replace(" ","&nbsp;",$related_field_title);
$select .= ", CONCAT('".str_replace(array('{','}'),array("',COALESCE({$unique_join_name}.",", ''),'"),str_replace("'","\\'",$related_field_title))."') as $unique_field_name";
}
else
{
$select .= ", $unique_join_name.$related_field_title AS $unique_field_name";
}
if($this->field_exists($related_field_title))
$select .= ", `{$this->table_name}`.$related_field_title AS '{$this->table_name}.$related_field_title'";
}
}
//set_relation_n_n special queries. We prefer sub queries from a simple join for the relation_n_n as it is faster and more stable on big tables.
if(!empty($this->relation_n_n))
{
$select = $this->relation_n_n_queries($select);
}
$this->db->select($select, false);
$results = $this->db->get($this->table_name)->result();
return $results;
}
public function get_row($table_name = null)
{
$table_name = $table_name === null ? $this->table_name : $table_name;
return $this->db->get($table_name)->row();
}
public function set_primary_key($field_name, $table_name = null)
{
$table_name = $table_name === null ? $this->table_name : $table_name;
$this->primary_keys[$table_name] = $field_name;
}
protected function relation_n_n_queries($select)
{
$this_table_primary_key = $this->get_primary_key();
foreach($this->relation_n_n as $relation_n_n)
{
list($field_name, $relation_table, $selection_table, $primary_key_alias_to_this_table,
$primary_key_alias_to_selection_table, $title_field_selection_table, $priority_field_relation_table) = array_values((array)$relation_n_n);
$primary_key_selection_table = $this->get_primary_key($selection_table);
$field = "";
$use_template = strpos($title_field_selection_table,'{') !== false;
$field_name_hash = $this->_unique_field_name($title_field_selection_table);
if($use_template)
{
$title_field_selection_table = str_replace(" ", "&nbsp;", $title_field_selection_table);
$field .= "CONCAT('".str_replace(array('{','}'),array("',COALESCE(",", ''),'"),str_replace("'","\\'",$title_field_selection_table))."')";
}
else
{
$field .= "$selection_table.$title_field_selection_table";
}
//Sorry Codeigniter but you cannot help me with the subquery!
$select .= ", (SELECT GROUP_CONCAT(DISTINCT $field) FROM $selection_table "
."LEFT JOIN $relation_table ON $relation_table.$primary_key_alias_to_selection_table = $selection_table.$primary_key_selection_table "
."WHERE $relation_table.$primary_key_alias_to_this_table = `{$this->table_name}`.$this_table_primary_key GROUP BY $relation_table.$primary_key_alias_to_this_table) AS $field_name";
}
return $select;
}
function order_by($order_by , $direction)
{
$this->db->order_by( $order_by , $direction );
}
function where($key, $value = NULL, $escape = TRUE)
{
$this->db->where( $key, $value, $escape);
}
function or_where($key, $value = NULL, $escape = TRUE)
{
$this->db->or_where( $key, $value, $escape);
}
function having($key, $value = NULL, $escape = TRUE)
{
$this->db->having( $key, $value, $escape);
}
function or_having($key, $value = NULL, $escape = TRUE)
{
$this->db->or_having( $key, $value, $escape);
}
function like($field, $match = '', $side = 'both')
{
$this->db->like($field, $match, $side);
}
function or_like($field, $match = '', $side = 'both')
{
$this->db->or_like($field, $match, $side);
}
function limit($value, $offset = '')
{
$this->db->limit( $value , $offset );
}
function get_total_results()
{
//set_relation_n_n special queries. We prefer sub queries from a simple join for the relation_n_n as it is faster and more stable on big tables.
if(!empty($this->relation_n_n))
{
$select = "{$this->table_name}.*";
$select = $this->relation_n_n_queries($select);
$this->db->select($select,false);
}
return $this->db->get($this->table_name)->num_rows();
}
function set_basic_table($table_name = null)
{
if( !($this->db->table_exists($table_name)) )
return false;
$this->table_name = $table_name;
return true;
}
function get_edit_values($primary_key_value)
{
$primary_key_field = $this->get_primary_key();
$this->db->where($primary_key_field,$primary_key_value);
$result = $this->db->get($this->table_name)->row();
return $result;
}
function join_relation($field_name , $related_table , $related_field_title)
{
$related_primary_key = $this->get_primary_key($related_table);
if($related_primary_key !== false)
{
$unique_name = $this->_unique_join_name($field_name);
$this->db->join( $related_table.' as '.$unique_name , "$unique_name.$related_primary_key = {$this->table_name}.$field_name",'left');
$this->relation[$field_name] = array($field_name , $related_table , $related_field_title);
return true;
}
return false;
}
function set_relation_n_n_field($field_info)
{
$this->relation_n_n[$field_info->field_name] = $field_info;
}
protected function _unique_join_name($field_name)
{
return 'j'.substr(md5($field_name),0,8); //This j is because is better for a string to begin with a letter and not with a number
}
protected function _unique_field_name($field_name)
{
return 's'.substr(md5($field_name),0,8); //This s is because is better for a string to begin with a letter and not with a number
}
function get_relation_array($field_name , $related_table , $related_field_title, $where_clause, $order_by, $limit = null, $search_like = null)
{
$relation_array = array();
$field_name_hash = $this->_unique_field_name($field_name);
$related_primary_key = $this->get_primary_key($related_table);
$select = "$related_table.$related_primary_key, ";
if(strstr($related_field_title,'{'))
{
$related_field_title = str_replace(" ", "&nbsp;", $related_field_title);
$select .= "CONCAT('".str_replace(array('{','}'),array("',COALESCE(",", ''),'"),str_replace("'","\\'",$related_field_title))."') as $field_name_hash";
}
else
{
$select .= "$related_table.$related_field_title as $field_name_hash";
}
$this->db->select($select,false);
if($where_clause !== null)
$this->db->where($where_clause);
if($where_clause !== null)
$this->db->where($where_clause);
if($limit !== null)
$this->db->limit($limit);
if($search_like !== null)
$this->db->having("$field_name_hash LIKE '%".$this->db->escape_like_str($search_like)."%'");
$order_by !== null
? $this->db->order_by($order_by)
: $this->db->order_by($field_name_hash);
$results = $this->db->get($related_table)->result();
foreach($results as $row)
{
$relation_array[$row->$related_primary_key] = $row->$field_name_hash;
}
return $relation_array;
}
function get_ajax_relation_array($search, $field_name , $related_table , $related_field_title, $where_clause, $order_by)
{
return $this->get_relation_array($field_name , $related_table , $related_field_title, $where_clause, $order_by, 10 , $search);
}
function get_relation_total_rows($field_name , $related_table , $related_field_title, $where_clause)
{
if($where_clause !== null)
$this->db->where($where_clause);
return $this->db->count_all_results($related_table);
}
function get_relation_n_n_selection_array($primary_key_value, $field_info)
{
$select = "";
$related_field_title = $field_info->title_field_selection_table;
$use_template = strpos($related_field_title,'{') !== false;;
$field_name_hash = $this->_unique_field_name($related_field_title);
if($use_template)
{
$related_field_title = str_replace(" ", "&nbsp;", $related_field_title);
$select .= "CONCAT('".str_replace(array('{','}'),array("',COALESCE(",", ''),'"),str_replace("'","\\'",$related_field_title))."') as $field_name_hash";
}
else
{
$select .= "$related_field_title as $field_name_hash";
}
$this->db->select('*, '.$select,false);
$selection_primary_key = $this->get_primary_key($field_info->selection_table);
if(empty($field_info->priority_field_relation_table))
{
if(!$use_template){
$this->db->order_by("{$field_info->selection_table}.{$field_info->title_field_selection_table}");
}
}
else
{
$this->db->order_by("{$field_info->relation_table}.{$field_info->priority_field_relation_table}");
}
$this->db->where($field_info->primary_key_alias_to_this_table, $primary_key_value);
$this->db->join(
$field_info->selection_table,
"{$field_info->relation_table}.{$field_info->primary_key_alias_to_selection_table} = {$field_info->selection_table}.{$selection_primary_key}"
);
$results = $this->db->get($field_info->relation_table)->result();
$results_array = array();
foreach($results as $row)
{
$results_array[$row->{$field_info->primary_key_alias_to_selection_table}] = $row->{$field_name_hash};
}
return $results_array;
}
function get_relation_n_n_unselected_array($field_info, $selected_values)
{
$use_where_clause = !empty($field_info->where_clause);
$select = "";
$related_field_title = $field_info->title_field_selection_table;
$use_template = strpos($related_field_title,'{') !== false;
$field_name_hash = $this->_unique_field_name($related_field_title);
if($use_template)
{
$related_field_title = str_replace(" ", "&nbsp;", $related_field_title);
$select .= "CONCAT('".str_replace(array('{','}'),array("',COALESCE(",", ''),'"),str_replace("'","\\'",$related_field_title))."') as $field_name_hash";
}
else
{
$select .= "$related_field_title as $field_name_hash";
}
$this->db->select('*, '.$select,false);
if($use_where_clause){
$this->db->where($field_info->where_clause);
}
$selection_primary_key = $this->get_primary_key($field_info->selection_table);
if(!$use_template)
$this->db->order_by("{$field_info->selection_table}.{$field_info->title_field_selection_table}");
$results = $this->db->get($field_info->selection_table)->result();
$results_array = array();
foreach($results as $row)
{
if(!isset($selected_values[$row->$selection_primary_key]))
$results_array[$row->$selection_primary_key] = $row->{$field_name_hash};
}
return $results_array;
}
function db_relation_n_n_update($field_info, $post_data ,$main_primary_key)
{
$this->db->where($field_info->primary_key_alias_to_this_table, $main_primary_key);
if(!empty($post_data))
$this->db->where_not_in($field_info->primary_key_alias_to_selection_table , $post_data);
$this->db->delete($field_info->relation_table);
$counter = 0;
if(!empty($post_data))
{
foreach($post_data as $primary_key_value)
{
$where_array = array(
$field_info->primary_key_alias_to_this_table => $main_primary_key,
$field_info->primary_key_alias_to_selection_table => $primary_key_value,
);
$this->db->where($where_array);
$count = $this->db->from($field_info->relation_table)->count_all_results();
if($count == 0)
{
if(!empty($field_info->priority_field_relation_table))
$where_array[$field_info->priority_field_relation_table] = $counter;
$this->db->insert($field_info->relation_table, $where_array);
}elseif($count >= 1 && !empty($field_info->priority_field_relation_table))
{
$this->db->update( $field_info->relation_table, array($field_info->priority_field_relation_table => $counter) , $where_array);
}
$counter++;
}
}
}
function db_relation_n_n_delete($field_info, $main_primary_key)
{
$this->db->where($field_info->primary_key_alias_to_this_table, $main_primary_key);
$this->db->delete($field_info->relation_table);
}
function get_field_types_basic_table()
{
$db_field_types = array();
foreach($this->db->query("SHOW COLUMNS FROM `{$this->table_name}`")->result() as $db_field_type)
{
$type = explode("(",$db_field_type->Type);
$db_type = $type[0];
if(isset($type[1]))
{
if(substr($type[1],-1) == ')')
{
$length = substr($type[1],0,-1);
}
else
{
list($length) = explode(" ",$type[1]);
$length = substr($length,0,-1);
}
}
else
{
$length = '';
}
$db_field_types[$db_field_type->Field]['db_max_length'] = $length;
$db_field_types[$db_field_type->Field]['db_type'] = $db_type;
$db_field_types[$db_field_type->Field]['db_null'] = $db_field_type->Null == 'YES' ? true : false;
$db_field_types[$db_field_type->Field]['db_extra'] = $db_field_type->Extra;
}
$results = $this->db->field_data($this->table_name);
foreach($results as $num => $row)
{
$row = (array)$row;
$results[$num] = (object)( array_merge($row, $db_field_types[$row['name']]) );
}
return $results;
}
function get_field_types($table_name)
{
$results = $this->db->field_data($table_name);
return $results;
}
function db_update($post_array, $primary_key_value)
{
$primary_key_field = $this->get_primary_key();
return $this->db->update($this->table_name,$post_array, array( $primary_key_field => $primary_key_value));
}
function db_insert($post_array)
{
$insert = $this->db->insert($this->table_name,$post_array);
if($insert)
{
return $this->db->insert_id();
}
return false;
}
function db_delete($primary_key_value)
{
$primary_key_field = $this->get_primary_key();
if($primary_key_field === false)
return false;
$this->db->limit(1);
$this->db->delete($this->table_name,array( $primary_key_field => $primary_key_value));
if( $this->db->affected_rows() != 1)
return false;
else
return true;
}
function db_file_delete($field_name, $filename)
{
if( $this->db->update($this->table_name,array($field_name => ''),array($field_name => $filename)) )
{
return true;
}
else
{
return false;
}
}
function field_exists($field,$table_name = null)
{
if(empty($table_name))
{
$table_name = $this->table_name;
}
return $this->db->field_exists($field,$table_name);
}
function get_primary_key($table_name = null)
{
if($table_name == null)
{
if(isset($this->primary_keys[$this->table_name]))
{
return $this->primary_keys[$this->table_name];
}
if(empty($this->primary_key))
{
$fields = $this->get_field_types_basic_table();
foreach($fields as $field)
{
if($field->primary_key == 1)
{
return $field->name;
}
}
return false;
}
else
{
return $this->primary_key;
}
}
else
{
if(isset($this->primary_keys[$table_name]))
{
return $this->primary_keys[$table_name];
}
$fields = $this->get_field_types($table_name);
foreach($fields as $field)
{
if($field->primary_key == 1)
{
return $field->name;
}
}
return false;
}
}
function escape_str($value)
{
return $this->db->escape_str($value);
}
}
@@ -3,11 +3,11 @@
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Studiengang_model extends CI_Model
class Studiengang_model extends DB_Model
{
public $table = 'tbl_studiengang';
public $id = '';
public $table = 'public.tbl_studiengang';
public $id = 'studiengang_kz';
public $order = 'DESC';
function __construct()
@@ -80,4 +80,4 @@ class Studiengang_model extends CI_Model
}
/* End of file Studiengang_model.php */
/* Location: ./application/models/Studiengang_model.php */
/* Location: ./application/models/Studiengang_model.php */
@@ -4,6 +4,7 @@ class Person_model extends DB_Model
public function __construct($uid=null)
{
parent::__construct($uid);
$this->dbTable='public.tbl_person';
}
public function getPerson($person_id = null)
@@ -26,4 +27,21 @@ class Person_model extends DB_Model
return $query->result_object();
}
}
/**
* Laedt Personendaten eine BenutzerUID
* @param string $uid DB-Attr: tbl_benutzer.uid .
* @return bool
*/
public function getPersonFromBenutzerUID($uid)
{
if (!$this->fhc_db_acl->bb->isBerechtigt('person','s'))
{
$this->db->select('tbl_person.*');
$this->db->from('public.tbl_person JOIN public.tbl_benutzer USING (person_id)');
$query = $this->db->get_where(null, array('uid' => $uid));
return $query->result_object();
}
}
}
+2 -1
View File
@@ -57,7 +57,8 @@
},
"require-dev":
{
"squizlabs/php_codesniffer": "2.*"
"squizlabs/php_codesniffer": "2.*",
"fzaninotto/faker": "1.*"
},
"config":
{
Generated
+1740 -63
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -299,10 +299,13 @@ switch (ENVIRONMENT)
*
*/
// First load the FHC-Config-Files
// First load the FHC-Config-Files ...
require_once 'config/global.config.inc.php';
require_once 'config/vilesci.config.inc.php';
// ... and the vendor autoload
include_once 'vendor/autoload.php';
// Now the bootstrap file
require_once BASEPATH.'core/CodeIgniter.php';
@@ -11,4 +11,4 @@ modules:
- AcceptanceHelper
config:
PhpBrowser:
url: 'http://localhost/myapp/'
url: 'http://localhost/build/'
+11
View File
@@ -0,0 +1,11 @@
class_name: ApiTester
modules:
enabled:
- \Helper\Api
- REST:
# API URL
url: http://localhost/build/index.ci.php/api/v1/
# Can also be a framework module name
depends: PhpBrowser
# Limits PhpBrowser to JSON or XML
part: Json
+11
View File
@@ -0,0 +1,11 @@
<?php
$I = new ApiTester($scenario);
$I->wantTo('test the Login API');
$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org');
$I->sendGET('/userauth/login/username/codeception%40whisperocity.com/password/secret/device_id/abcdef123');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'success' => true,
'message' => 'User successfully logged in']);
+2
View File
@@ -0,0 +1,2 @@
<?php
// Here you can initialize variables that will be available to your tests