public function update($event, $step, $r)
	{	
		global $app_mode;

		$this->permlink = permlinkurl_id($r['ID']);

		callback_event('rah_bitly.update', '', false, $r);

		if (!$this->permlink || $r['Status'] < STATUS_LIVE)
		{
			return;
		}

		if (
			$this->prev_permlink !== $this->permlink ||
			empty($r['custom_'.$this->field]) ||
			$this->prev_status != $r['Status']
		) {
			$uri = $this->fetch($this->permlink);
		}

		if (empty($uri))
		{
			return;
		}

		$fields = getCustomFields();

		if (!isset($fields[$this->field]))
		{
			return;
		}

		safe_update(
			'textpattern',
			'custom_'.intval($this->field)."='".doSlash($uri)."'",
			"ID='".doSlash($r['ID'])."'"
		);

		$js = 
			'$(document).ready(function(){'.
				'$(\'input[name="custom_'.$this->field.'"]\').val("'.escape_js($uri).'");'.
			'});';

		if ($app_mode == 'async')
		{
			send_script_response($js);
		}
	}