[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [17265] prepare for custom code outside tree
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [17265] prepare for custom code outside tree |
Date: |
Thu, 2 Nov 2017 12:25:09 -0400 (EDT) |
Revision: 17265
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17265
Author: sigurdne
Date: 2017-11-02 12:25:07 -0400 (Thu, 02 Nov 2017)
Log Message:
-----------
prepare for custom code outside tree
Added Paths:
-----------
thirdparty/PE_custom/BK_EBE/helpdesk/
thirdparty/PE_custom/BK_EBE/helpdesk/inc/
thirdparty/PE_custom/BK_EBE/helpdesk/inc/custom/
thirdparty/PE_custom/BK_EBE/helpdesk/inc/custom/helpdesk/
thirdparty/PE_custom/BK_EBE/helpdesk/inc/custom/helpdesk/ticket_LRS_pre_commit_validate.php
Copied:
thirdparty/PE_custom/BK_EBE/helpdesk/inc/custom/helpdesk/ticket_LRS_pre_commit_validate.php
(from rev 17264,
trunk/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php)
===================================================================
---
thirdparty/PE_custom/BK_EBE/helpdesk/inc/custom/helpdesk/ticket_LRS_pre_commit_validate.php
(rev 0)
+++
thirdparty/PE_custom/BK_EBE/helpdesk/inc/custom/helpdesk/ticket_LRS_pre_commit_validate.php
2017-11-02 16:25:07 UTC (rev 17265)
@@ -0,0 +1,96 @@
+<?php
+ /*
+ * This file will only work for the implementation of LRS
+ */
+
+ /**
+ * Intended for custom validation of tickets prior to commit.
+ *
+ * @author Sigurd Nes <address@hidden>
+ */
+ class ticket_LRS_pre_commit_validate extends helpdesk_botts
+ {
+
+ protected
+ $db,
+ $join,
+ $left_join,
+ $like;
+ function __construct()
+ {
+ parent::__construct();
+ $this->db = & $GLOBALS['phpgw']->db;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
+ $this->like = & $this->db->like;
+ }
+
+ /**
+ * Do your magic
+ * @param integer $id
+ * @param array $data
+ * @param array $values_attribute
+ */
+ function validate( $id = 0, &$data, $values_attribute = array()
)
+ {
+ if($id) // only on add
+ {
+ return;
+ }
+
+ if(!empty($data['reverse_id']))
+ {
+ return true;
+ }
+
+ $org_unit = (int)$values_attribute['1']['value'];
+ $sql = "SELECT arbeidssted FROM fm_org_unit WHERE id =
{$org_unit}";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $arbeidssted = (int)$this->db->f('arbeidssted');
+ $category = CreateObject('phpgwapi.categories', -1,
'helpdesk', '.ticket')->return_single($data['cat_id']);
+ $parent_id = (int)$category[0]['parent'];
+
+ if($parent_id == 255)
+ {
+ $location_id =
$GLOBALS['phpgw']->locations->get_id('property', ".entity.6.1");
+ }
+ else
+ {
+ $location_id =
$GLOBALS['phpgw']->locations->get_id('property', ".entity.6.2");
+ }
+
+
+ $sql = "SELECT json_representation->>'alias' as alias
FROM fm_bim_item WHERE location_id = {$location_id}"
+ . " AND CAST(json_representation->>'arbeidssted_start'
AS INTEGER) <= {$arbeidssted}"
+ . " AND CAST(json_representation->>'arbeidssted_slutt'
AS INTEGER) >= {$arbeidssted}";
+
+ $this->db->query($sql);
+ $this->db->next_record();
+ $alias = strtolower($this->db->f('alias'));
+
+ if(!$data['assignedto'] =
$GLOBALS['phpgw']->accounts->name2id($alias))
+ {
+ $data['assignedto'] =
isset($GLOBALS['phpgw_info']['user']['preferences']['helpdesk']['assigntodefault'])
? $GLOBALS['phpgw_info']['user']['preferences']['helpdesk']['assigntodefault']
: '';
+ }
+
+ $current_prefs_user =
$this->bocommon->create_preferences('helpdesk',$GLOBALS['phpgw_info']['user']['account_id']);
+ if(empty($current_prefs_user['email']))
+ {
+ $GLOBALS['phpgw']->preferences->add('helpdesk',
'email', "{$GLOBALS['phpgw_info']['user']['account_lid'address@hidden");
+
$GLOBALS['phpgw']->preferences->save_repository();
+ }
+
+ $assigned_prefs = createObject('phpgwapi.preferences',
(int)$data['assignedto']);
+ $assigned_prefs_data = $assigned_prefs->read();
+ if(empty($assigned_prefs_data['helpdesk']['email']))
+ {
+ $assigned_prefs->add('helpdesk', 'email',
"address@hidden");
+ $assigned_prefs->save_repository();
+ }
+
+ return true;
+ }
+ }
+ $ticket_LRS_pre_commit_validate = new ticket_LRS_pre_commit_validate();
+ $ticket_LRS_pre_commit_validate->validate($id, $data,
$values_attribute);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [17265] prepare for custom code outside tree,
sigurdne <=