chamilo-lms icon indicating copy to clipboard operation
chamilo-lms copied to clipboard

Add a color of your choice in the agenda

Open andreboivin opened this issue 2 years ago • 8 comments

Without modification of the database, it is possible to choose any color for the events added to the calendar. I put the modified files in the included zip. For improvement, it would be interesting to replace the html5 form in agenda.lib.php: $form->addElement('color', 'color', get_lang('SelectColor')); by a javascript in order to keep the same display according to the browsers agenda_color agenda_color.zip

andreboivin avatar Mar 12 '22 14:03 andreboivin

Looks nice would it not be better to make a pull request ? Makes it easyer for the devs to integrate it.

spacecabbie avatar Mar 20 '22 12:03 spacecabbie

I understand but I'm not familiar with the pull request and I don't have time to learn it. This is why I simply put the modified files in the archive, comparing with those of chamilo-lms/tree/1.11.x/ it will be easy to integrate the modifications.

andreboivin avatar Mar 20 '22 13:03 andreboivin

Hello,

Thank you for this great enhancement. It seems to be working fine inside courses and personal agenda but it doesn't seems to be working for the global website agenda.

Regards.

aelalfey avatar Apr 05 '22 13:04 aelalfey

In inc/lib/agenda.lib.php add this line $this->event_personal_color = $row['color']; near line 1761:

$my_events = []; if (Database::num_rows($result)) { while ($row = Database::fetch_array($result, 'ASSOC')) { $this->event_personal_color = $row['color']; $event = [];

andreboivin avatar Apr 07 '22 17:04 andreboivin

Oups! For the system calendar there is no color field in the sys_calendar table

andreboivin avatar Apr 07 '22 17:04 andreboivin

Hi @andreboivin First of all, this is a nice contribution, thanks for the effort. Second, sorry for the delay in integrating it. Sadly, there will be more delay... (meaning it will move to the 2.0 milestone) Third, I sent a PR here https://github.com/chamilo/chamilo-lms/pull/4513 to make the integration easier. And finally, here is the list of issues that block its integration:

  • Although I tried to fix it with a slightly better default color, the default set in https://github.com/chamilo/chamilo-lms/pull/4513/files#diff-4c64d4e0244737c7c711510a432e68ec2888c315175035e531f7ab56a0e3630fR258 was hardcoded (it still kind of is) to the default course event color, which is not the same as personal events, platform events, session events, group events, etc. There should be some kind of function call there getting the default color for the current type of event. There is no method in agenda.lib.php for that but there should be one to generate the feature here.
  • As mentioned above, the sys_calendar table doesn't have a color field, which blocks the possibility to configure the color of each global agenda event. personal_agenda has it, so it would make sense to have a color field in sys_calendar, but that needs to be added (which means database change, which means major Chamilo version). The field doesn't exist at this stage, so it will have to be added to the DB structure on install/upgrade. I've created an issue for that here: #4514
  • It conflicts with a feature called agenda_colors available through changes in configuration.php, which allows the admin to set a default color by event type for the whole system. If we enable the proposed feature here, then anyone will be able to change the colors, which would oppose the admin-directed choice offered by agenda_colors. As such, a new configuration option (agenda_colors_by_users ?) should be added to decide whether we want users to be able to choose their color or not. Then the agenda_colors option could still be taken into account for default colors, but could be overwritten by final users

For all these reasons, I cannot accept this contribution in 1.11.x just yet. Hopefully, the PR will allow admins who want this feature to enable it quickly (with the issues exposed) until then.

ywarnier avatar Dec 27 '22 22:12 ywarnier

Although the feature hasn't been added yet, I have uploaded a change to the database structure that will allow system events to be changed as well in Chamilo 2.1 and up

ywarnier avatar Jan 14 '24 00:01 ywarnier

The System calendar code (still using public/main/calendar/agenda.php and surrounding scripts) should move to use /resource/CCalendarEvent, which should include colors straight away, now.

ywarnier avatar Mar 18 '24 21:03 ywarnier