mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
formatting
This commit is contained in:
parent
5ae0b05bbc
commit
46f9c75630
@ -23,9 +23,10 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
include(PHPGW_API_INC."/class.sbox.inc.php");
|
||||
include(PHPGW_API_INC . '/class.sbox.inc.php');
|
||||
|
||||
class sbox2 extends sbox {
|
||||
class sbox2 extends sbox
|
||||
{
|
||||
/*
|
||||
* Function: search for an id of an db-entry, eg. an address
|
||||
* Parameter: $name base name for all template-vars and of the submitted vars (not to conflict with other template-var-names !!!)
|
||||
@ -45,10 +46,9 @@
|
||||
* In the submitted page the vars $query_XXX and $id_XXX are set according to what is selected, see getAddress as Example
|
||||
*/
|
||||
|
||||
function getId($name,$lang_name,$prompt,$id_name,$content='',$note='') {
|
||||
function getId($name,$lang_name,$prompt,$id_name,$content='',$note='')
|
||||
{
|
||||
// echo "<p>getId('$name','$lang_name','$prompt',$id_name,'$content') =";
|
||||
global $phpgw;
|
||||
|
||||
$ret['doSearchFkt'] =
|
||||
'<script language="JavaScript">'."\n".
|
||||
" function doSearch(field,ask) {\n".
|
||||
@ -71,22 +71,32 @@
|
||||
" $lang_name\n".
|
||||
"</noscript>";
|
||||
|
||||
if (is_array($content)) { // result from search
|
||||
if (!count($content)) { // search was unsuccsessful
|
||||
if (is_array($content))
|
||||
{ // result from search
|
||||
if (!count($content))
|
||||
{ // search was unsuccsessful
|
||||
$ret[$name] = lang('no entries found, try again ...');
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret[$name.'_OK'] = ''; // flag we have something so select
|
||||
$ret[$name] = "<select name=\"id_$name\">\n";
|
||||
while (list( $id,$text ) = each( $content )) {
|
||||
while (list( $id,$text ) = each( $content ))
|
||||
{
|
||||
$ret[$name] .= "<option value=\"$id\">" . $phpgw->strip_html($text) . "\n";
|
||||
}
|
||||
$ret[$name] .= '<option value="0">'.lang('none')."\n";
|
||||
$ret[$name] .= '</select>';
|
||||
}
|
||||
} else {
|
||||
if ($id_name) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($id_name)
|
||||
{
|
||||
$ret[$name] = $content . "\n<input type=\"hidden\" name=\"id_$name\" value=\"$id_name\">";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret[$name] = "<span class=note>$note</span>";
|
||||
}
|
||||
}
|
||||
@ -97,20 +107,27 @@
|
||||
"</noscript>";
|
||||
|
||||
// print_r($ret);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function addr2name( $addr ) {
|
||||
global $phpgw;
|
||||
function addr2name( $addr )
|
||||
{
|
||||
$name = $addr['n_family'];
|
||||
if ($addr['n_given'])
|
||||
{
|
||||
$name .= ', '.$addr['n_given'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($addr['n_prefix'])
|
||||
{
|
||||
$name .= ', '.$addr['n_prefix'];
|
||||
}
|
||||
}
|
||||
if ($addr['org_name'])
|
||||
{
|
||||
$name = $addr['org_name'].': '.$name;
|
||||
}
|
||||
return $phpgw->strip_html($name);
|
||||
}
|
||||
|
||||
@ -126,76 +143,105 @@
|
||||
* Note As query's for an address are submitted, you have to check $query_XXX if it is a search or a regular submit (!$query_string)
|
||||
*/
|
||||
|
||||
function getAddress( $name,$id_name,$query_name,$title='') {
|
||||
function getAddress( $name,$id_name,$query_name,$title='')
|
||||
{
|
||||
// echo "<p>getAddress('$name',$id_name,'$query_name','$title')</p>";
|
||||
global $phpgw;
|
||||
|
||||
if ($id_name || $query_name) {
|
||||
if ($id_name || $query_name)
|
||||
{
|
||||
$contacts = createobject('phpgwapi.contacts');
|
||||
|
||||
if ($query_name) {
|
||||
if ($query_name)
|
||||
{
|
||||
$addrs = $contacts->read( 0,0,'',$query_name,'','DESC','org_name,n_family,n_given' );
|
||||
$content = array( );
|
||||
while ($addrs && list( $key,$addr ) = each( $addrs )) {
|
||||
while ($addrs && list( $key,$addr ) = each( $addrs ))
|
||||
{
|
||||
$content[$addr['id']] = $this->addr2name( $addr );
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
list( $addr ) = $contacts->read_single_entry( $id_name );
|
||||
if (count($addr)) {
|
||||
if (count($addr))
|
||||
{
|
||||
$content = $this->addr2name( $addr );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$title) $title = lang('Addressbook');
|
||||
if (!$title)
|
||||
{
|
||||
$title = lang('Addressbook');
|
||||
}
|
||||
|
||||
return $this->getId($name,$title,lang('Pattern for Search in Addressbook'),$id_name,$content,lang('use Button to search for Address'));
|
||||
}
|
||||
|
||||
function addr2email( $addr,$home='' ) {
|
||||
global $phpgw;
|
||||
|
||||
if (!is_array($addr)) {
|
||||
function addr2email( $addr,$home='' )
|
||||
{
|
||||
if (!is_array($addr))
|
||||
{
|
||||
$home = substr($addr,-1) == 'h';
|
||||
$contacts = createobject('phpgwapi.contacts');
|
||||
list( $addr ) = $contacts->read_single_entry( intval($addr) );
|
||||
}
|
||||
if ($home) $home = '_home';
|
||||
if ($home)
|
||||
{
|
||||
$home = '_home';
|
||||
}
|
||||
|
||||
if (!count($addr) || !$addr['email'.$home])
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($addr['n_given'])
|
||||
{
|
||||
$name = $addr['n_given'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($addr['n_prefix'])
|
||||
{
|
||||
$name = $addr['n_prefix'];
|
||||
|
||||
}
|
||||
}
|
||||
$name .= ($name ? ' ' : '') . $addr['n_family'];
|
||||
|
||||
return $name.' <'.$addr['email'.$home].'>';
|
||||
}
|
||||
|
||||
function getEmail( $name,$id_name,$query_name,$title='') {
|
||||
function getEmail( $name,$id_name,$query_name,$title='')
|
||||
{
|
||||
// echo "<p>getAddress('$name',$id_name,'$query_name','$title')</p>";
|
||||
global $phpgw;
|
||||
|
||||
if ($id_name || $query_name) {
|
||||
if ($id_name || $query_name)
|
||||
{
|
||||
$contacts = createobject('phpgwapi.contacts');
|
||||
|
||||
if ($query_name) {
|
||||
if ($query_name)
|
||||
{
|
||||
$addrs = $contacts->read( 0,0,'',$query_name,'','DESC','org_name,n_family,n_given' );
|
||||
$content = array( );
|
||||
while ($addrs && list( $key,$addr ) = each( $addrs )) {
|
||||
while ($addrs && list( $key,$addr ) = each( $addrs ))
|
||||
{
|
||||
if ($addr['email'])
|
||||
{
|
||||
$content[$addr['id']] = $this->addr2email( $addr );
|
||||
}
|
||||
if ($addr['email_home'])
|
||||
{
|
||||
$content[$addr['id'].'h'] = $this->addr2email( $addr,'_home' );
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = $this->addr2email( $id_name );
|
||||
}
|
||||
}
|
||||
if (!$title) $title = lang('Addressbook');
|
||||
if (!$title)
|
||||
{
|
||||
$title = lang('Addressbook');
|
||||
}
|
||||
|
||||
return $this->getId($name,$title,lang('Pattern for Search in Addressbook'),$id_name,$content);
|
||||
}
|
||||
@ -211,28 +257,35 @@
|
||||
*
|
||||
* Note As query's for an address are submitted, you have to check $query_XXX if it is a search or a regular submit (!$query_string)
|
||||
*/
|
||||
|
||||
function getProject( $name,$id_name,$query_name,$title='' ) {
|
||||
function getProject( $name,$id_name,$query_name,$title='' )
|
||||
{
|
||||
// echo "<p>getProject('$name',$id_name,'$query_name','$title')</p>";
|
||||
global $phpgw;
|
||||
|
||||
if ($id_name || $query_name) {
|
||||
if ($id_name || $query_name)
|
||||
{
|
||||
$projects = createobject('projects.projects');
|
||||
if ($query_name) {
|
||||
if ($query_name)
|
||||
{
|
||||
$projs = $projects->read_projects( 0,0,$query_name,'','','','',0 );
|
||||
$content = array();
|
||||
while ($projs && list( $key,$proj ) = each( $projs )) {
|
||||
while ($projs && list( $key,$proj ) = each( $projs ))
|
||||
{
|
||||
$content[$proj['id']] = $proj['title'];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
list( $proj ) = $projects->read_single_project( $id_name );
|
||||
if (count($proj)) {
|
||||
if (count($proj))
|
||||
{
|
||||
$content = $proj['title'];
|
||||
// $customer_id = $proj['customer'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$title) $title = lang('Project');
|
||||
if (!$title)
|
||||
{
|
||||
$title = lang('Project');
|
||||
}
|
||||
|
||||
return $this->getId($name,$title,lang('Pattern for Search in Projects'),$id_name,$content,lang('use Button to search for Project'));
|
||||
}
|
||||
@ -246,14 +299,17 @@
|
||||
* On submit $XXX is the key of the selected item (XXX is the content of $name)
|
||||
* Returns: string to set for a template or to echo into html page
|
||||
*/
|
||||
|
||||
function getArrayItem($name, $key, $arr=0,$no_lang=0) { // should be in class common.sbox
|
||||
function getArrayItem($name, $key, $arr=0,$no_lang=0)
|
||||
{ // should be in class common.sbox
|
||||
if (!is_array($arr))
|
||||
{
|
||||
$arr = array('no','yes');
|
||||
}
|
||||
|
||||
$out = "<select name=\"$name\">\n";
|
||||
|
||||
while (list($k,$text) = each($arr)) {
|
||||
while (list($k,$text) = each($arr))
|
||||
{
|
||||
$out .= '<option value="'.$k.'"';
|
||||
if($k == $key) $out .= " SELECTED";
|
||||
$out .= ">" . ($no_lang ? $text : lang($text)) . "</option>\n";
|
||||
@ -263,19 +319,24 @@
|
||||
return $out;
|
||||
}
|
||||
|
||||
function accountInfo($id,$account_data=0,$longname=0) {
|
||||
global $phpgw;
|
||||
function accountInfo($id,$account_data=0,$longname=0)
|
||||
{
|
||||
if (!$id)
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
|
||||
if (!$id) return ' ';
|
||||
|
||||
if (!is_array($account_data)) {
|
||||
if (!is_array($account_data))
|
||||
{
|
||||
$accounts = createobject('phpgwapi.accounts',$id);
|
||||
$accounts->db = $phpgw->db;
|
||||
$accounts->read_repository();
|
||||
$account_data = $accounts->data;
|
||||
}
|
||||
if ($longnames)
|
||||
{
|
||||
return $account_data['firstname'].' '.$account_data['lastname'];
|
||||
}
|
||||
|
||||
return $account_data['account_lid'];
|
||||
}
|
||||
@ -287,14 +348,15 @@
|
||||
* $id2text($id,$acct_data) fkt that translates account_id $id in text to show
|
||||
*/
|
||||
|
||||
function getAccount($name,$id,$longnames=0) {
|
||||
global $phpgw;
|
||||
function getAccount($name,$id,$longnames=0)
|
||||
{
|
||||
$accounts = createobject('phpgwapi.accounts');
|
||||
$accounts->db = $phpgw->db;
|
||||
$accs = $accounts->get_list('accounts');
|
||||
|
||||
$aarr = Array(lang('not assigned'));
|
||||
while ($a = current($accs)) {
|
||||
while ($a = current($accs))
|
||||
{
|
||||
$aarr[$a['account_id']] = $this->accountInfo($a['account_id'],$a,$longnames);
|
||||
next($accs);
|
||||
}
|
||||
@ -303,11 +365,12 @@
|
||||
|
||||
function getDate($n_year,$n_month,$n_day,$date)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
if (!$date) {
|
||||
if (!$date)
|
||||
{
|
||||
$day = $month = $year = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$day = date('d',$date);
|
||||
$month = date('m',$date);
|
||||
$year = date('Y',$date);
|
||||
|
Loading…
Reference in New Issue
Block a user