2011-09-15 20:00:17 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EGroupware - eTemplate serverside date widget
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @copyright 2011 Nathan Gray
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* eTemplate project manager widgets
|
|
|
|
*
|
|
|
|
* @todo Move to projectmanager app once etemplate_new recognises other app's widgets
|
|
|
|
*/
|
|
|
|
class etemplate_widget_projectmanager extends etemplate_widget_transformer
|
|
|
|
{
|
|
|
|
protected static $transformation = array(
|
|
|
|
'type' => array(
|
|
|
|
'projectmanager-select' => 'menupopup',
|
|
|
|
'projectmanager-pricelist' => 'menupopup',
|
|
|
|
'projectmanager-select-erole' => 'menupopup',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* (Array of) comma-separated list of legacy options to automatically replace when parsing with set_attrs
|
|
|
|
*
|
|
|
|
* @var string|array
|
|
|
|
*/
|
|
|
|
protected $legacy_options = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill type options in self::$request->sel_options to be used on the client
|
|
|
|
*
|
|
|
|
* @param string $cname
|
|
|
|
*/
|
|
|
|
public function beforeSendToClient($cname)
|
|
|
|
{
|
2012-03-14 12:32:28 +01:00
|
|
|
$form_name = self::form_name($cname, $this->id);
|
2012-03-14 00:09:16 +01:00
|
|
|
if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array();
|
2012-03-14 12:32:28 +01:00
|
|
|
|
2011-09-15 20:00:17 +02:00
|
|
|
if ($this->type)
|
|
|
|
{
|
|
|
|
$pm_widget = new projectmanager_widget();
|
2013-11-06 22:03:33 +01:00
|
|
|
if($this->is_readonly($cname, $form_name))
|
2013-11-04 22:53:05 +01:00
|
|
|
{
|
2013-11-06 22:03:33 +01:00
|
|
|
// Go direct to get full erole list
|
|
|
|
$eroles = new projectmanager_eroles_bo();
|
|
|
|
foreach((array)$eroles->search(array(),false,'role_title ASC','','',false,'AND',false,array('pm_id'=>array(0,$eroles->pm_id))) as $erole)
|
|
|
|
{
|
|
|
|
self::$request->sel_options[$form_name][$erole['role_id']] = array(
|
|
|
|
'label' => $erole['role_description'],
|
|
|
|
'title' => lang('Element role title').': '.$erole['role_title'].$eroles->get_info($erole['role_id']),
|
|
|
|
);
|
|
|
|
}
|
2013-11-04 22:53:05 +01:00
|
|
|
}
|
2013-02-08 17:10:26 +01:00
|
|
|
$cell = $this->attrs;
|
|
|
|
$cell['type']=$this->type;
|
2013-11-06 22:03:33 +01:00
|
|
|
$cell['readonly'] = false;
|
2012-03-14 12:32:28 +01:00
|
|
|
$pm_widget->pre_process($form_name, self::get_array(self::$request->content, $form_name),
|
2011-09-15 20:00:17 +02:00
|
|
|
$cell,
|
2013-10-17 19:02:36 +02:00
|
|
|
$garbage,
|
2011-09-15 20:00:17 +02:00
|
|
|
$extension,
|
|
|
|
$template
|
|
|
|
);
|
2012-04-24 21:44:50 +02:00
|
|
|
self::$request->sel_options[$form_name] += (array)$cell['sel_options'];
|
2011-09-15 20:00:17 +02:00
|
|
|
|
|
|
|
// if no_lang was modified, forward modification to the client
|
2012-03-14 12:32:28 +01:00
|
|
|
if ($cell['no_lang'] != $this->attr['no_lang'])
|
|
|
|
{
|
|
|
|
self::setElementAttribute($form_name, 'no_lang', $no_lang);
|
|
|
|
}
|
2011-09-15 20:00:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
parent::beforeSendToClient($cname);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validate input
|
|
|
|
*
|
|
|
|
* @todo
|
|
|
|
* @param string $cname current namespace
|
|
|
|
* @param array $content
|
2012-05-03 16:17:47 +02:00
|
|
|
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
2011-09-15 20:00:17 +02:00
|
|
|
* @param array &$validated=array() validated content
|
|
|
|
* @return boolean true if no validation error, false otherwise
|
|
|
|
*/
|
2012-05-03 16:17:47 +02:00
|
|
|
public function validate($cname, array $expand, array $content, &$validated=array())
|
2011-09-15 20:00:17 +02:00
|
|
|
{
|
2013-02-08 17:10:26 +01:00
|
|
|
$form_name = self::form_name($cname, $this->id, $expand);
|
|
|
|
|
|
|
|
$ok = true;
|
|
|
|
if (!$this->is_readonly($cname, $form_name))
|
|
|
|
{
|
|
|
|
$value = $value_in = self::get_array($content, $form_name);
|
|
|
|
|
|
|
|
switch($this->type)
|
|
|
|
{
|
|
|
|
case 'projectmanager-select-erole':
|
|
|
|
$value = null;
|
|
|
|
if(is_array($value_in)) $value = implode(',',$value_in);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$value = $value_in;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$valid =& self::get_array($validated, $form_name, true);
|
|
|
|
$valid = $value;
|
|
|
|
}
|
2011-09-15 20:00:17 +02:00
|
|
|
}
|
|
|
|
}
|