Compare commits

...

949 Commits
2.9.0 ... 3.4.2

Author SHA1 Message Date
yuri
344da24b5e fix stream fetched twice 2015-06-12 14:50:54 +03:00
yuri
23ef028cb4 fix varchar search 2015-06-12 12:06:19 +03:00
yuri
492d4869c2 disable cut param for text 2015-06-12 11:02:02 +03:00
yuri
56e45c32f8 fix draft 2015-06-12 10:24:00 +03:00
yuri
cb41c55e7a bottom mode 2015-06-11 16:42:58 +03:00
yuri
7d63eaf3e0 fix bottom panels 2015-06-11 16:34:03 +03:00
yuri
1538b08fd9 version 2015-06-11 14:06:11 +03:00
yuri
82a8914848 fix entity manager 2015-06-11 14:03:28 +03:00
yuri
2d5bf843d5 fix css 2015-06-11 12:22:37 +03:00
yuri
f22f6d54aa edit bottom 2015-06-11 12:20:11 +03:00
yuri
d609e4f70b fix merge and mass u pdate 2015-06-11 11:49:32 +03:00
yuri
8f56769e14 change document layout 2015-06-11 10:58:04 +03:00
yuri
fa5b2da69e change documnts 2015-06-11 10:52:14 +03:00
yuri
937202784d autocomplete category tree 2015-06-11 10:49:34 +03:00
yuri
07424df41a document mass update 2015-06-11 10:47:46 +03:00
yuri
e960ac472e version 2015-06-10 17:45:40 +03:00
yuri
84113356b5 fix mass update 2015-06-10 17:45:03 +03:00
yuri
3844946dc0 fix parent 2015-06-10 17:40:14 +03:00
yuri
9ecdf5713c fix create 2015-06-10 17:32:56 +03:00
yuri
f1abd22512 fix email template 2015-06-10 15:40:26 +03:00
yuri
c963058571 improve field hide/show 2015-06-10 12:04:23 +03:00
yuri
7e264780ec fix acl 2015-06-09 16:29:46 +03:00
Taras Machyshyn
0750a89f74 Ukrainian corrections 2015-06-09 16:07:47 +03:00
Taras Machyshyn
5b52668359 Fixed metadata cache bug 2015-06-09 15:51:23 +03:00
Taras Machyshyn
3c91f8450d Bug fixing 2015-06-09 14:05:01 +03:00
yuri
f820168283 Merge branch 'hotfix/3.3.1' 2015-06-09 12:54:37 +03:00
yuri
bdb90a0016 Merge branch 'hotfix/3.3.1' of ssh://172.20.0.1/var/git/espo/backend into hotfix/3.3.1 2015-06-09 12:54:20 +03:00
yuri
521fa42bf1 fix layout 2015-06-09 12:25:15 +03:00
yuri
1b272ea0c7 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-06-09 12:22:01 +03:00
Taras Machyshyn
b055adfd87 Updated composer.lock file 2015-06-09 12:21:46 +03:00
yuri
42ea6e0d7c cleanup 2015-06-09 12:11:17 +03:00
yuri
20b21622ed layout manager improvement 2015-06-09 11:57:11 +03:00
yuri
34c61a2fc5 lang 2015-06-09 10:47:43 +03:00
yuri
cf8198dc98 version 2015-06-09 10:31:30 +03:00
yuri
c57fd2c55e Merge branch 'master' of https://github.com/espocrm/espocrm 2015-06-08 17:52:57 +03:00
yuri
3669bf4e11 fix modal 2015-06-08 17:29:58 +03:00
yuri
b6bbdada06 modal fit height 2015-06-08 17:17:14 +03:00
yuri
804a618408 folders width 2015-06-05 15:27:07 +03:00
yuri
a1192474d9 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-06-05 14:53:24 +03:00
yuri
dd28642370 setReadOnly form action 2015-06-05 14:53:11 +03:00
Taras Machyshyn
b92295cbb1 Installer: added check PHP < 5.4.0 2015-06-05 13:08:47 +03:00
Taras Machyshyn
d186cd2b1a Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-06-05 12:23:18 +03:00
Taras Machyshyn
9ebee47d5c Orm converter improvements 2015-06-05 12:23:05 +03:00
yuri
3fdc7c8cf7 create button change 2015-06-05 11:10:07 +03:00
Yuri Kuznetsov
b298b26bab Merge pull request #53 from alasdaircr/attr-not-empty
Fix ifAttrNotEmpty failing with boolean attributes
2015-06-05 10:17:54 +03:00
Alasdair Campbell
0a38857e64 Fix ifAttrNotEmpty failing with boolean attributes 2015-06-05 00:06:31 +01:00
yuri
2497e9bd88 fix modals 2015-06-04 17:52:24 +03:00
yuri
bee44612e5 external account id max length 2015-06-04 11:33:11 +03:00
Yuri Kuznetsov
8946b4ad11 Merge pull request #52 from alasdaircr/post-entrypoints
PATCH: Allow POST entrypoints
2015-06-04 10:10:34 +03:00
Alasdair Campbell
d4b78b9977 PATCH: Allow POST entrypoints 2015-06-03 16:12:17 +01:00
yuri
f9614385df Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-06-03 16:30:22 +03:00
yuri
7352abebe9 activities control 2015-06-03 16:30:12 +03:00
yuri
5c57b34893 user activities 2015-06-03 15:55:13 +03:00
yuri
0d873b7302 fix campaign fields 2015-06-03 12:41:06 +03:00
yuri
ccca6a8f55 fix fullForm link 2015-06-03 11:16:09 +03:00
Taras Machyshyn
bad9cc848f Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-06-02 17:31:18 +03:00
Taras Machyshyn
e3ab16a7bf Merge branch 'hotfix/3.3.1' 2015-06-02 17:31:04 +03:00
Taras Machyshyn
6db068e625 Improve Extension installation 2015-06-02 17:29:58 +03:00
Taras Machyshyn
64b1ac3ccf Rebuild fixes 2015-06-02 17:23:57 +03:00
yuri
ca038970ff folders notify 2015-06-02 17:11:39 +03:00
yuri
4d852c8515 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-06-02 17:09:00 +03:00
yuri
b96ea5100b modals select 2015-06-02 17:05:51 +03:00
yuri
fd86727bfc scopes in entity templates 2015-06-02 15:52:54 +03:00
yuri
8dacf66242 record tree create acl 2015-06-02 15:44:36 +03:00
Taras Machyshyn
bbb4271dd1 Merge branch 'hotfix/3.3.1' 2015-06-02 15:33:45 +03:00
Taras Machyshyn
8b72499c19 Databse rebuild fixes 2015-06-02 15:31:20 +03:00
yuri
0a9a5a47af document folders 3 2015-06-02 12:19:28 +03:00
yuri
4304724315 disable isOverdue field 2015-06-02 11:02:37 +03:00
yuri
8dc3c146e0 fix 2015-05-29 18:14:50 +03:00
yuri
7cefff04a7 document folders 2 2015-05-29 17:18:42 +03:00
yuri
dd6d6995b9 row actions active fix 2015-05-28 16:59:36 +03:00
yuri
3606dc39e3 document folder 1 2015-05-28 16:19:37 +03:00
yuri
03fef2fc8c Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-28 11:38:16 +03:00
yuri
704e548654 opp lead source disable customization and none for empty 2015-05-28 11:35:26 +03:00
yuri
6120d5501d fix followers order 2015-05-28 10:47:13 +03:00
Taras Machyshyn
3f8c338265 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-27 17:19:18 +03:00
Taras Machyshyn
ec07b23af8 Test corrections 2015-05-27 17:19:04 +03:00
yuri
cc349ca545 tooltip 2015-05-27 16:39:36 +03:00
yuri
b16ec66eb3 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-27 16:34:31 +03:00
yuri
22667e17f1 Repository: leftJoin method 2015-05-27 16:34:18 +03:00
yuri
5741834d53 fix test 2015-05-27 16:32:18 +03:00
yuri
0df39cdc4f fix middle tables 2015-05-27 16:30:36 +03:00
yuri
70489e8846 email loop prevention and query middle table change 2015-05-27 16:17:45 +03:00
Taras Machyshyn
c4558ec633 Merge branch 'hotfix/3.3.1' 2015-05-27 16:03:09 +03:00
Taras Machyshyn
5b500ae42a Added support UTF-8 strings for saved JSON data 2015-05-27 16:01:24 +03:00
yuri
cdbe6a2383 active filter 2 2015-05-26 16:32:29 +03:00
yuri
48c650eab2 user active filter 2015-05-26 16:31:33 +03:00
yuri
0c815b5761 followers 3 2015-05-26 16:17:24 +03:00
yuri
9b104b9a16 followers 2 2015-05-26 12:26:30 +03:00
yuri
97248e2b18 fix users panel 2015-05-26 11:41:15 +03:00
yuri
b3aa244f4e fix side panels 2015-05-26 11:40:13 +03:00
yuri
45c59ff242 fix createRelated 2015-05-26 11:30:25 +03:00
yuri
0038c3666d followers 1 2015-05-26 11:25:29 +03:00
yuri
7cfebbf87e fix entryPoint error messages 2015-05-26 10:34:57 +03:00
yuri
0cd3666a96 Merge branch 'hotfix/3.3.1' 2015-05-25 11:15:06 +03:00
yuri
d4a5f68398 fix before remove 2015-05-25 11:14:53 +03:00
yuri
1a30a9c29a pre-loader huck 2015-05-22 16:51:20 +03:00
yuri
cd75ddbbd7 select filter search 2015-05-22 16:46:03 +03:00
yuri
55aedb7194 selectRelated filters 2015-05-22 15:40:37 +03:00
yuri
aa303d164f reply from histpry panel 2015-05-22 15:17:55 +03:00
yuri
1723f63b21 label 2015-05-22 11:47:16 +03:00
yuri
55fef695ec fix panels 2015-05-22 11:42:44 +03:00
yuri
42ee41ae54 cleanup 2015-05-22 11:10:03 +03:00
yuri
676f480db8 full form on modal header 2015-05-21 15:34:07 +03:00
yuri
233408b076 wysiwyg size and scroll 2 2015-05-21 14:55:05 +03:00
yuri
9dfec82f6e fix frontend acl 2015-05-21 12:33:21 +03:00
yuri
3c791b6363 wysiwyg size and scroll 2015-05-21 11:39:51 +03:00
yuri
5a0e5f6804 total count in title 2015-05-21 11:13:25 +03:00
yuri
3376ab06d0 improve reply email 2015-05-21 11:01:42 +03:00
yuri
e8b22f9331 remove email ico 2015-05-21 10:33:59 +03:00
yuri
0b9104f992 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-20 17:12:28 +03:00
yuri
566d0e50a6 unlink all 2015-05-20 17:11:55 +03:00
yuri
be5a6a0ee0 fix controller 2015-05-20 16:10:07 +03:00
yuri
4df460d6cb fix paneld 2015-05-20 14:31:20 +03:00
yuri
7443c969b1 refactor panels 2015-05-20 14:27:38 +03:00
Taras Machyshyn
3b5b1fb1b3 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-20 13:05:18 +03:00
Taras Machyshyn
5737927e2d Merge branch 'hotfix/3.3.1' 2015-05-20 13:05:01 +03:00
Taras Machyshyn
c59b837315 Fixed a bug with '__APPEND__' merge 2015-05-20 13:03:33 +03:00
yuri
ce75b68df0 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-20 12:02:51 +03:00
yuri
d17257fc95 link fields filters fix 2015-05-20 12:02:07 +03:00
Taras Machyshyn
ed996eff43 Merge branch 'hotfix/3.3.1' 2015-05-20 10:57:20 +03:00
Taras Machyshyn
8f70c32687 Correction Ukrainian translation 2015-05-20 10:36:08 +03:00
yuri
d134db65a3 fix varchar searc 2015-05-19 18:07:56 +03:00
yuri
deaa3f3f73 fix varchar searc 2015-05-19 18:05:50 +03:00
yuri
5f5f6dcf38 fix query sanitize 2015-05-19 15:31:06 +03:00
yuri
8e373a9c33 fix warnings 2015-05-19 15:23:44 +03:00
yuri
f7a367d755 email to case 2015-05-19 15:17:11 +03:00
yuri
fea113269b compose email from detail view imporovement 2015-05-19 15:01:36 +03:00
yuri
5299da7a21 contact target list for import 2015-05-19 12:28:39 +03:00
yuri
9a06ee3221 opted out panel 2015-05-19 12:16:40 +03:00
yuri
5b489e2341 target list opted out api 2015-05-19 11:48:43 +03:00
yuri
5b0e4f910d fix target list add 2015-05-18 18:10:43 +03:00
Taras Machyshyn
575a4f12cc Fixed a bug with deleting/adding an autoincrement field 2015-05-18 16:14:55 +03:00
yuri
9b77f74e53 optedOut column 2015-05-18 12:02:34 +03:00
yuri
7be801c647 target list btn style 2015-05-18 11:30:14 +03:00
yuri
a95471a239 fix lang 2015-05-18 11:26:54 +03:00
yuri
8982993813 dropdownItemList 2015-05-18 11:25:17 +03:00
Taras Machyshyn
cc48dc2a65 Fixed a bug with module 'order' option 2015-05-18 10:47:21 +03:00
yuri
9e0d8632f5 email ui improvements 2015-05-15 17:46:17 +03:00
yuri
2f751085e0 bcc 2015-05-15 17:37:06 +03:00
yuri
f5faae13c4 email icon 2 2015-05-15 17:30:04 +03:00
yuri
015fd4014c email ico 2015-05-15 17:22:11 +03:00
yuri
ff9c68d7f6 createdAccount filter 2015-05-15 16:45:28 +03:00
yuri
323138eebf filter email by subject 2015-05-15 16:36:42 +03:00
yuri
43f15252bb relatedAttributeFunctions 2015-05-15 15:26:17 +03:00
yuri
25ad4ffa43 campaign and document small improvements 2015-05-15 15:06:50 +03:00
yuri
0cd3a464d8 acl improvement 2015-05-15 12:15:14 +03:00
yuri
71e9b313bb campaign label 2015-05-15 11:08:12 +03:00
yuri
9b13f82c55 selectize 2015-05-15 11:01:57 +03:00
yuri
20cf214187 stream hover 2015-05-14 12:26:26 +03:00
yuri
2d06568470 hover list row 2015-05-14 12:19:09 +03:00
yuri
59ccd121c5 fix modal in notification 2015-05-14 11:18:47 +03:00
yuri
caa0256f19 fix email notification 2015-05-14 10:54:13 +03:00
yuri
b27b356997 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-13 13:40:35 +03:00
yuri
3b76eec06c cleanup 2015-05-13 12:18:40 +03:00
yuri
04a768ee40 fix filter style 2015-05-13 12:07:46 +03:00
Taras Machyshyn
0a3490d4f2 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-13 11:53:55 +03:00
Taras Machyshyn
df71605c47 Fixed a bug with username of installer 2015-05-13 11:53:42 +03:00
yuri
7424828f0c remove account filters 2015-05-13 11:27:48 +03:00
yuri
c9c759f33b Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-13 11:15:09 +03:00
yuri
98835fdb6c fix uk_UA lang 2015-05-13 11:14:57 +03:00
Taras Machyshyn
d32887ed40 Improved some descriptions 2015-05-13 11:02:17 +03:00
yuri
6dd7573f7b fix followed filter 2015-05-13 10:44:16 +03:00
yuri
0027e1bf9a fix invitartion 2015-05-12 15:21:24 +03:00
Taras Machyshyn
eb10aa33d6 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-12 12:16:54 +03:00
Taras Machyshyn
cfe77569f1 Changed footer 2015-05-12 12:16:43 +03:00
yuri
62da3462bc follow button improvement 2015-05-12 11:35:27 +03:00
yuri
334b0baacc email account: email address 2015-05-12 11:35:10 +03:00
yuri
d16d177eaf entity manager: order 2015-05-11 15:17:58 +03:00
yuri
2966f158fe fix campaign 2015-05-11 13:07:43 +03:00
yuri
1f57bcb250 Merge branch 'master' of https://github.com/espocrm/espocrm 2015-05-11 12:32:38 +03:00
yuri
90e775c27a fix multi enum search 2015-05-11 12:30:36 +03:00
yuri
9ff47844e7 fix fetch 2015-05-11 12:09:51 +03:00
yuri
042d98d05b fetch for bottom and side views 2015-05-11 12:06:20 +03:00
yuri
0533c5a3ef sticked panels 2015-05-11 11:34:51 +03:00
yuri
0325f637b2 monitoredFolders tooltip 2015-05-11 11:27:17 +03:00
yuri
3d2bfe48b9 show stream count 2015-05-11 11:08:58 +03:00
yuri
c8a538d73e cleanup 2015-05-11 11:04:06 +03:00
yuri
fbc171b07f update fr_FR 2015-05-11 11:03:13 +03:00
yuri
70e4921961 fix email import 2015-05-11 11:00:46 +03:00
Yuri Kuznetsov
1ca96c7ca8 Update README.md 2015-05-09 10:04:58 +03:00
yuri
65359f103f disable task stream 2015-05-08 17:18:27 +03:00
yuri
e5afffbde1 datetimeOptional fix 2015-05-08 12:51:09 +03:00
yuri
66364e91b7 datetimeOptional field type and task stream 2015-05-08 12:38:52 +03:00
yuri
567ca19398 converted to panel change 2015-05-08 11:51:03 +03:00
yuri
1e073def9d footer catch 2015-05-08 11:24:31 +03:00
yuri
70c772dfd2 note.related_id 2015-05-08 10:58:44 +03:00
yuri
709259f45e fix task complete button 2015-05-07 18:19:41 +03:00
yuri
dca51642e3 email userse filter 2015-05-07 17:59:02 +03:00
yuri
f24aea6354 followCreateEntities field 2015-05-07 15:05:22 +03:00
yuri
c020cd4251 followed filter 2015-05-07 14:14:42 +03:00
yuri
452e2ddc51 css changes 2015-05-07 11:59:03 +03:00
yuri
1860c69313 fix filters css 2015-05-07 11:49:59 +03:00
yuri
201beca8fa audited change 2015-05-07 11:22:52 +03:00
yuri
9182aeef99 Followed bool filter 2015-05-07 11:11:27 +03:00
yuri
d2cb7f60de stream status changes 2015-05-07 10:35:52 +03:00
yuri
c6beb0aac3 inCategory search 2015-05-06 17:38:41 +03:00
yuri
e394b12888 fix linkedWith 2015-05-06 16:06:28 +03:00
yuri
a461c8515f Merge branch 'master' into feature/tree 2015-05-06 15:45:40 +03:00
yuri
9bb36e1a35 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-06 15:39:55 +03:00
yuri
1a5c75daac remove oveflow hidden for .field 2015-05-06 15:23:58 +03:00
yuri
2c7633e74d task detailSmall change 2015-05-06 15:22:53 +03:00
yuri
996ad352e1 create task from email 2015-05-06 15:18:56 +03:00
yuri
5c4b0d7723 change link field tpl 2015-05-06 14:31:46 +03:00
yuri
6485ed38d6 layouts ability to add new 2015-05-06 12:22:48 +03:00
yuri
48d9c0a7ff sort entity manager 2015-05-06 12:08:31 +03:00
yuri
40c4b77cbf field tpl changes 2015-05-06 12:01:03 +03:00
Taras Machyshyn
9b0ed1c833 Added possibility to define custom tables in metadata under 'additionalTables' option 2015-05-06 11:17:39 +03:00
yuri
bc6e74a092 compose email body height 2015-05-06 11:13:31 +03:00
yuri
52bdb136d4 fix wtsiwyg 2015-05-06 11:06:58 +03:00
yuri
f0e77da5d4 overflow hidden for field 2015-05-06 10:56:57 +03:00
yuri
0b77c4cdfe move inbound email to core 2015-05-06 10:40:22 +03:00
yuri
2efa0c0ca7 lang 2015-05-06 10:00:11 +03:00
yuri
87892c799c dev 2015-05-05 17:25:37 +03:00
yuri
5bfa258881 dev 2015-05-05 15:58:07 +03:00
yuri
d742de40c5 fix get imap folders ssl 2015-05-05 13:51:43 +03:00
yuri
bb3bd0e915 dev 2015-05-05 13:38:11 +03:00
yuri
8d50f52b7f cleanup 2015-05-05 11:39:57 +03:00
yuri
bd2fd5eb3a Merge branch 'master' into feature/tree 2015-05-05 11:38:51 +03:00
yuri
2db25fda63 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-05 11:38:36 +03:00
yuri
3067abcac2 save calendar view 2015-05-05 11:30:29 +03:00
yuri
c0c77e6e6b task attachments 2015-05-05 11:23:35 +03:00
Taras Machyshyn
4037ffa295 Changed 'relationName' to camelCase 2015-05-05 10:49:44 +03:00
Taras Machyshyn
2aa263847f Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-05 10:30:08 +03:00
Taras Machyshyn
50f9f24887 OrmMetadata: fixed 'midKeys' merging priority 2015-05-05 10:29:52 +03:00
yuri
e36ee5aaff link multiple <div> 2015-05-05 10:14:03 +03:00
yuri
6d8017f1dc fix link manager 2015-05-04 16:00:03 +03:00
yuri
d22ce60f7b fix link manager 2015-05-04 15:48:58 +03:00
yuri
bc7d4f214f fix email preview 2015-05-04 15:34:03 +03:00
yuri
daa80d7196 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-05-04 15:23:49 +03:00
yuri
8d3da43dca list buttonDisabled 2015-05-04 15:23:25 +03:00
yuri
15b329580c fix layout 2015-05-04 15:19:41 +03:00
yuri
0e2f8d9bf9 fix email link 2015-05-04 15:15:39 +03:00
yuri
951d68724b acl imporvements 2015-05-04 12:24:32 +03:00
yuri
f678253b05 fix outbound email encoding 2015-05-04 11:11:08 +03:00
yuri
0603eaf48d dev 2015-05-04 10:35:24 +03:00
yuri
753caf7eeb dev 2015-05-01 17:32:28 +03:00
yuri
5dbf719a53 gitignore 2015-05-01 17:31:38 +03:00
yuri
1e945cff41 dev 2015-05-01 13:14:20 +03:00
Taras Machyshyn
4a1237cdcc Translation corrections 2015-05-01 12:51:40 +03:00
Taras Machyshyn
b60e65379e Improved ScheduledJobLog 2015-05-01 12:03:17 +03:00
yuri
6da4e1796b dev 2015-04-30 15:55:07 +03:00
yuri
2666f05bd5 dev 2015-04-30 15:02:21 +03:00
Taras Machyshyn
461bffbf02 Jobs: improved scheduledJobLog 2015-04-30 13:07:54 +03:00
yuri
2653bba158 dev 2015-04-30 12:14:47 +03:00
yuri
56d73519bf dev 2015-04-29 18:27:54 +03:00
yuri
df3a7d78f4 dev 2015-04-29 17:39:17 +03:00
Taras Machyshyn
898a7d89c7 Fixed ScheduledJobLog clean-up 2015-04-29 17:17:00 +03:00
yuri
2734b9bf8c dev 2015-04-29 16:33:44 +03:00
yuri
2c074c6e82 dev 2015-04-28 18:09:17 +03:00
yuri
1e67fe69e1 dev 2015-04-28 17:53:31 +03:00
Taras Machyshyn
08cf333c0c Metadata: optimization 2015-04-28 15:38:45 +03:00
Taras Machyshyn
0f62d7da13 Metadata: code improvements 2015-04-28 15:28:26 +03:00
Taras Machyshyn
8ce806d41f Metadata: renamed option 'skip' to 'skipOrmDefs' 2015-04-28 14:54:43 +03:00
Taras Machyshyn
59a564cc1b FieldManager fixes 2015-04-28 14:40:50 +03:00
Taras Machyshyn
1135573af6 Metadata changes: generated fields now added to metadata 2015-04-28 11:59:05 +03:00
yuri
c9a1e3733c listSmall 2015-04-28 10:16:41 +03:00
yuri
6dbeba3473 quick view more quicker 2015-04-24 13:22:19 +03:00
yuri
351087781e fix email inbox 2015-04-24 12:37:03 +03:00
yuri
92f977d6c2 camelCase aliases 2015-04-24 11:45:27 +03:00
yuri
489fbb8800 fix search 2015-04-24 11:26:38 +03:00
yuri
159c19fe08 conflict fix 2015-04-24 10:43:36 +03:00
yuri
c13e46554d change upgrade done message 2015-04-24 10:14:17 +03:00
yuri
6f45e26028 version 2015-04-24 10:04:19 +03:00
yuri
7e02481b35 version 2015-04-24 09:59:16 +03:00
yuri
79e94a8255 Merge branch 'hotfix/3.2.2' 2015-04-24 09:54:11 +03:00
yuri
288398d4c2 fix preferences decode 2015-04-23 17:18:23 +03:00
yuri
92afc4deee cleanup 2015-04-23 15:49:05 +03:00
Taras Machyshyn
f6892877c1 Extension can be installed with the same version 2015-04-23 15:44:31 +03:00
yuri
30c57921d1 refresh for extensions and upgrades installed 2015-04-23 15:30:11 +03:00
yuri
d23bf569c0 cleanup 2015-04-23 15:22:29 +03:00
yuri
796830d2dd set not held row action 2015-04-23 15:17:47 +03:00
yuri
286ec0325d set held mass action 2015-04-23 15:15:08 +03:00
yuri
c8338e1759 link filter change 2015-04-23 12:34:35 +03:00
yuri
5f8adf51c1 Merge branch 'hotfix/3.2.2' 2015-04-23 11:57:10 +03:00
yuri
c7cc44edf6 Merge branch 'hotfix/3.2.2' of ssh://172.20.0.1/var/git/espo/backend into hotfix/3.2.2 2015-04-23 11:56:41 +03:00
yuri
e958d7c488 fix inbound email 2015-04-23 11:55:25 +03:00
Taras Machyshyn
77ff11990b Installer: disable prompt password saving while installing 2015-04-23 11:48:23 +03:00
yuri
e1538a5028 fix acl 2015-04-23 11:40:55 +03:00
Taras Machyshyn
994e0c1eda Extensions: improved restore functionality of install script 2015-04-23 10:48:42 +03:00
Taras Machyshyn
d51e88be60 Minor bug fixes for fileManager 2015-04-23 10:42:24 +03:00
yuri
b1ba07a995 task date completed 2015-04-22 17:07:32 +03:00
yuri
146a7aba1f filters 2015-04-22 16:43:45 +03:00
yuri
981c60c78a fix plain text 2015-04-22 16:28:04 +03:00
yuri
2e85e7fc56 email: show plain 2015-04-22 16:26:30 +03:00
yuri
99edab675a create contact from email 2015-04-22 16:12:55 +03:00
yuri
1a8d3a3cdf fix rerender on remove from list 2015-04-22 15:29:40 +03:00
yuri
43abd1740e modals change 2015-04-22 15:01:09 +03:00
yuri
261d60f338 cleanup 2015-04-22 11:20:19 +03:00
yuri
1a36d7758b reply to all be default 2015-04-22 11:08:22 +03:00
yuri
c09fc39881 fix image crop 2015-04-22 10:46:30 +03:00
yuri
0a7cd28ab5 assignedUser not required for Account/Contact/Lead 2015-04-22 10:27:10 +03:00
yuri
bf8bf5e4d9 fix link parent 2015-04-22 10:19:51 +03:00
yuri
1defafd258 remove async false 2015-04-22 10:13:10 +03:00
yuri
4854133f46 fix in acl table 2015-04-22 10:04:01 +03:00
yuri
d93879a24d cleanup 2015-04-21 18:01:36 +03:00
yuri
8ff6d2063c fix calendar modal 2015-04-21 17:59:21 +03:00
yuri
a46ecce6d0 not held in history 2015-04-21 17:57:19 +03:00
yuri
49175ae1b1 fix compose email modal 2015-04-21 17:40:45 +03:00
yuri
532473df15 fix modal 2015-04-21 17:14:38 +03:00
yuri
252ba4dccc modal buttonList 2015-04-21 17:11:02 +03:00
yuri
1ddac304d7 Email drafts filter 2015-04-21 16:12:41 +03:00
yuri
44ecebad03 translateOption Global by default 2015-04-21 15:42:48 +03:00
yuri
67d8c6cb17 version number in upgrade page 2015-04-21 15:40:50 +03:00
yuri
c52ca7244f reply prefix changes 2015-04-21 15:35:42 +03:00
yuri
b42b276054 cleanup 2015-04-21 14:39:07 +03:00
yuri
619a279dbb isEditable 2015-04-21 14:34:53 +03:00
yuri
56e0c9928e dont show email content in note if not parent view 2015-04-21 12:29:46 +03:00
yuri
25a424266b filters change 2015-04-21 12:19:14 +03:00
yuri
c8b13e07b1 Merge branch 'hotfix/3.2.1' 2015-04-17 16:05:19 +03:00
yuri
9595d528a8 wysywyg strip base tag 2015-04-17 15:22:29 +03:00
yuri
48cf4a6ed6 admin panel: outbound email change 2015-04-17 12:35:46 +03:00
yuri
9de2b5f7ef Merge branch 'hotfix/3.2.1' 2015-04-17 11:57:14 +03:00
yuri
9bfb27e10a layout pretty print 2015-04-17 11:57:00 +03:00
yuri
be50630d2f fix primary address 2015-04-17 11:51:16 +03:00
yuri
7d7234a226 some change with filters 2015-04-17 11:31:31 +03:00
yuri
a7517bed9d document file field change 2015-04-17 10:48:01 +03:00
yuri
66fca4dadd change documents listSmall 2015-04-16 17:15:29 +03:00
yuri
645b64437f change email ack 2015-04-16 17:12:18 +03:00
yuri
efa2755f19 acl refactor 2 2015-04-16 16:36:26 +03:00
yuri
4fe0f53878 acl refactor 2015-04-16 12:39:56 +03:00
yuri
d8b629a5a0 fix email note if sent is fail 2015-04-16 10:31:03 +03:00
yuri
5db5b41f7f email notification change 2015-04-15 17:36:53 +03:00
yuri
6d0b39f2b6 fix email note 2015-04-15 16:43:06 +03:00
yuri
909aa49e39 email notificator change 2015-04-15 16:42:48 +03:00
yuri
dd3d09f895 fix email note 2015-04-15 16:36:49 +03:00
yuri
395182bda5 filter layout 2015-04-15 16:27:27 +03:00
yuri
fd7d73756a email improvement 2015-04-15 15:47:10 +03:00
yuri
aff95d47dd Merge branch 'hotfix/3.2.1' 2015-04-15 12:11:13 +03:00
yuri
b778f74628 Test Connection for email account 2015-04-15 12:10:59 +03:00
yuri
9f72d65281 Merge branch 'hotfix/3.2.1' 2015-04-15 11:02:30 +03:00
yuri
6db658c0b3 fix follow button 2015-04-15 10:47:03 +03:00
yuri
6fb88665bb messageId fix 2015-04-15 10:05:08 +03:00
yuri
669cc2b883 defaultReminders 2015-04-14 17:35:31 +03:00
yuri
dec262e999 cleanup 2015-04-14 16:47:30 +03:00
yuri
cb03047ac3 rowActionsView prop 2015-04-14 16:42:13 +03:00
yuri
8c5f94ace4 view and edit for record dashlet 2015-04-14 16:40:18 +03:00
yuri
6269f02bca filters improvements 2015-04-14 16:22:42 +03:00
yuri
f20a47542a disable escape for quick edit 2015-04-14 14:30:55 +03:00
yuri
c77e3b7e92 link field placeholder 2015-04-14 12:28:50 +03:00
yuri
e7b033304c clear_cache.php 2015-04-14 12:11:45 +03:00
yuri
2b8a8d23eb fix notifications hook 2015-04-14 11:51:34 +03:00
yuri
0f59f79a9e fix email search 2015-04-14 11:50:05 +03:00
yuri
2904cd1f53 performance tweeks 2015-04-14 11:43:29 +03:00
yuri
d87ae60fea version 2015-04-13 12:16:30 +03:00
yuri
0d17cf6e78 lang cache issue 2015-04-13 11:53:22 +03:00
yuri
81739d59f5 quickDetailDisabled 2015-04-13 11:07:16 +03:00
yuri
7704d5afd0 layout change 2015-04-13 10:43:18 +03:00
yuri
da268f2b29 note email from === parent 2015-04-13 10:30:57 +03:00
yuri
01dc251ef2 fix email RE 2015-04-13 10:17:20 +03:00
yuri
9054d70f4c fix email from 2015-04-13 10:14:05 +03:00
yuri
788b265cd4 email fixes 2015-04-13 10:00:48 +03:00
yuri
c96640bcb1 fix orm double join 2015-04-10 15:41:45 +03:00
yuri
66fb7b4e81 fix import 2015-04-10 11:49:42 +03:00
yuri
d83a19e316 fix lang 2015-04-10 10:24:58 +03:00
yuri
452e39903e ua lang 2015-04-09 15:28:07 +03:00
yuri
797fcc172c email to lead: use reply to 2015-04-09 14:06:11 +03:00
yuri
cdb7c919b3 sort layout field list 2015-04-09 12:27:38 +03:00
yuri
0f7f438935 layoutSearch fix 2015-04-09 12:12:10 +03:00
yuri
7c01eedda8 followCreatedEntities param 2015-04-09 12:05:40 +03:00
yuri
bab7f3e9fc email notifications 2015-04-09 11:56:47 +03:00
yuri
761d85a112 fix email import and send 2015-04-09 11:02:55 +03:00
yuri
52e323123a notifications 2 2015-04-08 18:23:14 +03:00
yuri
01af1677cf notifications 2015-04-08 17:38:32 +03:00
yuri
d4f4fcb10e email optimization 2015-04-07 16:54:54 +03:00
yuri
74fd228bfb fix email small layout 2015-04-07 15:46:31 +03:00
yuri
f452d2e5d2 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-04-07 15:25:29 +03:00
yuri
3a01348e02 improve draft email 2015-04-07 15:25:15 +03:00
Taras Machyshyn
b1743ee4a2 Cleared passwords when loggin input data 2015-04-07 12:32:13 +03:00
Taras Machyshyn
ab14769387 Changed current year for installer 2015-04-07 12:04:13 +03:00
yuri
5c800601e4 cleanup addition 2015-04-07 11:23:25 +03:00
yuri
8aea81340b default layout changes 2015-04-07 10:28:26 +03:00
yuri
8513911f21 Merge branch 'master' of https://github.com/espocrm/espocrm 2015-04-06 17:38:33 +03:00
yuri
6a46c453cd add client custom dir 2015-04-06 17:38:10 +03:00
yuri
2029dc5e10 fix tasks panel 2015-04-06 17:34:04 +03:00
yuri
70664d1a7a fix template entityDefs 2015-04-06 16:13:08 +03:00
yuri
7d212ec62f fix default detail layout 2015-04-06 16:10:20 +03:00
yuri
fa7b145e07 fix link manager 2015-04-06 16:02:10 +03:00
yuri
830645cb73 parent type length 100 2015-04-06 15:43:47 +03:00
yuri
94e03b3c18 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-04-06 15:36:46 +03:00
Taras Machyshyn
3ace85eebc Improved Orm convertor 2015-04-06 15:36:14 +03:00
yuri
c6cfdd9e90 version 2015-04-06 12:37:57 +03:00
yuri
d1b2dfae3e default task status 2015-04-06 12:29:48 +03:00
yuri
98fb345a5a dont create auth token if logged browser basic auth 2015-04-06 11:26:18 +03:00
Yuri Kuznetsov
481314886f Update README.md 2015-04-03 18:59:02 +03:00
yuri
ad90cd171a leadSource field 2015-04-03 12:50:14 +03:00
yuri
8272e0e652 default duration 2015-04-03 12:07:11 +03:00
yuri
f218de2e04 fix messages 2015-04-03 11:58:58 +03:00
yuri
53529fc506 duration options 2015-04-03 11:47:55 +03:00
yuri
aef99fb4fd lang 2015-04-03 11:08:42 +03:00
yuri
86f690c79f midAlias ORM 2015-04-03 10:29:28 +03:00
yuri
71f9e90436 join many alias 2015-04-02 17:48:46 +03:00
yuri
75608f41b1 Merge branch 'hotfix/3.1.2' 2015-04-02 15:30:19 +03:00
yuri
0730ae5b3f fix forgot password 2015-04-02 15:27:29 +03:00
yuri
a7f537879e change dev index.php 2015-04-02 15:20:05 +03:00
yuri
6066cf1d65 change version 2015-04-02 14:24:20 +03:00
yuri
ccda236b6e Merge branch 'hotfix/3.1.2' 2015-04-02 11:46:22 +03:00
yuri
32ec348369 pt_BR fixes 2015-04-02 11:46:04 +03:00
yuri
d85f66171d Merge branch 'hotfix/3.1.2' 2015-04-02 11:13:26 +03:00
yuri
8c6aa46ec8 fix email plain 2015-04-02 11:12:56 +03:00
yuri
d2f7bc475a fix role and team list layout 2015-04-02 10:57:25 +03:00
yuri
410cf02518 filters layout changes 2015-04-01 16:49:44 +03:00
yuri
958414017e Merge branch 'hotfix/3.1.2' 2015-04-01 16:22:30 +03:00
yuri
8fbfad9637 async false for upgrade 2015-04-01 16:22:17 +03:00
yuri
07e8f94748 fix form leave out 2015-04-01 15:52:21 +03:00
yuri
4db162f9f7 fix form leave out 2015-04-01 15:33:03 +03:00
yuri
459dfb7937 Merge branch 'master' of https://github.com/espocrm/espocrm 2015-04-01 15:07:55 +03:00
yuri
56b0536152 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-04-01 15:07:42 +03:00
yuri
5bb7dd3ccd list buttons 2015-04-01 15:07:27 +03:00
yuri
6e50e4fd8e hide cc field if empty 2015-04-01 12:23:00 +03:00
yuri
878e1616da change email layout and email from name fix 2015-04-01 12:16:35 +03:00
yuri
64a410099e form leave out 2015-04-01 11:32:37 +03:00
yuri
9cb8664ddf fix token remove 2015-04-01 09:49:41 +03:00
Taras Machyshyn
6d5c3c8ad5 Code optimization for Orm convertation 2015-03-31 17:23:53 +03:00
Yuri Kuznetsov
f07c8fca64 Update README.md 2015-03-31 16:41:56 +03:00
yuri
944c76ad93 imprort improvements 2015-03-31 15:50:33 +03:00
yuri
ae8f9df02b fix metadata to orm 2015-03-31 10:57:10 +03:00
yuri
6da3659b7d Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-31 10:48:13 +03:00
yuri
1f1d9f3abd Merge branch 'hotfix/3.1.2' 2015-03-31 10:48:08 +03:00
yuri
530d7f2d81 import email: findParent lead 2015-03-31 10:47:53 +03:00
Taras Machyshyn
e67ecded2a Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-31 10:43:31 +03:00
Taras Machyshyn
b9343d5e64 Improved Orm convertation 2015-03-31 10:43:14 +03:00
yuri
898393c7ac Merge branch 'hotfix/3.1.2' 2015-03-30 17:44:16 +03:00
yuri
9b2ea5298d fix iframe links 2015-03-30 17:14:37 +03:00
yuri
0d2b56c58f signature fix 2015-03-30 17:07:28 +03:00
yuri
076c920dc7 upgrade summernote 2015-03-30 16:58:45 +03:00
yuri
638df642ec import dev 2015-03-30 16:47:27 +03:00
yuri
d2f4190612 field changes 2015-03-30 16:18:29 +03:00
yuri
7201f517e8 row actions change 2015-03-30 15:32:18 +03:00
yuri
c91365f627 change calendar query 2015-03-30 15:03:41 +03:00
yuri
f3bc4dbccf import dev 2015-03-30 13:39:14 +03:00
yuri
d4daef6012 autoincrement creatable 2015-03-30 12:29:53 +03:00
yuri
dbf4f68a44 user filters 2015-03-30 12:28:54 +03:00
yuri
8a7325963b import revert/remove duplicates 2015-03-30 12:26:41 +03:00
yuri
fc0d8dffcd fix prev 2015-03-30 11:34:54 +03:00
yuri
f8498e3adc save and remove options 2015-03-30 11:22:14 +03:00
yuri
e4b51ba675 fix isOverdue 2015-03-27 16:49:32 +02:00
yuri
83f9ead607 record getEntity 2015-03-27 16:44:34 +02:00
yuri
bf6778770e fix label 2015-03-27 16:23:40 +02:00
yuri
093b80293a import dev 2015-03-27 16:20:44 +02:00
yuri
34dee314e7 import dev 2015-03-27 15:46:59 +02:00
yuri
313b94168e search.tpl fix 2015-03-27 13:10:56 +02:00
yuri
d6085bbdcf createdAt to filters 2015-03-27 12:43:09 +02:00
yuri
160dc5d61c Merge branch 'hotfix/3.1.2' 2015-03-27 12:10:41 +02:00
yuri
987b383d7c fix plainText signature 2015-03-27 12:10:12 +02:00
yuri
8b4cb1568e import dev 2015-03-27 12:00:10 +02:00
yuri
aef4028180 replace tabs 2015-03-27 11:52:07 +02:00
yuri
9b779ee8cd change streamRelated for account 2015-03-26 18:08:35 +02:00
yuri
ccc339cf48 import 1 2015-03-26 17:23:26 +02:00
yuri
6aabbfd944 replace tabs 2015-03-26 13:58:32 +02:00
yuri
0e87626e34 cleanup 2015-03-26 13:22:20 +02:00
yuri
8641181511 fix task panel 2015-03-26 13:20:21 +02:00
yuri
123c3ef8ab grand filters change 2015-03-26 13:14:13 +02:00
yuri
07bd5a9d60 opp by stage w/o Closed Won 2015-03-25 16:07:05 +02:00
yuri
deca89039a calendar dashlet changes 2015-03-25 15:58:08 +02:00
yuri
1542fa86d8 Merge branch 'hotfix/3.1.1' 2015-03-25 15:28:11 +02:00
yuri
93ca814fe3 fix save filters margin 2015-03-25 15:27:54 +02:00
yuri
4d9e5ee302 accountId improvements 2015-03-25 15:25:39 +02:00
yuri
0a697cdc0a note superParent 2 2015-03-25 14:42:19 +02:00
yuri
1b01e476ac clearnup 2015-03-25 14:09:10 +02:00
yuri
ee689fb351 remove dashletOptions when dashlet removed 2015-03-25 14:08:34 +02:00
yuri
92a76d80f2 Merge branch 'hotfix/3.1.1' 2015-03-25 10:26:56 +02:00
yuri
a662c1a5fe improve uniqid 2015-03-25 10:26:02 +02:00
yuri
3ffa949276 fix create in select 2015-03-24 17:44:16 +02:00
yuri
371966e2cf add super parent for note 2015-03-24 17:24:38 +02:00
yuri
8f1a4d2a02 link, linkParent and belondToParent fix 2015-03-24 16:44:15 +02:00
yuri
3128b6f25a add index to email 2015-03-24 15:51:36 +02:00
yuri
0920821f1e change lang message 2015-03-24 12:12:24 +02:00
yuri
0f8f9c01ff change css 2015-03-24 12:06:29 +02:00
yuri
1d9621bc91 change version 2015-03-24 11:25:09 +02:00
yuri
e138daec5f fix table head hight 2015-03-24 11:16:26 +02:00
yuri
4a51e754d7 fix in inbound email 2015-03-24 11:01:55 +02:00
yuri
e6e0bc1703 fix inbound email double notification 2015-03-24 10:52:33 +02:00
yuri
49fbc6e082 email fromName changes 2015-03-24 10:39:08 +02:00
yuri
a0ed610f60 search by target lists 2015-03-23 18:07:39 +02:00
yuri
9f8c0eb4a2 cleanup 2015-03-23 16:50:32 +02:00
yuri
be29fac010 rename role to title 2015-03-23 16:02:07 +02:00
yuri
b3cefd9bcb change case layout 2015-03-23 15:54:34 +02:00
yuri
501d6f2692 fix markdown parsing 2015-03-23 15:45:48 +02:00
yuri
3d7560024f fixes email reply 2015-03-23 14:39:01 +02:00
yuri
a201b45d04 change stream messages 2015-03-23 11:45:30 +02:00
yuri
41f88a4015 modal.detail scroll to top hack 2015-03-23 11:18:45 +02:00
yuri
52a131ef93 fix dashlet actions 2015-03-23 10:34:54 +02:00
yuri
7ab28601ca dashlet options clone 2015-03-23 10:04:34 +02:00
yuri
5de509a0de fix warnings 2015-03-23 10:00:08 +02:00
yuri
2534b14dce fix frontend acl 2015-03-23 09:50:40 +02:00
yuri
27f98b95eb fix currency field 2015-03-20 17:09:02 +02:00
yuri
b08bee78b9 iframe fix 2015-03-20 16:57:46 +02:00
yuri
a39327a95b 2015 2015-03-20 16:23:18 +02:00
yuri
f979a8dd46 fix options 2015-03-20 15:23:22 +02:00
yuri
ecf1645e05 cleanup 2015-03-20 14:31:24 +02:00
yuri
d015bec89c navbar changes 2015-03-20 14:31:07 +02:00
yuri
92e1d4b8e6 clearnup 2015-03-19 17:13:02 +02:00
yuri
a75df456e2 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-19 17:11:43 +02:00
yuri
5393c2f314 header changes 2015-03-19 17:08:04 +02:00
yuri
c49bcc29db logo changes 2015-03-19 16:21:45 +02:00
yuri
3e74fb49ac contact list layout 2015-03-19 15:43:51 +02:00
Taras Machyshyn
cf885cafb4 Upgrade improvements 2015-03-19 15:38:20 +02:00
yuri
7a7c605687 fix frontend/index.php 2015-03-19 15:35:38 +02:00
yuri
5676d42801 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-19 15:02:45 +02:00
Taras Machyshyn
c893a4441d Added a file to Gruntfile.js 2015-03-19 15:01:36 +02:00
yuri
c5e1d0847f Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-19 14:13:19 +02:00
Taras Machyshyn
f0b4c2dc79 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-19 13:49:41 +02:00
Taras Machyshyn
1584f25af5 Fixed a bug with the upgrade 2015-03-19 13:49:25 +02:00
yuri
761e7b2344 detaul buttons changes 2015-03-19 12:58:36 +02:00
yuri
7099c92c39 fixes with el 2015-03-19 12:44:23 +02:00
yuri
be26ec2651 inline edit disanled option 2015-03-19 11:49:08 +02:00
yuri
7a2f49ad43 list fixes 2015-03-19 10:54:25 +02:00
yuri
22477385f7 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-18 18:18:20 +02:00
yuri
e7ae0862ba menu title 2015-03-18 18:18:10 +02:00
yuri
f501a7377d navbar changes 2015-03-18 18:16:19 +02:00
yuri
9ce9ccdb5c update bootstrap 2015-03-18 17:37:46 +02:00
yuri
f8a425b7d1 fix select all 2015-03-18 17:37:23 +02:00
yuri
8ab92f8668 navbar changes 2015-03-18 17:30:56 +02:00
Taras Machyshyn
e598665242 Added upgrade.php script to upgrade EspoCRM via CLI 2015-03-18 17:22:07 +02:00
yuri
1bc984f8fa fix select all icon 2015-03-18 17:18:24 +02:00
Taras Machyshyn
3a0b1a22f0 Improved logging when permission denied for a log file 2015-03-18 17:09:47 +02:00
Taras Machyshyn
8fd41d5ea7 Bug fixes 2015-03-18 17:00:58 +02:00
yuri
787adc72a5 changes in calls/mettings dashlets 2015-03-18 16:52:43 +02:00
yuri
a99b043d95 add bool filter to cases 2015-03-18 16:45:00 +02:00
yuri
2079c19dc0 add deferred status to tasks 2015-03-18 16:35:17 +02:00
yuri
9f9ba2c915 cases dashlet change 2015-03-18 16:35:06 +02:00
yuri
31db584658 change task dashlet 2015-03-18 16:13:54 +02:00
yuri
a09c7db717 fix array field json 2015-03-18 15:44:48 +02:00
yuri
19bd38bb85 array field cursor 2015-03-18 12:22:41 +02:00
yuri
7e678a8378 opportunity account not required 2015-03-18 12:14:02 +02:00
yuri
93c5d7eb91 fix options view helper 2015-03-18 11:51:12 +02:00
yuri
a9fcf5d510 Merge branch 'hotfix/3.0.2' 2015-03-18 11:40:36 +02:00
yuri
6f1266dcea Merge branch 'hotfix/3.0.2' of ssh://172.20.0.1/var/git/espo/backend into hotfix/3.0.2 2015-03-18 11:40:25 +02:00
yuri
2395fb6986 change version 2015-03-18 11:40:05 +02:00
yuri
48a0fa5e96 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-18 10:52:02 +02:00
yuri
95a0f78fa7 array field param noEmprtString 2015-03-18 10:51:51 +02:00
yuri
85f18fe338 change default dashboard tab 2015-03-18 10:38:02 +02:00
yuri
cbfad8eb79 dashboard changes 2015-03-18 10:37:22 +02:00
Taras Machyshyn
5cd4a92049 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-17 18:04:53 +02:00
Taras Machyshyn
e5b4de1683 Jobs: added attempts for jobs 2015-03-17 18:04:40 +02:00
yuri
cdd07a9f44 dashboard tabs 2015-03-17 17:54:42 +02:00
yuri
121eaabe40 fix quick view modal 2015-03-17 14:53:57 +02:00
yuri
f559c512fd change info color 2015-03-17 11:54:21 +02:00
yuri
9aa5ed63d0 bool filters labels 2015-03-17 11:53:12 +02:00
yuri
fa9c0e5b3b fix query in empty array 2015-03-17 11:39:47 +02:00
yuri
469c6f3b45 email-to-lead fix 2015-03-17 11:05:21 +02:00
yuri
e23e013432 Lead Create for campaign 2015-03-17 10:45:51 +02:00
yuri
e051ef4935 email fixes 2015-03-16 19:04:58 +02:00
yuri
2a4e816448 fix email from 2015-03-16 18:09:11 +02:00
yuri
4095530491 clearnup 2015-03-16 17:26:55 +02:00
yuri
5a40507b54 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-16 17:26:06 +02:00
yuri
f438b0898b email to lead and fucking fixes 2015-03-16 17:25:53 +02:00
Taras Machyshyn
58cfeeb1be Removed unnecessary debug message 2015-03-16 15:51:43 +02:00
yuri
6dbd521501 fix email and phone fields 2015-03-16 14:40:57 +02:00
yuri
541cb13ec3 view helper fix 2 2015-03-16 13:42:33 +02:00
yuri
e7fbcbbac6 view helper fix 2015-03-16 13:36:52 +02:00
yuri
7bc3d8a826 show from name in email 2015-03-16 13:13:07 +02:00
yuri
a814a95c9a list row dropdown css change 2015-03-16 13:04:26 +02:00
yuri
e95a40f24d quick view 2015-03-16 12:43:57 +02:00
yuri
b5972da08e autocomplete fix for assignmentPermission 2015-03-16 11:47:03 +02:00
yuri
9f488c5539 fix text field 2015-03-16 11:15:19 +02:00
yuri
aeea86155c fix email record list 2015-03-16 10:25:10 +02:00
yuri
843ca2a7c5 fix email address primary pdo quote 2015-03-13 15:32:04 +02:00
yuri
bbb67856c0 Merge branch 'master' of https://github.com/espocrm/espocrm 2015-03-13 15:27:40 +02:00
Yuri Kuznetsov
1100e82364 Merge pull request #38 from Threxxy/patch-1
INSERTing number fix for PhoneNumber.php
2015-03-13 15:27:28 +02:00
Pete
7dfafaee22 INSERTing number fix for PhoneNumber.php
Adding a new phone number to a contact was giving the error: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'primary' at row 1

