Class-
public with sharing class ReadingPermissionController {
public ReadingPermission__c newReadingPermission {get;set;}
public String returnUrl {get;set;}
public ReadingPermissionController(ApexPages.StandardController setCon) {
ReadingPermission__c r = (ReadingPermission__c) setCon.getRecord();
newReadingPermission = new ReadingPermission__c();
if(r.Id != null) {
newReadingPermission = [Select Id, Name, Permission_Holder_Name__c, Permission_Holder_ID__c, Permission_Holder_Type__c, Granted_Permissions__c from ReadingPermission__c where id =: r.Id];
}
//system.assert(false, newReadingPermission );
returnUrl = apexpages.currentPage().getParameters().get('retURL');
}
public List getReviewerList() {
List options = new List();
options.add(new SelectOption('' , '--None--'));
List users = [Select Id, name from user where profileId in: OnlineReadingBaseClass.getOnlineReadingProfileIds()];
for(User u : users) {
options.add(new SelectOption(u.Id, u.Name));
}
return options;
}
public List getQueueList() {
List sOptions = new List();
List groupList = [select Id, name from Group where type = 'Queue'];
sOptions.add(new SelectOption('' , '--None--'));
for(Group g : groupList) {
sOptions.add(new SelectOption(g.Id , g.Name));
}
return sOptions;
}
public List getGroupList() {
List sOptions = new List();
List groupList = [select Id, name from Group where type = 'Regular'];
sOptions.add(new SelectOption('' , '--None--'));
for(Group g : groupList) {
sOptions.add(new SelectOption(g.Id , g.Name));
}
return sOptions;
}
public PageReference save() {
PageReference pag = null;
try {
upsert newReadingPermission;
pag = new PageReference(returnUrl);
} catch(Exception e) {
ApexPages.addMessages(e);
}
return pag;
}
public PageReference saveAndNew() {
PageReference pag = null;
try {
upsert newReadingPermission;
newReadingPermission = new ReadingPermission__c();
} catch(Exception e) {
ApexPages.addMessages(e);
}
return pag;
}
public PageReference cancel() {
return new PageReference(returnUrl);
}
}