Explorar o código

added AclBase getID for default_objects

Piotr Labudda %!s(int64=9) %!d(string=hai) anos
pai
achega
775a73f357
Modificáronse 1 ficheiros con 34 adicións e 3 borrados
  1. 34 3
      SE/se-lib/Core/AclBase.php

+ 34 - 3
SE/se-lib/Core/AclBase.php

@@ -25,7 +25,39 @@ class Core_AclBase {
   public function getSimpleSchema() { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function getSimpleSchema() { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   // TODO: get more xsd restrictions like minOccurs, maxOccurs, nillable and restrictions
   // TODO: get more xsd restrictions like minOccurs, maxOccurs, nillable and restrictions
 
 
-  public function getID() { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }// TODO: Legacy
+  public function getID() {
+    if ('default_objects' == $this->getSourceName()) {
+      $idZasobDatabase = DB::getPDO()->getZasobId();
+      $namespace = $this->getNamespace();
+      $sqlNamespace = DB::getPDO()->quote($namespace, PDO::PARAM_STR);
+      $idZasob = DB::getPDO()->fetchValue("
+        select z.ID
+        from CRM_LISTA_ZASOBOW z
+        where z.`TYPE` = 'TABELA'
+          and z.`DESC` = {$sqlNamespace}
+          and z.PARENT_ID = {$idZasobDatabase}
+          and z.A_STATUS not in('DELETED')
+      ");
+      if ($idZasob) return $idZasob;
+      $idZasob = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [
+        'PARENT_ID' => $idZasobDatabase,
+        'DESC' => $namespace,
+        'TYPE' => "TABELA",
+        'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
+        'A_RECORD_CREATE_DATE' => "NOW()"
+      ]);
+      DB::getPDO()->insert('CRM_LISTA_ZASOBOW_HIST', [
+        'ID_USERS2' => $idZasob,
+        'PARENT_ID' => $idZasobDatabase,
+        'DESC' => $namespace,
+        'TYPE' => "TABELA",
+        'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
+        'A_RECORD_CREATE_DATE' => "NOW()"
+      ]);
+      return $idZasob;
+    }
+    throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501);
+  }
   public function init($force = false) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function init($force = false) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isInitialized() { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isInitialized() { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function getFields() {// @returns array - $this->_fields // TODO: mved to getFieldListByIdZasob
   public function getFields() {// @returns array - $this->_fields // TODO: mved to getFieldListByIdZasob
@@ -842,8 +874,7 @@ if($DBG){die();}
           $xsdLastUpdate = substr($lastUpdateDate, 0, 10) . "T" . substr($lastUpdateDate, 11) . ":00";
           $xsdLastUpdate = substr($lastUpdateDate, 0, 10) . "T" . substr($lastUpdateDate, 11) . ":00";
         } else if (preg_match('/^\d\d\d\d\-\d\d\-\d\d\-\d\d:\d\d:\d\d$/', $lastUpdateDate)) { // 'Y-m-d-H:i:s'
         } else if (preg_match('/^\d\d\d\d\-\d\d\-\d\d\-\d\d:\d\d:\d\d$/', $lastUpdateDate)) { // 'Y-m-d-H:i:s'
           $xsdLastUpdate = substr($lastUpdateDate, 0, 10) . "T" . substr($lastUpdateDate, 11);
           $xsdLastUpdate = substr($lastUpdateDate, 0, 10) . "T" . substr($lastUpdateDate, 11);
-        }
-        if (preg_match('/^\d\d\d\d\-\d\d\-\d\d\ \d\d:\d\d:\d\d$/', $lastUpdateDate)) {
+        } else if (preg_match('/^\d\d\d\d\-\d\d\-\d\d\ \d\d:\d\d:\d\d$/', $lastUpdateDate)) {
           $xsdLastUpdate = substr($lastUpdateDate, 0, 10) . "T" . substr($lastUpdateDate, 11);
           $xsdLastUpdate = substr($lastUpdateDate, 0, 10) . "T" . substr($lastUpdateDate, 11);
         }
         }
         return $xsdLastUpdate;
         return $xsdLastUpdate;