Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Partners
CiviCooP
Velt
velt_mosaico
Commits
09936d3b
Commit
09936d3b
authored
Nov 24, 2021
by
jaapjansma
Browse files
Fixed issue 8733: oude afbeeldingen in de afbeeldingen bibliotheek.
parent
7db8a14b
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
0 → 100644
View file @
09936d3b
# Velt Mosaico
Voeg de volgende instellingen aan drupal settings.php toe
```
php
global
$mosaico_hash
,
$mosaico_old_hashes
;
// Hergebruik de oude velt.nu directories, het is wellicht eenvoudiger om de bestanden die in de tussentijd
// zijn geupload te kopieren dan de oude bestanden.
$mosaico_hash
=
'abc'
;
// oude velt.nu (gehost door Ward).
$mosaico_old_hashes
=
[
'def'
,
// velt.nu gehost door Koba
'ghi'
// oude portaal.accept.velt.nu (gehost door Ward)
];
```
mosaico.inc
View file @
09936d3b
<?php
/**
* Returns a hash
*
* @return false|string
*/
function
_mosaico_get_hash
()
{
global
$mosaico_hash
;
if
(
!
empty
(
$mosaico_hash
))
{
return
$mosaico_hash
;
}
return
drupal_get_hash_salt
();
}
function
_mosaico_migrate_directories
(
$sender_contact_id
,
$uploads_directory
)
{
global
$mosaico_old_hashes
;
$mosaico_hash
=
_mosaico_get_hash
();
if
(
!
isset
(
$mosaico_old_hashes
)
||
!
is_array
(
$mosaico_old_hashes
))
{
$mosaico_old_hashes
=
[];
}
$drupal_hash
=
drupal_get_hash_salt
();
if
(
$drupal_hash
!=
$mosaico_hash
&&
!
in_array
(
$drupal_hash
,
$mosaico_old_hashes
))
{
$mosaico_old_hashes
[]
=
$drupal_hash
;
}
$sender_id
=
drupal_hash_base64
(
$sender_contact_id
.
$mosaico_hash
);
$baseUri
=
'public://mosaico/'
.
$sender_id
.
'/'
;
if
(
!
file_exists
(
$baseUri
))
{
drupal_mkdir
(
$baseUri
,
NULL
,
TRUE
);
}
$uploadPath
=
drupal_realpath
(
$baseUri
.
$uploads_directory
);
if
(
!
file_exists
(
$uploadPath
))
{
drupal_mkdir
(
$uploadPath
,
NULL
,
TRUE
);
}
foreach
(
$mosaico_old_hashes
as
$mosaico_old_hash
)
{
$old_sender_id
=
drupal_hash_base64
(
$sender_contact_id
.
$mosaico_old_hash
);
$oldBaseUri
=
'public://mosaico/'
.
$old_sender_id
.
'/'
;
$oldUploadPath
=
$oldBaseUri
.
$uploads_directory
;
if
(
file_exists
(
$oldBaseUri
)
&&
!
file_exists
(
$oldBaseUri
.
'.migrated'
)
&&
file_exists
(
$oldUploadPath
)
&&
is_dir
(
$oldUploadPath
))
{
$files_in_dir
=
scandir
(
$oldUploadPath
);
foreach
(
$files_in_dir
as
$file_name
)
{
$file_path
=
$oldUploadPath
.
'/'
.
$file_name
;
if
(
is_file
(
$file_path
))
{
$new_file_name
=
file_create_filename
(
basename
(
$file_path
),
$uploadPath
);
copy
(
$file_path
,
$new_file_name
);
}
}
touch
(
$oldBaseUri
.
'.migrated'
);
}
}
}
function
_mosaico_get_sender_id
(
$sender_contact_id
)
{
$mosaico_hash
=
_mosaico_get_hash
();
return
drupal_hash_base64
(
$sender_contact_id
.
$mosaico_hash
);
}
/**
* Returns the Configuration array
...
...
@@ -9,8 +67,12 @@
function
_mosaico_config
(
$mailing
)
{
static
$mConfig
=
array
();
$uploadsDirectory
=
"uploads/"
;
list
(
$sender_contact_id
,
$reply_to_contact_id
)
=
explode
(
'-'
,
$mailing
->
sender_id
);
$sender_id
=
drupal_hash_base64
(
$sender_contact_id
.
drupal_get_hash_salt
());
//$sender_id = drupal_hash_base64($sender_contact_id.drupal_get_hash_salt());
_mosaico_migrate_directories
(
$sender_contact_id
,
$uploadsDirectory
);
$sender_id
=
_mosaico_get_sender_id
(
$sender_contact_id
);
$baseUri
=
'public://mosaico/'
.
$sender_id
.
'/'
;
$basePath
=
drupal_realpath
(
$baseUri
);
$baseUrl
=
file_create_url
(
$baseUri
);
...
...
@@ -18,10 +80,6 @@ function _mosaico_config($mailing) {
$mosaicoUri
=
'public://mosaico/'
;
$mosaicoPath
=
drupal_realpath
(
$mosaicoUri
);
if
(
!
file_exists
(
$baseUri
))
{
drupal_mkdir
(
$baseUri
,
NULL
,
TRUE
);
}
if
(
empty
(
$mConfig
))
{
$mConfig
=
array
(
/* base uri for image folders */
...
...
@@ -36,7 +94,7 @@ function _mosaico_config($mailing) {
'MOSAICO_DIR'
=>
$mosaicoPath
,
/* local file system path to the static images folder (relative to BASE_DIR) */
'UPLOADS_DIR'
=>
"
uploads
/"
,
'UPLOADS_DIR'
=>
$
uploads
Directory
,
/* local file system path to the static images folder (relative to BASE_DIR) */
'STATIC_DIR'
=>
"static/"
,
...
...
velt_mosaico.info
View file @
09936d3b
...
...
@@ -3,7 +3,7 @@ description = Integrates Mosaico in the Velt Portal
core
=
7.
x
package
=
"Velt"
version
=
"7.x-1.
4
"
version
=
"7.x-1.
5
"
dependencies
[]
=
entity
dependencies
[]
=
views
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment