2001-01-11 10:52:33 +01:00
< ? php
2002-09-27 19:39:49 +02:00
/************************************************************************** \
* phpGroupWare API - Commononly used functions *
* Written by Dan Kuykendall < seek3r @ phpgroupware . org > *
* and Joseph Engo < jengo @ phpgroupware . org > *
* and Mark Peters < skeeter @ phpgroupware . org > *
* and Bettina Gille [ ceb @ phpgroupware . org ] *
* Commononly used functions by phpGroupWare developers *
* Copyright ( C ) 2000 - 2002 Dan Kuykendall *
* ------------------------------------------------------------------------ *
* This library is part of the phpGroupWare API *
* http :// www . phpgroupware . org / api *
* ------------------------------------------------------------------------ *
* This library is free software ; you can redistribute it and / or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation ; either version 2.1 of the License , *
* or any later version . *
* This library is distributed in the hope that it will be useful , but *
* WITHOUT ANY WARRANTY ; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . *
* See the GNU Lesser General Public License for more details . *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library ; if not , write to the Free Software Foundation , *
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA *
\ **************************************************************************/
/* $Id$ */
2001-01-11 10:52:33 +01:00
2001-06-17 18:52:25 +02:00
$d1 = strtolower ( @ substr ( PHPGW_API_INC , 0 , 3 ));
$d2 = strtolower ( @ substr ( PHPGW_SERVER_ROOT , 0 , 3 ));
$d3 = strtolower ( @ substr ( PHPGW_APP_INC , 0 , 3 ));
2001-06-13 23:10:36 +02:00
if ( $d1 == 'htt' || $d1 == 'ftp' || $d2 == 'htt' || $d2 == 'ftp' || $d3 == 'htt' || $d3 == 'ftp' )
{
echo 'Failed attempt to break in via an old Security Hole!<br>' . " \n " ;
exit ;
}
unset ( $d1 ); unset ( $d2 ); unset ( $d3 );
/*!
@ class common
@ abstract common class that contains commonly used functions
*/
2001-03-18 06:16:00 +01:00
class common
{
2001-12-27 16:48:42 +01:00
var $debug_info ; // An array with debugging info from the API
2001-12-29 11:57:35 +01:00
var $found_files ;
2001-12-27 16:48:42 +01:00
2001-03-23 06:56:15 +01:00
/*!
2001-09-08 18:02:59 +02:00
@ function cmp_version
@ abstract Compares two Version strings and return 1 if str2 is newest ( bigger version number ) than str1
@ discussion This function checks for major version only .
@ param $str1
@ param $str2
2001-03-23 06:56:15 +01:00
*/
2002-01-05 16:33:46 +01:00
function cmp_version ( $str1 , $str2 , $debug = False )
2001-03-23 06:56:15 +01:00
{
ereg ( " ([0-9]+) \ .([0-9]+) \ .([0-9]+)[a-zA-Z]*([0-9]*) " , $str1 , $regs );
ereg ( " ([0-9]+) \ .([0-9]+) \ .([0-9]+)[a-zA-Z]*([0-9]*) " , $str2 , $regs2 );
2002-02-17 16:34:13 +01:00
if ( $debug )
{
echo '<br>cmp_version(' . $str1 . ',' . $str2 . ')' ;
echo " <br> $regs[0] - $regs2[0] " ;
}
2002-01-05 16:33:46 +01:00
2001-09-08 18:02:59 +02:00
for ( $i = 1 ; $i < 5 ; $i ++ )
{
2002-01-05 16:33:46 +01:00
if ( $debug ) { echo " <br> $i : $regs[$i] - $regs2[$i] " ; }
2001-03-23 06:56:15 +01:00
if ( $regs2 [ $i ] == $regs [ $i ])
2001-09-08 18:02:59 +02:00
{
2002-02-17 16:34:13 +01:00
if ( $debug ) { echo ' are equal...' ; }
2001-03-23 06:56:15 +01:00
continue ;
2001-09-08 18:02:59 +02:00
}
2001-03-23 06:56:15 +01:00
if ( $regs2 [ $i ] > $regs [ $i ])
2001-09-08 18:02:59 +02:00
{
2002-02-17 16:34:13 +01:00
if ( $debug ) { echo ', and a < b. Returning 1.' ; }
2001-03-23 06:56:15 +01:00
return 1 ;
2001-09-08 18:02:59 +02:00
}
elseif ( $regs2 [ $i ] < $regs [ $i ])
{
2002-02-17 16:34:13 +01:00
if ( $debug ) { echo ', and a > b. Returning 0.' ; }
2001-09-08 18:02:59 +02:00
return 0 ;
}
}
2002-02-17 16:34:13 +01:00
if ( $debug )
{
echo ' - all equal. Returning NULL.' ;
return '' ;
}
2001-09-08 18:02:59 +02:00
}
/*!
@ function cmp_version_long
@ abstract Compares two Version strings and return 1 if str2 is newest ( bigger version number ) than str1
@ discussion This function checks all fields . cmp_version () checks release version only .
@ param $str1
@ param $str2
*/
2002-01-04 05:44:09 +01:00
function cmp_version_long ( $str1 , $str2 , $debug = False )
2001-09-08 18:02:59 +02:00
{
ereg ( " ([0-9]+) \ .([0-9]+) \ .([0-9]+)[a-zA-Z]*([0-9]*) \ .([0-9]*) " , $str1 , $regs );
ereg ( " ([0-9]+) \ .([0-9]+) \ .([0-9]+)[a-zA-Z]*([0-9]*) \ .([0-9]*) " , $str2 , $regs2 );
2002-02-17 16:34:13 +01:00
if ( $debug )
{
echo '<br>cmp_version_long(' . $str1 . ',' . $str2 . ')' ;
echo " <br> $regs[0] - $regs2[0] " ;
}
if ( ! $regs [ 0 ])
{
if ( $debug ) { echo '<br>calling cmp_version(' . $str1 . ',' . $str2 . ')' ; }
return $this -> cmp_version ( $str1 , $str2 , $debug );
}
2002-01-04 05:44:09 +01:00
2001-09-08 18:02:59 +02:00
for ( $i = 1 ; $i < 6 ; $i ++ )
{
2002-01-04 05:44:09 +01:00
if ( $debug ) { echo " <br> $i : $regs[$i] - $regs2[$i] " ; }
2001-09-08 18:02:59 +02:00
if ( $regs2 [ $i ] == $regs [ $i ])
{
2002-01-04 05:44:09 +01:00
if ( $debug ) { echo ' are equal...' ; }
2001-09-08 18:02:59 +02:00
continue ;
}
if ( $regs2 [ $i ] > $regs [ $i ])
{
2002-02-17 16:34:13 +01:00
if ( $debug ) { echo ', and a < b. Returning 1.' ; }
2001-09-08 18:02:59 +02:00
return 1 ;
}
elseif ( $regs2 [ $i ] < $regs [ $i ])
{
2002-02-17 16:34:13 +01:00
if ( $debug ) { echo ', and a > b. Returning 0.' ; }
2001-09-08 18:02:59 +02:00
return 0 ;
}
2001-03-23 06:56:15 +01:00
}
2002-02-17 16:34:13 +01:00
if ( $debug )
{
echo ' - all equal. Returning NULL.' ;
return '' ;
}
2001-03-23 06:56:15 +01:00
}
2001-01-11 10:52:33 +01:00
2001-03-18 06:16:00 +01:00
// Convert an array into the format needed for the access column.
2001-03-14 07:38:11 +01:00
/*!
2001-03-23 06:38:11 +01:00
@ function array_to_string
2001-03-14 07:38:11 +01:00
@ abstract Convert an array into the format needed for the access column
@ param $access
@ param $array
*/
2001-03-18 06:16:00 +01:00
function array_to_string ( $access , $array )
{
$this -> debug_info [] = 'array_to_string() is a depreciated function - use ACL instead' ;
$s = '' ;
if ( $access == 'group' || $access == 'public' || $access == 'none' )
{
if ( count ( $array ))
{
while ( $t = each ( $array )) {
$s .= ',' . $t [ 1 ];
}
$s .= ',' ;
}
if ( ! count ( $array ) && $access == 'none' )
{
$s = '' ;
}
}
return $s ;
}
2001-02-05 17:37:38 +01:00
2001-03-18 06:16:00 +01:00
// This is used for searching the access fields
2001-03-14 07:38:11 +01:00
/*!
@ function sql_search
@ abstract this function is used for searching the access fields
@ param $table
@ param $owner
*/
2001-03-18 06:16:00 +01:00
function sql_search ( $table , $owner = 0 )
{
2001-08-04 16:26:10 +02:00
$this -> debug_info [] = 'sql_search() is a deprecated function - use ACL instead' ;
2001-03-18 06:16:00 +01:00
$s = '' ;
if ( ! $owner )
{
2001-09-02 09:13:23 +02:00
$owner = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ];
2001-03-18 06:16:00 +01:00
}
2001-09-02 09:13:23 +02:00
$groups = $GLOBALS [ 'phpgw' ] -> accounts -> membership ( intval ( $owner ));
2001-03-18 06:16:00 +01:00
if ( gettype ( $groups ) == 'array' )
{
while ( $group = each ( $groups ))
{
$s .= " or $table like '%, " . $group [ 2 ] . " ,%' " ;
}
}
return $s ;
}
2001-02-05 17:37:38 +01:00
2001-06-13 23:10:36 +02:00
// return a array of installed languages
2001-03-14 07:38:11 +01:00
/*!
@ function getInstalledLanguages
@ abstract return an array of installed languages
@ result $installedLanguages ; an array containing the installed languages
*/
2001-06-13 23:10:36 +02:00
function getInstalledLanguages ()
{
2002-02-18 02:54:15 +01:00
$GLOBALS [ 'phpgw' ] -> db -> query ( 'select distinct lang from phpgw_lang' );
2001-09-02 01:42:16 +02:00
while ( @ $GLOBALS [ 'phpgw' ] -> db -> next_record ())
2001-06-13 23:10:36 +02:00
{
2001-09-02 01:42:16 +02:00
$installedLanguages [ $GLOBALS [ 'phpgw' ] -> db -> f ( 'lang' )] = $GLOBALS [ 'phpgw' ] -> db -> f ( 'lang' );
2001-06-13 23:10:36 +02:00
}
return $installedLanguages ;
}
2001-01-11 10:52:33 +01:00
2001-06-13 23:10:36 +02:00
// return the preferred language of the users
// it's using HTTP_ACCEPT_LANGUAGE (send from the users browser)
// and ...(to find out which languages are installed)
2001-03-14 07:38:11 +01:00
/*!
@ function getPreferredLanguage
@ abstract return the preferred langugae of the users
@ discussion it uses HTTP_ACCEPT_LANGUAGE ( from the users browser ) < br >
and .... to find out which languages are installed
*/
2001-06-13 23:10:36 +02:00
function getPreferredLanguage ()
{
// create a array of languages the user is accepting
2001-09-02 01:42:16 +02:00
$userLanguages = explode ( ',' , $GLOBALS [ 'HTTP_ACCEPT_LANGUAGE' ]);
2001-06-13 23:10:36 +02:00
$supportedLanguages = $this -> getInstalledLanguages ();
// find usersupported language
while ( list ( $key , $value ) = each ( $userLanguages ))
{
// remove everything behind '-' example: de-de
$value = trim ( $value );
$pieces = explode ( '-' , $value );
$value = $pieces [ 0 ];
# print 'current lang $value<br>';
if ( $supportedLanguages [ $value ])
{
$retValue = $value ;
break ;
}
}
// no usersupported language found -> return english
if ( empty ( $retValue ))
{
$retValue = 'en' ;
}
return $retValue ;
}
// connect to the ldap server and return a handle
2001-03-14 07:38:11 +01:00
/*!
@ function ldapConnect
@ abstract connect to the ldap server and return a handle
@ param $host ldap host
@ param $dn ldap_root_dn
@ param $passwd ldap_root_pw
*/
2001-06-13 23:10:36 +02:00
function ldapConnect ( $host = '' , $dn = '' , $passwd = '' )
{
if ( ! $host )
{
2001-09-02 01:42:16 +02:00
$host = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'ldap_host' ];
2001-06-13 23:10:36 +02:00
}
2001-01-11 10:52:33 +01:00
2001-06-13 23:10:36 +02:00
if ( ! $dn )
{
2001-09-02 01:42:16 +02:00
$dn = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'ldap_root_dn' ];
2001-06-13 23:10:36 +02:00
}
2001-01-11 10:52:33 +01:00
2001-06-13 23:10:36 +02:00
if ( ! $passwd )
{
2001-09-02 01:42:16 +02:00
$passwd = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'ldap_root_pw' ];
2001-06-13 23:10:36 +02:00
}
// connect to ldap server
if ( ! $ds = ldap_connect ( $host ))
{
2001-11-25 02:24:42 +01:00
/* log does not exist in setup(, yet) */
if ( is_object ( $GLOBALS [ 'phpgw' ] -> log ))
{
$GLOBALS [ 'phpgw' ] -> log -> message ( 'F-Abort, Failed connecting to LDAP server' );
$GLOBALS [ 'phpgw' ] -> log -> commit ();
}
2001-08-05 11:54:44 +02:00
2001-06-13 23:10:36 +02:00
printf ( " <b>Error: Can't connect to LDAP server %s!</b><br> " , $host );
return False ;
}
// bind as admin, we not to able to do everything
if ( ! ldap_bind ( $ds , $dn , $passwd ))
{
2001-11-25 02:29:04 +01:00
if ( is_object ( $GLOBALS [ 'phpgw' ] -> log ))
{
$GLOBALS [ 'phpgw' ] -> log -> message ( 'F-Abort, Failed binding to LDAP server' );
$GLOBALS [ 'phpgw' ] -> log -> commit ();
}
2001-08-05 11:54:44 +02:00
2001-06-13 23:10:36 +02:00
printf ( " <b>Error: Can't bind to LDAP server: %s!</b><br> " , $dn );
return False ;
}
return $ds ;
}
2001-01-11 10:52:33 +01:00
2001-03-14 07:38:11 +01:00
/*!
@ function randomstring
@ abstract return a random string of size $size
@ param $size int - size of random string to return
*/
2001-06-13 23:10:36 +02:00
function randomstring ( $size )
{
$s = '' ;
srand (( double ) microtime () * 1000000 );
$random_char = array ( '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ,
'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' ,
'w' , 'x' , 'y' , 'z' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' ,
'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' );
for ( $i = 0 ; $i < $size ; $i ++ )
{
$s .= $random_char [ rand ( 1 , 61 )];
}
return $s ;
}
2001-01-11 10:52:33 +01:00
2001-04-04 09:14:31 +02:00
// Look at the note towards the top of this file (jengo)
function filesystem_separator ()
{
return filesystem_separator ();
}
2001-03-14 07:38:11 +01:00
/*!
@ function error_list
2001-04-04 09:14:31 +02:00
@ abstract This is used for reporting errors in a nice format .
@ param $error - array of errors
2001-03-14 07:38:11 +01:00
*/
2001-12-27 16:16:22 +01:00
function error_list ( $errors , $text = 'Error' )
2001-04-04 09:14:31 +02:00
{
if ( ! is_array ( $errors ))
{
return False ;
}
2001-01-11 10:52:33 +01:00
2002-05-25 00:30:35 +02:00
if ( $text == 'Error' )
2001-04-04 09:14:31 +02:00
{
2002-05-25 00:30:35 +02:00
$text = '' ;
2001-04-04 09:14:31 +02:00
}
2002-05-25 00:30:35 +02:00
else
{
$text .= ': ' ;
}
reset ( $errors );
while ( list (, $value ) = each ( $errors ))
{
$msgbox_input [ $text . $value ] = False ;
}
return $this -> msgbox ( $msgbox_input );
2001-04-04 09:14:31 +02:00
}
2001-03-18 06:16:00 +01:00
2001-03-14 07:38:11 +01:00
/*!
@ function check_owner
@ abstract none yet
@ param $record ?
@ param $link ?
@ param $label ?
@ param $extravars
*/
2001-06-13 23:10:36 +02:00
// This is a depreciated function - use ACL instead (jengo)
2001-03-18 06:16:00 +01:00
function check_owner ( $record , $link , $label , $extravars = '' )
{
$this -> debug_info [] = 'check_owner() is a depreciated function - use ACL instead' ;
2001-09-02 01:42:16 +02:00
$s = '<a href="' . $GLOBALS [ 'phpgw' ] -> link ( $link , $extravars ) . '"> ' . lang ( $label ) . ' </a>' ;
2001-03-18 06:16:00 +01:00
if ( ereg ( '^[0-9]+$' , $record ))
{
2001-09-02 01:42:16 +02:00
if ( $record != $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ])
2001-03-18 06:16:00 +01:00
{
$s = ' ' ;
}
}
else
{
2001-09-02 01:42:16 +02:00
if ( $record != $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'userid' ])
2001-03-18 06:16:00 +01:00
{
$s = ' ' ;
}
}
return $s ;
2001-06-13 23:10:36 +02:00
}
2001-01-11 10:52:33 +01:00
2001-03-14 07:38:11 +01:00
/*!
@ function display_fullname
@ abstract return the fullname of a user
2001-03-22 14:26:54 +01:00
@ param $lid account loginid
2001-03-14 07:38:11 +01:00
@ param $firstname firstname
@ param $lastname lastname
*/
2001-03-22 14:25:06 +01:00
function display_fullname ( $lid = '' , $firstname = '' , $lastname = '' )
{
if ( ! $lid && ! $firstname && ! $lastname )
{
2001-09-02 01:42:16 +02:00
$lid = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_lid' ];
$firstname = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'firstname' ];
$lastname = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'lastname' ];
2001-03-22 14:25:06 +01:00
}
2002-11-08 23:42:14 +01:00
if ( $firstname )
2001-03-22 14:25:06 +01:00
{
2002-11-08 23:42:14 +01:00
$a [] = $firstname ;
2001-03-22 14:25:06 +01:00
}
2001-06-13 23:10:36 +02:00
2002-11-08 23:42:14 +01:00
if ( $lastname )
2001-03-22 19:10:09 +01:00
{
2002-11-08 23:42:14 +01:00
$a [] = $lastname ;
2001-03-22 19:10:09 +01:00
}
2001-03-22 14:25:06 +01:00
2001-05-13 06:08:01 +02:00
if ( isset ( $a ))
2001-03-25 16:41:17 +02:00
{
2001-05-13 06:08:01 +02:00
switch ( count ( $a ))
{
case 0 :
return $lid ;
break ;
case 1 :
2002-11-08 23:42:14 +01:00
return $a [ 0 ] . ' <' . $lid . '>' ;
2001-05-13 06:08:01 +02:00
break ;
case 2 :
2002-11-08 23:42:14 +01:00
return $a [ 0 ] . ' ' . $a [ 1 ] . ' <' . $lid . '>' ; //implode(', ',$a);
2001-05-13 06:08:01 +02:00
break ;
}
}
else
{
return $lid ;
2001-03-25 16:41:17 +02:00
}
2001-03-22 14:25:06 +01:00
}
2001-03-14 07:38:11 +01:00
/*!
@ function grab_owner_name
@ abstract grab the owner name
@ param $id account id
*/
2001-06-13 23:10:36 +02:00
function grab_owner_name ( $accountid = '' )
{
2001-09-06 00:46:47 +02:00
$GLOBALS [ 'phpgw' ] -> accounts -> get_account_name ( $accountid , $lid , $fname , $lname );
return $this -> display_fullname ( $lid , $fname , $lname );
2001-06-13 23:10:36 +02:00
}
2001-01-11 10:52:33 +01:00
2001-03-14 18:21:09 +01:00
/*!
@ function create_tabs
@ abstract create tabs
@ param $tabs ?
@ param $selected ?
@ param $fontsize optional
*/
2002-11-18 17:19:56 +01:00
function create_tabs ( $tabs , $selected )
2001-06-13 23:10:36 +02:00
{
2002-11-18 17:19:56 +01:00
$output_text = '<table cellspacing="0" cellpadding="0"><tr>' ;
2001-09-05 05:06:14 +02:00
2002-11-18 17:19:56 +01:00
/* This is a php3 workaround
2001-09-05 05:06:14 +02:00
if ( PHPGW_IMAGES_DIR == 'PHPGW_IMAGES_DIR' )
{
$ir = ExecMethod ( 'phpgwapi.phpgw.common.get_image_path' , 'phpgwapi' );
}
else
{
$ir = PHPGW_IMAGES_DIR ;
2002-11-18 17:19:56 +01:00
} */
2001-06-13 23:10:36 +02:00
$i = 1 ;
while ( $tab = each ( $tabs ))
{
if ( $tab [ 0 ] == $selected )
{
if ( $i == 1 )
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="right"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-start1' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left" nowrap background="' . $this -> image ( 'phpgwapi' , 'tabs-bg1' ) . '"> <b><a href="'
2001-06-13 23:10:36 +02:00
. $tab [ 1 ][ 'link' ] . '" class="tablink">' . $fs . $tab [ 1 ][ 'label' ]
. $fse . '</a></b> </td>' ;
if ( $i == count ( $tabs ))
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-end1' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
else
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-sepr' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
}
else
{
if ( $i == 1 )
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="right"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-start0' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left" nowrap background="' . $this -> image ( 'phpgwapi' , 'tabs-bg0' ) . '"> <b><a href="'
2001-06-13 23:10:36 +02:00
. $tab [ 1 ][ 'link' ] . '" class="tablink">' . $fs . $tab [ 1 ][ 'label' ] . $fse
. '</a></b> </td>' ;
if (( $i + 1 ) == $selected )
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-sepl' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
2001-12-28 07:02:30 +01:00
elseif ( $i == $selected || $i != count ( $tabs ))
2001-06-13 23:10:36 +02:00
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-sepm' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
2001-12-28 07:02:30 +01:00
elseif ( $i == count ( $tabs ))
2001-06-13 23:10:36 +02:00
{
if ( $i == $selected )
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-end1' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
else
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-end0' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
}
else
{
if ( $i != count ( $tabs ))
{
2002-11-18 17:19:56 +01:00
$output_text .= '<td align="left"><img src="' . $this -> image ( 'phpgwapi' , 'tabs-sepr' ) . '"></td>' ;
2001-06-13 23:10:36 +02:00
}
}
}
$i ++ ;
$output_text .= " \n " ;
}
$output_text .= " </table> \n " ;
return $output_text ;
}
2002-01-04 05:06:13 +01:00
2001-03-14 07:38:11 +01:00
/*!
@ function get_app_dir
2001-03-14 18:21:09 +01:00
@ abstract get directory of application
@ discussion $appname can either be passed or derived from $phpgw_info [ 'flags' ][ 'currentapp' ];
@ param $appname name of application
2001-03-14 07:38:11 +01:00
*/
2001-06-13 23:10:36 +02:00
function get_app_dir ( $appname = '' )
{
if ( $appname == '' )
{
2001-09-02 01:42:16 +02:00
$appname = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2001-06-13 23:10:36 +02:00
}
if ( $appname == 'home' || $appname == 'logout' || $appname == 'login' )
{
$appname = 'phpgwapi' ;
}
$appdir = PHPGW_INCLUDE_ROOT . '/' . $appname ;
$appdir_default = PHPGW_SERVER_ROOT . '/' . $appname ;
2002-01-02 15:33:05 +01:00
if ( @ is_dir ( $appdir ))
2001-06-13 23:10:36 +02:00
{
return $appdir ;
}
2002-01-02 15:33:05 +01:00
elseif ( @ is_dir ( $appdir_default ))
2001-06-13 23:10:36 +02:00
{
return $appdir_default ;
}
else
{
return False ;
}
}
2001-03-14 18:21:09 +01:00
/*!
@ function get_inc_dir
@ abstract get inc ( include dir ) of application
@ discussion $appname can either be passed or derived from $phpgw_info [ 'flags' ][ 'currentapp' ];
@ param $appname name of application
*/
2001-06-13 23:10:36 +02:00
function get_inc_dir ( $appname = '' )
{
if ( ! $appname )
{
2001-09-02 01:42:16 +02:00
$appname = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2001-06-13 23:10:36 +02:00
}
if ( $appname == 'home' || $appname == 'logout' || $appname == 'login' )
{
$appname = 'phpgwapi' ;
}
2001-02-06 15:11:44 +01:00
2001-06-13 23:10:36 +02:00
$incdir = PHPGW_INCLUDE_ROOT . '/' . $appname . '/inc' ;
$incdir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/inc' ;
2001-02-06 15:11:44 +01:00
2002-01-02 15:33:05 +01:00
if ( @ is_dir ( $incdir ))
2001-06-13 23:10:36 +02:00
{
return $incdir ;
}
2002-01-02 15:33:05 +01:00
elseif ( @ is_dir ( $incdir_default ))
2001-06-13 23:10:36 +02:00
{
return $incdir_default ;
}
else
{
return False ;
}
}
2001-03-14 18:21:09 +01:00
/*!
@ function list_themes
@ abstract list themes available
*/
2002-09-27 19:39:49 +02:00
function list_themes ()
{
$tpl_dir = $this -> get_tpl_dir ( 'phpgwapi' );
$dh = opendir ( $tpl_dir . SEP . 'css' );
while ( $file = readdir ( $dh ))
{
2002-10-19 22:46:35 +02:00
if ( eregi ( " \ .css $ " , $file ) && $file != 'phpgw.css' )
2002-09-27 19:39:49 +02:00
{
$list [] = substr ( $file , 0 , strpos ( $file , '.' ));
}
}
closedir ( $dh );
reset ( $list );
return $list ;
2001-06-13 23:10:36 +02:00
}
2001-03-14 18:21:09 +01:00
/*!
@ function list_templates
@ abstract list available templates
*/
2001-06-13 23:10:36 +02:00
function list_templates ()
{
$d = dir ( PHPGW_SERVER_ROOT . '/phpgwapi/templates' );
while ( $entry = $d -> read ())
{
2002-09-29 20:22:17 +02:00
if ( $entry != 'CVS' && $entry != '.' && $entry != '..' && is_dir ( PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry ))
2001-06-13 23:10:36 +02:00
{
$list [ $entry ][ 'name' ] = $entry ;
$f = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php' ;
if ( file_exists ( $f ))
{
include ( $f );
2001-09-02 01:42:16 +02:00
$list [ $entry ][ 'title' ] = 'Use ' . $GLOBALS [ 'phpgw_info' ][ 'template' ][ $entry ][ 'title' ] . 'interface' ;
2001-06-13 23:10:36 +02:00
}
else
{
$list [ $entry ][ 'title' ] = $entry ;
}
}
}
$d -> close ();
reset ( $list );
return $list ;
}
2001-03-14 18:21:09 +01:00
/*!
@ function get_tpl_dir
@ abstract get template dir of an application
@ param $appname appication name optional can be derived from $phpgw_info [ 'flags' ][ 'currentapp' ];
*/
2002-09-25 06:04:24 +02:00
function get_tpl_dir ( $appname = '' , $layout = '' )
2001-06-13 23:10:36 +02:00
{
if ( ! $appname )
{
2001-08-21 20:34:56 +02:00
$appname = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2001-06-13 23:10:36 +02:00
}
2002-11-30 03:02:32 +01:00
if ( $appname == 'home' || $appname == 'logout' || $appname == 'login' || $appname == 'about' || $appname == 'help' )
2001-06-13 23:10:36 +02:00
{
$appname = 'phpgwapi' ;
}
2001-09-18 05:50:00 +02:00
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ]) && isset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ]))
{
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ];
}
2001-06-13 23:10:36 +02:00
// Setting this for display of template choices in user preferences
2002-04-30 05:35:52 +02:00
if ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] == 'user_choice' )
2001-06-13 23:10:36 +02:00
{
2001-08-21 20:34:56 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'usrtplchoice' ] = 'user_choice' ;
2001-06-13 23:10:36 +02:00
}
2002-04-30 05:35:52 +02:00
if (( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] == 'user_choice' ||
2001-09-17 15:21:40 +02:00
! isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ])) &&
2001-08-21 20:34:56 +02:00
isset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ]))
2001-06-13 23:10:36 +02:00
{
2001-08-21 20:34:56 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ];
2001-06-13 23:10:36 +02:00
}
2002-04-30 05:35:52 +02:00
elseif ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] == 'user_choice' ||
2001-08-21 20:34:56 +02:00
! isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ]))
2001-06-13 23:10:36 +02:00
{
2001-08-21 20:34:56 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] = 'default' ;
2001-06-13 23:10:36 +02:00
}
2002-05-31 23:22:25 +02:00
/******** start temporarily code **************************************/
/* this just makes sure the template set is updated to the new format */
2002-10-25 05:04:28 +02:00
if ( !@ is_file ( PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] . '/phpgw.xsl' ))
2002-05-31 23:22:25 +02:00
{
2002-10-25 05:04:28 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] = 'idsociety' ;
2002-05-31 23:22:25 +02:00
}
/******** end temporarily code **************************************/
2001-08-21 20:34:56 +02:00
$tpldir = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ];
2001-06-13 23:10:36 +02:00
$tpldir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/default' ;
2002-09-25 06:04:24 +02:00
if ( $layout == 'default' )
{
$tpldir = $tpldir_default ;
}
2001-12-30 10:42:55 +01:00
if ( @ is_dir ( $tpldir ))
2001-06-13 23:10:36 +02:00
{
return $tpldir ;
}
2001-12-30 10:42:55 +01:00
elseif ( @ is_dir ( $tpldir_default ))
2001-06-13 23:10:36 +02:00
{
return $tpldir_default ;
}
else
{
return False ;
}
}
2001-03-14 18:21:09 +01:00
/*!
@ function get_image_dir
@ abstract get image dir of an application
@ param $appname application name optional can be derived from $phpgw_info [ 'flags' ][ 'currentapp' ];
*/
2002-10-06 05:06:03 +02:00
function get_image_dir ( $appname = '' , $layout = '' )
2001-06-13 23:10:36 +02:00
{
if ( $appname == '' )
{
2001-09-02 01:42:16 +02:00
$appname = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2001-06-13 23:10:36 +02:00
}
2002-01-08 04:37:51 +01:00
if ( empty ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ]))
2001-06-13 23:10:36 +02:00
{
2002-01-08 04:37:51 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] = 'default' ;
2001-06-13 23:10:36 +02:00
}
2002-10-06 05:06:03 +02:00
if ( $layout )
{
$imagedir_layout = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'templates' . SEP . $layout . SEP . 'images' ;
if ( @ is_dir ( $imagedir_layout ))
{
return $imagedir_layout ;
}
}
$imagedir = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] . '/images' ;
2001-06-13 23:10:36 +02:00
$imagedir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/default/images' ;
$imagedir_olddefault = PHPGW_SERVER_ROOT . '/' . $appname . '/images' ;
2001-06-17 18:52:25 +02:00
if ( @ is_dir ( $imagedir ))
2001-06-13 23:10:36 +02:00
{
return $imagedir ;
}
2001-06-17 18:52:25 +02:00
elseif ( @ is_dir ( $imagedir_default ))
2001-06-13 23:10:36 +02:00
{
return $imagedir_default ;
}
2001-06-17 18:52:25 +02:00
elseif ( @ is_dir ( $imagedir_olddefault ))
2001-06-13 23:10:36 +02:00
{
return $imagedir_olddefault ;
}
else
{
return False ;
}
}
2001-03-14 18:21:09 +01:00
/*!
@ function get_image_path
@ abstract get image path of an application
@ param $appname appication name optional can be derived from $phpgw_info [ 'flags' ][ 'currentapp' ];
*/
2002-10-06 05:06:03 +02:00
function get_image_path ( $appname = '' , $layout = '' )
2001-03-08 09:44:57 +01:00
{
if ( $appname == '' )
{
2001-09-02 01:42:16 +02:00
$appname = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2001-03-08 09:44:57 +01:00
}
2001-09-02 01:42:16 +02:00
if ( empty ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ]))
2001-03-08 09:44:57 +01:00
{
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] = 'default' ;
2001-03-08 09:44:57 +01:00
}
2002-10-06 05:06:03 +02:00
if ( $layout )
{
$imagedir_layout = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'templates' . SEP . $layout . SEP . 'images' ;
if ( @ is_dir ( $imagedir_layout ))
{
return $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . SEP . $appname . SEP . 'templates' . SEP . $layout . SEP . 'images' ;
}
}
2001-09-02 01:42:16 +02:00
$imagedir = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] . '/images' ;
2001-03-08 09:44:57 +01:00
$imagedir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/default/images' ;
$imagedir_olddefault = PHPGW_SERVER_ROOT . '/' . $appname . '/images' ;
2001-06-17 18:52:25 +02:00
if ( @ is_dir ( $imagedir ))
2001-03-08 09:44:57 +01:00
{
2001-09-02 01:42:16 +02:00
return $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . '/' . $appname . '/templates/' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] . '/images' ;
2001-03-08 09:44:57 +01:00
}
2001-06-17 18:52:25 +02:00
elseif ( @ is_dir ( $imagedir_default ))
2001-03-08 09:44:57 +01:00
{
2001-09-02 01:42:16 +02:00
return $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . '/' . $appname . '/templates/default/images' ;
2001-03-08 09:44:57 +01:00
}
2001-06-17 18:52:25 +02:00
elseif ( @ is_dir ( $imagedir_olddefault ))
2001-03-08 09:44:57 +01:00
{
2001-09-02 01:42:16 +02:00
return $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . '/' . $appname . '/images' ;
2001-03-08 09:44:57 +01:00
}
else
{
return False ;
2001-06-13 23:10:36 +02:00
}
2001-03-08 09:44:57 +01:00
}
2001-05-06 18:37:40 +02:00
2002-11-03 02:03:07 +01:00
function find_image ( $appname , $image , $navbar = False )
2001-05-06 18:37:40 +02:00
{
2002-02-03 01:52:53 +01:00
static $imgpref ;
if ( ! @ $imgpref )
2002-01-21 18:51:54 +01:00
{
2002-02-03 01:52:53 +01:00
switch ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'image_type' ])
{
case 1 :
$imgpref = Array ( 'png' , 'jpg' , 'gif' );
break ;
case 2 :
$imgpref = Array ( 'png' , 'jpg' , 'nogifs' );
break ;
default :
$imgpref = Array ( 'gif' , 'jpg' , 'png' );
break ;
}
2002-01-21 18:51:54 +01:00
}
2002-01-06 07:01:07 +01:00
if ( !@ is_array ( $this -> found_files [ $appname ]))
2001-05-06 18:37:40 +02:00
{
2001-12-29 11:57:35 +01:00
$imagedir = '/' . $appname . '/templates/' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] . '/images' ;
2002-11-03 02:03:07 +01:00
if ( ! $navbar )
2001-12-29 11:57:35 +01:00
{
2002-11-03 02:03:07 +01:00
$imagedir_olddefault = '/' . $appname . '/images' ;
$imagedir_default = '/' . $appname . '/templates/default/images' ;
if ( @ is_dir ( PHPGW_INCLUDE_ROOT . $imagedir_olddefault ))
2001-12-29 11:57:35 +01:00
{
2002-11-03 02:03:07 +01:00
$d = dir ( PHPGW_INCLUDE_ROOT . $imagedir_olddefault );
while ( false != ( $entry = $d -> read ()))
2001-12-29 11:57:35 +01:00
{
2002-11-03 02:03:07 +01:00
if ( $entry != '.' && $entry != '..' )
{
$this -> found_files [ $appname ][ $entry ] = $imagedir_olddefault ;
}
2001-12-29 11:57:35 +01:00
}
2002-11-03 02:03:07 +01:00
$d -> close ();
2001-12-29 11:57:35 +01:00
}
2002-01-04 05:06:13 +01:00
2002-11-03 02:03:07 +01:00
if ( @ is_dir ( PHPGW_INCLUDE_ROOT . $imagedir_default ))
2001-12-29 11:57:35 +01:00
{
2002-11-03 02:03:07 +01:00
$d = dir ( PHPGW_INCLUDE_ROOT . $imagedir_default );
while ( false != ( $entry = $d -> read ()))
2001-12-29 11:57:35 +01:00
{
2002-11-03 02:03:07 +01:00
if ( $entry != '.' && $entry != '..' )
{
$this -> found_files [ $appname ][ $entry ] = $imagedir_default ;
}
2001-12-29 11:57:35 +01:00
}
2002-11-03 02:03:07 +01:00
$d -> close ();
2001-12-29 11:57:35 +01:00
}
}
2002-01-04 05:06:13 +01:00
2001-12-29 11:57:35 +01:00
if ( @ is_dir ( PHPGW_INCLUDE_ROOT . $imagedir ))
{
$d = dir ( PHPGW_INCLUDE_ROOT . $imagedir );
2001-12-29 18:35:13 +01:00
while ( false != ( $entry = $d -> read ()))
2001-12-29 11:57:35 +01:00
{
if ( $entry != '.' && $entry != '..' )
{
2001-12-30 09:24:41 +01:00
$this -> found_files [ $appname ][ $entry ] = $imagedir ;
2001-12-29 11:57:35 +01:00
}
}
$d -> close ();
}
2001-05-06 18:37:40 +02:00
}
2001-12-29 11:57:35 +01:00
2002-01-21 18:51:54 +01:00
if ( isset ( $this -> found_files [ $appname ][ $image . '.' . $imgpref [ 0 ]]))
2001-12-29 18:35:13 +01:00
{
2002-01-21 18:51:54 +01:00
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ $appname ][ $image . '.' . $imgpref [ 0 ]] . '/' . $image . '.' . $imgpref [ 0 ];
2001-12-29 18:35:13 +01:00
}
2002-01-21 18:51:54 +01:00
elseif ( isset ( $this -> found_files [ $appname ][ $image . '.' . $imgpref [ 1 ]]))
2001-12-29 18:35:13 +01:00
{
2002-01-21 18:51:54 +01:00
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ $appname ][ $image . '.' . $imgpref [ 1 ]] . '/' . $image . '.' . $imgpref [ 1 ];
2001-12-29 18:35:13 +01:00
}
2002-01-21 18:51:54 +01:00
elseif ( isset ( $this -> found_files [ $appname ][ $image . '.' . $imgpref [ 2 ]]))
2001-12-29 18:35:13 +01:00
{
2002-01-21 18:51:54 +01:00
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ $appname ][ $image . '.' . $imgpref [ 2 ]] . '/' . $image . '.' . $imgpref [ 2 ];
2001-12-29 18:35:13 +01:00
}
2001-12-30 09:24:41 +01:00
elseif ( isset ( $this -> found_files [ $appname ][ $image ]))
2001-05-06 18:37:40 +02:00
{
2001-12-30 09:24:41 +01:00
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ $appname ][ $image ] . '/' . $image ;
2001-05-06 18:37:40 +02:00
}
2002-01-21 18:51:54 +01:00
elseif ( isset ( $this -> found_files [ 'phpgwapi' ][ $image . '.' . $imgpref [ 0 ]]))
2002-01-08 03:14:47 +01:00
{
2002-01-21 18:51:54 +01:00
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ 'phpgwapi' ][ $image . '.' . $imgpref [ 0 ]] . '/' . $image . '.' . $imgpref [ 0 ];
2002-01-08 03:14:47 +01:00
}
2002-01-21 18:51:54 +01:00
elseif ( isset ( $this -> found_files [ 'phpgwapi' ][ $image . '.' . $imgpref [ 1 ]]))
2002-01-08 03:14:47 +01:00
{
2002-01-21 18:51:54 +01:00
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ 'phpgwapi' ][ $image . '.' . $imgpref [ 1 ]] . '/' . $image . '.' . $imgpref [ 1 ];
2002-01-08 03:14:47 +01:00
}
2002-01-21 18:51:54 +01:00
elseif ( isset ( $this -> found_files [ 'phpgwapi' ][ $image . '.' . $imgpref [ 2 ]]))
2002-01-08 03:14:47 +01:00
{
2002-01-21 18:51:54 +01:00
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ 'phpgwapi' ][ $image . '.' . $imgpref [ 2 ]] . '/' . $image . '.' . $imgpref [ 2 ];
2002-01-08 03:14:47 +01:00
}
elseif ( isset ( $this -> found_files [ 'phpgwapi' ][ $image ]))
{
$imgfile = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ 'phpgwapi' ][ $image ] . '/' . $image ;
}
2001-05-06 18:37:40 +02:00
else
{
$imgfile = '' ;
}
return $imgfile ;
}
2002-11-03 02:03:07 +01:00
function image ( $appname , $image = '' , $ext = '' , $navbar = False , $use_lang = True )
2001-05-06 18:37:40 +02:00
{
2002-10-28 05:50:43 +01:00
if ( ! is_array ( $image ))
2001-05-06 18:37:40 +02:00
{
2002-10-28 05:50:43 +01:00
if ( empty ( $image ))
2002-01-08 03:14:47 +01:00
{
2002-10-28 05:50:43 +01:00
return '' ;
2002-01-08 03:14:47 +01:00
}
2002-10-28 05:50:43 +01:00
$image = array ( $image );
}
if ( $use_lang )
{
while ( list (, $img ) = each ( $image ))
2002-01-08 03:14:47 +01:00
{
2002-10-28 05:50:43 +01:00
$lang_images [] = $img . '_' . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ];
$lang_images [] = $img ;
2002-01-08 03:14:47 +01:00
}
2002-10-28 05:50:43 +01:00
$image = $lang_images ;
2001-05-06 18:37:40 +02:00
}
2002-10-28 05:50:43 +01:00
while ( ! $image_found && list (, $img ) = each ( $image ))
2001-05-06 18:37:40 +02:00
{
2002-10-28 05:50:43 +01:00
if ( isset ( $this -> found_files [ $appname ][ $img . $ext ]))
2002-01-08 03:14:47 +01:00
{
2002-10-28 05:50:43 +01:00
$image_found = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $this -> found_files [ $appname ][ $img . $ext ] . '/' . $img . $ext ;
2002-01-08 03:14:47 +01:00
}
else
{
2002-11-03 02:03:07 +01:00
$image_found = $this -> find_image ( $appname , $img . $ext , $navbar );
2002-01-08 03:14:47 +01:00
}
2001-05-06 18:37:40 +02:00
}
2002-10-28 05:50:43 +01:00
return $image_found ;
2001-05-06 18:37:40 +02:00
}
2001-12-29 18:35:13 +01:00
2002-11-03 02:03:07 +01:00
function image_on ( $appname , $image , $extension = '_on' , $navbar = False )
2001-12-29 18:35:13 +01:00
{
2002-11-03 02:03:07 +01:00
$with_extension = $this -> image ( $appname , $image , $extension , $navbar );
$without_extension = $this -> image ( $appname , $image , '' , $navbar );
2001-12-29 18:35:13 +01:00
if ( $with_extension != '' )
{
return $with_extension ;
}
elseif ( $without_extension != '' )
{
return $without_extension ;
}
else
{
return '' ;
}
}
2002-05-24 21:15:24 +02:00
/*!
@ function msgbox
@ abstract Generate a consistant msgbox for app apps to use
@ discussion makes it easier and more consistant to generate message boxes
*/
2002-10-25 05:04:28 +02:00
function msgbox ( $text = '' , $type = True , $base = '' )
2002-10-18 02:20:53 +02:00
{
if ( $text == '' && @ isset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'msgbox_data' ]))
{
$text = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'msgbox_data' ];
unset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'msgbox_data' ]);
}
elseif ( $text == '' )
{
return ;
}
2002-10-25 05:04:28 +02:00
$GLOBALS [ 'phpgw' ] -> xslttpl -> add_file ( $this -> get_tpl_dir ( 'phpgwapi' , 'default' ) . SEP . 'msgbox' );
2002-10-18 02:20:53 +02:00
$prev_helper = $GLOBALS [ 'phpgw' ] -> translation -> translator_helper ;
$GLOBALS [ 'phpgw' ] -> translation -> translator_helper = '' ;
if ( is_array ( $text ))
{
reset ( $text );
while ( list ( $key , $value ) = each ( $text ))
{
if ( $value == True )
{
$img = $this -> image ( 'phpgwapi' , 'msgbox_good' );
$alt = lang ( 'OK' );
}
else
{
$img = $this -> image ( 'phpgwapi' , 'msgbox_bad' );
$alt = lang ( 'ERROR' );
}
2002-10-20 02:34:12 +02:00
$data [] = array
2002-10-18 02:20:53 +02:00
(
'msgbox_text' => lang ( $key ),
'msgbox_img' => $img ,
'msgbox_img_alt' => $alt ,
'lang_msgbox_statustext' => $alt
);
}
}
else
{
if ( $type == True )
{
$img = $this -> image ( 'phpgwapi' , 'msgbox_good' );
$alt = lang ( 'OK' );
}
else
{
$img = $this -> image ( 'phpgwapi' , 'msgbox_bad' );
$alt = lang ( 'ERROR' );
}
2002-10-20 02:34:12 +02:00
$data = array
2002-10-18 02:20:53 +02:00
(
'msgbox_text' => lang ( $text ),
'msgbox_img' => $img ,
'msgbox_img_alt' => $alt ,
'lang_msgbox_statustext' => $alt
);
}
$GLOBALS [ 'phpgw' ] -> translation -> translator_helper = $prev_helper ;
2002-10-18 23:45:03 +02:00
2002-10-25 05:04:28 +02:00
if ( $base )
2002-10-20 02:34:12 +02:00
{
2002-10-25 05:04:28 +02:00
$GLOBALS [ 'phpgw' ] -> xslttpl -> set_var ( $base , array ( 'msgbox_data' => $data ), True );
2002-10-20 02:34:12 +02:00
}
else
{
2002-10-25 05:04:28 +02:00
return $data ;
2002-10-20 02:34:12 +02:00
}
2002-10-18 02:20:53 +02:00
}
2002-10-23 22:47:33 +02:00
function framework ()
2002-05-24 21:15:24 +02:00
{
2002-10-25 05:04:28 +02:00
$this -> navbar ();
2002-10-26 22:33:04 +02:00
2003-03-30 13:04:57 +02:00
$app_title = isset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ]) ? ' [' . $GLOBALS [ 'phpgw_info' ][ 'apps' ][ $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ]][ 'title' ] . ']' : '' ;
2002-10-25 05:04:28 +02:00
$css = $this -> get_css_url ();
2002-10-23 22:47:33 +02:00
$var = array
(
2002-10-25 05:04:28 +02:00
'charset' => lang ( 'charset' ),
2003-03-30 13:04:57 +02:00
'website_title' => $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'site_title' ] . $app_title ,
2002-11-08 23:42:14 +01:00
'webserver_url' => $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ],
2002-10-25 05:04:28 +02:00
'phpgw_css_file' => $css [ 0 ],
'theme_css_file' => $css [ 1 ],
2002-10-28 05:50:43 +01:00
'app_tpl' => $app_tpl
2002-10-23 22:47:33 +02:00
);
2002-11-30 03:02:32 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'headonly' ] == True )
{
$GLOBALS [ 'phpgw' ] -> xslttpl -> add_file ( $this -> get_tpl_dir ( 'phpgwapi' , 'default' ) . SEP . 'phpgw_header' );
}
else
{
$GLOBALS [ 'phpgw' ] -> xslttpl -> add_file ( $this -> get_tpl_dir ( 'phpgwapi' ) . SEP . 'phpgw' );
}
2002-05-26 21:57:35 +02:00
2002-11-15 23:31:51 +01:00
$cur_app = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2002-10-25 05:04:28 +02:00
switch ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ])
2002-10-23 22:47:33 +02:00
{
2002-10-25 05:04:28 +02:00
case 'idsociety' :
$find_single = strrpos ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ], '/' );
$find_double = strpos ( strrev ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . ' ' ), '//' );
if ( $find_double )
{
$find_double = strlen ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ]) - $find_double - 1 ;
}
if ( $find_double )
{
if ( $find_single == $find_double + 1 )
{
$GLOBALS [ 'strip_portion' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ];
}
else
{
$GLOBALS [ 'strip_portion' ] = substr ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ], 0 , $find_double + 1 );
}
}
else
{
$GLOBALS [ 'strip_portion' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . '/' ;
}
2002-05-24 21:15:24 +02:00
2002-10-25 05:04:28 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'home' )
{
$var [ 'home_img' ] = $this -> image ( 'phpgwapi' , 'welcome2' );
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ][] = $this -> image_on ( 'phpgwapi' , 'welcome2' , '_over' );
}
else
{
$var [ 'home_img' ] = $this -> image_on ( 'phpgwapi' , 'welcome2' , '_over' );
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ][] = $this -> image ( 'phpgwapi' , 'welcome2' );
}
$var [ 'home_img_hover' ] = $this -> image_on ( 'phpgwapi' , 'welcome2' , '_over' );
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'preferences' )
{
2002-11-18 23:09:01 +01:00
$var [ 'prefs_img' ] = $this -> image ( 'preferences' , 'preferences2' );
2002-11-15 23:31:51 +01:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ][] = $this -> image_on ( 'preferences' , 'preferences2' , '_over' );
2002-10-25 05:04:28 +02:00
}
else
{
2002-11-15 23:31:51 +01:00
$var [ 'prefs_img' ] = $this -> image_on ( 'preferences' , 'preferences2' , '_over' );
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ][] = $this -> image ( 'preferences' , 'preferences2' );
2002-10-25 05:04:28 +02:00
}
2002-11-15 23:31:51 +01:00
$var [ 'prefs_img_hover' ] = $this -> image_on ( 'preferences' , 'preferences2' , '_over' );
2002-10-23 22:47:33 +02:00
2002-10-25 05:04:28 +02:00
$var [ 'logout_img' ] = $this -> image ( 'phpgwapi' , 'log_out2' );
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ][] = $this -> image_on ( 'phpgwapi' , 'log_out2' , '_over' );
$var [ 'logout_img_hover' ] = $this -> image_on ( 'phpgwapi' , 'log_out2' , '_over' );
2002-05-24 21:15:24 +02:00
2002-10-25 05:04:28 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'about' )
{
$var [ 'about_img' ] = $this -> image ( 'phpgwapi' , 'question_mark2' );
$var [ 'about_img_hover' ] = $this -> image_on ( 'phpgwapi' , 'question_mark2' , '_over' );
}
else
{
$var [ 'about_img' ] = $this -> image_on ( 'phpgwapi' , 'question_mark2' , '_over' );
$var [ 'about_img_hover' ] = $this -> image ( 'phpgwapi' , 'question_mark2' );
}
2002-10-23 22:47:33 +02:00
2002-11-30 03:02:32 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'help' )
2002-11-15 23:31:51 +01:00
{
2002-11-30 03:02:32 +01:00
$var [ 'help_img' ] = $this -> image ( 'phpgwapi' , 'help' );
$var [ 'help_img_hover' ] = $this -> image_on ( 'phpgwapi' , 'help' , '_over' );
2002-11-15 23:31:51 +01:00
}
else
{
2002-11-30 03:02:32 +01:00
$var [ 'help_img' ] = $this -> image_on ( 'phpgwapi' , 'help' , '_over' );
$var [ 'help_img_hover' ] = $this -> image ( 'phpgwapi' , 'help' );
2002-11-15 23:31:51 +01:00
}
2002-10-25 05:04:28 +02:00
$var [ 'logo_img' ] = $this -> image ( 'phpgwapi' , 'logo2' );
$var [ 'nav_bar_left_top_bg_img' ] = $this -> image ( 'phpgwapi' , 'nav_bar_left_top_bg' );
2002-10-26 22:33:04 +02:00
break ;
case 'verdilak' :
$app = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
$var [ 'logo_img' ] = $this -> image ( 'phpgwapi' , 'logo' );
$var [ 'home_img' ] = $this -> image ( 'phpgwapi' , 'welcome-' . ( $app == 'home' ? 'red' : 'grey' ));
2002-11-16 00:43:20 +01:00
$var [ 'prefs_img' ] = $this -> image ( 'preferences' , 'preferences-' . ( $app == 'preferences' ? 'red' : 'grey' ));
2002-11-28 02:38:13 +01:00
$var [ 'logout_img' ] = $this -> image ( 'phpgwapi' , 'logout' );
$var [ 'about_img' ] = $this -> image ( 'phpgwapi' , 'about-' . ( $app == 'about' ? 'red' : 'grey' ));
2002-11-30 03:02:32 +01:00
$var [ 'help_img' ] = $this -> image ( 'phpgwapi' , 'help' );
2002-10-28 05:50:43 +01:00
$var [ 'greybar' ] = $this -> image ( 'phpgwapi' , 'greybar' );
2002-10-25 05:04:28 +02:00
break ;
2002-11-08 23:42:14 +01:00
case 'justweb' :
$var [ 'logo_img' ] = $this -> image ( 'phpgwapi' , 'logo' );
$var [ 'home_img' ] = $this -> image ( 'phpgwapi' , 'tab_home' );
2002-11-16 00:43:20 +01:00
$var [ 'prefs_img' ] = $this -> image ( 'preferences' , 'tab_prefs' );
2002-11-08 23:42:14 +01:00
$var [ 'logout_img' ] = $this -> image ( 'phpgwapi' , 'tab_logout' );
$var [ 'about_img' ] = $this -> image ( 'phpgwapi' , 'tab_help' );
2002-11-30 03:02:32 +01:00
$var [ 'help_img' ] = $this -> image ( 'phpgwapi' , 'tab_help' );
2002-11-08 23:42:14 +01:00
break ;
2002-11-15 23:31:51 +01:00
case 'funkwerk' :
$var [ 'about_img' ] = '!' ;
2002-11-30 03:02:32 +01:00
$var [ 'help_img' ] = '?' ;
2002-11-15 23:31:51 +01:00
switch ( $cur_app )
{
case 'home' :
$var [ 'top_css_home' ] = 'top_menu_selected' ;
2002-11-30 03:02:32 +01:00
$var [ 'top_css' ] = $var [ 'top_css_prefs' ] = $var [ 'top_css_about' ] = $var [ 'top_css_help' ] = 'top_menu' ;
2002-11-15 23:31:51 +01:00
break ;
case 'preferences' :
$var [ 'top_css_prefs' ] = 'top_menu_selected' ;
2002-11-30 03:02:32 +01:00
$var [ 'top_css' ] = $var [ 'top_css_home' ] = $var [ 'top_css_about' ] = $var [ 'top_css_help' ] = 'top_menu' ;
2002-11-15 23:31:51 +01:00
break ;
case 'about' :
$var [ 'top_css_about' ] = 'top_menu_selected' ;
2002-11-30 03:02:32 +01:00
$var [ 'top_css' ] = $var [ 'top_css_home' ] = $var [ 'top_css_prefs' ] = $var [ 'top_css_help' ] = 'top_menu' ;
2002-11-15 23:31:51 +01:00
break ;
2002-11-30 03:02:32 +01:00
case 'help' :
$var [ 'top_css_help' ] = 'top_menu_selected' ;
2002-11-15 23:31:51 +01:00
$var [ 'top_css' ] = $var [ 'top_css_home' ] = $var [ 'top_css_prefs' ] = $var [ 'top_css_about' ] = 'top_menu' ;
break ;
default :
2002-11-30 03:02:32 +01:00
$var [ 'top_css' ] = $var [ 'top_css_home' ] = $var [ 'top_css_prefs' ] = $var [ 'top_css_about' ] = $var [ 'top_css_help' ] = 'top_menu' ;
2002-11-15 23:31:51 +01:00
break ;
}
break ;
2002-10-27 00:39:19 +02:00
default :
$var [ 'home_img' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'icon' ];
$var [ 'prefs_img' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'preferences' ][ 'icon' ];
$var [ 'logout_img' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'icon' ];
2002-11-15 23:31:51 +01:00
$var [ 'about_img' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'icon' ];
2002-11-30 03:02:32 +01:00
$var [ 'help_img' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'icon' ];
2002-10-27 00:39:19 +02:00
break ;
2002-10-25 05:04:28 +02:00
}
2002-10-26 22:33:04 +02:00
2002-11-15 06:15:39 +01:00
$var [ 'home_link' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'url' ];
$var [ 'prefs_link' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'preferences' ][ 'url' ];
$var [ 'logout_link' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'url' ];
$var [ 'about_link' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'url' ];
2002-11-30 03:02:32 +01:00
$var [ 'help_link' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'url' ];
2002-10-23 22:47:33 +02:00
2002-11-15 06:15:39 +01:00
$var [ 'home_title' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'title' ];
$var [ 'prefs_title' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'preferences' ][ 'title' ];
$var [ 'logout_title' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'title' ];
$var [ 'about_title' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'title' ];
2002-11-30 03:02:32 +01:00
$var [ 'help_title' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'title' ];
2002-11-15 06:15:39 +01:00
$var [ 'home_statustext' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'title' ];
$var [ 'prefs_statustext' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'preferences' ][ 'title' ];
$var [ 'logout_statustext' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'title' ];
$var [ 'about_statustext' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'title' ];
2002-11-30 03:02:32 +01:00
$var [ 'help_statustext' ] = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'title' ];
2002-11-15 06:15:39 +01:00
if ( isset ( $GLOBALS [ 'phpgw_ifo' ][ 'navbar' ][ 'admin' ]) && isset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'show_currentusers' ]))
2002-10-23 22:47:33 +02:00
{
2003-03-21 01:47:18 +01:00
$var [ 'current_users' ] = lang ( 'Current users' ) . ': ' . $GLOBALS [ 'phpgw' ] -> session -> total ();
2002-10-25 05:04:28 +02:00
$var [ 'url_current_users' ] = $GLOBALS [ 'phpgw' ] -> link ( '/index.php' , 'menuaction=admin.uicurrentsessions.list_sessions' );
2002-10-23 22:47:33 +02:00
}
2002-10-25 05:04:28 +02:00
$var [ 'user_info_name' ] = $this -> display_fullname ();
2002-10-23 22:47:33 +02:00
$now = time ();
2002-10-25 05:04:28 +02:00
$var [ 'user_info_date' ] = lang ( $this -> show_date ( $now , 'l' )) . ' '
. $this -> show_date ( $now , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]);
2002-10-23 22:47:33 +02:00
$var [ 'user_info' ] = $var [ 'user_info_name' ] . ' - ' . $var [ 'user_info_date' ];
2003-03-30 13:04:57 +02:00
foreach ( $GLOBALS [ 'phpgw_info' ][ 'navbar' ] as $app => $data )
2002-10-23 22:47:33 +02:00
{
2002-11-15 23:31:51 +01:00
if ( $app == $cur_app )
{
$app_css = 'left_selected' ;
}
else
{
$app_css = 'left' ;
}
2003-01-04 01:12:48 +01:00
if ( $app != 'home' && $app != 'preferences' && $app != 'about' && $app != 'logout' && $app != 'help' && $app != 'manual' )
2002-10-23 22:47:33 +02:00
{
$var [ 'applications' ][] = array
(
2002-10-26 22:33:04 +02:00
'icon' => $data [ 'icon' ],
2003-03-30 13:04:57 +02:00
'title' => $data [ 'title' ],
2002-10-26 22:33:04 +02:00
'img_src_over' => $data [ 'icon_hover' ],
2002-10-28 05:50:43 +01:00
'url' => $data [ 'url' ],
2003-03-30 13:04:57 +02:00
'name' => $data [ 'title' ],
2002-11-15 23:31:51 +01:00
'statustext' => $data [ 'title' ],
2003-01-04 01:12:48 +01:00
'css' => $app_css
2002-10-23 22:47:33 +02:00
);
2002-10-26 22:33:04 +02:00
if ( $data [ 'icon_hover' ] != '' )
2002-10-23 22:47:33 +02:00
{
2002-10-26 22:33:04 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ][] = $data [ 'icon_hover' ];
2002-10-23 22:47:33 +02:00
}
2002-10-28 05:50:43 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'navbar_format' ] == 'text' &&
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ] == 'default' )
{
$tabs [ $app ] = array
(
'label' => $data [ 'title' ],
'link' => $data [ 'url' ]
);
}
2002-10-23 22:47:33 +02:00
}
2002-10-28 05:50:43 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'navbar_format' ] == 'text' &&
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ] == 'default' )
{
2002-11-15 23:31:51 +01:00
if ( $app == 'home' || $app == 'preferences' || $app == 'about' || $app == 'logout' || $app == 'manual' )
2002-10-28 05:50:43 +01:00
{
$base_tabs [ $app ] = array
(
'label' => $data [ 'title' ],
'link' => $data [ 'url' ]
);
}
}
}
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'navbar_format' ] == 'text' &&
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ] == 'default' )
{
$var [ 'app_tabs' ] = $this -> create_tabs ( $tabs , $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ], - 1 );
$var [ 'base_tabs' ] = $this -> create_tabs ( $base_tabs , $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ], - 1 );
2002-10-23 22:47:33 +02:00
}
2002-10-25 05:04:28 +02:00
$var [ 'onload' ] = $this -> load_preload_images_data ();
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'msgbox_data' ])
{
$this -> msgbox ( '' , False , 'phpgw' );
}
2002-11-30 03:02:32 +01:00
$var [ 'app_tpl' ] = '' ;
$var [ 'current_app' ] = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2002-11-02 23:25:14 +01:00
2002-11-30 03:02:32 +01:00
$menuaction = get_var ( 'menuaction' , Array ( 'GET' ));
2002-11-02 23:25:14 +01:00
2002-11-30 03:02:32 +01:00
if ( $menuaction && $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'xslt_app' ])
{
2003-01-04 01:54:55 +01:00
list ( $app , $class , $method ) = explode ( '.' , $menuaction );
$var [ 'app_tpl' ] = $method ;
//$app_function = strrchr($menuaction,'.');
//$var['app_tpl'] = substr($app_function,1,strlen($app_function));
2002-10-25 05:04:28 +02:00
}
2002-10-23 22:47:33 +02:00
$var [ 'lang_powered_by' ] = lang ( 'powered by' );
$var [ 'lang_version' ] = lang ( 'version' );
$var [ 'phpgw_version' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'versions' ][ 'phpgwapi' ];
$var [ 'lang_phpgw_statustext' ] = lang ( 'phpGroupWare --> homepage' );
$var [ 'top_spacer_middle_img' ] = $GLOBALS [ 'phpgw' ] -> common -> image ( 'phpgwapi' , 'top_spacer_middle' );
2002-11-15 06:15:39 +01:00
$var [ 'navbar_format' ] = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'navbar_format' ];
2002-10-23 22:47:33 +02:00
2002-10-27 00:39:19 +02:00
$GLOBALS [ 'phpgw' ] -> xslttpl -> set_var ( 'phpgw' , $var );
2002-10-23 22:47:33 +02:00
}
2002-05-26 21:57:35 +02:00
2001-03-14 18:21:09 +01:00
/*!
@ function navbar
2002-01-28 05:07:41 +01:00
@ abstract Build the application navigation bar based on user ' s accessible applications
2001-03-14 18:21:09 +01:00
@ discussion * someone wanna add some detail here *
*/
2001-03-08 09:44:57 +01:00
function navbar ()
2001-06-13 23:10:36 +02:00
{
2002-10-23 22:47:33 +02:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'title' ] = lang ( 'home' );
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'url' ] = $GLOBALS [ 'phpgw' ] -> link ( '/home.php' );
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'icon' ] = $this -> image ( 'phpgwapi' , Array ( 'home' , 'nonav' ));
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'home' ][ 'icon_hover' ] = $this -> image_on ( 'phpgwapi' , Array ( 'home' , 'nonav' ), '-over' );
2001-03-08 09:44:57 +01:00
2003-03-28 17:19:46 +01:00
list ( $first ) = each ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ]);
if ( is_array ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'admin' ]) && $first != 'admin' )
2001-12-31 17:10:12 +01:00
{
$newarray [ 'admin' ] = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'admin' ];
2003-03-28 17:19:46 +01:00
foreach ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ] as $index => $value )
2001-12-31 17:10:12 +01:00
{
if ( $index != 'admin' )
{
$newarray [ $index ] = $value ;
}
}
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ] = $newarray ;
reset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ]);
}
unset ( $index );
unset ( $value );
unset ( $newarray );
2002-01-28 05:07:41 +01:00
2002-11-15 23:31:51 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] == 'idsociety' || $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] == 'funkwerk' )
2002-11-03 02:03:07 +01:00
{
$navbar = True ;
}
else
{
$navbar = False ;
}
2003-03-28 17:19:46 +01:00
foreach ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ] as $app => $data )
2001-03-08 09:44:57 +01:00
{
2002-10-28 05:50:43 +01:00
if ( is_long ( $app ))
2001-03-08 09:44:57 +01:00
{
continue ;
}
2003-03-28 17:19:46 +01:00
if ( $app == 'preferences' || $GLOBALS [ 'phpgw_info' ][ 'apps' ][ $app ][ 'status' ] != 2 && $GLOBALS [ 'phpgw_info' ][ 'apps' ][ $app ][ 'status' ] != 3 )
2001-03-08 09:44:57 +01:00
{
2003-03-30 13:04:57 +02:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ $app ][ 'title' ] = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ $app ][ 'title' ];
2002-11-03 02:03:07 +01:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ $app ][ 'url' ] = $GLOBALS [ 'phpgw' ] -> link ( '/' . $app . '/index.php' );
2002-10-28 05:50:43 +01:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ $app ][ 'name' ] = $app ;
2001-12-30 05:58:39 +01:00
2002-10-28 05:50:43 +01:00
if ( $app != $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ])
2001-12-29 18:35:13 +01:00
{
2002-11-03 02:03:07 +01:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ $app ][ 'icon' ] = $this -> image ( $app , Array ( 'navbar' , 'nonav' ), '' , $navbar );
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ $app ][ 'icon_hover' ] = $this -> image_on ( $app , Array ( 'navbar' , 'nonav' ), '-over' , $navbar );
2001-12-29 18:35:13 +01:00
}
else
{
2002-11-03 02:03:07 +01:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ $app ][ 'icon' ] = $this -> image_on ( $app , Array ( 'navbar' , 'nonav' ), '-over' , $navbar );
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ $app ][ 'icon_hover' ] = $this -> image ( $app , Array ( 'navbar' , 'nonav' ), '' , $navbar );
2001-12-29 18:35:13 +01:00
}
2001-03-08 09:44:57 +01:00
}
}
2002-10-23 22:47:33 +02:00
2002-11-15 23:31:51 +01:00
/* apps for the top menu */
2002-11-30 03:02:32 +01:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'title' ] = lang ( 'manual' );
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'url' ] = $GLOBALS [ 'phpgw' ] -> link ( '/help.php' );
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'icon' ] = $this -> image ( 'phpgwapi' , Array ( 'help' , 'nonav' ));
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'help' ][ 'icon_hover' ] = $this -> image_on ( 'phpgwapi' , Array ( 'help' , 'nonav' ), '-over' );
2002-11-15 23:31:51 +01:00
2003-03-28 17:19:46 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'home' )
2001-03-08 09:44:57 +01:00
{
2003-03-28 17:19:46 +01:00
$app = $app_title = 'phpGroupWare' ;
2001-03-08 09:44:57 +01:00
}
else
{
2001-09-02 01:42:16 +02:00
$app = $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ];
2003-03-28 17:19:46 +01:00
$app_title = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ $app ][ 'title' ];
}
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'preferences' ]) // preferences last
{
$prefs = $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'preferences' ];
unset ( $GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'preferences' ]);
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'preferences' ] = $prefs ;
2001-03-08 09:44:57 +01:00
}
2001-01-11 10:52:33 +01:00
2002-01-28 05:07:41 +01:00
/* We handle this here becuase its special */
2003-03-30 13:04:57 +02:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'title' ] = lang ( 'about %1' , $GLOBALS [ 'phpgw_info' ][ 'apps' ][ $app ][ 'title' ]);
2002-10-23 22:47:33 +02:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'url' ] = $GLOBALS [ 'phpgw' ] -> link ( '/about.php' , 'app=' . $app );
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'icon' ] = $this -> image ( 'phpgwapi' , Array ( 'about' , 'nonav' ));
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'about' ][ 'icon_hover' ] = $this -> image_on ( 'phpgwapi' , Array ( 'about' , 'nonav' ), '-over' );
2001-01-11 10:52:33 +01:00
2002-10-25 05:04:28 +02:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'title' ] = lang ( 'logout' );
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'url' ] = $GLOBALS [ 'phpgw' ] -> link ( '/logout.php' );
2002-01-08 03:14:47 +01:00
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'icon' ] = $this -> image ( 'phpgwapi' , Array ( 'logout' , 'nonav' ));
$GLOBALS [ 'phpgw_info' ][ 'navbar' ][ 'logout' ][ 'icon_hover' ] = $this -> image_on ( 'phpgwapi' , Array ( 'logout' , 'nonav' ), '-over' );
2001-03-08 09:44:57 +01:00
}
2001-01-11 10:52:33 +01:00
2001-03-14 18:21:09 +01:00
/*!
2002-09-29 06:17:49 +02:00
@ function get_css_url
@ abstract returns the path of the css file for the choosen layout / theme
2002-05-30 23:13:07 +02:00
@ discussion * someone wanna add some detail here *
2001-03-14 18:21:09 +01:00
*/
2002-09-29 06:17:49 +02:00
function get_css_url ()
2002-09-27 02:14:18 +02:00
{
if ( ! $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ])
{
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] == 'user_choice' )
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = 'default' ;
}
else
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ];
}
}
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_theme' ] == 'user_choice' )
{
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ]))
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = 'default' ;
}
}
else
{
if ( isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_theme' ]))
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_theme' ];
}
}
if ( @ file_exists ( PHPGW_SERVER_ROOT . SEP . 'phpgwapi' . SEP . 'templates' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ]
. SEP . 'css' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] . '.css' ))
{
$css_file = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . SEP . 'phpgwapi' . SEP . 'templates' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ]
. SEP . 'css' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] . '.css' ;
}
2002-11-15 06:15:39 +01:00
elseif ( @ file_exists ( PHPGW_SERVER_ROOT . SEP . 'phpgwapi' . SEP . 'templates' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ] . SEP
. 'css' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ] . '.css' ))
2002-09-27 02:14:18 +02:00
{
2002-11-15 06:15:39 +01:00
$css_file = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . SEP . 'phpgwapi' . SEP . 'templates' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ]
. SEP . 'css' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ] . '.css' ;
2002-09-27 02:14:18 +02:00
}
else
{
/* Hope we don't get to this point. Better then the user seeing a */
/* complety back screen and not know whats going on */
$GLOBALS [ 'phpgw' ] -> log -> write ( array ( 'text' => 'F-Abort, No themes found' ));
}
2002-10-19 22:46:35 +02:00
$phpgw_css_file = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . SEP . 'phpgwapi' . SEP . 'templates' . SEP . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ]
. SEP . 'css' . SEP . 'phpgw.css' ;
2002-10-25 05:04:28 +02:00
return array ( $phpgw_css_file , $css_file );
2002-09-27 02:14:18 +02:00
}
2002-05-30 23:13:07 +02:00
function load_preload_images_data ()
{
if ( @ is_array ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ]))
{
$preload_image_string = '' ;
reset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ]);
while ( list ( $key , $value ) = each ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'preload_images' ]))
{
if ( $preload_image_string != '' )
{
$preload_image_string .= " ,' $value ' " ;
}
else
{
$preload_image_string .= " ' $value ' " ;
}
}
2002-05-31 10:29:19 +02:00
return " MM_preloadImages( $preload_image_string ); " ;
2002-05-30 23:13:07 +02:00
}
2002-05-31 10:29:19 +02:00
return '' ;
2002-05-30 23:13:07 +02:00
}
2002-09-27 02:14:18 +02:00
2002-05-30 23:13:07 +02:00
/*!
@ function phpgw_header
@ abstract load the phpgw header
*/
function phpgw_header ( $forceheader = True , $forcenavbar = True )
{
2002-05-31 20:13:07 +02:00
/* So far I dont have use for $forceheader and $forcenavbar */
/* I only allow this to be run once by using the constant */
2002-10-26 22:33:04 +02:00
/* not longer needed f<EFBFBD> r xslttpl and would require to load the phpgw template
2002-05-31 20:13:07 +02:00
if ( ! defined ( 'PHPGW_HEADER_RAN' ))
{
define ( 'PHPGW_HEADER_RAN' , True );
2002-09-29 06:17:49 +02:00
$this -> get_css_url ();
2002-05-31 20:13:07 +02:00
$this -> load_phpgw_body_tags ();
2002-10-18 02:20:53 +02:00
$GLOBALS [ 'phpgw' ] -> template -> set_var ( 'phpgw_msgbox' , $this -> msgbox ());
2002-05-31 20:13:07 +02:00
$GLOBALS [ 'phpgw' ] -> template -> set_block ( 'phpgw' , 'phpgw_head_javascript' );
$GLOBALS [ 'phpgw' ] -> template -> pfp ( 'out' , 'phpgw_main_start' );
}
2002-10-26 22:33:04 +02:00
*/
2001-03-08 09:44:57 +01:00
}
2002-05-24 12:38:03 +02:00
2001-03-14 18:21:09 +01:00
/*!
2002-05-24 12:38:03 +02:00
@ function phpgw_appheader
@ abstract load header . inc . php for an application
2001-03-14 18:21:09 +01:00
*/
2002-05-24 12:38:03 +02:00
function phpgw_appheader ()
2001-03-08 09:44:57 +01:00
{
2002-05-24 12:38:03 +02:00
if ( ! is_array ( MENUACTION ))
{
list ( $app , $class , $method ) = explode ( '.' , MENUACTION );
if ( is_array ( $GLOBALS [ $class ] -> public_functions ) && $GLOBALS [ $class ] -> public_functions [ 'header' ])
{
$GLOBALS [ $class ] -> header ();
}
}
elseif ( file_exists ( PHPGW_APP_INC . '/header.inc.php' ))
2001-03-08 09:44:57 +01:00
{
2002-05-24 12:38:03 +02:00
include ( PHPGW_APP_INC . '/header.inc.php' );
2001-03-08 09:44:57 +01:00
}
}
2002-05-30 11:47:09 +02:00
/*!
@ function phpgw_appfooter
@ abstract load footer . inc . php for an application
*/
function phpgw_appfooter ()
{
if ( ! is_array ( MENUACTION ))
{
list ( $app , $class , $method ) = explode ( '.' , MENUACTION );
if ( is_array ( $GLOBALS [ $class ] -> public_functions ) && $GLOBALS [ $class ] -> public_functions [ 'footer' ])
{
$GLOBALS [ $class ] -> footer ();
}
}
elseif ( file_exists ( PHPGW_APP_INC . '/footer.inc.php' ))
{
include ( PHPGW_APP_INC . '/footer.inc.php' );
}
}
2001-03-08 09:44:57 +01:00
2002-10-26 22:33:04 +02:00
function start_xslt_capture ()
{
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'xslt_capture' ]))
{
$GLOBALS [ 'phpgw_info' ][ 'xslt_capture' ] = True ;
ob_start (); // capture the output
}
}
/* Note : need to be run BEFORE exit is called , as buffers get flushed automatically before
* any registered shutdown - functions ( eg . phpgw_footer ) gets called
*/
function stop_xslt_capture ()
{
if ( isset ( $GLOBALS [ 'phpgw_info' ][ 'xslt_capture' ]))
{
unset ( $GLOBALS [ 'phpgw_info' ][ 'xslt_capture' ]);
$output = ob_get_contents (); // get captured output
ob_end_clean (); // stop capture and clean output-buffer
if ( ! empty ( $output ))
{
$GLOBALS [ 'phpgw' ] -> xslttpl -> set_var ( 'phpgw' , array ( 'body_data' => $output ));
}
}
}
2001-03-08 09:44:57 +01:00
function phpgw_footer ()
2002-10-26 00:34:04 +02:00
{
if ( ! defined ( 'PHPGW_FOOTER_RAN' ))
{
define ( 'PHPGW_FOOTER_RAN' , True );
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'home' &&
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'login' &&
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'logout' &&
!@ $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappfooter' ])
{
2002-10-29 23:15:32 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'support_old_style_apps' ])
{
$this -> start_xslt_capture (); // if index already turned it off
}
2002-10-26 00:34:04 +02:00
$this -> phpgw_appfooter ();
}
2002-10-29 23:15:32 +01:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'support_old_style_apps' ])
{
$this -> stop_xslt_capture ();
}
2002-10-26 22:33:04 +02:00
2002-10-26 00:34:04 +02:00
$GLOBALS [ 'phpgw' ] -> xslttpl -> pp ();
$GLOBALS [ 'phpgw' ] -> db -> disconnect ();
/* Clean up mcrypt */
if ( @ is_object ( $GLOBALS [ 'phpgw' ] -> crypto ))
{
$GLOBALS [ 'phpgw' ] -> crypto -> cleanup ();
unset ( $GLOBALS [ 'phpgw' ] -> crypto );
}
if ( DEBUG_TIMER )
{
$GLOBALS [ 'debug_timer_stop' ] = perfgetmicrotime ();
echo 'Page loaded in ' . ( $GLOBALS [ 'debug_timer_stop' ] - $GLOBALS [ 'debug_timer_start' ]) . ' seconds.' ;
}
}
}
2001-03-08 09:44:57 +01:00
function hex2bin ( $data )
{
$len = strlen ( $data );
return pack ( 'H' . $len , $data );
}
2001-12-27 16:48:42 +01:00
2001-03-14 18:21:09 +01:00
/*!
@ function encrypt
@ abstract encrypt data passed to the function
@ param $data data ( string ? ) to be encrypted
*/
2001-06-13 23:10:36 +02:00
function encrypt ( $data )
2001-03-08 09:44:57 +01:00
{
2001-09-02 01:42:16 +02:00
return $GLOBALS [ 'phpgw' ] -> crypto -> encrypt ( $data );
2001-03-08 09:44:57 +01:00
}
2001-03-14 18:21:09 +01:00
/*!
@ function decrypt
@ abstract decrypt $data
@ param $data data to be decrypted
*/
2001-03-08 09:44:57 +01:00
function decrypt ( $data )
{
2001-12-20 17:19:55 +01:00
return $GLOBALS [ 'phpgw' ] -> crypto -> decrypt ( $data );
2001-03-08 09:44:57 +01:00
}
2001-12-27 16:48:42 +01:00
2001-03-14 18:21:09 +01:00
/*!
@ function des_cryptpasswd
@ abstract des encrypt a password
@ param $userpass userpassword
@ param $random random seed
*/
2001-03-08 09:44:57 +01:00
function des_cryptpasswd ( $userpass , $random )
{
$lcrypt = '{crypt}' ;
2002-11-24 22:53:21 +01:00
$password = crypt ( $userpass , $random );
2001-03-08 09:44:57 +01:00
$ldappassword = sprintf ( '%s%s' , $lcrypt , $password );
return $ldappassword ;
}
2002-11-24 22:53:21 +01:00
2001-03-14 18:21:09 +01:00
/*!
@ function md5_cryptpasswd
@ abstract md5 encrypt password
@ param $userpass user password
@ param $random random seed
2002-05-26 21:57:35 +02:00
*/
2001-06-13 23:10:36 +02:00
function md5_cryptpasswd ( $userpass , $random )
{
$bsalt = '$1$' ;
2001-12-27 16:48:42 +01:00
$esalt = '$' ;
2001-06-13 23:10:36 +02:00
$lcrypt = '{crypt}' ;
2001-12-27 16:48:42 +01:00
$modsalt = sprintf ( '%s%s%s' , $bsalt , $random , $esalt );
2001-06-13 23:10:36 +02:00
$password = crypt ( $userpass , $modsalt );
$ldappassword = sprintf ( '%s%s' , $lcrypt , $password );
return $ldappassword ;
}
2002-05-26 21:57:35 +02:00
/*!
@ function sha_cryptpasswd
@ abstract sha encrypt password
@ param $userpass user password
*/
2002-05-14 03:02:19 +02:00
function sha_cryptpasswd ( $userpass )
{
$hash = base64_encode ( mhash ( MHASH_SHA1 , $userpass ));
$ldappassword = sprintf ( '%s%s' , '{SHA}' , $hash );
return $ldappassword ;
}
2001-03-14 18:21:09 +01:00
/*!
@ function encrypt_password
@ abstract encrypt password
@ abstract uses the encryption type set in setup and calls the appropriate encryption functions
@ param $password password to encrypt
*/
2001-06-13 23:10:36 +02:00
function encrypt_password ( $password )
{
2002-05-14 03:02:19 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'ldap_encryption_type' ] == 'DES' )
2001-06-13 23:10:36 +02:00
{
$salt = $this -> randomstring ( 2 );
$e_password = $this -> des_cryptpasswd ( $password , $salt );
}
2002-05-14 03:02:19 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'ldap_encryption_type' ] == 'MD5' )
2001-06-13 23:10:36 +02:00
{
2001-12-27 16:48:42 +01:00
$salt = $this -> randomstring ( 8 );
2001-06-13 23:10:36 +02:00
$e_password = $this -> md5_cryptpasswd ( $password , $salt );
}
2002-05-14 03:02:19 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'ldap_encryption_type' ] == 'SHA' )
{
if ( @ function_exists ( 'mhash' ))
{
$e_password = $this -> sha_cryptpasswd ( $password );
}
else
{
/* this should error instead... */
$salt = $this -> randomstring ( 8 );
$e_password = $this -> md5_cryptpasswd ( $password , $salt );
}
}
2001-06-13 23:10:36 +02:00
return $e_password ;
}
2001-10-21 12:49:29 +02:00
/*!
@ function find_portal_order
@ abstract find the current position of the app is the users portal_order preference
@ param $app application id to find current position - required
@ discussion No discussion
*/
function find_portal_order ( $app )
{
if ( ! is_array ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]))
{
return - 1 ;
}
@ reset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]);
while ( list ( $seq , $appid ) = each ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]))
{
if ( $appid == $app )
{
@ reset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]);
return $seq ;
}
}
@ reset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]);
return - 1 ;
}
2001-03-14 18:21:09 +01:00
/*!
@ function hook
2002-01-02 15:33:05 +01:00
@ abstract temp wrapper to new hooks class
2001-03-14 18:21:09 +01:00
*/
2002-01-02 15:33:05 +01:00
function hook ( $location , $appname = '' , $no_permission_check = False )
2001-03-14 13:10:01 +01:00
{
2002-01-02 15:33:05 +01:00
echo '$' . " GLOBALS['phpgw']common->hook() " . ' has been replaced. Please change to the new $' . " GLOBALS['phpgw']hooks->process() " . '. For now this will act as a wrapper<br>' ;
return $GLOBALS [ 'phpgw' ] -> hooks -> process ( $location , $order , $no_permission_check );
2001-12-27 16:48:42 +01:00
}
2001-01-11 10:52:33 +01:00
2001-03-14 18:21:09 +01:00
/*!
@ function hook_single
2002-01-02 15:33:05 +01:00
@ abstract temp wrapper to new hooks class
2001-03-14 18:21:09 +01:00
*/
2001-09-04 01:02:36 +02:00
// Note: $no_permission_check should *ONLY* be used when it *HAS* to be. (jengo)
function hook_single ( $location , $appname = '' , $no_permission_check = False )
2001-06-07 03:46:12 +02:00
{
2002-01-02 15:33:05 +01:00
echo '$' . " GLOBALS['phpgw']common->hook_single() " . ' has been replaced. Please change to the new $' . " GLOBALS['phpgw']hooks->single() " . '. For now this will act as a wrapper<br>' ;
return $GLOBALS [ 'phpgw' ] -> hooks -> single ( $location , $order , $no_permission_check );
2001-06-07 03:46:12 +02:00
}
2001-01-11 10:52:33 +01:00
2001-03-14 18:21:09 +01:00
/*!
@ function hook_count
2002-01-02 15:33:05 +01:00
@ abstract temp wrapper to new hooks class
2001-03-14 18:21:09 +01:00
*/
2001-06-07 03:46:12 +02:00
function hook_count ( $location )
{
2002-01-02 15:33:05 +01:00
echo '$' . " GLOBALS['phpgw']common->hook_count() " . ' has been replaced. Please change to the new $' . " GLOBALS['phpgw']hooks->count() " . '. For now this will act as a wrapper<br>' ;
return $GLOBALS [ 'phpgw' ] -> hooks -> count ( $location );
2001-06-07 03:46:12 +02:00
}
/* Wrapper to the session->appsession() */
function appsession ( $data = '##NOTHING##' )
{
$this -> debug_info [] = '$phpgw->common->appsession() is a depreciated function'
. ' - use $phpgw->session->appsession() instead' ;
2001-09-02 01:42:16 +02:00
return $GLOBALS [ 'phpgw' ] -> session -> appsession ( 'default' , '' , $data );
2001-06-07 03:46:12 +02:00
}
2001-01-11 10:52:33 +01:00
2001-03-14 18:21:09 +01:00
/*!
@ function show_date
@ abstract show current date
@ param $t time - optional can be pulled from user preferences
@ param $format - optional can be pulled from user prefernces
*/
2001-06-13 23:10:36 +02:00
function show_date ( $t = '' , $format = '' )
{
2002-06-25 03:38:34 +02:00
if ( ! is_object ( $GLOBALS [ 'phpgw' ] -> datetime ))
{
$GLOBALS [ 'phpgw' ] -> datetime = createobject ( 'phpgwapi.datetime' );
}
if ( ! $t || intval ( $t ) <= 0 )
2001-06-13 23:10:36 +02:00
{
2002-04-30 05:35:52 +02:00
$t = $GLOBALS [ 'phpgw' ] -> datetime -> gmtnow ;
2001-06-13 23:10:36 +02:00
}
2001-01-11 10:52:33 +01:00
2002-04-30 05:35:52 +02:00
// + (date('I') == 1?3600:0)
2002-06-25 03:38:34 +02:00
$t += $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2002-04-30 05:35:52 +02:00
2001-06-13 23:10:36 +02:00
if ( ! $format )
{
2001-09-02 01:42:16 +02:00
$format = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ] . ' - ' ;
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'timeformat' ] == '12' )
2001-06-13 23:10:36 +02:00
{
$format .= 'h:i:s a' ;
}
else
{
$format .= 'H:i:s' ;
}
}
return date ( $format , $t );
}
2001-12-27 16:48:42 +01:00
2001-03-15 06:55:06 +01:00
/*!
@ function dateformatorder
@ abstract
@ param $yearstr year - string
@ param $monthstr month - string
@ param $day day - string
@ param $add_seperator boolean defaults to false
*/
2001-06-13 23:10:36 +02:00
function dateformatorder ( $yearstr , $monthstr , $daystr , $add_seperator = False )
{
2001-09-02 01:42:16 +02:00
$dateformat = strtolower ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]);
$sep = substr ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ], 1 , 1 );
2001-06-13 23:10:36 +02:00
$dlarr [ strpos ( $dateformat , 'y' )] = $yearstr ;
$dlarr [ strpos ( $dateformat , 'm' )] = $monthstr ;
$dlarr [ strpos ( $dateformat , 'd' )] = $daystr ;
ksort ( $dlarr );
if ( $add_seperator )
{
return ( implode ( $sep , $dlarr ));
}
else
{
return ( implode ( ' ' , $dlarr ));
}
}
2001-12-27 16:48:42 +01:00
2001-03-15 06:55:06 +01:00
/*!
@ function formattime
@ abstract format the time takes settings from user preferences
@ param $hour hour
@ param $min minutes
@ param $sec defaults to ''
*/
2001-12-08 16:34:12 +01:00
function formattime ( $hour , $min , $sec = '' )
{
$h12 = $hour ;
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'timeformat' ] == '12' )
{
if ( $hour >= 12 )
{
$ampm = ' pm' ;
}
else
{
$ampm = ' am' ;
}
$h12 %= 12 ;
if ( $h12 == 0 && $hour )
{
$h12 = 12 ;
}
if ( $h12 == 0 && ! $hour )
{
$h12 = 0 ;
}
}
else
{
$h12 = $hour ;
}
if ( $sec )
{
$sec = " : $sec " ;
}
return " $h12 : $min $sec $ampm " ;
}
2001-07-02 22:02:15 +02:00
// This is not the best place for it, but it needs to be shared bewteen Aeromail and SM
/*!
@ function get_email_passwd_ex
@ abstract uses code in / email class msg to obtain the appropriate password for email
@ param ( none - it will abtain the info it needs on its own )
*/
2001-08-08 21:37:17 +02:00
/*
2001-07-02 22:02:15 +02:00
function get_email_passwd_ex ()
{
2001-08-08 21:37:17 +02:00
// ---- Create the email Message Class if needed -----
2001-09-07 19:51:48 +02:00
if ( is_object ( $GLOBALS [ 'phpgw' ] -> msg ))
2001-07-02 22:02:15 +02:00
{
2001-08-08 21:37:17 +02:00
$do_free_me = False ;
2001-07-02 22:02:15 +02:00
}
else
{
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> msg = CreateObject ( 'email.mail_msg' );
2001-08-08 21:37:17 +02:00
$do_free_me = True ;
2001-07-02 22:02:15 +02:00
}
// use the Msg class to obtain the appropriate password
2001-09-02 01:42:16 +02:00
$tmp_prefs = $GLOBALS [ 'phpgw' ] -> preferences -> read ();
2001-07-02 22:02:15 +02:00
if ( ! isset ( $tmp_prefs [ 'email' ][ 'passwd' ]))
{
2001-09-02 01:42:16 +02:00
$email_passwd = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'passwd' ];
2001-07-02 22:02:15 +02:00
}
else
{
2001-09-02 01:42:16 +02:00
$email_passwd = $GLOBALS [ 'phpgw' ] -> msg -> decrypt_email_passwd ( $tmp_prefs [ 'email' ][ 'passwd' ]);
2001-07-02 22:02:15 +02:00
}
2001-08-08 21:37:17 +02:00
// cleanup and return
if ( $do_free_me )
2001-07-02 22:02:15 +02:00
{
2001-09-02 01:42:16 +02:00
unset ( $GLOBALS [ 'phpgw' ] -> msg );
2001-07-02 22:02:15 +02:00
}
return $email_passwd ;
}
2001-08-08 21:37:17 +02:00
*/
2001-02-20 09:29:31 +01:00
// This is not the best place for it, but it needs to be shared bewteen Aeromail and SM
2001-03-15 06:55:06 +01:00
/*!
@ function create_emailpreferences
@ abstract create email preferences
@ discussion This is not the best place for it , but it needs to be shared between Aeromail and SM
@ param $prefs
2001-12-27 16:48:42 +01:00
@ param $account_id - optional defaults to : phpgw_info [ 'user' ][ 'account_id' ]
2001-08-08 21:37:17 +02:00
*/
function create_emailpreferences ( $prefs = '' , $accountid = '' )
{
2001-11-13 19:19:53 +01:00
return $GLOBALS [ 'phpgw' ] -> preferences -> create_email_preferences ( $accountid );
2001-08-08 21:37:17 +02:00
// ---- Create the email Message Class if needed -----
2001-09-07 19:51:48 +02:00
if ( is_object ( $GLOBALS [ 'phpgw' ] -> msg ))
2001-08-08 21:37:17 +02:00
{
$do_free_me = False ;
}
else
{
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> msg = CreateObject ( 'email.mail_msg' );
2001-08-08 21:37:17 +02:00
$do_free_me = True ;
}
2001-12-27 16:48:42 +01:00
// this sets the preferences into the phpgw_info structure
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> msg -> create_email_preferences ();
2001-08-08 21:37:17 +02:00
// cleanup and return
if ( $do_free_me )
{
2001-09-02 01:42:16 +02:00
unset ( $GLOBALS [ 'phpgw' ] -> msg );
2001-08-08 21:37:17 +02:00
}
}
/*
2001-03-19 21:25:04 +01:00
function create_emailpreferences ( $prefs , $accountid = '' )
2001-02-20 09:29:31 +01:00
{
2001-03-19 21:25:04 +01:00
$account_id = get_account_id ( $accountid );
2001-02-20 09:29:31 +01:00
2001-07-02 22:02:15 +02:00
// NEW EMAIL PASSWD METHOD (shared between SM and aeromail)
$prefs [ 'email' ][ 'passwd' ] = $this -> get_email_passwd_ex ();
2001-08-08 21:37:17 +02:00
// Add default preferences info
2001-03-07 20:02:25 +01:00
if ( ! isset ( $prefs [ 'email' ][ 'userid' ]))
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mail_login_type' ] == 'vmailmgr' )
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
$prefs [ 'email' ][ 'userid' ] = $GLOBALS [ 'phpgw' ] -> accounts -> id2name ( $account_id )
. '@' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mail_suffix' ];
2001-02-20 09:29:31 +01:00
}
else
{
2001-09-02 01:42:16 +02:00
$prefs [ 'email' ][ 'userid' ] = $GLOBALS [ 'phpgw' ] -> accounts -> id2name ( $account_id );
2001-02-20 09:29:31 +01:00
}
}
2001-08-08 21:37:17 +02:00
// Set Server Mail Type if not defined
2001-09-02 01:42:16 +02:00
if ( empty ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mail_server_type' ]))
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mail_server_type' ] = 'imap' ;
2001-02-20 09:29:31 +01:00
}
2001-07-02 22:02:15 +02:00
2001-08-08 21:37:17 +02:00
// OLD EMAIL PASSWD METHOD
2001-03-07 20:02:25 +01:00
if ( ! isset ( $prefs [ 'email' ][ 'passwd' ]))
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
$prefs [ 'email' ][ 'passwd' ] = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'passwd' ];
2001-02-20 09:29:31 +01:00
}
2001-02-21 04:48:59 +01:00
else
{
2001-03-07 20:02:25 +01:00
$prefs [ 'email' ][ 'passwd' ] = $this -> decrypt ( $prefs [ 'email' ][ 'passwd' ]);
2001-08-08 21:37:17 +02:00
}
2001-07-02 22:02:15 +02:00
// NEW EMAIL PASSWD METHOD Located at the begining of this function
2001-03-07 20:02:25 +01:00
if ( ! isset ( $prefs [ 'email' ][ 'address' ]))
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
$prefs [ 'email' ][ 'address' ] = $GLOBALS [ 'phpgw' ] -> accounts -> id2name ( $account_id )
. '@' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mail_suffix' ];
2001-02-20 09:29:31 +01:00
}
2001-03-07 20:02:25 +01:00
if ( ! isset ( $prefs [ 'email' ][ 'mail_server' ]))
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
$prefs [ 'email' ][ 'mail_server' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mail_server' ];
2001-02-20 09:29:31 +01:00
}
2001-03-07 20:02:25 +01:00
if ( ! isset ( $prefs [ 'email' ][ 'mail_server_type' ]))
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
$prefs [ 'email' ][ 'mail_server_type' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mail_server_type' ];
2001-02-20 09:29:31 +01:00
}
2001-03-07 20:02:25 +01:00
if ( ! isset ( $prefs [ 'email' ][ 'imap_server_type' ]))
2001-02-20 09:29:31 +01:00
{
2001-09-02 01:42:16 +02:00
$prefs [ 'email' ][ 'imap_server_type' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'imap_server_type' ];
2001-02-20 09:29:31 +01:00
}
2001-08-08 21:37:17 +02:00
// These sets the mail_port server variable
2001-03-07 20:02:25 +01:00
if ( $prefs [ 'email' ][ 'mail_server_type' ] == 'imap' )
2001-02-20 09:29:31 +01:00
{
2001-03-07 20:02:25 +01:00
$prefs [ 'email' ][ 'mail_port' ] = '143' ;
2001-02-20 09:29:31 +01:00
}
2001-04-09 13:45:01 +02:00
elseif ( $prefs [ 'email' ][ 'mail_server_type' ] == 'pop3' )
2001-02-20 09:29:31 +01:00
{
2001-03-07 20:02:25 +01:00
$prefs [ 'email' ][ 'mail_port' ] = '110' ;
2001-02-20 09:29:31 +01:00
}
2002-09-17 04:47:35 +02:00
elseif ( $prefs [ 'email' ][ 'mail_server_type' ] == 'imaps' )
{
$prefs [ 'email' ][ 'mail_port' ] = '993' ;
}
elseif ( $prefs [ 'email' ][ 'mail_server_type' ] == 'pop3s' )
{
$prefs [ 'email' ][ 'mail_port' ] = '995' ;
}
2001-08-08 21:37:17 +02:00
// This is going to be used to switch to the nntp class
2002-05-31 11:25:52 +02:00
if ( isset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'newsmode' ]) &&
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'newsmode' ])
2001-02-20 09:29:31 +01:00
{
2001-03-07 20:02:25 +01:00
$prefs [ 'email' ][ 'mail_server_type' ] = 'nntp' ;
2001-02-21 04:02:20 +01:00
}
2001-07-02 22:02:15 +02:00
// DEBUG
//echo "<br>prefs['email']['passwd']: " .$prefs['email']['passwd'] .'<br>';
2001-03-08 19:51:17 +01:00
return $prefs ;
2001-02-20 09:29:31 +01:00
}
2001-08-08 21:37:17 +02:00
*/
2001-02-20 09:29:31 +01:00
2001-06-13 23:10:36 +02:00
// This will be moved into the applications area.
2001-03-15 06:55:06 +01:00
/*!
@ function check_code
@ abstract ?
@ discussion This will be moved into the applications area
*/
2001-06-13 23:10:36 +02:00
function check_code ( $code )
{
$s = '<br>' ;
switch ( $code )
{
case 13 : $s .= lang ( 'Your message has been sent' ); break ;
case 14 : $s .= lang ( 'New entry added sucessfully' ); break ;
case 15 : $s .= lang ( 'Entry updated sucessfully' ); break ;
case 16 : $s .= lang ( 'Entry has been deleted sucessfully' ); break ;
case 18 : $s .= lang ( 'Password has been updated' ); break ;
case 38 : $s .= lang ( 'Password could not be changed' ); break ;
case 19 : $s .= lang ( 'Session has been killed' ); break ;
case 27 : $s .= lang ( 'Account has been updated' ); break ;
case 28 : $s .= lang ( 'Account has been created' ); break ;
case 29 : $s .= lang ( 'Account has been deleted' ); break ;
case 30 : $s .= lang ( 'Your settings have been updated' ); break ;
case 31 : $s .= lang ( 'Group has been added' ); break ;
case 32 : $s .= lang ( 'Group has been deleted' ); break ;
case 33 : $s .= lang ( 'Group has been updated' ); break ;
case 34 : $s .= lang ( 'Account has been deleted' ) . '<p>'
. lang ( 'Error deleting x x directory' , lang ( 'users' ), ' ' . lang ( 'private' ) . ' ' )
. ',<br>' . lang ( 'Please x by hand' , lang ( 'delete' )) . '<br><br>'
. lang ( 'To correct this error for the future you will need to properly set the' )
. '<br>' . lang ( 'permissions to the files/users directory' )
. '<br>' . lang ( 'On *nix systems please type: x' , 'chmod 770 '
2001-09-02 01:42:16 +02:00
. $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'files_dir' ] . '/users/' );
2001-06-13 23:10:36 +02:00
break ;
case 35 : $s .= lang ( 'Account has been updated' ) . '<p>'
. lang ( 'Error renaming x x directory' , lang ( 'users' ),
' ' . lang ( 'private' ) . ' ' )
. ',<br>' . lang ( 'Please x by hand' ,
lang ( 'rename' )) . '<br><br>'
. lang ( 'To correct this error for the future you will need to properly set the' )
. '<br>' . lang ( 'permissions to the files/users directory' )
. '<br>' . lang ( 'On *nix systems please type: x' , 'chmod 770 '
2001-09-02 01:42:16 +02:00
. $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'files_dir' ] . '/users/' );
2001-06-13 23:10:36 +02:00
break ;
case 36 : $s .= lang ( 'Account has been created' ) . '<p>'
. lang ( 'Error creating x x directory' , lang ( 'users' ),
' ' . lang ( 'private' ) . ' ' )
. ',<br>' . lang ( 'Please x by hand' ,
lang ( 'create' )) . '<br><br>'
. lang ( 'To correct this error for the future you will need to properly set the' )
. '<br>' . lang ( 'permissions to the files/users directory' )
. '<br>' . lang ( 'On *nix systems please type: x' , 'chmod 770 '
2001-09-02 01:42:16 +02:00
. $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'files_dir' ] . '/users/' );
2001-06-13 23:10:36 +02:00
break ;
case 37 : $s .= lang ( 'Group has been added' ) . '<p>'
. lang ( 'Error creating x x directory' , lang ( 'groups' ), ' ' )
. ',<br>' . lang ( 'Please x by hand' ,
lang ( 'create' )) . '<br><br>'
. lang ( 'To correct this error for the future you will need to properly set the' )
. '<br>' . lang ( 'permissions to the files/users directory' )
. '<br>' . lang ( 'On *nix systems please type: x' , 'chmod 770 '
2001-09-02 01:42:16 +02:00
. $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'files_dir' ] . '/groups/' );
2001-06-13 23:10:36 +02:00
break ;
case 38 : $s .= lang ( 'Group has been deleted' ) . '<p>'
. lang ( 'Error deleting x x directory' , lang ( 'groups' ), ' ' )
. ',<br>' . lang ( 'Please x by hand' ,
lang ( 'delete' )) . '<br><br>'
. lang ( 'To correct this error for the future you will need to properly set the' )
. '<br>' . lang ( 'permissions to the files/users directory' )
. '<br>' . lang ( 'On *nix systems please type: x' , 'chmod 770 '
2001-09-02 01:42:16 +02:00
. $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'files_dir' ] . '/groups/' );
2001-06-13 23:10:36 +02:00
break ;
case 39 : $s .= lang ( 'Group has been updated' ) . '<p>'
. lang ( 'Error renaming x x directory' , lang ( 'groups' ), ' ' )
. ',<br>' . lang ( 'Please x by hand' ,
lang ( 'rename' )) . '<br><br>'
. lang ( 'To correct this error for the future you will need to properly set the' )
. '<br>' . lang ( 'permissions to the files/users directory' )
. '<br>' . lang ( 'On *nix systems please type: x' , 'chmod 770 '
2001-09-02 01:42:16 +02:00
. $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'files_dir' ] . '/groups/' );
2001-06-13 23:10:36 +02:00
break ;
case 40 : $s .= lang ( 'You have not entered a title' ) . '.' ;
break ;
case 41 : $s .= lang ( 'You have not entered a valid time of day' ) . '.' ;
break ;
case 42 : $s .= lang ( 'You have not entered a valid date' ) . '.' ;
break ;
2001-08-31 03:01:05 +02:00
case 43 : $s .= lang ( 'You have not entered participants' ) . '.' ;
break ;
2001-06-13 23:10:36 +02:00
default : return '' ;
}
return $s ;
}
2001-03-15 06:55:06 +01:00
/*!
2001-06-13 23:10:36 +02:00
@ function phpgw_error
2001-03-15 06:55:06 +01:00
@ abstract process error message
@ param $error error
@ param $line line
@ param $file file
2001-06-13 23:10:36 +02:00
*/
function phpgw_error ( $error , $line = '' , $file = '' )
{
echo '<p><b>phpGroupWare internal error:</b><p>' . $error ;
if ( $line )
{
echo 'Line: ' . $line ;
}
if ( $file )
{
echo 'File: ' . $file ;
}
echo '<p>Your session has been halted.' ;
exit ;
}
2001-01-11 10:52:33 +01:00
2001-03-15 06:55:06 +01:00
/*!
@ function create_phpcode_from_array
@ abstract create phpcode from array
@ param $array - array
*/
2001-06-13 23:10:36 +02:00
function create_phpcode_from_array ( $array )
{
while ( list ( $key , $val ) = each ( $array ))
{
if ( is_array ( $val ))
{
while ( list ( $key2 , $val2 ) = each ( $val ))
{
if ( is_array ( $val2 ))
{
while ( list ( $key3 , $val3 ) = each ( $val2 ))
{
if ( is_array ( $val3 ))
{
while ( list ( $key4 , $val4 ) = each ( $val3 ))
{
$s .= '$phpgw_info["' . $key . '"]["' . $key2 . '"]["' . $key3 . '"]["' . $key4 . '"]="' . $val4 . '";' ;
$s .= " \n " ;
}
}
else
{
$s .= '$phpgw_info["' . $key . '"]["' . $key2 . '"]["' . $key3 . '"]="' . $val3 . '";' ;
$s .= " \n " ;
}
}
}
else
{
$s .= '$phpgw_info["' . $key . '"]["' . $key2 . '"]="' . $val2 . '";' ;
$s .= " \n " ;
}
}
}
else
{
$s .= '$phpgw_info["' . $key . '"]="' . $val . '";' ;
$s .= " \n " ;
}
}
return $s ;
}
// This will return the full phpgw_info array, used for debugging
2001-03-15 06:55:06 +01:00
/*!
@ function debug_list_array_contents
@ abstract return the full phpgw_info array for debugging
@ param array - array
2001-06-13 23:10:36 +02:00
*/
function debug_list_array_contents ( $array )
{
while ( list ( $key , $val ) = each ( $array ))
{
if ( is_array ( $val ))
{
while ( list ( $key2 , $val2 ) = each ( $val ))
{
if ( is_array ( $val2 ))
{
while ( list ( $key3 , $val3 ) = each ( $val2 ))
{
if ( is_array ( $val3 ))
{
while ( list ( $key4 , $val4 ) = each ( $val3 ))
{
echo $$array . " [ $key ][ $key2 ][ $key3 ][ $key4 ]= $val4 <br> " ;
}
}
else
{
echo $$array . " [ $key ][ $key2 ][ $key3 ]= $val3 <br> " ;
}
}
}
else
{
echo $$array . " [ $key ][ $key2 ]= $val2 <br> " ;
}
}
}
else
{
echo $$array . " [ $key ]= $val <br> " ;
}
}
}
// This will return a list of functions in the API
2001-03-15 06:55:06 +01:00
/*!
@ function debug_list_core_functions
@ abstract return a list of functionsin the API
*/
2001-06-13 23:10:36 +02:00
function debug_list_core_functions ()
{
echo '<br><b>core functions</b><br>' ;
echo '<pre>' ;
chdir ( PHPGW_INCLUDE_ROOT . '/phpgwapi' );
system ( " grep -r '^[ \t ]*function' * " );
echo '</pre>' ;
}
// This will return a value for the next id an app/class may need to insert values into ldap.
2001-03-22 09:23:35 +01:00
/*!
@ function next_id
@ abstract return the next higher value for an integer , and increment it in the db .
*/
2001-06-13 23:10:36 +02:00
function next_id ( $appname , $min = 0 , $max = 0 )
{
if ( ! $appname )
{
return - 1 ;
}
2001-03-22 09:23:35 +01:00
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " SELECT id FROM phpgw_nextid WHERE appname=' " . $appname . " ' " , __LINE__ , __FILE__ );
while ( $GLOBALS [ 'phpgw' ] -> db -> next_record () )
2001-06-13 23:10:36 +02:00
{
2001-09-02 01:42:16 +02:00
$id = $GLOBALS [ 'phpgw' ] -> db -> f ( 'id' );
2001-06-13 23:10:36 +02:00
}
2001-03-22 09:23:35 +01:00
2001-06-13 23:10:36 +02:00
if ( empty ( $id ) || ! $id )
{
$id = 1 ;
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " INSERT INTO phpgw_nextid (appname,id) VALUES (' " . $appname . " ', " . $id . " ) " , __LINE__ , __FILE__ );
2001-06-13 23:10:36 +02:00
}
elseif ( $id < $min )
{
$id = $min ;
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " UPDATE phpgw_nextid SET id= " . $id . " WHERE appname=' " . $appname . " ' " , __LINE__ , __FILE__ );
2001-06-13 23:10:36 +02:00
}
elseif ( $max && ( $id > $max ))
{
return False ;
}
else
{
$id = $id + 1 ;
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " UPDATE phpgw_nextid SET id= " . $id . " WHERE appname=' " . $appname . " ' " , __LINE__ , __FILE__ );
2001-06-13 23:10:36 +02:00
}
2001-03-22 09:23:35 +01:00
2001-06-13 23:10:36 +02:00
return intval ( $id );
}
2001-03-23 05:42:22 +01:00
2001-06-13 23:10:36 +02:00
// This will return a value for the last id entered, which an app may need to check
// values for ldap.
2001-03-23 05:42:22 +01:00
/*!
@ function last_id
@ abstract return the current id in the next_id table for a particular app / class .
*/
2001-06-13 23:10:36 +02:00
function last_id ( $appname , $min = 0 , $max = 0 )
{
if ( ! $appname )
{
return - 1 ;
}
2001-03-23 05:42:22 +01:00
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " SELECT id FROM phpgw_nextid WHERE appname=' " . $appname . " ' " , __LINE__ , __FILE__ );
while ( $GLOBALS [ 'phpgw' ] -> db -> next_record () )
2001-06-13 23:10:36 +02:00
{
2001-09-02 01:42:16 +02:00
$id = $GLOBALS [ 'phpgw' ] -> db -> f ( 'id' );
2001-06-13 23:10:36 +02:00
}
2001-03-23 05:42:22 +01:00
2001-06-13 23:10:36 +02:00
if ( empty ( $id ) || ! $id )
{
if ( $min )
{
$id = $min ;
}
else
{
$id = 1 ;
}
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " INSERT INTO phpgw_nextid (appname,id) VALUES (' " . $appname . " ', " . $id . " ) " , __LINE__ , __FILE__ );
2001-06-13 23:10:36 +02:00
}
elseif ( $id < $min )
{
$id = $min ;
2001-09-02 01:42:16 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " UPDATE phpgw_nextid SET id= " . $id . " WHERE appname=' " . $appname . " ' " , __LINE__ , __FILE__ );
2001-06-13 23:10:36 +02:00
}
elseif ( $max && ( $id > $max ))
{
return False ;
}
else
{
return intval ( $id );
}
2001-03-23 05:42:22 +01:00
}
2001-06-13 23:10:36 +02:00
} //end common class
2001-12-30 05:58:39 +01:00