OSDN Git Service

送信済みメール一覧機能
authorCake <cake_67@users.sourceforge.jp>
Thu, 23 Dec 2010 06:31:13 +0000 (15:31 +0900)
committerCake <cake_67@users.sourceforge.jp>
Thu, 23 Dec 2010 06:31:13 +0000 (15:31 +0900)
12 files changed:
app/controllers/send_mails_controller.php
app/locale/jpn/LC_MESSAGES/default.po
app/models/send_mail.php
app/views/character_pictures/admin_listview.ctp
app/views/elements/character_sheet_index.ctp
app/views/elements/sidenav_admin_user.ctp
app/views/elements/sidenav_config.ctp
app/views/layouts/admin_default.ctp
app/views/layouts/default.ctp
app/views/send_mails/contact.ctp
app/webroot/css/base.css
app/webroot/css/character-sheet.css

index 19acf4f..7720526 100644 (file)
@@ -22,10 +22,11 @@ class SendMailsController extends AppController {
                'recursive' => 1,
                'contain' => array(
                        'User',
+                       'FromUser',
                ),
                'limit' => 20,
                'order' => array(
-                       'SendMails.modified' => 'asc'
+                       'SendMail.modified' => 'desc'
                ),
        );
 
@@ -96,12 +97,21 @@ class SendMailsController extends AppController {
                if (!empty($this->data)) {
                        $postdata = $this->data;
 
+                       $this->data['SendMail']['user_id'] = 1;
+
+                       if (!empty($this->user_id)) {
+                               $this->data['SendMail']['from_user_id'] = $this->user_id;
+                       }
+
+                       $this->data['SendMail']['useragent'] = $_SERVER["HTTP_USER_AGENT"];
+                       $this->data['SendMail']['host'] = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
+
                        $this->SendMail->set($this->data);
                        if ($this->SendMail->validates()) {
                        
                                $from = $this->data['SendMail']['from'];
                                $this->data['SendMail']['from'] = $this->Crypt->crypt($this->data['SendMail']['from']);
-                               $this->data['SendMail']['subject'] = $this->data['SendMail']['subject']. sprintf(__('[%s %s] ', true), $this->site_configs['Site.siteName']['value'], __('Contact', true));
+                               $this->data['SendMail']['subject'] = sprintf(__('[%s %s] ', true), $this->site_configs['Site.siteName']['value'], __('Contact', true)). $this->data['SendMail']['subject'];
 
                                $this->SendMail->create();
                                if ($this->SendMail->save($this->data, array('fieldList' => $this->SendMail->fields['add'], 'validate' => false))) {
@@ -137,15 +147,15 @@ class SendMailsController extends AppController {
 
        function admin_index() {
                $this->SendMail->recursive = 0;
-               $this->set('sendMails', $this->paginate());
-       }
-       function admin_view($id = null) {
-               if (!$id) {
-                       $this->Session->setFlash(__('Invalid send mail', true));
-                       $this->redirect(array('action' => 'index'));
+
+               $send_mails = $this->paginate();
+               foreach ($send_mails as $k => $v) {
+                       $send_mails[$k] = $this->_restore_html_sendmail($v);
                }
-               $this->set('sendMail', $this->SendMail->read(null, $id));
+
+               $this->set('sendMails', $send_mails);
        }
+
        function admin_delete($id = null) {
                if (!$id) {
                        $this->Session->setFlash(__('Invalid id for send mail', true));
@@ -172,4 +182,24 @@ class SendMailsController extends AppController {
 
                        return true;
                }
+
+               function _restore_html_sendmail($data, $nl2br = false) {
+                       if (isset($data['SendMail']['from']) && !empty($data['SendMail']['from'])) {
+                               $data['SendMail']['from'] = $this->Crypt->decrypt($data['SendMail']['from']);
+                       }
+
+                       if (isset($data['User']['pcmail']) && !empty($data['User']['pcmail'])) {
+                               $data['User']['pcmail'] = $this->Crypt->decrypt($data['User']['pcmail']);
+                       }
+                       if (isset($data['FromUser']['pcmail']) && !empty($data['FromUser']['pcmail'])) {
+                               $data['FromUser']['pcmail'] = $this->Crypt->decrypt($data['FromUser']['pcmail']);
+                       }
+
+                       $data['SendMail']['body'] = $this->{$this->modelClass}->restore_html($data['SendMail']['body'], false, false, false);
+                       if ($nl2br) {
+                               $data['SendMail']['body'] = str_replace('<br />', "\n", $data['SendMail']['body']);
+                       }
+
+                       return $data;
+               }
 }
index d67cf2a..32edcc2 100644 (file)
@@ -1291,18 +1291,16 @@ msgstr "システム一覧"
 msgid "Add New System"
 msgstr "システム作成"
 
-#: /views/elements/admin_user_sidenav.ctp:2
-msgid "List of Users"
-msgstr "ユーザ一覧"
+msgid "Mail Registing List"
+msgstr "メール登録中一覧"
+
+msgid "Mail Sended List"
+msgstr "メール送信一覧"
 
 #: /views/elements/admin_user_sidenav.ctp:3
 msgid "Add New User"
 msgstr "ユーザ作成"
 
-#: /views/elements/admin_user_sidenav.ctp:3
-msgid "List of Mail Registing"
-msgstr "メール登録中一覧"
-
 #: /views/elements/character_picture_index.ctp:9
 msgid "%s's Pictures"
 msgstr "%sの画像一覧"
@@ -2444,10 +2442,6 @@ msgstr "アカウントを削除すると、あなたの全キャラクターも
 msgid "Please input your password, if you want to delete your account."
 msgstr "本当に削除するならば、確認のためにパスワードを入力して下さい。"
 
-#: /views/users/listview.ctp:2
-msgid "List Users"
-msgstr "ユーザ一覧"
-
 #: /views/users/login.ctp:
 msgid "Registration"
 msgstr "ユーザ登録"
@@ -2510,3 +2504,18 @@ msgstr "送信"
 
 msgid "Rewrite"
 msgstr "修正"
+
+msgid "No Logged-in"
+msgstr "ログインなし"
+
+msgid "Send Mails"
+msgstr "送信済みメール"
+
+msgid "From"
+msgstr "送信者"
+
+msgid "From Address"
+msgstr "送信者アドレス"
+
+msgid "Receive"
+msgstr "受信者"
index aa8bbd2..6abb4b9 100644 (file)
@@ -3,7 +3,7 @@ class SendMail extends AppModel {
        var $name = 'SendMail';
 
        var $fields = array(
-               'add' => array('from', 'subject', 'body'),
+               'add' => array('user_id', 'from', 'from_user_id', 'subject', 'body', 'useragent', 'host'),
                'escape' => array(
                        'subject' => array(
                                'html' => true,
@@ -13,7 +13,8 @@ class SendMail extends AppModel {
                        'body' => array(
                                'html' => true,
                                'tags' => true,
-                               'all' => true,
+                               'images' => true,
+                               'sctipts' => true,
                        ),
                ),
        );
@@ -53,9 +54,9 @@ class SendMail extends AppModel {
                        'className' => 'User',
                        'foreignKey' => 'from_user_id',
                        'fields' => array(
-                               'User.id', 
-                               'User.name',
-                               'User.pcmail'
+                               'FromUser.id', 
+                               'FromUser.name',
+                               'FromUser.pcmail'
                        ),
                ),
        );
index 2acd860..43cdcdf 100644 (file)
@@ -60,7 +60,7 @@ foreach ($characterPictures as $characterPicture):
 <div class="actions">
        <ul>
                <li><?php echo $html->link(__('New CharacterPicture', true), array('action' => 'add')); ?></li>
-               <li><?php echo $html->link(__('List Users', true), array('controller' => 'users', 'action' => 'index')); ?> </li>
+               <li><?php echo $html->link(__('Users List', true), array('controller' => 'users', 'action' => 'index')); ?> </li>
                <li><?php echo $html->link(__('New User', true), array('controller' => 'users', 'action' => 'add')); ?> </li>
                <li><?php echo $html->link(__('List Characters', true), array('controller' => 'characters', 'action' => 'index')); ?> </li>
                <li><?php echo $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add')); ?> </li>
index 5f2296e..66ef370 100644 (file)
@@ -15,7 +15,7 @@
 <?php endif; ?>
 <?php __('List of All CharacterSheets');?>
 </h2>
-</h2></div>
+</span></div>
 <div class="boxBody">
 <p>
 <?php
index de2707e..162faac 100644 (file)
@@ -1,5 +1,6 @@
 <ul>
-<li><?php echo $html->link(__('List of Users', true), array('controller' => 'users', 'action' => 'listview', 'prefix' => Configure::read('Routing.prefixes'))); ?></li>
+<li><?php echo $html->link(__('Users List', true), array('controller' => 'users', 'action' => 'listview', 'prefix' => Configure::read('Routing.prefixes'))); ?></li>
 <li><?php echo $html->link(__('Add New User', true), array('controller' => 'users', 'action' => 'add', 'prefix' => Configure::read('Routing.prefixes'))); ?></li>
-<li><?php echo $html->link(__('List of Mail Registing', true), array('controller' => 'regist_mails', 'prefix' => Configure::read('Routing.prefixes'))); ?></li>
+<li><?php echo $html->link(__('Mail Sended List', true), array('controller' => 'send_mails', 'prefix' => Configure::read('Routing.prefixes'))); ?></li>
+<li><?php echo $html->link(__('Mail Registing List', true), array('controller' => 'regist_mails', 'prefix' => Configure::read('Routing.prefixes'))); ?></li>
 </ul>
index 7f4ffbc..c067d52 100644 (file)
@@ -1,5 +1,5 @@
 <ul>
-       <li><?php echo $html->link(__('List of Users', true), array('controller' => 'users', 'action' => 'listview')); ?> </li>
+       <li><?php echo $html->link(__('Users List', true), array('controller' => 'users', 'action' => 'listview')); ?> </li>
        <li><?php echo $html->link(__('Edit User', true), array('controller' => 'users', 'action' => 'edit')); ?> </li>
        <li><?php echo $html->link(__('Edit Image', true), array('controller' => 'users', 'action' => 'edit_image')); ?> </li>
        <li><?php echo $html->link(__('Regist Mail', true), array('controller' => 'regist_mails', 'action' => 'add')); ?> </li>
index fea9b25..7371380 100644 (file)
@@ -128,6 +128,7 @@ echo $this->element('sidenav_admin_user', array(
 switch ($this->params["controller"]) {
        case 'users':
        case 'regist_mails':
+       case 'send_mails':
                echo $this->element('sidenav_admin_user', array());
                break;
        case 'systems':
index 790696d..7e725cd 100644 (file)
@@ -167,6 +167,7 @@ switch ($this->params["controller"]) {
                }
                break;
        case 'regist_mails':
+       case 'send_mails':
                        if ($user['User']['id']) {
                                echo $this->element('sidenav_config', array());
                        }
index ca1579f..b81118e 100644 (file)
@@ -8,10 +8,14 @@
        <fieldset>
                <legend><?php __('Contact Mail'); ?></legend>
        <?php
+               $usermail = null;
+               if (isset($user['User']['pcmail'])) {
+                       $usermail = $user['User']['pcmail'];
+               }
                echo $form->input('from', array(
                        'type' => 'text',
                        'label' =>  __('Your Address', true),
-                       'value' => $user['User']['pcmail'],
+                       'value' => $usermail,
                        'class' => 'longInput',
                ));
                echo $form->input('subject', array(
index 3444192..b5027bd 100644 (file)
@@ -604,13 +604,9 @@ div.admin_listview table
 }
 
 td.lastAccess,
-td.modified,
-td.userAgent {
+td.modified {
        white-space: normal;
 }
-td.userAgent {
-       width: 200px;
-}
 
 div.siteConfigs
 {
index a929718..c1d67d8 100644 (file)
@@ -164,7 +164,7 @@ div.view div.attachments {
 .boxBody div.publicFlag {
        width: auto;
 }
-/* 立ち絵 */
+/* 背景画像 */
 .fullLength {
        height:100%;
        min-height:100%;
@@ -307,7 +307,8 @@ span.paging form .submit input[type="submit"] {
 
 /* ユーザ一覧 */
 #Users_admin_search table th,
-#Users_admin_listview table th {
+#Users_admin_listview table th,
+#SendMails_admin_index table th {
        white-space: nowrap;
 }
 .users .characterList {
@@ -331,6 +332,13 @@ span.paging form .submit input[type="submit"] {
        top: -4px;
        left: 5px;
 }
+div.UserAgent,
+div.Host {
+       font-size: 80%;
+       text-align: right;
+       color: #999;
+}
+
 
 /* 履歴一覧 */
 dl#ArchiveList {