コード例 #1
0
  /**
   * Set the value of a boolean field in a document.
   *
   * @param doc the document to modify.
   * @param fieldName the name of the field.
   * @param value the value.
   * @return true if <code>doc</code> modified.
   */
  protected boolean updateDocBooleanValue(XWikiDocument doc, String fieldName, Boolean value) {
    boolean needsUpdate = false;

    int intvalue = intFromBoolean(value);

    if (intvalue != doc.getIntValue(getClassFullName(), fieldName)) {
      doc.setIntValue(getClassFullName(), fieldName, intvalue);
      needsUpdate = true;
    }

    return needsUpdate;
  }
コード例 #2
0
 // Copy & Paste and customise from bugged method in XWiki class.
 private int checkActive(String user, XWikiContext context) throws XWikiException {
   int active = 1;
   // These users are necessarly active
   if (user.equals(XWikiRightService.GUEST_USER_FULLNAME)
       || (user.equals(XWikiRightService.SUPERADMIN_USER_FULLNAME))) {
     return active;
   }
   String checkactivefield = context.getWiki().getXWikiPreference("auth_active_check", context);
   if (checkactivefield.equals("1")) {
     XWikiDocument userdoc = context.getWiki().getDocument(user, context);
     active = userdoc.getIntValue("XWiki.XWikiUsers", "active");
   } else {
     mLogger.warn(
         "XWikiPreferences field auth_active_check != 1 which means all users"
             + "are always handled as active");
   }
   return active;
 }