• R/O
  • SSH
  • HTTPS

necosuke-lpo: Commit


Commit MetaInfo

Revisão26 (tree)
Hora2008-07-07 14:44:47
Autorjunkikuchi

Mensagem de Log

今月の利用状況グラフが今月分のデータを表示していなかった不具合を修正
LPO や表示条件、コンテンツの取得ををアカウントオブジェクト経由に修正

Mudança Sumário

Diff

--- trunk/application/models/Account.php (revision 25)
+++ trunk/application/models/Account.php (revision 26)
@@ -96,4 +96,36 @@
9696
9797 public function getConversionLpoRows($url) {
9898 }
99+
100+ public function getLpo($lpo_id) {
101+ $lpo_t = new Lpo();
102+
103+ return $lpo_t->fetchRow(
104+ $lpo_t->select()
105+ ->where('account_id = ?', $this->id)
106+ ->where('id = ?', $lpo_id)
107+ );
108+ }
109+
110+ public function getCondition($condition_id) {
111+ $condition_t = new Condition();
112+ $condition = $condition_t->find($condition_id)->current();
113+
114+ if($condition && $this->getLpo($condition->lpo_id)) {
115+ return $condition;
116+ } else {
117+ return null;
118+ }
119+ }
120+
121+ public function getContent($content_id) {
122+ $content_t = new Content();
123+ $content = $content_t->find($content_id)->current();
124+
125+ if($content && $this->getCondition($content->condition_id)) {
126+ return $content;
127+ } else {
128+ return null;
129+ }
130+ }
99131 }
--- trunk/application/models/Log.php (revision 25)
+++ trunk/application/models/Log.php (revision 26)
@@ -158,7 +158,11 @@
158158 }
159159
160160 public function getUsage() {
161- $row = $this->fetchRow($this->select()->from($this, 'COUNT(*) AS count'));
161+ $row = $this->fetchRow(
162+ $this->select()
163+ ->from($this, 'COUNT(*) AS count')
164+ ->where("date_format(`date`, '%Y%m') = date_format(now(), '%Y%m')")
165+ );
162166 return $row->count;
163167 }
164168 }
--- trunk/application/controllers/IndexController.php (revision 25)
+++ trunk/application/controllers/IndexController.php (revision 26)
@@ -376,7 +376,10 @@
376376 $id = $this->getRequest()->getParam('id');
377377
378378 $lpo_t = new Lpo();
379- $lpo = $lpo_t->find($id)->current();
379+ $lpo = $this->acct->getLpo($id);
380+ if(!$lpo) {
381+ $this->_redirect('/');
382+ }
380383
381384 $this->view->action = $this->getRequest()->getParam('action');
382385 $this->view->chart = $this->getChartParam();
@@ -422,7 +425,7 @@
422425 }
423426
424427 $lpo_t = new Lpo();
425- $lpo = $lpo_t->createRow();
428+ $lpo = $lpo_t->createRow();
426429 if($form->getElement('active')->getValue()) {
427430 $lpo->status = 'active';
428431 } else {
@@ -446,8 +449,10 @@
446449
447450 $id = $this->getRequest()->getParam('id');
448451
449- $lpo_t = new Lpo();
450- $lpo = $lpo_t->find($id)->current();
452+ $lpo = $this->acct->getLpo($id);
453+ if(!$lpo) {
454+ $this->_redirect('/');
455+ }
451456
452457 $form = $this->getLpoForm();
453458 $form->setAction('/index/lpo-update-submit/id/' . $id);
@@ -481,8 +486,11 @@
481486 return $this->render('lpo-update');
482487 }
483488
484- $lpo_t = new Lpo();
485- $lpo = $lpo_t->find($id)->current();
489+ $lpo = $this->acct->getLpo($id);
490+ if(!$lpo) {
491+ $this->_redirect('/');
492+ }
493+
486494 if($form->getElement('active')->getValue()) {
487495 $lpo->status = 'active';
488496 } else {
@@ -505,8 +513,10 @@
505513
506514 $id = $this->getRequest()->getParam('id');
507515
508- $lpo_t = new Lpo();
509- $lpo = $lpo_t->find($id)->current();
516+ $lpo = $this->acct->getLpo($id);
517+ if(!$lpo) {
518+ $this->_redirect('/');
519+ }
510520
511521 $form = $this->getDeleteForm();
512522 $form->setAction('/index/lpo-delete-submit/id/' . $id);
@@ -537,8 +547,11 @@
537547 $db = Zend_Db_Table_Abstract::getDefaultAdapter();
538548 $db->beginTransaction();
539549 try {
540- $lpo_t = new Lpo();
541- $lpo = $lpo_t->find($id)->current();
550+ $lpo = $this->acct->getLpo($id);
551+ if(!$lpo) {
552+ $this->_redirect('/');
553+ }
554+
542555 $lpo->del();
543556 $lpo->save();
544557
@@ -710,7 +723,10 @@
710723 $id = $this->getRequest()->getParam('id');
711724
712725 $condition_t = new Condition();
713- $condition = $condition_t->find($id)->current();
726+ $condition = $this->acct->getCondition($id);
727+ if(!$condition) {
728+ $this->_redirect('/');
729+ }
714730
715731 $this->view->chart = $this->getChartParam();
716732 $this->view->date = $this->getDateParam()->toString('YYYY-MM-dd');
@@ -731,8 +747,10 @@
731747
732748 $id = $this->getRequest()->getParam('id');
733749
734- $lpo_t = new Lpo();
735- $lpo = $lpo_t->find($id)->current();
750+ $lpo = $this->acct->getLpo($id);
751+ if(!$lpo) {
752+ $this->_redirect('/');
753+ }
736754
737755 $form = $this->getConditionForm();
738756 $form->setAction('/index/lpo-condition-create-submit/id/' . $id);
@@ -749,6 +767,11 @@
749767
750768 $id = $this->getRequest()->getParam('id');
751769
770+ $lpo = $this->acct->getLpo($id);
771+ if(!$lpo) {
772+ $this->_redirect('/');
773+ }
774+
752775 if(!$this->getRequest()->isPost()) {
753776 return $this->_forward('lpo-condition-create');
754777 }
@@ -784,8 +807,10 @@
784807
785808 $id = $this->getRequest()->getParam('id');
786809
787- $condition_t = new Condition();
788- $condition = $condition_t->find($id)->current();
810+ $condition = $this->acct->getCondition($id);
811+ if(!$condition) {
812+ $this->_redirect('/');
813+ }
789814
790815 switch($this->getRequest()->getParam('priority')) {
791816 case 'up':
@@ -827,8 +852,11 @@
827852 return $this->render('lpo-condition-update');
828853 }
829854
830- $condition_t = new Condition();
831- $condition = $condition_t->find($id)->current();
855+ $condition = $this->acct->getCondition($id);
856+ if(!$condition) {
857+ $this->_redirect('/');
858+ }
859+
832860 if($form->getElement('active')->getValue()) {
833861 $condition->status = 'active';
834862 } else {
@@ -849,8 +877,10 @@
849877
850878 $id = $this->getRequest()->getParam('id');
851879
852- $condition_t = new Condition();
853- $condition = $condition_t->find($id)->current();
880+ $condition = $this->acct->getCondition($id);
881+ if(!$condition) {
882+ $this->_redirect('/');
883+ }
854884
855885 $form = $this->getDeleteForm();
856886 $form->setAction('/index/lpo-condition-delete-submit/id/' . $id);
@@ -882,8 +912,11 @@
882912 $db = Zend_Db_Table_Abstract::getDefaultAdapter();
883913 $db->beginTransaction();
884914 try {
885- $condition_t = new Condition();
886- $condition = $condition_t->find($id)->current();
915+ $condition = $this->acct->getCondition($id);
916+ if(!$condition) {
917+ $this->_redirect('/');
918+ }
919+
887920 $condition->del();
888921 $condition->save();
889922
@@ -915,8 +948,10 @@
915948
916949 $id = $this->getRequest()->getParam('id');
917950
918- $content_t = new Content();
919- $content = $content_t->find($id)->current();
951+ $content = $this->acct->getContent($id);
952+ if(!$content) {
953+ $this->_redirect('/');
954+ }
920955
921956 $condition = $content->findParentRow('Condition');
922957 $lpo = $condition->findParentRow('Lpo');
@@ -936,8 +971,10 @@
936971
937972 $id = $this->getRequest()->getParam('id');
938973
939- $condition_t = new Condition();
940- $condition = $condition_t->find($id)->current();
974+ $condition = $this->acct->getCondition($id);
975+ if(!$condition) {
976+ $this->_redirect('/');
977+ }
941978
942979 $this->view->action = $this->getRequest()->getParam('action');
943980 $this->view->lpo = $condition->findParentRow('Lpo');
@@ -958,10 +995,13 @@
958995
959996 $id = $this->getRequest()->getParam('id');
960997
961- $condition_t = new Condition();
962- $condition = $condition_t->find($id)->current();
963- $lpo = $condition->findParentRow('Lpo');
998+ $condition = $this->acct->getCondition($id);
999+ if(!$condition) {
1000+ $this->_redirect('/');
1001+ }
9641002
1003+ $lpo = $condition->findParentRow('Lpo');
1004+
9651005 $this->view->action = $this->getRequest()->getParam('action');
9661006 $this->view->lpo = $lpo;
9671007 $this->view->condition = $condition;
@@ -1002,8 +1042,10 @@
10021042
10031043 $id = $this->getRequest()->getParam('id');
10041044
1005- $content_t = new Content();
1006- $content = $content_t->find($id)->current();
1045+ $content = $this->acct->getContent($id);
1046+ if(!$content) {
1047+ $this->_redirect('/');
1048+ }
10071049 $condition = $content->findParentRow('Condition');
10081050 $lpo = $condition->findParentRow('Lpo');
10091051
@@ -1040,8 +1082,11 @@
10401082 return $this->render('lpo-content-update');
10411083 }
10421084
1043- $content_t = new Content();
1044- $content = $content_t->find($id)->current();
1085+ $content = $this->acct->getContent($id);
1086+ if(!$content) {
1087+ $this->_redirect('/');
1088+ }
1089+
10451090 if($form->getElement('active')->getValue()) {
10461091 $content->status = 'active';
10471092 } else {
@@ -1063,8 +1108,10 @@
10631108
10641109 $id = $this->getRequest()->getParam('id');
10651110
1066- $content_t = new Content();
1067- $content = $content_t->find($id)->current();
1111+ $content = $this->acct->getContent($id);
1112+ if(!$content) {
1113+ $this->_redirect('/');
1114+ }
10681115 $condition = $content->findParentRow('Condition');
10691116 $lpo = $condition->findParentRow('Lpo');
10701117
@@ -1099,8 +1146,10 @@
10991146 $db = Zend_Db_Table_Abstract::getDefaultAdapter();
11001147 $db->beginTransaction();
11011148 try {
1102- $content_t = new Content();
1103- $content = $content_t->find($id)->current();
1149+ $content = $this->acct->getContent($id);
1150+ if(!$content) {
1151+ $this->_redirect('/');
1152+ }
11041153 $content->del();
11051154 $content->save();
11061155
@@ -1130,8 +1179,10 @@
11301179 $this->_helper->layout->disableLayout();
11311180
11321181 $id = $this->getRequest()->getParam('id');
1133- $content_t = new Content();
1134- $content = $content_t->find($id)->current();
1182+ $content = $this->acct->getContent($id);
1183+ if(!$content) {
1184+ $this->_redirect('/');
1185+ }
11351186
11361187 $this->view->content = $content;
11371188 }
@@ -1170,8 +1221,6 @@
11701221 return $this->_forward('account-update');
11711222 }
11721223
1173- $id = $this->getRequest()->getParam('id');
1174-
11751224 $form = $this->getAccountForm();
11761225
11771226 if(!$form->isValid($_POST)) {
Show on old repository browser