Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17306 Rev 17307
Línea 918... Línea 918...
918
                'success'   => false,
918
                'success'   => false,
919
                'data'   => 'ERROR_UPLOAD_FILE'
919
                'data'   => 'ERROR_UPLOAD_FILE'
920
            ]);
920
            ]);
921
        }
921
        }
Línea 922... Línea 922...
922
 
922
 
923
        /* // Obtener dimensiones objetivo para el redimensionamiento
923
        // Obtener dimensiones objetivo para el redimensionamiento
924
        list($target_width_str, $target_height_str) = explode('x', $this->config['leaderslinked.image_sizes.company_image_size']);
924
        list($target_width_str, $target_height_str) = explode('x', $this->config['leaderslinked.image_sizes.company_image_size']);
925
        $target_width = (int)$target_width_str;
925
        $target_width = (int)$target_width_str;
Línea 926... Línea 926...
926
        $target_height = (int)$target_height_str; */
926
        $target_height = (int)$target_height_str;
927
 
927
 
928
        // Generar nombres de archivo únicos
928
        // Generar nombres de archivo únicos
929
        $source = $storage->getTmpFilename();
929
        $source = $storage->getTmpFilename();
Línea 930... Línea 930...
930
        $filename = 'company-' . uniqid() . '.png';
930
        $filename = 'company-' . uniqid() . '.png';
931
        $target_filename = $storage->composePathToFilename(Storage::TYPE_COMPANY, $company->uuid, $filename);
931
        $target_filename = $storage->composePathToFilename(Storage::TYPE_COMPANY, $company->uuid, $filename);
932
 
932
 
933
        // Subir y redimensionar la imagen
933
        // Subir y redimensionar la imagen
Línea 934... Línea 934...
934
        if (!$storage->uploadImageWithOutChangeSize($source, $target_filename)) {
934
        if (!$storage->uploadImageResize($source, $target_filename, $target_width, $target_height)) {
935
            return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
935
            return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
Línea 946... Línea 946...
946
        $company->image = $filename;
946
        $company->image = $filename;
947
        if (!$companyMapper->update($company)) {
947
        if (!$companyMapper->update($company)) {
948
            return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
948
            return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
949
        }
949
        }
Línea -... Línea 950...
-
 
950
 
-
 
951
        // Actualizar la imagen del propietario si es necesario
-
 
952
        $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
-
 
953
        $companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
-
 
954
 
-
 
955
        if ($companyUser) {
-
 
956
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
957
            $user = $userMapper->fetchOne($companyUser->user_id);
-
 
958
 
-
 
959
            if ($user) {
-
 
960
                // Copiar la imagen del perfil para la imagen principal
-
 
961
                $user_filename = 'user-' . uniqid() . '.png';
-
 
962
                $target_filename_user = $storage->composePathToFilename(Storage::TYPE_USER, $user->uuid, $user_filename);
-
 
963
 
-
 
964
                // Copiar la imagen del perfil para la imagen principal
-
 
965
                if (!$storage->uploadImageResize($source, $target_filename_user, $target_width, $target_height)) {
-
 
966
                    return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
-
 
967
                }
-
 
968
 
-
 
969
                // Eliminar la imagen existente del usuario si está presente
-
 
970
                if ($user->image) {
-
 
971
                    $storage->deleteFile($target_user_path, $user->uuid, $user->image);
-
 
972
                }
-
 
973
 
-
 
974
                // Actualizar la imagen principal del usuario
-
 
975
                $user->image = $user_filename;
-
 
976
                if (!$userMapper->update($user)) {
-
 
977
                    return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
-
 
978
                }
-
 
979
            }
-
 
980
        }
950
 
981
 
951
        // Registrar la actualización de la imagen
982
        // Registrar la actualización de la imagen
Línea 952... Línea 983...
952
        $this->logger->info('Se actualizo la imagen de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
983
        $this->logger->info('Se actualizo la imagen de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
953
 
984