Fix #5791 - Search Criteria on Orders / Columns on orders
authorEdward <edward@roojs.com>
Tue, 2 Apr 2019 04:28:03 +0000 (12:28 +0800)
committerEdward <edward@roojs.com>
Tue, 2 Apr 2019 04:28:03 +0000 (12:28 +0800)
DataObjects/Core_person.php
DataObjects/Core_person_settings.php [new file with mode: 0644]
DataObjects/pman.links.ini
sql/core_person_settings.sql [new file with mode: 0644]

index 12a9793..b72ecbe 100644 (file)
@@ -640,14 +640,12 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
     
     function authUserArray()
     {
-        
         $aur = $this->toArray();
         
         if ($this->id < 1) {
             return $aur;
         }
         
-        
         //DB_DataObject::debugLevel(1);
         $c = DB_Dataobject::factory('core_company');
         $im = DB_Dataobject::factory('Images');
@@ -697,6 +695,17 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         $oath_require = $s->lookup('core', 'two_factor_auth_required');
         $aur['require_oath'] = $oath_require ?  $oath_require->val : 0;
         
+        $aur['core_person_settings'] = array();
+                
+        $core_person_settings = DB_DataObject::factory('core_person_settings');
+        $core_person_settings->setFrom(array(
+            'person_id' => $this->id
+        ));
+        
+        foreach ($core_person_settings->fetchAll() as $k => $v) {
+            $aur['core_person_settings'][$v->scope] = $v->toArray();
+        }
+        
         return $aur;
     }
     
diff --git a/DataObjects/Core_person_settings.php b/DataObjects/Core_person_settings.php
new file mode 100644 (file)
index 0000000..0dd1ac7
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Table Definition for Core_person_settings
+ */
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
+
+class Pman_Core_DataObjects_Core_person_settings extends DB_DataObject 
+{
+    ###START_AUTOCODE
+    /* the code below is auto generated do not remove the above tag */
+
+    public $__table = 'core_person_settings';
+    public $id;
+    public $person_id;
+    public $scope;
+    public $data;
+    
+    /* the code above is auto generated do not remove the tag below */
+    ###END_AUTOCODE
+    
+    function beforeInsert($q, $roo)
+    {
+        if(
+                !$roo->authUser ||
+                (!empty($this->person_id) && $this->person_id != $roo->authUser->id)
+        ) {
+            $roo->jerr('Access Dennied');
+        }
+        
+    }
+    
+    function beforeUpdate($old, $q, $roo)
+    {
+        if(
+                !$roo->authUser ||
+                (!empty($this->person_id) && $this->person_id != $roo->authUser->id)
+        ) {
+            $roo->jerr('Access Dennied');
+        }
+    }
+    
+ }
index ce00327..2aeba9b 100644 (file)
@@ -80,8 +80,8 @@ to_group_id = core_group:id
 authorized_by = core_person:id
 updated_by = core_person:id
 
-
-
+[core_person_settings]
+person_id = core_person:id
 
 [database__render]
 core_project = name
diff --git a/sql/core_person_settings.sql b/sql/core_person_settings.sql
new file mode 100644 (file)
index 0000000..3612677
--- /dev/null
@@ -0,0 +1,9 @@
+
+CREATE TABLE core_person_settings (
+    id int(11) NOT NULL auto_increment,  
+    PRIMARY KEY   (id)
+);
+
+ALTER TABLE core_person_settings ADD COLUMN person_id INT(11) NOT NULL DEFAULT 0;
+ALTER TABLE core_person_settings ADD COLUMN scope VARCHAR(254) NOT NULL DEFAULT '';
+ALTER TABLE core_person_settings ADD COLUMN data TEXT NOT NULL DEFAULT '';
\ No newline at end of file