Show Wordpress-User in Event view

Hi,

I’ve just started your grandiose Scheduler for Wordpress.
I’d like to us it for booking schemes of equipment in our (scientific) lab. Different user can book different resources, but only one at a time.
Most worked out of the box, but I couldn’t find out how to show which user has entered which booking. I know that dhtmlxScheduler saves the user in its table and this most likely correspond to the ID of the user in wordpress. But how can I show this realname in the event view (when someone clicks an entry?)

Regards,
Jan

Hi.
To show event author name you should make two things:

  1. take real name on server side. I’ve already customized code, just update dhtmlxSchedulerConfigurator.php from attachment.
  2. set template for events. For example, you could set event_bar_text template (in Admin panel tab Templates) like here:
return (event.user ? (event.user + ": ") : "") + "<span title=\""+event.text+"\">" + event.text + "</span>";

dhtmlxSchedulerConfigurator.zip (10.2 KB)

Thanks a lot for this great plugin. I am liking it more and more. Actually, I downloaded dhtmlxSchedulerConfigurator and made some changes to view userid in each event, which worked fine in normal mode, but in PrivateMode Extended, it prevents users from editing or deleting their own events. In the text view mode of calendar, the controls appear but do not function properly. I checked the Log, and it seems that with the new dhtmlxSchedulerConfigurator, readonly is true.
I tried to figure out a solution, but no luck at all. I appreciate any help, with best regards.

Hi.
Could you attach changed file?

Dear radyno, good to hear from you! I used the same file as you posted here, the one above this post. I created an admin user for you, so if you have time, I would appreciate looking into the problem. Please check your Inbox for your id and pw.

Hi.
Update dhtmlxSchedulerConfigurator.php one more time and in event templates replace “event.user” by “event.user_name”, please.
dhtmlxSchedulerConfigurator.zip (10.2 KB)

Thanks a lot for your support, but we have another problem now. With the new configurator users can not create new events, the event text will turn red (in bold) right after creating and won’t save. Sorry for the trouble, but could you help with this too?

Update dhtmlxSchedulerConfigurator.php one more time, please.
This fix will work just in PrivateExtended Mode.
dhtmlxSchedulerConfigurator.zip (10.2 KB)

Great! Works like a charm now. Thank you for your support.

Great plugin again!! I have on emore question, how to export the “label” of a custom list and usernames using iCal. I have tried several codes with getlabel or str_replace but no luck. For instance I query the values of custom fields and user. What I get (as $dsc, for example) is only user id (numbers) and text values but not labels or usernames. Any help would be greatly appreciated.

To take username by user id you may use Wordpress native API:
codex.wordpress.org/Function_Ref … t_userdata

If to talk about custom fields - it generates it’s own keys for every custom field value.
But it doesn’t store them like “key: value”, so you have to work hard to find them out.

  1. You have to take option scheduler_php like here:
    $scheduler_php = get_option(‘scheduler_php’);

  2. You have to find custom field serialization in scheduler_php:
    optionsList_{customfield_name}{:}{customfield_name}_0:F1,{customfield_name}_1:F2,{customfield_name}_2:F3,…

For example:
optionsList_field{:}field_0:F1,field_1:F2,field_2:F3
where field is customfield name.

  1. Then parse this line to generate hash from keys and values.

  2. Replace custom field keys in request result by corresponding values.

Thanks a lot radyno;
The username worked right out of the box, but honestly I have problem understanding the customfield instructions and make the right code as I am not familiar with php. The custom field is a list (event.text). How should I generate hash from keys and values and replace custom field keys in request result by corresponding values.

What to put instead of ???

...
$scheduler_php = get_option('scheduler_php');
???
...
$dsc = $scheduler_php->optionsList_text;
...

Sorry to interrupt you master.
Best regards

$dsc = $scheduler_php->optionsList_text;
$dsc = explode("{*:*}", $dsc);
$dsc = $dsc[1];
$dsc = explode(",", $dsc);
$hash = Array();
for ($i = 0; $i < count($dsc); $i++) {
    $line = explode(":", $dsc[$i]);
    $hash[$line[0]] = $line[1];
}

/*
now hash contains values like:
'text_0': 'First option',
'text_1': 'Second option',
'text_2': 'Third option'

where 'First option', 'Second option', 'Third option' are names which you wrote in admin panel for custom field options
*/

Now you can replace value from database field ‘text’ by value:

$value = 'text_1'; // for example you take this value from database field text
$value = $hash[$value];

Thanks a lot. My problem is now solved with your great help and support.

The codes works and the user appears as requested.
Instead of user nickname (nicename), I used user display name and again it works.
I noticed that when another user edits an event, it displays “guest” or the creator user and not the editing user. I tryed all the files in this topic (with some modifications) but didnt work.
Is it possible to fix that?

Hi,
is it possible that user which edits event is not logged in? If yes then it’s correct, because system doesn’t know his id and think that’s someone from the street. If it’s logged in user - could you provide files which you updated and step-by-step description what to do to replay your issue at local machine?
It would be usefull if you will provide link to your scheduler with two test user accounts.

tripbrokers.gr/scheduler

Try there… I installed it today for demo use, showing my big issues!

Hi, excellent demo! It may be used as example how people should describe their problems!
About your issues:

  1. Export timeline view to PDF:
    please, open file pdfGenerator.php in export directory and modify code like here (one line was added):
	private function renderScales($xml) {
		$scales = $xml->scale;
		$this->mode = (string) $scales->attributes()->mode;
		if (strpos($this->mode, "timeline") !== false) $this->mode = 'timeline';
		$this->today = $this->strip((string) $scales->attributes()->today);
  1. Ilya answered you here:
    viewtopic.php?f=16&t=21738

  2. It’s correct behavior. If you like to set new event author after editing then you may open file wordpress/wp-content/plugins/event-calendar-scheduler/codebase/dhtmlxSchedulerConfigurator.php and replace set_event_user method with the follow:

	public function set_event_user($action) {
		$status = $action->get_status();
		if ($this->settings["privatemode"] == "ext") {
			$user = $action->get_value('user');
			if ($user != $this->userid) {
				$action->error();
			}
		} else {
			if ($this->settings["privatemode"] == "on") {
				if ($status == "inserted")
					$action->set_value("user", $this->userid);
			} else {
				$action->set_value("user", $this->userid);
			}
		}

		if ($action->get_value('event_pid') == '') {
			$action->set_value('event_pid', 0);
		}
		if ($action->get_value('event_length') == '') {
			$action->set_value('event_length', 0);
		}
	}
  1. I’m not sure if I understand correctly logic. Could you describe more in details?
    There are users demo1, demo2 and admin. demo1 created event1, demo2 created event2, admin created event_adm.
    If guest opens site he will see event1, event2, event_admm but will not have ability to edit them.
    If demo1 opens site he will see event1, event2, event_adm, will have ability to edit event1.
    If demo2 opens site he will see event1, event2, event_adm, will have ability to edit event2.
    If admin opens site he will see event1, event2, event_adm, will have ability to edit event_adm.
    It’s a correct logic for this mode - everyone can see all events, but can editor only his own.

  2. Modify dhtmlxSchedulerConfigurator.php:

$scheduler .= "</script>
			<div id=\"scheduler_here\" class=\"dhx_cal_container\" style='width:".$settings['settings_width']."; height:".$settings['settings_height']."; z-index: 9999999;'>