projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
DataObjects/Core_person.php
[Pman.Core]
/
DataObjects
/
Core_company.php
diff --git
a/DataObjects/Core_company.php
b/DataObjects/Core_company.php
index
f122b0f
..
038d092
100644
(file)
--- a/
DataObjects/Core_company.php
+++ b/
DataObjects/Core_company.php
@@
-2,7
+2,7
@@
/**
* Table Definition for Companies
*/
/**
* Table Definition for Companies
*/
-require_once 'DB/DataObject.php';
+
class_exists('DB_DataObject') ? '' :
require_once 'DB/DataObject.php';
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
{
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
{
@@
-40,7
+40,8
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
function applyFilters($q, $au)
{
function applyFilters($q, $au)
{
- $tn = $this->tableName();
+
+ $tn = $this->tableName();
$this->selectAdd("i18n_translate('c' , {$tn}.country, 'en') as country_display_name ");
$tn = $this->tableName();
$this->selectAdd("i18n_translate('c' , {$tn}.country, 'en') as country_display_name ");
$tn = $this->tableName();
@@
-48,7
+49,7
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
$x = DB_DataObject::factory('core_company');
$x->comptype= 'OWNER';
$x->find(true);
$x = DB_DataObject::factory('core_company');
$x->comptype= 'OWNER';
$x->find(true);
-
+
if (!empty($q['query']['company_project_id'])) {
$add = '';
if (!empty($q['query']['company_include_self'])) {
if (!empty($q['query']['company_project_id'])) {
$add = '';
if (!empty($q['query']['company_include_self'])) {
@@
-57,6
+58,7
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
if (!empty($q['query']['company_not_self'])) {
$add = " AND {$tn}.id != {$x->id}";
}
if (!empty($q['query']['company_not_self'])) {
$add = " AND {$tn}.id != {$x->id}";
}
+
$pids = array();
$pid = $q['query']['company_project_id'];
if (strpos($pid, ',')) {
$pids = array();
$pid = $q['query']['company_project_id'];
if (strpos($pid, ',')) {
@@
-102,8
+104,8
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
) as comptype_display_name
");
) as comptype_display_name
");
- if(!empty($q['
search
']['name'])){
- $s = $this->escape($q['
search
']['name']);
+ if(!empty($q['
query
']['name'])){
+ $s = $this->escape($q['
query
']['name']);
$this->whereAdd("
{$tn}.name LIKE '%$s%'
");
$this->whereAdd("
{$tn}.name LIKE '%$s%'
");
@@
-121,7
+123,9
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
}
// ---------- AUTHENTICATION
}
// ---------- AUTHENTICATION
- function isAuth()
+ // not sure where authetnication via company is used?? posibly media-outreach
+
+ function isAuth()
{
$db = $this->getDatabaseConnection();
$sesPrefix = $db->dsn['database'];
{
$db = $this->getDatabaseConnection();
$sesPrefix = $db->dsn['database'];
@@
-245,14
+249,32
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
function beforeInsert($q, $roo)
{
if(!empty($q['_check_name'])){
function beforeInsert($q, $roo)
{
if(!empty($q['_check_name'])){
- $this->checkName($roo);
+ if($this->checkName()){
+ $roo->jok('OK');
+ }
+
+ $roo->jerr('EXIST');
}
}
function beforeUpdate($old, $q,$roo)
{
}
}
function beforeUpdate($old, $q,$roo)
{
+
+ if(!empty($q['_flag_delete'])){
+ $this->deleted_dt = $this->sqlValue("NOW()");
+ $this->deleted_by = $roo->getAuthUser()->id;
+ }
+
+ if(!empty($q['_flag_undelete'])){
+ $this->deleted_dt = "";
+ $this->deleted_by = 0;
+ }
if(!empty($q['_check_name'])){
if(!empty($q['_check_name'])){
- $this->checkName($roo);
+ if($this->checkName()){
+ $roo->jok('OK');
+ }
+
+ $roo->jerr('EXIST');
}
if(!empty($q['_merge_id'])){
}
if(!empty($q['_merge_id'])){
@@
-268,12
+290,18
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
function beforeDelete($req, $roo)
{
function beforeDelete($req, $roo)
{
+
// should check for members....
if(!empty($this->is_system) &&
($old->code != $this->code || $old->name != $this->name)
){
$roo->jerr('This company is not allow to delete');
}
// should check for members....
if(!empty($this->is_system) &&
($old->code != $this->code || $old->name != $this->name)
){
$roo->jerr('This company is not allow to delete');
}
+
+
+ }
+ function onDelete($req, $roo)
+ {
$img = DB_DataObject::factory('Images');
$img->ontable = $this->tableName();
$img->onid = $this->id;
$img = DB_DataObject::factory('Images');
$img->ontable = $this->tableName();
$img->onid = $this->id;
@@
-423,7
+451,7
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
$companies->insert();
$companies->onInsert(array(), $roo);
}
$companies->insert();
$companies->onInsert(array(), $roo);
}
- function lookupOwner()
+
static
function lookupOwner()
{
$enum = DB_DataObject::Factory('core_enum')->lookup('COMPTYPE', 'OWNER' );
$companies = DB_DataObject::factory('core_company');
{
$enum = DB_DataObject::Factory('core_enum')->lookup('COMPTYPE', 'OWNER' );
$companies = DB_DataObject::factory('core_company');
@@
-438,7
+466,7
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
{
$affects = array();
{
$affects = array();
- $all_links = $
GLOBALS['_DB_DATAOBJECT']['LINKS'][$this->_database]
;
+ $all_links = $
this->databaseLinks()
;
foreach($all_links as $tbl => $links) {
foreach($links as $col => $totbl_col) {
foreach($all_links as $tbl => $links) {
foreach($links as $col => $totbl_col) {
@@
-475,8
+503,21
@@
class Pman_Core_DataObjects_Core_Company extends DB_DataObject
}
}
- function checkName(
$roo
)
+ function checkName()
{
{
+ $company = DB_DataObject::factory('core_company');
+ $company->setFrom(array(
+ 'name' => $this->name
+ ));
+ if(!empty($this->id)){
+ $company->whereAdd("id != {$this->id}");
+ }
+
+ if(!$company->find(true)){
+ return true;
+ }
+
+ return false;
}
}
}
}