Supportseite WaihonaPedia

WelcomeScreenGroovy


import java.util.Collection;
import java.util.Iterator;
import org.apache.commons.lang.StringUtils;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.XWikiException;
import org.slf4j.LoggerFactory;

public class WelcomeScreen {
    def xwiki;
    def context;
    def LOGGER = LoggerFactory.getLogger("WelcomeScreen");

 /

  • Fonction qui initialise le traitement de la class
     *
  • @param initContext com.xpn.xwiki.XWikiContext
  • @param initXWiki com.xpn.xwiki.api.XWiki
  • @author Taleb Mohamed
     */
        public setXWiki(xwiki, context) {
          this.xwiki = xwiki;
          this.context = context;
        }

     public String getMailWelcomeScreen(String country, String language){
      String mail;
      try {
        mail = getMailModerator(country,language);
        if(mail !="") return mail;
        mail = getMailSupportGroup(country,language);
        if(mail !="") return mail;
        mail = getMailGlobalModerator(country,language);
        if(mail !="") return mail;
        return xwiki.getXWikiPreference('admin_email');
      }
      catch (XWikiException e) {
       e.printStackTrace();
      }   
     } 

    public def getMailModerator (String country) {
   String countryQuery;
  try {  
   countryQuery =  "select propMailUser.value from BaseObject objUser, StringProperty propMailUser, StringProperty propCountryUser , BaseObject objGroup, StringProperty propMember where "  +
       "objUser.className='XWiki.XWikiUsers' and  " +
       "propMailUser.id.id=objUser.id and propMailUser.name='email' and  " +
       "propCountryUser.id.id=objUser.id and propCountryUser.name='country'  and propCountryUser.value = '"+country+"' and " +
       "objGroup.className='XWiki.XWikiGroups' and " +
       "propMember.id.id=objGroup.id and objGroup.name = 'XWiki.Moderator' and propMember.name='member' and propMember.value = objUser.name ";
   List result = xwiki.search(countryQuery);
   if(result.size()>0) return result.get(0);
   return "";
  }
  catch (XWikiException e) {
   e.printStackTrace();
  }
    }

 public def getMailModerator (String country, String language) {
  String countryQuery;  
  try {  
   countryQuery =  "select propMailUser.value from BaseObject objUser, StringProperty propMailUser, StringProperty propCountryUser , StringProperty propDefaultLanguageUser, BaseObject objGroup, StringProperty propMember where "  +
       "objUser.className='XWiki.XWikiUsers' and  " +
       "propMailUser.id.id=objUser.id and propMailUser.name='email' and  " +
       "propCountryUser.id.id=objUser.id and propCountryUser.name='country'  and propCountryUser.value = '"+country+"' and " +
       "propDefaultLanguageUser.id.id=objUser.id and propDefaultLanguageUser.name='default_language'  and propDefaultLanguageUser.value = '"+language+"' and " +
       "objGroup.className='XWiki.XWikiGroups' and " +
       "propMember.id.id=objGroup.id and objGroup.name = 'XWiki.Moderator' and propMember.name='member' and propMember.value = objUser.name ";
   List result = xwiki.search(countryQuery);
   if(result.size()>0) return result.get(0);
  return getMailModerator (country);
   return "";
  }
  catch (XWikiException e) {
   e.printStackTrace();
  }
    }

 public def getMailGlobalModerator (String country) {
   String countryQuery;
  try {  
   countryQuery =  "select propMailUser.value from BaseObject objUser, StringProperty propMailUser, StringProperty propCountryUser , BaseObject objGroup, StringProperty propMember where "  +
       "objUser.className='XWiki.XWikiUsers' and  " +
       "propMailUser.id.id=objUser.id and propMailUser.name='email' and  " +
       "propCountryUser.id.id=objUser.id and propCountryUser.name='country'  and propCountryUser.value = '"+country+"' and " +
       "objGroup.className='XWiki.XWikiGroups' and " +
       "propMember.id.id=objGroup.id and objGroup.name = 'XWiki.GlobalModerator' and propMember.name='member' and propMember.value = objUser.name ";
   List result = xwiki.search(countryQuery);
   if(result.size()>0) return result.get(0);
   return "";
  }
  catch (XWikiException e) {
   e.printStackTrace();
  }
    }

