<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Userprofilelock_Plugin_Core extends Zend_Controller_Plugin_Abstract
{

	public function onRenderLayoutDefault($event, $mode = null)
	{

		$view = $event->getPayload();
		$viewer = Engine_Api::_()->user()->getViewer();

		$script = "var profilelock = false;";
		if (!empty(Engine_Api::_()->getApi('settings', 'core')->getSetting('userprofilelock.enable', 1)) && !empty($viewer->profilelock)) {
			$script = "var unlockURL = 'profilelock/index/lock/id/" . $viewer->getIdentity() . "/profilelock/1';";
			$script .= "var profilelock = true;";
		}
		$view->headScript()->appendScript($script);
	}
}
