kpammi

UserHandler

Aug 30th, 2016
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class UserHandler implements ITrigger{
  2.     public UserHandler() {}
  3.     public void bulkBefore() {}
  4.     public void bulkAfter(){}
  5.     public void beforeInsert(SObject so) {
  6.         User beforeInsertUser = (User) so;
  7.         System.debug('User Trigger ==> Before insert: User Profile Id= '+beforeInsertUser);
  8.         if(beforeInsertUser.ProfileId == '00e80000001KWWa'){
  9.             //Set the profile picture to public.
  10.             System.debug('Setting UserPreferencesShowProfilePicToGuestUsers');
  11.             beforeInsertUser.UserPreferencesShowProfilePicToGuestUsers = true;
  12.         }
  13.     }
  14.     public void beforeUpdate(SObject oldSo, SObject so){}
  15.     public void beforeDelete(SObject so){}
  16.     public void afterInsert(SObject so){
  17.         User afterInsertUser = (User) so;
  18.         System.debug('User Trigger ==> After insert');
  19.         System.debug('User = '+afterInsertUser);
  20.         if(afterInsertUser.ProfileId == '00e80000001KWWa'){
  21.             //Set the Profile Picture
  22.             System.debug('Setting Profile Picture');
  23.             ConnectApi.Photo cc = ConnectApi.UserProfiles.setPhoto('0DB80000000CdzgGAC', afterInsertUser.Id, '0698A00000014YA', null);
  24.         }
  25.     }
  26.     public void afterUpdate(SObject oldSo, SObject so){}
  27.     public void afterDelete(SObject so){}
  28.     public void andFinally(){}
  29. }
RAW Paste Data