[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [13403] property: update ticket on project change
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [13403] property: update ticket on project change |
Date: |
Wed, 10 Jun 2015 17:37:48 +0000 |
Revision: 13403
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13403
Author: sigurdne
Date: 2015-06-10 17:37:47 +0000 (Wed, 10 Jun 2015)
Log Message:
-----------
property: update ticket on project change
Modified Paths:
--------------
trunk/property/inc/class.boproject.inc.php
trunk/property/inc/class.menu.inc.php
Added Paths:
-----------
trunk/property/inc/custom/default/EBF_update_ticket_on_project_change.php
Modified: trunk/property/inc/class.boproject.inc.php
===================================================================
--- trunk/property/inc/class.boproject.inc.php 2015-06-10 13:11:58 UTC (rev
13402)
+++ trunk/property/inc/class.boproject.inc.php 2015-06-10 17:37:47 UTC (rev
13403)
@@ -44,6 +44,7 @@
var $cat_id;
var $allrows;
var $project_type_id;
+ var $acl_location = '.project';
var $public_functions = array
(
@@ -54,11 +55,11 @@
'check_perms' => true
);
- function property_boproject($session=false)
+ function __construct($session=false)
{
$this->so =
CreateObject('property.soproject');
$this->bocommon = &
$this->so->bocommon;
- $this->cats =
CreateObject('phpgwapi.categories', -1, 'property', '.project');
+ $this->cats =
CreateObject('phpgwapi.categories', -1, 'property', $this->acl_location);
$this->cats->supress_info = true;
$this->interlink = &
$this->so->interlink;
$this->custom = &
$this->so->custom;
@@ -907,6 +908,34 @@
$values_attribute =
$this->custom->convert_attribute_save($values_attribute);
}
+ // Custom rules - pre commit
+ $criteria = array
+ (
+ 'appname' => 'property',
+ 'location' => '.project',
+ 'allrows' => true
+ );
+
+ $custom_functions =
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+ foreach ( $custom_functions as $entry )
+ {
+ // prevent path traversal
+ if ( preg_match('/\.\./', $entry['file_name']) )
+ {
+ continue;
+ }
+
+ $file = PHPGW_SERVER_ROOT .
"/property/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+
+ if ( $entry['active'] && is_file($file) &&
!$entry['client_side'] && $entry['pre_commit'])
+ {
+ require_once $file;
+ }
+ }
+ unset($entry);
+ reset($custom_functions);
+
if ($action=='edit')
{
try
@@ -945,6 +974,22 @@
{
$receipt = $this->so->add($project,
$values_attribute);
}
+
+ foreach ( $custom_functions as $entry )
+ {
+ // prevent path traversal
+ if ( preg_match('/\.\./', $entry['file_name']) )
+ {
+ continue;
+ }
+
+ $file = PHPGW_SERVER_ROOT .
"/property/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+
+ if ( $entry['active'] && is_file($file) &&
!$entry['client_side'] && !$entry['pre_commit'])
+ {
+ require_once $file;
+ }
+ }
return $receipt;
}
Modified: trunk/property/inc/class.menu.inc.php
===================================================================
--- trunk/property/inc/class.menu.inc.php 2015-06-10 13:11:58 UTC (rev
13402)
+++ trunk/property/inc/class.menu.inc.php 2015-06-10 17:37:47 UTC (rev
13403)
@@ -156,6 +156,55 @@
)
);
+ $admin_children_project = array
+ (
+ 'project_cats' => array
+ (
+ 'text' =>
lang('project categories'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.uicategories.index', 'appname' => 'property', 'location' => '.project',
'global_cats' => 'true', 'menu_selection' =>
'admin::property::project::project_cats') )
+ ),
+ 'project_attribs' => array
+ (
+ 'text' =>
lang('project attributes'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.ui_custom.list_attribute', 'appname' => 'property', 'location'
=>'.project', 'menu_selection' => 'admin::property::project::project_attribs') )
+ ),
+ 'workorder_status' => array
+ (
+ 'text' =>
lang('Workorders status'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'workorder_status') )
+ ),
+ 'project_status' => array
+ (
+ 'text' =>
lang('project status'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'project_status') )
+ ),
+ 'project_group' => array
+ (
+ 'text' =>
lang('project group'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'project_group') )
+ ),
+ 'workorder_detail' => array
+ (
+ 'text' =>
lang('Workorder Detail Categories'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'wo_hours') )
+ ),
+ 'workorder_recalculate' => array
+ (
+ 'text' =>
lang('Workorder recalculate actual cost'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uiworkorder.recalculate') )
+ ),
+ 'project_functions' => array
+ (
+ 'text' => lang('custom
functions'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.ui_custom.list_custom_function','appname' => 'property', 'location' =>
'.project', 'menu_selection' => 'admin::property::project::project_functions') )
+ ),
+ 'check_missing_project_budget'
=> array
+ (
+ 'text' => lang('check
missing project budget'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uiproject.check_missing_project_budget') )
+ )
+ );
+
$admin_children_ticket = array
(
'ticket_cats' => array
@@ -296,16 +345,7 @@
(
'text' =>
lang('Accounting voucher type'),
'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'voucher_type') )
- ),
- 'check_missing_project_budget'
=> array
- (
- 'text' => lang('check
missing project budget'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uiproject.check_missing_project_budget') )
)
-
-
-
-
);
$admin_children_agreement = array
@@ -435,26 +475,12 @@
'text' => lang('Update
the not active category for locations'),
'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uilocation.update_cat') )
),
- 'project_cats' => array
+ 'project' => array
(
- 'text' =>
lang('project categories'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.uicategories.index', 'appname' => 'property', 'location' => '.project',
'global_cats' => 'true', 'menu_selection' => 'admin::property::project_cats') )
+ 'text' =>
lang('project'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.uicategories.index', 'appname' => 'property', 'location' => '.project',
'global_cats' => 'true', 'menu_selection' =>
'admin::property::project::project_cats') ),
+ 'children' =>
$admin_children_project
),
- 'project_attribs' => array
- (
- 'text' =>
lang('project attributes'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.ui_custom.list_attribute', 'appname' => 'property', 'location'
=>'.project', 'menu_selection' => 'admin::property::project_attribs') )
- ),
- 'workorder_detail' => array
- (
- 'text' =>
lang('Workorder Detail Categories'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'wo_hours') )
- ),
- 'workorder_recalculate' => array
- (
- 'text' =>
lang('Workorder recalculate actual cost'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uiworkorder.recalculate') )
- ),
'ticket' => array
(
'text' =>
lang('helpdesk'),
@@ -560,21 +586,6 @@
'text' =>
lang('order_dim1'),//translation have to refeflect the (local) meaning
'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'order_dim1') )
),
- 'workorder_status' => array
- (
- 'text' =>
lang('Workorders status'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'workorder_status') )
- ),
- 'project_status' => array
- (
- 'text' =>
lang('project status'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'project_status') )
- ),
- 'project_group' => array
- (
- 'text' =>
lang('project group'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uigeneric.index', 'type' => 'project_group') )
- ),
'agreement' => array
(
'text' =>
lang('Agreement'),
Added: trunk/property/inc/custom/default/EBF_update_ticket_on_project_change.php
===================================================================
--- trunk/property/inc/custom/default/EBF_update_ticket_on_project_change.php
(rev 0)
+++ trunk/property/inc/custom/default/EBF_update_ticket_on_project_change.php
2015-06-10 17:37:47 UTC (rev 13403)
@@ -0,0 +1,87 @@
+<?php
+
+ /*
+ * This class will update finnish date in ticket where tickets are
linked to project.
+ */
+
+ class update_ticket_on_project_change extends property_boproject
+ {
+
+ function __construct()
+ {
+ parent::__construct();
+ if($this->acl_location != '.project')
+ {
+ throw new
Exception("'update_ticket_on_project_change' is intended for location =
'.project'");
+ }
+ $this->historylog =
CreateObject('property.historylog','tts');
+ $this->botts =
CreateObject('property.botts');
+ $this->db = &
$GLOBALS['phpgw']->db;
+ $this->like = & $this->db->like;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
+
+ }
+
+ public function check_values($project, $values_attribute)
+ {
+ $origin = $this->interlink->get_relation('property',
'.project', $project['id'], 'origin');
+ $ids = array();
+ foreach($origin as $_origin)
+ {
+ if($_origin['location'] == '.ticket')
+ {
+ foreach($_origin['data'] as $data)
+ {
+ $ids[]=$data['id'];
+ }
+ }
+ }
+
+ foreach($ids as $id)
+ {
+ $this->update_ticket($id, $project,
$values_attribute);
+ }
+ }
+
+ private function update_ticket($id, $project, $values_attribute)
+ {
+ $finnish_date = (int)$project['end_date'];
+ if(!$finnish_date)
+ {
+ return;
+ }
+
+ $this->db->query("SELECT finnish_date, finnish_date2
FROM fm_tts_tickets WHERE id='$id'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $oldfinnish_date = (int)$this->db->f('finnish_date');
+ $oldfinnish_date2 = (int)$this->db->f('finnish_date2');
+
+ $update = false;
+
+ if ($oldfinnish_date && $finnish_date &&
$oldfinnish_date2 != $finnish_date)
+ {
+ $this->db->query("UPDATE fm_tts_tickets SET
finnish_date2='{$finnish_date}' WHERE id='{$id}'",__LINE__,__FILE__);
+ $old_value = $oldfinnish_date2;
+ $update = true;
+ }
+ else if(!$oldfinnish_date && $finnish_date &&
$oldfinnish_date != $finnish_date)
+ {
+ $this->db->query("UPDATE fm_tts_tickets SET
finnish_date='{$finnish_date}' , finnish_date2='{$finnish_date}' WHERE
id='{$id}'",__LINE__,__FILE__);
+ $old_value = $oldfinnish_date;
+ $update = true;
+ }
+
+ if($update)
+ {
+ $fields_updated = array('finnish_date');
+
$this->historylog->add('F',$id,$finnish_date,$old_value);
+ $this->botts->mail_ticket($id, $fields_updated,
$receipt=array(),'', false, true);
+ }
+ }
+ }
+
+ $trigger = new update_ticket_on_project_change();
+ $trigger->check_values($project, $values_attribute);
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [13403] property: update ticket on project change,
Sigurd Nes <=