[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7758] catch: notify by email
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7758] catch: notify by email |
Date: |
Fri, 30 Sep 2011 10:54:25 +0000 |
Revision: 7758
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7758
Author: sigurdne
Date: 2011-09-30 10:54:25 +0000 (Fri, 30 Sep 2011)
Log Message:
-----------
catch: notify by email
Modified Paths:
--------------
trunk/catch/inc/custom/default/notify_by_email.php
trunk/catch/inc/custom/default/update_location_at_record.php
trunk/catch/setup/setup.inc.php
trunk/catch/setup/tables_current.inc.php
trunk/catch/setup/tables_update.inc.php
trunk/property/inc/cron/default/catch_ppc.php
Modified: trunk/catch/inc/custom/default/notify_by_email.php
===================================================================
--- trunk/catch/inc/custom/default/notify_by_email.php 2011-09-29 19:05:58 UTC
(rev 7757)
+++ trunk/catch/inc/custom/default/notify_by_email.php 2011-09-30 10:54:25 UTC
(rev 7758)
@@ -1,17 +1,38 @@
<?php
- if(!isset($config_data['notify_email']) || $config_data['notify_email'])
+ $validator = CreateObject('phpgwapi.EmailAddressValidator');
+
+ if(!isset($config_data['notify_email']) ||
!$config_data['notify_email'])
{
- throw new Exception('notify_accounting_by_email: missing
"notify_email" in config for this catch schema');
+ throw new Exception("notify_accounting_by_email: missing
'notify_email' in config for this catch schema:{$schema_text}");
}
+ else if( !$validator->check_email_address($config_data['notify_email'])
)
+ {
+ throw new Exception("notify_accounting_by_email: not a valid
'notify_email' in config for this catch schema:{$schema_text}");
+ }
$to_array = array
(
-
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'],
$config_data['notify_email']
);
+ $socommon = CreateObject('property.socommon');
+ $prefs = $socommon->create_preferences('property',$user_id);
+//_debug_array($prefs);
+ if ($validator->check_email_address($prefs['email']))
+ {
+ $account_name = $GLOBALS['phpgw']->accounts->id2name($user_id);
+ // avoid problems with the delimiter in the send class
+ if(strpos($account_name,','))
+ {
+ $_account_name = explode(',', $account_name);
+ $account_name = ltrim($_account_name[1]) . ' ' .
$_account_name[0];
+ }
+ $from_email = "{$account_name}<{$prefs['email']}>";
+ $to_array[] = $from_email;
+ }
+
if (!is_object($GLOBALS['phpgw']->send))
{
$GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
@@ -20,56 +41,84 @@
$_to = implode(';',$to_array);
$from_name = 'noreply';
- $from_email = "{$from_name}<address@hidden>";
+ $from_email = isset($from_email) && $from_email ? $from_email :
"{$from_name}<address@hidden>";
$cc = '';
$bcc ='';
- $subject = 'Resultat av import';
- $body = 'Se vedlegg';
+ $subject = "{$schema_text}::{$id}";
+
+ /*
+ $_link_to_item = 'http://'.
$GLOBALS['phpgw_info']['server']['hostname'] .
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' =>
'property.uientity.view',
+ 'type'
=> 'catch',
+ 'entity_id'
=> $entity_id,
+ 'cat_id'
=> $cat_id,
+ 'id'
=> $id
+ ));
+ */
+ //$body = "<a href='{$_link_to_item}'>{$subject}</a>";
+ unset($_link_to_item);
+
+ $body ="<H2>Det er registrert ny post i {$schema_text}</H2>";
+
$jasper_id = isset($config_data['jasper_id']) &&
$config_data['jasper_id'] ? $config_data['jasper_id'] : 0;
-
+
+ $attachments = array();
+
if(!$jasper_id)
{
- throw new Exception('notify_accounting_by_email: missing
"jasper_id" in config for this catch schema');
+ $this->receipt['error'][]=array('msg'=>lang('notify_by_email:
missing "jasper_id" in config for catch %1 schema', $schema_text));
}
-
- $jasper_parameters = '';
- $_parameters = array();
+ else
+ {
+ $jasper_parameters = '';
+ $_parameters = array();
- $_parameters[] = "id|{$id}";
- $jasper_parameters = '"' . implode(';', $_parameters) . '"';
+ $_parameters[] = "id|{$id}";
+ $jasper_parameters = '"' . implode(';', $_parameters) . '"';
- unset($_parameters);
+ unset($_parameters);
- $output_type = 'PDF';
- $values_jasper = execMethod('property.bojasper.read_single',
$jasper_id);
- $report_source =
"{$GLOBALS['phpgw_info']['server']['files_dir']}/property/jasper/{$jasper_id}/{$values_jasper['file_name']}";
- $jasper_wrapper = CreateObject('phpgwapi.jasper_wrapper');
+ $output_type = 'PDF';
+ $values_jasper =
execMethod('property.bojasper.read_single', $jasper_id);
+ $report_source =
"{$GLOBALS['phpgw_info']['server']['files_dir']}/property/jasper/{$jasper_id}/{$values_jasper['file_name']}";
+ $jasper_wrapper =
CreateObject('phpgwapi.jasper_wrapper');
//_debug_array($jasper_parameters);
//_debug_array($output_type);
//_debug_array($report_source);die();
- try
+ try
+ {
+ $report = $jasper_wrapper->execute($jasper_parameters,
$output_type, $report_source, true);
+ }
+ catch(Exception $e)
+ {
+ $error = $e->getMessage();
+ echo "<H1>{$error}</H1>";
+ }
+
+ $jasper_fname =
tempnam($GLOBALS['phpgw_info']['server']['temp_dir'], 'PDF_') . '.pdf';
+ file_put_contents($jasper_fname, $report['content'], LOCK_EX);
+
+ $attachments[] = array
+ (
+ 'file' => $jasper_fname,
+ 'name' => $report['filename'],
+ 'type' => $report['mime']
+ );
+
+ if($attachments)
+ {
+ $body .= "</br>Se vedlegg";
+ }
+ }
+
+ if ($GLOBALS['phpgw']->send->msg('email', $_to, $subject,
stripslashes($body), '', $cc, $bcc, $from_email, $from_name, 'html', '',
$attachments , true))
{
- $report = $jasper_wrapper->execute($jasper_parameters,
$output_type, $report_source, true);
+ $this->receipt['message'][]=array('msg'=> "email notification
sent to: {$_to}");
}
- catch(Exception $e)
+ if( isset($jasper_fname) && is_file($jasper_fname) )
{
- $error = $e->getMessage();
- echo "<H1>{$error}</H1>";
+ unlink($jasper_fname);
}
-
- $jasper_fname = tempnam($GLOBALS['phpgw_info']['server']['temp_dir'],
'PDF_') . '.pdf';
- file_put_contents($jasper_fname, $report['content'], LOCK_EX);
-
- $attachments = array();
-
- $attachments[] = array
- (
- 'file' => $jasper_fname,
- 'name' => $report['filename'],
- 'type' => $report['mime']
- );
-
- $rcpt = $GLOBALS['phpgw']->send->msg('email', $_to, $subject,
stripslashes($body), '', $cc, $bcc, $from_email, $from_name, 'html', '',
$attachments , true);
- unlink($jasper_fname);
Modified: trunk/catch/inc/custom/default/update_location_at_record.php
===================================================================
--- trunk/catch/inc/custom/default/update_location_at_record.php
2011-09-29 19:05:58 UTC (rev 7757)
+++ trunk/catch/inc/custom/default/update_location_at_record.php
2011-09-30 10:54:25 UTC (rev 7758)
@@ -12,8 +12,16 @@
$target_table =
"fm_{$this->type_app[$this->type]}_{$entity_id}_{$cat_id}";
}
+ $sql = "SELECT id FROM {$target_table} WHERE (location_code is
NULL OR location_code = '')";
+ $metadata = $this->db->metadata($target_table);
+
+ if(isset($metadata['target_id']))
+ {
+ $sql .= 'OR (target_id IS NOT NULL AND location_id IS
NOT NULL AND p_num IS NULL)';
+ }
+
$ids = array();
- $this->db->query("SELECT id FROM $target_table WHERE
(location_code is NULL OR location_code = '') OR (target_id IS NOT NULL AND
location_id IS NOT NULL AND p_num IS NULL)",__LINE__,__FILE__);
+ $this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$ids[] = $this->db->f('id');
Modified: trunk/catch/setup/setup.inc.php
===================================================================
--- trunk/catch/setup/setup.inc.php 2011-09-29 19:05:58 UTC (rev 7757)
+++ trunk/catch/setup/setup.inc.php 2011-09-30 10:54:25 UTC (rev 7758)
@@ -27,7 +27,7 @@
*/
$setup_info['catch']['name'] = 'catch';
- $setup_info['catch']['version'] = '0.9.17.510';
+ $setup_info['catch']['version'] = '0.9.17.511';
$setup_info['catch']['app_order'] = 20;
$setup_info['catch']['enable'] = 1;
$setup_info['catch']['globals_checked'] = True;
Modified: trunk/catch/setup/tables_current.inc.php
===================================================================
--- trunk/catch/setup/tables_current.inc.php 2011-09-29 19:05:58 UTC (rev
7757)
+++ trunk/catch/setup/tables_current.inc.php 2011-09-30 10:54:25 UTC (rev
7758)
@@ -111,7 +111,7 @@
'input_type' => array('type' => 'varchar',
'precision' => 10,'nullable' => False),
'name' => array('type' => 'varchar',
'precision' => 50,'nullable' => False),
'descr' => array('type' => 'varchar',
'precision' => 200,'nullable' => true),
- 'value' => array('type' => 'varchar',
'precision' => 1000,'nullable' => False)
+ 'value' => array('type' => 'varchar',
'precision' => 1000,'nullable' => true)
),
'pk' => array('type_id','id'),
'fk' => array(),
Modified: trunk/catch/setup/tables_update.inc.php
===================================================================
--- trunk/catch/setup/tables_update.inc.php 2011-09-29 19:05:58 UTC (rev
7757)
+++ trunk/catch/setup/tables_update.inc.php 2011-09-30 10:54:25 UTC (rev
7758)
@@ -324,3 +324,23 @@
return $GLOBALS['setup_info']['catch']['currentver'];
}
}
+
+ /**
+ * Update catch version from 0.9.17.510 to 0.9.17.511
+ * Allow value is null
+ *
+ */
+
+ $test[] = '0.9.17.510';
+ function catch_upgrade0_9_17_510()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_catch_config_attrib','value',array('type'
=> 'varchar', 'precision' => 1000,'nullable' => true));
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['catch']['currentver'] =
'0.9.17.511';
+ return $GLOBALS['setup_info']['catch']['currentver'];
+ }
+ }
Modified: trunk/property/inc/cron/default/catch_ppc.php
===================================================================
--- trunk/property/inc/cron/default/catch_ppc.php 2011-09-29 19:05:58 UTC
(rev 7757)
+++ trunk/property/inc/cron/default/catch_ppc.php 2011-09-30 10:54:25 UTC
(rev 7758)
@@ -42,6 +42,7 @@
$this->db = & $GLOBALS['phpgw']->db;
$this->join = & $this->db->join;
$this->like = & $this->db->like;
+ set_time_limit(1000);
}
function pre_run($data = array())
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7758] catch: notify by email,
Sigurd Nes <=