Ticket #2953 (closed Feature Requests: fixed)

Opened 4 months ago

Last modified 4 months ago

Device User log in/out User Event

Reported by: mwolf9 Assigned to: p_lindheimer
Priority: minor Milestone: 2.5
Component: Core - Users/Devices Version: 2.5-branch
Keywords: Cc:
Confirmation: Confirmed SVN Revision (if applicable):
Backend Engine: All Backend Engine Version:

Description

I have made a modification to include AMI UserEvents? on user log in/out events. The target file is /var/lib/asterisk/agi-bin/user_login_out.agi. The modifications are noted by the //ADDED LINE comments.

	// Insert a specificed user into a specified device and then
	// update the hint for that user to reflect the new device(s)
	// and update the voicemial link
	//
	function insert_user($user, $device) {
		debug("insert_user: user: $user, device: $device",8);
		global $agi;
		global $astspooldir;
		global $fm_devstate;
		global $dnd_devstate;

		set_device_user($device, $user);
		$previous_devices = get_devices($user);
		$new_devices = insert_device($previous_devices,$device);
		debug("insert_user: Setting user $user to devices $new_devices",5);
		set_user_devices($user, $new_devices);
		set_hint($user, $new_devices);
		$agi->exec("UserEvent", "UserDeviceAdded|Data:{$user},{$device}");//ADDED LINE 

		if ($fm_devstate) {
			debug("insert_user: Setting FollowMe DEVSTATES for device $device",5);
			$agi->set_variable('DEVSTATE(Custom:FOLLOWME'.$device.')',get_followme_state($user));
		}
		if ($dnd_devstate) {
			debug("insert_user: Setting DND DEVSTATES for device $device",5);
			$agi->set_variable('DEVSTATE(Custom:DEVDND'.$device.')',get_dnd_state($user));
		}

		$vmcontext = get_voicemail_context($user);
		if ($vmcontext != 'novm') {
			exec("/bin/ln -s {$astspooldir}/voicemail/{$vmcontext}/{$user}/ {$astspooldir}/voicemail/device/$device", $output, $ret);
			if ($ret) {
				debug("Got Return code: $ret trying to: /bin/ln -s {$astspooldir}/voicemail/{$vmcontext}/{$user}/ {$astspooldir}/voicemail/device/$device",5);
			}
		}
	}

	// Remove the current user from a device and then update
	// the hint of that current user to reflect their current devices
	//
	function remove_user($device) {
		debug("remove_user: device: $device",8);
		global $agi;
		global $astspooldir;
		global $fm_devstate;
		global $dnd_devstate;

		$current_user = get_user($device);
		if ($current_user != '') {
			$current_devices = get_devices($current_user);
			$new_devices = remove_device($current_devices,$device);
			debug("remove_user: Setting user $current_user to devices $new_devices",5);
			set_user_devices($current_user, $new_devices);
			set_hint($current_user, $new_devices);
			$agi->exec("UserEvent", "UserDeviceRemoved|Data:{$current_user},{$device}");//ADDED LINE 
			exec("/bin/rm -f {$astspooldir}/voicemail/device/$device",$output, $ret);

			debug("Setting device $device states to INVALID before deleting them",5);
			if ($fm_devstate) {
				debug("Setting device $device FollowMe state to INVALID before deleting",5);
				$agi->set_variable('DEVSTATE(Custom:FOLLOWME'.$device.')','INVALID');
			}
			if ($dnd_devstate) {
				debug("Setting device $device DND state to INVALID before deleting",5);
				$agi->set_variable('DEVSTATE(Custom:DEVDND'.$device.')','INVALID');
			}
			// I thought they should then be deleted, but they still end up there probably because setting them to invalid re-creates them
			//
			//$agi->database_deltree('CustomDevstate','FOLLOWME'.$device);
			//$agi->database_deltree('CustomDevstate','DEVDND'.$device);
			if ($ret) {
				debug("Got Return code: $ret trying to remove: {$astspooldir}/voicemail/device/$device",5);
			}
			set_device_user($device, 'none');
		}
	}

Attachments

file.patch (0.9 kB) - added by mwolf9 on 07/25/08 17:02:14.

Change History

07/25/08 17:02:14 changed by mwolf9

  • attachment file.patch added.

07/25/08 17:44:23 changed by p_lindheimer

  • confirmation changed from Unreviewed to Confirmed.
  • milestone changed from Cut Line to 2.5.

07/25/08 17:49:19 changed by p_lindheimer

  • status changed from new to closed.
  • resolution set to fixed.

(In [6186]) closes #2953 adds events when users login/out of a device to support products like iSymphony, FOP or anyone else who needs to know

Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads