diff --git a/html/webapp/modules/pm/components/Action.class.php b/html/webapp/modules/pm/components/Action.class.php
index eac672b..64869ce 100755
--- a/html/webapp/modules/pm/components/Action.class.php
+++ b/html/webapp/modules/pm/components/Action.class.php
@@ -276,6 +276,14 @@ function setMessage()
if(!$this->_db->updateExecute("uploads", $params, "upload_id", true)) {
return false;
}
+ //アップロードファイルの参照を複数のメッセージ間で共有可能にする add by horiguchi@horitada.info
+ $messageUploadsParams = array(
+ "message_id" => $message_id,
+ "upload_id" => $upload_id
+ );
+ if(!$this->_db->insertExecute("pm_message_uploads", $messageUploadsParams, true)) {
+ return false;
+ }
}
}
diff --git a/html/webapp/modules/pm/components/View.class.php b/html/webapp/modules/pm/components/View.class.php
index d8ec749..d463d8d 100755
--- a/html/webapp/modules/pm/components/View.class.php
+++ b/html/webapp/modules/pm/components/View.class.php
@@ -1288,14 +1288,22 @@ function getUploadOwner($upload_id = 0){
function &getUploadReaders($upload_id = 0){
$readers = array();
+ //アップロードファイルの参照を複数のメッセージ間で共有可能にする add by horiguchi@horitada.info
$params = array(
+ $upload_id,
$upload_id
);
-
- $sql = "SELECT r.receiver_user_id ".
- "FROM {pm_message_receiver} as r, {uploads} as u ".
- "WHERE u.unique_id = r.message_id ".
- "AND u.upload_id = ?";
+ $sql = "( ".
+ "SELECT r.receiver_user_id ".
+ "FROM {pm_message_receiver} r ".
+ "LEFT JOIN {uploads} u ON u.unique_id = r.message_id ".
+ "WHERE u.upload_id = ? ".
+ ") UNION ( ".
+ "SELECT r.receiver_user_id ".
+ "FROM {pm_message_receiver} r ".
+ "LEFT JOIN {pm_message_uploads} mu ON mu.message_id = r.message_id ".
+ "WHERE mu.upload_id = ? ".
+ ") ";
$records = $this->_db->execute($sql, $params, null, null, true, null);
if ($records === false) {
diff --git a/html/webapp/modules/pm/install.ini b/html/webapp/modules/pm/install.ini
index 8b90f23..f669a5e 100755
--- a/html/webapp/modules/pm/install.ini
+++ b/html/webapp/modules/pm/install.ini
@@ -1,4 +1,4 @@
-version = "2.4.2.1"
+version = "2.4.2.1-osws20161111"
action_name="pm_view_main_init"
delete_action = "pm_action_admin_operation"
module_update_action="pm_update"
diff --git a/html/webapp/modules/pm/sql/mysql/table.sql b/html/webapp/modules/pm/sql/mysql/table.sql
index a573de5..19682b0 100644
--- a/html/webapp/modules/pm/sql/mysql/table.sql
+++ b/html/webapp/modules/pm/sql/mysql/table.sql
@@ -172,3 +172,11 @@ CREATE TABLE `pm_forward` (
PRIMARY KEY (`forward_id`),
INDEX pm_forward_insert_user_id (insert_user_id)
) ENGINE=MyISAM;
+
+-- -
+-- テーブルの構造 `pm_message_uploads`
+-- -
+CREATE TABLE `pm_message_uploads` (
+ `message_id` int(11) unsigned NOT NULL,
+ `upload_id` int(11) unsigned NOT NULL
+) ENGINE=MyISAM;
diff --git a/html/webapp/modules/pm/update/Update.class.php b/html/webapp/modules/pm/update/Update.class.php
index 7d0b95e..2cae958 100644
--- a/html/webapp/modules/pm/update/Update.class.php
+++ b/html/webapp/modules/pm/update/Update.class.php
@@ -77,6 +77,21 @@ function execute()
$result = $this->db->execute($sql);
if($result === false) return false;
}
+
+ //アップロードファイルの参照を複数のメッセージ間で共有可能にする add by horiguchi@horitada.info
+ $adodb = $this->db->getAdoDbObject();
+ $metaTables = $adodb->MetaTables();
+ if (!in_array($this->db->getPrefix()."pm_message_uploads", $metaTables)) {
+ $sql = "CREATE TABLE `".$this->db->getPrefix()."pm_message_uploads` (" .
+ "`message_id` int(11) UNSIGNED NOT NULL,".
+ "`upload_id` int(11) UNSIGNED NOT NULL ".
+ ") TYPE=MyISAM;";
+ $result = $this->db->execute($sql);
+ if ($result === false) {
+ return false;
+ }
+ }
+
return true;
}
}