Hi Ross,
I observed that staff users can only be added as teachers or support staff. I think this does not represent a true school scenario. There are laboratory attendants, secretaries, account staff, exam officers, ICT staff, etc. Now, I want to hack the gibbon core thus:
I will alter the table “gibbonstaff”, set “type” to enum(‘Teaching’, ‘Support’, ‘Any other’). Now, this how i will do it, I will edit the file that adds new role types to automatically make the adjustment on gibbonstaff when a new staff user role is added.
But I want to find out from you if the newly added staff type will reflect in every other part of the system where registered staff are needed. For example, in the Departments section, in the class section, and others.
Daniel,
What you are trying to do does already exist in Gibbon, and is called Roles. There are 4 Role Categories (Staff, Student, Parent, Other), and within these you can have as many roles as you like (e.g. Exam Officer, as you suggested above).
Take a look at Admin > User Admin in the main menu, and then Manage Roles in the right hand menu. You can add roles (or duplicate existing roles), and then assign permissions to the role, before finally assigning the role to users.
Hope this helps,
Ross
Thanks Ross,
I am aware of the feature you just mentioned. What I am saying is this: if you go to Admin > User Admin > Manage Staff, here you can only assign two kinds of staff even if you have declared 5 staff roles under Admin > User Admin > Manage Roles. And so, I want the additional staff roles created under Admin > User Admin > Manage Roles to appear whenever I go to Admin > User Admin > Manage Staff. Like I said earlier, currently only “teaching” and “support” are available in the field “type” at Admin > User Admin > Manage Staff > Add. (Of course, you are aware of this).
I think you now have a better understanding of what I mean. And so, back to my question, will the newly added staff type reflect in every other part of the system where registered staff are
needed? For example, in the Departments section, in the class section,
and others.
Thanks in advance.
Daniel,
Ah, I see what you mean. That field is currently not customisable, but there is the Job Title role that you could use to similar effect. I have made a note to look at this in v12 (see https://docs.google.com/spreadsheets/d/16DKH38v42-a0aGRlBEABuk_pfZe-RgmC_bkzBg7jD_w/edit?usp=sharing), so it should be available by July. Sorry, v11 is crammed full of new feature requests already.
In terms of Departments, it would be possible to do the same thing, but the departmental roles carry functional meaning around the system, so such a change would be considerable. I am just not sure we have the resources to offer this kind of change right now. However, the person’s job description is listed with their image in the Department view, so you can use that to add some of the information you need.
Thanks,
Ross
Of course Ross, I know that the field is not customizable. I want to hack the core to make the changes. Just tell me if the added staff type will appear wherever it’s needed or not. Don’t worry about what will happen on update, I will handle that.
Daniel,
I always forget you are a courageous, core hacking Gibbon maniac! I think if you change it on the staff manage page, it should not have any negative conseqeunces across the system. If it does, let me know here.
Thanks,
Ross
Hey Ross,
It’s been long that I came to this forum. Actually I have been relaxing for a while now. I should have got back to you since, but never mind, I just had to take some time off.
I made the changes I mentioned about on the day you replied me and it worked fine. This is what I did:
1. I altered the gibbonstaff table thus:
"
ALTER TABLE gibbonstaff
CHANGE type
type
VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
"
Of course, inserting the following code in PHPMyAdmin will change it back to how it was originally:
"
ALTER TABLE gibbonstaff
CHANGE type
type
ENUM(‘Teaching’,‘Support’) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
"
2. Next, I changed the code for the usertype dropdown in “staff_manage_add.php” thus:
"
<?php
print "" . _('Please select...') . "" ;
$nextdata=array();
$nextsql="SELECT DISTINCT name FROM gibbonrole WHERE category='Staff' ORDER BY name" ;
$nextresult=$connection2->prepare($nextsql);
$nextresult->execute($nextdata);
while ($nextrow=$nextresult->fetch())
{
print "" . htmlPrep(_($nextrow["name"])) . "" ;
}
?>
"
3. Lastly, I changed the code that indicates the stored user type in the appropriate dropdown in “staff_manage_edit.php” thus:
"
<?php
print "" . _('Please select...') . "" ;
print "" . htmlPrep(_($row["type"])) . "" ;
$nextdata=array();
$nextsql="SELECT DISTINCT name FROM gibbonrole WHERE category='Staff' ORDER BY name" ;
$nextresult=$connection2->prepare($nextsql);
$nextresult->execute($nextdata);
while ($nextrow=$nextresult->fetch()) {
print "" . htmlPrep(_($nextrow["name"])) . "" ;
}
?>
"
There is one thing I want to bring to your notice in (3) above: the dropdown will display the person’s usertype twice while editing the profile. It did when I run the code. This doesn’t affect the effectiveness or efficiency, everything works perfectly, only that it makes a particular entry appear twice instead of once. Please run the code to view this for yourself. Help me rewrite the code to make sure that the person’s usertype will show only once while editing the profile.
Thanks for your response in advance Ross.
Daniel,
This looks like an interested solution. If you want to use GitHub to create a fork of branch of the v11 branch, you could do push this code to me, and I could try it out and see if it works, and how to implement the fix you are looking for.
Thanks,
Ross
Ross,
Are you saying that I should send the entire code? I thought that the few lines above are all I need to show you to adjust or do otherwise.
Daniel,
If you incorporate the changes in the way I described, it is easier for me to control the code base. With contributions coming in from different people, I am trying to standardise changes to make everything more consistence.
Thanks,
Ross
Okay Ross,
I will push the code to you.
Hey Ross,
I have made the necessary adjustment in the number (3) code above. Don’t bother correcting anything again unless you want to improve it. Take a look at the correct code:
"
<?php
print "" . _('Please select...') . "" ;
$realdata=array();
$realsql="SELECT type FROM gibbonStaff WHERE gibbonStaffID='{$gibbonStaffID}'" ;
$realresult=$connection2->prepare($realsql);
$realresult->execute($realdata);
$realrow=$realresult->fetch();
$nextdata=array();
$nextsql="(SELECT type FROM gibbonStaff WHERE gibbonStaffID='{$gibbonStaffID}') UNION (SELECT name FROM gibbonrole WHERE category='Staff') ORDER BY type ASC" ;
$nextresult=$connection2->prepare($nextsql);
$nextresult->execute($nextdata);
while ($nextrow=$nextresult->fetch())
{
$selected="" ;
if ($realrow["type"]==$nextrow["type"]) {$selected="selected" ;}
print "" . htmlPrep(_($nextrow["type"])) . "" ;
}
?>
"
I will send the complete files to your email address.
Cheers!
Daniel,
Thanks for this. Is there any chance you can wrap it up as a GitHub push request? This means I can automatically check your version against the dev branch to see if any changes have been made. I appreciate your input, but for consistency, and to avoid mistakes, we are only accepting code contributions via GitHub push requests.
Cheers,
Ross
I have never forked a project on github before. I only download codes from there. I’m not even sure I have an account. But if that’s what it takes, I will try and pull the requests via github.
Daniel,
I never got the push request from you, but the job went into the todo list for v12, and has now been completed. You can find the changes in the dev branch at:
https://github.com/GibbonEdu/core/commit/8ffab4ea25594dfd9d780b871d5b6c8e835f6c3a
This change is NOT backwards compatible with v11.
The code is mostly the same as yours (I forgot your code was here, so ended up doing it myself, but the result is much the same : ).
Thanks,
Ross