Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 248 Rev 249
Línea 71... Línea 71...
71
 
71
 
72
 
72
 
-
 
73
 
-
 
74
    public function indexAction()
-
 
75
    {
-
 
76
        $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
77
        $currentUser = $currentUserPlugin->getUser();
-
 
78
        
-
 
79
        //$currentCompany = $currentUserPlugin->getCompany();
-
 
80
        
Línea 73... Línea 81...
73
 
81
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
74
    public function indexAction()
82
        $currentNetwork = $currentNetworkPlugin->getNetwork();
75
    {
83
        
Línea 76... Línea 84...
76
        
84
        
77
        $code = $this->params()->fromRoute('code');
85
        $code = $this->params()->fromRoute('code');
78
        $shorterMapper = ShorterMapper::getInstance($this->adapter);
86
        $shorterMapper = ShorterMapper::getInstance($this->adapter);
79
        $shorter = $shorterMapper->fetchOneByUuid($code);
87
        $shorter = $shorterMapper->fetchOneByUuid($code);
-
 
88
        
-
 
89
        if(!$shorter || $shorter->status == Shorter::STATUS_INACTIVE) {
-
 
90
           /// $response = $this->getResponse();
-
 
91
            //$response->setStatusCode(404);
-
 
92
            //return $response;
-
 
93
            
-
 
94
            return new JsonModel([
-
 
95
                'success' => false,
-
 
96
                'data' => 'ERROR_FEED_OR_POST_SHARED'
-
 
97
            ]);
-
 
98
        }
-
 
99
       
-
 
100
        if($currentUser->hasIdentity()) {
-
 
101
 
-
 
102
            $target = $shorter->target;
-
 
103
            if(strpos($target, '-feed-') !== -1) {
-
 
104
                
-
 
105
                $s = explode('-feed-', $target);
-
 
106
                $url = $this->url()->fromRoute('dashboard', ['feed' => trim($s[1]) ]);
-
 
107
                
-
 
108
            } 
-
 
109
            else if(strpos($target, '-post-') !== -1) {
-
 
110
                $s = explode('-post-', $target);
-
 
111
                $url = $this->url()->fromRoute('post', ['id' => trim($s[1]) ]);
-
 
112
            } 
-
 
113
            else {
-
 
114
                $url = $this->url()->fromRoute('dashboard');
-
 
115
            }
-
 
116
            
-
 
117
            $hostname = empty($_SERVER['HTTP_HOST']) ?  '' : $_SERVER['HTTP_HOST'];
-
 
118
            
-
 
119
            $networkMapper = NetworkMapper::getInstance($this->adapter);
-
 
120
            $network = $networkMapper->fetchOneByHostnameForFrontend($hostname);
-
 
121
            
-
 
122
            if(!$network) {
-
 
123
                $network = $networkMapper->fetchOneByDefault();
-
 
124
            }
-
 
125
            
-
 
126
            $hostname = trim($network->main_hostname);
-
 
127
            $url = 'https://' . $hostname . $url;
-
 
128
            
-
 
129
            return new JsonModel([
-
 
130
                'success' => true,
-
 
131
                'data' => [
-
 
132
                    'redirect' => true, 
-
 
133
                    'url' => $url
-
 
134
                ]
-
 
135
            ]);
-
 
136
            
-
 
137
             
-
 
138
        } else {
-
 
139
          
-
 
140
            return new JsonModel([
-
 
141
                'success' => true,
80
        
142
                'data' => [
81
        if(!$shorter || $shorter->status == Shorter::STATUS_INACTIVE) {
-
 
82
            $response = $this->getResponse();
-
 
83
            $response->setStatusCode(404);
-
 
84
            return $response;
-
 
85
        }
-
 
Línea 86... Línea 143...
86
        
143
                    'redirect' => false,
Línea 87... Línea 144...
87
        return new JsonModel([
144
                    'url' => $shorter->url
88
            'success' => true,
145
                ]