Cast the boolean to an int and it appears to be fixed.
2015-03-13 13:08:41 +00:00
yuri
cd1aab0b1e cleanup 2015-03-13 13:52:00 +02:00
yuri
fa9c2806ca mass actions 2015-03-13 13:49:22 +02:00
yuri
736a53c8d0 calendar changes 2015-03-12 17:11:56 +02:00
yuri
0b713be508 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-03-12 16:24:21 +02:00
yuri
715b290174 task date 2015-03-12 16:24:07 +02:00
yuri
54d241d247 fix notice 2015-03-12 10:28:52 +02:00
yuri
bf8f9023e2 fix task panel filter 2015-03-12 10:15:44 +02:00
Taras Machyshyn
f57c81efe4 correction ru_RU translation 2015-03-11 16:44:57 +02:00
Taras Machyshyn
6d12cf44b4 fixed problem with espocrm news for https connections 2015-03-11 16:35:23 +02:00
yuri
4e76855a12 cleanup 2015-03-11 16:16:35 +02:00
yuri
724b2adbbd fix calendar date-end 2015-03-11 16:09:08 +02:00
yuri
c95031912a calendar-page 2015-03-11 12:59:31 +02:00
yuri
4f7c6dacee assignment permission 3 2015-03-11 12:34:12 +02:00
yuri
716e434099 assignmentPermission 2 2015-03-11 12:15:51 +02:00
yuri
f1f566d56f readOnly fix 2015-03-11 11:52:39 +02:00
yuri
4cf1b8dbda assignmentPermission 1 2015-03-10 16:49:43 +02:00
yuri
87ce26f3cd fix default jobs scheduling value 2015-03-10 16:24:53 +02:00
yuri
94c157df7a fix user side 2015-03-10 15:55:23 +02:00
yuri
d13ccb8dc7 reset model if status = 400 and not new 2015-03-10 15:53:10 +02:00
yuri
b73d82ba00 cancel prev 2015-03-10 15:49:19 +02:00
yuri
afdeeeffa7 reset model if bad request 2015-03-10 15:45:21 +02:00
yuri
16cd135cb7 fixes in oauth2 client 2015-03-10 10:14:52 +02:00
yuri
0c6df91604 email draft 2015-03-09 17:06:26 +02:00
yuri
58a6ced886 fix unread 2015-03-09 16:23:11 +02:00
yuri
d0d3f39f5d email signature 2015-03-09 15:48:13 +02:00
yuri
82a96c743c email/phone paste fix 2015-03-09 12:19:26 +02:00
yuri
a18453c3af play notification sound only onnce 2015-03-09 11:47:25 +02:00
yuri
a75dc61748 mettings held action 2015-03-09 11:23:05 +02:00
yuri
0a60663548 documents for opp 2015-03-09 11:16:30 +02:00
yuri
53cac1c299 convert lead: emails 2015-03-09 11:14:12 +02:00
yuri
4d624aa6d1 campaign log error Espo 2015-03-09 11:06:50 +02:00
yuri
ca807c7ec8 Merge branch 'feature/campaign' 2015-03-06 18:11:02 +02:00
yuri
f245b30d90 fix presets 2015-03-06 18:10:40 +02:00
yuri
0cfb29ad6d cleanup 2015-03-06 17:19:49 +02:00
yuri
27ed23cb51 email improvements 2015-03-06 17:18:45 +02:00
Taras Machyshyn
1794042cea fix bug into CronManager 2015-03-06 16:55:23 +02:00
yuri
6657078a89 email personStringData field 2015-03-06 12:16:02 +02:00
yuri
a156e869fc if email duplicat then add user/team 2015-03-06 11:13:42 +02:00
yuri
06ffe9d373 fix ORM Query 2015-03-05 18:38:42 +02:00
yuri
817fc2fd40 fix ORM Query 2015-03-05 18:36:07 +02:00
yuri
2ec4464a52 dev 2015-03-05 15:12:55 +02:00
yuri
e79874c039 Merge branch 'master' into feature/campaign 2015-03-05 13:07:07 +02:00
yuri
72b9d77e44 changes in side panels 2015-03-05 13:06:08 +02:00
yuri
c622b976de side panel action refresh 2015-03-05 12:27:17 +02:00
yuri
4e0d570f90 dev 2015-03-05 12:26:11 +02:00
yuri
ffce8cb0f7 Merge branch 'master' into feature/campaign 2015-03-05 11:34:19 +02:00
yuri
6dd2e365ad fix currency notStorable 2015-03-05 11:34:11 +02:00
yuri
c324729cdf Merge branch 'master' into feature/campaign 2015-03-05 11:16:23 +02:00
yuri
5b3eee299c fix currency joins 2015-03-05 11:16:11 +02:00
yuri
2ff6946b91 dev 2015-03-05 11:14:02 +02:00
yuri
c3a44a413a add types for inline download 2015-03-04 16:43:04 +02:00
yuri
a4050b1476 Merge branch 'master' into feature/campaign 2015-03-04 14:52:50 +02:00
yuri
2da6d68fe3 fix email preview 2015-03-04 14:50:08 +02:00
yuri
ed19b9d328 check isPost in User change own password 2015-03-04 12:26:09 +02:00
yuri
f41e4f2df4 Merge branch 'master' into feature/campaign 2015-03-04 12:15:32 +02:00
yuri
410bd7f177 fix panel tpls 2015-03-04 12:15:17 +02:00
yuri
caa659020e dev 2015-03-04 12:13:47 +02:00
yuri
877820f5f5 merge with master 2015-03-04 11:47:55 +02:00
yuri
18c6847481 email preview in stream 2015-03-04 11:27:04 +02:00
yuri
274c043f44 improve action events 2015-03-04 11:15:34 +02:00
yuri
529d8c1100 changes in relationship panel 2015-03-04 11:03:32 +02:00
yuri
c05c169948 disable ability to remove ow user 2015-03-04 10:31:44 +02:00
yuri
99db3f5416 fix email attachmentsField handle 2015-03-04 10:29:58 +02:00
yuri
1fa976a43c fix email acl real 2015-03-04 10:24:47 +02:00
yuri
32198144cc add document to tablist 2015-03-04 10:08:26 +02:00
yuri
29420a5306 attendeess panels 2015-03-04 10:06:57 +02:00
yuri
67f6f9b250 Merge branch 'master' into feature/campaign 2015-03-04 09:52:46 +02:00
yuri
c2bbc2e61e showModal action 2015-03-04 09:52:31 +02:00
yuri
2d74cddf86 Merge branch 'master' into feature/campaign 2015-03-03 18:01:45 +02:00
yuri
53049cf1f4 merge layout improve 2015-03-03 17:36:43 +02:00
yuri
6aa012891d dev 2015-03-03 17:26:00 +02:00
yuri
5a7f3ed101 dev 2015-03-03 15:58:17 +02:00
yuri
131743e702 Merge branch 'master' into feature/campaign 2015-03-03 15:51:51 +02:00
yuri
b5cde9a157 fix view-helper 2015-03-03 15:51:40 +02:00
yuri
b150aad977 dev 2015-03-03 15:45:20 +02:00
yuri
75d220e74d dev 2015-03-03 13:38:15 +02:00
Taras Machyshyn
39a3d215d6 Improved set owner, group permissions 2015-03-03 12:42:02 +02:00
yuri
8fe87ccd04 Merge branch 'master' into feature/campaign 2015-03-03 12:32:55 +02:00
yuri
621a2ffbbf add Views.Record.RowActions.Empty 2015-03-03 12:32:19 +02:00
yuri
0f582c59ab dev 2015-03-03 12:31:10 +02:00
yuri
ce18f41400 Merge branch 'master' into feature/campaign 2015-03-03 12:25:31 +02:00
yuri
d780847232 relationship-remove-only 2015-03-03 12:25:15 +02:00
yuri
c074423f0b campaign dev 2015-03-03 12:24:18 +02:00
yuri
31cb2fed88 Merge branch 'master' into feature/campaign 2015-03-03 11:24:26 +02:00
yuri
225f407545 cleanup 2015-03-03 11:23:19 +02:00
yuri
f10dd19446 campaign 2015-03-03 11:20:56 +02:00
yuri
78d5547e08 Merge branch 'hotfix/3.0.2' 2015-03-03 11:00:32 +02:00
yuri
af08f23ca1 de_DE changes 2015-03-03 11:00:19 +02:00
yuri
99d2f14008 campaign dev 2015-03-02 17:52:23 +02:00
yuri
a90a2b859d Merge branch 'master' into feature/campaign 2015-03-02 13:26:26 +02:00
yuri
b0edae1eae Merge branch 'hotfix/3.0.2' 2015-03-02 13:25:56 +02:00
yuri
a5d923c4e3 add ms. to salutation 2015-03-02 13:25:17 +02:00
yuri
86e118341e Merge branch 'master' into feature/campaign 2015-03-02 12:56:06 +02:00
yuri
ed152c9d4c Merge branch 'hotfix/3.0.2' 2015-03-02 12:55:53 +02:00
yuri
8fa805f5eb fix person name salutation 2015-03-02 12:55:35 +02:00
yuri
16ce5385f4 campaign dev 2015-03-02 12:24:57 +02:00
yuri
d1fe581706 Merge branch 'master' into feature/campaign 2015-03-02 12:02:55 +02:00
yuri
dc651b5d77 refactor detail-bottom 2015-03-02 12:02:34 +02:00
yuri
be3dabe5a7 campaign dev 2015-03-02 11:55:43 +02:00
yuri
21326ec3b5 Merge branch 'master' into feature/campaign 2015-03-02 10:25:38 +02:00
yuri
8b851463bc change container padding 2015-02-27 17:32:42 +02:00
yuri
d4a3eb1026 change target list layout 2015-02-27 17:18:24 +02:00
yuri
0980120184 fix taget list service 2015-02-27 15:49:48 +02:00
yuri
db275028d1 Merge branch 'master' into feature/campaign 2015-02-27 15:49:33 +02:00
yuri
f78004b9d3 fix loadAddition 2015-02-27 15:47:30 +02:00
yuri
bac0227675 Merge branch 'master' into feature/campaign 2015-02-27 15:44:59 +02:00
yuri
9f84faa776 fix loadAdditionalFieldsForList 2015-02-27 15:44:28 +02:00
yuri
639c52d1d6 fix relation 2015-02-27 15:36:46 +02:00
yuri
811db09a1d calculate entryCount 2015-02-27 15:24:27 +02:00
yuri
9c61e03542 Merge branch 'master' into feature/campaign 2015-02-27 15:24:11 +02:00
yuri
3e4e86bd5a refactor Record 2015-02-27 15:15:03 +02:00
yuri
5acf253a98 campaign 2015-02-27 15:10:06 +02:00
yuri
84cfcd4352 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-27 12:28:02 +02:00
Taras Machyshyn
73f3673a11 Improved unique indexes for relationship tables 2015-02-27 12:27:37 +02:00
yuri
2c18f75152 Merge branch 'master' into feature/campaign 2015-02-27 12:25:39 +02:00
yuri
3601ee35bd change layouts 2015-02-27 12:25:28 +02:00
yuri
76379f49be Merge branch 'master' into feature/campaign 2015-02-27 12:21:47 +02:00
yuri
1f1fc9111f change lead list layout 2015-02-27 12:21:33 +02:00
yuri
334bd55ad6 Merge branch 'master' into feature/campaign 2015-02-27 12:20:44 +02:00
yuri
2f9f0964ed change contact list layouts 2015-02-27 12:20:28 +02:00
yuri
b5b04f85d0 Merge branch 'master' into feature/campaign 2015-02-27 12:14:50 +02:00
yuri
554f5de0af fix createLink 2015-02-27 12:14:36 +02:00
yuri
5f528c9f6f Merge branch 'master' into feature/campaign 2015-02-27 12:10:28 +02:00
yuri
64b98a7a3c mass relate 3 2015-02-27 12:10:16 +02:00
yuri
74c9d5a8e6 fix email address and phone number repository 2015-02-27 12:02:28 +02:00
yuri
ff2ca7f18c mass relate dev 2 2015-02-26 17:14:44 +02:00
yuri
a0203d3310 fix search manager 2015-02-26 16:05:57 +02:00
yuri
bddd55213f merge with hotfix 2015-02-26 15:55:00 +02:00
yuri
fa97c0ede4 fix selectRElated filters copied 2015-02-26 15:50:41 +02:00
yuri
1dbfe36d1e select all dev 2015-02-26 15:48:11 +02:00
yuri
ec898f297a Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-26 14:49:00 +02:00
Taras Machyshyn
67049d2f08 DBAL: added an unique index for midKeys of manyMany relationship table 2015-02-26 14:42:14 +02:00
yuri
a2c7f84907 ORM: massRelate 2015-02-26 13:24:32 +02:00
yuri
338ba010a2 fix relationship 2015-02-26 11:52:27 +02:00
yuri
a9737e8352 Merge branch 'master' into feature/campaign 2015-02-26 11:23:01 +02:00
yuri
fb8a4b90ca maxEmailAccountCount 2015-02-26 11:16:57 +02:00
yuri
6876bd9a6d cleanup 2015-02-25 15:16:25 +02:00
yuri
392f107de1 emails: dont show attachments if there are no 2015-02-25 14:57:58 +02:00
yuri
17ab2cc717 fix quickDetail 2015-02-25 13:42:01 +02:00
yuri
abddb6c686 change email history layout 2015-02-25 13:21:08 +02:00
yuri
0a5ec4b81c cleanup and backdrop for quickDetail 2015-02-25 13:14:50 +02:00
yuri
ddba654f00 quickDetail and fixes in list expanded 2015-02-25 13:08:32 +02:00
yuri
27a5833b36 change text field detailMaxNewLineCount 2015-02-25 11:11:09 +02:00
yuri
c4cc29b452 remove contract php files 2015-02-25 10:22:20 +02:00
yuri
ac56846e1b trim person name, phone and email 2015-02-25 10:21:04 +02:00
yuri
efb7592782 fix typo 2015-02-25 10:15:00 +02:00
yuri
6c40c5a20c improve emails notes 2015-02-25 10:13:34 +02:00
yuri
724c79d089 fix sentEmail note in case 2015-02-24 18:36:47 +02:00
yuri
7148cb232b improve wysiwyg field 2015-02-24 17:52:02 +02:00
yuri
9943d1794b fix iframe resize 2015-02-24 17:06:57 +02:00
yuri
972615c8e6 Added Campaigns and Target Lists 2015-02-24 15:57:34 +02:00
yuri
213546b83f enable multi-enum filter 2015-02-23 17:29:09 +02:00
yuri
e23345edc6 use getEntityType 2015-02-23 17:09:15 +02:00
yuri
7af38e8d21 fix leads detail-side 2015-02-23 17:05:15 +02:00
yuri
b1e62ecb20 add getEntityType into entity 2015-02-23 17:05:00 +02:00
yuri
f05e3924ff fix mass-update layouy and leads side panel 2015-02-23 16:54:06 +02:00
yuri
2ccb9c3a17 noJoin links 2015-02-23 16:53:48 +02:00
yuri
c64d27f413 fix record list dashlet 2015-02-23 16:12:58 +02:00
yuri
2a3711d0b4 improve search manager 2015-02-23 16:05:15 +02:00
yuri
2baace4ef9 fix Zend issues 2015-02-23 15:30:45 +02:00
yuri
aa501a4429 fix my opportunities dashlet 2015-02-20 17:35:49 +02:00
yuri
3095f61011 change opportunity dashlet layout 2015-02-20 17:31:33 +02:00
yuri
001de70fe8 show only future calls and meetings in dashlet 2015-02-20 17:21:06 +02:00
yuri
58733450d1 steam status styles 2015-02-20 17:06:45 +02:00
yuri
0605672c32 cleanup 2015-02-20 16:33:49 +02:00
yuri
0c570b0d83 cleanup 2015-02-20 16:31:17 +02:00
yuri
0833428b71 no subject 2015-02-20 16:10:17 +02:00
yuri
4c4714a846 disabledCountQuery 2015-02-20 14:59:40 +02:00
yuri
155cd428f6 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-20 11:53:04 +02:00
yuri
06bde4f1ce move autoFollow to job 2015-02-20 11:51:31 +02:00
yuri
6112a9d02d job: pending jobs fix 2015-02-20 11:51:11 +02:00
yuri
a3f4beac61 autofill executeTime if notset 2015-02-20 11:50:25 +02:00
yuri
b116821731 cron: don't fail jobs if pending and expired 2015-02-20 10:46:46 +02:00
Taras Machyshyn
3439267926 merge changes 2015-02-19 17:12:31 +02:00
yuri
1ac55737b4 optimization 2015-02-19 16:07:18 +02:00
yuri
c66cfeb297 auto-follow 2015-02-19 15:28:49 +02:00
yuri
85f9fe6f3b fix link autocomplete 2015-02-19 13:44:10 +02:00
yuri
fe9154fde7 autocomplete off 2015-02-19 13:21:03 +02:00
yuri
bdc7bbada4 fix autocomplete off 2015-02-19 13:19:03 +02:00
yuri
9f4a203abe Merge branch 'hotfix/3.0.1' 2015-02-18 18:07:19 +02:00
yuri
a89872b785 3.0.1 2015-02-18 17:13:41 +02:00
yuri
b6bc0471b8 Merge branch 'hotfix/3.0.1' of ssh://172.20.0.1/var/git/espo/backend into hotfix/3.0.1 2015-02-18 17:05:02 +02:00
yuri
c38544e6ad refresh dashlet on header 2015-02-18 15:56:54 +02:00
yuri
6122edb091 cleanup 2015-02-18 15:13:36 +02:00
yuri
684441040c limitQuery 2015-02-18 15:10:30 +02:00
yuri
55c733b13a ability to to execute count query to know about out of range 2015-02-18 15:06:53 +02:00
yuri
dc7571d30c fix findMyQuery 2015-02-18 15:05:53 +02:00
yuri
699c1d1f23 ORM: findByQuery 2015-02-18 12:36:11 +02:00
yuri
f67fbbd621 calendar distinguish by status 2015-02-18 12:09:42 +02:00
yuri
dbcc7e61c1 calendar resize fix 2015-02-18 11:30:50 +02:00
Taras Machyshyn
afd0f5a5ef Extensions: don't run afterUninstall script for updating an extension 2015-02-18 09:53:53 +02:00
yuri
859f1f0cd9 ability to refresh calendar 2015-02-17 17:41:32 +02:00
yuri
3f8ccb69fc fix calendar shade color 2015-02-17 17:28:58 +02:00
yuri
ba65ccffe4 Merge branch 'hotfix/3.0.1' 2015-02-17 16:49:40 +02:00
yuri
533fff4d30 Merge branch 'hotfix/3.0.1' of ssh://172.20.0.1/var/git/espo/backend into hotfix/3.0.1 2015-02-17 16:49:03 +02:00
yuri
7b0b3d05ad fix zend mail 2015-02-17 16:46:13 +02:00
Taras Machyshyn
e09c101f82 Upgrades: fixed an error 2015-02-17 16:45:21 +02:00
yuri
c87c657b02 calendar shade past activities 2015-02-17 16:45:03 +02:00
Taras Machyshyn
4e6b300477 Upgrades: improved restore functionality 2015-02-17 16:39:51 +02:00
Taras Machyshyn
7453eb583a impoved Uprades code 2015-02-17 15:53:35 +02:00
Taras Machyshyn
b5d2eb93aa Upgrades: impoved beforeRunAction(), afterRunAction() 2015-02-17 15:53:27 +02:00
Taras Machyshyn
b5b8ab4a8e added initialize(), finalize() methods to upgrade scripts 2015-02-17 15:53:18 +02:00
Taras Machyshyn
b6010a7ad7 added a new fileManager test, fixes 2015-02-17 15:53:07 +02:00
Taras Machyshyn
ebdb649bd7 Improved upgrade/install extenions feature 2015-02-17 15:52:53 +02:00
Taras Machyshyn
ec17306992 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-17 15:50:36 +02:00
Taras Machyshyn
9b6bf4171b impoved Uprades code 2015-02-17 15:43:51 +02:00
yuri
252b5ef729 Merge branch 'hotfix/3.0.1' 2015-02-17 15:39:24 +02:00
yuri
220d4d1b77 improve importer 2015-02-17 15:21:47 +02:00
yuri
2f8e1aeaf2 fix field iframe wysiwyg height 2015-02-17 14:57:17 +02:00
Taras Machyshyn
ced41021f0 Upgrades: impoved beforeRunAction(), afterRunAction() 2015-02-17 13:46:37 +02:00
Taras Machyshyn
36e3cc4688 added initialize(), finalize() methods to upgrade scripts 2015-02-17 13:02:02 +02:00
yuri
20db3b0bd2 improve email quick-edit 2015-02-17 12:25:39 +02:00
Taras Machyshyn
0ab702726d added a new fileManager test, fixes 2015-02-17 12:03:55 +02:00
yuri
6d796c0b20 fix stream note header 2015-02-17 11:50:04 +02:00
yuri
100fec9409 increase notifications panel width 2015-02-17 11:15:54 +02:00
yuri
0b5beeba85 play sound when notification comes 2015-02-17 11:10:07 +02:00
Taras Machyshyn
dec5ab6a16 Improved upgrade/install extenions feature 2015-02-17 11:02:01 +02:00
yuri
909d31b9fe frontend: improve notification 2015-02-17 10:59:28 +02:00
yuri
d9522cf555 fix navbar resize 2015-02-17 10:39:01 +02:00
yuri
e42a877bf6 try catch for importing emails 2015-02-17 10:36:44 +02:00
yuri
68cbadda4c improve header menu 2015-02-16 16:00:51 +02:00
yuri
8beeb64cbf log checkemail errors 2015-02-16 14:56:28 +02:00
yuri
da3a18e766 Duplicate email check by messageId instead of messageIdInternal 2015-02-16 12:43:57 +02:00
yuri
ffb94b960d fix entity manager 2015-02-13 16:24:31 +02:00
yuri
f73ac0779b restoreDate and afterSave 2015-02-13 12:30:36 +02:00
yuri
8003af682e email account create fix 2015-02-12 18:32:37 +02:00
yuri
cbf7bf18f2 fix preferences saving 2015-02-12 17:54:22 +02:00
yuri
ceaa0a8322 refresh email list view after send 2015-02-12 16:49:53 +02:00
yuri
8ca410d994 fix calendar 2015-02-12 16:44:12 +02:00
yuri
5fc7f2509d fix app.js 2015-02-12 16:08:15 +02:00
yuri
f2e1ba3780 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-11 15:53:49 +02:00
yuri
93ac871640 change year 2015-02-11 15:53:39 +02:00
Taras Machyshyn
187a8a02a1 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-11 12:44:18 +02:00
Taras Machyshyn
bcf5686eec fixed getModuleList() 2015-02-11 12:44:05 +02:00
yuri
027507b61e display task in top bar in calendar 2015-02-11 11:59:15 +02:00
yuri
49b3d17952 change default filters 2015-02-11 11:27:00 +02:00
yuri
e0958cfeec improve notifications 2015-02-11 11:00:43 +02:00
Taras Machyshyn
00e12b50b7 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-10 15:02:17 +02:00
Taras Machyshyn
44b8b00106 fixed calendar issue in IE 2015-02-10 15:02:02 +02:00
yuri
e0855e3092 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-10 13:24:10 +02:00
yuri
cb0d70430a ability to remove stream records for admin 2015-02-10 13:22:58 +02:00
Taras Machyshyn
042575ce6b improved 'fieldManager' 2015-02-10 12:46:19 +02:00
yuri
5cd18b57d2 industry list update 2015-02-10 12:25:14 +02:00
yuri
d1e46e3d9a fix field manager 2015-02-10 11:56:13 +02:00
yuri
1a3348f2c2 change user entityDefs links 2015-02-10 11:41:58 +02:00
yuri
75edc5c165 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-10 11:30:17 +02:00
yuri
60184ebbbe ability to disable fields and link for layout manager 2015-02-10 11:30:05 +02:00
yuri
ddb6cb7483 Clear link-multiple field input if not selected 2015-02-10 10:32:45 +02:00
Taras Machyshyn
2ddd44a2fe Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-09 17:11:08 +02:00
Taras Machyshyn
ce55866445 added check 'php' version for extension/upgrade packages 2015-02-09 17:10:46 +02:00
Taras Machyshyn
2bc7f85a58 added getPhpVersion() 2015-02-09 17:07:06 +02:00
yuri
a27df2c41f Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-09 13:01:36 +02:00
yuri
170581dd28 fetched values for linkMultiple fields 2015-02-09 13:01:18 +02:00
Taras Machyshyn
00b0c904ae fixed warnings 2015-02-09 12:14:27 +02:00
yuri
fdab17265f change version 2015-02-09 12:12:27 +02:00
Taras Machyshyn
96d0a7db00 bug fixes 2015-02-09 11:32:39 +02:00
Taras Machyshyn
2835928ac0 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-06 17:37:32 +02:00
Taras Machyshyn
4c22b42b99 fixed cache bug for Extensions 2015-02-06 17:37:11 +02:00
yuri
64ddaa40a8 add reminder time 2015-02-06 16:17:04 +02:00
yuri
bc7006e193 open url field in new pahe 2015-02-06 15:51:45 +02:00
yuri
1ae0a9df28 inline download: add types 2015-02-06 15:05:56 +02:00
yuri
a4f9280eba cleanup 2015-02-06 13:23:36 +02:00
yuri
2528fc34c8 Enable User tab 2015-02-06 13:16:41 +02:00
yuri
979f07bf9b Merge improvements 2 2015-02-06 12:19:13 +02:00
yuri
52bff4de1c fix service factory 2015-02-06 12:16:31 +02:00
Taras Machyshyn
4c017361f8 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-06 11:38:41 +02:00
Taras Machyshyn
84aa1339d9 fixed a bug with php reserved names for classes 2015-02-06 11:38:26 +02:00
yuri
987cd4a121 Import Email: fix issue with text and html attachments 2015-02-06 11:38:20 +02:00
yuri
e50ad5106f Load user data each time app starts 2015-02-06 10:47:34 +02:00
yuri
071cbcb0fb cleanup 2015-02-06 10:47:18 +02:00
yuri
43f1cb9af9 Field Manager:Reload metadata when field is saved 2015-02-06 10:46:50 +02:00
yuri
220c55e9b4 fix entity manager 2015-02-06 10:02:14 +02:00
yuri
927610efb0 clearnup 2015-02-06 09:55:30 +02:00
yuri
78fcaf1fa3 update handlebars 2015-02-06 09:39:55 +02:00
yuri
3bd9af031d cleanup 2015-02-05 19:05:06 +02:00
yuri
16ee3d68e8 merge changes 1 2015-02-05 18:13:08 +02:00
yuri
d49ee3c187 fix select and create 2015-02-05 16:31:39 +02:00
Taras Machyshyn
2e544f1ccf Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-05 15:05:08 +02:00
Taras Machyshyn
1c51125e66 changed 'acceptedVersions' identifier to semantic versioner 2015-02-05 15:04:51 +02:00
yuri
1ed47f5d0d fix navbar update width 2015-02-05 13:35:47 +02:00
yuri
133fa0cb36 note order 2015-02-05 12:53:44 +02:00
yuri
295904bf4c change admin tpl 2015-02-05 11:59:32 +02:00
yuri
951230f7e1 change admin tpl 2015-02-05 11:57:24 +02:00
yuri
ee58886206 fix imap encoding issue 2015-02-05 11:56:52 +02:00
yuri
41575f6f13 add industry 2015-02-05 11:22:36 +02:00
yuri
18ae33d417 send password only to active users 2015-02-05 11:16:22 +02:00
yuri
36daf5a762 iframe 2015-02-05 11:01:55 +02:00
yuri
8a41a2cd05 change calls/meetings dashlet order 2015-02-05 10:24:01 +02:00
yuri
61497d2a01 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-04 17:07:00 +02:00
yuri
a3045a88f3 Inbound Email improve 2015-02-04 17:06:50 +02:00
Taras Machyshyn
fd072520a9 fixed tests 2015-02-04 17:01:01 +02:00
yuri
6ef9d8428f improve js actions 2015-02-03 16:15:39 +02:00
yuri
33a7176165 blockquote 2015-02-03 15:53:52 +02:00
yuri
044de7d744 stream info 2015-02-03 13:15:14 +02:00
yuri
801ba05cd8 afterDelete beforeDelete 2015-02-03 12:45:54 +02:00
yuri
0dc5a4e4f3 after/before Create/Update in Record service 2015-02-03 12:43:56 +02:00
yuri
230ed63e67 getEntityBeforeUpdate 2015-02-03 12:38:10 +02:00
yuri
7316866a1a Merge branch 'hotfix/2.9.3' 2015-02-03 12:36:44 +02:00
yuri
c7be54d9c9 fix textcomplete 2 2015-02-03 12:36:26 +02:00
yuri
dcc118ec5d Merge branch 'hotfix/2.9.3' 2015-02-03 12:18:14 +02:00
yuri
84e98054b7 fix textcomplete 2015-02-03 12:17:39 +02:00
yuri
f37308f5a5 lead source changes 2015-02-03 11:58:54 +02:00
yuri
9688b3be3c clearnup 2015-02-02 18:09:41 +02:00
yuri
6490a1ca97 cleanup 2015-02-02 17:19:55 +02:00
yuri
c15fc89f52 refresh panel 2015-02-02 15:35:35 +02:00
yuri
9207030ccb row actions change to avoid user removing 2015-02-02 15:00:27 +02:00
yuri
018eb44de6 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-02 12:49:46 +02:00
yuri
bc92b96a6b user isActive 2 2015-02-02 12:49:37 +02:00
yuri
ee57c9223c User:isActive 2015-02-02 12:22:37 +02:00
Taras Machyshyn
f799ffc61f Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-02-02 12:10:21 +02:00
Taras Machyshyn
bdb1f2f3b6 improved Util::merge() functionality 2015-02-02 12:10:04 +02:00
yuri
fd755df67b Merge branch 'hotfix/2.9.3' 2015-02-02 11:21:14 +02:00
yuri
e9edd01d08 modified date and id for remove 2015-02-02 11:21:00 +02:00
yuri
dea7e0b33e modified date and id for remove 2015-02-02 11:20:28 +02:00
yuri
25b50baa1a showPanel/hidePanel 2015-01-30 16:09:43 +02:00
yuri
8a53657b9c text search by email address 2015-01-30 15:51:47 +02:00
yuri
c6ecbf4942 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-01-30 14:55:51 +02:00
yuri
56d11807a1 access check in select managers change 2015-01-30 14:52:34 +02:00
yuri
cf3b4b284a record.base 2015-01-30 14:47:14 +02:00
yuri
953a59cb57 no create for users and teams in subpanels 2015-01-30 13:13:38 +02:00
yuri
f60061a387 Merge branch 'hotfix/2.9.3' 2015-01-30 12:54:00 +02:00
yuri
c627d84273 cleanup 2015-01-30 12:53:52 +02:00
Taras Machyshyn
5a16ee0493 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-01-29 17:11:28 +02:00
Taras Machyshyn
14252d6e9e FileManager: improved 'remove()' functionality 2015-01-29 17:11:16 +02:00
yuri
c0de3e1c4e Merge branch 'stable' 2015-01-29 13:00:11 +02:00
yuri
e0c3530ae5 change version 2015-01-29 12:34:13 +02:00
yuri
8b4070f9ae Merge branch 'hotfix/2.9.2' 2015-01-29 12:14:13 +02:00
yuri
0b6c5c2862 Merge branch 'hotfix/2.9.2' of ssh://172.20.0.1/var/git/espo/backend into hotfix/2.9.2 2015-01-29 12:13:54 +02:00
yuri
ce9ff10cb0 fix imap 2015-01-29 12:03:43 +02:00
Taras Machyshyn
de688bfa12 CronManager minor changes 2015-01-29 11:44:47 +02:00
yuri
f4ef5fc36f add tentative event status 2015-01-28 17:04:45 +02:00
yuri
b1e184c6d1 link manager dev 2015-01-28 16:38:27 +02:00
yuri
fbf665fd76 Merge branch 'hotfix/2.9.2' 2015-01-28 10:39:14 +02:00
yuri
95fd66a7a6 Entity::isSaved 2015-01-28 10:38:57 +02:00
yuri
4b98ea79e0 change link manager edit modal 2015-01-28 10:19:17 +02:00
yuri
2e916a2ba8 Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend 2015-01-27 17:31:13 +02:00
yuri
26a4d1c6ff link manager dev 2015-01-27 17:31:00 +02:00
Taras Machyshyn
33fef4c90e Merge branch 'hotfix/2.9.2' 2015-01-27 17:19:18 +02:00
yuri
2dc15294fc Merge branch 'hotfix/2.9.2' 2015-01-27 16:30:26 +02:00
yuri
171df33736 move logic to Repository::afterSave 2015-01-27 16:27:05 +02:00
yuri
9b846b45bc link manager dev 2015-01-27 16:21:22 +02:00
yuri
bc65975f74 fix in default config 2015-01-27 11:53:55 +02:00
yuri
a5308831f2 Merge branch 'hotfix/2.9.2' 2015-01-27 11:42:17 +02:00
yuri
ef05e4e9f4 add cryptKey to systemItems 2015-01-27 11:40:51 +02:00
yuri
83f0a81eb7 add global Search Entity List param 2015-01-27 11:21:06 +02:00
yuri
9e28d4a261 change meetings and calls dashlets layouts 2015-01-27 10:30:48 +02:00
yuri
a9b3320302 Merge branch 'hotfix/2.9.2' 2015-01-26 17:36:21 +02:00
yuri
b67580ee1d Merge branch 'hotfix/2.9.2' of ssh://172.20.0.1/var/git/espo/backend into hotfix/2.9.2 2015-01-26 17:36:06 +02:00
yuri
884ccb5265 Select Managers changes and Email changes 2015-01-26 17:35:43 +02:00
Taras Machyshyn
ac56c3f79e added 'Cleanup' job 2015-01-26 15:24:10 +02:00
Taras Machyshyn
e218056683 Cron job improvements 2015-01-26 12:28:00 +02:00
yuri
838288a463 Merge branch 'hotfix/2.9.2' 2015-01-26 12:11:30 +02:00
yuri
e74b90d048 fix email notFound 2015-01-26 11:12:25 +02:00
yuri
b2a653a3dc fix App controller 2015-01-26 11:09:54 +02:00
yuri
48ee7d4cc7 Merge branch 'hotfix/2.9.2' of ssh://172.20.0.1/var/git/espo/backend into hotfix/2.9.2 2015-01-23 18:19:25 +02:00
yuri
1d38f80748 improve email accounts 2015-01-23 18:19:02 +02:00
Taras Machyshyn
c712366737 cron jobs improvements and fixes 2015-01-23 17:44:59 +02:00
yuri
71f40fd440 checlemailaccounts job 2015-01-23 17:12:12 +02:00
yuri
9049ebfa8c fix email importer 2015-01-23 17:05:33 +02:00
yuri
f4b9356173 em dev 2015-01-22 15:55:11 +02:00
yuri
beaa4a29ba Merge branch 'hotfix/2.9.1' 2015-01-22 15:32:36 +02:00
yuri
632ee66155 Merge branch 'hotfix/2.9.1' of ssh://172.20.0.1/var/git/espo/backend into hotfix/2.9.1 2015-01-22 15:14:25 +02:00
yuri
4446bc3167 fix oauth client 2015-01-22 15:14:16 +02:00
Taras Machyshyn
785934c7cc Language: chnaged set(), delete() methods 2015-01-22 14:49:40 +02:00
Taras Machyshyn
ac36096d55 Merge branch 'hotfix/2.9.1' of ssh://172.20.0.1/var/git/espo/backend into hotfix/2.9.1 2015-01-22 13:15:15 +02:00
Taras Machyshyn
8ec8cb3c56 Metadata: fixed description 2015-01-22 13:14:55 +02:00
Taras Machyshyn
1f7cb2402d changed Metadata methods set(), get(), added save() 2015-01-22 13:14:06 +02:00
yuri
987ba2faa5 EM dev 2015-01-22 12:10:53 +02:00
yuri
a24f697dca Merge branch 'hotfix/2.9.1' 2015-01-22 11:41:42 +02:00
yuri
3825893ec1 integrations changes 2015-01-22 11:28:17 +02:00
yuri
a4ed78b953 change version 2015-01-21 17:22:08 +02:00
yuri
c7947d0c46 Merge branch 'hotfix/2.9.1' 2015-01-21 17:13:48 +02:00
yuri
eed9059913 integration changes 2015-01-21 17:11:12 +02:00
yuri
20a1053413 fix select manager 2015-01-21 15:50:41 +02:00
yuri
16aca57f17 em deb 2015-01-21 15:30:02 +02:00
yuri
a225748840 make documents customizable 2015-01-21 15:19:06 +02:00
yuri
fff1be9d07 entity manager dev 2015-01-21 15:13:37 +02:00
yuri
b73ca3f1bc change accountInfo messages 2015-01-20 18:14:48 +02:00
yuri
93a4f999b6 entity manager 2 2015-01-20 18:01:05 +02:00
yuri
3030643ce4 entity manager 1 2015-01-20 16:40:04 +02:00
Taras Machyshyn
e814ea9ec6 added 'save()' method to Layout 2015-01-20 15:34:29 +02:00
Taras Machyshyn
de16e9a9ce added '2015' to 'About' page 2015-01-20 12:36:52 +02:00
Taras Machyshyn
62fba991e2 fixed pt_BR translation syntax errors 2015-01-20 12:31:46 +02:00
Taras Machyshyn
832c63e014 added 'getPhpContents()' to FileManager 2015-01-20 12:22:04 +02:00
yuri
46913c3574 cleanup 2015-01-20 10:55:04 +02:00
yuri
0194d364b8 change opportunity list small layout 2015-01-19 15:09:30 +02:00
yuri
1c7785f6ba fix salutation list 2015-01-19 10:41:45 +02:00
1031 changed files with 37267 additions and 12118 deletions

