mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 17:33:49 +01:00
initial implementation of merge class and element roles for projectmanager - projectmanager fields are not yet supported but will be implemented later. This feature is sponsored by www.inspectionsunlimited.com.
This commit is contained in:
parent
bf2155634d
commit
b80eaab81f
@ -37,9 +37,10 @@ class addressbook_merge extends bo_merge
|
|||||||
*
|
*
|
||||||
* @param int $id id of entry
|
* @param int $id id of entry
|
||||||
* @param string &$content=null content to create some replacements only if they are use
|
* @param string &$content=null content to create some replacements only if they are use
|
||||||
|
* @param array $eroles=null element roles with keys app, app_id and erole_id
|
||||||
* @return array|boolean
|
* @return array|boolean
|
||||||
*/
|
*/
|
||||||
protected function get_replacements($id,&$content=null)
|
protected function get_replacements($id,&$content=null,$eroles=null)
|
||||||
{
|
{
|
||||||
if (!($replacements = $this->contact_replacements($id)))
|
if (!($replacements = $this->contact_replacements($id)))
|
||||||
{
|
{
|
||||||
|
@ -69,9 +69,10 @@ abstract class bo_merge
|
|||||||
*
|
*
|
||||||
* @param int $id id of entry
|
* @param int $id id of entry
|
||||||
* @param string &$content=null content to create some replacements only if they are use
|
* @param string &$content=null content to create some replacements only if they are use
|
||||||
|
* @param array $eroles=null element roles with keys app, app_id and erole_id
|
||||||
* @return array|boolean array with replacements or false if entry not found
|
* @return array|boolean array with replacements or false if entry not found
|
||||||
*/
|
*/
|
||||||
abstract protected function get_replacements($id,&$content=null);
|
abstract protected function get_replacements($id,&$content=null,$eroles=null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if merge-print is implemented for given mime-type (and/or extension)
|
* Return if merge-print is implemented for given mime-type (and/or extension)
|
||||||
@ -123,7 +124,7 @@ abstract class bo_merge
|
|||||||
* Return replacements for a contact
|
* Return replacements for a contact
|
||||||
*
|
*
|
||||||
* @param int|string|array $contact contact-array or id
|
* @param int|string|array $contact contact-array or id
|
||||||
* @param string $prefix='' prefix like eg. 'user'
|
* @param string $prefix='' prefix like eg. 'user' or 'erole'
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function contact_replacements($contact,$prefix='')
|
public function contact_replacements($contact,$prefix='')
|
||||||
@ -252,9 +253,10 @@ abstract class bo_merge
|
|||||||
* @param string &$err error-message on error
|
* @param string &$err error-message on error
|
||||||
* @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
|
* @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
|
||||||
* @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
|
* @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
|
||||||
|
* @param array $eroles=null element roles with keys app, app_id and erole_id
|
||||||
* @return string|boolean merged document or false on error
|
* @return string|boolean merged document or false on error
|
||||||
*/
|
*/
|
||||||
public function &merge($document,$ids,&$err,$mimetype,array $fix=null)
|
public function &merge($document,$ids,&$err,$mimetype,array $fix=null,array $eroles=null)
|
||||||
{
|
{
|
||||||
if (!($content = file_get_contents($document)))
|
if (!($content = file_get_contents($document)))
|
||||||
{
|
{
|
||||||
@ -266,7 +268,7 @@ abstract class bo_merge
|
|||||||
{
|
{
|
||||||
$mimetype = 'application/rtf';
|
$mimetype = 'application/rtf';
|
||||||
}
|
}
|
||||||
return $this->merge_string($content,$ids,$err,$mimetype,$fix);
|
return $this->merge_string($content,$ids,$err,$mimetype,$fix,$eroles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -277,10 +279,10 @@ abstract class bo_merge
|
|||||||
* @param string &$err error-message on error
|
* @param string &$err error-message on error
|
||||||
* @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
|
* @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
|
||||||
* @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
|
* @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
|
||||||
* @param string $document=null path/url of document, if applicable
|
* @param array $eroles=null element roles with keys app, app_id and erole_id
|
||||||
* @return string|boolean merged document or false on error
|
* @return string|boolean merged document or false on error
|
||||||
*/
|
*/
|
||||||
public function &merge_string($content,$ids,&$err,$mimetype,array $fix=null)
|
public function &merge_string($content,$ids,&$err,$mimetype,array $fix=null,array $eroles=null)
|
||||||
{
|
{
|
||||||
if ($mimetype == 'application/xml' &&
|
if ($mimetype == 'application/xml' &&
|
||||||
preg_match('/'.preg_quote('<?mso-application progid="').'([^"]+)'.preg_quote('"?>').'/',substr($content,0,200),$matches))
|
preg_match('/'.preg_quote('<?mso-application progid="').'([^"]+)'.preg_quote('"?>').'/',substr($content,0,200),$matches))
|
||||||
@ -356,11 +358,11 @@ abstract class bo_merge
|
|||||||
if ($lableprint) $content = $Labelrepeat;
|
if ($lableprint) $content = $Labelrepeat;
|
||||||
|
|
||||||
// generate replacements
|
// generate replacements
|
||||||
if (!($replacements = $this->get_replacements($id,$content)))
|
if(!($replacements = $this->get_replacements($id,$content,is_array($eroles) ? $eroles : null)))
|
||||||
{
|
{
|
||||||
$err = lang('Entry not found!');
|
$err = lang('Entry not found!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// some general replacements: current user, date and time
|
// some general replacements: current user, date and time
|
||||||
if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')))
|
if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')))
|
||||||
{
|
{
|
||||||
@ -635,9 +637,10 @@ abstract class bo_merge
|
|||||||
*
|
*
|
||||||
* @param string $document vfs-path of document
|
* @param string $document vfs-path of document
|
||||||
* @param array $ids array with contact id(s)
|
* @param array $ids array with contact id(s)
|
||||||
|
* @param array $eroles=null element roles with keys app, app_id and erole_id
|
||||||
* @return string with error-message on error, otherwise it does NOT return
|
* @return string with error-message on error, otherwise it does NOT return
|
||||||
*/
|
*/
|
||||||
public function download($document,$ids)
|
public function download($document,$ids,$eroles=null)
|
||||||
{
|
{
|
||||||
$content_url = egw_vfs::PREFIX.$document;
|
$content_url = egw_vfs::PREFIX.$document;
|
||||||
switch (($mimetype = egw_vfs::mime_content_type($document)))
|
switch (($mimetype = egw_vfs::mime_content_type($document)))
|
||||||
@ -684,7 +687,7 @@ abstract class bo_merge
|
|||||||
$content_url = 'zip://'.$archive.'#'.($content_file = 'xl/sharedStrings.xml');
|
$content_url = 'zip://'.$archive.'#'.($content_file = 'xl/sharedStrings.xml');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!($merged =& $this->merge($content_url,$ids,$err,$mimetype,$fix)))
|
if (!($merged =& $this->merge($content_url,$ids,$err,$mimetype,$fix,$eroles)))
|
||||||
{
|
{
|
||||||
return $err;
|
return $err;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class select_widget
|
|||||||
'post_process' => True,
|
'post_process' => True,
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* availible extensions and there names for the editor
|
* availible extensions and their names for the editor
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $human_name = array(
|
var $human_name = array(
|
||||||
@ -38,6 +38,7 @@ class select_widget
|
|||||||
'select-country' => 'Select Country',
|
'select-country' => 'Select Country',
|
||||||
'select-state' => 'Select State', // US-states
|
'select-state' => 'Select State', // US-states
|
||||||
'select-cat' => 'Select Category', // Category-Selection, size: -1=Single+All, 0=Single, >0=Multiple with size lines
|
'select-cat' => 'Select Category', // Category-Selection, size: -1=Single+All, 0=Single, >0=Multiple with size lines
|
||||||
|
'select-erole' => 'Select Element role',
|
||||||
'select-account' => 'Select Account', // label=accounts(default),groups,both
|
'select-account' => 'Select Account', // label=accounts(default),groups,both
|
||||||
// size: -1=Single+not assigned, 0=Single, >0=Multiple
|
// size: -1=Single+not assigned, 0=Single, >0=Multiple
|
||||||
'select-year' => 'Select Year',
|
'select-year' => 'Select Year',
|
||||||
@ -212,6 +213,43 @@ class select_widget
|
|||||||
$cell['size'] = $rows.($type2 ? ','.$type2 : '');
|
$cell['size'] = $rows.($type2 ? ','.$type2 : '');
|
||||||
$cell['no_lang'] = True;
|
$cell['no_lang'] = True;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'select-erole': // $type2: extraStyleMultiselect
|
||||||
|
$eroles = new projectmanager_eroles_so();
|
||||||
|
if ($readonly)
|
||||||
|
{
|
||||||
|
$cell['no_lang'] = True;
|
||||||
|
if ($value)
|
||||||
|
{
|
||||||
|
if (!is_array($value)) $value = explode(',',$value);
|
||||||
|
foreach($value as $key => $id)
|
||||||
|
{
|
||||||
|
if ($id && ($name = $eroles->id2title($id)))
|
||||||
|
{
|
||||||
|
$cell['sel_options'][$id] = $name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($value[$key]); // remove not (longer) existing or inaccessible eroles
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($eroles->get_free_eroles() as $id => $data)
|
||||||
|
{
|
||||||
|
$global = $data['pm_id'] == 0 ? ' ('.lang('Global').')' : '';
|
||||||
|
$cell['sel_options'][$data['role_id']] = array(
|
||||||
|
'label' => $data['role_title'] . $global,
|
||||||
|
'title' => $data['role_description'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cell['size'] = $rows.($type2 ? ','.$type2 : '');
|
||||||
|
$cell['no_lang'] = True;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'select-account': // options: #rows,{accounts(default)|both|groups|owngroups},{0(=lid)|1(default=name)|2(=lid+name),expand-multiselect-rows,not-to-show-accounts,...)}
|
case 'select-account': // options: #rows,{accounts(default)|both|groups|owngroups},{0(=lid)|1(default=name)|2(=lid+name),expand-multiselect-rows,not-to-show-accounts,...)}
|
||||||
//echo "<p>select-account widget: name=$cell[name], type='$type', rows=$rows, readonly=".(int)($cell['readonly'] || $readonlys)."</p>\n";
|
//echo "<p>select-account widget: name=$cell[name], type='$type', rows=$rows, readonly=".(int)($cell['readonly'] || $readonlys)."</p>\n";
|
||||||
@ -507,8 +545,6 @@ class select_widget
|
|||||||
* will return no data (if it has a preprocessing method). The framework insures that
|
* will return no data (if it has a preprocessing method). The framework insures that
|
||||||
* the post-processing of all contained widget has been done before.
|
* the post-processing of all contained widget has been done before.
|
||||||
*
|
*
|
||||||
* Only used by select-dow so far
|
|
||||||
*
|
|
||||||
* @param string $name form-name of the widget
|
* @param string $name form-name of the widget
|
||||||
* @param mixed &$value the extension returns here it's input, if there's any
|
* @param mixed &$value the extension returns here it's input, if there's any
|
||||||
* @param mixed &$extension_data persistent storage between calls or pre- and post-process
|
* @param mixed &$extension_data persistent storage between calls or pre- and post-process
|
||||||
@ -536,6 +572,11 @@ class select_widget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'select-erole':
|
||||||
|
$value = null;
|
||||||
|
if(is_array($value_in)) $value = implode(',',$value_in);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'select-dow':
|
case 'select-dow':
|
||||||
$value = 0;
|
$value = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user