[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7326] Added mail-sending
From: |
Erik Holm-Larsen |
Subject: |
[Fmsystem-commits] [7326] Added mail-sending |
Date: |
Mon, 30 May 2011 10:22:18 +0000 |
Revision: 7326
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7326
Author: erikhl
Date: 2011-05-30 10:22:17 +0000 (Mon, 30 May 2011)
Log Message:
-----------
Added mail-sending
Modified Paths:
--------------
trunk/activitycalendar/inc/class.socontactperson.inc.php
trunk/activitycalendar/inc/class.uiactivities.inc.php
trunk/activitycalendar/setup/phpgw_no.lang
Modified: trunk/activitycalendar/inc/class.socontactperson.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.socontactperson.inc.php 2011-05-30
07:15:35 UTC (rev 7325)
+++ trunk/activitycalendar/inc/class.socontactperson.inc.php 2011-05-30
10:22:17 UTC (rev 7326)
@@ -208,6 +208,30 @@
return $result;
}
+ function get_mailaddress_for_group_contact($contact_person_id)
+ {
+ if(isset($contact_person_id)){
+ $q1="SELECT email FROM bb_group_contact WHERE
id={$contact_person_id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record()){
+ $result = $this->db->f('email');
+ }
+ }
+ return $result;
+ }
+
+ function get_mailaddress_for_org_contact($contact_person_id)
+ {
+ if(isset($contact_person_id)){
+ $q1="SELECT email FROM bb_group_contact WHERE
id={$contact_person_id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record()){
+ $result = $this->db->f('email');
+ }
+ }
+ return $result;
+ }
+
/**
* Function for adding a new activity to the database. Updates the
activity object.
Modified: trunk/activitycalendar/inc/class.uiactivities.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiactivities.inc.php 2011-05-30
07:15:35 UTC (rev 7325)
+++ trunk/activitycalendar/inc/class.uiactivities.inc.php 2011-05-30
10:22:17 UTC (rev 7326)
@@ -18,7 +18,7 @@
'add' => true,
'edit' => true,
'download' => true,
- 'download_export' => true
+ 'send_mail' => true
);
public function __construct()
@@ -129,6 +129,9 @@
{
if(isset($activity)) // If an activity object is created
{
+ $old_state = $activity->get_state();
+ $new_state = phpgw::get_var('state');
+
// ... set all parameters
$activity->set_title(phpgw::get_var('title'));
$activity->set_organization_id(phpgw::get_var('organization_id'));
@@ -137,7 +140,7 @@
$district_array = phpgw::get_var('district');
$activity->set_district(implode(",",
$district_array));
$activity->set_office(phpgw::get_var('office'));
- $activity->set_state(phpgw::get_var('state'));
+ $activity->set_state($new_state);
$activity->set_category(phpgw::get_var('category'));
$target_array = phpgw::get_var('target');
$activity->set_target(implode(",",
$target_array));
@@ -154,6 +157,22 @@
{
$error = lang('messages_form_error');
}
+
+ if($new_state == 3 || $new_state == 4 ||
$new_state == 5 )
+ {
+ $kontor =
activitycalendar_soactivity::get_instance()->get_office_name($activity->get_office());
+ $subject = "Melding fra AktivBy";
+ $body = lang('mail_body_state_' .
$new_state, $kontor);
+
+ if(isset($g_id) && $g_id > 0)
+ {
+
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),$subject,$body);
+ }
+ else if (isset($o_id) && $o_id > 0)
+ {
+
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),$subject,$body);
+ }
+ }
}
}
@@ -261,8 +280,109 @@
$value['ajax'][] = false;
$value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'activitycalendar.uiactivities.edit', 'id' => $value['id'])));
$value['labels'][] = lang('edit');
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'activitycalendar.uiactivities.send_mail', 'activity_id' =>
$value['id'],'message_type' => 'update')));
+ $value['labels'][] = lang('send_mail');
break;
}
}
+
+ public function send_mail()
+ {
+ $activity_id = (int)phpgw::get_var('activity_id');
+ $activity =
activitycalendar_soactivity::get_instance()->get_single($activity_id);
+
+ $message_type = phpgw::get_var('message_type');
+ if($message_type)
+ {
+ //$subject = lang('mail_subject_update', $avtivity->get_id() .
'-' . $activity->get_title(), $activity->get_link());
+ $subject = lang('mail_subject_update');
+ $body = lang('mail_body_update', $activity->get_id() . ', ' .
$activity->get_title());
+ }
+ else
+ {
+ $subject = "dette er en test";
+ $body = "testmelding fra Aktivitetsoversikt";
+ }
+
+ //var_dump($subject);
+ //var_dump($body);
+
+
+ if($activity->get_group_id())
+ {
+
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),
$subject, $body);
+ }
+ else if($activity->get_organization_id())
+ {
+
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),
$subject, $body);
+ }
+
+ }
+
+ function send_mailnotification_to_organization($contact_person_id,
$subject, $body)
+ {
+
+ //var_dump($contact_person_id . ',' . $subject . ',' . $body);
+ if (!is_object($GLOBALS['phpgw']->send))
+ {
+ $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
+ }
+
+ $config = CreateObject('phpgwapi.config','booking');
+ $config->read();
+ $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ //$from = "address@hidden";
+
+ if (strlen(trim($body)) == 0)
+ {
+ return false;
+ }
+
+ $mailtoAddress =
activitycalendar_socontactperson::get_instance()->get_mailaddress_for_org_contact($contact_person_id);
+ //$mailtoAddress = "address@hidden";
+
+ if (strlen($mailtoAddress) > 0)
+ {
+ try
+ {
+ //var_dump('inne i try');
+ $GLOBALS['phpgw']->send->msg('email',
$mailtoAddress, $subject, $body, '', '', '', $from, '', 'plain');
+ }
+ catch (phpmailerException $e)
+ {
+ //var_dump($e);
+ }
+ }
+ }
+
+ function send_mailnotification_to_group($contact_person_id, $subject,
$body)
+ {
+ $send = CreateObject('phpgwapi.send');
+
+ $config = CreateObject('phpgwapi.config','booking');
+ $config->read();
+ $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ //$from = "address@hidden";
+
+ if (strlen(trim($body)) == 0)
+ {
+ return false;
+ }
+
+ $mailtoAddress =
activitycalendar_socontactperson::get_instance()->get_mailaddress_for_group_contact($contact_person_id);
+ //$mailtoaddress = "address@hidden";
+
+ if (strlen($mailtoAddress) > 0)
+ {
+ try
+ {
+ $send->msg('email', $mailtoAddress, $subject,
$body, '', '', '', $from, '', 'plain');
+ }
+ catch (phpmailerException $e)
+ {
+ }
+ }
+ }
}
?>
Modified: trunk/activitycalendar/setup/phpgw_no.lang
===================================================================
--- trunk/activitycalendar/setup/phpgw_no.lang 2011-05-30 07:15:35 UTC (rev
7325)
+++ trunk/activitycalendar/setup/phpgw_no.lang 2011-05-30 10:22:17 UTC (rev
7326)
@@ -371,4 +371,10 @@
state_5 activitycalendar no Avvist
activity_import activitycalendar no Importer aktiviteter
office activitycalendar no Kontor
-activity_helptext activitycalendar no Før ny aktivitet kan
registreres må du sjekke at organisasjon/gruppe finnes og er oppdatert, og at
arena finnes og er oppdatert.
\ No newline at end of file
+activity_helptext activitycalendar no Før ny aktivitet kan
registreres må du sjekke at organisasjon/gruppe finnes og er oppdatert, og at
arena finnes og er oppdatert.
+mail_subject_update activitycalendar no Melding om oppdatering
av aktivitet
+mail_body_update activitycalendar no Du må oppdatere
informasjonen som er registrert på aktivitet %1 . Bruk følgende lenke for å gå
inn på aktiviteten: %2
+mail_body_state_3 activitycalendar no Ditt tips er publisert
i kommuneportalen. Mvh %1 kulturkontor
+mail_body_state_4 activitycalendar no Ditt tips er behandlet
og publisert i kommuneportalen. Mvh %1 kulturkontor
+mail_body_state_5 activitycalendar no Ditt tips er behandlet,
men vil ikke bli publisert i kommuneportalen. Mvh %1 kulturkontor
+send_mail activitycalendar no Send e-post
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7326] Added mail-sending,
Erik Holm-Larsen <=