 public def getMailGlobalModerator (String country, String language) {
   String countryQuery;
  try {  
   countryQuery =  "select propMailUser.value from BaseObject objUser, StringProperty propMailUser, StringProperty propCountryUser , StringProperty propDefaultLanguageUser, BaseObject objGroup, StringProperty propMember where "  +
       "objUser.className='XWiki.XWikiUsers' and  " +
       "propMailUser.id.id=objUser.id and propMailUser.name='email' and  " +
       "propCountryUser.id.id=objUser.id and propCountryUser.name='country'  and propCountryUser.value = '"+country+"' and " +
       "propDefaultLanguageUser.id.id=objUser.id and propDefaultLanguageUser.name='default_language'  and propDefaultLanguageUser.value = '"+language+"' and " +
       "objGroup.className='XWiki.XWikiGroups' and " +
       "propMember.id.id=objGroup.id and objGroup.name = 'XWiki.GlobalModerator' and propMember.name='member' and propMember.value = objUser.name ";
   List result = xwiki.search(countryQuery);
   if(result.size()>0) return result.get(0);
   
return getMailGlobalModerator (country);
   return "";
  }
  catch (XWikiException e) {
   e.printStackTrace();
  }
    }

 public def getMailSupportGroup(String country) {
   String countryQuery;
  try {  
   countryQuery = "select propContactEmail.value from XWikiDocument doc, BaseObject obj, StringProperty propCountry, StringProperty propContactEmail where  doc.fullName=obj.name and "+
    "obj.className='WaihonaCode.supportGroupClass' and "+
    "obj.name<>'WaihonaCode.supportGroupClassTemplate' and "+      
    "propContactEmail.id = obj.id.id and "+
    "propContactEmail.name = 'contactEmail' and "+
    "propCountry.id = obj.id.id and propCountry.name = 'countryCode' and propCountry.value = '"+country+"'";
   List result = xwiki.search(countryQuery);
   if(result.size()>0) return result.get(0);
   return "";
  }
  catch (XWikiException e) {
   e.printStackTrace();
  }
    } 

 public def getMailSupportGroup(String country, String language) {
   String countryQuery;
  try {  
   countryQuery = "select propContactEmail.value from XWikiDocument doc, BaseObject obj, StringProperty propCountry, StringProperty propContactEmail, StringProperty propLanguage where  doc.fullName=obj.name and "+
    "obj.className='WaihonaCode.supportGroupClass' and " +
    "obj.name<>'WaihonaCode.supportGroupClassTemplate' and " +      
    "propContactEmail.id = obj.id.id and " +
    "propContactEmail.name = 'contactEmail' and " +
    "propLanguage.id = obj.id.id and propLanguage.name = 'language' and propLanguage.value like '%"+language+"%' and " +
    "propCountry.id = obj.id.id and propCountry.name = 'countryCode' and propCountry.value = '"+country+"'";
   List result = xwiki.search(countryQuery);
   if(result.size()>0) return result.get(0);
  return getMailSupportGroup(country);
   return "";
  }
  catch (XWikiException e) {
   e.printStackTrace();
  }
    }
}

Über den Inhalt der Website

 

Alle Informationen auf dieser WebSite dienen ausschließlich der Aufklärung. Der richtige Ort, um spezifischen medizinischen Rat, Diagnosen und Behandlungen zu erhalten, ist Ihr Arzt. Die Nutzung dieser Website erfolgt ausschließlich auf eigene Gefahr. Wenn Sie etwas finden, das Ihrer Meinung nach einer Korrektur oder Klärung bedarf, lassen Sie es uns bitte wissen: 

Senden Sie eine E-Mail: wiki@waihonapedia.org