Commander
Posts: 12
|
Posted: 11/12/2015, 10:08 PM |
|
One of the most basic features of a database editor, is the ability to display a record as either read-only (if the user doesn't have the proper permission), or allow the record to be editable if the user has write permission.
But, I can't figure out how to allow the record page to only be "updatable" if the user is "Admin", but display the record page read-only (without the "submit" and "delete" buttons, and labels to display text fields instead of editable textboxes, ect) if the user is not "Admin".
Is there an easy way to do this (using the app builder wizard), or do I have to spend dozens of hours to learn all the ins and outs of codecharge just to have this basic database UI functionality?
|
|
|
Oper
Posts: 1195
|
Posted: 11/13/2015, 4:25 AM |
|
the Edit Form has a Property for that and Every User has a Group Assigned
something like:
if CCGetGroupID() > 50 then
Form.UpdateAllowed=False
Form.DeleteAllowed=False
Form.InsertAllowed=False
End if
or ccgetuserid()
Beforeshow Page Event.
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
Commander
Posts: 12
|
Posted: 11/14/2015, 2:34 PM |
|
Thanks for the quick response - I'll see if I can get it working :)
|
|
|
Commander
Posts: 12
|
Posted: 11/16/2015, 9:15 PM |
|
Yes that worked!
Thank you.
Basically, I just added these lines in the before show's:
Delete_Beforeshow:
Articles.Button_Delete.visible=false
Update_Beforeshow:
if ccgetgroupid <> 2 then
Articles.Button_Update.visible=false
end if
|
|
|
Oper
Posts: 1195
|
Posted: 11/17/2015, 4:38 AM |
|
If you press enter it will UPDATE
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
Commander
Posts: 12
|
Posted: 11/17/2015, 7:04 AM |
|
I had trouble finding the right place to insert the code, so I did that hack.
But, know we're on the same page and found the right "beforeshow" spot for the page:
if ccgetgroupid <> 2 then
Articles.UpdateAllowed=false
Articles.InsertAllowed=false
end if
Thanks for the warning about the enter key
|
|
|
Oper
Posts: 1195
|
Posted: 11/17/2015, 7:27 AM |
|
Exactly !!
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
eratech
Posts: 513
|
Posted: 11/18/2015, 11:32 PM |
|
@Commander
Or if you check the properties of any Record, the 'Restricted' property - select 'Yes' and the popup will show the Security Groups and Select/Insert/Update/Delete options for each.
Believe it or not, about 80% of the 'basic features of a database editor' are there or already defaulted to useful values.
eg: Record loaded without ID parameter: defaults to Insert mode, sets defaults in fields, shows/hides the relevant buttons.
If the delete function is not allowed for this user or record, it hides the Buttons automatically.
The advantage is, for example, if you add a new security group or change one, you click a few properties and the form regenerates the code. If you hardcode a lot of Visible and InsertAllowed, you have to do those changes yourself.
Honestly: use the designer and Events and let CCS do a lot of the work for you. If you spend a lot of time trying to figure out where to jam in some code you will not get the best out of CCS (been through that with my first ASP.NET project about 10 years ago)
Cheers
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
ccsminer
Posts: 159
|
Posted: 11/30/2015, 7:39 AM |
|
Eric brings up a very valuable point - doing as little hand-coding as possible with CCS to achieve the best results.
CCS is so flexible, that it's tempting to hand-code.
|
|
|
Oper
Posts: 1195
|
Posted: 11/30/2015, 4:51 PM |
|
we went a little deep and use something like that
Res = ValidateSYSSecurity ( 'ResourceName', FormNameHere )
This Function will Disable or Enable every option for every form
if the User was Assigned for this user
we call this Function in every Program/Page
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
ccsminer
Posts: 159
|
Posted: 12/01/2015, 9:04 AM |
|
Quote Oper:
we went a little deep and use something like that
Res = ValidateSYSSecurity ( 'ResourceName', FormNameHere )
This Function will Disable or Enable every option for every form
if the User was Assigned for this user
we call this Function in every Program/Page
What would the equivalent code be if using PHP?
|
|
|
Commander
Posts: 12
|
Posted: 12/14/2015, 5:05 PM |
|
Quote ccsminer:
Eric brings up a very valuable point - doing as little hand-coding as possible with CCS to achieve the best results.
CCS is so flexible, that it's tempting to hand-code.
I'll take your word that that CCS is very flexible, but the problem is that I just need to do one simple project with CCS right now (a KB system). So, I don't have the time to spend days learning all the ins and outs of CCS just to be able to add some minimal functionality to do it the "right way", so I have no choice but to do some brute force (hand-coding) to accomplish this is as little time as possible so I can make a small profit on the project.
Now, I'm trying to replace a Textbox input control from the ASP generated code with a WYSIWYG component from here:
https://www.webwiz.co.uk/web-wiz-rich-text-editor/
And getting nowhere quickly because I don't have the intimate knowledge of CCS to do it the non-code way. Ugh!
|
|
|
Oper
Posts: 1195
|
Posted: 12/14/2015, 5:24 PM |
|
That will be a little tricky and wont get much help here unless there is someone with experience with that Editor
(No that hard but you will need good acknowledge of CCS)
i will advice give a try with FCKEditor or CKeditor depend what version of CCS you are using.
Quote Commander:
Quote ccsminer:
Eric brings up a very valuable point - doing as little hand-coding as possible with CCS to achieve the best results.
CCS is so flexible, that it's tempting to hand-code.
I'll take your word that that CCS is very flexible, but the problem is that I just need to do one simple project with CCS right now (a KB system). So, I don't have the time to spend days learning all the ins and outs of CCS just to be able to add some minimal functionality to do it the "right way", so I have no choice but to do some brute force (hand-coding) to accomplish this is as little time as possible so I can make a small profit on the project.
Now, I'm trying to replace a Textbox input control from the ASP generated code with a WYSIWYG component from here:
https://www.webwiz.co.uk/web-wiz-rich-text-editor/
And getting nowhere quickly because I don't have the intimate knowledge of CCS to do it the non-code way. Ugh!
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
Commander
Posts: 12
|
Posted: 12/14/2015, 6:24 PM |
|
Interesting...I have CCS5, which editor would work for it? Is there any documentation on how to integrate it into a CCS5 project?
|
|
|
eratech
Posts: 513
|
Posted: 12/15/2015, 3:11 AM |
|
Hi Commander
CCS 5 has a button for attaching CKEditor to a text area but I think you need to download CKEditor (FCKEditor was discontinued some time ago I think) and put it in your CCS Project (like a subfolder) and you can set the parameters when setting up CKEditor.
You might need to manually publish the CKEditor files, but the button (Forms > Advanced> Add CKEditor) will set up the javascript and parameters. You can also add extra settings and parameters if you wanted to customise the toolbar beyond the defaults.
Documentation - the age old 'read the help file' has most of what you need (search for 'ckeditor' and ignore the FCKEditor stuff)
Online help and downloadable Windows Help file (CHM format) are here: http://support.yessoftware.com/tutorials.asp
Cheers
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
Commander
Posts: 12
|
Posted: 12/16/2015, 7:40 AM |
|
Thanks for that info - that was VERY helpful!
I ended up using the ckeditor - it wasn't too painful and I am very grateful for the built-in support of it in CCS5 :)
So obviously I needed to have the ckeditor be read only when the user is not an admin, so I added this to the record_edit before_show form event:
' -------------------------
' Write your own code here.
' -------------------------
Articles.DeleteAllowed=false
if ccgetgroupid <> 2 then
Articles.UpdateAllowed=false
Articles.InsertAllowed=false
end if
HTMLTemplate.SetVar "@ccgetgroupid", ccgetgroupid
'End Custom Code
Then in the client code, I also wanted to hide the toolbar if the user is not admin, but also hide some buttons even if the user is an admin:
editor = CKEDITOR.replace(id, {
height: "300",
width: "800",
toolbar: "Basic"
});
editor.config.toolbarGroups = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'forms', groups: [ 'forms' ] },
'/',
{ name: 'links', groups: [ 'links' ] },
{ name: 'insert', groups: [ 'insert' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
'/',
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'colors', groups: [ 'colors' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'others', groups: [ 'others' ] },
{ name: 'about', groups: [ 'about' ] }
];
var secid = {ccgetgroupid}
if (secid == 1)
{
editor.config.removeButtons = 'Source,ShowBlocks,About,Maximize,Save,NewPage,Preview,Print,Templates,Form,Radio,Checkbox,TextField,Textarea,Select,Button,ImageButton,HiddenField,Language';
editor.config.readOnly = true;
editor.config.toolbarCanCollapse = true;
editor.config.toolbarStartupExpanded= false;
}
else
{
editor.config.removeButtons = 'About,Maximize,ShowBlocks,Save,NewPage,Preview,Print,Templates,Form,Radio,Checkbox,TextField,Textarea,Select,Button,ImageButton,HiddenField,Language';
editor.config.readOnly = false;
editor.config.toolbarCanCollapse = false;
editor.config.toolbarStartupExpanded= true;
};
|
|
|
eratech
Posts: 513
|
Posted: 12/21/2015, 7:17 PM |
|
@Commander - glad it worked and thanks for providing the code for anyone else having the problem, especially the read only options.
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
|