Results 1 to 2 of 2

Thread: [SOLVED] Run search method

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    4

    Default [SOLVED] Run search method

    Hello,
    is there a way to run search in Ajax view from URL GET params?

    Or maybe is there a way to run search from Zimlet?
    Last edited by mich.buk; 06-09-2011 at 02:25 AM.

  2. #2
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    4

    Default

    OK i found an answer. I wrote simple zimlet:

    Code:
    /**
     * SIMLE USAGE
     * open zimbra page with URL: "http://your_zimbra_domain.com/zimbra/?Search=example_query"
     */
    
    
    function com_zimbra_search_msg_HandlerObject() {
    }
    
    com_zimbra_search_msg_HandlerObject.prototype = new ZmZimletBase();
    com_zimbra_search_msg_HandlerObject.prototype.constructor = com_zimbra_search_msg_HandlerObject;
    
    com_zimbra_search_msg_HandlerObject.prototype.init = function() {
    	this._simpleAppName = this.createApp("Search mail", "zimbraIcon", "Search mail");
    
    };
    
    var old_createApp = com_zimbra_search_msg_HandlerObject.prototype.createApp;
    
    com_zimbra_search_msg_HandlerObject.prototype.createApp = function(label, image, tooltip) {
      //old_createApp(label, image, tooltip);
      
      // looking in GET string 'Search' if founded search messages
      if(window.location.href.indexOf('Search') > -1) {
        this.findMessages(getFromGET('Search'));
      }
    };
    
    com_zimbra_search_msg_HandlerObject.prototype.findMessages = function(query) {
      var _types = new AjxVector();
      _types.add("CONV");
    
      var search_messages_callback = new AjxCallback(this, this._search_messages_handler);
      
      appCtxt.getSearchController().search({
        query:      query,
        userText:   false,
        limit:      9999,
        types:      _types,
        noRender:   true,
        callback:   search_messages_callback
      });
    };
    
    com_zimbra_search_msg_HandlerObject.prototype._search_messages_handler = function(result) {
      var searchResult = result.getResponse();  
      var items = searchResult.getResults(ZmItem.CONV);
       
      var controller = appCtxt.getCurrentController();
      controller.show(searchResult);
      
      return 1;
    };
    
    function getFromGET(name) {
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href );
      if( results == null )
        return "";
      else
        return results[1];
    }

Similar Threads

  1. Replies: 0
    Last Post: 05-30-2011, 05:26 PM
  2. Enhance Zimbra search to search local files
    By krabina in forum Developers
    Replies: 0
    Last Post: 11-03-2010, 02:28 PM
  3. No response from Jetty on clean 5.02 OS install
    By cniknet in forum Administrators
    Replies: 0
    Last Post: 02-16-2008, 11:17 AM
  4. Search within search
    By zocs in forum Users
    Replies: 0
    Last Post: 12-24-2007, 01:09 AM
  5. Replies: 13
    Last Post: 08-22-2007, 01:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •