WaihonaPedia ondersteuningspagina

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();
  }
    }
}

Over de inhoud van de website:

 

Alle informatie die u hier vindt is ter informatie, geen medisch advies! De plaats voor het vinden van specifieke medische adviezen, diagnoses en de behandeling is uw arts. Gebruik van deze site is strikt op eigen risico. Als u vindt dat iets onjuist is, verduidelijking behoeft, verbeterd kan worden, doe dan mee, meld uzelf aan op onze website en stel een verbetering voor. Mocht u dit liever per email doen dan kan dat ook!

Stuur een email: wiki@waihonapedia.org