diff --git a/phpgwapi/inc/class.db_oracle.inc.php b/phpgwapi/inc/class.db_oracle.inc.php
index 7b29743d7a..301c98cef5 100644
--- a/phpgwapi/inc/class.db_oracle.inc.php
+++ b/phpgwapi/inc/class.db_oracle.inc.php
@@ -1,454 +1,546 @@
query($query);
- }
+ /* public: constructor */
+ function db($query = '')
+ {
+ $this->query($query);
+ }
- /* public: some trivial reporting */
- function link_id() {
- return $this->Link_ID;
- }
+ /* public: some trivial reporting */
+ function link_id()
+ {
+ return $this->Link_ID;
+ }
- function query_id() {
- return $this->Query_ID;
- }
+ function query_id()
+ {
+ return $this->Query_ID;
+ }
- function connect() {
- ## see above why we do this
- if ($this->OraPutEnv) {
- PutEnv("ORACLE_SID=$this->Database");
- PutEnv("ORACLE_HOME=$this->Home");
- }
- if ( 0 == $this->Link_ID ) {
- if($this->Debug) {
- printf("
Connect()ing to $this->Database...
\n");
- }
- if($this->Remote) {
- if($this->Debug) {
- printf("
connect() $this->User/******@$this->Database.world
\n");
- }
- if($GLOBALS['phpgw_info']['server']['db_persistent'])
- {
- $this->Link_ID=ora_plogon("$this->User/$this->Password@$this->Database","");
- /************** (comment by SSilk)
- this dosn't work on my system:
- $this->Link_ID=ora_plogon("$this->User@$this->Database.world","$this->Password");
- ***************/
- }
- else
- {
- $this->Link_ID=ora_logon("$this->User/$this->Password@$this->Database","");
- /************** (comment by SSilk)
- this dosn't work on my system:
- $this->Link_ID=ora_logon("$this->User@$this->Database.world","$this->Password");
- ***************/
- }
- } else {
- if($this->Debug) {
- printf("
connect() $this->User, $this->Password
\n");
- }
- if($GLOBALS['phpgw_info']['server']['db_persistent'])
- {
- $this->Link_ID=ora_plogon("$this->User","$this->Password");
- /* (comment by SSilk: don't know how this could work, but I leave this untouched!) */
- }
- else
- {
- $this->Link_ID=ora_logon("$this->User","$this->Password");
- }
- }
- if($this->Debug) {
- printf("
connect() Link_ID: $this->Link_ID
\n");
- }
- if (!$this->Link_ID) {
- $this->halt("connect() Link-ID == false " .
- "($this->Link_ID), ora_".($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."logon failed");
- } else {
- //echo "commit on
";
- ora_commiton($this->Link_ID);
- }
- if($this->Debug) {
- printf("
connect() Obtained the Link_ID: $this->Link_ID
\n");
- }
- }
- }
-
- ## In order to increase the # of cursors per system/user go edit the
- ## init.ora file and increase the max_open_cursors parameter. Yours is on
- ## the default value, 100 per user.
- ## We tried to change the behaviour of query() in a way, that it tries
- ## to safe cursors, but on the other side be carefull with this, that you
- ## don't use an old result.
- ##
- ## You can also make extensive use of ->disconnect()!
- ## The unused QueryIDs will be recycled sometimes.
+ function connect()
+ {
+ ## see above why we do this
+ if ($this->OraPutEnv)
+ {
+ PutEnv("ORACLE_SID=$this->Database");
+ PutEnv("ORACLE_HOME=$this->Home");
+ }
+ if ( 0 == $this->Link_ID )
+ {
+ if($this->Debug)
+ {
+ printf('
Connecting to ' . $this->Database . "...
\n");
+ }
+ if($this->Remote)
+ {
+ if($this->Debug)
+ {
+ printf("
connect() $this->User/******@$this->Database.world
\n");
+ }
+ if($GLOBALS['phpgw_info']['server']['db_persistent'])
+ {
+ $this->Link_ID = ora_plogon("$this->User/$this->Password@$this->Database","");
+ /************** (comment by SSilk)
+ this dosn't work on my system:
+ $this->Link_ID = ora_plogon("$this->User@$this->Database.world","$this->Password");
+ ***************/
+ }
+ else
+ {
+ $this->Link_ID = ora_logon("$this->User/$this->Password@$this->Database","");
+ /************** (comment by SSilk)
+ this dosn't work on my system:
+ $this->Link_ID=ora_logon("$this->User@$this->Database.world","$this->Password");
+ ***************/
+ }
+ }
+ else
+ {
+ if($this->Debug)
+ {
+ printf("
connect() $this->User, $this->Password
\n");
+ }
+ if($GLOBALS['phpgw_info']['server']['db_persistent'])
+ {
+ $this->Link_ID=ora_plogon("$this->User","$this->Password");
+ /* (comment by SSilk: don't know how this could work, but I leave this untouched!) */
+ }
+ else
+ {
+ $this->Link_ID=ora_logon("$this->User","$this->Password");
+ }
+ }
+ if($this->Debug)
+ {
+ printf("
connect() Link_ID: $this->Link_ID
\n");
+ }
+ if (!$this->Link_ID)
+ {
+ $this->halt('connect() Link-ID == false '
+ . "($this->Link_ID), ora_".($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'logon failed');
+ }
+ else
+ {
+ //echo 'commit on
';
+ ora_commiton($this->Link_ID);
+ }
+ if($this->Debug)
+ {
+ printf("
connect() Obtained the Link_ID: $this->Link_ID
\n");
+ }
+ }
+ }
- function query($Query_String) {
+ ## In order to increase the # of cursors per system/user go edit the
+ ## init.ora file and increase the max_open_cursors parameter. Yours is on
+ ## the default value, 100 per user.
+ ## We tried to change the behaviour of query() in a way, that it tries
+ ## to safe cursors, but on the other side be carefull with this, that you
+ ## don't use an old result.
+ ##
+ ## You can also make extensive use of ->disconnect()!
+ ## The unused QueryIDs will be recycled sometimes.
- /* No empty queries, please, since PHP4 chokes on them. */
- if ($Query_String == "")
- /* The empty query string is passed on from the constructor,
- * when calling the class without a query, e.g. in situations
- * like these: '$db = new DB_Sql_Subclass;'
- */
- return 0;
+ function query($Query_String)
+ {
+ /* No empty queries, please, since PHP4 chokes on them. */
+ if ($Query_String == '')
+ {
+ /* The empty query string is passed on from the constructor,
+ * when calling the class without a query, e.g. in situations
+ * like these: '$db = new DB_Sql_Subclass;'
+ */
+ return 0;
+ }
+ $this->connect();
+ $this->lastQuery=$Query_String;
- $this->connect();
- $this->lastQuery=$Query_String;
+ if (!$this->Query_ID)
+ {
+ $this->Query_ID = ora_open($this->Link_ID);
+ }
+ if($this->Debug)
+ {
+ printf("Debug: query = %s
\n", $Query_String);
+ printf("
Debug: Query_ID: %d
\n", $this->Query_ID);
+ }
- if (!$this->Query_ID) {
- $this->Query_ID= ora_open($this->Link_ID);
- }
- if($this->Debug) {
- printf("Debug: query = %s
\n", $Query_String);
- printf("
Debug: Query_ID: %d
\n", $this->Query_ID);
- }
-
- if(!@ora_parse($this->Query_ID,$Query_String)) {
- $this->Errno=ora_errorcode($this->Query_ID);
- $this->Error=ora_error($this->Query_ID);
- $this->halt("
ora_parse() failed:
$Query_String
Snap & paste this to sqlplus!");
- } elseif (!@ora_exec($this->Query_ID)) {
- $this->Errno=ora_errorcode($this->Query_ID);
- $this->Error=ora_error($this->Query_ID);
- $this->halt("
\n$Query_String\n
Snap & paste this to sqlplus!");
- }
+ if(!@ora_parse($this->Query_ID,$Query_String))
+ {
+ $this->Errno=ora_errorcode($this->Query_ID);
+ $this->Error=ora_error($this->Query_ID);
+ $this->halt("
ora_parse() failed:
$Query_String
Snap & paste this to sqlplus!");
+ }
+ elseif (!@ora_exec($this->Query_ID))
+ {
+ $this->Errno=ora_errorcode($this->Query_ID);
+ $this->Error=ora_error($this->Query_ID);
+ $this->halt("
\n$Query_String\n
Snap & paste this to sqlplus!");
+ }
- $this->Row=0;
+ $this->Row=0;
- if(!$this->Query_ID) {
- $this->halt("Invalid SQL: ".$Query_String);
- }
-
- return $this->Query_ID;
- }
-
- function next_record() {
- if (!$this->no_next_fetch &&
- 0 == ora_fetch($this->Query_ID)) {
- if ($this->Debug) {
- printf("
next_record(): ID: %d,Rows: %d
\n",
- $this->Query_ID,$this->num_rows());
- }
- $this->Row +=1;
-
- $errno=ora_errorcode($this->Query_ID);
- if(1403 == $errno) { # 1043 means no more records found
- $this->Errno=0;
- $this->Error="";
- $this->disconnect();
- $stat=0;
- } else {
- $this->Error=ora_error($this->Query_ID);
- $this->Errno=$errno;
- if($this->Debug) {
- printf("
%d Error: %s",
- $this->Errno,
- $this->Error);
- }
- $stat=0;
- }
- } else {
- $this->no_next_fetch=false;
- for($ix=0;$ix
\n";
- }
- $stat=1;
- }
+ if(!$this->Query_ID)
+ {
+ $this->halt('Invalid SQL: '.$Query_String);
+ }
- return $stat;
- }
+ return $this->Query_ID;
+ }
- ## seek() works only for $pos - 1 and $pos
- ## Perhaps I make a own implementation, but my
- ## opinion is, that this should be done by PHP3
- function seek($pos) {
- if ($this->Row - 1 == $pos) {
- $this->no_next_fetch=true;
- } elseif ($this->Row == $pos ) {
- ## do nothing
- } else {
- $this->halt("Invalid seek(): Position is cannot be handled by API.
".
- "Difference too big. Wanted: $pos Current pos: $this->Row");
- }
- if ($Debug) echo "
Debug: seek = $pos
";
- $this->Row=$pos;
- }
+ function next_record()
+ {
+ if (!$this->no_next_fetch &&
+ 0 == ora_fetch($this->Query_ID))
+ {
+ if ($this->Debug)
+ {
+ printf("
next_record(): ID: %d,Rows: %d
\n",
+ $this->Query_ID,$this->num_rows());
+ }
+ $this->Row +=1;
- function lock($table, $mode = "write") {
- if ($mode == "write") {
- $result = ora_do($this->Link_ID, "lock table $table in row exclusive mode");
- } else {
- $result = 1;
- }
- return $result;
- }
-
- function unlock() {
- return ora_do($this->Link_ID, "commit");
- }
+ $errno=ora_errorcode($this->Query_ID);
+ if(1403 == $errno)
+ { # 1043 means no more records found
+ $this->Errno = 0;
+ $this->Error = '';
+ $this->disconnect();
+ $stat=0;
+ }
+ else
+ {
+ $this->Error=ora_error($this->Query_ID);
+ $this->Errno=$errno;
+ if($this->Debug)
+ {
+ printf('
%d Error: %s',
+ $this->Errno,
+ $this->Error);
+ }
+ $stat=0;
+ }
+ }
+ else
+ {
+ $this->no_next_fetch=false;
+ for($ix=0;$ix
\n";
+ }
+ $stat=1;
+ }
+ return $stat;
+ }
- function metadata($table,$full=false) {
- $count = 0;
- $id = 0;
- $res = array();
-
- /*
- * Due to compatibility problems with Table we changed the behavior
- * of metadata();
- * depending on $full, metadata returns the following values:
- *
- * - full is false (default):
- * $result[]:
- * [0]["table"] table name
- * [0]["name"] field name
- * [0]["type"] field type
- * [0]["len"] field length
- * [0]["flags"] field flags ("NOT NULL", "INDEX")
- * [0]["format"] precision and scale of number (eg. "10,2") or empty
- * [0]["index"] name of index (if has one)
- * [0]["chars"] number of chars (if any char-type)
- *
- * - full is true
- * $result[]:
- * ["num_fields"] number of metadata records
- * [0]["table"] table name
- * [0]["name"] field name
- * [0]["type"] field type
- * [0]["len"] field length
- * [0]["flags"] field flags ("NOT NULL", "INDEX")
- * [0]["format"] precision and scale of number (eg. "10,2") or empty
- * [0]["index"] name of index (if has one)
- * [0]["chars"] number of chars (if any char-type)
- * ["meta"][field name] index of field named "field name"
- * The last one is used, if you have a field name, but no index.
- * Test: if (isset($result['meta']['myfield'])) {} ...
- */
+ ## seek() works only for $pos - 1 and $pos
+ ## Perhaps I make a own implementation, but my
+ ## opinion is, that this should be done by PHP3
+ function seek($pos)
+ {
+ if($this->Row - 1 == $pos)
+ {
+ $this->no_next_fetch=true;
+ }
+ elseif ($this->Row == $pos )
+ {
+ ## do nothing
+ }
+ else
+ {
+ $this->halt("Invalid seek(): Position is cannot be handled by API.
".
+ "Difference too big. Wanted: $pos Current pos: $this->Row");
+ }
+ if($Debug)
+ {
+ echo "
Debug: seek = $pos
";
+ }
+ $this->Row=$pos;
+ }
- $this->connect();
+ function lock($table, $mode = 'write')
+ {
+ if ($mode == 'write')
+ {
+ $result = ora_do($this->Link_ID, "lock table $table in row exclusive mode");
+ }
+ else
+ {
+ $result = 1;
+ }
+ return $result;
+ }
- ## This is a RIGHT OUTER JOIN: "(+)", if you want to see, what
- ## this query results try the following:
- ## $table = new Table; $db = new my_DB_Sql; # you have to make
- ## # your own class
- ## $table->show_results($db->query(see query vvvvvv))
- ##
- $this->query("SELECT T.table_name,T.column_name,T.data_type,".
- "T.data_length,T.data_precision,T.data_scale,T.nullable,".
- "T.char_col_decl_length,I.index_name".
- " FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I".
- " WHERE T.column_name=I.column_name (+)".
- " AND T.table_name=I.table_name (+)".
- " AND T.table_name=UPPER('$table') ORDER BY T.column_id");
-
- $i=0;
- while ($this->next_record()) {
- $res[$i]["table"] = $this->Record[table_name];
- $res[$i]["name"] = strtolower($this->Record[column_name]);
- $res[$i]["type"] = $this->Record[data_type];
- $res[$i]["len"] = $this->Record[data_length];
- if ($this->Record[index_name]) $res[$i]["flags"] = "INDEX ";
- $res[$i]["flags"] .= ( $this->Record[nullable] == 'N') ? '' : 'NOT NULL';
- $res[$i]["format"]= (int)$this->Record[data_precision].",".
- (int)$this->Record[data_scale];
- if ("0,0"==$res[$i]["format"]) $res[$i]["format"]='';
- $res[$i]["index"] = $this->Record[index_name];
- $res[$i]["chars"] = $this->Record[char_col_decl_length];
- if ($full) {
- $j=$res[$i]["name"];
- $res["meta"][$j] = $i;
- $res["meta"][strtoupper($j)] = $i;
- }
- if ($full) $res["meta"][$res[$i]["name"]] = $i;
- $i++;
- }
- if ($full) $res["num_fields"]=$i;
-# $this->disconnect();
- return $res;
- }
+ function unlock()
+ {
+ return ora_do($this->Link_ID, 'commit');
+ }
- ## THIS FUNCTION IS UNSTESTED!
- function affected_rows() {
- if ($Debug) echo "
Debug: affected_rows=". ora_numrows($this->Query_ID)."
";
- return ora_numrows($this->Query_ID);
- }
+ function metadata($table,$full=false)
+ {
+ $count = 0;
+ $id = 0;
+ $res = array();
- ## Known bugs: It will not work for SELECT DISTINCT and any
- ## other constructs which are depending on the resulting rows.
- ## So you *really need* to check every query you make, if it
- ## will work with it.
- ##
- ## Also, for a qualified replacement you need to parse the
- ## selection, cause this will fail: "SELECT id, from FROM ...").
- ## "FROM" is - as far as I know a keyword in Oracle, so it can
- ## only be used in this way. But you have been warned.
- function num_rows() {
- $curs=ora_open($this->Link_ID);
+ /*
+ * Due to compatibility problems with Table we changed the behavior
+ * of metadata();
+ * depending on $full, metadata returns the following values:
+ *
+ * - full is false (default):
+ * $result[]:
+ * [0]['table'] table name
+ * [0]['name'] field name
+ * [0]['type'] field type
+ * [0]['len'] field length
+ * [0]['flags'] field flags ('NOT NULL', 'INDEX')
+ * [0]['format'] precision and scale of number (eg. '10,2') or empty
+ * [0]['index'] name of index (if has one)
+ * [0]['chars'] number of chars (if any char-type)
+ *
+ * - full is true
+ * $result[]:
+ * ['num_fields'] number of metadata records
+ * [0]['table'] table name
+ * [0]['name'] field name
+ * [0]['type'] field type
+ * [0]['len'] field length
+ * [0]['flags'] field flags ('NOT NULL', 'INDEX')
+ * [0]['format'] precision and scale of number (eg. '10,2') or empty
+ * [0]['index'] name of index (if has one)
+ * [0]['chars'] number of chars (if any char-type)
+ * ['meta'][field name] index of field named 'field name'
+ * The last one is used, if you have a field name, but no index.
+ * Test: if (isset($result['meta']['myfield'])) {} ...
+ */
- ## this is the important part and it is also the HACK!
- if (eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) ) {
- $from_pos = strpos(strtoupper($this->lastQuery),"FROM");
- $q = "SELECT count(*) ". substr($this->lastQuery, $from_pos);
-
- ORA_parse($curs,$q);
- ORA_exec($curs);
- ORA_fetch($curs);
- if ($Debug) echo "
Debug: num_rows=". ORA_getcolumn($curs,0)."
";
- return(ORA_getcolumn($curs,0));
- } else {
- $this->halt("Last Query was not a SELECT: $this->lastQuery");
- }
- }
+ $this->connect();
- function num_fields() {
- if ($Debug) echo "
Debug: num_fields=". ora_numcols($this->Query_ID) . "
";
- return ora_numcols($this->Query_ID);
- }
+ ## This is a RIGHT OUTER JOIN: '(+)', if you want to see, what
+ ## this query results try the following:
+ ## $table = new Table; $db = new my_DB_Sql; # you have to make
+ ## # your own class
+ ## $table->show_results($db->query(see query vvvvvv))
+ ##
+ $this->query("SELECT T.table_name,T.column_name,T.data_type,".
+ "T.data_length,T.data_precision,T.data_scale,T.nullable,".
+ "T.char_col_decl_length,I.index_name".
+ " FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I".
+ " WHERE T.column_name=I.column_name (+)".
+ " AND T.table_name=I.table_name (+)".
+ " AND T.table_name=UPPER('$table') ORDER BY T.column_id");
- function nf() {
- return $this->num_rows();
- }
+ $i=0;
+ while ($this->next_record())
+ {
+ $res[$i]['table'] = $this->Record[table_name];
+ $res[$i]['name'] = strtolower($this->Record[column_name]);
+ $res[$i]['type'] = $this->Record[data_type];
+ $res[$i]['len'] = $this->Record[data_length];
+ if ($this->Record[index_name])
+ {
+ $res[$i]['flags'] = 'INDEX ';
+ }
+ $res[$i]['flags'] .= ( $this->Record['nullable'] == 'N') ? '' : 'NOT NULL';
+ $res[$i]['format']= (int)$this->Record['data_precision'].','.
+ (int)$this->Record[data_scale];
+ if ('0,0'==$res[$i]['format'])
+ {
+ $res[$i]['format']='';
+ }
+ $res[$i]['index'] = $this->Record[index_name];
+ $res[$i]['chars'] = $this->Record[char_col_decl_length];
+ if ($full)
+ {
+ $j=$res[$i]['name'];
+ $res['meta'][$j] = $i;
+ $res['meta'][strtoupper($j)] = $i;
+ }
+ if ($full)
+ {
+ $res['meta'][$res[$i]['name']] = $i;
+ }
+ $i++;
+ }
+ if ($full)
+ {
+ $res['num_fields']=$i;
+ }
+ # $this->disconnect();
+ return $res;
+ }
- function np() {
- print $this->num_rows();
- }
+ ## THIS FUNCTION IS UNSTESTED!
+ function affected_rows()
+ {
+ if ($Debug)
+ {
+ echo '
Debug: affected_rows='. ora_numrows($this->Query_ID).'
';
+ }
+ return ora_numrows($this->Query_ID);
+ }
- function f($Name) {
- return $this->Record[$Name];
- }
+ ## Known bugs: It will not work for SELECT DISTINCT and any
+ ## other constructs which are depending on the resulting rows.
+ ## So you *really need* to check every query you make, if it
+ ## will work with it.
+ ##
+ ## Also, for a qualified replacement you need to parse the
+ ## selection, cause this will fail: 'SELECT id, from FROM ...').
+ ## 'FROM' is - as far as I know a keyword in Oracle, so it can
+ ## only be used in this way. But you have been warned.
+ function num_rows()
+ {
+ $curs=ora_open($this->Link_ID);
- function p($Name) {
- print $this->Record[$Name];
- }
+ ## this is the important part and it is also the HACK!
+ if (eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) )
+ {
+ $from_pos = strpos(strtoupper($this->lastQuery),'FROM');
+ $q = 'SELECT count(*) '. substr($this->lastQuery, $from_pos);
- /* public: sequence number */
- function nextid($seq_name)
- {
- $this->connect();
+ ORA_parse($curs,$q);
+ ORA_exec($curs);
+ ORA_fetch($curs);
+ if ($Debug)
+ {
+ echo '
Debug: num_rows='. ORA_getcolumn($curs,0).'
';
+ }
+ return(ORA_getcolumn($curs,0));
+ }
+ else
+ {
+ $this->halt("Last Query was not a SELECT: $this->lastQuery");
+ }
+ }
- /* Independent Query_ID */
- $Query_ID = ora_open($this->Link_ID);
-
- if(!@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL"))
- {
- // There is no such sequence yet, then create it
- if(!@ora_parse($Query_ID,"CREATE SEQUENCE $seq_name")
- ||
- !@ora_exec($Query_ID)
- )
- {
- $this->halt("
nextid() function - unable to create sequence");
- return 0;
- }
- @ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL");
- }
- if (!@ora_exec($Query_ID)) {
- $this->halt("
ora_exec() failed:
nextID function");
- }
- if (@ora_fetch($Query_ID) ) {
- $next_id = ora_getcolumn($Query_ID, 0);
- }
- else {
- $next_id = 0;
- }
- if ( Query_ID > 0 ) {
- ora_close(Query_ID);
- }
-
- return $next_id;
- }
+ function num_fields()
+ {
+ if ($Debug)
+ {
+ echo '
Debug: num_fields='. ora_numcols($this->Query_ID) . '
';
+ }
+ return ora_numcols($this->Query_ID);
+ }
- function disconnect() {
- if($this->Debug) {
- echo "Debug: Disconnecting $this->Query_ID...
\n";
- }
- if ( $this->Query_ID < 1 ) {
- echo "Warning: disconnect(): Cannot free ID $this->Query_ID\n";
-# return();
- }
- ora_close($this->Query_ID);
- $this->Query_ID=0;
- }
-
- /* private: error handling */
- function halt($msg) {
- if ($this->Halt_On_Error == "no")
- return;
+ function nf()
+ {
+ return $this->num_rows();
+ }
- $this->haltmsg($msg);
+ function np()
+ {
+ print $this->num_rows();
+ }
- if ($this->Halt_On_Error != "report")
- die("Session halted.");
- }
+ function f($Name)
+ {
+ return $this->Record[$Name];
+ }
- function haltmsg($msg) {
- printf("Database error: %s
\n", $msg);
- printf("Oracle Error: %s (%s)
\n",
- $this->Errno,
- $this->Error);
- }
+ function p($Name)
+ {
+ print $this->Record[$Name];
+ }
- function table_names() {
- $this->connect();
- $this->query("
- SELECT table_name,tablespace_name
- FROM user_tables");
- $i=0;
- while ($this->next_record())
- {
- $info[$i]["table_name"] =$this->Record["table_name"];
- $info[$i]["tablespace_name"]=$this->Record["tablespace_name"];
- $i++;
- }
- return $info;
- }
-}
+ /* public: sequence number */
+ function nextid($seq_name)
+ {
+ $this->connect();
+
+ /* Independent Query_ID */
+ $Query_ID = ora_open($this->Link_ID);
+
+ if(!@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL"))
+ {
+ // There is no such sequence yet, then create it
+ if(!@ora_parse($Query_ID,"CREATE SEQUENCE $seq_name") ||
+ !@ora_exec($Query_ID))
+ {
+ $this->halt('
nextid() function - unable to create sequence');
+ return 0;
+ }
+ @ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL");
+ }
+ if (!@ora_exec($Query_ID))
+ {
+ $this->halt("
ora_exec() failed:
nextID function");
+ }
+ if (@ora_fetch($Query_ID) )
+ {
+ $next_id = ora_getcolumn($Query_ID, 0);
+ }
+ else
+ {
+ $next_id = 0;
+ }
+ if ( Query_ID > 0 )
+ {
+ ora_close(Query_ID);
+ }
+ return $next_id;
+ }
+
+ function disconnect()
+ {
+ if($this->Debug)
+ {
+ echo "Debug: Disconnecting $this->Query_ID...
\n";
+ }
+ if ( $this->Query_ID < 1 )
+ {
+ echo "Warning: disconnect(): Cannot free ID $this->Query_ID\n";
+ # return();
+ }
+ ora_close($this->Query_ID);
+ $this->Query_ID=0;
+ }
+
+ /* private: error handling */
+ function halt($msg)
+ {
+ if ($this->Halt_On_Error == 'no')
+ {
+ return;
+ }
+
+ $this->haltmsg($msg);
+
+ if ($this->Halt_On_Error != 'report')
+ {
+ die('Session halted.');
+ }
+ }
+
+ function haltmsg($msg)
+ {
+ printf("Database error: %s
\n", $msg);
+ printf("Oracle Error: %s (%s)
\n",
+ $this->Errno,
+ $this->Error);
+ }
+
+ function table_names()
+ {
+ $this->connect();
+ $this->query('SELECT table_name,tablespace_name FROM user_tables');
+ $i=0;
+ while ($this->next_record())
+ {
+ $info[$i]['table_name'] = $this->Record['table_name'];
+ $info[$R]['tablespace_name'] = $this->Record['tablespace_name'];
+ $i++;
+ }
+ return $info;
+ }
+ }
diff --git a/phpgwapi/inc/class.nextmatchs.inc.php b/phpgwapi/inc/class.nextmatchs.inc.php
index 59eedba2d2..5b84a126d8 100644
--- a/phpgwapi/inc/class.nextmatchs.inc.php
+++ b/phpgwapi/inc/class.nextmatchs.inc.php
@@ -27,208 +27,223 @@
@class nextmatchs
@abstract
*/
- class nextmatchs
- {
- var $maxmatches;
- var $action;
- var $template;
-
- function nextmatchs()
+ class nextmatchs
{
- global $phpgw_info, $menuaction;
+ var $maxmatches;
+ var $action;
+ var $template;
- $this->template = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
- $this->template->set_file(array(
- '_nextmatchs' => 'nextmatchs.tpl'
- ));
- $this->template->set_block('_nextmatchs','nextmatchs');
- $this->template->set_block('_nextmatchs','filter');
- $this->template->set_block('_nextmatchs','form');
- $this->template->set_block('_nextmatchs','icon');
- $this->template->set_block('_nextmatchs','link');
- $this->template->set_block('_nextmatchs','search');
- $this->template->set_block('_nextmatchs','cats');
- $this->template->set_block('_nextmatchs','search_filter');
- $this->template->set_block('_nextmatchs','cats_search_filter');
+ function nextmatchs()
+ {
+ global $phpgw_info, $menuaction;
- if(isset($phpgw_info['user']['preferences']['common']['maxmatchs'])
- && intval($phpgw_info['user']['preferences']['common']['maxmatchs']) > 0)
- {
- $this->maxmatches = intval($phpgw_info['user']['preferences']['common']['maxmatchs']);
- }
- else
- {
- $this->maxmatches = 15;
+ $this->template = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
+ $this->template->set_file(array(
+ '_nextmatchs' => 'nextmatchs.tpl'
+ ));
+ $this->template->set_block('_nextmatchs','nextmatchs');
+ $this->template->set_block('_nextmatchs','filter');
+ $this->template->set_block('_nextmatchs','form');
+ $this->template->set_block('_nextmatchs','icon');
+ $this->template->set_block('_nextmatchs','link');
+ $this->template->set_block('_nextmatchs','search');
+ $this->template->set_block('_nextmatchs','cats');
+ $this->template->set_block('_nextmatchs','search_filter');
+ $this->template->set_block('_nextmatchs','cats_search_filter');
+
+ if(isset($phpgw_info['user']['preferences']['common']['maxmatchs'])
+ && intval($phpgw_info['user']['preferences']['common']['maxmatchs']) > 0)
+ {
+ $this->maxmatches = intval($phpgw_info['user']['preferences']['common']['maxmatchs']);
+ }
+ else
+ {
+ $this->maxmatches = 15;
+ }
+
+ if(isset($menuaction))
+ {
+ $this->action = $menuaction;
+ }
}
- if(isset($menuaction))
+ /*!
+ @function set_icon
+ @abstract ?
+ @param $align ?
+ @param $img_src ?
+ @param $label ?
+ */
+ function set_icon($align,$img,$label)
{
- $this->action = $menuaction;
- }
- }
+ global $phpgw, $phpgw_info;
- /*!
- @function set_icon
- @abstract ?
- @param $align ?
- @param $img_src ?
- @param $label ?
- */
- function set_icon($align,$img,$label)
- {
- global $phpgw, $phpgw_info;
-
- switch(strtolower($phpgw_info['user']['account_lid']))
- {
- case 'ceb':
+ switch(strtolower($phpgw_info['user']['account_lid']))
+ {
+ case 'ceb':
$border = 2;
break;
- default:
+ default:
$border = 0;
break;
+ }
+
+ $var = array(
+ 'align' => $align,
+ 'img' => $phpgw->common->image('phpgwapi',$img),
+ 'label' => lang($label),
+ 'border' => $border
+ );
+ $this->template->set_var($var);
+ return $this->template->fp('out','link');
}
- $var = array(
- 'align' => $align,
- 'img' => $phpgw->common->image('phpgwapi',$img),
- 'label' => lang($label),
- 'border' => $border
- );
- $this->template->set_var($var);
- return $this->template->fp('out','link');
- }
-
- /*!
- @function page
- @abstract ?
- */
- function page($extravars='')
- {
- global $phpgw;
-
- if($extravars && is_string($extravars) && substr($extravars,0,1)!='&')
+ /*!
+ @function page
+ @abstract ?
+ */
+ function page($extravars='')
{
- $extras = '&'.$extravars;
+ global $phpgw;
+
+ if($extravars && is_string($extravars) && substr($extravars,0,1)!='&')
+ {
+ $extras = '&'.$extravars;
+ }
+ elseif($extravars && is_array($extravars))
+ {
+ @reset($extravars);
+ while(list($var,$value) = each($extravars))
+ {
+ $t_extras[] = $var.'='.$value;
+ }
+ $extras = implode($t_extras,'&');
+ }
+
+ return $phpgw->link('/index.php','menuaction='.$this->action.$extras);
}
- elseif($extravars && is_array($extravars))
+
+ /*!
+ @function set_link
+ @abstract ?
+ @param $img_src ?
+ @param $label ?
+ @param $link ?
+ @param $extravars ?
+ */
+ function set_link($align,$img,$link,$alt,$extravars)
{
- @reset($extravars);
+ global $phpgw, $phpgw_info;
+
+ $hidden = '';
while(list($var,$value) = each($extravars))
{
- $t_extras[] = $var.'='.$value;
- }
- $extras = implode($t_extras,'&');
- }
-
- return $phpgw->link('/index.php','menuaction='.$this->action.$extras);
- }
-
- /*!
- @function set_link
- @abstract ?
- @param $img_src ?
- @param $label ?
- @param $link ?
- @param $extravars ?
- */
- function set_link($align,$img,$link,$alt,$extravars)
- {
- global $phpgw, $phpgw_info;
-
- $hidden = '';
- while(list($var,$value) = each($extravars))
- {
- if(((is_int($value) && $value == 0) || $value))
- {
- if(is_int($value))
+ if(((is_int($value) && $value == 0) || $value))
{
- $param = intval($value);
- }
- else
- {
- $param = '"'.$value.'"';
- }
- $hidden .= ' '."\n";
- }
- }
- $border = 0;
- $var = Array(
- 'align' => $align,
- 'action' => ($this->action?$this->page():$phpgw->link($link)),
- 'form_name' => $img,
- 'hidden' => substr($hidden,0,strlen($hidden)-1),
- 'img' => $phpgw->common->image('phpgwapi',$img),
- 'label' => $alt,
- 'border' => $border,
- 'start' => $extravars['start']
- );
- $this->template->set_var($var);
- return $this->template->fp('out','form');
- }
-
- /*!
- @function show_tpl
- @abstract ?
- @param $sn ?
- @param $start ?
- @param $total ?
- @param $extra ?
- @param $twidth ?
- @param $bgtheme ?
- @param $search_obj ?
- @param $filter_obj ?
- @param $showsearch ?
- */
- function show_tpl($sn,$localstart,$total,$extra, $twidth, $bgtheme,$search_obj=0,$filter_obj=1,$showsearch=1,$yours=0,$cat_id=0,$cat_field='fcat_id')
- {
- global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
- $start = $localstart;
-
- $cats = CreateObject('phpgwapi.categories');
-
- $extravars = Array();
- $extravars = $this->split_extras($extravars,$extra);
-
- $var = array(
- 'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
- 'lang_category' => lang('Category'),
- 'lang_all' => lang('All'),
- 'lang_select' => lang('Select'),
- 'cat_field' => $cat_field,
- 'categories' => $cats->formated_list('select','all',$cat_id,'True'),
- 'filter_value' => $filter,
- 'qfield' => $qfield,
- 'start_value' => $start,
- 'order_value' => $order,
- 'sort_value' => $sort,
- 'query_value' => urlencode(stripslashes($query)),
- 'table_width' => $twidth,
- 'th_bg' => $phpgw_info['theme']['th_bg'],
- 'left' => $this->left($sn,$start,$total,$extra),
- 'search' => ($showsearch?$this->search($search_obj):''),
- 'filter' => ($filter_obj?$this->filter($filter_obj,$yours):''),
- 'right' => $this->right($sn,$start,$total,$extra)
- );
- $this->template->set_var($var);
- $this->template->parse('cats','cats');
- $this->template->parse('cats_search_filter_data','cats_search_filter');
- return $this->template->fp('out','nextmatchs');
- }
-
- function split_extras($extravars,$extradata)
- {
- if($extradata)
- {
- if(is_string($extradata))
- {
- $extraparams = explode('&',$extradata);
- $c_extraparams = count($extraparams) + 1;
- for($i=0;$i<$c_extraparams;$i++)
- {
- if($extraparams[$i])
+ if(is_int($value))
+ {
+ $param = intval($value);
+ }
+ else
+ {
+ $param = '"'.$value.'"';
+ }
+ $hidden .= ' '."\n";
+ }
+ }
+ $border = 0;
+ $var = Array(
+ 'align' => $align,
+ 'action' => ($this->action?$this->page():$phpgw->link($link)),
+ 'form_name' => $img,
+ 'hidden' => substr($hidden,0,strlen($hidden)-1),
+ 'img' => $phpgw->common->image('phpgwapi',$img),
+ 'label' => $alt,
+ 'border' => $border,
+ 'start' => $extravars['start']
+ );
+ $this->template->set_var($var);
+ return $this->template->fp('out','form');
+ }
+
+ /*!
+ @function show_tpl
+ @abstract ?
+ @param $sn ?
+ @param $start ?
+ @param $total ?
+ @param $extra ?
+ @param $twidth ?
+ @param $bgtheme ?
+ @param $search_obj ?
+ @param $filter_obj ?
+ @param $showsearch ?
+ */
+ function show_tpl($sn,$localstart,$total,$extra, $twidth, $bgtheme,$search_obj=0,$filter_obj=1,$showsearch=1,$yours=0,$cat_id=0,$cat_field='fcat_id')
+ {
+ global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
+ $start = $localstart;
+
+ $cats = CreateObject('phpgwapi.categories');
+
+ $extravars = Array();
+ $extravars = $this->split_extras($extravars,$extra);
+
+ $var = array(
+ 'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
+ 'lang_category' => lang('Category'),
+ 'lang_all' => lang('All'),
+ 'lang_select' => lang('Select'),
+ 'cat_field' => $cat_field,
+ 'categories' => $cats->formated_list('select','all',$cat_id,'True'),
+ 'filter_value' => $filter,
+ 'qfield' => $qfield,
+ 'start_value' => $start,
+ 'order_value' => $order,
+ 'sort_value' => $sort,
+ 'query_value' => urlencode(stripslashes($query)),
+ 'table_width' => $twidth,
+ 'th_bg' => $phpgw_info['theme']['th_bg'],
+ 'left' => $this->left($sn,$start,$total,$extra),
+ 'search' => ($showsearch?$this->search($search_obj):''),
+ 'filter' => ($filter_obj?$this->filter($filter_obj,$yours):''),
+ 'right' => $this->right($sn,$start,$total,$extra)
+ );
+ $this->template->set_var($var);
+ $this->template->parse('cats','cats');
+ $this->template->parse('cats_search_filter_data','cats_search_filter');
+ return $this->template->fp('out','nextmatchs');
+ }
+
+ function split_extras($extravars,$extradata)
+ {
+ if($extradata)
+ {
+ if(is_string($extradata))
+ {
+ $extraparams = explode('&',$extradata);
+ $c_extraparams = count($extraparams) + 1;
+ for($i=0;$i<$c_extraparams;$i++)
+ {
+ if($extraparams[$i])
+ {
+ list($var,$value) = explode('=',$extraparams[$i]);
+ if($var != 'menuaction')
+ {
+ $extravars[$var] = $value;
+ }
+ else
+ {
+ $this->action = $value;
+ }
+ }
+ }
+ }
+ elseif(is_array($extradata))
+ {
+ while(list($var,$value) = each($extradata))
{
- list($var,$value) = explode('=',$extraparams[$i]);
if($var != 'menuaction')
{
$extravars[$var] = $value;
@@ -240,514 +255,498 @@
}
}
}
- elseif(is_array($extradata))
+ return $extravars;
+ }
+
+ function extras_to_string($extra)
+ {
+ if(is_array($extra))
{
- while(list($var,$value) = each($extradata))
+ @reset($extra);
+ while(list($var,$value) = each($extra))
{
- if($var != 'menuaction')
- {
- $extravars[$var] = $value;
- }
- else
- {
- $this->action = $value;
- }
+ $t_extras[] = $var . '=' . $value;
}
+ $extra_s = '&' . implode('&',$t_extras);
}
- }
- return $extravars;
- }
-
- function extras_to_string($extra)
- {
- if(is_array($extra))
- {
- @reset($extra);
- while(list($var,$value) = each($extra))
- {
- $t_extras[] = $var . '=' . $value;
- }
- $extra_s = '&' . implode('&',$t_extras);
- }
- return $extra_s;
- }
-
- /*!
- @function left
- @abstract ?
- @param $scriptname ?
- @param $start ?
- @param $total ?
- @param $extradate ?
- */
- function left($scriptname,$start,$total,$extradata = '')
- {
- global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
-
- $extravars = Array(
- 'order' => $order,
- 'filter' => $filter,
- 'q_field' => $qfield,
- 'sort' => $sort,
- 'query' => urlencode(stripslashes($query))
- );
-
- $extravars = $this->split_extras($extravars,$extradata);
-
- $ret_str = '';
-
- if (($start != 0)
- && ($start > $this->maxmatches))
- {
- $extravars['start'] = 0;
- $ret_str .= $this->set_link('left','first.gif',$scriptname,lang('First page'),$extravars);
- }
- else
- {
- $ret_str .= $this->set_icon('left','first-grey.gif',lang('First page'));
+ return $extra_s;
}
- if ($start != 0)
+ /*!
+ @function left
+ @abstract ?
+ @param $scriptname ?
+ @param $start ?
+ @param $total ?
+ @param $extradate ?
+ */
+ function left($scriptname,$start,$total,$extradata = '')
{
- // Changing the sorting order screaws up the starting number
- if (($start - $this->maxmatches) < 0)
+ global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
+
+ $extravars = Array(
+ 'order' => $order,
+ 'filter' => $filter,
+ 'q_field' => $qfield,
+ 'sort' => $sort,
+ 'query' => urlencode(stripslashes($query))
+ );
+
+ $extravars = $this->split_extras($extravars,$extradata);
+
+ $ret_str = '';
+
+ if (($start != 0)
+ && ($start > $this->maxmatches))
{
$extravars['start'] = 0;
+ $ret_str .= $this->set_link('left','first.gif',$scriptname,lang('First page'),$extravars);
}
else
{
- $extravars['start'] = ($start - $this->maxmatches);
+ $ret_str .= $this->set_icon('left','first-grey.gif',lang('First page'));
}
- $ret_str .= $this->set_link('left','left.gif',$scriptname,lang('Previous page'),$extravars);
- }
- else
- {
- $ret_str .= $this->set_icon('left','left-grey.gif',lang('Previous page'));
- }
- return $ret_str;
- } /* left() */
- /*!
- @function right
- @abstract ?
- @param $scriptname ?
- @param $start ?
- @param $total ?
- @param $extradate ?
- */
- function right($scriptname,$start,$total,$extradata = '')
- {
- global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
-
- /*
- $extravars = Array();
- if ((isset($order)) && ($order != ''))
- {
- $extravars['order'] = $order;
- }
- if ((isset($filter)) && ($filter != ''))
- {
- $extravars['filter'] = $filter;
- }
- if ((isset($q_field)) && ($q_field != ''))
- {
- $extravars['q_field'] = $qfield;
- }
- if ((isset($sort)) && ($sort != ''))
- {
- $extravars['sort'] = $sort;
- }
- if ((isset($query)) && ($query != ''))
- {
- $extravars['query'] = urlencode(stripslashes($query));
- }
- */
-
- $extravars = Array(
- 'order' => $order,
- 'filter' => $filter,
- 'q_field' => $qfield,
- 'sort' => $sort,
- 'query' => urlencode(stripslashes($query))
- );
-
- $extravars = $this->split_extras($extravars,$extradata);
-
- $ret_str = '';
-
- if (($total > $this->maxmatches)
- && ($total > $start + $this->maxmatches))
- {
- $extravars['start'] = ($start + $this->maxmatches);
- $ret_str .= $this->set_link('right','right.gif',$scriptname,lang('Next page'),$extravars);
- }
- else
- {
- $ret_str .= $this->set_icon('right','right-grey.gif',lang('Next page'));
- }
-
- if (($start != $total - $this->maxmatches)
- && (($total - $this->maxmatches) > ($start + $this->maxmatches)))
- {
- $extravars['start'] = ($total - $this->maxmatches);
- $ret_str .= $this->set_link('right','last.gif',$scriptname,lang('Last page'),$extravars);
- }
- else
- {
- $ret_str .= $this->set_icon('right','last-grey.gif',lang('Last page'));
- }
- return $ret_str;
- } /* right() */
-
- /*!
- @function search_filter
- @abstract ?
- @param $search_obj default 0
- */
- function search_filter($search_obj=0,$filter_obj=1,$yours=0,$link='',$extra='')
- {
- global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
-
- $start = $localstart;
- $var = array(
- 'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
- 'filter_value' => $filter,
- 'qfield' => $qfield,
- 'start_value' => $start,
- 'order_value' => $order,
- 'sort_value' => $sort,
- 'query_value' => urlencode(stripslashes($query)),
- 'th_bg' => $phpgw_info['theme']['th_bg'],
- 'search' => $this->search($search_obj),
- 'filter' => ($filter_obj?$this->filter($filter_obj,$yours):'')
- );
- $this->template->set_var($var);
- return $this->template->fp('out','search_filter');
- }
-
- /*!
- @function cats_search_filter
- @abstract ?
- @param $search_obj default 0
- */
- function cats_search_filter($search_obj=0,$filter_obj=1,$yours=0,$cat_id=0,$cat_field='fcat_id',$link='',$extra='')
- {
- global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
-
- $start = $localstart;
- $cats = CreateObject('phpgwapi.categories');
- $var = array(
- 'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
- 'lang_category' => lang('Category'),
- 'lang_all' => lang('All'),
- 'lang_select' => lang('Select'),
- 'cat_field' => $cat_field,
- 'categories' => $cats->formated_list('select','all',$cat_id,'True'),
- 'filter_value' => $filter,
- 'qfield' => $qfield,
- 'start_value' => $start,
- 'order_value' => $order,
- 'sort_value' => $sort,
- 'query_value' => urlencode(stripslashes($query)),
- 'th_bg' => $phpgw_info['theme']['th_bg'],
- 'search' => $this->search($search_obj),
- 'filter' => ($filter_obj?$this->filter($filter_obj,$yours):'')
- );
- $this->template->set_var($var);
- return $this->template->fp('out','cats_search_filter');
- }
-
- /*!
- @function search
- @abstract ?
- @param $search_obj default 0
- */
- function search($search_obj=0)
- {
- global $query;
-
- $_query = stripslashes($query);
-
- // If the place a " in there search, it will mess everything up
- // Our only option is to remove it
- if (ereg('"',$_query))
- {
- $_query = ereg_replace('"','',$_query);
- }
- $var = array(
- 'query_value' => stripslashes($_query),
- 'searchby' => $this->searchby($search_obj),
- 'lang_search' => lang('Search')
- );
- $this->template->set_var($var);
- return $this->template->fp('out','search');
- } /* search() */
-
- /*!
- @function filterobj
- @abstract ?
- @param $filtertable
- @param $indxfieldname ?
- @param $strfieldname ?
- */
- function filterobj($filtertable, $idxfieldname, $strfieldname)
- {
- global $phpgw;
-
- $filter_obj = array(array('none','show all'));
- $index = 0;
-
- $phpgw->db->query("SELECT $idxfieldname, $strfieldname from $filtertable",__LINE__,__FILE__);
- while($phpgw->db->next_record())
- {
- $index++;
- $filter_obj[$index][0] = $phpgw->db->f($idxfieldname);
- $filter_obj[$index][1] = $phpgw->db->f($strfieldname);
- }
-
- return $filter_obj;
- } /* filterobj() */
-
- /*!
- @function searchby
- @abstract ?
- @param $search_obj ?
- */
- function searchby($search_obj)
- {
- global $qfield, $phpgw, $phpgw_info;
-
- $str = '';
- if (is_array($search_obj))
- {
- $indexlimit = count($search_obj);
- for ($index=0; $index<$indexlimit; $index++)
+ if ($start != 0)
{
- if ($qfield == '')
+ // Changing the sorting order screaws up the starting number
+ if (($start - $this->maxmatches) < 0)
{
- $qfield = $search_obj[$index][0];
- }
- $str .= '';
- }
- $str = '' . "\n";
- }
- return $str;
- } /* searchby() */
-
- /*!
- @function filter
- @abstract ?
- @param $filter_obj
- */
- function filter($filter_obj,$yours=0)
- {
- global $filter, $phpgw, $phpgw_info;
-
- if (is_long($filter_obj))
- {
- if ($filter_obj == 1)
- {
- // $user_groups = $phpgw->accounts->membership($phpgw_info['user']['account_id']);
- $indexlimit = count($user_groups);
-
- if ($yours)
- {
- $filter_obj = array(
- array('none',lang('Show all')),
- array('yours',lang('Only yours')),
- array('private',lang('private'))
- );
+ $extravars['start'] = 0;
}
else
{
- $filter_obj = array(
- array('none',lang('Show all')),
- array('private',lang('private'))
- );
+ $extravars['start'] = ($start - $this->maxmatches);
}
+ $ret_str .= $this->set_link('left','left.gif',$scriptname,lang('Previous page'),$extravars);
+ }
+ else
+ {
+ $ret_str .= $this->set_icon('left','left-grey.gif',lang('Previous page'));
+ }
+ return $ret_str;
+ } /* left() */
+
+ /*!
+ @function right
+ @abstract ?
+ @param $scriptname ?
+ @param $start ?
+ @param $total ?
+ @param $extradate ?
+ */
+ function right($scriptname,$start,$total,$extradata = '')
+ {
+ global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
+
+ /*
+ $extravars = Array();
+ if ((isset($order)) && ($order != ''))
+ {
+ $extravars['order'] = $order;
+ }
+ if ((isset($filter)) && ($filter != ''))
+ {
+ $extravars['filter'] = $filter;
+ }
+ if ((isset($q_field)) && ($q_field != ''))
+ {
+ $extravars['q_field'] = $qfield;
+ }
+ if ((isset($sort)) && ($sort != ''))
+ {
+ $extravars['sort'] = $sort;
+ }
+ if ((isset($query)) && ($query != ''))
+ {
+ $extravars['query'] = urlencode(stripslashes($query));
+ }
+ */
+
+ $extravars = Array(
+ 'order' => $order,
+ 'filter' => $filter,
+ 'q_field' => $qfield,
+ 'sort' => $sort,
+ 'query' => urlencode(stripslashes($query))
+ );
+
+ $extravars = $this->split_extras($extravars,$extradata);
+
+ $ret_str = '';
+
+ if (($total > $this->maxmatches)
+ && ($total > $start + $this->maxmatches))
+ {
+ $extravars['start'] = ($start + $this->maxmatches);
+ $ret_str .= $this->set_link('right','right.gif',$scriptname,lang('Next page'),$extravars);
+ }
+ else
+ {
+ $ret_str .= $this->set_icon('right','right-grey.gif',lang('Next page'));
+ }
+
+ if (($start != $total - $this->maxmatches)
+ && (($total - $this->maxmatches) > ($start + $this->maxmatches)))
+ {
+ $extravars['start'] = ($total - $this->maxmatches);
+ $ret_str .= $this->set_link('right','last.gif',$scriptname,lang('Last page'),$extravars);
+ }
+ else
+ {
+ $ret_str .= $this->set_icon('right','last-grey.gif',lang('Last page'));
+ }
+ return $ret_str;
+ } /* right() */
+
+ /*!
+ @function search_filter
+ @abstract ?
+ @param $search_obj default 0
+ */
+ function search_filter($search_obj=0,$filter_obj=1,$yours=0,$link='',$extra='')
+ {
+ global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
+
+ $start = $localstart;
+ $var = array(
+ 'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
+ 'filter_value' => $filter,
+ 'qfield' => $qfield,
+ 'start_value' => $start,
+ 'order_value' => $order,
+ 'sort_value' => $sort,
+ 'query_value' => urlencode(stripslashes($query)),
+ 'th_bg' => $phpgw_info['theme']['th_bg'],
+ 'search' => $this->search($search_obj),
+ 'filter' => ($filter_obj?$this->filter($filter_obj,$yours):'')
+ );
+ $this->template->set_var($var);
+ return $this->template->fp('out','search_filter');
+ }
+
+ /*!
+ @function cats_search_filter
+ @abstract ?
+ @param $search_obj default 0
+ */
+ function cats_search_filter($search_obj=0,$filter_obj=1,$yours=0,$cat_id=0,$cat_field='fcat_id',$link='',$extra='')
+ {
+ global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
+
+ $start = $localstart;
+ $cats = CreateObject('phpgwapi.categories');
+ $var = array(
+ 'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
+ 'lang_category' => lang('Category'),
+ 'lang_all' => lang('All'),
+ 'lang_select' => lang('Select'),
+ 'cat_field' => $cat_field,
+ 'categories' => $cats->formated_list('select','all',$cat_id,'True'),
+ 'filter_value' => $filter,
+ 'qfield' => $qfield,
+ 'start_value' => $start,
+ 'order_value' => $order,
+ 'sort_value' => $sort,
+ 'query_value' => urlencode(stripslashes($query)),
+ 'th_bg' => $phpgw_info['theme']['th_bg'],
+ 'search' => $this->search($search_obj),
+ 'filter' => ($filter_obj?$this->filter($filter_obj,$yours):'')
+ );
+ $this->template->set_var($var);
+ return $this->template->fp('out','cats_search_filter');
+ }
+
+ /*!
+ @function search
+ @abstract ?
+ @param $search_obj default 0
+ */
+ function search($search_obj=0)
+ {
+ global $query;
+
+ $_query = stripslashes($query);
+
+ // If the place a " in there search, it will mess everything up
+ // Our only option is to remove it
+ if (ereg('"',$_query))
+ {
+ $_query = ereg_replace('"','',$_query);
+ }
+ $var = array(
+ 'query_value' => stripslashes($_query),
+ 'searchby' => $this->searchby($search_obj),
+ 'lang_search' => lang('Search')
+ );
+ $this->template->set_var($var);
+ return $this->template->fp('out','search');
+ } /* search() */
+
+ /*!
+ @function filterobj
+ @abstract ?
+ @param $filtertable
+ @param $indxfieldname ?
+ @param $strfieldname ?
+ */
+ function filterobj($filtertable, $idxfieldname, $strfieldname)
+ {
+ global $phpgw;
+
+ $filter_obj = array(array('none','show all'));
+ $index = 0;
+
+ $phpgw->db->query("SELECT $idxfieldname, $strfieldname from $filtertable",__LINE__,__FILE__);
+ while($phpgw->db->next_record())
+ {
+ $index++;
+ $filter_obj[$index][0] = $phpgw->db->f($idxfieldname);
+ $filter_obj[$index][1] = $phpgw->db->f($strfieldname);
+ }
+
+ return $filter_obj;
+ } /* filterobj() */
+
+ /*!
+ @function searchby
+ @abstract ?
+ @param $search_obj ?
+ */
+ function searchby($search_obj)
+ {
+ global $qfield, $phpgw, $phpgw_info;
+
+ $str = '';
+ if (is_array($search_obj))
+ {
+ $indexlimit = count($search_obj);
for ($index=0; $index<$indexlimit; $index++)
{
- $filter_obj[2+$index][0] = $user_groups[$index]['account_id'];
- $filter_obj[2+$index][1] = 'Group - ' . $user_groups[$index]['account_name'];
+ if ($qfield == '')
+ {
+ $qfield = $search_obj[$index][0];
+ }
+ $str .= '';
}
+ $str = '' . "\n";
}
- }
+ return $str;
+ } /* searchby() */
- if (is_array($filter_obj))
+ /*!
+ @function filter
+ @abstract ?
+ @param $filter_obj
+ */
+ function filter($filter_obj,$yours=0)
{
- $str = '';
+ global $filter, $phpgw, $phpgw_info;
- $indexlimit = count($filter_obj);
-
- for ($index=0; $index<$indexlimit; $index++)
+ if (is_long($filter_obj))
{
- if ($filter == '')
+ if ($filter_obj == 1)
{
- $filter = $filter_obj[$index][0];
+ // $user_groups = $phpgw->accounts->membership($phpgw_info['user']['account_id']);
+ $indexlimit = count($user_groups);
+
+ if ($yours)
+ {
+ $filter_obj = array(
+ array('none',lang('Show all')),
+ array('yours',lang('Only yours')),
+ array('private',lang('private'))
+ );
+ }
+ else
+ {
+ $filter_obj = array(
+ array('none',lang('Show all')),
+ array('private',lang('private'))
+ );
+ }
+ for ($index=0; $index<$indexlimit; $index++)
+ {
+ $filter_obj[2+$index][0] = $user_groups[$index]['account_id'];
+ $filter_obj[2+$index][1] = 'Group - ' . $user_groups[$index]['account_name'];
+ }
}
- $str .= ' '."\n";
}
- $str = ' ';
- $this->template->set_var('select',$str);
- $this->template->set_var('lang_filter',lang('Filter'));
- }
-
- return $this->template->fp('out','filter');
- } /* filter() */
-
- /*!
- @function alternate_row_color
- @abstract alternate row colour
- @param $currentcolor default ''
- */
- function alternate_row_color($currentcolor = '')
- {
- global $phpgw_info;
-
- if (! $currentcolor)
- {
- global $tr_color;
- $currentcolor = $tr_color;
- }
-
- if ($currentcolor == $phpgw_info['theme']['row_on'])
- {
- $tr_color = $phpgw_info['theme']['row_off'];
- }
- else
- {
- $tr_color = $phpgw_info['theme']['row_on'];
- }
-
- return $tr_color;
- }
-
- // If you are using the common bgcolor="{tr_color}"
- // This function is a little cleanier approch
- /*!
- @function template_alternate_row_color
- @abstract ?
- @param $tpl ?
- */
- function template_alternate_row_color(&$tpl)
- {
- $tpl->set_var('tr_color',$this->alternate_row_color());
- }
-
- /*!
- @function show_sort_order
- @abstract ?
- @param $sort ?
- @param $var ?
- @param $order ?
- @param $program ?
- @param $text ?
- @param $extra default ''
- */
- function show_sort_order($sort,$var,$order,$program,$text,$extra='',$build_a_href=True)
- {
- global $phpgw, $filter, $qfield, $start, $query;
-
- if (($order == $var) && ($sort == 'ASC'))
- {
- $sort = 'DESC';
- }
- else if (($order == $var) && ($sort == 'DESC'))
- {
- $sort = 'ASC';
- }
- else
- {
- $sort = 'ASC';
- }
-
- if (is_array($extra))
- {
- $extra = $this->extras_to_string($extra);
- }
-
- $extravar = 'order='.$var.'&sort='.$sort.'&filter='.$filter.'&qfield='.$qfield.'&start='.$start.'&query='.urlencode(stripslashes($query)).$extra;
-
- $link = ($this->action?$this->page($extravar):$phpgw->link($program,$extravar));
-
- if ($build_a_href)
- {
- return '' . $text . '';
- }
- else
- {
- return $link;
- }
- }
-
- /*!
- @function show_sort_order_imap
- @abstract ?
- @param $old_sort : the current sort value
- @param $new_sort : the sort value you want if you click on this
- @param $default_order : user's preference for ordering list items (force this when a new [different] sorting is requested)
- @param $order : the current order (will be flipped if old_sort = new_sort)
- @param $program : script file name
- @param $text : Text the link will show
- @param $extra : any extra stuff you want to pass, url style
- */
- function show_sort_order_imap($old_sort,$new_sort,$default_order,$order,$program,$text,$extra='')
- {
- global $phpgw;
-
- if (is_array($extra))
- {
- $extra = $this->extras_to_string($extra);
- }
- if ($old_sort == $new_sort)
- {
- // alternate order, like on outkrook, click on present sorting reverses order
- if ((int)$order == 1)
+ if (is_array($filter_obj))
{
- $our_order = 0;
+ $str = '';
+
+ $indexlimit = count($filter_obj);
+
+ for ($index=0; $index<$indexlimit; $index++)
+ {
+ if ($filter == '')
+ {
+ $filter = $filter_obj[$index][0];
+ }
+ $str .= ' '."\n";
+ }
+
+ $str = ' ';
+ $this->template->set_var('select',$str);
+ $this->template->set_var('lang_filter',lang('Filter'));
}
- elseif ((int)$order == 0)
+
+ return $this->template->fp('out','filter');
+ } /* filter() */
+
+ /*!
+ @function alternate_row_color
+ @abstract alternate row colour
+ @param $currentcolor default ''
+ */
+ function alternate_row_color($currentcolor = '')
+ {
+ global $phpgw_info;
+
+ if (! $currentcolor)
{
- $our_order = 1;
+ global $tr_color;
+ $currentcolor = $tr_color;
+ }
+
+ if ($currentcolor == $phpgw_info['theme']['row_on'])
+ {
+ $tr_color = $phpgw_info['theme']['row_off'];
}
else
{
- // we should never get here
- $our_order = 1;
+ $tr_color = $phpgw_info['theme']['row_on'];
}
- }
- else
- {
- //user has selected a new sort scheme, reset the order to user's default
- $our_order = $default_order;
- }
-
- $extravar = 'order='.$our_order.'&sort='.$new_sort.$extra;
- $link = ($this->action?$this->page($extravar):$phpgw->link($program,$extravar));
- return '' .$text .'';
- }
+ return $tr_color;
+ }
- function show_hits($total_records='',$start=0)
- {
- if ($total_records > $this->maxmatches)
+ // If you are using the common bgcolor="{tr_color}"
+ // This function is a little cleanier approch
+ /*!
+ @function template_alternate_row_color
+ @abstract ?
+ @param $tpl ?
+ */
+ function template_alternate_row_color(&$tpl)
{
- if ($start + $this->maxmatches > $total_records)
+ $tpl->set_var('tr_color',$this->alternate_row_color());
+ }
+
+ /*!
+ @function show_sort_order
+ @abstract ?
+ @param $sort ?
+ @param $var ?
+ @param $order ?
+ @param $program ?
+ @param $text ?
+ @param $extra default ''
+ */
+ function show_sort_order($sort,$var,$order,$program,$text,$extra='',$build_a_href=True)
+ {
+ global $phpgw, $filter, $qfield, $start, $query;
+
+ if (($order == $var) && ($sort == 'ASC'))
{
- $end = $total_records;
+ $sort = 'DESC';
+ }
+ else if (($order == $var) && ($sort == 'DESC'))
+ {
+ $sort = 'ASC';
}
else
{
- $end = $start + $this->maxmatches;
+ $sort = 'ASC';
+ }
+
+ if (is_array($extra))
+ {
+ $extra = $this->extras_to_string($extra);
+ }
+
+ $extravar = 'order='.$var.'&sort='.$sort.'&filter='.$filter.'&qfield='.$qfield.'&start='.$start.'&query='.urlencode(stripslashes($query)).$extra;
+
+ $link = ($this->action?$this->page($extravar):$phpgw->link($program,$extravar));
+
+ if ($build_a_href)
+ {
+ return '' . $text . '';
+ }
+ else
+ {
+ return $link;
}
- return lang('showing x - x of x',($start + 1),$end,$total_records);
}
- else
+
+ /*!
+ @function show_sort_order_imap
+ @abstract ?
+ @param $old_sort : the current sort value
+ @param $new_sort : the sort value you want if you click on this
+ @param $default_order : user's preference for ordering list items (force this when a new [different] sorting is requested)
+ @param $order : the current order (will be flipped if old_sort = new_sort)
+ @param $program : script file name
+ @param $text : Text the link will show
+ @param $extra : any extra stuff you want to pass, url style
+ */
+ function show_sort_order_imap($old_sort,$new_sort,$default_order,$order,$program,$text,$extra='')
{
- return lang('showing x',$total_records);
+ global $phpgw;
+
+ if (is_array($extra))
+ {
+ $extra = $this->extras_to_string($extra);
+ }
+ if ($old_sort == $new_sort)
+ {
+ // alternate order, like on outkrook, click on present sorting reverses order
+ if ((int)$order == 1)
+ {
+ $our_order = 0;
+ }
+ elseif ((int)$order == 0)
+ {
+ $our_order = 1;
+ }
+ else
+ {
+ // we should never get here
+ $our_order = 1;
+ }
+ }
+ else
+ {
+ //user has selected a new sort scheme, reset the order to user's default
+ $our_order = $default_order;
+ }
+
+ $extravar = 'order='.$our_order.'&sort='.$new_sort.$extra;
+
+ $link = ($this->action?$this->page($extravar):$phpgw->link($program,$extravar));
+ return '' .$text .'';
}
- }
- }
- // End of nextmatchs class
+
+ function show_hits($total_records='',$start=0)
+ {
+ if ($total_records > $this->maxmatches)
+ {
+ if ($start + $this->maxmatches > $total_records)
+ {
+ $end = $total_records;
+ }
+ else
+ {
+ $end = $start + $this->maxmatches;
+ }
+ return lang('showing x - x of x',($start + 1),$end,$total_records);
+ }
+ else
+ {
+ return lang('showing x',$total_records);
+ }
+ }
+ } // End of nextmatchs class
?>