Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6277 | Rev 6749 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6277 Rev 6605
Línea 49... Línea 49...
49
use LeadersLinked\Model\Company;
49
use LeadersLinked\Model\Company;
50
use LeadersLinked\Model\Connection;
50
use LeadersLinked\Model\Connection;
51
use LeadersLinked\Model\Service;
51
use LeadersLinked\Model\Service;
52
use LeadersLinked\Mapper\DailyPulseEmojiMapper;
52
use LeadersLinked\Mapper\DailyPulseEmojiMapper;
53
use LeadersLinked\Mapper\UserProfileMapper;
53
use LeadersLinked\Mapper\UserProfileMapper;
-
 
54
use LeadersLinked\Mapper\NetworkMapper;
-
 
55
use LeadersLinked\Model\Network;
-
 
56
use LeadersLinked\Mapper\LocationMapper;
Línea 54... Línea 57...
54
 
57
 
55
class HelperController extends AbstractActionController
58
class HelperController extends AbstractActionController
56
{
59
{
57
    /**
60
    /**
Línea 1859... Línea 1862...
1859
                'success' => false,
1862
                'success' => false,
1860
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1863
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1861
            ]);
1864
            ]);
1862
        }
1865
        }
1863
    }
1866
    }
-
 
1867
    
-
 
1868
    public function menuAction()
-
 
1869
    {
-
 
1870
        
-
 
1871
        
-
 
1872
        $request = $this->getRequest();
-
 
1873
        
-
 
1874
        
-
 
1875
 
-
 
1876
        if ($request->isGet()) {
-
 
1877
            $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
-
 
1878
            $network =  $currentNetworkPlugin->getNetwork();
-
 
1879
            
-
 
1880
            
-
 
1881
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
1882
            if($currentUserPlugin->hasIdentity()) {
-
 
1883
                $currentUser = $currentUserPlugin->getUser();
-
 
1884
        
-
 
1885
                
-
 
1886
                
-
 
1887
 
-
 
1888
                
-
 
1889
  
-
 
1890
 
-
 
1891
                
-
 
1892
                
-
 
1893
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
-
 
1894
                
-
 
1895
                $link_admin         = $currentUser->usertype_id == UserType::ADMIN ? 1 : 0;
-
 
1896
                $link_impersonate   = $currentUser->is_super_user == User::IS_SUPER_USER_YES ? 1 : 0;
-
 
1897
 
-
 
1898
                $fullname = trim($currentUser->first_name . ' ' . $currentUser->last_name);
-
 
1899
                
-
 
1900
                $profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
-
 
1901
                $visits = $profileVisitMapper->getTotalByVisitedId($currentUser->id);
-
 
1902
                
-
 
1903
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
-
 
1904
                $connections = $connectionMapper->fetchTotalConnectionByUser($currentUser->id);
-
 
1905
                
-
 
1906
                
-
 
1907
                if($currentUser->location_id) {
-
 
1908
                    $locationMapper = LocationMapper::getInstance($this->adapter);
-
 
1909
                    $location = $locationMapper->fetchOne($currentUser->location_id);
-
 
1910
                    
-
 
1911
                    $country = $location->country;
-
 
1912
                } else {
-
 
1913
                    $country = '';
-
 
1914
                }
-
 
1915
                
-
 
1916
                
-
 
1917
 
-
 
1918
                if($currentUser->usertype_id == UserType::ADMIN) {
-
 
1919
                    $link_admin = '/backend/signin-admin';
-
 
1920
                } else {
-
 
1921
                    $link_admin = '';
-
 
1922
                }
-
 
1923
                
-
 
1924
                $link_company = '';
-
 
1925
                if($network->default != Network::DEFAULT_YES) {
-
 
1926
                    $companyMapper = CompanyMapper::getInstance($this->adapter);
-
 
1927
                    $company = $companyMapper->fetchDefaultForNetworkByNetworkId($network->id);
-
 
1928
                    if($company) {
-
 
1929
                        $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
-
 
1930
                        $companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
-
 
1931
                        if($companyUser) {
-
 
1932
                            if($companyUser && $companyUser->status == CompanyUser::STATUS_ACCEPTED && $companyUser->backend == CompanyUser::BACKEND_YES ) {
-
 
1933
                                $link_company = ['route' => 'backend/signin-company', 'id' => $company->uuid ];
-
 
1934
                            }
-
 
1935
                        }
-
 
1936
                    }
-
 
1937
                }
-
 
1938
                
-
 
1939
                if ($acl->isAllowed($currentUser->usertype_id,  'knowledge-area')) {
-
 
1940
                    $route_knowledge_area = $this->url()->fromRoute('knowledge-area');
-
 
1941
                    $link_knowledge_area = 1;
-
 
1942
                } else {
-
 
1943
                    
-
 
1944
                    $route_knowledge_area = '';
-
 
1945
                    $link_knowledge_area = 0;
-
 
1946
                }
-
 
1947
                
-
 
1948
                if ($acl->isAllowed($currentUser->usertype_id,  'my-coach')) {
-
 
1949
                    $route_my_coach = $this->url()->fromRoute('my-coach');
-
 
1950
                    $link_my_coach = 1;
-
 
1951
                } else {
-
 
1952
                    
-
 
1953
                    $route_my_coach = '';
-
 
1954
                    $link_my_coach = 0;
-
 
1955
                }
-
 
1956
                
-
 
1957
                if($network->default == Network::DEFAULT_YES) {
-
 
1958
                    if($network->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER)  {
-
 
1959
                        $pages = getAclMenuDefaultNetworkConnectionUser2User();
-
 
1960
                    } else {
-
 
1961
                        $pages = getAclMenuDefaultNetworkConnectionAll2All();
-
 
1962
                    }
-
 
1963
                } else {
-
 
1964
                    if($network->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER)  {
-
 
1965
                        
-
 
1966
                        $pages = getAclMenuNonDefaulNetworkConnectionUser2User();
-
 
1967
                        
-
 
1968
                    } else {
-
 
1969
                        $pages = getAclMenuNonDefaultNetworkConnectionAll2All();
-
 
1970
                    }
-
 
1971
                }
-
 
1972
                
-
 
1973
                
-
 
1974
                $menu = [];
-
 
1975
                foreach ($pages as $page) {
-
 
1976
                    
-
 
1977
                    if (!$page || empty($page['route']) || !$acl->isAllowed($currentUser->usertype_id, $page['route'])) {
-
 
1978
                        continue;
-
 
1979
                    }
-
 
1980
                    
-
 
1981
                    $ajax = false;
-
 
1982
                    if ($page['route'] == 'company' && $network->default == Network::DEFAULT_NO) {
-
 
1983
                        
-
 
1984
                        if ($link_company) {
-
 
1985
                            $page['route'] = $this->url($link_company['route'], ['id' => $link_company['id']]);
-
 
1986
                            $ajax = true;
-
 
1987
                        } else {
-
 
1988
                            continue;
-
 
1989
                        }
-
 
1990
                    }
-
 
1991
                    
-
 
1992
                    $option = [
-
 
1993
                        'label' => $page['label'],
-
 
1994
                        'href' => $page['route'],
-
 
1995
                        'img' => empty($page['class']) ? '' : $page['class'],
-
 
1996
                        'ajax' => $ajax ? 1 : 0,
-
 
1997
                        'childs' => [],
-
 
1998
                    ];
-
 
1999
                    
-
 
2000
                    $childs = empty($page['pages']) ? [] : $page['pages'];
-
 
2001
                    if ($childs) {
-
 
2002
                        foreach ($childs as $child) {
-
 
2003
                            if (!$acl->isAllowed($currentUser->usertype_id,  $child['route'])) {
-
 
2004
                                continue;
-
 
2005
                            }
-
 
2006
                            
-
 
2007
                            $childs_level2 = [];
-
 
2008
                            
-
 
2009
                            $childsLevel2 = empty($child['pages']) ? [] : $child['pages'];
-
 
2010
                            
-
 
2011
                            if ($childsLevel2) {
-
 
2012
                                foreach ($childsLevel2 as $childLevel2) {
-
 
2013
                                    if (!$acl->isAllowed($currentUser->usertype_id,  $childLevel2['route'])) {
-
 
2014
                                        continue;
-
 
2015
                                    }
-
 
2016
                                    
-
 
2017
                                    array_push($childs_level2, [
-
 
2018
                                        'label' => $childLevel2['label'],
-
 
2019
                                        'href' => $childLevel2['route'],
-
 
2020
                                        
-
 
2021
                                    ]);
-
 
2022
                                }
-
 
2023
                            }
-
 
2024
                            
-
 
2025
                            array_push($option['childs'], [
-
 
2026
                                'label' => $child['label'],
-
 
2027
                                'href' => $child['route'],
-
 
2028
                                'childs' => $childs_level2,
-
 
2029
                            ]);
-
 
2030
                        }
-
 
2031
                    }
-
 
2032
                    
-
 
2033
                    array_push($menu, $option);
-
 
2034
                }
-
 
2035
                
-
 
2036
                
-
 
2037
                $image = $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $currentUser->uuid, 'filename' => $currentUser->image]);
-
 
2038
                $isChatPage = $this->getEvent()->getViewModel()->getVariable('is_chat');
-
 
2039
                $routeCheckSession = $this->url()->fromRoute('check-session');
-
 
2040
 
-
 
2041
                
-
 
2042
                
-
 
2043
                return new JsonModel([
-
 
2044
                    'menu'                  => $menu,
-
 
2045
                    'isChatPage'            => $isChatPage == 1,
-
 
2046
                    'routeCheckSession'     => $routeCheckSession,
-
 
2047
                    'linkAdmin'             => $link_admin == 1,
-
 
2048
                    'linkImpersonate'       => $link_impersonate == 1,
-
 
2049
                    'image'                 => $image,
-
 
2050
                    'fullName'              => $fullname,
-
 
2051
                    'country'               => $country,
-
 
2052
                    'visits'                => $visits,
-
 
2053
                    'connections'           => $connections,
-
 
2054
                    'logoForNavbar'         => 'https://' . $network->main_hostname . '/storage-network/type/navbar',
-
 
2055
                    'defaultNetwork'        => $network->default,
-
 
2056
                    'linkKnowledgeArea'     => $link_knowledge_area == 1,
-
 
2057
                    'routeKnowledgeArea'    => $route_knowledge_area,
-
 
2058
                    'linkMyCoach'           => $link_my_coach == 1,
-
 
2059
                    'routeMyCoach'          => $route_my_coach,
-
 
2060
               ]);     
-
 
2061
 
-
 
2062
                
-
 
2063
                
-
 
2064
            }
-
 
2065
            
-
 
2066
            
-
 
2067
            return new JsonModel([
-
 
2068
                'menu'                  => [],
-
 
2069
                'isChatPage'            => false,
-
 
2070
                'routeCheckSession'     => '',
-
 
2071
                'linkAdmin'             => false,
-
 
2072
                'linkImpersonate'       => false,
-
 
2073
                'image'                 => '',
-
 
2074
                'fullName'              => '',
-
 
2075
                'country'               => 0,
-
 
2076
                'visits'                => 0,
-
 
2077
                'connections'           => 0,
-
 
2078
                'logoForNavbar'         => 'https://' . $network->main_hostname . '/storage-network/type/navbar',
-
 
2079
                'defaultNetwork'        => $network->default,
-
 
2080
                'linkKnowledgeArea'     => false,
-
 
2081
                'routeKnowledgeArea'    => '',
-
 
2082
                'linkMyCoach'           => false,
-
 
2083
                'routeMyCoach'          => '',
-
 
2084
            ]);   
-
 
2085
           
-
 
2086
        } else {
-
 
2087
            
-
 
2088
            return new JsonModel([
-
 
2089
                'success' => false,
-
 
2090
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
2091
            ]);
-
 
2092
        }
-
 
2093
 
-
 
2094
        
-
 
2095
        return new JsonModel([
-
 
2096
            'success' => false,
-
 
2097
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
2098
        ]);
-
 
2099
    }
1864
}
2100
}