2
.gitignore vendored
View File

@@ -13,4 +13,4 @@
/tests/testData/cache/*
composer.phar
vendor/
/custom/Espo/Custom/Resources/*
/custom/Espo/Custom/*

View File

@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
module.exports = function (grunt) {
var jsFilesToMinify = [
@@ -65,10 +65,10 @@ module.exports = function (grunt) {
'client/src/controllers/base.js',
'client/src/view.js',
];
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
mkdir: {
tmp: {
options: {
@@ -126,7 +126,8 @@ module.exports = function (grunt) {
'modules/**',
'img/**',
'css/**',
'sounds/**'
'sounds/**',
'custom/**'
],
dest: 'build/tmp/client',
},
@@ -154,6 +155,8 @@ module.exports = function (grunt) {
'bootstrap.php',
'cron.php',
'rebuild.php',
'clear_cache.php',
'upgrade.php',
'index.php',
'LICENSE.txt',
'.htaccess',

View File

@@ -2,10 +2,17 @@
<a href='http://www.espocrm.com'>EspoCRM is an Open Source CRM</a> (Customer Relationship Management) software that allows you to see, enter and evaluate all your company relationships regardless of the type. People, companies or opportunities - all in an easy and intuitive interface.
It's a web application with a frontend designed as a single page application based on backbone.js and a RESTful backend written in PHP.
It's a web application with a frontend designed as a single page application based on backbone.js and a REST API backend written in PHP.
Download the latest release from our [website](http://www.espocrm.com).
### Requirements
* PHP 5.4 or above (with pdo, json, gd, mcrypt extensions);
* MySQL 5.1 or above.
For more information about server configuration see [this article](http://blog.espocrm.com/administration/server-configuration-for-espocrm/).
### How to report bug
Create an issue [here](https://github.com/espocrm/espocrm/issues) or post on our [forum](http://forum.espocrm.com/bug-reports?routestring=forum/bug-reports).
@@ -33,6 +40,21 @@ You need to have nodejs and Grunt CLI installed.
The build will be created in the `build` directory.
### How to make translation
Build po file with command:
`node po.js en_EN`
(specify needed language instead of en_EN)
After that tranlate the generated po file.
Build json files from the translated po file:
1. Put your po file espocrm-en_EN.po to the `build` directory
2. Run `node lang.js en_EN`
The files will be created in build directory.
### License
EspoCRM is published under the GNU GPLv3 [license](https://raw.githubusercontent.com/espocrm/espocrm/master/LICENSE.txt).

View File

@@ -0,0 +1,72 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Acl;
use \Espo\Entities\User;
use \Espo\ORM\Entity;
class Email extends \Espo\Core\Acl\Base
{
public function checkEntityRead(User $user, Entity $entity, $data)
{
if ($this->checkEntity($user, $entity, $data, 'read')) {
return true;
}
if ($data === false) {
return false;
}
if (is_array($data)) {
if (empty($data['read']) || $data['read'] == 'no') {
return false;
}
}
if (!$entity->has('usersIds')) {
$entity->loadLinkMultipleField('users');
}
$userIdList = $entity->get('usersIds');
if (is_array($userIdList) && in_array($user->id, $userIdList)) {
return true;
}
return false;
}
public function checkIsOwner(User $user, Entity $entity)
{
if ($entity->has('assignedUserId')) {
if ($user->id === $entity->get('assignedUserId')) {
return true;
}
}
if ($user->id === $entity->get('createdById')) {
return true;
}
return false;
}
}

View File

@@ -72,7 +72,7 @@ class Admin extends \Espo\Core\Controllers\Base
{
$upgradeManager = new \Espo\Core\UpgradeManager($this->getContainer());
$upgradeManager->install($data['id']);
$upgradeManager->install($data);
return true;
}

View File

@@ -18,22 +18,27 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Controllers;
use \Espo\Core\Exceptions\BadRequest;
class App extends \Espo\Core\Controllers\Record
class App extends \Espo\Core\Controllers\Base
{
public function actionUser()
{
$preferences = $this->getPreferences()->toArray();
unset($preferences['smtpPassword']);
$user = $this->getUser();
if (!$user->has('teamsIds')) {
$user->loadLinkMultipleField('teams');
}
return array(
'user' => $this->getUser()->toArray(),
'acl' => $this->getAcl()->toArray(),
'user' => $user->toArray(),
'acl' => $this->getAcl()->getMap(),
'preferences' => $preferences,
'token' => $this->getUser()->get('token')
);

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Controllers;
@@ -29,19 +29,19 @@ use \Espo\Core\Exceptions\Error;
class Email extends \Espo\Core\Controllers\Record
{
public function actionGetCopiedAttachments($params, $data, $request)
{
{
$id = $request->get('id');
return $this->getRecordService()->getCopiedAttachments($id);
}
public function actionSendTestEmail($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (empty($data['password'])) {
if (is_null($data['password'])) {
if ($data['type'] == 'preferences') {
if (!$this->getUser()->isAdmin() && $data['id'] != $this->getUser()->id) {
throw new Forbidden();
@@ -50,7 +50,7 @@ class Email extends \Espo\Core\Controllers\Record
if (!$preferences) {
throw new Error();
}
$data['password'] = $this->getContainer()->get('crypt')->decrypt($preferences->get('smtpPassword'));
} else {
if (!$this->getUser()->isAdmin()) {
@@ -59,8 +59,29 @@ class Email extends \Espo\Core\Controllers\Record
$data['password'] = $this->getConfig()->get('smtpPassword');
}
}
return $this->getRecordService()->sendTestEmail($data);
}
public function actionMarkAsRead($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (empty($data['ids']) || !is_array($data['ids'])) {
throw new BadRequest();
}
$ids = $data['ids'];
return $this->getRecordService()->markAsReadByIds($ids);
}
public function actionMarkAllAsRead($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
return $this->getRecordService()->markAllAsRead();
}
}

View File

@@ -18,20 +18,20 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Controllers;
use \Espo\Core\Exceptions\Forbidden;
class EmailAccount extends \Espo\Core\Controllers\Record
{
{
public function actionGetFolders($params, $data, $request)
{
{
return $this->getRecordService()->getFolders(array(
'host' => $request->get('host'),
'port' => $request->get('port'),
'ssl' => $request->get('ssl'),
'ssl' => $request->get('ssl') === 'true',
'username' => $request->get('username'),
'password' => $request->get('password'),
'id' => $request->get('id')
@@ -44,5 +44,27 @@ class EmailAccount extends \Espo\Core\Controllers\Record
throw new Forbidden();
}
}
public function actionTestConnection($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (is_null($data['password'])) {
$emailAccount = $this->getEntityManager()->getEntity('EmailAccount', $data['id']);
if (!$emailAccount) {
throw new Error();
}
if ($emailAccount->get('assignedUserId') != $this->getUser()->id && !$this->getUser()->isAdmin()) {
throw new Forbidden();
}
$data['password'] = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('password'));
}
return $this->getRecordService()->testConnection($data);
}
}

View File

@@ -0,0 +1,237 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Controllers;
use \Espo\Core\Exceptions\BadRequest;
use \Espo\Core\Exceptions\Forbidden;
use \Espo\Core\Exceptions\Error;
class EntityManager extends \Espo\Core\Controllers\Base
{
protected function checkControllerAccess()
{
if (!$this->getUser()->isAdmin()) {
throw new Forbidden();
}
}
public function actionCreateEntity($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (empty($data['name']) || empty($data['type'])) {
throw new BadRequest();
}
$name = $data['name'];
$type = $data['type'];
$name = filter_var($name, \FILTER_SANITIZE_STRING);
$type = filter_var($type, \FILTER_SANITIZE_STRING);
$params = array();
if (!empty($data['labelSingular'])) {
$params['labelSingular'] = $data['labelSingular'];
}
if (!empty($data['labelPlural'])) {
$params['labelPlural'] = $data['labelPlural'];
}
if (!empty($data['stream'])) {
$params['stream'] = $data['stream'];
}
if (!empty($data['sortBy'])) {
$params['sortBy'] = $data['sortBy'];
}
if (!empty($data['sortDirection'])) {
$params['asc'] = $data['sortDirection'] === 'asc';
}
$result = $this->getContainer()->get('entityManagerUtil')->create($name, $type, $params);
if ($result) {
$tabList = $this->getConfig()->get('tabList', []);
$tabList[] = $name;
$this->getConfig()->set('tabList', $tabList);
$this->getConfig()->save();
$this->getContainer()->get('dataManager')->rebuild();
} else {
throw new Error();
}
return true;
}
public function actionUpdateEntity($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (empty($data['name'])) {
throw new BadRequest();
}
$name = $data['name'];
$name = filter_var($name, \FILTER_SANITIZE_STRING);
if (!empty($data['sortDirection'])) {
$data['asc'] = $data['sortDirection'] === 'asc';
}
$result = $this->getContainer()->get('entityManagerUtil')->update($name, $data);
if ($result) {
$this->getContainer()->get('dataManager')->clearCache();
} else {
throw new Error();
}
return true;
}
public function actionRemoveEntity($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (empty($data['name'])) {
throw new BadRequest();
}
$name = $data['name'];
$name = filter_var($name, \FILTER_SANITIZE_STRING);
$result = $this->getContainer()->get('entityManagerUtil')->delete($name);
if ($result) {
$tabList = $this->getConfig()->get('tabList', []);
if (($key = array_search($name, $tabList)) !== false) {
unset($tabList[$key]);
$tabList = array_values($tabList);
}
$this->getConfig()->set('tabList', $tabList);
$this->getConfig()->save();
$this->getContainer()->get('dataManager')->clearCache();
} else {
throw new Error();
}
return true;
}
public function actionCreateLink($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
$paramList = [
'entity',
'entityForeign',
'link',
'linkForeign',
'label',
'labelForeign',
'linkType'
];
$d = array();
foreach ($paramList as $item) {
if (empty($data[$item])) {
throw new BadRequest();
}
$d[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
}
$result = $this->getContainer()->get('entityManagerUtil')->createLink($d);
if ($result) {
$this->getContainer()->get('dataManager')->rebuild();
} else {
throw new Error();
}
return true;
}
public function actionUpdateLink($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
$paramList = [
'entity',
'entityForeign',
'link',
'linkForeign',
'label',
'labelForeign'
];
$d = array();
foreach ($paramList as $item) {
$d[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
}
$result = $this->getContainer()->get('entityManagerUtil')->updateLink($d);
if ($result) {
$this->getContainer()->get('dataManager')->clearCache();
} else {
throw new Error();
}
return true;
}
public function actionRemoveLink($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
$paramList = [
'entity',
'link',
];
$d = array();
foreach ($paramList as $item) {
$d[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
}
$result = $this->getContainer()->get('entityManagerUtil')->deleteLink($d);
if ($result) {
$this->getContainer()->get('dataManager')->clearCache();
} else {
throw new Error();
}
return true;
}
}

View File

@@ -61,7 +61,7 @@ class Extension extends \Espo\Core\Controllers\Record
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
$manager->install($data['id']);
$manager->install($data);
return true;
}
@@ -74,7 +74,7 @@ class Extension extends \Espo\Core\Controllers\Record
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
$manager->uninstall($data['id']);
$manager->uninstall($data);
return true;
}
@@ -103,7 +103,7 @@ class Extension extends \Espo\Core\Controllers\Record
{
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
$manager->delete($params['id']);
$manager->delete($params);
return true;
}

View File

@@ -28,10 +28,10 @@ use \Espo\Core\Exceptions\Forbidden;
class ExternalAccount extends \Espo\Core\Controllers\Record
{
public static $defaultAction = 'list';
public function actionList($params, $data, $request)
{
$integrations = $this->getEntityManager()->getRepository('Integration')->find();
$integrations = $this->getEntityManager()->getRepository('Integration')->find();
$arr = array();
foreach ($integrations as $entity) {
if ($entity->get('enabled') && $this->getMetadata()->get('integrations.' . $entity->id .'.allowUserAccounts')) {
@@ -44,22 +44,22 @@ class ExternalAccount extends \Espo\Core\Controllers\Record
'list' => $arr
);
}
public function actionGetOAuth2Info($params, $data, $request)
{
$id = $request->get('id');
list($integration, $userId) = explode('__', $id);
if ($this->getUser()->id != $userId) {
throw new Forbidden();
}
}
$entity = $this->getEntityManager()->getEntity('Integration', $integration);
if ($entity) {
return array(
'clientId' => $entity->get('clientId'),
'redirectUri' => $this->getConfig()->get('siteUrl') . '/oauthcallback',
'redirectUri' => $this->getConfig()->get('siteUrl') . '?entryPoint=oauthCallback',
'isConnected' => $this->getRecordService()->ping($integration, $userId)
);
}
@@ -67,57 +67,57 @@ class ExternalAccount extends \Espo\Core\Controllers\Record
public function actionRead($params, $data, $request)
{
list($integration, $userId) = explode('__', $params['id']);
list($integration, $userId) = explode('__', $params['id']);
if ($this->getUser()->id != $userId) {
throw new Forbidden();
}
$entity = $this->getEntityManager()->getEntity('ExternalAccount', $params['id']);
}
$entity = $this->getEntityManager()->getEntity('ExternalAccount', $params['id']);
return $entity->toArray();
}
public function actionUpdate($params, $data)
{
return $this->actionPatch($params, $data);
}
public function actionPatch($params, $data)
{
list($integration, $userId) = explode('__', $params['id']);
if ($this->getUser()->id != $userId) {
throw new Forbidden();
}
if (isset($data['enabled']) && !$data['enabled']) {
$data['data'] = null;
}
}
$entity = $this->getEntityManager()->getEntity('ExternalAccount', $params['id']);
$entity->set($data);
$this->getEntityManager()->saveEntity($entity);
return $entity->toArray();
return $entity->toArray();
}
public function actionAuthorizationCode($params, $data, $request)
{
if (!$request->isPost()) {
throw new Error('Bad HTTP method type.');
}
}
$id = $data['id'];
$code = $data['code'];
list($integration, $userId) = explode('__', $id);
list($integration, $userId) = explode('__', $id);
if ($this->getUser()->id != $userId) {
throw new Forbidden();
}
$service = $this->getRecordService();
$service = $this->getRecordService();
return $service->authorizationCode($integration, $userId, $code);
}
}

View File

@@ -18,50 +18,94 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Controllers;
use Espo\Core\Utils as Utils;
use \Espo\Core\Exceptions\Error;
use \Espo\Core\Exceptions\Forbidden;
use \Espo\Core\Exceptions\BadRequest;
class Import extends \Espo\Core\Controllers\Record
{
protected function checkControllerAccess()
{
if (!$this->getUser()->isAdmin()) {
throw new Forbidden();
}
}
public function actionPatch($params, $data)
{
throw new BadRequest();
}
public function actionUpdate($params, $data)
{
throw new BadRequest();
}
public function actionMassUpdate($params, $data, $request)
{
throw new BadRequest();
}
public function actionCreateLink($params, $data)
{
throw new BadRequest();
}
public function actionRemoveLink($params, $data)
{
throw new BadRequest();
}
class Import extends \Espo\Core\Controllers\Base
{
protected function getFileManager()
{
return $this->getContainer()->get('fileManager');
}
protected function getEntityManager()
{
return $this->getContainer()->get('entityManager');
}
public function actionUploadFile($params, $data)
{
{
$contents = $data;
$attachment = $this->getEntityManager()->getEntity('Attachment');
$attachment->set('type', 'text/csv');
$attachment->set('role', 'Import File');
$attachment->set('role', 'Import File');
$attachment->set('name', 'import-file.csv');
$this->getEntityManager()->saveEntity($attachment);
$this->getFileManager()->putContents('data/upload/' . $attachment->id, $contents);
return array(
'attachmentId' => $attachment->id
);
}
public function actionRevert($params, $data)
{
return $this->getService('Import')->revert($data['entityType'], $data['idsToRemove']);
{
if (empty($data['id'])) {
throw new BadRequest();
}
return $this->getService('Import')->revert($data['id']);
}
public function actionRemoveDuplicates($params, $data)
{
if (empty($data['id'])) {
throw new BadRequest();
}
return $this->getService('Import')->removeDuplicates($data['id']);
}
public function actionCreate($params, $data)
{
{
$importParams = array(
'headerRow' => $data['headerRow'],
'fieldDelimiter' => $data['fieldDelimiter'],
@@ -74,13 +118,13 @@ class Import extends \Espo\Core\Controllers\Base
'defaultValues' => $data['defaultValues'],
'action' => $data['action'],
);
$attachmentId = $data['attachmentId'];
if (!$this->getAcl()->check($data['entityType'], 'edit')) {
throw new Forbidden();
}
return $this->getService('Import')->import($data['entityType'], $data['fields'], $attachmentId, $importParams);
}
}

View File

@@ -18,9 +18,9 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Modules\Crm\Controllers;
namespace Espo\Controllers;
class InboundEmail extends \Espo\Core\Controllers\Record
{
@@ -30,18 +30,34 @@ class InboundEmail extends \Espo\Core\Controllers\Record
throw new Forbidden();
}
}
public function actionGetFolders($params, $data, $request)
{
{
return $this->getRecordService()->getFolders(array(
'host' => $request->get('host'),
'port' => $request->get('port'),
'ssl' => $request->get('ssl'),
'ssl' => $request->get('ssl') === 'true',
'username' => $request->get('username'),
'password' => $request->get('password'),
'id' => $request->get('id')
));
}
public function actionTestConnection($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (is_null($data['password'])) {
$inboundEmail = $this->getEntityManager()->getEntity('InboundEmail', $data['id']);
if (!$inboundEmail) {
throw new Error();
}
$data['password'] = $this->getContainer()->get('crypt')->decrypt($inboundEmail->get('password'));
}
return $this->getRecordService()->testConnection($data);
}
}

View File

@@ -33,7 +33,7 @@ class Layout extends \Espo\Core\Controllers\Base
{
$data = $this->getContainer()->get('layout')->get($params['scope'], $params['name']);
if (empty($data)) {
throw new NotFound("Layout " . $params['scope'] . ":" . $params['name'] . ' is not found');
throw new NotFound("Layout " . $params['scope'] . ":" . $params['name'] . ' is not found.');
}
return $data;
}
@@ -43,16 +43,18 @@ class Layout extends \Espo\Core\Controllers\Base
if (!$this->getUser()->isAdmin()) {
throw new Forbidden();
}
$result = $this->getContainer()->get('layout')->set($data, $params['scope'], $params['name']);
$layoutManager = $this->getContainer()->get('layout');
$layoutManager->set($data, $params['scope'], $params['name']);
$result = $layoutManager->save();
if ($result === false) {
throw new Error("Error while saving layout");
throw new Error("Error while saving layout.");
}
$this->getContainer()->get('dataManager')->updateCacheTimestamp();
return $this->getContainer()->get('layout')->get($params['scope'], $params['name']);
return $layoutManager->get($params['scope'], $params['name']);
}
public function actionPatch($params, $data)

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Controllers;
@@ -28,22 +28,22 @@ use \Espo\Core\Exceptions\BadRequest;
use \Espo\Core\Exceptions\NotFound;
class Preferences extends \Espo\Core\Controllers\Base
{
{
protected function getPreferences()
{
return $this->getContainer()->get('preferences');
}
protected function getEntityManager()
{
return $this->getContainer()->get('entityManager');
}
protected function getCrypt()
{
return $this->getContainer()->get('crypt');
}
protected function handleUserAccess($userId)
{
if (!$this->getUser()->isAdmin()) {
@@ -52,7 +52,7 @@ class Preferences extends \Espo\Core\Controllers\Base
}
}
}
public function actionDelete($params, $data)
{
$userId = $params['id'];
@@ -60,38 +60,38 @@ class Preferences extends \Espo\Core\Controllers\Base
throw new BadRequest();
}
$this->handleUserAccess($userId);
return $this->getEntityManager()->getRepository('Preferences')->resetToDefaults($userId);
return $this->getEntityManager()->getRepository('Preferences')->resetToDefaults($userId);
}
public function actionPatch($params, $data)
{
return $this->actionUpdate($params, $data);
}
}
public function actionUpdate($params, $data)
{
$userId = $params['id'];
$this->handleUserAccess($userId);
if (array_key_exists('smtpPassword', $data)) {
$data['smtpPassword'] = $this->getCrypt()->encrypt($data['smtpPassword']);
}
$user = $this->getEntityManager()->getEntity('User', $userId);
$user = $this->getEntityManager()->getEntity('User', $userId);
$entity = $this->getEntityManager()->getEntity('Preferences', $userId);
if ($entity) {
if ($entity && $user) {
$entity->set($data);
$this->getEntityManager()->saveEntity($entity);
$entity->set('smtpEmailAddress', $user->get('emailAddress'));
$entity->set('smtpEmailAddress', $user->get('emailAddress'));
$entity->set('name', $user->get('name'));
$entity->clear('smtpPassword');
return $entity->toArray();
return $entity->toArray();
}
throw new Error();
}
@@ -101,18 +101,19 @@ class Preferences extends \Espo\Core\Controllers\Base
$userId = $params['id'];
$this->handleUserAccess($userId);
$entity = $this->getEntityManager()->getEntity('Preferences', $userId);
$entity = $this->getEntityManager()->getEntity('Preferences', $userId);
$user = $this->getEntityManager()->getEntity('User', $userId);
if (!$entity || !$user) {
throw new NotFound();
}
$entity->set('smtpEmailAddress', $user->get('emailAddress'));
$entity->set('name', $user->get('name'));
$entity->clear('smtpPassword');
if ($entity) {
return $entity->toArray();
}
throw new NotFound();
return $entity->toArray();
}
}

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Controllers;
@@ -35,30 +35,31 @@ class User extends \Espo\Core\Controllers\Record
if (empty($userId)) {
throw new Error();
}
if (!$this->getUser()->isAdmin() && $this->getUser()->id != $userId) {
throw new Forbidden();
}
$user = $this->getEntityManager()->getEntity('User', $userId);
if (empty($user)) {
throw new NotFound();
}
$acl = new \Espo\Core\Acl($user, $this->getConfig(), $this->getContainer()->get('fileManager'), $this->getMetadata());
return $acl->toArray();
return $this->getAclManager()->getMap($user);
}
public function actionChangeOwnPassword($params, $data)
public function actionChangeOwnPassword($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
return $this->getService('User')->changePassword($this->getUser()->id, $data['password']);
}
public function actionChangePasswordByRequest($params, $data, $request)
{
if (!$request->isPost()) {
throw new Forbidden();
throw new BadRequest();
}
if (empty($data['requestId']) || empty($data['password'])) {
throw new BadRequest();
@@ -86,7 +87,7 @@ class User extends \Espo\Core\Controllers\Record
if (!$request->isPost()) {
throw new Forbidden();
}
if (empty($data['userName']) || empty($data['emailAddress'])) {
throw new BadRequest();
}

View File

@@ -22,260 +22,61 @@
namespace Espo\Core;
use \Espo\Core\Exceptions\Error;
use \Espo\ORM\Entity;
class Acl
{
private $data = array();
private $user;
private $cacheFile;
private $aclManager;
private $actionList = array('read', 'edit', 'delete');
private $levelList = array('all', 'team', 'own', 'no');
protected $fileManager;
protected $metadata;
public function __construct(\Espo\Entities\User $user, $config = null, $fileManager = null, $metadata = null)
public function __construct(AclManager $aclManager, \Espo\Entities\User $user)
{
$this->aclManager = $aclManager;
$this->user = $user;
$this->metadata = $metadata;
if (!$this->user->isFetched()) {
throw new Error();
}
$this->user->loadLinkMultipleField('teams');
if ($fileManager) {
$this->fileManager = $fileManager;
}
$this->cacheFile = 'data/cache/application/acl/' . $user->id . '.php';
if ($config && $config->get('useCache') && file_exists($this->cacheFile)) {
$cached = include $this->cacheFile;
$this->data = $cached;
$this->initSolid();
} else {
$this->load();
$this->initSolid();
if ($config && $fileManager && $config->get('useCache')) {
$this->buildCache();
}
}
}
public function checkScope($scope, $action = null, $isOwner = null, $inTeam = null, $entity = null)
protected function getAclManager()
{
if (array_key_exists($scope, $this->data)) {
if ($this->data[$scope] === false) {
return false;
}
if ($this->data[$scope] === true) {
return true;
}
if (!is_null($action)) {
if (array_key_exists($action, $this->data[$scope])) {
$value = $this->data[$scope][$action];
if ($value === 'all' || $value === true) {
return true;
}
if (!$value || $value === 'no') {
return false;
}
if (is_null($isOwner)) {
return true;
}
if ($isOwner) {
if ($value === 'own' || $value === 'team') {
return true;
}
}
if ($inTeam === null && $entity) {
$inTeam = $this->checkInTeam($entity);
}
if ($inTeam) {
if ($value === 'team') {
return true;
}
}
return false;
}
}
return true;
}
return true;
return $this->aclManager;
}
public function toArray()
protected function getUser()
{
return $this->data;
return $this->user;
}
public function getMap()
{
return $this->getAclManager()->getMap($this->getUser());
}
public function getLevel($scope, $action)
{
if ($this->user->isAdmin()) {
return 'all';
}
if (array_key_exists($scope, $this->data)) {
if (array_key_exists($action, $this->data[$scope])) {
return $this->data[$scope][$action];
}
}
return false;
return $this->getAclManager()->getLevel($this->getUser(), $scope, $action);
}
public function check($subject, $action = null, $isOwner = null, $inTeam = null)
public function get($permission)
{
if ($this->user->isAdmin()) {
return true;
}
if (is_string($subject)) {
return $this->checkScope($subject, $action, $isOwner, $inTeam);
} else {
$entity = $subject;
if ($entity instanceof Entity) {
$entityName = $entity->getEntityName();
return $this->checkScope($entityName, $action, $this->checkIsOwner($entity), $inTeam, $entity);
}
}
return $this->getAclManager()->get($this->getUser(), $permission);
}
public function checkReadOnlyTeam($scope)
{
if (isset($this->data[$scope]) && isset($this->data[$scope]['read'])) {
return $this->data[$scope]['read'] === 'team';
}
return false;
return $this->getAclManager()->checkReadOnlyTeam($this->getUser(), $scope);
}
public function checkReadOnlyOwn($scope)
{
if ($this->user->isAdmin()) {
return false;
}
if (isset($this->data[$scope]) && isset($this->data[$scope]['read'])) {
return $this->data[$scope]['read'] === 'own';
}
return false;
return $this->getAclManager()->checkReadOnlyOwn($this->getUser(), $scope);
}
public function checkIsOwner($entity)
public function check($subject, $action = null, $isOwner = null, $inTeam = null)
{
if ($this->user->isAdmin()) {
return false;
}
$userId = $this->user->id;
if ($userId === $entity->get('assignedUserId') || $userId === $entity->get('createdById')) {
return true;
}
return false;
return $this->getAclManager()->check($this->getUser(), $subject, $action, $isOwner, $inTeam) ;
}
public function checkInTeam($entity)
public function checkScope($scope, $action = null, $isOwner = null, $inTeam = null, $entity = null)
{
$userTeamIds = $this->user->get('teamsIds');
if (!$entity->hasRelation('teams') || !$entity->hasField('teamsIds')) {
return false;
}
if (!$entity->has('teamsIds')) {
$entity->loadLinkMultipleField('teams');
}
$teamIds = $entity->get('teamsIds');
if (empty($teamIds)) {
return false;
}
foreach ($userTeamIds as $id) {
if (in_array($id, $teamIds)) {
return true;
}
}
return false;
}
private function load()
{
$aclTables = array();
$userRoles = $this->user->get('roles');
foreach ($userRoles as $role) {
$aclTables[] = $role->get('data');
}
$teams = $this->user->get('teams');
foreach ($teams as $team) {
$teamRoles = $team->get('roles');
foreach ($teamRoles as $role) {
$aclTables[] = $role->get('data');
}
}
$this->data = $this->merge($aclTables);
}
private function initSolid()
{
$data = $this->metadata->get('app.acl.solid', array());
foreach ($data as $entityName => $item) {
$this->data[$entityName] = $item;
}
}
private function merge($tables)
{
$data = array();
foreach ($tables as $table) {
foreach ($table as $scope => $row) {
if ($row == false) {
if (!isset($data[$scope])) {
$data[$scope] = false;
}
} else {
if (!isset($data[$scope])) {
$data[$scope] = array();
}
if ($data[$scope] == false) {
$data[$scope] = array();
}
foreach ($row as $action => $level) {
if (!isset($data[$scope][$action])) {
$data[$scope][$action] = $level;
} else {
if (array_search($data[$scope][$action], $this->levelList) > array_search($level, $this->levelList)) {
$data[$scope][$action] = $level;
}
}
}
}
}
}
return $data;
}
private function buildCache()
{
$contents = '<' . '?'. 'php return ' . var_export($this->data, true) . ';';
$this->fileManager->putContents($this->cacheFile, $contents);
return $this->getAclManager()->checkScope($this->getUser(), $subject, $action, $isOwner, $inTeam, $entity) ;
}
}

View File

@@ -0,0 +1,223 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Acl;
use \Espo\Core\Interfaces\Injectable;
use \Espo\Entities\User;
use \Espo\ORM\Entity;
class Base implements Injectable
{
protected $dependencies = array(
'config',
'entityManager',
'aclManager'
);
protected $injections = array();
public function inject($name, $object)
{
$this->injections[$name] = $object;
}
public function __construct()
{
$this->init();
}
protected function init()
{
}
protected function getInjection($name)
{
return $this->injections[$name];
}
protected function addDependency($name)
{
$this->dependencies[] = $name;
}
public function getDependencyList()
{
return $this->dependencies;
}
protected function getConfig()
{
return $this->getInjection('config');
}
protected function getEntityManager()
{
return $this->getInjection('entityManager');
}
protected function getAclManager()
{
return $this->getInjection('aclManager');
}
public function checkReadOnlyTeam(User $user, $scope, $data)
{
if (empty($data) || !is_array($data) || !isset($data['read'])) {
return false;
}
return $data['read'] === 'team';
}
public function checkReadOnlyOwn(User $user, $scope, $data)
{
if (empty($data) || !is_array($data) || !isset($data['read'])) {
return false;
}
return $data['read'] === 'own';
}
public function checkEntity(User $user, Entity $entity, $data, $action)
{
return $this->checkScope($user, $data, $entity->getEntityType(), $action, null, null, $entity);
}
public function checkScope(User $user, $data, $scope, $action = null, $isOwner = null, $inTeam = null, Entity $entity = null)
{
if (is_null($data)) {
return true;
}
if ($data === false) {
return false;
}
if ($data === true) {
return true;
}
if (!is_null($action)) {
if (array_key_exists($action, $data)) {
$value = $data[$action];
if ($value === 'all' || $value === true) {
return true;
}
if (!$value || $value === 'no') {
return false;
}
if (is_null($isOwner)) {
if ($entity) {
$isOwner = $this->checkIsOwner($user, $entity);
} else {
return true;
}
}
if ($isOwner) {
if ($value === 'own' || $value === 'team') {
return true;
}
}
if (is_null($inTeam) && $entity) {
$inTeam = $this->checkInTeam($user, $entity);
}
if ($inTeam) {
if ($value === 'team') {
return true;
}
}
return false;
}
}
return true;
}
public function checkIsOwner(User $user, Entity $entity)
{
if ($entity->has('assignedUserId')) {
if ($user->id === $entity->get('assignedUserId')) {
return true;
}
}
if ($entity->has('createdById')) {
if ($user->id === $entity->get('createdById')) {
return true;
}
}
return false;
}
public function checkInTeam(User $user, Entity $entity)
{
$userTeamIds = $user->get('teamsIds');
if (!$entity->hasRelation('teams') || !$entity->hasField('teamsIds')) {
return false;
}
if (!$entity->has('teamsIds')) {
$entity->loadLinkMultipleField('teams');
}
$teamIds = $entity->get('teamsIds');
if (empty($teamIds)) {
return false;
}
foreach ($userTeamIds as $id) {
if (in_array($id, $teamIds)) {
return true;
}
}
return false;
}
public function checkEntityDelete(User $user, Entity $entity, $data)
{
$result = $this->checkEntity($user, $entity, $data, 'delete');
if (!$result) {
if (is_array($data)) {
if ($data['edit'] != 'no') {
if ($entity->has('createdById') && $entity->get('createdById') == $user->id) {
if (!$entity->has('assignedUserId')) {
return true;
} else {
if (!$entity->get('assignedUserId')) {
return true;
}
if ($entity->get('assignedUserId') == $entity->get('createdById')) {
return true;
}
}
}
}
}
}
return $result;
}
}

View File

@@ -0,0 +1,247 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Acl;
use \Espo\Core\Exceptions\Error;
use \Espo\ORM\Entity;
class Table
{
private $data = array(
'table' => array()
);
private $cacheFile;
private $actionList = ['read', 'edit', 'delete'];
private $levelList = ['all', 'team', 'own', 'no'];
protected $fileManager;
protected $metadata;
public function __construct(\Espo\Entities\User $user, $config = null, $fileManager = null, $metadata = null)
{
$this->user = $user;
$this->metadata = $metadata;
if (!$this->user->isFetched()) {
throw new Error();
}
$this->user->loadLinkMultipleField('teams');
if ($fileManager) {
$this->fileManager = $fileManager;
}
$this->cacheFile = 'data/cache/application/acl/' . $user->id . '.php';
if ($config && $config->get('useCache') && file_exists($this->cacheFile)) {
$cached = include $this->cacheFile;
$this->data = $cached;
$this->initSolid();
} else {
$this->load();
$this->initSolid();
if ($config && $fileManager && $config->get('useCache')) {
$this->buildCache();
}
}
}
public function getMap()
{
return $this->data;
}
public function getScopeData($scope)
{
if (array_key_exists($scope, $this->data['table'])) {
return $this->data['table'][$scope];
}
return null;
}
public function get($permission)
{
if ($permission == 'table') {
return null;
}
if (array_key_exists($permission, $this->data)) {
return $this->data[$permission];
}
return null;
}
public function getLevel($scope, $action)
{
if (array_key_exists($scope, $this->data['table'])) {
if (array_key_exists($action, $this->data['table'][$scope])) {
return $this->data['table'][$scope][$action];
}
}
return false;
}
private function load()
{
$aclTables = [];
$assignmentPermissionList = [];
$userPermissionList = [];
$userRoles = $this->user->get('roles');
foreach ($userRoles as $role) {
$aclTables[] = $role->get('data');
$assignmentPermissionList[] = $role->get('assignmentPermission');
$userPermissionList[] = $role->get('userPermission');
}
$teams = $this->user->get('teams');
foreach ($teams as $team) {
$teamRoles = $team->get('roles');
foreach ($teamRoles as $role) {
$aclTables[] = $role->get('data');
$assignmentPermissionList[] = $role->get('assignmentPermission');
$userPermissionList[] = $role->get('userPermission');
}
}
$this->data['table'] = $this->merge($aclTables);
$this->data['assignmentPermission'] = $this->mergeValues($assignmentPermissionList, $this->metadata->get('app.acl.valueDefaults.assignmentPermission', 'all'));
$this->data['userPermission'] = $this->mergeValues($userPermissionList, $this->metadata->get('app.acl.valueDefaults.userPermission', 'no'));
}
private function initSolid()
{
if (!$this->metadata) {
return;
}
$data = $this->metadata->get('app.acl.solid', array());
foreach ($data as $entityType => $item) {
$this->data['table'][$entityType] = $item;
}
}
private function mergeValues(array $list, $defaultValue)
{
$result = null;
foreach ($list as $level) {
if ($level != 'not-set') {
if (is_null($result)) {
$result = $level;
continue;
}
if (array_search($result, $this->levelList) > array_search($level, $this->levelList)) {
$result = $level;
}
}
}
if (is_null($result)) {
$result = $defaultValue;
}
return $result;
}
private function getScopeList()
{
$scopeList = [];
$scopes = $this->metadata->get('scopes');
foreach ($scopes as $scope => $d) {
if (!empty($d['acl'])) {
$scopeList[] = $scope;
}
}
return $scopeList;
}
private function merge($tables)
{
$data = array();
$scopeList = $this->getScopeList();
foreach ($tables as $table) {
foreach ($scopeList as $scope) {
if (!isset($table->$scope)) {
continue;
}
$row = $table->$scope;
if ($row == false) {
if (!isset($data[$scope])) {
$data[$scope] = false;
}
} else if ($row === true) {
$data[$scope] = true;
} else {
if (!isset($data[$scope])) {
$data[$scope] = array();
}
if ($data[$scope] == false) {
$data[$scope] = array();
}
if (is_array($row) || $row instanceof \stdClass) {
foreach ($row as $action => $level) {
if (!isset($data[$scope][$action])) {
$data[$scope][$action] = $level;
} else {
if (array_search($data[$scope][$action], $this->levelList) > array_search($level, $this->levelList)) {
$data[$scope][$action] = $level;
}
}
}
}
}
}
}
foreach ($scopeList as $scope) {
if (!array_key_exists($scope, $data)) {
$aclType = $this->metadata->get('scopes.' . $scope . '.acl');
if ($aclType === true) {
$aclType = 'recordAllTeamOwnNo';
}
if (!empty($aclType)) {
$data[$scope] = $this->metadata->get('app.acl.defaults.' . $aclType, true);
}
}
}
return $data;
}
private function buildCache()
{
$contents = '<' . '?'. 'php return ' . var_export($this->data, true) . ';';
$this->fileManager->putContents($this->cacheFile, $contents);
}
}

View File

@@ -0,0 +1,181 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core;
use \Espo\Core\Exceptions\Error;
use \Espo\ORM\Entity;
use \Espo\Entities\User;
use \Espo\Core\Utils\Util;
class AclManager
{
private $container;
private $metadata;
private $implementationHashMap = array();
private $tableHashMap = array();
public function __construct(Container $container)
{
$this->container = $container;
$this->metadata = $container->get('metadata');
}
protected function getContainer()
{
return $this->container;
}
public function getImplementation($scope)
{
if (empty($this->implementationHashMap[$scope])) {
$normalizedName = Util::normilizeClassName($scope);
$className = '\\Espo\\Custom\\Acl\\' . $normalizedName;
if (!class_exists($className)) {
$moduleName = $this->metadata->getScopeModuleName($scope);
if ($moduleName) {
$className = '\\Espo\\Modules\\' . $moduleName . '\\Acl\\' . $normalizedName;
} else {
$className = '\\Espo\\Acl\\' . $normalizedName;
}
if (!class_exists($className)) {
$className = '\\Espo\\Core\\Acl\\Base';
}
}
if (class_exists($className)) {
$acl = new $className();
$dependencies = $acl->getDependencyList();
foreach ($dependencies as $name) {
$acl->inject($name, $this->container->get($name));
}
$this->implementationHashMap[$scope] = $acl;
} else {
throw new Error();
}
}
return $this->implementationHashMap[$scope];
}
protected function getTable(User $user)
{
$key = spl_object_hash($user);
if (empty($this->tableHashMap[$key])) {
$config = $this->getContainer()->get('config');
$fileManager = $this->getContainer()->get('fileManager');
$metadata = $this->getContainer()->get('metadata');
$this->tableHashMap[$key] = new \Espo\Core\Acl\Table($user, $config, $fileManager, $metadata);
}
return $this->tableHashMap[$key];
}
public function getMap(User $user)
{
return $this->getTable($user)->getMap();
}
public function getLevel(User $user, $scope, $action)
{
if ($user->isAdmin()) {
return 'all';
}
return $this->getTable($user)->getLevel($scope, $action);
}
public function get(User $user, $permission)
{
if ($user->isAdmin()) {
return true;
}
return $this->getTable($user)->get($permission);
}
public function checkReadOnlyTeam(User $user, $scope)
{
if ($user->isAdmin()) {
return false;
}
$data = $this->getTable($user)->getScopeData($scope);
return $this->getImplementation($scope)->checkReadOnlyTeam($user, $scope, $data);
}
public function checkReadOnlyOwn(User $user, $scope)
{
if ($user->isAdmin()) {
return false;
}
$data = $this->getTable($user)->getScopeData($scope);
return $this->getImplementation($scope)->checkReadOnlyOwn($user, $scope, $data);
}
public function check(User $user, $subject, $action = null, $isOwner = null, $inTeam = null)
{
if ($user->isAdmin()) {
return true;
}
if (is_string($subject)) {
return $this->checkScope($user, $subject, $action, $isOwner, $inTeam);
} else {
$entity = $subject;
if ($entity instanceof Entity) {
$entityType = $entity->getEntityType();
$impl = $this->getImplementation($entityType);
$methodName = 'checkEntity' . ucfirst($action);
if (method_exists($impl, $methodName)) {
$data = $this->getTable($user)->getScopeData($entityType);
return $impl->$methodName($user, $entity, $data);
}
return $this->checkEntity($user, $entity, $action);
}
}
}
public function checkEntity(User $user, Entity $entity, $action)
{
if ($user->isAdmin()) {
return true;
}
$data = $this->getTable($user)->getScopeData($entity->getEntityType());
return $this->getImplementation($scope)->checkEntity($user, $entity, $data, $action);
}
public function checkScope(User $user, $scope, $action = null, $isOwner = null, $inTeam = null, $entity = null)
{
if ($user->isAdmin()) {
return true;
}
$data = $this->getTable($user)->getScopeData($scope);
return $this->getImplementation($scope)->checkScope($user, $data, $scope, $action, $isOwner, $inTeam, $entity);
}
}

View File

@@ -105,22 +105,23 @@ class Application
$container = $this->getContainer();
$slim->get('/', function() {});
$slim->post('/', function() {});
$entryPointManager = new \Espo\Core\EntryPointManager($container);
$auth = $this->getAuth();
$apiAuth = new \Espo\Core\Utils\Api\Auth($auth, $entryPointManager->checkAuthRequired($entryPoint), true);
$slim->add($apiAuth);
try {
$auth = $this->getAuth();
$apiAuth = new \Espo\Core\Utils\Api\Auth($auth, $entryPointManager->checkAuthRequired($entryPoint), true);
$slim->add($apiAuth);
$slim->hook('slim.before.dispatch', function () use ($entryPoint, $entryPointManager, $container) {
try {
$slim->hook('slim.before.dispatch', function () use ($entryPoint, $entryPointManager, $container) {
$entryPointManager->run($entryPoint);
} catch (\Exception $e) {
$container->get('output')->processError($e->getMessage(), $e->getCode(), true);
}
});
});
$slim->run();
$slim->run();
} catch (\Exception $e) {
$container->get('output')->processError($e->getMessage(), $e->getCode(), true);
}
}
public function runCron()
@@ -138,6 +139,12 @@ class Application
$dataManager->rebuild();
}
public function runClearCache()
{
$dataManager = $this->getContainer()->get('dataManager');
$dataManager->clearCache();
}
public function isInstalled()
{
$config = $this->getContainer()->get('config');

View File

@@ -79,6 +79,28 @@ class Container
return $className;
}
protected function loadLog()
{
$logConfig = $this->get('config')->get('logger');
$log = new \Espo\Core\Utils\Log('Espo');
$levelCode = $log->getLevelCode($logConfig['level']);
if ($logConfig['isRotate']) {
$handler = new \Espo\Core\Utils\Log\Monolog\Handler\RotatingFileHandler($logConfig['path'], $logConfig['maxRotateFiles'], $levelCode);
} else {
$handler = new \Espo\Core\Utils\Log\Monolog\Handler\StreamHandler($logConfig['path'], $levelCode);
}
$log->pushHandler($handler);
$errorHandler = new \Monolog\ErrorHandler($log);
$errorHandler->registerExceptionHandler(null, false);
$errorHandler->registerErrorHandler(array(), false);
return $log;
}
protected function loadContainer()
{
return $this;
@@ -172,14 +194,20 @@ class Container
);
}
private function loadAclManager()
{
$className = $this->getServiceClassName('acl', '\\Espo\\Core\\AclManager');
return new $className(
$this->get('container')
);
}
private function loadAcl()
{
$className = $this->getServiceClassName('acl', '\\Espo\\Core\\Acl');
return new $className(
$this->get('user'),
$this->get('config'),
$this->get('fileManager'),
$this->get('metadata')
$this->get('aclManager'),
$this->get('user')
);
}
@@ -208,6 +236,7 @@ class Container
return new \Espo\Core\Utils\Language(
$this->get('fileManager'),
$this->get('config'),
$this->get('metadata'),
$this->get('preferences')
);
}
@@ -221,7 +250,7 @@ class Container
private function loadScheduledJob()
{
return new \Espo\Core\Cron\ScheduledJob(
return new \Espo\Core\Utils\ScheduledJob(
$this
);
}

View File

@@ -90,6 +90,11 @@ abstract class Base
return $this->container->get('acl');
}
protected function getAclManager()
{
return $this->container->get('aclManager');
}
protected function getConfig()
{
return $this->container->get('config');

View File

@@ -25,6 +25,7 @@ namespace Espo\Core\Controllers;
use \Espo\Core\Exceptions\Error;
use \Espo\Core\Exceptions\Forbidden;
use \Espo\Core\Exceptions\NotFound;
use \Espo\Core\Exceptions\BadRequest;
use \Espo\Core\Utils\Util;
class Record extends Base
@@ -33,6 +34,8 @@ class Record extends Base
public static $defaultAction = 'list';
protected $defaultRecordServiceName = 'Record';
protected function getEntityManager()
{
return $this->getContainer()->get('entityManager');
@@ -47,8 +50,8 @@ class Record extends Base
if ($this->getServiceFactory()->checkExists($name)) {
$service = $this->getServiceFactory()->create($name);
} else {
$service = $this->getServiceFactory()->create('Record');
$service->setEntityName($name);
$service = $this->getServiceFactory()->create($this->defaultRecordServiceName);
$service->setEntityType($name);
}
return $service;
@@ -66,13 +69,17 @@ class Record extends Base
return $entity->toArray();
}
public function actionPatch($params, $data)
public function actionPatch($params, $data, $request)
{
return $this->actionUpdate($params, $data);
return $this->actionUpdate($params, $data, $request);
}
public function actionCreate($params, $data)
public function actionCreate($params, $data, $request)
{
if (!$request->isPost()) {
throw BadRequest();
}
if (!$this->getAcl()->check($this->name, 'edit')) {
throw new Forbidden();
}
@@ -86,8 +93,12 @@ class Record extends Base
throw new Error();
}
public function actionUpdate($params, $data)
public function actionUpdate($params, $data, $request)
{
if (!$request->isPut() && !$request->isPatch()) {
throw BadRequest();
}
if (!$this->getAcl()->check($this->name, 'edit')) {
throw new Forbidden();
}
@@ -132,7 +143,7 @@ class Record extends Base
return array(
'total' => $result['total'],
'list' => $result['collection']->toArray()
'list' => isset($result['collection']) ? $result['collection']->toArray() : $result['list']
);
}
@@ -167,12 +178,16 @@ class Record extends Base
return array(
'total' => $result['total'],
'list' => $result['collection']->toArray()
'list' => isset($result['collection']) ? $result['collection']->toArray() : $result['list']
);
}
public function actionDelete($params)
public function actionDelete($params, $data, $request)
{
if (!$request->isDelete()) {
throw BadRequest();
}
$id = $params['id'];
if ($this->getRecordService()->deleteEntity($id)) {
@@ -193,74 +208,128 @@ class Record extends Base
$ids = $request->get('ids');
$where = $request->get('where');
$byWhere = $request->get('byWhere');
$params = array();
if ($byWhere) {
$params['where'] = $where;
} else {
$params['ids'] = $ids;
}
return array(
'id' => $this->getRecordService()->export($ids, $where)
'id' => $this->getRecordService()->export($params)
);
}
public function actionMassUpdate($params, $data, $request)
{
if (!$request->isPut()) {
throw new BadRequest();
}
if (!$this->getAcl()->check($this->name, 'edit')) {
throw new Forbidden();
}
if (empty($data['attributes'])) {
throw new BadRequest();
}
$params = array();
if (array_key_exists('where', $data) && !empty($data['byWhere'])) {
$params['where'] = json_decode(json_encode($data['where']), true);
} else if (array_key_exists('ids', $data)) {
$params['ids'] = $data['ids'];
}
$ids = $data['ids'];
$where = $data['where'];
$attributes = $data['attributes'];
$idsUpdated = $this->getRecordService()->massUpdate($attributes, $ids, $where);
$idsUpdated = $this->getRecordService()->massUpdate($attributes, $params);
return $idsUpdated;
}
public function actionMassDelete($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (!$this->getAcl()->check($this->name, 'delete')) {
throw new Forbidden();
}
$ids = $data['ids'];
$where = $data['where'];
$params = array();
if (array_key_exists('where', $data) && !empty($data['byWhere'])) {
$where = json_decode(json_encode($data['where']), true);
$params['where'] = $where;
}
if (array_key_exists('ids', $data)) {
$where = json_decode(json_encode($data['where']), true);
$params['ids'] = $data['ids'];
}
$idsRemoved = $this->getRecordService()->massRemove($ids, $where);
$idsRemoved = $this->getRecordService()->massRemove($params);
return $idsRemoved;
}
public function actionCreateLink($params, $data)
public function actionCreateLink($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (empty($params['id']) || empty($params['link'])) {
throw new BadRequest();
}
$id = $params['id'];
$link = $params['link'];
$foreignIds = array();
if (isset($data['id'])) {
$foreignIds[] = $data['id'];
}
if (isset($data['ids']) && is_array($data['ids'])) {
foreach ($data['ids'] as $foreignId) {
$foreignIds[] = $foreignId;
if (!empty($data['massRelate'])) {
if (!is_array($data['where'])) {
throw new BadRequest();
}
$where = json_decode(json_encode($data['where']), true);
return $this->getRecordService()->linkEntityMass($id, $link, $where);
} else {
$foreignIds = array();
if (isset($data['id'])) {
$foreignIds[] = $data['id'];
}
if (isset($data['ids']) && is_array($data['ids'])) {
foreach ($data['ids'] as $foreignId) {
$foreignIds[] = $foreignId;
}
}
}
$result = false;
foreach ($foreignIds as $foreignId) {
if ($this->getRecordService()->linkEntity($id, $link, $foreignId)) {
$result = $result || true;
$result = false;
foreach ($foreignIds as $foreignId) {
if ($this->getRecordService()->linkEntity($id, $link, $foreignId)) {
$result = true;
}
}
if ($result) {
return true;
}
}
if ($result) {
return true;
}
throw new Error();
}
public function actionRemoveLink($params, $data)
public function actionRemoveLink($params, $data, $request)
{
if (!$request->isDelete()) {
throw new BadRequest();
}
$id = $params['id'];
$link = $params['link'];
if (empty($params['id']) || empty($params['link'])) {
throw new BadRequest();
}
$foreignIds = array();
if (isset($data['id'])) {
$foreignIds[] = $data['id'];
@@ -284,8 +353,11 @@ class Record extends Base
throw new Error();
}
public function actionFollow($params)
public function actionFollow($params, $data, $request)
{
if (!$request->isPut()) {
throw new BadRequest();
}
if (!$this->getAcl()->check($this->name, 'read')) {
throw new Forbidden();
}
@@ -293,13 +365,35 @@ class Record extends Base
return $this->getRecordService()->follow($id);
}
public function actionUnfollow($params)
public function actionUnfollow($params, $data, $request)
{
if (!$request->isDelete()) {
throw new BadRequest();
}
if (!$this->getAcl()->check($this->name, 'read')) {
throw new Forbidden();
}
$id = $params['id'];
return $this->getRecordService()->unfollow($id);
}
public function actionMerge($params, $data, $request)
{
if (!$request->isPost()) {
throw new BadRequest();
}
if (empty($data['targetId']) || empty($data['sourceIds']) || !is_array($data['sourceIds'])) {
throw new BadRequest();
}
$targetId = $data['targetId'];
$sourceIds = $data['sourceIds'];
if (!$this->getAcl()->check($this->name, 'edit')) {
throw new Forbidden();
}
return $this->getRecordService()->merge($targetId, $sourceIds);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Controllers;
use \Espo\Core\Exceptions\Error;
use \Espo\Core\Exceptions\Forbidden;
use \Espo\Core\Exceptions\NotFound;
use \Espo\Core\Exceptions\BadRequest;
use \Espo\Core\Utils\Util;
class RecordTree extends Record
{
public static $defaultAction = 'list';
protected $defaultRecordServiceName = 'RecordTree';
public function actionListTree($params, $data, $request)
{
if (!$this->getAcl()->check($this->name, 'read')) {
throw new Forbidden();
}
$where = $request->get('where');
$parentId = $request->get('parentId');
$maxDepth = $request->get('maxDepth');
$collection = $this->getRecordService()->getTree($parentId, array(
'where' => $where
), 0, $maxDepth);
return array(
'list' => $collection->toArray(),
'path' => $this->getRecordService()->getTreeItemPath($parentId)
);
}
}

View File

@@ -22,17 +22,18 @@
namespace Espo\Core;
use \PDO;
use Espo\Core\Utils\Json;
use Espo\Core\Exceptions\NotFound;
class CronManager
{
private $container;
private $config;
private $fileManager;
private $entityManager;
private $scheduledJobCron;
private $serviceCron;
private $jobService;
private $scheduledJobService;
private $scheduledJobUtil;
const PENDING = 'Pending';
const RUNNING = 'Running';
@@ -41,19 +42,18 @@ class CronManager
protected $lastRunTime = 'data/cache/application/cronLastRunTime.php';
public function __construct(\Espo\Core\Container $container)
{
$this->container = $container;
$this->config = $this->container->get('config');
$this->fileManager = $this->container->get('fileManager');
$this->entityManager = $this->container->get('entityManager');
$this->serviceFactory = $this->container->get('serviceFactory');
$this->scheduledJobCron = $this->container->get('scheduledJob');
$this->serviceCron = new \Espo\Core\Cron\Service( $this->container->get('serviceFactory'));
$this->jobService = $this->container->get('serviceFactory')->create('job');
$this->scheduledJobService = $this->container->get('serviceFactory')->create('scheduledJob');
$this->scheduledJobUtil = $this->container->get('scheduledJob');
$this->cronJob = new \Espo\Core\Utils\Cron\Job($this->config, $this->entityManager);
$this->cronScheduledJob = new \Espo\Core\Utils\Cron\ScheduledJob($this->config, $this->entityManager);
}
protected function getContainer()
@@ -71,32 +71,38 @@ class CronManager
return $this->fileManager;
}
protected function getJobService()
protected function getEntityManager()
{
return $this->jobService;
return $this->entityManager;
}
protected function getScheduledJobService()
protected function getServiceFactory()
{
return $this->scheduledJobService;
return $this->serviceFactory;
}
protected function getScheduledJobCron()
protected function getScheduledJobUtil()
{
return $this->scheduledJobCron;
return $this->scheduledJobUtil;
}
protected function getServiceCron()
protected function getCronJob()
{
return $this->serviceCron;
return $this->cronJob;
}
protected function getCronScheduledJob()
{
return $this->cronScheduledJob;
}
protected function getLastRunTime()
{
$lastRunTime = $this->getFileManager()->getContents($this->lastRunTime);
if (!is_int($lastRunTime)) {
$lastRunTime = time() - (intval($this->getConfig()->get('cron.minExecutionTime')) + 60);
$lastRunData = $this->getFileManager()->getPhpContents($this->lastRunTime);
$lastRunTime = time() - intval($this->getConfig()->get('cron.minExecutionTime')) - 1;
if (is_array($lastRunData) && !empty($lastRunData['time'])) {
$lastRunTime = $lastRunData['time'];
}
return $lastRunTime;
@@ -104,7 +110,10 @@ class CronManager
protected function setLastRunTime($time)
{
return $this->getFileManager()->putContentsPHP($this->lastRunTime, $time);
$data = array(
'time' => $time,
);
return $this->getFileManager()->putPhpContents($this->lastRunTime, $data);
}
protected function checkLastRunTime()
@@ -120,65 +129,143 @@ class CronManager
return false;
}
/**
* Run Cron
*
* @return void
*/
public function run()
{
if (!$this->checkLastRunTime()) {
$GLOBALS['log']->info('Cron Manager: Stop cron running, too frequency execution');
return; //stop cron running, too frequency execution
$GLOBALS['log']->info('CronManager: Stop cron running, too frequent execution.');
return;
}
$this->setLastRunTime(time());
$entityManager = $this->getEntityManager();
$cronJob = $this->getCronJob();
$cronScheduledJob = $this->getCronScheduledJob();
//Check scheduled jobs and create related jobs
$this->createJobsFromScheduledJobs();
$pendingJobs = $this->getJobService()->getPendingJobs();
$pendingJobs = $cronJob->getPendingJobs();
foreach ($pendingJobs as $job) {
$this->getJobService()->updateEntity($job['id'], array(
'status' => self::RUNNING,
));
$jobEntity = $entityManager->getEntity('Job', $job['id']);
if (!isset($jobEntity)) {
$GLOBALS['log']->error('CronManager: empty Job entity ['.$job['id'].'].');
continue;
}
$jobEntity->set('status', self::RUNNING);
$entityManager->saveEntity($jobEntity);
$isSuccess = true;
try {
if (!empty($job['scheduled_job_id'])) {
$this->getScheduledJobCron()->run($job);
$this->runScheduledJob($job);
} else {
$this->getServiceCron()->run($job);
$this->runService($job);
}
} catch (\Exception $e) {
$isSuccess = false;
$GLOBALS['log']->error('Failed job running, job ['.$job['id'].']. Error Details: '.$e->getMessage());
$GLOBALS['log']->error('CronManager: Failed job running, job ['.$job['id'].']. Error Details: '.$e->getMessage());
}
$status = $isSuccess ? self::SUCCESS : self::FAILED;
$this->getJobService()->updateEntity($job['id'], array(
'status' => $status,
));
$jobEntity->set('status', $status);
$entityManager->saveEntity($jobEntity);
//set status in the schedulerJobLog
if (!empty($job['scheduled_job_id'])) {
$this->getScheduledJobService()->addLogRecord($job['scheduled_job_id'], $status);
$cronScheduledJob->addLogRecord($job['scheduled_job_id'], $status);
}
}
}
/**
* Run Scheduled Job
*
* @param array $job
*
* @return void
*/
protected function runScheduledJob(array $job)
{
$jobName = $job['method'];
$className = $this->getScheduledJobUtil()->get($jobName);
if ($className === false) {
throw new NotFound();
}
$jobClass = new $className($this->container);
$method = $this->getScheduledJobUtil()->getMethodName();
if (!method_exists($jobClass, $method)) {
throw new NotFound();
}
$jobClass->$method();
}
/**
* Run Service
*
* @param array $job
*
* @return void
*/
protected function runService(array $job)
{
$serviceName = $job['service_name'];
if (!$this->getServiceFactory()->checkExists($serviceName)) {
throw new NotFound();
}
$service = $this->getServiceFactory()->create($serviceName);
$serviceMethod = $job['method'];
if (!method_exists($service, $serviceMethod)) {
throw new NotFound();
}
$data = $job['data'];
if (Json::isJSON($data)) {
$data = Json::decode($data, true);
}
$service->$serviceMethod($data);
}
/**
* Check scheduled jobs and create related jobs
* @return array List of created Jobs
*
* @return array List of created Jobs
*/
protected function createJobsFromScheduledJobs()
{
$activeScheduledJobs = $this->getScheduledJobService()->getActiveJobs();
$entityManager = $this->getEntityManager();
$activeScheduledJobs = $this->getCronScheduledJob()->getActiveJobs();
$cronJob = $this->getCronJob();
$runningScheduledJobs = $cronJob->getActiveJobs('scheduled_job_id', self::RUNNING, PDO::FETCH_COLUMN);
$createdJobs = array();
foreach ($activeScheduledJobs as $scheduledJob) {
if (in_array($scheduledJob['id'], $runningScheduledJobs)) {
continue;
}
$scheduling = $scheduledJob['scheduling'];
$cronExpression = \Cron\CronExpression::factory($scheduling);
@@ -186,26 +273,30 @@ class CronManager
try {
$prevDate = $cronExpression->getPreviousRunDate()->format('Y-m-d H:i:s');
} catch (\Exception $e) {
$GLOBALS['log']->error('ScheduledJob ['.$scheduledJob['id'].']: CronExpression - Impossible CRON expression ['.$scheduling.']');
$GLOBALS['log']->error('CronManager: ScheduledJob ['.$scheduledJob['id'].']: CronExpression - Impossible CRON expression ['.$scheduling.']');
continue;
}
if ($cronExpression->isDue()) {
$prevDate = date('Y-m-d H:i:00');
$prevDate = date('Y-m-d H:i:s');
}
$existsJob = $this->getJobService()->getJobByScheduledJob($scheduledJob['id'], $prevDate);
$existsJob = $cronJob->getJobByScheduledJob($scheduledJob['id'], $prevDate);
if (!isset($existsJob) || empty($existsJob)) {
//create a job
$data = array(
//create a new job
$jobEntity = $entityManager->getEntity('Job');
$jobEntity->set(array(
'name' => $scheduledJob['name'],
'status' => self::PENDING,
'scheduledJobId' => $scheduledJob['id'],
'executeTime' => $prevDate,
'method' => $scheduledJob['job'],
);
$createdJobs[] = $this->getJobService()->createEntity($data);
));
$jobEntityId = $entityManager->saveEntity($jobEntity);
if (!empty($jobEntityId)) {
$createdJobs[] = $jobEntityId;
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Entities;
class CategoryTreeItem extends \Espo\Core\ORM\Entity
{
public function toArray()
{
$data = parent::toArray();
$childList = $this->get('childList');
if (is_null($childList)) {
$data['childList'] = null;
} else {
$arr = [];
foreach ($childList as $entity) {
$arr[] = $entity->toArray();
}
$data['childList'] = $arr;
}
return $data;
}
}

View File

@@ -28,9 +28,9 @@ use \Espo\Core\Exceptions\NotFound,
class EntryPointManager
{
private $container;
private $fileManager;
private $container;
private $fileManager;
protected $data = null;
@@ -38,7 +38,7 @@ class EntryPointManager
protected $allowedMethods = array(
'run',
);
);
/**
* @var array - path to entryPoint files
@@ -46,14 +46,14 @@ class EntryPointManager
private $paths = array(
'corePath' => 'application/Espo/EntryPoints',
'modulePath' => 'application/Espo/Modules/{*}/EntryPoints',
'customPath' => 'custom/Espo/Custom/EntryPoints',
'customPath' => 'custom/Espo/Custom/EntryPoints',
);
public function __construct(\Espo\Core\Container $container)
{
$this->container = $container;
$this->fileManager = $container->get('fileManager');
$this->container = $container;
$this->fileManager = $container->get('fileManager');
}
protected function getContainer()
@@ -69,16 +69,16 @@ class EntryPointManager
public function checkAuthRequired($name)
{
$className = $this->getClassName($name);
if ($className === false) {
if (!$className) {
throw new NotFound();
}
return $className::$authRequired;
return $className::$authRequired;
}
public function run($name)
public function run($name)
{
$className = $this->getClassName($name);
if ($className === false) {
if (!$className) {
throw new NotFound();
}
$entryPoint = new $className($this->container);
@@ -89,7 +89,7 @@ class EntryPointManager
protected function getClassName($name)
{
$name = Util::normilizeClassName($name);
if (!isset($this->data)) {
$this->init();
}
@@ -98,8 +98,8 @@ class EntryPointManager
if (isset($this->data[$name])) {
return $this->data[$name];
}
return false;
return false;
}
@@ -108,8 +108,7 @@ class EntryPointManager
$classParser = $this->getContainer()->get('classParser');
$classParser->setAllowedMethods($this->allowedMethods);
$this->data = $classParser->getData($this->paths, $this->cacheFile);
}
}
}

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Core\EntryPoints;
@@ -29,50 +29,50 @@ use \Espo\Core\Exceptions\Forbidden;
abstract class Base
{
private $container;
public static $authRequired = true;
protected function getContainer()
{
return $this->container;
}
protected function getUser()
{
return $this->getContainer()->get('user');
}
protected function getAcl()
{
return $this->getContainer()->get('acl');
}
protected function getEntityManager()
{
return $this->getContainer()->get('entityManager');
}
protected function getServiceFactory()
{
return $this->getContainer()->get('serviceFactory');
}
}
protected function getConfig()
{
return $this->getContainer()->get('config');
}
protected function getMetadata()
{
return $this->getContainer()->get('metadata');
}
}
public function __construct(Container $container)
{
$this->container = $container;
}
abstract public function run();
abstract public function run();
}

View File

@@ -28,7 +28,6 @@ class ExtensionManager extends Upgrades\Base
protected $params = array(
'packagePath' => 'data/upload/extensions',
'backupPath' => 'data/.backup/extensions',
'scriptNames' => array(

View File

@@ -29,33 +29,33 @@ use \Espo\Core\Exceptions\NotFound;
class ClientManager
{
protected $entityManager;
protected $metadata;
protected $clientMap = array();
public function __construct($entityManager, $metadata, $config)
{
$this->entityManager = $entityManager;
$this->metadata = $metadata;
$this->config = $config;
}
protected function getMetadata()
{
return $this->metadata;
}
protected function getEntityManager()
{
return $this->entityManager;
}
protected function getConfig()
{
return $this->config;
}
public function storeAccessToken($hash, $data)
{
if (!empty($this->clientMap[$hash]) && !empty($this->clientMap[$hash]['externalAccountEntity'])) {
@@ -64,37 +64,37 @@ class ClientManager
$externalAccountEntity->set('tokenType', $data['tokenType']);
$this->getEntityManager()->saveEntity($externalAccountEntity);
}
}
}
public function create($integration, $userId)
{
$authMethod = $this->getMetadata()->get("integrations.{$integration}.authMethod");
$methodName = 'create' . ucfirst($authMethod);
return $this->$methodName($integration, $userId);
$authMethod = $this->getMetadata()->get("integrations.{$integration}.authMethod");
$methodName = 'create' . ucfirst($authMethod);
return $this->$methodName($integration, $userId);
}
protected function createOAuth2($integration, $userId)
{
{
$integrationEntity = $this->getEntityManager()->getEntity('Integration', $integration);
$externalAccountEntity = $this->getEntityManager()->getEntity('ExternalAccount', $integration . '__' . $userId);
$className = $this->getMetadata()->get("integrations.{$integration}.clientClassName");
$redirectUri = $this->getConfig()->get('siteUrl') . '/oauthcallback'; // TODO move to client class
$redirectUri = $this->getConfig()->get('siteUrl') . '?entryPoint=oauthCallback'; // TODO move to client class
if (!$externalAccountEntity) {
throw new Error("External Account {$integration} not found for {$userId}");
}
if (!$integrationEntity->get('enabled')) {
return null;
}
}
if (!$externalAccountEntity->get('enabled')) {
return null;
}
$oauth2Client = new \Espo\Core\ExternalAccount\OAuth2\Client();
}
$oauth2Client = new \Espo\Core\ExternalAccount\OAuth2\Client();
$client = new $className($oauth2Client, array(
'endpoint' => $this->getMetadata()->get("integrations.{$integration}.params.endpoint"),
'tokenEndpoint' => $this->getMetadata()->get("integrations.{$integration}.params.tokenEndpoint"),
@@ -105,12 +105,12 @@ class ClientManager
'refreshToken' => $externalAccountEntity->get('refreshToken'),
'tokenType' => $externalAccountEntity->get('tokenType'),
), $this);
$this->addToClientMap($client, $integrationEntity, $externalAccountEntity, $userId);
return $client;
return $client;
}
protected function addToClientMap($client, $integrationEntity, $externalAccountEntity, $userId)
{
$this->clientMap[spl_object_hash($client)] = array(

View File

@@ -29,9 +29,9 @@ use \Espo\Core\ExternalAccount\OAuth2\Client;
abstract class OAuth2Abstract implements IClient
{
protected $client = null;
protected $manager = null;
protected $paramList = array(
'endpoint',
'tokenEndpoint',
@@ -42,33 +42,33 @@ abstract class OAuth2Abstract implements IClient
'refreshToken',
'redirectUri',
);
protected $clientId = null;
protected $clientSecret = null;
protected $accessToken = null;
protected $refreshToken = null;
protected $redirectUri = null;
public function __construct($client, array $params = array(), $manager = null)
{
$this->client = $client;
$this->setParams($params);
$this->manager = $manager;
}
public function getParam($name)
{
if (in_array($name, $this->paramList)) {
return $this->$name;
}
}
public function setParam($name, $value)
{
if (in_array($name, $this->paramList)) {
@@ -79,7 +79,7 @@ abstract class OAuth2Abstract implements IClient
$this->$name = $value;
}
}
public function setParams(array $params)
{
foreach ($this->paramList as $name) {
@@ -88,42 +88,41 @@ abstract class OAuth2Abstract implements IClient
}
}
}
protected function afterTokenRefreshed($data)
{
if ($this->manager) {
$this->manager->storeAccessToken(spl_object_hash($this), $data);
}
}
public function getAccessTokenFromAuthorizationCode($code)
{
$r = $this->client->getAccessToken($this->getParam('tokenEndpoint'), Client::GRANT_TYPE_AUTHORIZATION_CODE, array(
'code' => $code,
'redirect_uri' => $this->getParam('redirectUri')
));
if ($r['code'] == 200) {
$data = array();
if (!empty($r['result'])) {
$data['accessToken'] = $r['result']['access_token'];
$data['tokenType'] = $r['result']['token_type'];
$data['refreshToken'] = $r['result']['refresh_token'];
$data['refreshToken'] = $r['result']['refresh_token'];
}
return $data;
}
return null;
}
abstract protected function getPingUrl();
public function ping()
{
if (empty($this->accessToken) || empty($this->clientId) || empty($this->clientSecret)) {
return false;
}
$url = $this->getPingUrl();
try {
@@ -133,35 +132,48 @@ abstract class OAuth2Abstract implements IClient
return false;
}
}
public function request($url, $params = array(), $httpMethod = Client::HTTP_METHOD_GET, $allowRenew = true)
public function request($url, $params = null, $httpMethod = Client::HTTP_METHOD_GET, $contentType = null, $allowRenew = true)
{
$r = $this->client->request($url, $params, $httpMethod);
$httpHeaders = array();
if (!empty($contentType)) {
$httpHeaders['Content-Type'] = $contentType;
switch ($contentType) {
case Client::CONTENT_TYPE_MULTIPART_FORM_DATA:
$httpHeaders['Content-Length'] = strlen($params);
break;
case Client::CONTENT_TYPE_APPLICATION_JSON:
$httpHeaders['Content-Length'] = strlen($params);
break;
}
}
$r = $this->client->request($url, $params, $httpMethod, $httpHeaders);
$code = null;
if (!empty($r['code'])) {
$code = $r['code'];
}
if ($code == 200) {
}
if ($code >= 200 && $code < 300) {
return $r['result'];
} else {
$handledData = $this->handleErrorResponse($r);
if ($allowRenew && is_array($handledData)) {
if ($handledData['action'] == 'refreshToken') {
if ($this->refreshToken()) {
return $this->request($url, $params, $httpMethod, false);
if ($this->refreshToken()) {
return $this->request($url, $params, $httpMethod, $contentType, false);
}
} else if ($handledData['action'] == 'renew') {
return $this->request($url, $params, $httpMethod, false);
return $this->request($url, $params, $httpMethod, $contentType, false);
}
}
}
throw new Error("Error after requesting {$httpMethod} {$url}.", $code);
}
protected function refreshToken()
{
if (!empty($this->refreshToken)) {
@@ -183,11 +195,11 @@ abstract class OAuth2Abstract implements IClient
}
}
}
protected function handleErrorResponse($r)
{
if ($r['code'] == 401 && !empty($r['result'])) {
$result = $r['result'];
$result = $r['result'];
if (strpos($r['header'], 'error=invalid_token') !== false) {
return array(
'action' => 'refreshToken'
@@ -198,7 +210,7 @@ abstract class OAuth2Abstract implements IClient
);
}
} else if ($r['code'] == 400 && !empty($r['result'])) {
if ($r['result']['error'] == 'invalid_token') {
if ($r['result']['error'] == 'invalid_token') {
return array(
'action' => 'refreshToken'
);

View File

@@ -32,8 +32,9 @@ class Client
const TOKEN_TYPE_BEARER = 'Bearer';
const TOKEN_TYPE_OAUTH = 'OAuth';
const CONTENT_TYPE_APPLICATION = 0;
const CONTENT_TYPE_MULTIPART = 1;
const CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENENCODED = 'application/x-www-form-urlencoded';
const CONTENT_TYPE_MULTIPART_FORM_DATA = 'multipart/form-data';
const CONTENT_TYPE_APPLICATION_JSON = 'application/json';
const HTTP_METHOD_GET = 'GET';
const HTTP_METHOD_POST = 'POST';
@@ -118,7 +119,7 @@ class Client
$this->accessTokenSecret = $accessTokenSecret;
}
public function request($url, $params = array(), $httpMethod = self::HTTP_METHOD_GET, array $httpHeaders = array(), $contentType = self::CONTENT_TYPE_MULTIPART)
public function request($url, $params = null, $httpMethod = self::HTTP_METHOD_GET, array $httpHeaders = array())
{
if ($this->accessToken) {
switch ($this->tokenType) {
@@ -137,10 +138,10 @@ class Client
}
}
return $this->execute($url, $params, $httpMethod, $httpHeaders, $contentType);
return $this->execute($url, $params, $httpMethod, $httpHeaders);
}
private function execute($url, $params = array(), $httpMethod, array $httpHeaders = array(), $contentType = self::CONTENT_TYPE_MULTIPART)
private function execute($url, $params = null, $httpMethod, array $httpHeaders = array())
{
$curlOptions = array(
CURLOPT_RETURNTRANSFER => true,
@@ -153,8 +154,10 @@ class Client
$curlOptions[CURLOPT_POST] = true;
case self::HTTP_METHOD_PUT:
case self::HTTP_METHOD_PATCH:
if (self::CONTENT_TYPE_APPLICATION === $contentType) {
if (is_array($params)) {
$postFields = http_build_query($params, null, '&');
} else {
$postFields = $params;
}
$curlOptions[CURLOPT_POSTFIELDS] = $postFields;
break;
@@ -165,7 +168,9 @@ class Client
if (strpos($url, '?') === false) {
$url .= '?';
}
$url .= http_build_query($params, null, '&');
if (is_array($params)) {
$url .= http_build_query($params, null, '&');
}
break;
default:
break;
@@ -228,7 +233,7 @@ class Client
$params['grant_type'] = $grantType;
$httpHeaders = array();
switch ($this->clientAuth) {
switch ($this->tokenType) {
case self::AUTH_TYPE_URI:
case self::AUTH_TYPE_FORM:
$params['client_id'] = $this->clientId;
@@ -242,7 +247,7 @@ class Client
throw new \Exception();
}
return $this->execute($url, $params, self::HTTP_METHOD_POST, $httpHeaders, self::CONTENT_TYPE_APPLICATION);
return $this->execute($url, $params, self::HTTP_METHOD_POST, $httpHeaders);
}
}

View File

@@ -73,7 +73,7 @@ class HookManager
protected function loadHooks()
{
if ($this->getConfig()->get('useCache') && file_exists($this->cacheFile)) {
$this->data = $this->getFileManager()->getContents($this->cacheFile);
$this->data = $this->getFileManager()->getPhpContents($this->cacheFile);
return;
}
@@ -89,14 +89,14 @@ class HookManager
$this->data = array_merge_recursive($this->data, $this->getHookData($this->paths['customPath']));
if ($this->getConfig()->get('useCache')) {
$this->getFileManager()->putContentsPHP($this->cacheFile, $this->data);
$this->getFileManager()->putPhpContents($this->cacheFile, $this->data);
}
}
public function process($scope, $hookName, $injection = null)
public function process($scope, $hookName, $injection = null, array $options = array())
{
if ($scope != 'Common') {
$this->process('Common', $hookName, $injection);
$this->process('Common', $hookName, $injection, $options);
}
if (!empty($this->data[$scope])) {
@@ -106,7 +106,7 @@ class HookManager
$this->hooks[$className] = $this->createHookByClassName($className);
}
$hook = $this->hooks[$className];
$hook->$hookName($injection);
$hook->$hookName($injection, $options);
}
}
}
@@ -170,7 +170,9 @@ class HookManager
$sortedHookList = array_merge($sortedHookList, $hookDetails);
}
$hooks[$scopeName][$hookName] = isset($hooks[$scopeName][$hookName]) ? array_merge($hooks[$scopeName][$hookName], $sortedHookList) : $sortedHookList;
$normalizedScopeName = Util::normilizeScopeName($scopeName);
$hooks[$normalizedScopeName][$hookName] = isset($hooks[$normalizedScopeName][$hookName]) ? array_merge($hooks[$normalizedScopeName][$hookName], $sortedHookList) : $sortedHookList;
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Espo\Core\Hooks;
use \Espo\Core\Interfaces\Injectable;
class Base implements Injectable
abstract class Base implements Injectable
{
protected $dependencies = array(
'entityManager',
@@ -52,6 +52,11 @@ class Base implements Injectable
return $this->dependencies;
}
protected function addDependency($name)
{
$this->dependencies[] = $name;
}
protected function getInjection($name)
{
return $this->injections[$name];

View File

@@ -24,7 +24,6 @@ namespace Espo\Core\Jobs;
use \Espo\Core\Container;
abstract class Base
{
private $container;

View File

@@ -0,0 +1,38 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Loaders;
class EntityManagerUtil extends Base
{
public function load()
{
$entityManager = new \Espo\Core\Utils\EntityManager(
$this->getContainer()->get('metadata'),
$this->getContainer()->get('language'),
$this->getContainer()->get('fileManager')
);
return $entityManager;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php
/************************************************************************
* This file is part of EspoCRM.
*
@@ -24,21 +24,23 @@ namespace Espo\Core\Mail;
use \Zend\Mime\Mime as Mime;
use \Espo\ORM\Entity;
class Importer
{
private $entityManager;
private $fileManager;
private $config;
public function __construct($entityManager, $fileManager, $config)
{
$this->entityManager = $entityManager;
$this->fileManager = $fileManager;
$this->config = $config;
}
protected function getEntityManager()
{
return $this->entityManager;
@@ -47,45 +49,63 @@ class Importer
{
return $this->config;
}
protected function getFileManager()
{
return $this->fileManager;
}
public function importMessage($message, $userId, $teamsIds = array())
{
try {
$email = $this->getEntityManager()->getEntity('Email');
$subject = $message->subject;
if ($subject !== '0' && empty($subject)) {
$subject = '--empty--';
$subject = '(No Subject)';
}
$email->set('isHtml', false);
$email->set('name', $subject);
$email->set('status', 'Archived');
$email->set('attachmentsIds', array());
$email->set('assignedUserId', $userId);
$email->set('teamsIds', $teamsIds);
$fromArr = $this->getAddressListFromMessage($message, 'from');
if (isset($message->from)) {
$email->set('fromName', $message->from);
$email->set('fromString', $message->from);
}
if (isset($message->replyTo)) {
$email->set('replyToString', $message->replyTo);
}
$toArr = $this->getAddressListFromMessage($message, 'to');
$ccArr = $this->getAddressListFromMessage($message, 'cc');
$email->set('from', $fromArr[0]);
$email->set('to', implode(';', $this->getAddressListFromMessage($message, 'to')));
$email->set('cc', implode(';', $this->getAddressListFromMessage($message, 'cc')));
$email->set('to', implode(';', $toArr));
$email->set('cc', implode(';', $ccArr));
if (isset($message->messageId) && !empty($message->messageId)) {
$email->set('messageId', $message->messageId);
if (isset($message->deliveredTo)) {
$email->set('messageIdInternal', $message->messageId . '-' . $message->deliveredTo);
}
}
if ($this->checkIsDuplicate($email)) {
if ($duplicate = $this->findDuplicate($email)) {
$duplicate->loadLinkMultipleField('users');
$usersIds = $duplicate->get('usersIds');
$usersIds[] = $userId;
$duplicate->set('usersIds', $usersIds);
$this->getEntityManager()->saveEntity($duplicate);
if (!empty($teamsIds)) {
foreach ($teamsIds as $teamId) {
$this->getEntityManager()->getRepository('Email')->relate($duplicate, 'teams', $teamId);
}
}
return false;
}
@@ -95,7 +115,9 @@ class Importer
$dateSent = $dt->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s');
$email->set('dateSent', $dateSent);
}
}
} else {
$email->set('dateSent', date('Y-m-d H:i:s'));
}
if (isset($message->deliveryDate)) {
$dt = new \DateTime($message->deliveryDate);
if ($dt) {
@@ -103,17 +125,17 @@ class Importer
$email->set('deliveryDate', $deliveryDate);
}
}
$inlineIds = array();
if ($message->isMultipart()) {
foreach (new \RecursiveIteratorIterator($message) as $part) {
$this->importPartDataToEmail($email, $part, $inlineIds);
}
} else {
$this->importPartDataToEmail($email, $message, $inlineIds);
$this->importPartDataToEmail($email, $message, $inlineIds, 'text/plain');
}
$body = $email->get('body');
if (!empty($body)) {
foreach ($inlineIds as $cid => $attachmentId) {
@@ -122,6 +144,8 @@ class Importer
$email->set('body', $body);
}
$parentFound = false;
if (isset($message->references) && !empty($message->references)) {
$reference = str_replace(array('/', '@'), " ", trim($message->references, '<>'));
$parentType = $parentId = null;
@@ -131,54 +155,85 @@ class Importer
if (!empty($parentType) && !empty($parentId)) {
$email->set('parentType', $parentType);
$email->set('parentId', $parentId);
$parentFound = true;
}
}
}
if (!$email->has('parentId')) {
if (!$parentFound) {
$from = $email->get('from');
if ($from) {
$contact = $this->getEntityManager()->getRepository('Contact')->where(array(
'emailAddress' => $from
))->findOne();
if ($contact) {
if (!$this->getConfig()->get('b2cMode')) {
if ($contact->get('accountId')) {
$email->set('parentType', 'Account');
$email->set('parentId', $contact->get('accountId'));
}
} else {
$email->set('parentType', 'Contact');
$email->set('parentId', $contact->id);
}
$parentFound = $this->findParent($email, $from);
}
if (!$parentFound) {
if (!empty($toArr)) {
$parentFound = $this->findParent($email, $toArr[0]);
}
}
}
$this->getEntityManager()->saveEntity($email);
return $email;
} catch (\Exception $e) {}
}
protected function checkIsDuplicate($email)
protected function findParent(Entity $email, $emailAddress)
{
if ($email->get('messageIdInternal')) {
$contact = $this->getEntityManager()->getRepository('Contact')->where(array(
'emailAddress' => $emailAddress
))->findOne();
if ($contact) {
if (!$this->getConfig()->get('b2cMode')) {
if ($contact->get('accountId')) {
$email->set('parentType', 'Account');
$email->set('parentId', $contact->get('accountId'));
return true;
}
} else {
$email->set('parentType', 'Contact');
$email->set('parentId', $contact->id);
return true;
}
} else {
$account = $this->getEntityManager()->getRepository('Account')->where(array(
'emailAddress' => $emailAddress
))->findOne();
if ($account) {
$email->set('parentType', 'Account');
$email->set('parentId', $account->id);
return true;
} else {
$lead = $this->getEntityManager()->getRepository('Lead')->where(array(
'emailAddress' => $emailAddress
))->findOne();
if ($lead) {
$email->set('parentType', 'Lead');
$email->set('parentId', $lead->id);
return true;
}
}
}
}
protected function findDuplicate(Entity $email)
{
if ($email->get('messageId')) {
$duplicate = $this->getEntityManager()->getRepository('Email')->where(array(
'messageIdInternal' => $email->get('messageIdInternal')
'messageId' => $email->get('messageId')
))->findOne();
if ($duplicate) {
return true;
return $duplicate;
}
}
}
protected function getAddressListFromMessage($message, $type)
{
$addressList = array();
if (isset($message->$type)) {
$list = $message->getHeader($type)->getAddressList();
foreach ($list as $address) {
$addressList[] = $address->getEmail();
@@ -186,82 +241,107 @@ class Importer
}
return $addressList;
}
protected function importPartDataToEmail(\Espo\Entities\Email $email, $part, &$inlineIds = array())
protected function importPartDataToEmail(\Espo\Entities\Email $email, $part, &$inlineIds = array(), $defaultContentType = null)
{
try {
$type = strtok($part->contentType, ';');
$type = null;
if ($part->getHeaders() && isset($part->contentType)) {
$type = strtok($part->contentType, ';');
}
if (empty($type)) {
if (!empty($defaultContentType)) {
$type = $defaultContentType;
} else {
return;
}
}
$encoding = null;
switch ($type) {
case 'text/plain':
$content = $this->getContentFromPart($part);
if (!$email->get('body')) {
$email->set('body', $content);
}
$email->set('bodyPlain', $content);
break;
case 'text/html':
$content = $this->getContentFromPart($part);
$email->set('body', $content);
$email->set('isHtml', true);
break;
default:
$content = $part->getContent();
$disposition = null;
$fileName = null;
$contentId = null;
if (isset($part->ContentDisposition)) {
if (strpos($part->ContentDisposition, 'attachment') === 0) {
if (preg_match('/filename="?([^"]+)"?/i', $part->ContentDisposition, $m)) {
$fileName = $m[1];
$disposition = 'attachment';
}
} else if (strpos($part->ContentDisposition, 'inline') === 0) {
$contentId = trim($part->contentID, '<>');
$fileName = $contentId;
$disposition = 'inline';
$isAttachment = true;
if ($type == 'text/plain' || $type == 'text/html') {
$isAttachment = false;
$content = $this->getContentFromPart($part);
if ($type == 'text/plain') {
if ($email->get('bodyPlain')) {
$isAttachment = true;
} else {
$email->set('bodyPlain', $content);
if (!$email->get('body')) {
$email->set('body', $content);
}
}
if (isset($part->contentTransferEncoding)) {
$encoding = strtolower($part->getHeader('Content-Transfer-Encoding')->getTransferEncoding());
}
$attachment = $this->getEntityManager()->getEntity('Attachment');
$attachment->set('name', $fileName);
$attachment->set('type', $type);
if ($disposition == 'inline') {
$attachment->set('role', 'Inline Attachment');
} else if ($type == 'text/html') {
if ($email->get('isHtml')) {
$isAttachment = true;
} else {
$attachment->set('role', 'Attachment');
$email->set('body', $content);
$email->set('isHtml', true);
}
if ($encoding == 'base64') {
$content = base64_decode($content);
}
$attachment->set('size', strlen($content));
$this->getEntityManager()->saveEntity($attachment);
$path = 'data/upload/' . $attachment->id;
$this->getFileManager()->putContents($path, $content);
if ($disposition == 'attachment') {
$attachmentsIds = $email->get('attachmentsIds');
$attachmentsIds[] = $attachment->id;
$email->set('attachmentsIds', $attachmentsIds);
} else if ($disposition == 'inline') {
$inlineIds[$contentId] = $attachment->id;
}
}
if ($isAttachment) {
$content = $part->getContent();
$disposition = null;
$fileName = null;
$contentId = null;
if (isset($part->ContentDisposition)) {
if (strpos($part->ContentDisposition, 'attachment') === 0) {
if (preg_match('/filename="?([^"]+)"?/i', $part->ContentDisposition, $m)) {
$fileName = $m[1];
$disposition = 'attachment';
}
} else if (strpos($part->ContentDisposition, 'inline') === 0) {
$contentId = trim($part->contentID, '<>');
$fileName = $contentId;
$disposition = 'inline';
}
}
if (isset($part->contentTransferEncoding)) {
$encoding = strtolower($part->getHeader('Content-Transfer-Encoding')->getTransferEncoding());
}
$attachment = $this->getEntityManager()->getEntity('Attachment');
$attachment->set('name', $fileName);
$attachment->set('type', $type);
if ($disposition == 'inline') {
$attachment->set('role', 'Inline Attachment');
} else {
$attachment->set('role', 'Attachment');
}
if ($encoding == 'base64') {
$content = base64_decode($content);
}
$attachment->set('size', strlen($content));
$this->getEntityManager()->saveEntity($attachment);
$path = 'data/upload/' . $attachment->id;
$this->getFileManager()->putContents($path, $content);
if ($disposition == 'attachment') {
$attachmentsIds = $email->get('attachmentsIds');
$attachmentsIds[] = $attachment->id;
$email->set('attachmentsIds', $attachmentsIds);
} else if ($disposition == 'inline') {
$inlineIds[$contentId] = $attachment->id;
}
}
} catch (\Exception $e) {}
}
protected function getContentFromPart($part)
{
if ($part instanceof \Zend\Mime\Part) {
@@ -271,20 +351,20 @@ class Importer
}
} else {
$content = $part->getContent();
$encoding = null;
if (isset($part->contentTransferEncoding)) {
$cteHeader = $part->getHeader('Content-Transfer-Encoding');
$encoding = strtolower($cteHeader->getTransferEncoding());
}
if ($encoding == 'base64') {
$content = base64_decode($content);
}
$charset = 'UTF-8';
if (isset($part->contentType)) {
$ctHeader = $part->getHeader('Content-Type');
$charsetParamValue = $ctHeader->getParameter('charset');
@@ -292,17 +372,17 @@ class Importer
$charset = strtoupper($charsetParamValue);
}
}
if ($charset !== 'UTF-8') {
$content = mb_convert_encoding($content, 'UTF-8', $charset);
}
if (isset($part->contentTransferEncoding)) {
$cteHeader = $part->getHeader('Content-Transfer-Encoding');
if ($cteHeader->getTransferEncoding() == 'quoted-printable') {
$content = quoted_printable_decode($content);
}
}
if ($charset !== 'UTF-8') {
$content = mb_convert_encoding($content, 'UTF-8', $charset);
}
}
return $content;
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Espo\Core\Mail\Mail;
use ArrayIterator;
use Countable;
use Iterator;
use Traversable;
use Zend\Loader\PluginClassLocator;
class Headers extends \Zend\Mail\Headers
{
public static function fromString($string, $EOL = self::EOL)
{
$headers = new static();
$currentLine = '';
// iterate the header lines, some might be continuations
foreach (explode($EOL, $string) as $line) {
// check if a header name is present
if (preg_match('/^(?P<name>[\x21-\x39\x3B-\x7E]+):.*$/', $line, $matches)) {
if ($currentLine) {
// a header name was present, then store the current complete line
$headers->addHeaderLine($currentLine);
}
$currentLine = trim($line);
} elseif (preg_match('/^\s+.*$/', $line, $matches)) {
// continuation: append to current line
$currentLine .= $line;
} elseif (preg_match('/^\s*$/', $line)) {
// empty line indicates end of headers
break;
} else {
// Line does not match header format!
throw new Exception\RuntimeException(sprintf(
'Line "%s"does not match header format!',
$line
));
}
}
if ($currentLine) {
$headers->addHeaderLine($currentLine);
}
return $headers;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php
/************************************************************************
* This file is part of EspoCRM.
*
@@ -20,20 +20,22 @@
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Mail\Storage;
namespace Espo\Core\Mail\Mail\Storage;
class Imap extends \Zend\Mail\Storage\Imap
{
{
protected $messageClass = '\\Espo\\Core\\Mail\\Mail\\Storage\\Message';
public function getIdsFromUID($uid)
{
$uid = intval($uid) + 1;
return $this->protocol->search(array('UID ' . $uid . ':*'));
}
public function getIdsFromDate($date)
{
{
return $this->protocol->search(array('SINCE "' . $date . '"'));
}
}

View File

@@ -0,0 +1,155 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Mail\Mail\Storage;
use Espo\Core\Mail\Mail\Headers;
use Zend\Mail\Header\HeaderInterface;
use Zend\Mime;
use Zend\Mail\Storage\Exception;
use Zend\Mail\Storage\AbstractStorage;
class Message extends \Zend\Mail\Storage\Message
{
public function __construct(array $params)
{
if (isset($params['file'])) {
if (!is_resource($params['file'])) {
ErrorHandler::start();
$params['raw'] = file_get_contents($params['file']);
$error = ErrorHandler::stop();
if ($params['raw'] === false) {
throw new Exception\RuntimeException('could not open file', 0, $error);
}
} else {
$params['raw'] = stream_get_contents($params['file']);
}
}
if (!empty($params['flags'])) {
// set key and value to the same value for easy lookup
$this->flags = array_combine($params['flags'], $params['flags']);
}
if (isset($params['handler'])) {
if (!$params['handler'] instanceof AbstractStorage) {
throw new Exception\InvalidArgumentException('handler is not a valid mail handler');
}
if (!isset($params['id'])) {
throw new Exception\InvalidArgumentException('need a message id with a handler');
}
$this->mail = $params['handler'];
$this->messageNum = $params['id'];
}
$params['strict'] = isset($params['strict']) ? $params['strict'] : false;
if (isset($params['raw'])) {
self::splitMessage($params['raw'], $this->headers, $this->content, Mime\Mime::LINEEND, $params['strict']);
} elseif (isset($params['headers'])) {
if (is_array($params['headers'])) {
$this->headers = new Headers();
$this->headers->addHeaders($params['headers']);
} else {
if ($params['headers'] instanceof \Zend\Mail\Headers) {
$this->headers = $params['headers'];
} else {
if (empty($params['noToplines'])) {
self::splitMessage($params['headers'], $this->headers, $this->topLines);
} else {
$this->headers = Headers::fromString($params['headers']);
}
}
}
if (isset($params['content'])) {
$this->content = $params['content'];
}
}
}
public function __isset($name)
{
$headers = $this->getHeaders();
if (empty($headers) || !is_object($headers)) {
return false;
}
return $this->getHeaders()->has($name);
}
public function isMultipart()
{
if (!isset($this->contentType)) {
return false;
}
try {
return stripos($this->contentType, 'multipart/') === 0;
} catch (Exception\ExceptionInterface $e) {
return false;
}
}
public static function splitMessage($message, &$headers, &$body, $EOL = Mime\Mime::LINEEND, $strict = false)
{
if ($message instanceof Headers) {
$message = $message->toString();
}
// check for valid header at first line
$firstline = strtok($message, "\n");
if (!preg_match('%^[^\s]+[^:]*:%', $firstline)) {
$headers = array();
// TODO: we're ignoring \r for now - is this function fast enough and is it safe to assume noone needs \r?
$body = str_replace(array("\r", "\n"), array('', $EOL), $message);
return;
}
// see @ZF2-372, pops the first line off a message if it doesn't contain a header
if (!$strict) {
$parts = explode(':', $firstline, 2);
if (count($parts) != 2) {
$message = substr($message, strpos($message, $EOL)+1);
}
}
// find an empty line between headers and body
// default is set new line
if (strpos($message, $EOL . $EOL)) {
list($headers, $body) = explode($EOL . $EOL, $message, 2);
// next is the standard new line
} elseif ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) {
list($headers, $body) = explode("\r\n\r\n", $message, 2);
// next is the other "standard" new line
} elseif ($EOL != "\n" && strpos($message, "\n\n")) {
list($headers, $body) = explode("\n\n", $message, 2);
// at last resort find anything that looks like a new line
} else {
ErrorHandler::start(E_NOTICE|E_WARNING);
list($headers, $body) = preg_split("%([\r\n]+)\\1%U", $message, 2);
ErrorHandler::stop();
}
$headers = Headers::fromString($headers, $EOL);
}
}

View File

@@ -68,7 +68,7 @@ class Sender
$this->params = $params;
$this->transport = new SmtpTransport();
$opts = array(
'name' => 'admin',
'host' => $params['server'],
@@ -83,14 +83,14 @@ class Sender
if ($params['security']) {
$opts['connection_config']['ssl'] = strtolower($params['security']);
}
if (in_array('fromName', $params)) {
$this->params['fromName'] = $params['fromName'];
}
if (in_array('fromAddress', $params)) {
$this->params['fromAddress'] = $params['fromAddress'];
}
$options = new SmtpOptions($opts);
$this->transport->setOptions($options);
@@ -160,10 +160,14 @@ class Sender
} else {
$fromName = $config->get('outboundEmailFromName');
}
$message->addFrom($fromAddress, $fromName);
}
if (!$email->get('from')) {
$email->set('from', $fromAddress);
}
if (!empty($params['replyToAddress'])) {
$replyToName = null;
if (!empty($params['replyToName'])) {
@@ -203,7 +207,6 @@ class Sender
}
$attachmentPartList = array();
$attachmentCollection = $email->get('attachments');
$attachmentInlineCollection = $email->getInlineAttachments();
@@ -220,7 +223,7 @@ class Sender
$attachmentPartList[] = $attachment;
}
}
if (!empty($attachmentInlineCollection)) {
foreach ($attachmentInlineCollection as $a) {
$fileName = 'data/upload/' . $a->id;
@@ -239,12 +242,12 @@ class Sender
$message->setSubject($email->get('name'));
$body = new MimeMessage();
$textPart = new MimePart($email->getBodyPlainForSending());
$textPart->type = 'text/plain';
$textPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$textPart->charset = 'utf-8';
if ($email->get('isHtml')) {
$htmlPart = new MimePart($email->getBodyForSending());
$htmlPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
@@ -285,9 +288,19 @@ class Sender
$message->setBody($body);
if ($message->getHeaders()->has('content-type')) {
if ($messageType == 'text/plain') {
if ($message->getHeaders()->has('content-type')) {
$message->getHeaders()->removeHeader('content-type');
}
$message->getHeaders()->addHeaderLine('Content-Type', 'text/plain; charset=UTF-8');
} else {
if (!$message->getHeaders()->has('content-type')) {
$contentTypeHeader = new \Zend\Mail\Header\ContentType();
$message->getHeaders()->addHeader($contentTypeHeader);
}
$message->getHeaders()->get('content-type')->setType($messageType);
}
$message->setEncoding('UTF-8');
try {
@@ -305,7 +318,7 @@ class Sender
$this->transport->send($message);
$email->set('messageId', $messageId);
$email->set('messageId', '<' . $messageId . '>');
$email->set('status', 'Sent');
$email->set('dateSent', date("Y-m-d H:i:s"));
} catch (\Exception $e) {

View File

@@ -0,0 +1,103 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Notificators;
use \Espo\Core\Interfaces\Injectable;
use \Espo\ORM\Entity;
class Base implements Injectable
{
protected $dependencies = array(
'user',
'entityManager',
);
protected $injections = array();
public static $order = 9;
public function __construct()
{
$this->init();
}
protected function init()
{
}
protected function addDependency($name)
{
$this->dependencies[] = $name;
}
public function getDependencyList()
{
return $this->dependencies;
}
protected function getInjection($name)
{
return $this->injections[$name];
}
public function inject($name, $object)
{
$this->injections[$name] = $object;
}
protected function getEntityManager()
{
return $this->injections['entityManager'];
}
protected function getUser()
{
return $this->injections['user'];
}
public function process(Entity $entity)
{
if ($entity->has('assignedUserId') && $entity->get('assignedUserId')) {
$assignedUserId = $entity->get('assignedUserId');
if ($assignedUserId != $this->getUser()->id && $entity->isFieldChanged('assignedUserId')) {
$notification = $this->getEntityManager()->getEntity('Notification');
$notification->set(array(
'type' => 'Assign',
'userId' => $assignedUserId,
'data' => array(
'entityType' => $entity->getEntityType(),
'entityId' => $entity->id,
'entityName' => $entity->get('name'),
'isNew' => $entity->isNew(),
'userId' => $this->getUser()->id,
'userName' => $this->getUser()->get('name')
)
));
$this->getEntityManager()->saveEntity($notification);
}
}
}
}

View File

@@ -41,17 +41,20 @@ class Entity extends \Espo\ORM\Entity
$columnsData = new \stdClass();
}
foreach ($collection as $e) {
$id = $e->id;
$ids[] = $id;
$names->$id = $e->get('name');
if (!empty($columns)) {
$columnsData->$id = new \stdClass();
foreach ($columns as $column => $f) {
$columnsData->$id->$column = $e->get($f);
if ($collection) {
foreach ($collection as $e) {
$id = $e->id;
$ids[] = $id;
$names->$id = $e->get('name');
if (!empty($columns)) {
$columnsData->$id = new \stdClass();
foreach ($columns as $column => $f) {
$columnsData->$id->$column = $e->get($f);
}
}
}
}
$this->set($field . 'Ids', $ids);
$this->set($field . 'Names', $names);
if (!empty($columns)) {

View File

@@ -38,6 +38,8 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
protected $injections = array();
private $restoreData = null;
public function inject($name, $object)
{
$this->injections[$name] = $object;
@@ -79,6 +81,9 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
foreach ($defs['fields'] as $field => $d) {
if (isset($d['type']) && $d['type'] == 'currency') {
if (!empty($d['notStorable'])) {
continue;
}
if (empty($params['customJoin'])) {
$params['customJoin'] = '';
}
@@ -135,49 +140,65 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
}
}
protected function beforeRemove(Entity $entity)
protected function beforeRemove(Entity $entity, array $options = array())
{
parent::beforeRemove($entity);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeRemove', $entity);
parent::beforeRemove($entity, $options);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeRemove', $entity, $options);
$nowString = date('Y-m-d H:i:s', time());
if ($entity->hasField('modifiedAt')) {
$entity->set('modifiedAt', $nowString);
}
if ($entity->hasField('modifiedById')) {
$entity->set('modifiedById', $this->getEntityManager()->getUser()->id);
}
}
protected function afterRemove(Entity $entity)
protected function afterRemove(Entity $entity, array $options = array())
{
parent::afterRemove($entity);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity);
parent::afterRemove($entity, $options);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity, $options);
}
public function remove(Entity $entity)
public function remove(Entity $entity, array $options = array())
{
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeRemove', $entity);
$result = parent::remove($entity);
$result = parent::remove($entity, $options);
if ($result) {
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity, $options);
}
return $result;
}
protected function beforeSave(Entity $entity)
protected function beforeSave(Entity $entity, array $options = array())
{
parent::beforeSave($entity);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeSave', $entity);
parent::beforeSave($entity, $options);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeSave', $entity, $options);
}
protected function afterSave(Entity $entity)
protected function afterSave(Entity $entity, array $options = array())
{
parent::afterSave($entity);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterSave', $entity);
if (!empty($this->restoreData)) {
$entity->set($this->restoreData);
$this->restoreData = null;
}
parent::afterSave($entity, $options);
$this->handleEmailAddressSave($entity);
$this->handlePhoneNumberSave($entity);
$this->handleSpecifiedRelations($entity);
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterSave', $entity, $options);
}
public function save(Entity $entity)
public function save(Entity $entity, array $options = array())
{
$nowString = date('Y-m-d H:i:s', time());
$restoreData = array();
if ($entity->isNew()) {
if (!$entity->has('id')) {
$entity->set('id', uniqid());
$entity->set('id', Util::generateId());
}
if ($entity->hasField('createdAt')) {
@@ -198,11 +219,13 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
}
$entity->clear('modifiedById');
} else {
if ($entity->hasField('modifiedAt')) {
$entity->set('modifiedAt', $nowString);
}
if ($entity->hasField('modifiedById')) {
$entity->set('modifiedById', $this->entityManager->getUser()->id);
if (empty($options['silent'])) {
if ($entity->hasField('modifiedAt')) {
$entity->set('modifiedAt', $nowString);
}
if ($entity->hasField('modifiedById')) {
$entity->set('modifiedById', $this->entityManager->getUser()->id);
}
}
if ($entity->has('createdById')) {
@@ -214,13 +237,9 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
$entity->clear('createdById');
$entity->clear('createdAt');
}
$result = parent::save($entity);
$this->restoreData = $restoreData;
$entity->set($restoreData);
$this->handleEmailAddressSave($entity);
$this->handlePhoneNumberSave($entity);
$this->handleSpecifiedRelations($entity);
$result = parent::save($entity, $options);
return $result;
}
@@ -249,6 +268,10 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
if ($entity->has($fieldName) || $entity->has($columnsFieldsName)) {
if ($this->getMetadata()->get("entityDefs." . $entity->getEntityType() . ".fields.{$name}.noSave")) {
continue;
}
if ($entity->has($fieldName)) {
$specifiedIds = $entity->get($fieldName);
} else {
@@ -264,24 +287,36 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
$existingColumnsData = new \stdClass();
$defs = array();
$columns = $this->getMetadata()->get("entityDefs." . $entity->getEntityName() . ".fields.{$name}.columns");
$columns = $this->getMetadata()->get("entityDefs." . $entity->getEntityType() . ".fields.{$name}.columns");
if (!empty($columns)) {
$columnData = $entity->get($columnsFieldsName);
$defs['additionalColumns'] = $columns;
}
foreach ($entity->get($name, $defs) as $foreignEntity) {
$existingIds[] = $foreignEntity->id;
if (!empty($columns)) {
$data = new \stdClass();
foreach ($columns as $columnName => $columnField) {
$foreignId = $foreignEntity->id;
$data->$columnName = $foreignEntity->get($columnField);
$foreignCollection = $entity->get($name, $defs);
if ($foreignCollection) {
foreach ($foreignCollection as $foreignEntity) {
$existingIds[] = $foreignEntity->id;
if (!empty($columns)) {
$data = new \stdClass();
foreach ($columns as $columnName => $columnField) {
$foreignId = $foreignEntity->id;
$data->$columnName = $foreignEntity->get($columnField);
}
$existingColumnsData->$foreignId = $data;
$entity->setFetched($columnsFieldsName, $existingColumnsData);
}
$existingColumnsData->$foreignId = $data;
}
}
}
if ($entity->has($fieldName)) {
$entity->setFetched($fieldName, $existingIds);
}
if ($entity->has($columnsFieldsName) && !empty($columns)) {
$entity->setFetched($columnsFieldsName, $existingColumnsData);
}
foreach ($existingIds as $id) {
if (!in_array($id, $specifiedIds)) {
$toRemoveIds[] = $id;
@@ -295,10 +330,12 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
}
}
}
foreach ($specifiedIds as $id) {
if (!in_array($id, $existingIds)) {
$data = null;
if (!empty($columns)) {
if (!empty($columns) && isset($columnData->$id)) {
$data = $columnData->$id;
}
$this->relate($entity, $name, $id, $data);

View File

@@ -0,0 +1,95 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Repositories;
use \Espo\Core\Entities\CategoryTreeItem as Entity;
class CategoryTree extends \Espo\Core\ORM\Repositories\RDB
{
public function afterSave(Entity $entity, $options)
{
parent::afterSave($entity, $options);
$pdo = $this->getEntityManager()->getPDO();
$query = $this->getEntityManager()->getQuery();
$parentId = $entity->get('parentId');
$pathsTableName = $query->toDb($entity->getEntityType() . 'Path');
if ($entity->isNew()) {
if ($parentId) {
$sql = "
INSERT INTO `".$pathsTableName."` (ascendor_id, descendor_id)
SELECT ascendor_id, ".$pdo->quote($entity->id)."
FROM `".$pathsTableName."`
WHERE descendor_id = ".$pdo->quote($parentId)."
UNION ALL
SELECT ".$pdo->quote($entity->id).", ".$pdo->quote($entity->id)."
";
} else {
$sql = "
INSERT INTO `".$pathsTableName."` (ascendor_id, descendor_id)
VALUES
(".$pdo->quote($entity->id).", ".$pdo->quote($entity->id).")
";
}
$pdo->query($sql);
} else {
if ($entity->isFieldChanged('parentId')) {
$sql = "
DELETE a FROM `".$pathsTableName."` AS a
JOIN `".$pathsTableName."` AS d ON a.descendor_id = d.descendor_id
LEFT JOIN `".$pathsTableName."` AS x ON x.ascendor_id = d.ascendor_id AND x.descendor_id = a.ascendor_id
WHERE d.ascendor_id = ".$pdo->quote($entity->id)." AND x.ascendor_id IS NULL
";
$pdo->query($sql);
if (!empty($parentId)) {
$sql = "
INSERT INTO `".$pathsTableName."` (ascendor_id, descendor_id)
SELECT supertree.ascendor_id, subtree.descendor_id
FROM `".$pathsTableName."` AS supertree
JOIN `".$pathsTableName."` AS subtree
WHERE
subtree.ascendor_id = ".$pdo->quote($entity->id)." AND
supertree.descendor_id = ".$pdo->quote($parentId)."
";
$pdo->query($sql);
}
}
}
}
public function afterRemove(Entity $entity, $options)
{
parent::afterRemove($entity, $options);
$pdo = $this->getEntityManager()->getPDO();
$query = $this->getEntityManager()->getQuery();
$pathsTableName = $query->toDb($entity->getEntityType() . 'Path');
$sql = "DELETE FROM `".$pathsTableName."` WHERE descendor_id = ".$pdo->quote($entity->id)."";
$pdo->query($sql);
}
}

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Core;
@@ -29,11 +29,11 @@ use \Espo\Core\Utils\Util;
class SelectManagerFactory
{
private $entityManager;
private $user;
private $acl;
private $metadata;
public function __construct($entityManager, \Espo\Entities\User $user, Acl $acl, $metadata)
@@ -43,26 +43,28 @@ class SelectManagerFactory
$this->acl = $acl;
$this->metadata = $metadata;
}
public function create($entityName)
public function create($entityType)
{
$className = '\\Espo\\Custom\\SelectManagers\\' . Util::normilizeClassName($entityName);
$normalizedName = Util::normilizeClassName($entityType);
$className = '\\Espo\\Custom\\SelectManagers\\' . $normalizedName;
if (!class_exists($className)) {
$moduleName = $this->metadata->getScopeModuleName($entityName);
$moduleName = $this->metadata->getScopeModuleName($entityType);
if ($moduleName) {
$className = '\\Espo\\Modules\\' . $moduleName . '\\SelectManagers\\' . Util::normilizeClassName($entityName);
$className = '\\Espo\\Modules\\' . $moduleName . '\\SelectManagers\\' . $normalizedName;
} else {
$className = '\\Espo\\SelectManagers\\' . Util::normilizeClassName($entityName);
}
$className = '\\Espo\\SelectManagers\\' . $normalizedName;
}
if (!class_exists($className)) {
$className = '\\Espo\\Core\\SelectManagers\\Base';
}
}
$selectManager = new $className($this->entityManager, $this->user, $this->acl, $this->metadata);
$selectManager->setEntityName($entityName);
$selectManager->setEntityType($entityType);
return $selectManager;
}
}
}

View File

@@ -36,12 +36,14 @@ class Base
protected $entityManager;
protected $entityName;
protected $entityType;
protected $metadata;
private $seed = null;
private $userTimeZone = null;
const MIN_LENGTH_FOR_CONTENT_SEARCH = 4;
public function __construct($entityManager, \Espo\Entities\User $user, Acl $acl, $metadata)
@@ -49,12 +51,28 @@ class Base
$this->entityManager = $entityManager;
$this->user = $user;
$this->acl = $acl;
$this->metadata = $metadata;
}
public function setEntityName($entityName)
protected function getEntityManager()
{
$this->entityName = $entityName;
return $this->entityManager;
}
protected function getUser()
{
return $this->user;
}
public function setEntityType($entityType)
{
$this->entityType = $entityType;
}
protected function getEntityType()
{
return $this->entityType;
}
protected function limit($params, &$result)
@@ -71,7 +89,7 @@ class Base
{
if (!empty($params['sortBy'])) {
$result['orderBy'] = $params['sortBy'];
$type = $this->metadata->get("entityDefs.{$this->entityName}.fields." . $result['orderBy'] . ".type");
$type = $this->metadata->get("entityDefs.{$this->entityType}.fields." . $result['orderBy'] . ".type");
if ($type == 'link') {
$result['orderBy'] .= 'Name';
} else if ($type == 'linkParent') {
@@ -89,57 +107,67 @@ class Base
protected function getTextFilterFields()
{
return $this->metadata->get("entityDefs.{$this->entityName}.collection.textFilterFields", array('name'));
return $this->metadata->get("entityDefs.{$this->entityType}.collection.textFilterFields", array('name'));
}
protected function getSeed()
{
if (empty($this->seed)) {
$this->seed = $this->entityManager->getEntity($this->entityName);
$this->seed = $this->entityManager->getEntity($this->entityType);
}
return $this->seed;
}
protected function textFilter($value, &$result)
{
$fieldDefs = $this->getSeed()->getFields();
$fieldList = $this->getTextFilterFields();
$d = array();
foreach ($fieldList as $field) {
if (
strlen($item['value']) >= self::MIN_LENGTH_FOR_CONTENT_SEARCH
&&
!empty($fieldDefs[$field]['type']) && $fieldDefs[$field]['type'] == 'text'
) {
$d[$field . '*'] = '%' . $value . '%';
} else {
$d[$field . '*'] = $value . '%';
}
}
$result['whereClause'][] = array(
'OR' => $d
);
}
protected function where($params, &$result)
{
if (!empty($params['where']) && is_array($params['where'])) {
$where = array();
foreach ($params['where'] as $item) {
if ($item['type'] == 'boolFilters' && !empty($item['value']) && is_array($item['value'])) {
if ($item['type'] == 'bool' && !empty($item['value']) && is_array($item['value'])) {
foreach ($item['value'] as $filter) {
$p = $this->getBoolFilterWhere($filter);
if (!empty($p)) {
$params['where'][] = $p;
}
$this->boolFilter($filter, $result);
}
} else if ($item['type'] == 'textFilter' && !empty($item['value'])) {
if (!empty($item['value'])) {
if (empty($result['whereClause'])) {
$result['whereClause'] = array();
}
$fieldDefs = $this->getSeed()->getFields();
$fieldList = $this->getTextFilterFields();
$d = array();
foreach ($fieldList as $field) {
if (
strlen($item['value']) >= self::MIN_LENGTH_FOR_CONTENT_SEARCH
&&
!empty($fieldDefs[$field]['type']) && $fieldDefs[$field]['type'] == 'text'
) {
$d[$field . '*'] = '%' . $item['value'] . '%';
} else {
$d[$field . '*'] = $item['value'] . '%';
}
}
$where['OR'] = $d;
$this->textFilter($item['value'], $result);
}
} else if ($item['type'] == 'primary' && !empty($item['value'])) {
$this->primaryFilter($item['value'], $result);
}
}
$linkedWith = array();
$ignoreList = array('linkedWith', 'boolFilters');
foreach ($params['where'] as $item) {
$inCategory = array();
$ignoreList = ['linkedWith', 'inCategory', 'bool', 'primary'];
foreach ($params['where'] as $item) {
if (!in_array($item['type'], $ignoreList)) {
$part = $this->getWherePart($item);
if (!empty($part)) {
@@ -148,61 +176,119 @@ class Base
} else {
if ($item['type'] == 'linkedWith' && !empty($item['value'])) {
$linkedWith[$item['field']] = $item['value'];
} else if ($item['type'] == 'inCategory' && !empty($item['value'])) {
$inCategory[$item['field']] = $item['value'];
}
}
}
$result['whereClause'] = array_merge($result['whereClause'], $where);
if (!empty($linkedWith)) {
$joins = array();
$this->handleLinkedWith($linkedWith, $result);
}
if (!empty($inCategory)) {
$this->handleInCategory($inCategory, $result);
}
}
}
$part = array();
foreach ($linkedWith as $link => $idsValue) {
if (is_array($idsValue) && count($idsValue) == 1) {
$idsValue = $idsValue[0];
}
$relDefs = $this->getSeed()->getRelations();
if (!empty($relDefs[$link])) {
$defs = $relDefs[$link];
if ($defs['type'] == 'manyMany') {
$joins[] = $link;
if (!empty($defs['relationName']) && !empty($defs['midKeys'])) {
$key = $defs['midKeys'][1];
$relationName = $defs['relationName'];
$part[$relationName . '.' . $key] = $idsValue;
}
} else if ($defs['type'] == 'belongsTo') {
if (!empty($defs['type']['key'])) {
$key = $defs['type']['key'];
$part[$key] = $idsValue;
}
}
}
}
if (!empty($part)) {
$where[] = $part;
}
$result['joins'] = $joins;
$result['distinct'] = true;
protected function handleLinkedWith($linkedWith, &$result)
{
$joins = [];
$part = array();
foreach ($linkedWith as $link => $idsValue) {
if (is_array($idsValue) && count($idsValue) == 1) {
$idsValue = $idsValue[0];
}
$result['whereClause'] = $where;
$relDefs = $this->getSeed()->getRelations();
if (!empty($relDefs[$link])) {
$defs = $relDefs[$link];
if ($defs['type'] == 'manyMany') {
$joins[] = $link;
if (!empty($defs['midKeys'])) {
$key = $defs['midKeys'][1];
$part[$link . 'Middle.' . $key] = $idsValue;
}
} else if ($defs['type'] == 'belongsTo') {
if (!empty($defs['key'])) {
$key = $defs['key'];
$part[$key] = $idsValue;
}
}
}
}
if (!empty($part)) {
$result['whereClause'][] = $part;
}
$result['joins'] = array_merge($result['joins'], $joins);
$result['distinct'] = true;
}
protected function handleInCategory($inCategory, &$result)
{
$joins = [];
$part = array();
$query = $this->getEntityManager()->getQuery();
$tableName = $query->toDb($this->getSeed()->getEntityType());
foreach ($inCategory as $link => $val) {
$relDefs = $this->getSeed()->getRelations();
if (!empty($relDefs[$link])) {
$defs = $relDefs[$link];
$foreignEntity = $defs['entity'];
if (empty($foreignEntity)) {
continue;
}
$pathName = lcfirst($query->sanitize($foreignEntity . 'Path'));
if ($defs['type'] == 'manyMany') {
if (!empty($defs['relationName']) && !empty($defs['midKeys'])) {
$result['distinct'] = true;
$result['joins'][] = $link;
$key = $defs['midKeys'][1];
$relationName = lcfirst($defs['relationName']);
$result['customJoin'] .= "
JOIN " . $query->toDb($pathName) . " AS `{$pathName}` ON {$pathName}.descendor_id = ".$query->sanitize($relationName) . "." . $query->toDb($key) . "
";
$part[$pathName . '.ascendorId'] = $val;
}
} else if ($defs['type'] == 'belongsTo') {
if (!empty($defs['key'])) {
$key = $defs['key'];
$result['customJoin'] .= "
JOIN " . $query->toDb($pathName) . " AS `{$pathName}` ON {$pathName}.descendor_id = {$tableName}." . $query->toDb($key) . "
";
$part[$pathName . '.ascendorId'] = $val;
}
}
}
}
if (!empty($part)) {
$result['whereClause'][] = $part;
}
}
protected function q($params, &$result)
{
if (!empty($params['q'])) {
if (empty($result['whereClause'])) {
$result['whereClause'] = array();
}
$fieldDefs = $this->getSeed()->getFields();
$value = $params['q'];
@@ -221,38 +307,49 @@ class Base
}
}
$result['whereClause']['OR'] = $d;
$result['whereClause'][] = array(
'OR' => $d
);
}
}
protected function access(&$result)
{
if ($this->acl->checkReadOnlyOwn($this->entityName)) {
if (!array_key_exists('whereClause', $result)) {
$result['whereClause'] = array();
}
$result['whereClause']['assignedUserId'] = $this->user->id;
if ($this->acl->checkReadOnlyOwn($this->entityType)) {
$this->accessOnlyOwn($result);
}
if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityName)) {
if (!array_key_exists('whereClause', $result)) {
$result['whereClause'] = array();
}
$result['distinct'] = true;
if (!array_key_exists('joins', $result)) {
$result['joins'] = array();
}
if (!in_array('teams', $result['joins'])) {
$result['leftJoins'][] = 'teams';
}
$result['whereClause']['OR'] = array(
'Team.id' => $this->user->get('teamsIds'),
'assignedUserId' => $this->user->id
);
if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityType)) {
$this->accessOnlyTeam($result);
}
}
protected function accessOnlyOwn(&$result)
{
if (!$this->getSeed()->hasField('assignedUserId')) {
return;
}
$result['whereClause'][] = array(
'assignedUserId' => $this->getUser()->id
);
}
protected function accessOnlyTeam(&$result)
{
if (!$this->getSeed()->hasField('teamsIds')) {
return;
}
$result['distinct'] = true;
if (!in_array('teams', $result['joins'])) {
$result['leftJoins'][] = 'teams';
}
$result['whereClause'][] = array(
'OR' => array(
'teams.id' => $this->user->get('teamsIds'),
'assignedUserId' => $this->getUser()->id
)
);
}
public function getAclParams()
{
$result = array();
@@ -262,7 +359,12 @@ class Base
public function getSelectParams(array $params, $withAcl = false)
{
$result = array();
$result = array(
'joins' => [],
'leftJoins' => [],
'whereClause' => [],
'customJoin' => ''
);
$this->order($params, $result);
$this->limit($params, $result);
@@ -276,10 +378,121 @@ class Base
return $result;
}
protected function getUserTimeZone()
{
if (empty($this->userTimeZone)) {
$preferences = $this->getEntityManager()->getEntity('Preferences', $this->getUser()->id);
$timeZone = $preferences->get('timeZone');
$this->userTimeZone = $timeZone;
}
return $this->userTimeZone;
}
protected function convertDateTimeWhere($item)
{
$format = 'Y-m-d H:i:s';
$value = null;
$timeZone = 'UTC';
if (empty($item['field'])) {
return null;
}
if (empty($item['type'])) {
return null;
}
if (!empty($item['value'])) {
$value = $item['value'];
}
if (!empty($item['timeZone'])) {
$timeZone = $item['timeZone'];
}
$type = $item['type'];
$field = $item['field'];
if (empty($value) && in_array($type, array('on', 'before', 'after'))) {
return null;
}
$where = array();
$where['field'] = $field;
$dt = new \DateTime('now', new \DateTimeZone($timeZone));
switch ($type) {
case 'today':
$where['type'] = 'between';
$dt->setTime(0, 0, 0);
$dt->setTimezone(new \DateTimeZone('UTC'));
$from = $dt->format($format);
$dt->modify('+1 day');
$to = $dt->format($format);
$where['value'] = [$from, $to];
break;
case 'past':
$where['type'] = 'before';
$dt->setTimezone(new \DateTimeZone('UTC'));
$where['value'] = $dt->format($format);
break;
case 'future':
$where['type'] = 'after';
$dt->setTimezone(new \DateTimeZone('UTC'));
$where['value'] = $dt->format($format);
break;
case 'on':
$where['type'] = 'between';
$dt = new \DateTime($value, new \DateTimeZone($timeZone));
$dt->setTimezone(new \DateTimeZone('UTC'));
$from = $dt->format($format);
$dt->modify('+1 day');
$to = $dt->format($format);
$where['value'] = [$from, $to];
break;
case 'before':
$where['type'] = 'before';
$dt = new \DateTime($value, new \DateTimeZone($timeZone));
$dt->setTimezone(new \DateTimeZone('UTC'));
$where['value'] = $dt->format($format);
break;
case 'after':
$where['type'] = 'after';
$dt = new \DateTime($value, new \DateTimeZone($timeZone));
$dt->setTimezone(new \DateTimeZone('UTC'));
$where['value'] = $dt->format($format);
break;
case 'between':
$where['type'] = 'between';
if (is_array($value)) {
$dt = new \DateTime($value[0], new \DateTimeZone($timeZone));
$dt->setTimezone(new \DateTimeZone('UTC'));
$from = $dt->format($format);
$dt = new \DateTime($value[1], new \DateTimeZone($timeZone));
$dt->setTimezone(new \DateTimeZone('UTC'));
$to = $dt->format($format);
$where['value'] = [$from, $to];
}
break;
default:
$where['type'] = $type;
}
$result = $this->getWherePart($where);
return $result;
}
protected function getWherePart($item)
{
$part = array();
if (!empty($item['dateTime'])) {
return $this->convertDateTimeWhere($item);
}
if (!empty($item['type'])) {
switch ($item['type']) {
case 'or':
@@ -304,6 +517,12 @@ class Base
case 'on':
$part[$item['field'] . '='] = $item['value'];
break;
case 'startsWith':
$part[$item['field'] . '*'] = $item['value'] . '%';
break;
case 'contains':
$part[$item['field'] . '*'] = '%' . $item['value'] . '%';
break;
case 'notEquals':
case 'notOn':
$part[$item['field'] . '!='] = $item['value'];
@@ -328,6 +547,12 @@ class Base
case 'notIn':
$part[$item['field'] . '!='] = $item['value'];
break;
case 'isNull':
$part[$item['field'] . '='] = null;
break;
case 'isNotNull':
$part[$item['field'] . '!='] = null;
break;
case 'isTrue':
$part[$item['field'] . '='] = true;
break;
@@ -341,7 +566,7 @@ class Base
$part[$item['field'] . '<'] = date('Y-m-d');
break;
case 'future':
$part[$item['field'] . '>'] = date('Y-m-d');
$part[$item['field'] . '>='] = date('Y-m-d');
break;
case 'currentMonth':
$dt = new \DateTime();
@@ -408,6 +633,22 @@ class Base
return $part;
}
protected function boolFilter($filterName, &$result)
{
$method = 'boolFilter' . ucfirst($filterName);
if (method_exists($this, $method)) {
$this->$method($result);
}
}
protected function primaryFilter($filterName, &$result)
{
$method = 'filter' . ucfirst($filterName);
if (method_exists($this, $method)) {
$this->$method($result);
}
}
protected function getBoolFilterWhere($filterName)
{
$method = 'getBoolFilterWhere' . ucfirst($filterName);
@@ -416,13 +657,27 @@ class Base
}
}
protected function getBoolFilterWhereOnlyMy()
protected function boolFilterOnlyMy(&$result)
{
return array(
'type' => 'equals',
'field' => 'assignedUserId',
'value' => $this->user->id,
$result['whereClause'][] = array(
'assignedUserId' => $this->getUser()->id
);
}
protected function filterFollowed(&$result)
{
$query = $this->getEntityManager()->getQuery();
$result['customJoin'] .= "
JOIN subscription ON
subscription.entity_type = ".$query->quote($this->getEntityType())." AND
subscription.entity_id = ".$query->toDb($this->getEntityType()).".id AND
subscription.user_id = ".$query->quote($this->getUser()->id)."
";
}
protected function boolFilterFollowed(&$result)
{
$this->filterFollowed($result);
}
}

View File

@@ -48,31 +48,6 @@ class ServiceFactory
$this->container = $container;
}
protected function init()
{
$config = $this->getContainer()->get('config');
if (file_exists($this->cacheFile) && $config->get('useCache')) {
$this->data = $this->getFileManager()->getContents($this->cacheFile);
} else {
$this->data = $this->getClassNameHash($this->paths['corePath']);
foreach ($this->getContainer()->get('metadata')->getModuleList() as $moduleName) {
$path = str_replace('{*}', $moduleName, $this->paths['modulePath']);
$this->data = array_merge($this->data, $this->getClassNameHash($path));
}
$this->data = array_merge($this->data, $this->getClassNameHash($this->paths['customPath']));
if ($config->get('useCache')) {
$result = $this->getFileManager()->putContentsPHP($this->cacheFile, $this->data);
if ($result == false) {
throw new \Espo\Core\Exceptions\Error();
}
}
}
}
protected function getFileManager()
{
return $this->container->get('fileManager');
@@ -83,15 +58,19 @@ class ServiceFactory
return $this->container;
}
protected function init()
{
$classParser = $this->getContainer()->get('classParser');
$classParser->setAllowedMethods(null);
$this->data = $classParser->getData($this->paths, $this->cacheFile);
}
protected function getClassName($name)
{
$name = Util::normilizeClassName($name);
if (!isset($this->data)) {
$this->init();
}
$name = ucfirst($name);
if (isset($this->data[$name])) {
return $this->data[$name];
}
@@ -127,28 +106,5 @@ class ServiceFactory
}
throw new Error("Class '$className' does not exist");
}
// TODO delegate to another class
protected function getClassNameHash($dirs)
{
if (is_string($dirs)) {
$dirs = (array) $dirs;
}
$data = array();
foreach ($dirs as $dir) {
if (file_exists($dir)) {
$fileList = $this->getFileManager()->getFileList($dir, false, '\.php$', true);
foreach ($fileList as $file) {
$filePath = Util::concatPath($dir, $file);
$className = Util::getClassName($filePath);
$fileName = $this->getFileManager()->getFileName($filePath);
$data[$fileName] = $className;
}
}
}
return $data;
}
}

View File

@@ -53,6 +53,11 @@ abstract class Base implements Injectable
return $this->injections[$name];
}
protected function addDependency($name)
{
$this->dependencies[] = $name;
}
public function getDependencyList()
{
return $this->dependencies;

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Controllers;
class Base extends \Espo\Core\Controllers\Record
{
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Controllers;
class CategoryTree extends \Espo\Core\Controllers\RecordTree
{
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Controllers;
class Person extends \Espo\Core\Controllers\Record
{
}

View File

@@ -0,0 +1,29 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Entities;
class Base extends \Espo\Core\ORM\Entity
{
}

View File

@@ -0,0 +1,29 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Entities;
class CategoryTree extends \Espo\Core\Entities\CategoryTreeItem
{
}

View File

@@ -0,0 +1,29 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Entities;
class Person extends \Espo\Core\Entities\Person
{
}

View File

@@ -0,0 +1,21 @@
[
{
"label": "Overview",
"rows": [
[
{
"name": "name"
},
{
"name": "order"
}
],
[
false,
{
"name": "parent"
}
]
]
}
]

View File

@@ -0,0 +1,22 @@
[
{
"label": "",
"rows": [
[
{
"name": "name"
}
],
[
{
"name": "order"
}
],
[
{
"name": "parent"
}
]
]
}
]

View File

@@ -0,0 +1,3 @@
[
"parent"
]

View File

@@ -0,0 +1,14 @@
[
{
"name": "name",
"width": 40,
"link": true
},
{
"name": "order",
"width": 15
},
{
"name": "parent"
}
]

View File

@@ -0,0 +1,14 @@
[
{
"name": "name",
"width": 40,
"link": true
},
{
"name": "order",
"width": 15
},
{
"name": "parent"
}
]

View File

@@ -0,0 +1,3 @@
[
]

View File

@@ -0,0 +1,3 @@
[
"children"
]

View File

@@ -0,0 +1,4 @@
{
"controller": "Controllers.Record",
"boolFilterList": ["onlyMy"]
}

View File

@@ -0,0 +1,66 @@
{
"fields": {
"name": {
"type": "varchar",
"required": true
},
"description": {
"type": "text"
},
"createdAt": {
"type": "datetime",
"readOnly": true
},
"modifiedAt": {
"type": "datetime",
"readOnly": true
},
"createdBy": {
"type": "link",
"readOnly": true
},
"modifiedBy": {
"type": "link",
"readOnly": true
},
"assignedUser": {
"type": "link",
"required": true
},
"teams": {
"type": "linkMultiple"
}
},
"links": {
"createdBy": {
"type": "belongsTo",
"entity": "User"
},
"modifiedBy": {
"type": "belongsTo",
"entity": "User"
},
"assignedUser": {
"type": "belongsTo",
"entity": "User"
},
"teams": {
"type": "hasMany",
"entity": "Team",
"relationName": "EntityTeam",
"layoutRelationshipsDisabled": true
}
},
"collection": {
"sortBy": "createdAt",
"asc": false
},
"indexes": {
"name": {
"columns": ["name", "deleted"]
},
"assignedUser": {
"columns": ["assignedUserId", "deleted"]
}
}
}

View File

@@ -0,0 +1,9 @@
{
"entity": true,
"layouts": true,
"tab": true,
"acl": true,
"customizable": true,
"importable": true,
"notifications": true
}

View File

@@ -0,0 +1,26 @@
{
"controller": "Controllers.RecordTree",
"collection": "Collections.Tree",
"menu": {
"listTree": {
"buttons": [
{
"label": "List View",
"link": "#{entityType}/list",
"acl": "read",
"style": "default"
}
]
},
"list": {
"buttons": [
{
"label": "Tree View",
"link": "#{entityType}",
"acl": "read",
"style": "default"
}
]
}
}
}

View File

@@ -0,0 +1,106 @@
{
"fields": {
"name": {
"type": "varchar",
"required": true
},
"order": {
"type": "int",
"required": true,
"default": 1
},
"description": {
"type": "text"
},
"createdAt": {
"type": "datetime",
"readOnly": true
},
"modifiedAt": {
"type": "datetime",
"readOnly": true
},
"createdBy": {
"type": "link",
"readOnly": true
},
"modifiedBy": {
"type": "link",
"readOnly": true
},
"teams": {
"type": "linkMultiple"
},
"parent": {
"type": "link"
},
"childList": {
"type": "jsonArray",
"notStorable": true,
"disabled": true
}
},
"links": {
"createdBy": {
"type": "belongsTo",
"entity": "User"
},
"modifiedBy": {
"type": "belongsTo",
"entity": "User"
},
"teams": {
"type": "hasMany",
"entity": "Team",
"relationName": "EntityTeam",
"layoutRelationshipsDisabled": true
},
"parent": {
"type": "belongsTo",
"foreign": "children",
"entity": "{entityType}",
"isCustom": true
},
"children": {
"type": "hasMany",
"foreign": "parent",
"entity": "{entityType}",
"isCustom": true
}
},
"collection": {
"sortBy": "parent",
"asc": true
},
"indexes": {
"name": {
"columns": [
"name",
"deleted"
]
}
},
"additionalTables": {
"{entityType}Path": {
"fields": {
"id": {
"type": "id",
"dbType": "int",
"len": "11",
"autoincrement": true,
"unique" : true
},
"ascendorId": {
"type": "varchar",
"len": "100",
"index": true
},
"descendorId": {
"type": "varchar",
"len": "24",
"index": true
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
{
"entity": true,
"layouts": true,
"tab": true,
"acl": true,
"customizable": true,
"importable": false,
"notifications": false
}

View File

@@ -0,0 +1,4 @@
{
"controller": "Controllers.Record",
"boolFilterList": ["onlyMy"]
}

View File

@@ -0,0 +1,111 @@
{
"fields": {
"name": {
"type": "personName"
},
"salutationName": {
"type": "enum",
"options": ["", "Mr.", "Mrs.", "Ms.", "Dr."]
},
"firstName": {
"type": "varchar",
"maxLength": 100,
"default": ""
},
"lastName": {
"type": "varchar",
"maxLength": 100,
"required": true,
"default": ""
},
"description": {
"type": "text"
},
"createdAt": {
"type": "datetime",
"readOnly": true
},
"emailAddress": {
"type": "email"
},
"phoneNumber": {
"type": "phone",
"typeList": ["Mobile", "Office", "Home", "Fax", "Other"],
"defaultType": "Mobile"
},
"address": {
"type": "address"
},
"addressStreet": {
"type": "text",
"maxLength": 255,
"dbType": "varchar"
},
"addressCity": {
"type": "varchar"
},
"addressState": {
"type": "varchar"
},
"addressCountry": {
"type": "varchar"
},
"addressPostalCode": {
"type": "varchar"
},
"modifiedAt": {
"type": "datetime",
"readOnly": true
},
"createdBy": {
"type": "link",
"readOnly": true
},
"modifiedBy": {
"type": "link",
"readOnly": true
},
"assignedUser": {
"type": "link",
"required": true
},
"teams": {
"type": "linkMultiple"
}
},
"links": {
"createdBy": {
"type": "belongsTo",
"entity": "User"
},
"modifiedBy": {
"type": "belongsTo",
"entity": "User"
},
"assignedUser": {
"type": "belongsTo",
"entity": "User"
},
"teams": {
"type": "hasMany",
"entity": "Team",
"relationName": "EntityTeam",
"layoutRelationshipsDisabled": true
}
},
"collection": {
"sortBy": "createdAt",
"asc": false
},
"indexes": {
"firstName": {
"columns": ["firstName", "deleted"]
},
"name": {
"columns": ["firstName", "lastName"]
},
"assignedUser": {
"columns": ["assignedUserId", "deleted"]
}
}
}

View File

@@ -0,0 +1,9 @@
{
"entity": true,
"layouts": true,
"tab": true,
"acl": true,
"customizable": true,
"importable": true,
"notifications": true
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Repositories;
class Base extends \Espo\Core\ORM\Repositories\RDB
{
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Repositories;
class CategoryTree extends \Espo\Core\Repositories\CategoryTree
{
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Repositories;
class Person extends \Espo\Core\ORM\Repositories\RDB
{
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Services;
class Base extends \Espo\Services\Record
{
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Services;
class CategoryTree extends \Espo\Services\RecordTree
{
}

View File

@@ -0,0 +1,30 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Templates\Services;
class Person extends \Espo\Services\Record
{
}

View File

@@ -30,6 +30,7 @@ class UpgradeManager extends Upgrades\Base
protected $params = array(
'packagePath' => 'data/upload/upgrades',
'backupPath' => 'data/.backup/upgrades',
'scriptNames' => array(
'before' => 'BeforeUpgrade',

View File

@@ -22,9 +22,11 @@
namespace Espo\Core\Upgrades\Actions;
use Espo\Core\Utils\Util,
Espo\Core\Utils\Json,
Espo\Core\Exceptions\Error;
use Espo\Core\Utils\Util;
use Espo\Core\Utils\System;
use Espo\Core\Utils\Json;
use Espo\Core\Exceptions\Error;
use vierbergenlars\SemVer;
abstract class Base
{
@@ -32,6 +34,8 @@ abstract class Base
private $entityManager;
private $helper;
protected $data;
protected $params = null;
@@ -129,7 +133,7 @@ abstract class Base
return $this->config;
}
protected function getEntityManager()
public function getEntityManager()
{
if (!isset($this->entityManager)) {
$this->entityManager = $this->getContainer()->get('entityManager');
@@ -179,46 +183,60 @@ abstract class Base
*/
protected function isAcceptable()
{
$manifest = $this->getManifest();
$res = $this->checkPackageType();
$res &= $this->checkVersions();
//check php version
if (isset($manifest['php'])) {
$res &= $this->checkVersions($manifest['php'], System::getPhpVersion(), 'Your PHP version does not support this installation package.');
}
//check acceptableVersions
if (isset($manifest['acceptableVersions'])) {
$res &= $this->checkVersions($manifest['acceptableVersions'], $this->getConfig()->get('version'), 'Your EspoCRM version doesn\'t match for this installation package.');
}
//check dependencies
if (!empty($manifest['dependencies'])) {
$res &= $this->checkDependencies($manifest['dependencies']);
}
return (bool) $res;
}
protected function checkVersions()
public function checkVersions($versionList, $currentVersion, $errorMessage = '')
{
$manifest = $this->getManifest();
/** check acceptable versions */
$version = $manifest['acceptableVersions'];
if (empty($version)) {
if (empty($versionList)) {
return true;
}
$currentVersion = $this->getConfig()->get('version');
if (is_string($version)) {
$version = (array) $version;
if (is_string($versionList)) {
$versionList = (array) $versionList;
}
foreach ($version as $strVersion) {
try {
$semver = new SemVer\version($currentVersion);
} catch (\Exception $e) {
$GLOBALS['log']->error('Cannot recognize currentVersion ['.$currentVersion.'], error: '.$e->getMessage().'.');
return false;
}
$strVersion = trim($strVersion);
foreach ($versionList as $version) {
if ($strVersion == $currentVersion) {
return true;
$isInRange = false;
try {
$isInRange = $semver->satisfies(new SemVer\expression($version));
} catch (\Exception $e) {
$GLOBALS['log']->error('Version identification error: '.$e->getMessage().'.');
}
$strVersion = str_replace('\\', '', $strVersion);
$strVersion = preg_quote($strVersion);
$strVersion = str_replace('\\*', '+', $strVersion);
if (preg_match('/^'.$strVersion.'/', $currentVersion)) {
if ($isInRange) {
return true;
}
}
$this->throwErrorAndRemovePackage('Your EspoCRM version doesn\'t match for this installation package.');
$this->throwErrorAndRemovePackage($errorMessage);
}
protected function checkPackageType()
@@ -240,6 +258,11 @@ abstract class Base
return true;
}
protected function checkDependencies($dependencyList)
{
return true;
}
/**
* Run scripts by type
* @param string $type Ex. "before", "after"
@@ -293,7 +316,7 @@ abstract class Base
/**
* Get a list of files defined in manifest.json
*
* @return [type] [description]
* @return array
*/
protected function getDeleteFileList()
{
@@ -341,6 +364,18 @@ abstract class Base
return $this->data['fileList'];
}
protected function getRestoreFileList()
{
if (!isset($this->data['restoreFileList'])) {
$backupPath = $this->getPath('backupPath');
$backupFilePath = Util::concatPath($backupPath, self::FILES);
$this->data['restoreFileList'] = $this->getFileManager()->getFileList($backupFilePath, true, '', true, true);
}
return $this->data['restoreFileList'];
}
protected function copy($sourcePath, $destPath, $recursively = false, array $fileList = null, $copyOnlyFiles = false)
{
try {
@@ -467,18 +502,31 @@ abstract class Base
/**
* Execute an action. For ex., execute uninstall action in install
*
* @param [type] $actionName [description]
* @param [type] $data [description]
* @return [type] [description]
* @param string $actionName
* @param string $data
*
* @return void
*/
protected function executeAction($actionName, $data)
{
$currentAction = $this->getActionManager()->getAction();
$actionManager = $this->getActionManager();
$this->getActionManager()->setAction($actionName);
$this->getActionManager()->run($data);
$currentAction = $actionManager->getAction();
$actionManager->setAction($actionName);
$actionManager->run($data);
$actionManager->setAction($currentAction);
}
protected function initialize()
{
}
protected function finalize()
{
$this->getActionManager()->setAction($currentAction);
}
protected function beforeRunAction()
@@ -491,5 +539,38 @@ abstract class Base
}
protected function clearCache()
{
return $this->getContainer()->get('dataManager')->clearCache();
}
}
protected function checkIsWritable()
{
$fullFileList = array_merge($this->getDeleteFileList(), $this->getCopyFileList());
$result = $this->getFileManager()->isWritableList($fullFileList);
if (!$result) {
$permissionDeniedList = $this->getFileManager()->getLastPermissionDeniedList();
throw new Error("Permission denied for <br>". implode(", <br>", $permissionDeniedList));
}
}
protected function backupExistingFiles()
{
$fullFileList = array_merge($this->getDeleteFileList(), $this->getCopyFileList());
$backupPath = $this->getPath('backupPath');
return $this->copy('', array($backupPath, self::FILES), false, $fullFileList);
}
protected function getHelper()
{
if (!isset($this->helper)) {
$this->helper = new Helper();
}
$this->helper->setActionObject($this);
return $this->helper;
}
}

View File

@@ -24,14 +24,18 @@ namespace Espo\Core\Upgrades\Actions\Base;
class Delete extends \Espo\Core\Upgrades\Actions\Base
{
public function run($processId)
public function run($data)
{
$processId = $data['id'];
$GLOBALS['log']->debug('Delete package process ['.$processId.']: start run.');
if (empty($processId)) {
throw new Error('Delete package package ID was not specified.');
}
$this->initialize();
$this->setProcessId($processId);
$this->beforeRunAction();
@@ -41,6 +45,8 @@ class Delete extends \Espo\Core\Upgrades\Actions\Base
$this->afterRunAction();
$this->finalize();
$GLOBALS['log']->debug('Delete package process ['.$processId.']: end run.');
}

View File

@@ -23,24 +23,20 @@
namespace Espo\Core\Upgrades\Actions\Base;
use Espo\Core\Exceptions\Error;
use Espo\Core\Utils\Util;
class Install extends \Espo\Core\Upgrades\Actions\Base
{
/**
* Is copied extension files to Espo
*
* @var [type]
*/
protected $isCopied = null;
/**
* Main installation process
*
* @param string $processId Upgrade/Extension ID, gotten in upload stage
* @return bool
*/
public function run($processId)
public function run($data)
{
$processId = $data['id'];
$GLOBALS['log']->debug('Installation process ['.$processId.']: start run.');
if (empty($processId)) {
@@ -49,7 +45,7 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
$this->setProcessId($processId);
$this->isCopied = false;
$this->initialize();
/** check if an archive is unzipped, if no then unzip */
$packagePath = $this->getPackagePath();
@@ -58,21 +54,23 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
$this->isAcceptable();
}
//check permissions copied and deleted files
$this->checkIsWritable();
$this->beforeRunAction();
$this->backupExistingFiles();
/* run before install script */
$this->runScript('before');
/* remove files defined in a manifest */
if (!$this->deleteFiles()) {
$this->throwErrorAndRemovePackage('Permission denied to delete files.');
}
/* copy files from directory "Files" to EspoCRM files */
if (!$this->copyFiles()) {
$this->throwErrorAndRemovePackage('Cannot copy files.');
}
$this->isCopied = true;
/* remove files defined in a manifest */
$this->deleteFiles(true);
if (!$this->systemRebuild()) {
$this->throwErrorAndRemovePackage('Error occurred while EspoCRM rebuild.');
@@ -83,24 +81,34 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
$this->afterRunAction();
$this->clearCache();
/* delete unziped files */
$this->deletePackageFiles();
$this->finalize();
$GLOBALS['log']->debug('Installation process ['.$processId.']: end run.');
}
protected function restoreFiles()
{
$GLOBALS['log']->info('Installer: Restore previous files.');
$backupPath = $this->getPath('backupPath');
$backupFilePath = Util::concatPath($backupPath, self::FILES);
$res = true;
if ($this->isCopied) {
$res &= $this->copy(array($backupPath, self::FILES), '', true);
$GLOBALS['log']->info('Restore: copy back');
$backupFileList = $this->getRestoreFileList();
$copyFileList = $this->getCopyFileList();
$deleteFileList = array_diff($copyFileList, $backupFileList);
$res = $this->copy($backupFilePath, '', true);
$res &= $this->getFileManager()->remove($deleteFileList, null, true);
if ($res) {
$this->getFileManager()->removeInDir($backupPath, true);
}
$res &= $this->getFileManager()->removeInDir($backupPath, true);
return $res;
}

View File

@@ -22,13 +22,16 @@
namespace Espo\Core\Upgrades\Actions\Base;
use Espo\Core\Exceptions\Error,
Espo\Core\Utils\Util;
use Espo\Core\Exceptions\Error;
use Espo\Core\Utils\Util;
use Espo\Core\Utils\Json;
class Uninstall extends \Espo\Core\Upgrades\Actions\Base
{
public function run($processId)
public function run($data)
{
$processId = $data['id'];
$GLOBALS['log']->debug('Uninstallation process ['.$processId.']: start run.');
if (empty($processId)) {
@@ -37,44 +40,50 @@ class Uninstall extends \Espo\Core\Upgrades\Actions\Base
$this->setProcessId($processId);
$this->initialize();
$this->checkIsWritable();
$this->beforeRunAction();
/* run before install script */
$this->runScript('beforeUninstall');
if (!isset($data['isNotRunScriptBefore']) || !$data['isNotRunScriptBefore']) {
$this->runScript('beforeUninstall');
}
$backupPath = $this->getPath('backupPath');
if (file_exists($backupPath)) {
/* remove extension files, saved in fileList */
if (!$this->deleteFiles(true)) {
throw new Error('Permission denied to delete files.');
}
/* copy core files */
if (!$this->copyFiles()) {
throw new Error('Cannot copy files.');
$this->throwErrorAndRemovePackage('Cannot copy files.');
}
/* remove extension files, saved in fileList */
if (!$this->deleteFiles(true)) {
$this->throwErrorAndRemovePackage('Permission denied to delete files.');
}
}
if (!$this->systemRebuild()) {
throw new Error('Error occurred while EspoCRM rebuild.');
$this->throwErrorAndRemovePackage('Error occurred while EspoCRM rebuild.');
}
/* run before install script */
$this->runScript('afterUninstall');
/* run after uninstall script */
if (!isset($data['isNotRunScriptAfter']) || !$data['isNotRunScriptAfter']) {
$this->runScript('afterUninstall');
}
$this->afterRunAction();
$this->clearCache();
/* delete backup files */
$this->deletePackageFiles();
$GLOBALS['log']->debug('Uninstallation process ['.$processId.']: end run.');
}
$this->finalize();
protected function getDeleteFileList()
{
$extensionEntity = $this->getExtensionEntity();
return $extensionEntity->get('fileList');
$GLOBALS['log']->debug('Uninstallation process ['.$processId.']: end run.');
}
protected function restoreFiles()
@@ -87,6 +96,13 @@ class Uninstall extends \Espo\Core\Upgrades\Actions\Base
}
$res = $this->copy($filesPath, '', true);
$manifestJson = $this->getFileManager()->getContents(array($packagePath, $this->manifestName));
$manifest = Json::decode($manifestJson, true);
if (!empty($manifest['delete'])) {
$res &= $this->getFileManager()->remove($manifest['delete'], null, true);
}
$res &= $this->getFileManager()->removeInDir($packagePath, true);
return $res;
@@ -129,4 +145,41 @@ class Uninstall extends \Espo\Core\Upgrades\Actions\Base
throw new Error($errorMessage);
}
protected function getCopyFileList()
{
if (!isset($this->data['fileList'])) {
$backupPath = $this->getPath('backupPath');
$filesPath = Util::concatPath($backupPath, self::FILES);
$this->data['fileList'] = $this->getFileManager()->getFileList($filesPath, true, '', true, true);
}
return $this->data['fileList'];
}
protected function getRestoreFileList()
{
if (!isset($this->data['restoreFileList'])) {
$packagePath = $this->getPackagePath();
$filesPath = Util::concatPath($packagePath, self::FILES);
if (!file_exists($filesPath)) {
$this->unzipArchive($packagePath);
}
$this->data['restoreFileList'] = $this->getFileManager()->getFileList($filesPath, true, '', true, true);
}
return $this->data['restoreFileList'];
}
protected function getDeleteFileList()
{
$packageFileList = $this->getRestoreFileList();
$backupFileList = $this->getCopyFileList();
$deleteFileList = array_diff($packageFileList, $backupFileList);
return $deleteFileList;
}
}

View File

@@ -38,6 +38,10 @@ class Upload extends \Espo\Core\Upgrades\Actions\Base
$GLOBALS['log']->debug('Installation process ['.$processId.']: start upload the package.');
$this->initialize();
$this->beforeRunAction();
$packagePath = $this->getPackagePath();
$packageArchivePath = $this->getPackagePath(true);
@@ -55,6 +59,10 @@ class Upload extends \Espo\Core\Upgrades\Actions\Base
$this->isAcceptable();
$this->afterRunAction();
$this->finalize();
$GLOBALS['log']->debug('Installation process ['.$processId.']: end upload the package.');
return $processId;

View File

@@ -35,29 +35,15 @@ class Delete extends \Espo\Core\Upgrades\Actions\Base\Delete
*/
protected function getExtensionEntity()
{
return $this->extensionEntity;
}
/**
* Set Extension Entity
*
* @param \Espo\Entities\Extension $extensionEntity
*/
protected function setExtensionEntity(\Espo\Entities\Extension $extensionEntity)
{
$this->extensionEntity = $extensionEntity;
}
protected function beforeRunAction()
{
$processId = $this->getProcessId();
/** get extension entity */
$extensionEntity = $this->getEntityManager()->getEntity('Extension', $processId);
if (!isset($extensionEntity)) {
throw new Error('Extension Entity not found.');
if (!isset($this->extensionEntity)) {
$processId = $this->getProcessId();
$this->extensionEntity = $this->getEntityManager()->getEntity('Extension', $processId);
if (!isset($this->extensionEntity)) {
throw new Error('Extension Entity not found.');
}
}
$this->setExtensionEntity($extensionEntity);
return $this->extensionEntity;
}
protected function afterRunAction()

View File

@@ -37,8 +37,6 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
$this->uninstallExtension();
$this->deleteExtension();
}
$this->copyExistingFiles();
}
protected function afterRunAction()
@@ -51,12 +49,11 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
*
* @return bool
*/
protected function copyExistingFiles()
protected function backupExistingFiles()
{
$fileList = $this->getCopyFileList();
$backupPath = $this->getPath('backupPath');
parent::backupExistingFiles();
$res = $this->copy('', array($backupPath, self::FILES), false, $fileList);
$backupPath = $this->getPath('backupPath');
/** copy scripts files */
$packagePath = $this->getPackagePath();
@@ -65,19 +62,6 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
return $res;
}
protected function restoreFiles()
{
$res = true;
if ($this->isCopied) {
$extensionFileList = $this->getCopyFileList();
$res &= $this->getFileManager()->remove($extensionFileList);
}
$res &= parent::restoreFiles();
return $res;
}
protected function isNew()
{
$extensionEntity = $this->getExtensionEntity();
@@ -154,7 +138,7 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
$data = array(
'id' => $this->getProcessId(),
'name' => $manifest['name'],
'name' => trim($manifest['name']),
'isInstalled' => true,
'version' => $manifest['version'],
'fileList' => $fileList,
@@ -176,7 +160,7 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
$extensionEntity = $this->getExtensionEntity();
if (isset($extensionEntity)) {
$comparedVersion = version_compare($manifest['version'], $extensionEntity->get('version'));
$comparedVersion = version_compare($manifest['version'], $extensionEntity->get('version'), '>=');
if ($comparedVersion <= 0) {
$this->throwErrorAndRemovePackage('You cannot install an older version of this extension.');
}
@@ -187,8 +171,8 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
* Throw an exception and remove package files.
* Redeclared to prevent of deleting a package of installed extension.
*
* @param string $errorMessage [description]
* @return [type] [description]
* @param string $errorMessage
* @return void
*/
protected function throwErrorAndRemovePackage($errorMessage = '')
{
@@ -208,7 +192,11 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
{
$extensionEntity = $this->getExtensionEntity();
$this->executeAction(ExtensionManager::UNINSTALL, $extensionEntity->get('id'));
$this->executeAction(ExtensionManager::UNINSTALL, array(
'id' => $extensionEntity->get('id'),
'isNotRunScriptAfter' => true,
)
);
}
/**
@@ -220,10 +208,11 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
{
$extensionEntity = $this->getExtensionEntity();
$this->executeAction(ExtensionManager::DELETE, $extensionEntity->get('id'));
$this->executeAction(ExtensionManager::DELETE, array('id' => $extensionEntity->get('id')));
}
protected function checkDependencies($dependencyList)
{
return $this->getHelper()->checkDependencies($dependencyList);
}
}

View File

@@ -35,29 +35,15 @@ class Uninstall extends \Espo\Core\Upgrades\Actions\Base\Uninstall
*/
protected function getExtensionEntity()
{
return $this->extensionEntity;
}
/**
* Set Extension Entity
*
* @param \Espo\Entities\Extension $extensionEntity [description]
*/
protected function setExtensionEntity(\Espo\Entities\Extension $extensionEntity)
{
$this->extensionEntity = $extensionEntity;
}
protected function beforeRunAction()
{
$processId = $this->getProcessId();
/** get extension entity */
$extensionEntity = $this->getEntityManager()->getEntity('Extension', $processId);
if (!isset($extensionEntity)) {
throw new Error('Extension Entity not found.');
if (!isset($this->extensionEntity)) {
$processId = $this->getProcessId();
$this->extensionEntity = $this->getEntityManager()->getEntity('Extension', $processId);
if (!isset($this->extensionEntity)) {
throw new Error('Extension Entity not found.');
}
}
$this->setExtensionEntity($extensionEntity);
return $this->extensionEntity;
}
protected function afterRunAction()
@@ -68,4 +54,14 @@ class Uninstall extends \Espo\Core\Upgrades\Actions\Base\Uninstall
$extensionEntity->set('isInstalled', false);
$this->getEntityManager()->saveEntity($extensionEntity);
}
protected function getRestoreFileList()
{
if (!isset($this->data['restoreFileList'])) {
$extensionEntity = $this->getExtensionEntity();
$this->data['restoreFileList'] = $extensionEntity->get('fileList');
}
return $this->data['restoreFileList'];
}
}

View File

@@ -24,5 +24,8 @@ namespace Espo\Core\Upgrades\Actions\Extension;
class Upload extends \Espo\Core\Upgrades\Actions\Base\Upload
{
protected function checkDependencies($dependencyList)
{
return $this->getHelper()->checkDependencies($dependencyList);
}
}

View File

@@ -0,0 +1,77 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Core\Upgrades\Actions;
use Espo\Core\Exceptions\Error;
class Helper
{
private $actionObject;
public function __construct($actionObject = null)
{
if (isset($actionObject)) {
$this->setActionObject($actionObject);
}
}
public function setActionObject(\Espo\Core\Upgrades\Actions\Base $actionObject)
{
$this->actionObject = $actionObject;
}
protected function getActionObject()
{
return $this->actionObject;
}
/**
* Check dependencies
*
* @param array | string $dependencyList
*
* @return bool
*/
public function checkDependencies($dependencyList)
{
if (!is_array($dependencyList)) {
$dependencyList = (array) $dependencyList;
}
$actionObject = $this->getActionObject();
foreach ($dependencyList as $extensionName => $extensionVersion) {
$dependencyExtensionEntity = $actionObject->getEntityManager()->getRepository('Extension')->where(array(
'name' => trim($extensionName),
'isInstalled' => true,
))->findOne();
$errorMessage = 'Dependency Error: The extension "'.$extensionName.'" with version "'.$extensionVersion.'" is missing.';
if (!isset($dependencyExtensionEntity) || !$actionObject->checkVersions($extensionVersion, $dependencyExtensionEntity->get('version'), $errorMessage)) {
throw new Error($errorMessage);
}
}
return true;
}
}

View File

@@ -24,17 +24,12 @@ namespace Espo\Core\Upgrades\Actions\Upgrade;
class Install extends \Espo\Core\Upgrades\Actions\Base\Install
{
protected function systemRebuild()
protected function finalize()
{
$manifest = $this->getManifest();
$res = $this->getConfig()->set('version', $manifest['version']);
if (method_exists($this->getConfig(), 'save')) {
$res = $this->getConfig()->save();
}
$res &= parent::systemRebuild();
return $res;
$this->getConfig()->set('version', $manifest['version']);
$this->getConfig()->save();
}
/**

View File

@@ -67,7 +67,9 @@ class Output
$currentRoute = $this->getSlim()->router()->getCurrentRoute();
if (isset($currentRoute)) {
$GLOBALS['log']->error('API ['.$this->getSlim()->request()->getMethod().']:'.$currentRoute->getPattern().', Params:'.print_r($currentRoute->getParams(), true).', InputData: '.$this->getSlim()->request()->getBody().' - '.$message);
$inputData = $this->getSlim()->request()->getBody();
$inputData = $this->clearPasswords($inputData);
$GLOBALS['log']->error('API ['.$this->getSlim()->request()->getMethod().']:'.$currentRoute->getPattern().', Params:'.print_r($currentRoute->getParams(), true).', InputData: '.$inputData.' - '.$message);
}
$this->displayError($message, $code, $isPrint);
@@ -118,5 +120,17 @@ class Output
return null;
}
/**
* Clear passwords for inputData
*
* @param string $inputData
*
* @return string
*/
protected function clearPasswords($inputData)
{
return preg_replace('/"(.*?password.*?)":".*?"/i', '"$1":"*****"', $inputData);
}
}

View File

@@ -23,6 +23,7 @@
namespace Espo\Core\Utils;
use \Espo\Core\Exceptions\Error;
use \Espo\Core\Exceptions\Forbidden;
class Auth
{
@@ -44,6 +45,8 @@ class Auth
$authenticationMethod = $this->config->get('authenticationMethod', 'Espo');
$authenticationClassName = "\\Espo\\Core\\Utils\\Authentication\\" . $authenticationMethod;
$this->authentication = new $authenticationClassName($this->config, $this->entityManager, $this);
$this->request = $this->container->get('slim')->request();
}
public function useNoAuth($isAdmin = false)
@@ -63,8 +66,6 @@ class Auth
public function login($username, $password)
{
$GLOBALS['log']->debug('AUTH: Try to authenticate');
$entityManager = $this->entityManager;
$authToken = $entityManager->getRepository('AuthToken')->where(array('token' => $password))->findOne();
@@ -72,24 +73,28 @@ class Auth
$user = $this->authentication->login($username, $password, $authToken);
if ($user) {
if (!$user->isActive()) {
$GLOBALS['log']->debug("AUTH: Trying to login as user '".$user->get('userName')."' which is not active.");
return false;
}
$entityManager->setUser($user);
$this->container->setUser($user);
$GLOBALS['log']->debug('AUTH: Result of authenticate is [true]');
if (!$authToken) {
$authToken = $entityManager->getEntity('AuthToken');
$token = $this->createToken($user);
$authToken->set('token', $token);
$authToken->set('hash', $user->get('password'));
$authToken->set('ipAddress', $_SERVER['REMOTE_ADDR']);
$authToken->set('userId', $user->id);
if ($this->request->headers->get('HTTP_ESPO_AUTHORIZATION')) {
if (!$authToken) {
$authToken = $entityManager->getEntity('AuthToken');
$token = $this->createToken($user);
$authToken->set('token', $token);
$authToken->set('hash', $user->get('password'));
$authToken->set('ipAddress', $_SERVER['REMOTE_ADDR']);
$authToken->set('userId', $user->id);
}
$authToken->set('lastAccess', date('Y-m-d H:i:s'));
$entityManager->saveEntity($authToken);
$user->set('token', $authToken->get('token'));
}
$authToken->set('lastAccess', date('Y-m-d H:i:s'));
$entityManager->saveEntity($authToken);
$user->set('token', $authToken->get('token'));
return true;
}
}

View File

@@ -82,14 +82,14 @@ class Autoload
protected function init()
{
if (file_exists($this->cacheFile) && $this->getConfig()->get('useCache')) {
$this->data = $this->getFileManager()->getContents($this->cacheFile);
$this->data = $this->getFileManager()->getPhpContents($this->cacheFile);
return;
}
$this->data = $this->unify();
if ($this->getConfig()->get('useCache')) {
$result = $this->getFileManager()->putContentsPHP($this->cacheFile, $this->data);
$result = $this->getFileManager()->putPhpContents($this->cacheFile, $this->data);
if ($result == false) {
throw new \Espo\Core\Exceptions\Error('Autoload: Cannot save unified autoload.');
}

View File

@@ -150,7 +150,8 @@ class Config
$removeData = empty($this->removeData) ? null : $this->removeData;
$result = $this->getFileManager()->mergeContentsPHP($this->configPath, $values, $removeData);
$result = $this->getFileManager()->mergePhpContents($this->configPath, $values, $removeData);
if ($result) {
$this->changedData = array();
$this->removeData = array();
@@ -162,7 +163,7 @@ class Config
public function getDefaults()
{
return $this->getFileManager()->getContents($this->defaultConfigPath);
return $this->getFileManager()->getPhpContents($this->defaultConfigPath);
}
/**
@@ -178,9 +179,9 @@ class Config
$configPath = file_exists($this->configPath) ? $this->configPath : $this->defaultConfigPath;
$this->data = $this->getFileManager()->getContents($configPath);
$this->data = $this->getFileManager()->getPhpContents($configPath);
$systemConfig = $this->getFileManager()->getContents($this->systemConfigPath);
$systemConfig = $this->getFileManager()->getPhpContents($this->systemConfigPath);
$this->data = Util::merge($systemConfig, $this->data);
return $this->data;
@@ -261,7 +262,7 @@ class Config
}
if (empty($this->adminItems)) {
$this->adminItems= Util::merge($data['systemItems'], $data['adminItems']);
$this->adminItems = array_merge($data['systemItems'], $data['adminItems']);
}
return $this->adminItems;

View File

@@ -20,17 +20,54 @@
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
namespace Espo\Services;
namespace Espo\Core\Utils\Cron;
use \PDO;
use \Espo\Core\CronManager;
use \Espo\Core\Utils\Config;
use \Espo\Core\ORM\EntityManager;
class Job extends Record
class Job
{
private $config;
private $entityManager;
private $cronScheduledJob;
public function __construct(Config $config, EntityManager $entityManager)
{
$this->config = $config;
$this->entityManager = $entityManager;
$this->cronScheduledJob = new ScheduledJob($this->config, $this->entityManager);
}
protected function getConfig()
{
return $this->config;
}
protected function getEntityManager()
{
return $this->entityManager;
}
protected function getCronScheduledJob()
{
return $this->cronScheduledJob;
}
/**
* Get Pending Jobs
*
* @return array
*/
public function getPendingJobs()
{
/** Mark Failed old jobs and remove pending duplicates */
$this->markFailedJobs();
$this->markJobAttempts();
$this->removePendingJobDuplicates();
$jobList = $this->getActiveJobs();
@@ -52,21 +89,21 @@ class Job extends Record
*
* @param string $displayColumns
* @param string $status
*
* @return array
*/
protected function getActiveJobs($displayColumns = '*', $status = CronManager::PENDING, $fetchMode = PDO::FETCH_ASSOC)
public function getActiveJobs($displayColumns = '*', $status = CronManager::PENDING, $fetchMode = PDO::FETCH_ASSOC)
{
$jobConfigs = $this->getConfig()->get('cron');
$currentTime = time();
$periodTime = $currentTime - intval($jobConfigs['jobPeriod']);
$limit = empty($jobConfigs['maxJobNumber']) ? '' : 'LIMIT '.$jobConfigs['maxJobNumber'];
$query = "SELECT " . $displayColumns . " FROM job WHERE
`status` = '" . $status . "'
AND execute_time BETWEEN '".date('Y-m-d H:i:s', $periodTime)."' AND '".date('Y-m-d H:i:s', $currentTime)."'
AND execute_time <= '".date('Y-m-d H:i:s', $currentTime)."'
AND deleted = 0
ORDER BY execute_time DESC ".$limit;
ORDER BY execute_time ASC ".$limit;
$pdo = $this->getEntityManager()->getPDO();
$sth = $pdo->prepare($query);
@@ -77,11 +114,22 @@ class Job extends Record
return $rows;
}
public function getJobByScheduledJob($scheduledJobId, $date)
/**
* Get Jobs by ScheduledJobId and date
*
* @param string $scheduledJobId
* @param string $time
*
* @return array
*/
public function getJobByScheduledJob($scheduledJobId, $time)
{
$dateObj = new \DateTime($time);
$timeWithoutSeconds = $dateObj->format('Y-m-d H:i:');
$query = "SELECT * FROM job WHERE
scheduled_job_id = '".$scheduledJobId."'
AND execute_time = '".$date."'
AND execute_time LIKE '".$timeWithoutSeconds."%'
AND deleted = 0
LIMIT 1";
@@ -106,13 +154,30 @@ class Job extends Record
$currentTime = time();
$periodTime = $currentTime - intval($jobConfigs['jobPeriod']);
$update = "UPDATE job SET `status` = '" . CronManager::FAILED ."' WHERE
(`status` = '" . CronManager::PENDING ."' OR `status` = '" . CronManager::RUNNING ."')
AND execute_time < '".date('Y-m-d H:i:s', $periodTime)."' ";
$pdo = $this->getEntityManager()->getPDO();
$select = "SELECT id, scheduled_job_id, execute_time FROM `job` WHERE
(`status` = '" . CronManager::RUNNING ."')
AND execute_time < '".date('Y-m-d H:i:s', $periodTime)."' ";
$sth = $pdo->prepare($select);
$sth->execute();
$jobData = array();
while ($row = $sth->fetch(PDO::FETCH_ASSOC)){
$jobData[$row['id']] = $row;
}
$update = "UPDATE job SET `status` = '". CronManager::FAILED ."' WHERE id IN ('".implode("', '", array_keys($jobData))."')";
$sth = $pdo->prepare($update);
$sth->execute();
//add status 'Failed' to SchediledJobLog
$cronScheduledJob = $this->getCronScheduledJob();
foreach ($jobData as $jobId => $job) {
if (!empty($job['scheduled_job_id'])) {
$cronScheduledJob->addLogRecord($job['scheduled_job_id'], CronManager::FAILED, $job['execute_time']);
}
}
}
/**
@@ -122,10 +187,22 @@ class Job extends Record
*/
protected function removePendingJobDuplicates()
{
$duplicateJobs = $this->getActiveJobs('DISTINCT scheduled_job_id');
$pdo = $this->getEntityManager()->getPDO();
$query = "SELECT scheduled_job_id FROM job
WHERE
scheduled_job_id IS NOT NULL
AND `status` = '".CronManager::PENDING."'
AND execute_time <= '".date('Y-m-d H:i:s')."'
AND deleted = 0
GROUP BY scheduled_job_id
HAVING count( * ) > 1
ORDER BY execute_time ASC";
$sth = $pdo->prepare($query);
$sth->execute();
$duplicateJobs = $sth->fetchAll(PDO::FETCH_ASSOC);
foreach ($duplicateJobs as $row) {
if (!empty($row['scheduled_job_id'])) {
@@ -147,6 +224,40 @@ class Job extends Record
}
}
/**
* Mark job attempts
*
* @return void
*/
protected function markJobAttempts()
{
$query = "SELECT * FROM job WHERE
`status` = '" . CronManager::FAILED . "'
AND deleted = 0
AND execute_time <= '".date('Y-m-d H:i:s')."'
AND attempts > 0";
}
$pdo = $this->getEntityManager()->getPDO();
$sth = $pdo->prepare($query);
$sth->execute();
$rows = $sth->fetchAll(PDO::FETCH_ASSOC);
if ($rows) {
foreach ($rows as $row) {
$row['failed_attempts'] = isset($row['failed_attempts']) ? $row['failed_attempts'] : 0;
$attempts = $row['attempts'] - 1;
$failedAttempts = $row['failed_attempts'] + 1;
$update = "UPDATE job SET
`status` = '" . CronManager::PENDING ."',
attempts = '".$attempts."',
failed_attempts = '".$failedAttempts."'
WHERE
id = '".$row['id']."'
";
$pdo->prepare($update)->execute();
}
}
}
}

View File

@@ -18,50 +18,79 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
namespace Espo\Services;
namespace Espo\Core\Utils\Cron;
use \PDO;
use \Espo\Core\Utils\Config;
use \Espo\Core\ORM\EntityManager;
class ScheduledJob extends \Espo\Services\Record
{
class ScheduledJob
{
private $config;
private $entityManager;
public function __construct(Config $config, EntityManager $entityManager)
{
$this->config = $config;
$this->entityManager = $entityManager;
}
protected function getConfig()
{
return $this->config;
}
protected function getEntityManager()
{
return $this->entityManager;
}
/**
* Get active Scheduler Jobs
*
* @return array
*/
public function getActiveJobs()
{
$query = "SELECT * FROM scheduled_job WHERE
`status` = 'Active'
AND deleted = 0";
AND deleted = 0";
$pdo = $this->getEntityManager()->getPDO();
$sth = $pdo->prepare($query);
$sth = $pdo->prepare($query);
$sth->execute();
$rows = $sth->fetchAll(PDO::FETCH_ASSOC);
$list = array();
foreach ($rows as $row) {
$list[] = $row;
}
return $list;
}
return $list;
}
/**
* Add record to ScheduledJobLogRecord about executed job
* @param string $scheduledJobId
* @param string $status
*
* @return string Id of created ScheduledJobLogRecord
* @param string $scheduledJobId
* @param string $status
*
* @return string ID of created ScheduledJobLogRecord
*/
public function addLogRecord($scheduledJobId, $status)
public function addLogRecord($scheduledJobId, $status, $runTime = null)
{
$lastRun = date('Y-m-d H:i:s');
if (!isset($runTime)) {
$runTime = date('Y-m-d H:i:s');
}
$entityManager = $this->getEntityManager();
$scheduledJob = $entityManager->getEntity('ScheduledJob', $scheduledJobId);
$scheduledJob->set('lastRun', $lastRun);
$scheduledJob->set('lastRun', $runTime);
$entityManager->saveEntity($scheduledJob);
$scheduledJobLog = $entityManager->getEntity('ScheduledJobLogRecord');
@@ -69,15 +98,10 @@ class ScheduledJob extends \Espo\Services\Record
'scheduledJobId' => $scheduledJobId,
'name' => $scheduledJob->get('name'),
'status' => $status,
'executionTime' => $lastRun,
'executionTime' => $runTime,
));
$scheduledJobLogId = $entityManager->saveEntity($scheduledJobLog);
//$entityManager->getRepository('ScheduledJobLogRecord')->relate($scheduledJobLog, 'scheduledJob', $scheduledJob);
return $scheduledJobLogId;
}
}
return $scheduledJobLogId;
}
}

View File

@@ -33,16 +33,8 @@ class Converter
private $schemaConverter;
private $schemaFromMetadata = null;
/**
* @var array $meta - metadata array
*/
//private $meta;
public function __construct(\Espo\Core\Utils\Metadata $metadata, \Espo\Core\Utils\File\Manager $fileManager)
{
$this->metadata = $metadata;
@@ -53,7 +45,6 @@ class Converter
$this->schemaConverter = new Schema\Converter($this->fileManager);
}
protected function getMetadata()
{
return $this->metadata;
@@ -69,13 +60,11 @@ class Converter
return $this->schemaConverter;
}
public function getSchemaFromMetadata($entityList = null)
{
$ormMeta = $this->getMetadata()->getOrmMetadata();
$entityDefs = $this->getMetadata()->get('entityDefs');
$this->schemaFromMetadata = $this->getSchemaConverter()->process($ormMeta, $entityDefs, $entityList);
$this->schemaFromMetadata = $this->getSchemaConverter()->process($ormMeta, $entityList);
return $this->schemaFromMetadata;
}
@@ -98,11 +87,4 @@ class Converter
return $result;
}
}
?>
}

View File

@@ -22,12 +22,13 @@
namespace Espo\Core\Utils\Database\DBAL\Platforms;
use Doctrine\DBAL\Schema\TableDiff,
Doctrine\DBAL\Schema\Index,
Doctrine\DBAL\Schema\Table,
Doctrine\DBAL\Schema\Constraint,
Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Column;
class MySqlPlatform extends \Doctrine\DBAL\Platforms\MySqlPlatform
{
@@ -39,21 +40,52 @@ class MySqlPlatform extends \Doctrine\DBAL\Platforms\MySqlPlatform
$queryParts[] = 'RENAME TO ' . $diff->newName;
}
foreach ($diff->addedColumns as $column) {
if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) {
//espo: It works not correctly. It can rename some existing fields
foreach ($diff->renamedColumns as $oldColumnName => $column) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) {
continue;
}
//espo: remaned autoincrement field
if ($column->getAutoincrement()) {
$diff->removedColumns[$oldColumnName] = new Column($oldColumnName, $column->getType(), $column->toArray());
$columnName = $column->getQuotedName($this);
$diff->addedColumns[$columnName] = $column;
continue;
}
//END espo
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
/*$queryParts[] = 'CHANGE ' . $oldColumnName . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); */
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); //espo: fixed the problem
} //espo: END
foreach ($diff->removedColumns as $column) {
if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) {
continue;
}
//espo: remove autoincrement option
if ($column->getAutoincrement()) {
$columnName = $column->getQuotedName($this);
$changedColumn = clone $column;
$changedColumn->setNotNull(false);
$changedColumn->setAutoincrement(false);
$changedProperties = array(
'notnull',
'autoincrement',
);
$diff->changedColumns[$columnName] = new ColumnDiff($columnName, $changedColumn, $changedProperties, $column);
}
//END espo
//$queryParts[] = 'DROP ' . $column->getQuotedName($this); //espo: no needs to remove columns
}
@@ -71,19 +103,15 @@ class MySqlPlatform extends \Doctrine\DBAL\Platforms\MySqlPlatform
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
//espo: It works not correctly. It can rename some existing fields
foreach ($diff->renamedColumns as $oldColumnName => $column) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) {
foreach ($diff->addedColumns as $column) {
if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) {
continue;
}
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
/*$queryParts[] = 'CHANGE ' . $oldColumnName . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); */
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); //espo: fixed the problem
} //espo: END
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
$sql = array();
$tableSql = array();

View File

@@ -29,7 +29,7 @@ class Converter
{
private $metadata;
private $fileManager;
private $metadataUtils;
private $metadataHelper;
private $relationManager;
@@ -79,9 +79,18 @@ class Converter
protected $idParams = array(
'dbType' => 'varchar',
'len' => '24',
'len' => 24,
);
/**
* Permitted Entity options which will be moved to ormMetadata
*
* @var array
*/
protected $permittedEntityOptions = array(
'indexes',
'additionalTables',
);
public function __construct(\Espo\Core\Utils\Metadata $metadata, \Espo\Core\Utils\File\Manager $fileManager)
{
@@ -90,18 +99,17 @@ class Converter
$this->relationManager = new RelationManager($this->metadata);
$this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata);
$this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata);
}
protected function getMetadata()
{
return $this->metadata;
}
protected function getEntityDefs()
protected function getEntityDefs($reload = false)
{
if (empty($this->entityDefs)) {
if (empty($this->entityDefs) || $reload) {
$this->entityDefs = $this->getMetadata()->get('entityDefs');
}
@@ -118,14 +126,19 @@ class Converter
return $this->relationManager;
}
protected function getMetadataUtils()
protected function getMetadataHelper()
{
return $this->metadataUtils;
return $this->metadataHelper;
}
/**
* Orm metadata convertation process
*
* @return array
*/
public function process()
{
$entityDefs = $this->getEntityDefs();
$entityDefs = $this->getEntityDefs(true);
$ormMeta = array();
foreach($entityDefs as $entityName => $entityMeta) {
@@ -153,11 +166,14 @@ class Converter
),
);
if (isset($entityMeta['indexes'])) {
$ormMeta[$entityName]['indexes'] = $entityMeta['indexes'];
foreach ($this->permittedEntityOptions as $optionName) {
if (isset($entityMeta[$optionName])) {
$ormMeta[$entityName][$optionName] = $entityMeta[$optionName];
}
}
$ormMeta[$entityName]['fields'] = $this->convertFields($entityName, $entityMeta);
$ormMeta = $this->correctFields($entityName, $ormMeta);
$convertedLinks = $this->convertLinks($entityName, $entityMeta, $ormMeta);
@@ -168,65 +184,26 @@ class Converter
public function afterProcess(array $ormMeta)
{
$entityDefs = $this->getEntityDefs();
$currentOrmMeta = $ormMeta;
//load custom field definitions and customCodes
foreach($currentOrmMeta as $entityName => $entityParams) {
foreach($entityParams['fields'] as $fieldName => $fieldParams) {
//load custom field definitions
$fieldType = ucfirst($fieldParams['type']);
$className = '\Espo\Custom\Core\Utils\Database\Orm\Fields\\'.$fieldType;
if (!class_exists($className)) {
$className = '\Espo\Core\Utils\Database\Orm\Fields\\'.$fieldType;
}
if (class_exists($className) && method_exists($className, 'load')) {
$helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
$fieldResult = $helperClass->process( $fieldName, $entityName );
if (isset($fieldResult['unset'])) {
$ormMeta = Util::unsetInArray($ormMeta, $fieldResult['unset']);
unset($fieldResult['unset']);
}
$ormMeta = Util::merge($ormMeta, $fieldResult);
} //END: load custom field definitions
//todo move to separate file
//add a field 'isFollowed' for scopes with 'stream => true'
$scopeDefs = $this->getMetadata()->get('scopes.'.$entityName);
if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
if (!isset($entityParams['fields']['isFollowed'])) {
$ormMeta[$entityName]['fields']['isFollowed'] = array(
'type' => 'varchar',
'notStorable' => true,
);
}
} //END: add a field 'isFollowed' for stream => true
}
}
foreach($ormMeta as $entityName => &$entityParams) {
foreach($entityParams['fields'] as $fieldName => &$fieldParams) {
switch ($fieldParams['type']) {
case 'id':
if ($fieldParams['dbType'] != 'int') {
$fieldParams = array_merge($fieldParams, $this->idParams);
$fieldParams = array_merge($this->idParams, $fieldParams);
}
break;
case 'foreignId':
$fieldParams = array_merge($fieldParams, $this->idParams);
$fieldParams = array_merge($this->idParams, $fieldParams);
$fieldParams['notNull'] = false;
break;
case 'foreignType':
$fieldParams['dbType'] = Entity::VARCHAR;
$fieldParams['len'] = $this->defaultLength['varchar'];
if (empty($fieldParams['len'])) {
$fieldParams['len'] = $this->defaultLength['varchar'];
}
break;
case 'bool':
@@ -234,7 +211,6 @@ class Converter
break;
}
}
}
return $ormMeta;
@@ -250,6 +226,11 @@ class Converter
*/
protected function convertFields($entityName, &$entityMeta)
{
//List of unmerged fields with default field defenitions in $outputMeta
$unmergedFields = array(
'name',
);
$outputMeta = array(
'id' => array(
'type' => Entity::ID,
@@ -259,36 +240,31 @@ class Converter
'type' => isset($entityMeta['fields']['name']['type']) ? $entityMeta['fields']['name']['type'] : Entity::VARCHAR,
'notStorable' => true,
),
'deleted' => array(
'type' => Entity::BOOL,
'default' => false,
),
);
foreach($entityMeta['fields'] as $fieldName => $fieldParams) {
/** check if "fields" option exists in $fieldMeta */
$fieldTypeMeta = $this->getMetadataUtils()->getFieldDefsByType($fieldParams);
$fieldTypeMeta = $this->getMetadataHelper()->getFieldDefsByType($fieldParams);
if (isset($fieldTypeMeta['fields']) && is_array($fieldTypeMeta['fields'])) {
$fieldDefs = $this->convertField($entityName, $fieldName, $fieldParams, $fieldTypeMeta);
foreach($fieldTypeMeta['actualFields'] as $subFieldName) {
$subField = $this->convertActualFields($entityName, $fieldName, $fieldParams, $subFieldName, $fieldTypeMeta);
if (!isset($outputMeta[ $subField['naming'] ])) {
$subFieldDefs = $this->convertField($entityName, $subField['name'], $subField['params']);
if ($subFieldDefs !== false) {
$outputMeta[ $subField['naming'] ] = $subFieldDefs; //push fieldDefs to the main array
}
}
}
} else {
$fieldDefs = $this->convertField($entityName, $fieldName, $fieldParams, $fieldTypeMeta);
if ($fieldDefs !== false) {
$outputMeta[$fieldName] = $fieldDefs; //push fieldDefs to the main array
if ($fieldDefs !== false) {
//push fieldDefs to the ORM metadata array
if (isset($outputMeta[$fieldName]) && !in_array($fieldName, $unmergedFields)) {
$outputMeta[$fieldName] = array_merge($outputMeta[$fieldName], $fieldDefs);
} else {
$outputMeta[$fieldName] = $fieldDefs;
}
}
/** check and set the linkDefs from 'fields' metadata */
if (isset($fieldTypeMeta['linkDefs'])) {
$linkDefs = $this->getMetadataUtils()->getLinkDefsInFieldMeta($entityName, $fieldParams, $fieldTypeMeta['linkDefs']);
$linkDefs = $this->getMetadataHelper()->getLinkDefsInFieldMeta($entityName, $fieldParams, $fieldTypeMeta['linkDefs']);
if (isset($linkDefs)) {
if (!isset($entityMeta['links'])) {
$entityMeta['links'] = array();
@@ -298,35 +274,81 @@ class Converter
}
}
if (!isset($outputMeta['deleted'])) {
$outputMeta['deleted'] = array(
'type' => Entity::BOOL,
'default' => false,
);
return $outputMeta;
}
/**
* Correct fields defenitions based on \Espo\Custom\Core\Utils\Database\Orm\Fields
*
* @param array $ormMeta
*
* @return array
*/
protected function correctFields($entityName, array $ormMeta)
{
$entityDefs = $this->getEntityDefs();
$entityMeta = $ormMeta[$entityName];
//load custom field definitions and customCodes
foreach($entityMeta['fields'] as $fieldName => $fieldParams) {
//load custom field definitions
$fieldType = ucfirst($fieldParams['type']);
$className = '\Espo\Custom\Core\Utils\Database\Orm\Fields\\' . $fieldType;
if (!class_exists($className)) {
$className = '\Espo\Core\Utils\Database\Orm\Fields\\' . $fieldType;
}
if (class_exists($className) && method_exists($className, 'load')) {
$helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
$fieldResult = $helperClass->process( $fieldName, $entityName );
if (isset($fieldResult['unset'])) {
$ormMeta = Util::unsetInArray($ormMeta, $fieldResult['unset']);
unset($fieldResult['unset']);
}
$ormMeta = Util::merge($ormMeta, $fieldResult);
} //END: load custom field definitions
}
return $outputMeta;
//todo move to separate file
//add a field 'isFollowed' for scopes with 'stream => true'
$scopeDefs = $this->getMetadata()->get('scopes.'.$entityName);
if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
if (!isset($entityMeta['fields']['isFollowed'])) {
$ormMeta[$entityName]['fields']['isFollowed'] = array(
'type' => 'varchar',
'notStorable' => true,
);
$ormMeta[$entityName]['fields']['followersIds'] = array(
'type' => 'jsonArray',
'notStorable' => true,
);
$ormMeta[$entityName]['fields']['followersNames'] = array(
'type' => 'jsonObject',
'notStorable' => true,
);
}
} //END: add a field 'isFollowed' for stream => true
return $ormMeta;
}
protected function convertField($entityName, $fieldName, array $fieldParams, $fieldTypeMeta = null)
{
/** set default type if exists */
if (!isset($fieldParams['type']) || empty($fieldParams['type'])) {
$GLOBALS['log']->debug('Field type does not exist for '.$entityName.':'.$fieldName.'. Use default type ['.$this->defaultFieldType.']');
$fieldParams['type'] = $this->defaultFieldType;
} /** END: set default type if exists */
/** merge fieldDefs option from field definition */
if (!isset($fieldTypeMeta)) {
$fieldTypeMeta = $this->getMetadataUtils()->getFieldDefsByType($fieldParams);
$fieldTypeMeta = $this->getMetadataHelper()->getFieldDefsByType($fieldParams);
}
if (isset($fieldTypeMeta['fieldDefs'])) {
$fieldParams = Util::merge($fieldParams, $fieldTypeMeta['fieldDefs']);
}
/** check if need to skip this field in ORM metadata */
if (isset($fieldParams['skip']) && $fieldParams['skip'] === true) {
/** check if need to skipOrmDefs this field in ORM metadata */
if (isset($fieldParams['skipOrmDefs']) && $fieldParams['skipOrmDefs'] === true) {
return false;
}
@@ -350,45 +372,12 @@ class Converter
return $fieldDefs;
}
protected function convertActualFields($entityName, $fieldName, $fieldParams, $subFieldName, $fieldTypeMeta)
{
$subField = array();
$subField['params'] = $this->getInitValues($fieldParams);
if (isset($fieldTypeMeta['fieldDefs'])) {
$subField['params'] = Util::merge($subField['params'], $fieldTypeMeta['fieldDefs']);
}
//if empty field name, then use the main field
if (trim($subFieldName) == '') {
$subField['name'] = $fieldName;
$subField['naming'] = $fieldName;
} else {
$namingType = isset($fieldTypeMeta['naming']) ? $fieldTypeMeta['naming'] : $this->defaultNaming;
$subField['name'] = $subFieldName;
$subField['naming'] = Util::getNaming($fieldName, $subFieldName, $namingType);
if (isset($fieldTypeMeta['fields'][$subFieldName])) {
$subField['params'] = Util::merge($subField['params'], $fieldTypeMeta['fields'][$subFieldName]);
}
}
return $subField;
}
protected function convertLinks($entityName, $entityMeta, $ormMeta)
{
if (!isset($entityMeta['links'])) {
return array();
}
$entityDefs = $this->getEntityDefs();
$relationships = array();
foreach($entityMeta['links'] as $linkName => $linkParams) {

View File

@@ -34,30 +34,38 @@ class Currency extends Base
$alias = Util::toUnderScore($fieldName) . "_currency_alias";
return array(
$d = array(
$entityName => array(
'fields' => array(
$fieldName => array(
"type" => "float",
"orderBy" => $converedFieldName . " {direction}"
),
$fieldName . 'Converted' => array(
'type' => 'float',
'select' => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate" ,
'where' =>
array (
"=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate = {value}",
">" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate > {value}",
"<" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate < {value}",
">=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate >= {value}",
"<=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <= {value}",
"<>" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <> {value}"
),
'notStorable' => true,
'orderBy' => $converedFieldName . " {direction}"
),
)
),
),
);
$params = $this->getFieldParams($fieldName);
if (!empty($params['notStorable'])) {
$d[$entityName]['fields'][$fieldName]['notStorable'] = true;
} else {
$d[$entityName]['fields'][$fieldName . 'Converted'] = array(
'type' => 'float',
'select' => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate" ,
'where' =>
array (
"=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate = {value}",
">" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate > {value}",
"<" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate < {value}",
">=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate >= {value}",
"<=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <= {value}",
"<>" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <> {value}"
),
'notStorable' => true,
'orderBy' => $converedFieldName . " {direction}"
);
}
return $d;
}
}

Some files were not shown because too many files have changed in this diff Show More