mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +00:00
Fixed models
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Berechtigung_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_berechtigung';
|
||||
$this->pk = 'berechtigung_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Cronjob_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_cronjob';
|
||||
$this->pk = 'cronjob_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Filter_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_filter';
|
||||
$this->pk = 'filter_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Log_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_log';
|
||||
$this->pk = 'log_id';
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ class Message_model extends DB_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class Message_model extends DB_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Enables content locking.
|
||||
* An entry in the locktable means certain content is marked locked and a user is its editor.
|
||||
*/
|
||||
class PersonLock_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_person_lock';
|
||||
$this->pk = 'lock_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specific person is locked. By default, looks for entries with no app in locktable for the person.
|
||||
* Alternatively, looks only for locks in a certain app.
|
||||
* @param $person_id
|
||||
* @param null $app
|
||||
* @return array all locks for a person if locked, null otherwise
|
||||
*/
|
||||
public function checkIfLocked($person_id, $app = null)
|
||||
{
|
||||
$lockdata = array('person_id' => $person_id, 'app' => $app);
|
||||
|
||||
$result = $this->loadWhere($lockdata);
|
||||
|
||||
if ($result->error)
|
||||
return error($result->retval);
|
||||
|
||||
if (count($result->retval) > 0)
|
||||
return success($result->retval);
|
||||
else
|
||||
return success(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks a person. Returns null if person was not locked (e.g. when already locked).
|
||||
* @param $person_id
|
||||
* @param $uid user who locks the person
|
||||
* @param $app optional, application in which person is locked
|
||||
* @return array inserted lock id if person was locked, null otherwise
|
||||
*/
|
||||
public function lockPerson($person_id, $uid, $app = null)
|
||||
{
|
||||
$locked = $this->checkIfLocked($person_id, $app);
|
||||
|
||||
if ($locked->error)
|
||||
return error($locked->retval);
|
||||
|
||||
//insert only if not already locked
|
||||
if ($locked->retval === null)
|
||||
return $this->insert(array('person_id' => $person_id, 'uid' => $uid, 'app' => $app));
|
||||
else
|
||||
return success(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a lock for a person. By default, removes any entries in locktable for the person.
|
||||
* Alternatively, removes only locks in a certain app.
|
||||
* @param $person_id
|
||||
* @param null $app
|
||||
* @return array deleted lock ids if person was locked, null otherwise
|
||||
*/
|
||||
public function unlockPerson($person_id, $app = null)
|
||||
{
|
||||
$deleted = array();
|
||||
$locks = $this->checkIfLocked($person_id, $app);
|
||||
|
||||
if ($locks->retval === null)
|
||||
return success(null);
|
||||
|
||||
foreach ($locks->retval as $lock)
|
||||
{
|
||||
$result = $this->delete($lock->lock_id);
|
||||
if ($result->error)
|
||||
return error($result->retval);
|
||||
|
||||
$deleted[] = $lock;
|
||||
}
|
||||
|
||||
return success($deleted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Rolle_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_rolle';
|
||||
$this->pk = 'rolle_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Rolleberechtigung_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_rolleberechtigung';
|
||||
$this->pk = array('rolle_kurzbz', 'berechtigung_kurzbz');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Server_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_server';
|
||||
$this->pk = 'server_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Tag_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_tag';
|
||||
$this->pk = 'tag';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Variable_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_variable';
|
||||
$this->pk = array('uid', 'name');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Webservicelog_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_webservicelog';
|
||||
$this->pk = 'webservicelog_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Webservicerecht_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_webservicerecht';
|
||||
$this->pk = 'webservicerecht_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Webservicetyp_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_webservicetyp';
|
||||
$this->pk = 'webservicetyp_kurzbz';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user