Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 15338 Rev 15351
Línea 35... Línea 35...
35
use LeadersLinked\Model\EmailTemplate;
35
use LeadersLinked\Model\EmailTemplate;
36
use LeadersLinked\Mapper\NotificationMapper;
36
use LeadersLinked\Mapper\NotificationMapper;
37
use LeadersLinked\Mapper\UserNotificationSettingMapper;
37
use LeadersLinked\Mapper\UserNotificationSettingMapper;
38
use LeadersLinked\Mapper\EmailTemplateMapper;
38
use LeadersLinked\Mapper\EmailTemplateMapper;
39
use LeadersLinked\Library\QueueEmail;
39
use LeadersLinked\Library\QueueEmail;
-
 
40
use LeadersLinked\Mapper\NetworkMapper;
-
 
41
use LeadersLinked\Model\Network;
Línea 40... Línea 42...
40
 
42
 
41
class UserController extends AbstractActionController
43
class UserController extends AbstractActionController
42
{
44
{
43
    /**
45
    /**
Línea 87... Línea 89...
87
    {
89
    {
88
        $currentUserPlugin = $this->plugin('currentUserPlugin');
90
        $currentUserPlugin = $this->plugin('currentUserPlugin');
89
        $currentUser = $currentUserPlugin->getUser();
91
        $currentUser = $currentUserPlugin->getUser();
90
        $currentCompany = $currentUserPlugin->getCompany();
92
        $currentCompany = $currentUserPlugin->getCompany();
Línea -... Línea 93...
-
 
93
        
-
 
94
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
-
 
95
        $network = $currentNetworkPlugin->getNetwork();
-
 
96
        
91
        
97
        
Línea 92... Línea 98...
92
        $request = $this->getRequest();
98
        $request = $this->getRequest();
Línea 112... Línea 118...
112
                }
118
                }
113
            }
119
            }
Línea 114... Línea 120...
114
            
120
            
115
            if($isJson) {
121
            if($isJson) {
116
            {
-
 
117
                $sandbox = $this->config['leaderslinked.runmode.sandbox'];
-
 
118
                if($sandbox) {
-
 
119
                    $user_profile_url = $this->config['leaderslinked.frontend.sandbox_user_profile'];
-
 
120
                } else {
-
 
121
                    $user_profile_url = $this->config['leaderslinked.frontend.production_user_profile'];
-
 
122
                }
-
 
123
                
122
            {
124
                
-
 
125
                
123
 
126
                $search = $this->params()->fromQuery('search', []);
124
                $search = $this->params()->fromQuery('search', []);
Línea 127... Línea 125...
127
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
125
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
128
                
126
                
Línea 192... Línea 190...
192
                    
190
                    
193
                    foreach($records as $record)
191
                    foreach($records as $record)
Línea 194... Línea 192...
194
                    {
192
                    {
195
                        
193
                        
Línea 196... Línea 194...
196
                        $actions = []; 
194
                        $actions = []; 
Línea 324... Línea 322...
324
                    $records = $paginator->getCurrentItems();
322
                    $records = $paginator->getCurrentItems();
Línea 325... Línea 323...
325
                    
323
                    
326
                    foreach($records as $record)
324
                    foreach($records as $record)
327
                    {
325
                    {
328
                        $actions = [];
326
                        $actions = [];
Línea 329... Línea 327...
329
                        $actions['link_profile'] = str_replace('[uuid]', $record->uuid, $user_profile_url);
327
                        $actions['link_profile'] = 'https://'. $network->main_hostname . '/profile/view/' . $record->uuid;
330
                        
328
                        
331
                        
329
                        
Línea 1133... Línea 1131...
1133
    public function inviteAction()
1131
    public function inviteAction()
1134
    {
1132
    {
1135
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1133
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1136
        $currentUser = $currentUserPlugin->getUser();
1134
        $currentUser = $currentUserPlugin->getUser();
Línea -... Línea 1135...
-
 
1135
        
-
 
1136
        
1137
        
1137
        
Línea 1138... Línea 1138...
1138
        $currentCompany = $currentUserPlugin->getCompany();
1138
        $currentCompany = $currentUserPlugin->getCompany();
Línea 1139... Línea 1139...
1139
        
1139
        
Línea 1217... Línea 1217...
1217
                return new JsonModel([
1217
                return new JsonModel([
1218
                    'success'   => false,
1218
                    'success'   => false,
1219
                    'data'      => 'ERROR_USER_COMPANY_FOUND'
1219
                    'data'      => 'ERROR_USER_COMPANY_FOUND'
1220
                ]);
1220
                ]);
1221
            }
1221
            }
1222
            
-
 
-
 
1222
            $networkMapper = NetworkMapper::getInstance($this->adapter);
-
 
1223
            $network = $networkMapper->fetchOne($currentUser->network_id);
Línea 1223... Línea 1224...
1223
 
1224
 
Línea -... Línea 1225...
-
 
1225
            
-
 
1226
            if($companyUser) {
1224
            
1227
                
-
 
1228
                
-
 
1229
                if($network->default == Network::DEFAULT_YES) {
-
 
1230
                    $companyUser->status = CompanyUser::STATUS_ADMIN_WILL_ADD;
1225
            if($companyUser) {
1231
                } else {
Línea 1226... Línea 1232...
1226
                
1232
                    $companyUser->status = CompanyUser::STATUS_ACCEPTED;
-
 
1233
                }
-
 
1234
                $result = $companyUserMapper->update($companyUser);
1227
                $companyUser->status = CompanyUser::STATUS_ADMIN_WILL_ADD;
1235
                
1228
                $result = $companyUserMapper->update($companyUser);
1236
            } else {
1229
                
1237
 
1230
            } else {
1238
                
1231
                $companyUser = new CompanyUser();
1239
                $companyUser = new CompanyUser();
-
 
1240
                $companyUser->company_id = $currentCompany->id;
-
 
1241
                $companyUser->backend = CompanyUser::BACKEND_NO;
-
 
1242
                $companyUser->creator = CompanyUser::CREATOR_NO;
-
 
1243
                $companyUser->owner = CompanyUser::OWNER_NO;
-
 
1244
                
-
 
1245
                if($network->default == Network::DEFAULT_YES) {
-
 
1246
                    $companyUser->status = CompanyUser::STATUS_ADMIN_WILL_ADD;
-
 
1247
                } else {
1232
                $companyUser->company_id = $currentCompany->id;
1248
                    $companyUser->status = CompanyUser::STATUS_ACCEPTED;
1233
                $companyUser->backend = CompanyUser::BACKEND_NO;
1249
                }
Línea 1261... Línea 1277...
1261
                $userNotification = $userNotificationMapper->fetchOne($user->id);
1277
                $userNotification = $userNotificationMapper->fetchOne($user->id);
Línea 1262... Línea 1278...
1262
                
1278
                
1263
                if($userNotification && $userNotification->receive_invitation_company)
1279
                if($userNotification && $userNotification->receive_invitation_company)
1264
                {
1280
                {
1265
                    $emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
1281
                    $emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
Línea 1266... Línea 1282...
1266
                    $emailTemplate = $emailTemplateMapper->fetchOne(EmailTemplate::CODE_RECEIVE_INVITATION_COMPANY);
1282
                    $emailTemplate = $emailTemplateMapper->fetchOneByCodeAndNetworkId(EmailTemplate::CODE_RECEIVE_INVITATION_COMPANY, $currentUser->network_id);
1267
                    
-
 
1268
                    if($emailTemplate) {
-
 
1269
                        
-
 
1270
                        $sandbox = $this->config['leaderslinked.runmode.sandbox'];
-
 
1271
                        if($sandbox) {
1283
                    
1272
                            $company_profile_url = $this->config['leaderslinked.frontend.sandbox_company_profile'];
1284
                    if($emailTemplate) 
1273
                        } else {
-
 
Línea 1274... Línea -...
1274
                            $company_profile_url = $this->config['leaderslinked.frontend.production_company_profile'];
-
 
Línea 1275... Línea 1285...
1275
                        }
1285
                    {
1276
                        
1286
                        $company_profile_url = 'https://'. $network->main_hostname . '/company/view/' . $currentCompany->uuid;
1277
                        $company_profile_url = str_replace('[uuid]', $currentCompany->uuid, $company_profile_url);
1287
                        
1278
                        
1288
                        
Línea 1294... Línea 1304...
1294
                }
1304
                }
Línea 1295... Línea 1305...
1295
                
1305
                
Línea -... Línea 1306...
-
 
1306
                
1296
                
1307
                $this->logger->info('La empresa : ' . $currentCompany->name . ' envio al usuario : ' . $user->email . ' una invitación ', ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1297
                $this->logger->info('La empresa : ' . $currentCompany->name . ' envio al usuario : ' . $user->email . ' una invitación ', ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1308
                
1298
                
1309
                if($network->default == Network::DEFAULT_YES) {
-
 
1310
                    return new JsonModel([
-
 
1311
                        'success'   => true,
-
 
1312
                        'data'      => 'LABEL_USER_COMPANY_HAS_BEEN_CREATED',
-
 
1313
                    ]);
-
 
1314
                } else {
-
 
1315
                    return new JsonModel([
1299
                return new JsonModel([
1316
                        'success'   => true,
-
 
1317
                        'data'      => 'LABEL_USER_COMPANY_HAS_BEEN_INVITED_SENT',
-
 
1318
                    ]);
1300
                    'success'   => true,
1319
                }
Línea 1301... Línea 1320...
1301
                    'data'      => 'LABEL_USER_COMPANY_HAS_BEEN_SENT',
1320
                
1302
                ]);
1321
                
1303
            }  else {
1322
            }  else {