[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10356] custom functions
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10356] custom functions |
Date: |
Fri, 26 Oct 2012 11:19:18 +0000 |
Revision: 10356
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10356
Author: sigurdne
Date: 2012-10-26 11:19:17 +0000 (Fri, 26 Oct 2012)
Log Message:
-----------
custom functions
Modified Paths:
--------------
trunk/phpgwapi/inc/class.custom_functions.inc.php
trunk/phpgwapi/inc/class.js.inc.php
trunk/phpgwapi/setup/setup.inc.php
trunk/phpgwapi/setup/tables_current.inc.php
trunk/phpgwapi/setup/tables_update.inc.php
trunk/property/inc/class.boadmin_entity.inc.php
trunk/property/inc/class.uiadmin_entity.inc.php
trunk/property/inc/class.uientity.inc.php
trunk/property/templates/base/admin_entity.xsl
trunk/property/templates/base/attributes_form.xsl
Modified: trunk/phpgwapi/inc/class.custom_functions.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.custom_functions.inc.php 2012-10-26 08:11:52 UTC
(rev 10355)
+++ trunk/phpgwapi/inc/class.custom_functions.inc.php 2012-10-26 11:19:17 UTC
(rev 10356)
@@ -130,6 +130,7 @@
'file_name' =>
$this->_db->db_addslashes($custom_function['custom_function_file']),
'descr' =>
$this->_db->db_addslashes($custom_function['descr']),
'active' =>
!!$custom_function['active'],
+ 'client_side' =>
!!$custom_function['client_side'],
'custom_sort' => $custom_sort
);
@@ -214,9 +215,10 @@
$values = array
(
- 'descr' =>
$this->_db->db_addslashes($custom_function['descr']),
- 'file_name' =>
$custom_function['custom_function_file'],
- 'active' => $custom_function['active']
+ 'descr' =>
$this->_db->db_addslashes($custom_function['descr']),
+ 'file_name' =>
$custom_function['custom_function_file'],
+ 'active' =>
$custom_function['active'],
+ 'client_side' =>
$custom_function['client_side'],
);
unset($custom_function);
@@ -313,11 +315,12 @@
$id = $this->_db->f('id');
$custom_functions[] = array
(
- 'id' => $id,
- 'file_name' =>
$this->_db->f('file_name'),
- 'sorting' =>
$this->_db->f('custom_sort'),
- 'descr' =>
$this->_db->f('descr'),
- 'active' =>
!!$this->_db->f('active')
+ 'id' => $id,
+ 'file_name' =>
$this->_db->f('file_name'),
+ 'sorting' =>
$this->_db->f('custom_sort'),
+ 'descr' =>
$this->_db->f('descr'),
+ 'active' =>
!!$this->_db->f('active'),
+ 'client_side' =>
!!$this->_db->f('client_side')
);
}
@@ -358,7 +361,8 @@
'id' =>
(int)$this->_db->f('id'),
'descr' =>
$this->_db->f('descr', true),
'custom_function_file' =>
$this->_db->f('file_name'),
- 'active' =>
!!$this->_db->f('active')
+ 'active' =>
!!$this->_db->f('active'),
+ 'client_side' =>
!!$this->_db->f('client_side')
);
}
Modified: trunk/phpgwapi/inc/class.js.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.js.inc.php 2012-10-26 08:11:52 UTC (rev 10355)
+++ trunk/phpgwapi/inc/class.js.inc.php 2012-10-26 11:19:17 UTC (rev 10356)
@@ -63,7 +63,16 @@
*/
protected $files = array();
+
/**
+ *
+ * @var array list of "external files to be included in the
head section of a page
+ * Some times while using libs and such its not fesable to move
js files to /app/js/package/
+ * because the js files are using relative paths
+ */
+ protected $external_files;
+
+ /**
* Constructor
*/
public function __construct()
@@ -171,6 +180,20 @@
unset($jsfiles);
}
+
+ if ( !empty($this->external_files) &&
is_array($this->external_files) )
+ {
+ foreach($this->external_files as $file)
+ {
+ $links .= <<<HTML
+ <script type="text/javascript"
src="{$GLOBALS['phpgw_info']['server']['webserver_url']}/{$file}" >
+
+HTML;
+ }
+ }
+
+
+
return $links;
}
@@ -277,4 +300,17 @@
. '//]]' ."\n"
. "</script>\n";
}
+
+ /**
+ * Adds js file to external files.
+ *
+ * @param string $file Full path to js file relative to root of
phpgw install
+ */
+ function add_external_file($file)
+ {
+ if ( is_file(PHPGW_SERVER_ROOT . "/$file") )
+ {
+ $this->external_files[] = $file;
+ }
+ }
}
Modified: trunk/phpgwapi/setup/setup.inc.php
===================================================================
--- trunk/phpgwapi/setup/setup.inc.php 2012-10-26 08:11:52 UTC (rev 10355)
+++ trunk/phpgwapi/setup/setup.inc.php 2012-10-26 11:19:17 UTC (rev 10356)
@@ -12,7 +12,7 @@
// Basic information about this app
$setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'phpgwapi';
- $setup_info['phpgwapi']['version'] = '0.9.17.541';
+ $setup_info['phpgwapi']['version'] = '0.9.17.542';
$setup_info['phpgwapi']['versions']['current_header'] = '1.31';
$setup_info['phpgwapi']['versions']['system'] = '1.0';
$setup_info['phpgwapi']['enable'] = 3;
Modified: trunk/phpgwapi/setup/tables_current.inc.php
===================================================================
--- trunk/phpgwapi/setup/tables_current.inc.php 2012-10-26 08:11:52 UTC (rev
10355)
+++ trunk/phpgwapi/setup/tables_current.inc.php 2012-10-26 11:19:17 UTC (rev
10356)
@@ -545,6 +545,7 @@
(
'location_id' => array('type' =>
'int','precision' => 4,'nullable' => false),
'id' => array('type' =>
'int','precision' => 4,'nullable' => false),
+ 'parent_id' => array('type'
=> 'int','precision' => 4,'nullable' => true),
'name' => array('type' =>
'varchar','precision' => 100,'nullable' => false),
'group_sort' => array('type' =>
'int','precision' => 2,'nullable' => false),
'descr' => array('type' =>
'varchar','precision' => 150,'nullable' => true),
@@ -616,6 +617,7 @@
'descr' => array('type' => 'text','nullable' =>
true),
'file_name' => array('type' =>
'varchar','precision' => 255,'nullable' => false),
'active' => array('type' => 'int','precision'
=> 2,'nullable' => true),
+ 'client_side' => array('type' =>
'int','precision' => 2,'nullable' => true),//otherwise: server-side
'custom_sort' => array('type' =>
'int','precision' => 4,'nullable' => true)
),
'pk' => array('location_id', 'id'),
Modified: trunk/phpgwapi/setup/tables_update.inc.php
===================================================================
--- trunk/phpgwapi/setup/tables_update.inc.php 2012-10-26 08:11:52 UTC (rev
10355)
+++ trunk/phpgwapi/setup/tables_update.inc.php 2012-10-26 11:19:17 UTC (rev
10356)
@@ -3097,6 +3097,7 @@
$test[] = '0.9.17.540';
/**
* Add custom attibute type that allows attribute used as part of short
description
+ * Add support for clien-side custom functions
*
* @return string the new version number
*/
@@ -3123,4 +3124,35 @@
}
}
+ $test[] = '0.9.17.541';
+ /**
+ * Allow groups within groups
+ *
+ * @return string the new version number
+ */
+ function phpgwapi_upgrade0_9_17_541()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cust_attribute_group','parent_id',
array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => true
+ ));
+
+
+ //otherwise: server-side
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cust_function','client_side',
array(
+ 'type' => 'int',
+ 'precision' => 2,
+ 'nullable' => true
+ ));
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['phpgwapi']['currentver'] =
'0.9.17.542';
+ return $GLOBALS['setup_info']['phpgwapi']['currentver'];
+ }
+ }
+
+
Modified: trunk/property/inc/class.boadmin_entity.inc.php
===================================================================
--- trunk/property/inc/class.boadmin_entity.inc.php 2012-10-26 08:11:52 UTC
(rev 10355)
+++ trunk/property/inc/class.boadmin_entity.inc.php 2012-10-26 11:19:17 UTC
(rev 10356)
@@ -538,6 +538,7 @@
function save_custom_function( $custom_function, $action = '' )
{
+ $receipt = array();
$custom_function['appname'] =
$this->type_app[$this->type];
if ( !$custom_function['location'] &&
$custom_function['entity_id'] && $custom_function['cat_id'] )
{
@@ -549,12 +550,27 @@
if ( $custom_function['id'] != '' )
{
- $receipt =
$GLOBALS['phpgw']->custom_functions->edit( $custom_function );
+ $receipt['id'] = $custom_function['id'];
+ if(
$GLOBALS['phpgw']->custom_functions->edit( $custom_function ) )
+ {
+ $receipt['message'][] =
array('msg'=>'OK');
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>'Error');
+ }
}
}
else
{
- $receipt =
$GLOBALS['phpgw']->custom_functions->add( $custom_function );
+ if($receipt['id'] =
$GLOBALS['phpgw']->custom_functions->add( $custom_function ) )
+ {
+ $receipt['message'][] =
array('msg'=>'OK');
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>'Error');
+ }
}
return $receipt;
}
@@ -597,4 +613,4 @@
return $this->so->convert_to_eav();
}
- }
\ No newline at end of file
+ }
Modified: trunk/property/inc/class.uiadmin_entity.inc.php
===================================================================
--- trunk/property/inc/class.uiadmin_entity.inc.php 2012-10-26 08:11:52 UTC
(rev 10355)
+++ trunk/property/inc/class.uiadmin_entity.inc.php 2012-10-26 11:19:17 UTC
(rev 10356)
@@ -2547,16 +2547,18 @@
$uicols['descr'][1] = lang('id');
$uicols['name'][2] = 'descr';
$uicols['descr'][2] = lang('Descr');
- $uicols['name'][3] = 'active';
- $uicols['descr'][3] = lang('Active');
- $uicols['name'][4] = 'sorting';
- $uicols['descr'][4] = lang('sorting');
- $uicols['name'][5] = 'up';
- $uicols['descr'][5] = lang('up');
- $uicols['name'][6] = 'down';
- $uicols['descr'][6] = lang('down');
- $uicols['name'][7] = 'file_name';
- $uicols['descr'][7] = lang('Name');
+ $uicols['name'][3] = 'client_side';
+ $uicols['descr'][3] = lang('client-side');
+ $uicols['name'][4] = 'active';
+ $uicols['descr'][4] = lang('Active');
+ $uicols['name'][5] = 'sorting';
+ $uicols['descr'][5] = lang('sorting');
+ $uicols['name'][6] = 'up';
+ $uicols['descr'][6] = lang('up');
+ $uicols['name'][7] = 'down';
+ $uicols['descr'][7] = lang('down');
+ $uicols['name'][8] = 'file_name';
+ $uicols['descr'][8] = lang('Name');
$j = 0;
$count_uicols_name = count($uicols['name']);
@@ -2882,7 +2884,6 @@
'type' => $this->type
);
-
//_debug_array($values);
$entity = $this->bo->read_single($entity_id,false);
@@ -2920,6 +2921,7 @@
'custom_function_list'
=> $this->bo->select_custom_function($values['custom_function_file']),
'value_active'
=> $values['active'],
+ 'value_client_side'
=> $values['client_side'],
'lang_active'
=> lang('Active'),
'lang_active_statustext'
=> lang('check to activate custom function'),
);
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2012-10-26 08:11:52 UTC (rev
10355)
+++ trunk/property/inc/class.uientity.inc.php 2012-10-26 11:19:17 UTC (rev
10356)
@@ -2070,7 +2070,37 @@
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
$GLOBALS['phpgw']->js->validate_file( 'yahoo',
'entity.edit', 'property' );
+ $criteria = array
+ (
+ 'appname' =>
$this->type_app[$this->type],
+ 'location' =>
".{$this->type}.{$this->entity_id}.{$this->cat_id}",
+ 'allrows' => true
+ );
+ $custom_functions =
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+ if($custom_functions)
+ {
+ phpgw::import_class('phpgwapi.jquery');
+ phpgwapi_jquery::load_widget('core');
+ }
+
+ foreach ( $custom_functions as $entry )
+ {
+ // prevent path traversal
+ if ( preg_match('/\.\./', $entry['file_name']) )
+ {
+ continue;
+ }
+
+ $file = PHPGW_SERVER_ROOT .
"/{$this->type_app[$this->type]}/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+
+ if ( $entry['active'] && $entry['client_side']
&& is_file($file))
+ {
+
$GLOBALS['phpgw']->js->add_external_file("{$this->type_app[$this->type]}/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}");
+ }
+ }
+
}
function attrib_help()
Modified: trunk/property/templates/base/admin_entity.xsl
===================================================================
--- trunk/property/templates/base/admin_entity.xsl 2012-10-26 08:11:52 UTC
(rev 10355)
+++ trunk/property/templates/base/admin_entity.xsl 2012-10-26 11:19:17 UTC
(rev 10356)
@@ -1869,7 +1869,7 @@
</xsl:template>
<!-- add custom_function / edit custom_function -->
- <xsl:template match="edit_custom_function">
+ <xsl:template match="edit_custom_function"
xmlns:php="http://php.net/xsl">
<div align="left">
<table cellpadding="2" cellspacing="2" width="80%"
align="center">
<xsl:choose>
@@ -1971,6 +1971,23 @@
</xsl:choose>
</td>
</tr>
+ <tr>
+ <td>
+ <xsl:value-of
select="php:function('lang', 'client-side')"/>
+ </td>
+ <td>
+ <input type="checkbox"
name="values[client_side]" value="1">
+ <xsl:attribute
name="title">
+
<xsl:text>otherwise: server-side</xsl:text>
+ </xsl:attribute>
+ <xsl:if
test="value_client_side = '1'">
+
<xsl:attribute name="checked">
+
<xsl:text>checked</xsl:text>
+ </xsl:attribute>
+ </xsl:if>
+ </input>
+ </td>
+ </tr>
<tr height="50">
<td>
<xsl:variable
name="lang_save">
Modified: trunk/property/templates/base/attributes_form.xsl
===================================================================
--- trunk/property/templates/base/attributes_form.xsl 2012-10-26 08:11:52 UTC
(rev 10355)
+++ trunk/property/templates/base/attributes_form.xsl 2012-10-26 11:19:17 UTC
(rev 10356)
@@ -71,7 +71,7 @@
<xsl:call-template name="choice"/>
</xsl:when>
<xsl:when
test="datatype='LB'">
- <select
name="values_attribute[{counter}][value]" class="forms">
+ <select
id="id_{name}" name="values_attribute[{counter}][value]" class="forms">
<xsl:choose>
<xsl:when test="disabled!=''">
<xsl:attribute name="disabled">
@@ -450,7 +450,7 @@
</table>
</xsl:when>
<xsl:when
test="datatype='T'">
- <textarea
cols="{//textareacols}" rows="{//textarearows}"
name="values_attribute[{counter}][value]">
+ <textarea
id="id_{name}" cols="{//textareacols}" rows="{//textarearows}"
name="values_attribute[{counter}][value]">
<xsl:choose>
<xsl:when test="disabled!=''">
<xsl:attribute name="disabled">
@@ -492,7 +492,7 @@
</table>
</xsl:when>
<xsl:when
test="datatype='bolean'">
- <input
type="checkbox" name="values_attribute[{counter}][value]" value="1">
+ <input
id="id_{name}" type="checkbox" name="values_attribute[{counter}][value]"
value="1">
<xsl:choose>
<xsl:when test="value!=''">
<xsl:attribute name="checked">
@@ -574,7 +574,7 @@
</xsl:choose>
</xsl:when>
<xsl:otherwise>
- <input
type="text" name="values_attribute[{counter}][value]" value="{value}" size="30">
+ <input
id="id_{name}" type="text" name="values_attribute[{counter}][value]"
value="{value}" size="30">
<xsl:choose>
<xsl:when test="disabled!=''">
<xsl:attribute name="disabled">
@@ -614,6 +614,9 @@
<xsl:variable name="counter">
<xsl:value-of select="counter"/>
</xsl:variable>
+ <xsl:variable name="name">
+ <xsl:value-of select="name"/>
+ </xsl:variable>
<table cellpadding="2" cellspacing="2" align="left">
<xsl:for-each select="choice">
<tr>
@@ -633,10 +636,10 @@
<td align="left">
<xsl:choose>
<xsl:when
test="checked='checked'">
- <input
type="{input_type}" name="values_attribute[{$counter}][value][]" value="{id}"
checked="checked"/>
+ <input
id="id_{$name}_{id}" type="{input_type}"
name="values_attribute[{$counter}][value][]" value="{id}" checked="checked"/>
</xsl:when>
<xsl:otherwise>
- <input
type="{input_type}" name="values_attribute[{$counter}][value][]" value="{id}"/>
+ <input
id="id_{$name}_{id}" type="{input_type}"
name="values_attribute[{$counter}][value][]" value="{id}"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10356] custom functions,
Sigurd Nes <=