<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class User_Widget_SettingsMenuController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {
    $id = $this->_getParam('id', null);
    
    // Set up edit profile navigation
    $this->view->user_edit_navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('user_edit', ( $id ? array('params' => array('id'=>$id)) : array()));
    
    // Set up navigation
    $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('user_settings', ( $id ? array('params' => array('id'=>$id)) : array()));
    
    // Check last super admin
    $user = Engine_Api::_()->user()->getViewer();
    if( $user && $user->getIdentity() ) {
      if( 1 === engine_count(Engine_Api::_()->user()->getSuperAdmins()) && 1 === $user->level_id ) {
        foreach( $navigation as $page ) {
          if( $page instanceof Zend_Navigation_Page_Mvc &&
              $page->getAction() == 'delete' ) {
            $navigation->removePage($page);
          }
        }
      }
    }
  }
}
