Page d'assistance 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();
  }
    }
}

À propos du contenu du site Web

 

Toutes les informations contenues dans ce site Web sont uniquement destinées à des fins éducatives. Pour obtenir des conseils, des diagnostics et des traitements médicaux spécifiques, adressez-vous à votre médecin. L'utilisation de ce site est strictement à vos propres risques. Si vous trouvez quelque chose qui, selon vous, nécessite une correction ou une clarification, veuillez nous en faire part à l'adresse suivante : 

Envoyez un courriel : wiki@waihonapedia.org