Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
implement email template for link shares
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry de Graaff committed Nov 24, 2017
1 parent 4aedffb commit 9d9acbb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 8 deletions.
48 changes: 46 additions & 2 deletions zimlet/OwnCloudListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,14 @@ OwnCloudListView.prototype._sendFilesListCbk = function(resNames, urls, idsToAtt
for (var i = 0; i < urls.length; i+= 1) {
if(urls[i].link.match(/http:\/\/|https:\/\//i))
{
extraBodyText.push((urls[i].name + " "+passwordText+expiryText+" : " + urls[i].link).replace(/ {1,}/g," "));
if(tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'].length > 0)
{
extraBodyText.push((urls[i].name + " : " + urls[i].link));
}
else
{
extraBodyText.push((urls[i].name + " "+passwordText+expiryText+" : " + urls[i].link).replace(/ {1,}/g," "));
}
}
else
{
Expand All @@ -486,13 +493,50 @@ OwnCloudListView.prototype._sendFilesListCbk = function(resNames, urls, idsToAtt
}
if((extraBodyText.length > 0) || (idsToAttach.length > 0))
{
if(tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'].length > 0)
{
var body = tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'];
body = body.replace('{links}',extraBodyText.join("\r\n"));
if (appCtxt.get(ZmSetting.DISPLAY_NAME))
{
var displayname = appCtxt.get(ZmSetting.DISPLAY_NAME);
}
else
{
var displayname = appCtxt.getActiveAccount().name;
}
body = body.replace(/{displayname}/g,displayname);
body = body.replace(/{password}/g,this.sharedLinkPass);
body = body.replace(/{expiration}/g,this.sharedLinkExpiryDate);
if(this.sharedLinkPass == "")
{
body = body.replace(/\[password\][\s\S]*?\[\/password\]/, '');
}
if(this.sharedLinkExpiryDate == "")
{
body = body.replace(/\[expiration\][\s\S]*?\[\/expiration\]/, '');
}
body = body.replace('[password]','');
body = body.replace('[/password]','');
body = body.replace('[expiration]','');
body = body.replace('[/expiration]','');

if(appCtxt.get(ZmSetting.COMPOSE_AS_FORMAT) === ZmSetting.COMPOSE_HTML)
{
body = body.replace(/\n/g,'<br>');
}
}
else
{
var body = extraBodyText.join(htmlCompose ? "<br>" : "\n");
}
try {
cc._setView({
action: ZmOperation.NEW_MESSAGE,
inNewWindow: false,
msg: new ZmMailMsg(),
subjOverride: new AjxListFormat().format(resNames),
extraBodyText: extraBodyText.join(htmlCompose ? "<br>" : "\n")
extraBodyText: body
});
cc.saveDraft(ZmComposeController.DRAFT_TYPE_MANUAL, [].concat(idsToAttach).join(","));
}
Expand Down
2 changes: 1 addition & 1 deletion zimlet/tk_barrydegraaff_owncloud_zimlet.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ along with this program. If not, see http://www.gnu.org/licenses/.
}

.DwtDialog textarea{
width:98%;
width:98% !important;
font-family: monospace !important;
}
33 changes: 29 additions & 4 deletions zimlet/tk_barrydegraaff_owncloud_zimlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@ ownCloudZimlet.prototype.init =
{
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers'] = this.getUserProperty("owncloud_zimlet_use_numbers");
}

//Set default value
if(!this.getUserProperty("owncloud_zimlet_template"))
{
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'] = '';
}
else
{
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'] = this.getUserProperty("owncloud_zimlet_template");
}

/** End load default settings for new users **/

//sort by name asc by default, do we want to store this in the ldap?
Expand Down Expand Up @@ -1443,7 +1454,7 @@ ownCloudZimlet.prototype.displayDialog =
hideOCSstyle = " style=\"display:none !important;\" ";
}

html = "<div style='width:600px; height: 350px;'>" +
html = "<div style='width:600px; height: 400px;'>" +
"<table>"+
"<tr>" +
"<td style='min-width:100px'>"+ZmMsg.usernameLabel+"</td>" +
Expand Down Expand Up @@ -1475,7 +1486,8 @@ ownCloudZimlet.prototype.displayDialog =
"<td><input style='width:98%' type='text' id='owncloud_zimlet_default_folder' value='"+tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_default_folder']+"'></td>" +
"</tr>" +
"<tr><td>"+ZmMsg.importErrorMissingFolder.replace(/\./,'')+":&nbsp;</td><td><table><tr><td><input type='checkbox' id='owncloud_zimlet_ask_folder_each_time' value='true' " + (tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_ask_folder_each_time']=='false' ? '' : 'checked') +"></td></tr></table></td></tr>" +
"<tr><td>"+ZmMsg.usePrefix + " " + (ZmMsg.number).toLowerCase()+"&nbsp;</td><td><table><tr><td><input type='checkbox' id='owncloud_zimlet_use_numbers' value='true' " + (tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers']=='false' ? '' : 'checked') +"></td></tr></table></td></tr>" +
"<tr><td>"+ZmMsg.usePrefix + " " + (ZmMsg.number).toLowerCase()+":&nbsp;</td><td><table><tr><td><input type='checkbox' id='owncloud_zimlet_use_numbers' value='true' " + (tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers']=='false' ? '' : 'checked') +"></td></tr></table></td></tr>" +
"<tr><td>"+ZmMsg.template+":&nbsp;</td><td><textarea placeholder='"+ZmMsg.clickToAdd+"' onclick='ownCloudZimlet.prototype.setTemplate()' rows='6' id='owncloud_zimlet_template'>" + tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'] +"</textarea></td></tr>" +
"<tr><td colspan=2><br><br><small>"+ZmMsg.versionLabel+" "+ownCloudZimlet.version +"</small></td></tr>"
"</table>" +
"</div>";
Expand Down Expand Up @@ -1575,8 +1587,18 @@ ownCloudZimlet.prototype.verifyPassword = function ()
{
document.getElementById('WebDAVPasswordHint').innerHTML = "<small><b style='color:#cccccc'>Passwords with special characters may not work, if you have troubles try using a simple account and password (A-Za-z0-9-_)</b></small>";
}

}
};

/* Method to set the default template, it is always English, but the sysadmin can pre-set them with zmprov.
*/
ownCloudZimlet.prototype.setTemplate = function ()
{
if(!document.getElementById('owncloud_zimlet_template').value)
{
document.getElementById('owncloud_zimlet_template').value = 'Hello,\r\n\r\n{displayname} shared the following link(s) with you:\r\n\r\n{links}\r\n\r\n[password]You need the following password to access the link(s): {password}\r\n[/password][expiration]The link(s) expire on {expiration}.\r\n[/expiration]\r\n\r\nBest regards,\r\n\r\n\{displayname}';
}
};


/** Function to handle a show/hide button for password type input fields
*/
Expand Down Expand Up @@ -1671,6 +1693,9 @@ ownCloudZimlet.prototype.prefSaveBtn = function()
this.setUserProperty("owncloud_zimlet_oc_folder", document.getElementById('owncloud_zimlet_oc_folder').value, true);
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_oc_folder'] = document.getElementById('owncloud_zimlet_oc_folder').value;

this.setUserProperty("owncloud_zimlet_template", document.getElementById('owncloud_zimlet_template').value, true);
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'] = document.getElementById('owncloud_zimlet_template').value;

this._saveUserProperties({
},
new AjxCallback(
Expand Down
2 changes: 1 addition & 1 deletion zimlet/tk_barrydegraaff_owncloud_zimlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
-->
<zimlet name="tk_barrydegraaff_owncloud_zimlet"
version="0.9.3"
version="0.9.4"
target="main compose-window view-window"
label="WebDAV"
description="Attach from and save to WebDAV">
Expand Down

0 comments on commit 9d9acbb

Please sign in to comment.