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

class Userprofilelock_Plugin_Menus
{

	public function onMenuInitialize_UserProfilelock($row)
	{

		if (empty(Engine_Api::_()->getApi('settings', 'core')->getSetting('userprofilelock.enable', 1)))
			return false;

		$viewer = Engine_Api::_()->user()->getViewer();
		$subject = Engine_Api::_()->core()->getSubject();

		if ($viewer->getIdentity() && $subject->getIdentity() == $viewer->getIdentity()) {
			if (empty($subject->profilelock)) {
				$label = "Lock Profile";
				$class = "smoothbox userprofilelock_icon_lock";
			} else {
				$label = "Unlock Profile";
				$class = "smoothbox userprofilelock_icon_unlock";
			}

			return array(
				'label' => $label,
				'class' => $class,
				'route' => 'userprofile_lock',
				'params' => array(
					'controller' => 'index',
					'action' => 'lock',
					'id' => $subject->getIdentity(),
					'profilelock' => $subject->profilelock,
				)
			);
		}
		return false;
	}
}
