Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-08-2011, 07:23 AM
Starter Member
 
Posts: 3
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..
Reply With Quote
  #2 (permalink)  
Old 06-10-2011, 12:53 AM
Starter Member
 
Posts: 3
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];
}
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.