[Tutos-commits] tutos/php appointment.pinc,1.235,1.236
Projects / CRM / PLM / Calendar / Tasks / SCRUM / Test / Inventory
Brought to you by:
gokohnert
From: Gero K. <gok...@us...> - 2010-11-29 08:12:23
|
Update of /cvsroot/tutos/tutos/php In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv27966/php Modified Files: appointment.pinc Log Message: added search by name Index: appointment.pinc =================================================================== RCS file: /cvsroot/tutos/tutos/php/appointment.pinc,v retrieving revision 1.235 retrieving revision 1.236 diff -u -d -r1.235 -r1.236 --- appointment.pinc 4 Aug 2010 09:07:48 -0000 1.235 +++ appointment.pinc 29 Nov 2010 08:12:15 -0000 1.236 @@ -534,6 +534,51 @@ } /** + * search for a appointment + * fill a array with possible appointments + * mode 1 fill objects + * mode 0 do not fill objects + */ + function search_by_name(&$arr,&$user,$name,$mode = 1) { + global $table; + + if ( trim($name) == "" ) return 0; + + // search for a given object ID + $qx = ''; + $qpre = ' WHERE'; + if (preg_match('/#([0-9]*)/',trim($name),$regs)) { + if(is_numeric($regs[1])) { + $qx = ' where id = '.$regs[1]; + } + } else { + $qx = ' where '.$user->dbconn->Like("description",$name); + } + $q = "SELECT ".($mode == 1 ? '*':'id')." from ". $user->dbconn->prefix .$table['appointment1'][name]; + $q .= $qx; + $q .= " order by description "; + + check_dbacl($user->dbconn, $q, $user->id); + $r = $user->dbconn->Exec($q); + $n = $r->numrows(); + $a = 0; + while ( $a < $n ) { + if ($mode == 1) { + $x = new appointment($user->dbconn); + $x->read_result($r,$a); + $arr[$x->id] = &$x; + unset($x); + } else { + $id = $r->get($a,'id'); + $arr[$id] = $id; + } + $a++; + } + $r->free(); + return $n; + } + + /** * fill the internal neighbour list with possible objects where a object * currently attached/referencing to THIS could be reattached */ |