diff --git a/application/Espo/Controllers/Attachment.php b/application/Espo/Controllers/Attachment.php new file mode 100644 index 0000000000..76df1ec5fa --- /dev/null +++ b/application/Espo/Controllers/Attachment.php @@ -0,0 +1,8 @@ +get('ids'); $where = $request->get('where'); - if (!empty($ids)) { $where = array( diff --git a/application/Espo/Core/HookManager.php b/application/Espo/Core/HookManager.php index fc83e77e7d..f1e98957eb 100644 --- a/application/Espo/Core/HookManager.php +++ b/application/Espo/Core/HookManager.php @@ -25,7 +25,6 @@ class HookManager 'afterSave', ); - public function __construct(Container $container) { $this->container = $container; @@ -42,7 +41,6 @@ class HookManager return $this->container->get('fileManager'); } - protected function loadHooks() { if ($this->getConfig()->get('useCache') && file_exists($this->cacheFile)) { @@ -82,7 +80,7 @@ class HookManager { if (class_exists($className)) { $hook = new $className(); - $dependencies = $hook::$dependencies; + $dependencies = $hook->getDependencyList(); foreach ($dependencies as $name) { $hook->inject($name, $this->container->get($name)); } diff --git a/application/Espo/Core/Hooks/Base.php b/application/Espo/Core/Hooks/Base.php index a3325ec5f8..a300922f85 100644 --- a/application/Espo/Core/Hooks/Base.php +++ b/application/Espo/Core/Hooks/Base.php @@ -2,9 +2,11 @@ namespace Espo\Core\Hooks; -class Base +use \Espo\Core\Interfaces\Injectable; + +class Base implements Injectable { - static public $dependencies = array(); + protected $dependencies = array(); protected $injections = array( 'entityManager', @@ -14,13 +16,32 @@ class Base 'user', ); + public static $order = 9; + + public function __construct() + { + $this->init(); + } + + protected function init() + { + } + + public function getDependencyList() + { + return $this->dependencies; + } + + protected function getInjection($name) + { + return $this->injections[$name]; + } + public function inject($name, $object) { $this->injections[$name] = $object; } - - public static $order = 9; - + protected function getEntityManager() { return $this->injections['entityManager']; diff --git a/application/Espo/Core/Interfaces/Injectable.php b/application/Espo/Core/Interfaces/Injectable.php new file mode 100644 index 0000000000..e5b2ca1ee6 --- /dev/null +++ b/application/Espo/Core/Interfaces/Injectable.php @@ -0,0 +1,11 @@ +where(array('lower' => strtolower($emailOld)))->findOne(); $this->unrelate($entity, 'emailAddresses', $emailAddressOld); } - } + } } } protected function handleSpecifiedRelations(Entity $entity) { - foreach ($entity->getRelations() as $name => $defs) { - if ($defs['type'] == $entity::HAS_MANY || $defs['type'] == $entity::MANY_MANY) { + $relationTypes = array($entity::HAS_MANY, $entity::MANY_MANY, $entity::HAS_CHILDREN); + foreach ($entity->getRelations() as $name => $defs) { + if (in_array($defs['type'], $relationTypes)) { $fieldName = $name . 'Ids'; - if ($entity->has($fieldName)) { + if ($entity->has($fieldName)) { $specifiedIds = $entity->get($fieldName); if (is_array($specifiedIds)) { $toRemoveIds = array(); @@ -172,5 +173,6 @@ class Repository extends \Espo\ORM\Repository } } } + } diff --git a/application/Espo/Core/ServiceFactory.php b/application/Espo/Core/ServiceFactory.php index 4af4d3c7fd..a18742b76d 100644 --- a/application/Espo/Core/ServiceFactory.php +++ b/application/Espo/Core/ServiceFactory.php @@ -17,7 +17,7 @@ class ServiceFactory { if (class_exists($className)) { $service = new $className(); - $dependencies = $service::$dependencies; + $dependencies = $service->getDependencyList(); foreach ($dependencies as $name) { $service->inject($name, $this->container->get($name)); } diff --git a/application/Espo/Core/Services/Base.php b/application/Espo/Core/Services/Base.php index 6d77de97ff..f4c2e0feb7 100644 --- a/application/Espo/Core/Services/Base.php +++ b/application/Espo/Core/Services/Base.php @@ -2,9 +2,11 @@ namespace Espo\Core\Services; -abstract class Base +use \Espo\Core\Interfaces\Injectable; + +abstract class Base implements Injectable { - static public $dependencies = array(); + protected $dependencies = array(); protected $injections = array(); @@ -12,5 +14,24 @@ abstract class Base { $this->injections[$name] = $object; } - + + public function __construct() + { + $this->init(); + } + + protected function init() + { + } + + protected function getInjection($name) + { + return $this->injections[$name]; + } + + public function getDependencyList() + { + return $this->dependencies; + } } + diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index ffeedc7b58..97ab778852 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -7,7 +7,7 @@ use \PDO; class Activities extends \Espo\Core\Services\Base { - static public $dependencies = array( + protected $dependencies = array( 'entityManager', 'user', 'metadata', diff --git a/application/Espo/Resources/metadata/entityDefs/Attachment.json b/application/Espo/Resources/metadata/entityDefs/Attachment.json index 45cc53f95a..a23253a9a7 100644 --- a/application/Espo/Resources/metadata/entityDefs/Attachment.json +++ b/application/Espo/Resources/metadata/entityDefs/Attachment.json @@ -12,10 +12,6 @@ "type": "int", "min": 0 }, - "extension": { - "type": "varchar", - "maxLength": 10 - }, "parent": { "type": "linkParent" }, @@ -23,17 +19,9 @@ "type": "datetime", "readOnly": true }, - "modifiedAt": { - "type": "datetime", - "readOnly": true - }, "createdBy": { "type": "link", "readOnly": true - }, - "modifiedBy": { - "type": "link", - "readOnly": true } }, "links": { @@ -41,10 +29,6 @@ "type": "belongsTo", "entity": "User" }, - "modifiedBy": { - "type": "belongsTo", - "entity": "User" - }, "parent": { "type": "belongsToParent", "foreign": "attachments" diff --git a/application/Espo/Services/Attachment.php b/application/Espo/Services/Attachment.php new file mode 100644 index 0000000000..00af9581f4 --- /dev/null +++ b/application/Espo/Services/Attachment.php @@ -0,0 +1,30 @@ +dependencies[] = 'fileManager'; + } + + protected function getFileManager() + { + return $this->getInjection('fileManager'); + } + + public function createEntity($data) + { + $entity = parent::createEntity($data); + + list($prefix, $contents) = explode(',', $data['file']); + + if (!empty($entity->id)) { + $this->getFileManager()->setContent(base64_decode($contents), 'data/upload/' . $entity->id); + } + + return $entity; + } +} + diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index 196e077bdf..dea26d08ea 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -9,7 +9,7 @@ use \Espo\Core\Utils\Util; class Record extends \Espo\Core\Services\Base { - static public $dependencies = array( + protected $dependencies = array( 'entityManager', 'user', 'metadata', @@ -147,6 +147,11 @@ class Record extends \Espo\Core\Services\Base return $selectManager; } + + protected function storeEntity(Entity $entity) + { + return $this->getRepository()->save($entity); + } public function createEntity($data) { @@ -155,7 +160,7 @@ class Record extends \Espo\Core\Services\Base $entity->set($data); - if ($this->getRepository()->save($entity)) { + if ($this->storeEntity($entity)) { return $entity; } @@ -173,8 +178,11 @@ class Record extends \Espo\Core\Services\Base $entity->set($data); - $this->getRepository()->save($entity); - return $entity; + if ($this->storeEntity($entity)) { + return $entity; + } + + throw new Error(); } public function deleteEntity($id) diff --git a/application/Espo/Services/Stream.php b/application/Espo/Services/Stream.php index 612bff5886..aa1693261a 100644 --- a/application/Espo/Services/Stream.php +++ b/application/Espo/Services/Stream.php @@ -7,7 +7,7 @@ use \Espo\Core\Exceptions\NotFound; class Stream extends \Espo\Core\Services\Base { - static public $dependencies = array( + protected $dependencies = array( 'entityManager', 'user', 'metadata', diff --git a/data/upload/52d7f79f200b8 b/data/upload/52d7f79f200b8 new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d7f79f200b8 @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d7f7a1b3927 b/data/upload/52d7f7a1b3927 new file mode 100644 index 0000000000..bd0b889adf --- /dev/null +++ b/data/upload/52d7f7a1b3927 @@ -0,0 +1,19 @@ +git remote add upstream git@github.com:sugarcrm/Mango.git +git checkout -t -b caramel upstream/caramel +git checkout -b caramel + +git fetch upstream +git checkout caramel +git merge upstream/caramel + +git add --all +git commit -m 'comment' +git push origin caramel + + +git push -f origin HEAD^:master // remove last push from remote +git reset --soft HEAD^ + +git stash +git stash apply +git stash drop diff --git a/data/upload/52d7f7de5e7fa b/data/upload/52d7f7de5e7fa new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d7f7de5e7fa @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d7f7e06a2e8 b/data/upload/52d7f7e06a2e8 new file mode 100644 index 0000000000..bd0b889adf --- /dev/null +++ b/data/upload/52d7f7e06a2e8 @@ -0,0 +1,19 @@ +git remote add upstream git@github.com:sugarcrm/Mango.git +git checkout -t -b caramel upstream/caramel +git checkout -b caramel + +git fetch upstream +git checkout caramel +git merge upstream/caramel + +git add --all +git commit -m 'comment' +git push origin caramel + + +git push -f origin HEAD^:master // remove last push from remote +git reset --soft HEAD^ + +git stash +git stash apply +git stash drop diff --git a/data/upload/52d7f80cbeeaf b/data/upload/52d7f80cbeeaf new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d7f80cbeeaf @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d7f80f8878f b/data/upload/52d7f80f8878f new file mode 100644 index 0000000000..bd0b889adf --- /dev/null +++ b/data/upload/52d7f80f8878f @@ -0,0 +1,19 @@ +git remote add upstream git@github.com:sugarcrm/Mango.git +git checkout -t -b caramel upstream/caramel +git checkout -b caramel + +git fetch upstream +git checkout caramel +git merge upstream/caramel + +git add --all +git commit -m 'comment' +git push origin caramel + + +git push -f origin HEAD^:master // remove last push from remote +git reset --soft HEAD^ + +git stash +git stash apply +git stash drop diff --git a/data/upload/52d7f9c5e00de b/data/upload/52d7f9c5e00de new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d7f9c5e00de @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d7f9c7cacc9 b/data/upload/52d7f9c7cacc9 new file mode 100644 index 0000000000..bd0b889adf --- /dev/null +++ b/data/upload/52d7f9c7cacc9 @@ -0,0 +1,19 @@ +git remote add upstream git@github.com:sugarcrm/Mango.git +git checkout -t -b caramel upstream/caramel +git checkout -b caramel + +git fetch upstream +git checkout caramel +git merge upstream/caramel + +git add --all +git commit -m 'comment' +git push origin caramel + + +git push -f origin HEAD^:master // remove last push from remote +git reset --soft HEAD^ + +git stash +git stash apply +git stash drop diff --git a/data/upload/52d7fa8f1256f b/data/upload/52d7fa8f1256f new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d7fa8f1256f @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d7fa90cf95c b/data/upload/52d7fa90cf95c new file mode 100644 index 0000000000..bd0b889adf --- /dev/null +++ b/data/upload/52d7fa90cf95c @@ -0,0 +1,19 @@ +git remote add upstream git@github.com:sugarcrm/Mango.git +git checkout -t -b caramel upstream/caramel +git checkout -b caramel + +git fetch upstream +git checkout caramel +git merge upstream/caramel + +git add --all +git commit -m 'comment' +git push origin caramel + + +git push -f origin HEAD^:master // remove last push from remote +git reset --soft HEAD^ + +git stash +git stash apply +git stash drop diff --git a/data/upload/52d8007335b05 b/data/upload/52d8007335b05 new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d8007335b05 @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d80204bad7a b/data/upload/52d80204bad7a new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d80204bad7a @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d803585a5f5 b/data/upload/52d803585a5f5 new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d803585a5f5 @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d8039b1fc34 b/data/upload/52d8039b1fc34 new file mode 100644 index 0000000000..bd0b889adf --- /dev/null +++ b/data/upload/52d8039b1fc34 @@ -0,0 +1,19 @@ +git remote add upstream git@github.com:sugarcrm/Mango.git +git checkout -t -b caramel upstream/caramel +git checkout -b caramel + +git fetch upstream +git checkout caramel +git merge upstream/caramel + +git add --all +git commit -m 'comment' +git push origin caramel + + +git push -f origin HEAD^:master // remove last push from remote +git reset --soft HEAD^ + +git stash +git stash apply +git stash drop diff --git a/data/upload/52d8039dd386a b/data/upload/52d8039dd386a new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d8039dd386a @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d803a610aad b/data/upload/52d803a610aad new file mode 100644 index 0000000000..f168af234d --- /dev/null +++ b/data/upload/52d803a610aad @@ -0,0 +1,38 @@ +espoMetadata)) { + return $this->espoMetadata; + } + + $espoMetadataFile = Util::concatPath($this->getConfig()->get('cachePath'), 'ormMetadata.php'); + + if (!file_exists($espoMetadataFile) || !$this->getConfig()->get('useCache')) { + $this->getConverter()->process(); + } + + $this->espoMetadata = $this->getFileManager()->getContent($espoMetadataFile); + + return $this->espoMetadata; + } + + public function setOrmMetadata(array $espoMetadata) + { + $result = $this->getFileManager()->setContentPHP($espoMetadata, $this->getConfig()->get('cachePath'), 'ormMetadata.php'); + if ($result == false) { + $GLOBALS['log']->add('EXCEPTION', 'Metadata::setOrmMetadata() - Cannot save ormMetadata to a file'); + throw new \Espo\Core\Exceptions\Error(); + } + + $this->espoMetadata = $espoMetadata; + + return $result; + } + +} + diff --git a/data/upload/52d804b39c181 b/data/upload/52d804b39c181 new file mode 100644 index 0000000000..a5ed334e75 --- /dev/null +++ b/data/upload/52d804b39c181 @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Link +Icon[en_US]=gnome-panel-launcher +URL=/var/www +Name[en_US]=www +Name=www +Icon=gnome-panel-launcher diff --git a/data/upload/52d804b6726e6 b/data/upload/52d804b6726e6 new file mode 100644 index 0000000000..bd0b889adf --- /dev/null +++ b/data/upload/52d804b6726e6 @@ -0,0 +1,19 @@ +git remote add upstream git@github.com:sugarcrm/Mango.git +git checkout -t -b caramel upstream/caramel +git checkout -b caramel + +git fetch upstream +git checkout caramel +git merge upstream/caramel + +git add --all +git commit -m 'comment' +git push origin caramel + + +git push -f origin HEAD^:master // remove last push from remote +git reset --soft HEAD^ + +git stash +git stash apply +git stash drop diff --git a/data/upload/52d804bab19d4 b/data/upload/52d804bab19d4 new file mode 100644 index 0000000000..235f05d338 Binary files /dev/null and b/data/upload/52d804bab19d4 differ