Compare commits
No commits in common. "master" and "prod" have entirely different histories.
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -14,10 +14,3 @@ app/cake_eclipse_helper.php
|
||||||
app/webroot/pdf/*
|
app/webroot/pdf/*
|
||||||
app/webroot/attachments_files/*
|
app/webroot/attachments_files/*
|
||||||
backups/*
|
backups/*
|
||||||
|
|
||||||
# Go binaries
|
|
||||||
go/server
|
|
||||||
go/vault
|
|
||||||
go/go.mod
|
|
||||||
go/go.sum
|
|
||||||
go/goose.env
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||||
|
|
||||||
CMC Sales is a B2B sales management system for CMC Technologies. The codebase consists of:
|
CMC Sales is a B2B sales management system for CMC Technologies. The codebase consists of:
|
||||||
|
|
||||||
- **Legacy CakePHP 1.2.5 application** (in `/php/`) - Primary business logic
|
- **Legacy CakePHP 1.2.5 application** (2008-era) - Primary business logic
|
||||||
- **Modern Go API** (in `/go/`) - New development using sqlc and Gorilla Mux
|
- **Modern Go API** (in `/go-app/`) - New development using sqlc and Gorilla Mux
|
||||||
|
|
||||||
**Note**: Documentation also references a Django application that is not present in the current codebase.
|
**Note**: Documentation also references a Django application that is not present in the current codebase.
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ gunzip < backups/backup_*.sql.gz | mariadb -h 127.0.0.1 -u cmc -p cmc
|
||||||
### Go Application Development
|
### Go Application Development
|
||||||
```bash
|
```bash
|
||||||
# Navigate to Go app directory
|
# Navigate to Go app directory
|
||||||
cd go
|
cd go-app
|
||||||
|
|
||||||
# Configure private module access (first time only)
|
# Configure private module access (first time only)
|
||||||
go env -w GOPRIVATE=code.springupsoftware.com
|
go env -w GOPRIVATE=code.springupsoftware.com
|
||||||
|
|
@ -80,7 +80,7 @@ make build
|
||||||
### Go Application (Modern)
|
### Go Application (Modern)
|
||||||
- **Framework**: Gorilla Mux (HTTP router)
|
- **Framework**: Gorilla Mux (HTTP router)
|
||||||
- **Database**: sqlc for type-safe SQL queries
|
- **Database**: sqlc for type-safe SQL queries
|
||||||
- **Location**: `/go/`
|
- **Location**: `/go-app/`
|
||||||
- **Structure**:
|
- **Structure**:
|
||||||
- `cmd/server/` - Main application entry point
|
- `cmd/server/` - Main application entry point
|
||||||
- `internal/cmc/handlers/` - HTTP request handlers
|
- `internal/cmc/handlers/` - HTTP request handlers
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
FROM golang:1.24-alpine
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy go.mod and go.sum first
|
|
||||||
COPY go/go.mod go/go.sum ./
|
|
||||||
|
|
||||||
# Download dependencies
|
|
||||||
RUN go mod download
|
|
||||||
|
|
||||||
# Install Air for hot reload (pinned to v1.52.3 for Go 1.24 compatibility)
|
|
||||||
RUN go install github.com/air-verse/air@v1.52.3
|
|
||||||
# Install sqlc for SQL code generation
|
|
||||||
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
|
||||||
|
|
||||||
# Copy source code
|
|
||||||
COPY go/ .
|
|
||||||
|
|
||||||
# Generate sqlc code
|
|
||||||
RUN sqlc generate
|
|
||||||
|
|
||||||
# Copy Air config
|
|
||||||
COPY go/.air.toml .air.toml
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
CMD ["air", "-c", ".air.toml"]
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
# Use the official PHP 5.6 Apache image for classic mod_php
|
|
||||||
FROM php:5.6-apache
|
|
||||||
|
|
||||||
# Install required system libraries and PHP extensions for CakePHP
|
|
||||||
RUN sed -i 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' /etc/apt/sources.list && \
|
|
||||||
sed -i 's|http://security.debian.org/debian-security|http://archive.debian.org/debian-security|g' /etc/apt/sources.list && \
|
|
||||||
sed -i '/stretch-updates/d' /etc/apt/sources.list && \
|
|
||||||
echo 'Acquire::AllowInsecureRepositories "true";' > /etc/apt/apt.conf.d/99allow-insecure && \
|
|
||||||
echo 'Acquire::AllowDowngradeToInsecureRepositories "true";' >> /etc/apt/apt.conf.d/99allow-insecure && \
|
|
||||||
apt-get update && \
|
|
||||||
apt-get install --allow-unauthenticated -y libc-client2007e-dev libkrb5-dev libpng-dev libjpeg-dev libfreetype6-dev libcurl4-openssl-dev libxml2-dev libssl-dev libmcrypt-dev libicu-dev && \
|
|
||||||
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
|
|
||||||
docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
|
|
||||||
docker-php-ext-install mysqli pdo pdo_mysql mbstring gd curl imap
|
|
||||||
|
|
||||||
# Set environment variables.
|
|
||||||
ENV HOME /root
|
|
||||||
|
|
||||||
# Define working directory.
|
|
||||||
WORKDIR /root
|
|
||||||
|
|
||||||
ARG COMMIT
|
|
||||||
ENV COMMIT_SHA=${COMMIT}
|
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Copy vhost config to Apache's sites-available
|
|
||||||
ADD conf/apache-vhost.conf /etc/apache2/sites-available/cmc-sales.conf
|
|
||||||
ADD conf/ripmime /bin/ripmime
|
|
||||||
|
|
||||||
RUN chmod +x /bin/ripmime \
|
|
||||||
&& a2ensite cmc-sales \
|
|
||||||
&& a2dissite 000-default \
|
|
||||||
&& a2enmod rewrite \
|
|
||||||
&& a2enmod headers
|
|
||||||
|
|
||||||
# Copy site into place.
|
|
||||||
ADD php/ /var/www/cmc-sales
|
|
||||||
ADD php/app/config/database_local.php /var/www/cmc-sales/app/config/database.php
|
|
||||||
RUN mkdir -p /var/www/cmc-sales/app/tmp
|
|
||||||
RUN mkdir -p /var/www/cmc-sales/app/tmp/logs
|
|
||||||
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
|
||||||
|
|
||||||
# Ensure CakePHP tmp directory is writable by web server
|
|
||||||
RUN chmod -R 777 /var/www/cmc-sales/app/tmp
|
|
||||||
# By default, simply start apache.
|
|
||||||
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
|
||||||
|
|
@ -1,4 +1 @@
|
||||||
FROM mariadb:latest
|
FROM mariadb:latest
|
||||||
|
|
||||||
# Copy custom MariaDB configuration to disable strict mode
|
|
||||||
COPY conf/mariadb-no-strict.cnf /etc/mysql/conf.d/
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go/go.mod go/go.sum ./
|
COPY go-app/go.mod go-app/go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY go/ .
|
COPY go-app/ .
|
||||||
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
||||||
RUN sqlc generate
|
RUN sqlc generate
|
||||||
RUN go mod tidy
|
RUN go mod tidy
|
||||||
|
|
@ -16,8 +16,8 @@ RUN apk --no-cache add ca-certificates tzdata
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
COPY --from=builder /app/server .
|
COPY --from=builder /app/server .
|
||||||
COPY --from=builder /app/vault .
|
COPY --from=builder /app/vault .
|
||||||
COPY go/templates ./templates
|
COPY go-app/templates ./templates
|
||||||
COPY go/static ./static
|
COPY go-app/static ./static
|
||||||
COPY go/.env.example .env
|
COPY go-app/.env.example .env
|
||||||
EXPOSE 8082
|
EXPOSE 8082
|
||||||
CMD ["./server"]
|
CMD ["./server"]
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ RUN chmod +x /bin/ripmime \
|
||||||
&& a2enmod headers
|
&& a2enmod headers
|
||||||
|
|
||||||
# Copy site into place.
|
# Copy site into place.
|
||||||
ADD php/ /var/www/cmc-sales
|
ADD . /var/www/cmc-sales
|
||||||
ADD php/app/config/database.php /var/www/cmc-sales/app/config/database.php
|
ADD app/config/database.php /var/www/cmc-sales/app/config/database.php
|
||||||
RUN mkdir -p /var/www/cmc-sales/app/tmp
|
RUN mkdir /var/www/cmc-sales/app/tmp
|
||||||
RUN mkdir -p /var/www/cmc-sales/app/tmp/logs
|
RUN mkdir /var/www/cmc-sales/app/tmp/logs
|
||||||
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
||||||
|
|
||||||
# Ensure CakePHP tmp directory is writable by web server
|
# Ensure CakePHP tmp directory is writable by web server
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go/go.mod go/go.sum ./
|
COPY go-app/go.mod go-app/go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY go/ .
|
COPY go-app/ .
|
||||||
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
||||||
RUN sqlc generate
|
RUN sqlc generate
|
||||||
RUN go mod tidy
|
RUN go mod tidy
|
||||||
|
|
@ -14,8 +14,8 @@ FROM alpine:latest
|
||||||
RUN apk --no-cache add ca-certificates tzdata
|
RUN apk --no-cache add ca-certificates tzdata
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
COPY --from=builder /app/server .
|
COPY --from=builder /app/server .
|
||||||
COPY go/templates ./templates
|
COPY go-app/templates ./templates
|
||||||
COPY go/static ./static
|
COPY go-app/static ./static
|
||||||
COPY go/.env.example .env
|
COPY go-app/.env.example .env
|
||||||
EXPOSE 8082
|
EXPOSE 8082
|
||||||
CMD ["./server"]
|
CMD ["./server"]
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ RUN chmod +x /bin/ripmime \
|
||||||
&& a2enmod headers
|
&& a2enmod headers
|
||||||
|
|
||||||
# Copy site into place.
|
# Copy site into place.
|
||||||
ADD php/ /var/www/cmc-sales
|
ADD . /var/www/cmc-sales
|
||||||
ADD php/app/config/database_stg.php /var/www/cmc-sales/app/config/database.php
|
ADD app/config/database_stg.php /var/www/cmc-sales/app/config/database.php
|
||||||
RUN mkdir -p /var/www/cmc-sales/app/tmp
|
RUN mkdir -p /var/www/cmc-sales/app/tmp
|
||||||
RUN mkdir -p /var/www/cmc-sales/app/tmp/logs
|
RUN mkdir -p /var/www/cmc-sales/app/tmp/logs
|
||||||
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ Deploy to staging or production using the scripts in the `deploy/` directory:
|
||||||
|
|
||||||
**Deploy to Staging:**
|
**Deploy to Staging:**
|
||||||
```bash
|
```bash
|
||||||
./scripts/deploy/deploy-stg.sh
|
./deploy/deploy-stg.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
**Deploy to Production:**
|
**Deploy to Production:**
|
||||||
|
|
@ -88,8 +88,8 @@ Deploy to staging or production using the scripts in the `deploy/` directory:
|
||||||
|
|
||||||
**Rebuild without cache (useful after dependency changes):**
|
**Rebuild without cache (useful after dependency changes):**
|
||||||
```bash
|
```bash
|
||||||
./scripts/deploy/deploy-prod.sh --no-cache
|
./deploy/deploy-prod.sh --no-cache
|
||||||
./scripts/deploy/deploy-stg.sh --no-cache
|
./deploy/deploy-stg.sh --no-cache
|
||||||
```
|
```
|
||||||
|
|
||||||
### How Deployment Works
|
### How Deployment Works
|
||||||
|
|
|
||||||
0
php/app/.DS_Store → app/.DS_Store
vendored
0
php/app/.DS_Store → app/.DS_Store
vendored
|
|
@ -74,8 +74,8 @@ Cache::config('default', array(
|
||||||
));
|
));
|
||||||
|
|
||||||
Configure::write('email_directory', '/var/www/emails');
|
Configure::write('email_directory', '/var/www/emails');
|
||||||
Configure::write('pdf_directory', $basedir.'webroot/pdf/');
|
Configure::write('pdf_directory', $basedir.'/webroot/pdf/');
|
||||||
Configure::write('attachments_directory', $basedir.'webroot/attachments_files/');
|
Configure::write('attachments_directory', $basedir.'/webroot/attachments_files/');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -190,8 +190,6 @@ Configure::write('Tailscale.autoCreateUsers', false);
|
||||||
*/
|
*/
|
||||||
Configure::write('Tailscale.defaultAccessLevel', 'user');
|
Configure::write('Tailscale.defaultAccessLevel', 'user');
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timezone to Australian Eastern Time
|
|
||||||
* This handles both AEST and AEDT (daylight saving) automatically
|
|
||||||
*/
|
|
||||||
date_default_timezone_set('Australia/Sydney');
|
|
||||||
|
|
@ -40,82 +40,19 @@ class AttachmentsController extends AppController {
|
||||||
function add() {
|
function add() {
|
||||||
if (!empty($this->data)) {
|
if (!empty($this->data)) {
|
||||||
|
|
||||||
// Check if file was uploaded
|
$attachment = $this->Attachment->process_attachment($this->data);
|
||||||
if (empty($this->data['Attachment']['file']['tmp_name'])) {
|
if(!$attachment) {
|
||||||
$error = 'No file uploaded';
|
$this->Session->setFlash('The Attachment could not be saved. The filename exists');
|
||||||
if (isset($this->data['Attachment']['file']['error'])) {
|
|
||||||
$errorCodes = array(
|
|
||||||
UPLOAD_ERR_INI_SIZE => 'File exceeds upload_max_filesize',
|
|
||||||
UPLOAD_ERR_FORM_SIZE => 'File exceeds MAX_FILE_SIZE',
|
|
||||||
UPLOAD_ERR_PARTIAL => 'File only partially uploaded',
|
|
||||||
UPLOAD_ERR_NO_FILE => 'No file was uploaded',
|
|
||||||
UPLOAD_ERR_NO_TMP_DIR => 'Missing temporary folder',
|
|
||||||
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk',
|
|
||||||
UPLOAD_ERR_EXTENSION => 'File upload stopped by extension',
|
|
||||||
);
|
|
||||||
$errorCode = $this->data['Attachment']['file']['error'];
|
|
||||||
$error = isset($errorCodes[$errorCode]) ? $errorCodes[$errorCode] : 'Unknown error: ' . $errorCode;
|
|
||||||
}
|
|
||||||
$this->Session->setFlash(__('File upload error: ' . $error, true));
|
|
||||||
$principles = $this->Attachment->Principle->find('list');
|
|
||||||
$this->set(compact('products', 'principles'));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$this->Attachment->create();
|
||||||
|
|
||||||
// Proxy the upload request to the Go application
|
if ($this->Attachment->save($attachment)) {
|
||||||
$goHost = getenv('GO_APP_HOST');
|
|
||||||
$goUrl = 'http://' . $goHost . '/go/attachments/upload';
|
|
||||||
|
|
||||||
// Prepare the multipart form data for the Go app
|
|
||||||
$postFields = array();
|
|
||||||
|
|
||||||
$postFields['file'] = new CURLFile(
|
|
||||||
$this->data['Attachment']['file']['tmp_name'],
|
|
||||||
$this->data['Attachment']['file']['type'],
|
|
||||||
$this->data['Attachment']['file']['name']
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!empty($this->data['Attachment']['name'])) {
|
|
||||||
$postFields['name'] = $this->data['Attachment']['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($this->data['Attachment']['description'])) {
|
|
||||||
$postFields['description'] = $this->data['Attachment']['description'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($this->data['Attachment']['principle_id'])) {
|
|
||||||
$postFields['principle_id'] = $this->data['Attachment']['principle_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the request to Go app
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $goUrl);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
||||||
'Accept: application/json'
|
|
||||||
));
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
$curlError = curl_error($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
if ($httpCode == 201) {
|
|
||||||
$this->Session->setFlash(__('The Attachment has been saved', true));
|
$this->Session->setFlash(__('The Attachment has been saved', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
} else {
|
} else {
|
||||||
$errorMsg = 'The Attachment could not be saved.';
|
$this->Session->setFlash(__('The Attachment could not be saved. Please, try again.', true));
|
||||||
if ($curlError) {
|
|
||||||
$errorMsg .= ' cURL Error: ' . $curlError;
|
|
||||||
} elseif ($response) {
|
|
||||||
$errorMsg .= ' Response: ' . $response;
|
|
||||||
} else {
|
|
||||||
$errorMsg .= ' HTTP Code: ' . $httpCode;
|
|
||||||
}
|
}
|
||||||
error_log('Attachment upload failed: ' . $errorMsg);
|
|
||||||
$this->Session->setFlash(__($errorMsg, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$principles = $this->Attachment->Principle->find('list');
|
$principles = $this->Attachment->Principle->find('list');
|
||||||
|
|
@ -541,10 +541,6 @@ ENDINSTRUCTIONS;
|
||||||
$newDoc['Document']['revision'] = $number_of_revisions;
|
$newDoc['Document']['revision'] = $number_of_revisions;
|
||||||
$newDoc['Document']['type'] = 'quote';
|
$newDoc['Document']['type'] = 'quote';
|
||||||
|
|
||||||
// user_id for the new revision will be the current user
|
|
||||||
$currentUser = $this->GetCurrentUser();
|
|
||||||
$newDoc['Document']['user_id'] = $currentUser['User']['id'];
|
|
||||||
|
|
||||||
|
|
||||||
$newDoc['DocPage'] = $document['DocPage'];
|
$newDoc['DocPage'] = $document['DocPage'];
|
||||||
|
|
||||||
|
|
@ -600,6 +596,7 @@ ENDINSTRUCTIONS;
|
||||||
// Store job IDs to be processed after the main save
|
// Store job IDs to be processed after the main save
|
||||||
$newDoc['_job_ids'] = $job_ids;
|
$newDoc['_job_ids'] = $job_ids;
|
||||||
}
|
}
|
||||||
|
print_r($newDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -15,17 +15,8 @@ class EmailAttachmentsController extends AppController {
|
||||||
|
|
||||||
$file = $this->EmailAttachment->findById($id);
|
$file = $this->EmailAttachment->findById($id);
|
||||||
|
|
||||||
// Try legacy emails directory first (where vault saves files)
|
$file_path = Configure::read('email_directory');
|
||||||
$file_path = '/var/www/emails';
|
if(file_exists($file_path."/".$file['EmailAttachment']['name'])) {
|
||||||
$full_path = $file_path."/".$file['EmailAttachment']['name'];
|
|
||||||
|
|
||||||
// Fallback to attachments directory if not found in emails
|
|
||||||
if(!file_exists($full_path)) {
|
|
||||||
$file_path = Configure::read('attachments_directory');
|
|
||||||
$full_path = $file_path."/".$file['EmailAttachment']['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(file_exists($full_path)) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,13 +33,12 @@ class EmailAttachmentsController extends AppController {
|
||||||
header('Content-length: ' . $file['EmailAttachment']['size']);
|
header('Content-length: ' . $file['EmailAttachment']['size']);
|
||||||
header('Content-Disposition: attachment; filename='.$filename);
|
header('Content-Disposition: attachment; filename='.$filename);
|
||||||
|
|
||||||
readfile($full_path);
|
readfile($file_path."/".$file['EmailAttachment']['name']);
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "ERROR: File Not Found";
|
echo "ERROR!! : File Not Found";
|
||||||
echo '\n';
|
|
||||||
echo $file['EmailAttachment']['filename'];
|
echo $file['EmailAttachment']['filename'];
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
@ -65,17 +55,9 @@ class EmailAttachmentsController extends AppController {
|
||||||
$file = $this->EmailAttachment->find('first', array('conditions'=>array('EmailAttachment.id'=>$id)));
|
$file = $this->EmailAttachment->find('first', array('conditions'=>array('EmailAttachment.id'=>$id)));
|
||||||
//$this->set('attachment', $file);
|
//$this->set('attachment', $file);
|
||||||
|
|
||||||
// Try legacy emails directory first (where vault saves files)
|
$file_path = Configure::read('email_directory');
|
||||||
$file_path = '/var/www/emails';
|
|
||||||
$full_path = $file_path."/".$file['EmailAttachment']['name'];
|
|
||||||
|
|
||||||
// Fallback to attachments directory if not found in emails
|
$contents = file_get_contents($file_path."/".$file['EmailAttachment']['name']);
|
||||||
if(!file_exists($full_path)) {
|
|
||||||
$file_path = Configure::read('attachments_directory');
|
|
||||||
$full_path = $file_path."/".$file['EmailAttachment']['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$contents = file_get_contents($full_path);
|
|
||||||
|
|
||||||
|
|
||||||
if($file['EmailAttachment']['type'] == 'text/plain') {
|
if($file['EmailAttachment']['type'] == 'text/plain') {
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue