Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 29 additions & 36 deletions application/controllers/Datadeposit.php
Original file line number Diff line number Diff line change
Expand Up @@ -1996,41 +1996,38 @@ private function _study_validate_date($date) {

/**
*
* Email project summary
* Send project summary by email.
**/
public function email_summary()
{
$id=(int)$this->input->post("pid");
$email=$this->input->post("email");

//$id=27;
//$email='';

if (!$this->DD_project_model->has_access($id, $this->session->userdata('email'))) {
//redirect('datadeposit/projects');
show_error("PERMISSIONS_DENIED");
$id = (int)$this->input->post("pid");
$email = html_escape($this->input->post("email"));

if (! $this->DD_project_model->has_access($id, $this->session->userdata('email'))) {
echo json_encode(['error' => t("permissions_denied")]);
exit;
}

$this->load->helper('email');
$this->load->library('email');
if (!valid_email($email))
{
show_error("INVALID_EMAIL_ADDRESS");

if (! valid_email($email)) {
echo json_encode(['error' => t("invalid_email")]);
exit;
}

$project_title=$this->DD_project_model->get_title_by_id($id);
$user_name=$this->session->userdata('username');
$project_title = $this->DD_project_model->get_title_by_id($id);
$user_name = $this->session->userdata('username');

//get formatted project summary
$data['content']=$this->_get_formatted_project_summary($id);
$data['message']=sprintf(t('email_user_shared_project'),$user_name,$project_title);
//Get formatted project summary.
$data['content'] = $this->_get_formatted_project_summary($id);
$data['message'] = sprintf(t('email_user_shared_project'),$user_name,$project_title);

//format html for email
$css= file_get_contents(APPPATH.'../themes/datadeposit/email.css');
$contents=$this->load->view('datadeposit/emails/template', $data,TRUE);
//Format html for email.
$css = file_get_contents(APPPATH.'../themes/datadeposit/email.css');
$contents = $this->load->view('datadeposit/emails/template', $data,TRUE);

//convert external styles to inline styles
//Convert external styles to inline styles.
$this->load->library('CssToInlineStyles');
$this->csstoinlinestyles->setCSS($css);
$this->csstoinlinestyles->setHTML($contents);
Expand All @@ -2044,20 +2041,16 @@ public function email_summary()
$this->email->to($email);
$this->email->subject($project_title);
$this->email->message($contents);

if (!@$this->email->send())
{
die ("EMAIL_FAILED");
//echo $this->email->print_debugger();

if (! @$this->email->send()) {
echo json_encode(['error' => t("email_failed")]);
exit;
} else {
echo json_encode(['success' => t("email_sent_successful")]);
exit;
}
else
{
die ("EMAIL_SENT");
}
}




//get project summary
private function _get_formatted_project_summary($id)
{
Expand Down
2 changes: 2 additions & 0 deletions application/language/base/dd_projects_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,7 @@
<p>Reason for project reopen: <b>%s</b></p>
";

$lang['permissions_denied'] = "Permissions denied!";

/* End of file projects_lang.php */
/* Location: ./system/language/english/projects_lang.php */
33 changes: 27 additions & 6 deletions application/views/datadeposit/project_review_submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,40 @@

//send email
$('#send_email').click(function() {
$.post( "<?php echo site_url('datadeposit/email_summary/');?>",
{

if (! $("#share_email").val()) {
alert('Email address is required');
return false;
}

$.ajax({
dataType: "json",
data:{
'<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>',
email: $("#share_email").val(),
pid: <?php echo $project[0]->id; ?>
} );
$("#email-project").hide();
},
type:'POST',
url: "<?php echo site_url('datadeposit/email_summary/');?>",
success: function(data) {
if (data.success){
$("#email-project").hide();
$("#share_email").val('');
alert(data.success);
} else {
alert(data.error);
}
},
error: function(XHR, textStatus, thrownError) {
alert(XHR.error);
}
});
});

<?php if ($this->input->post("submit_project")):?>
//select submit tab
$('#tabs').tabs( "option", "active", 1 );
<?php endif;?>

});
</script>