[dev] Turba and IMSP patch

Michael Rubinsky mike at theupstairsroom.com
Tue Oct 26 14:38:43 PDT 2004


Sorry about that, not sure what happened...here they are again.



--On Monday, October 25, 2004 7:50 PM -0700 dev-request at lists.horde.org 
wrote:

> Date: Tue, 26 Oct 2004 00:13:12 +0200
> From: Jan Schneider <jan at horde.org>
> Subject: Re: [dev] Turba and IMSP patch
> To: dev at lists.horde.org
> Message-ID: <20041026001312.d8y5291zmsss0os4 at jan.dip.ammma.net>
> Content-Type: text/plain;        charset=ISO-8859-15; 
format="flowed"
>
> Zitat von Michael Rubinsky <mike at theupstairsroom.com>:
>
> > The following (finally) patches the Net_IMSP framework package and the
> > Turba imsp driver for the following:
>
> Looks like your patches are broken, they contain not a single newline.
>
> Jan.
>
>




Thanks -
Mike 
-------------- next part --------------
Index: IMSP/Book.php===================================================================RCS file: /repository/framework/Net_IMSP/IMSP/Book.php,vretrieving revision 1.14diff -r1.14 Book.php159,160c159,160<      * @param string $search Search criteria (may include * wild card).<      * @param optional string  $search_field Name of IMSP field to search on.--->      * @param string Array $search Search criteria in the form of>      *        'fieldName' => 'searchTerm' (may include * wild card).163,164c163,172<     function search($abook, $search, $search_field = 'name')<     {--->     function search($abook, $search)>     {   >         //If no field => value pairs, assume we are searching name.>         $criteria = array();>         if (!is_array($search)) {>             $criteria['name'] = $search;>         } else {>             $criteria = $search;>         }> 186c194,195<         $result = $this->_imsp->imspSend("$abook $search_field ",false,false);--->         //Start parsing the search array.>         $result = $this->_imsp->imspSend("$abook", false, false);190,195c199,203< <         // How about the search term as a {}.<         if (preg_match(IMSP_MUST_USE_LITERAL, $search)){<             $biSearch = sprintf("{%d}",strlen($search));< <             $result = $this->_imsp->imspSend($biSearch,false,true);--->         >         $count = count($criteria);>         $current = 1;>         foreach ($criteria as $search_field => $search){>             $result = $this->_imsp->imspSend(" $search_field ",false,false);200,214c208,235<             if (!preg_match(IMSP_COMMAND_CONTINUATION_RESPONSE<                             , $this->_imsp->imspReceive())) {< <                 return $this->_imsp->imspError(IMSP_NO_CONTINUATION_RESPONSE,<                                                __FILE__,__LINE__);<             }< <            $result = $this->_imsp->imspSend($search,false,true);<            if (is_a($result, 'PEAR_Error')) {<                return $result;<            }<         } else {<             $result = $this->_imsp->imspSend('"' . $search . '"',false,true);<             if (is_a($result, 'PEAR_Error')) {<                 return $result;--->             // How about the search term as a {}.>             if (preg_match(IMSP_MUST_USE_LITERAL, $search)){>                 $biSearch = sprintf("{%d}",strlen($search));>     >                 $result = $this->_imsp->imspSend($biSearch,false,true);>                 if (is_a($result, 'PEAR_Error')) {>                     return $result;>                 }>     >                 if (!preg_match(IMSP_COMMAND_CONTINUATION_RESPONSE>                                 , $this->_imsp->imspReceive())) {>     >                     return $this->_imsp->imspError(IMSP_NO_CONTINUATION_RESPONSE,>                                                    __FILE__,__LINE__);>                 }>     >                $result = $this->_imsp->imspSend($search,false,$current == $count);>                $current++;>                if (is_a($result, 'PEAR_Error')) {>                    return $result;>                }>             } else {>                 //Only send the CrLf if this is the last field/search atom..>                 $result = $this->_imsp->imspSend('"' . $search . '"', false, $current == $count);>                 $current++;>                 if (is_a($result, 'PEAR_Error')) {>                     return $result;>                 }217a239>         //Get the response
-------------- next part --------------
Index: config/sources.php.dist===================================================================RCS file: /repository/turba/config/sources.php.dist,vretrieving revision 1.93diff -r1.93 sources.php.dist433a434,439>  * >  * If you wish to keep track of ownership of individual contacts, set>  * 'contact_ownership' = true.  Note that entries created using other clients>  * will not be created this way and will therefore have no 'owner'.>  * Set 'contact_ownership' = false and the __owner field will be >  * automatically populated with the current username.435d440< 458c463,464<         'group_id_value' => 'group'--->         'group_id_value' => 'group',> 	    'contact_ownership' => false463a470>         '__owner' => '__owner',472c479,480<         'cellPhone' => 'cellphone'--->         'cellPhone' => 'cellphone',>         'freebusyUrl' => 'freebusyUrl'Index: lib/Driver/imsp.php===================================================================RCS file: /repository/turba/lib/Driver/imsp.php,vretrieving revision 1.18diff -r1.18 imsp.php98c98,102<     {--->     {   >         $query = array();>         $results = array();>         $hasName = false;>         104d107<         $results = array();108,114c111,119<         $temp = array_values($criteria);<         if (count($criteria)) {<             $searchField = $temp[0][0]['field'];<             $searchValue = $temp[0][0]['test'];<         } else {<             $searchField = 'name';<             $searchValue = '';--->         $imspSearch = array();>         if (count($criteria)){>             foreach($criteria as $key => $vals){>                 if (strval($key) == 'OR') {>                     //Don't support OR yet>                 } elseif (strval($key) == 'AND') {>                    $query = $this->_getSearch($vals);>                 }>             }117,132c122,136<         /* Make sure the searchvalue isn't FullName, since fullname is<          * created dynamically. */<         if ($searchField == 'fullname') {<             $searchField = 'name';<         }< <         /**<          * Are we searching for only Turba_Groups or Turba_Objects?<          * This is needed so the 'Show Lists' and 'Show Contacts' links<          * work correctly in Turba.<          */<         if ($searchField == '__type') {<             switch ($searchValue) {<             case 'Group':<                 $searchField = $this->_groupField;<                 $searchValue = $this->_groupValue;--->         for ($current = 0; $current < count($query); $current++) {>             $temp = $query[$current];>             $searchkey = $temp['field'];>             $searchval = $temp['test'];>             $searchop = $temp['op'];> >             //Now make sure we aren't searching on a dynamically created field>             switch ($searchkey){>             case 'fullname':>                 if (!$hasName){>                     $searchkey = 'name';>                     $hasName = true;>                 } else {>                     $searchkey = '';>                 }134,137c138,142<             case 'Object':<                 $searchField = 'name';<                 $searchValue = '';<                 $noGroups = true;--->                 >             case '__owner':>                 if (!$this->params['contact_ownership']){>                     continue 2;>                 }140d144<         }142,147c146,168<         /* If there is no searchValue than only use the wildcard. */<         if (strlen($searchValue) > 0 ) {<             $searchValue = '*' . $searchValue . '*';<         } else {<             $searchValue = '*';<         }--->             /**>              * Are we searching for only Turba_Groups or Turba_Objects?>              * This is needed so the 'Show Lists' and 'Show Contacts' links>              * work correctly in Turba.>              */>             if ($searchkey == '__type') {>                 switch ($searchval) {>                 case 'Group':>                     $searchkey = $this->_groupField;>                     $searchval = $this->_groupValue;>                     break;>                 case 'Object':>                     if (!$hasName){>                         $searchkey = 'name';>                         $searchval = '';>                         $hasName = true;>                     } else {>                         $searchkey = '';>                     }>                     $noGroups = true;>                     break;>                 }>             }149,150c170,187<         $names = $this->_imsp->search($this->_bookName, $searchValue,<                                       $searchField);--->             if (!$searchkey == ''){>                 //Check the searchval for content and for strict matches.>                 if (strlen($searchval) > 0 ) {>                     if ($searchop == 'LIKE'){ >                         $searchval = '*' . $searchval . '*';>                     }>                 } else {>                     $searchval = '*';>                 }>                 $imspSearch[$searchkey] = $searchval;>             }>         }>         if (!count($imspSearch)) {>             $imspSearch['name'] = '*';>         }>  >         //Finally get to the command.>         $names = $this->_imsp->search($this->_bookName, $imspSearch);158a196> 193a232>         $result = array();201c240,243< --->                 if (!isset($temp['__owner'])) {>                     $temp['__owner'] = Auth::getAuth();>                 }>                 244a287> 281d323< 284a327,329>         if (!$this->params['contact_ownership']){>             unset($attributes['__owner']);>         }301c346<      * @param string $object_id   (Ignored) the value of the key field.--->      * @param string $object_id   The value of the key field.347a393,430>     >     /**>      * Get the search criteria.>      * >      * @param $attributes array containing the turba search attribtes.>      * @return array containing arrays of search criteria.>      */>      function _getSearch($attributes){>          $search = array();>          foreach ($attributes as $key=>$values) {>              if (!empty($values['OR'])) {>                  //Not supported yet.>              } elseif (!empty($values['AND'])) {>                  $temp = $this->_getSearch($values);>                  for ($i=0; $i<count($temp); $i++) {>                      $search[] = $temp[$i];>                  }>              } else {>                  if (isset($values['field'])){>                      $search[] = $values;>                  } else {>                      foreach ($values as $test) {>                          if (!empty($test['OR'])) {>                              //not supported yet>                          } elseif (!empty($test['AND'])) {>                              $temp = $this->_getSearch($test);>                              for ($i=0; $i<count($temp); $i++){>                                  $search[] = $temp[$i];>                              }>                          } else {>                              $search[] = $test;>                          }>                      }>                  }>              }>          }>          return $search;>      }


More information about the dev mailing list