Changeset 74
- Timestamp:
- 02/24/06 14:55:52 (3 years ago)
- Files:
-
- trunk/apps/frontend/config/databases.yml (modified) (1 diff)
- trunk/apps/frontend/config/settings.yml (modified) (2 diffs)
- trunk/apps/frontend/lib/helper/GlobalHelper.php (modified) (2 diffs)
- trunk/apps/frontend/modules/moderator/templates/reportedAnswersSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/moderator/templates/reportedQuestionsSuccess.php (modified) (1 diff)
- trunk/lib/model/om/BaseAnswer.php (modified) (13 diffs)
- trunk/lib/model/om/BaseAnswerPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseInterest.php (modified) (6 diffs)
- trunk/lib/model/om/BaseInterestPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseQuestion.php (modified) (22 diffs)
- trunk/lib/model/om/BaseQuestionPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseQuestionTag.php (modified) (6 diffs)
- trunk/lib/model/om/BaseQuestionTagPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseRelevancy.php (modified) (6 diffs)
- trunk/lib/model/om/BaseRelevancyPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseReportAnswer.php (modified) (6 diffs)
- trunk/lib/model/om/BaseReportAnswerPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseReportQuestion.php (modified) (6 diffs)
- trunk/lib/model/om/BaseReportQuestionPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseSearchIndex.php (modified) (6 diffs)
- trunk/lib/model/om/BaseSearchIndexPeer.php (modified) (3 diffs)
- trunk/lib/model/om/BaseUser.php (modified) (28 diffs)
- trunk/lib/model/om/BaseUserPeer.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/frontend/config/databases.yml
r71 r74 1 1 all: 2 default:2 symfony: 3 3 class: sfPropelDatabase 4 4 param: 5 datasource: symfony6 5 phptype: mysql 7 6 hostspec: localhost trunk/apps/frontend/config/settings.yml
r71 r74 33 33 i18n: on 34 34 35 use_database: on 36 35 37 # default_module: default 36 38 # default_action: index … … 61 63 # url_format: PATH 62 64 # 63 # use_database: off64 65 # 65 66 # use_security: on trunk/apps/frontend/lib/helper/GlobalHelper.php
r64 r74 29 29 30 30 // First and previous page 31 $navigation .= link_to(image_tag('first.gif', 'align=absmiddle'), $uri.'1'); 32 $navigation .= link_to(image_tag('previous.gif', 'align=absmiddle'), $uri.$pager->getPreviousPage()).' '; 33 31 if ($pager->getPage() != 1) 32 { 33 $navigation .= link_to(image_tag('first.gif', 'align=absmiddle'), $uri.'1'); 34 $navigation .= link_to(image_tag('previous.gif', 'align=absmiddle'), $uri.$pager->getPreviousPage()).' '; 35 } 36 34 37 // Pages one by one 35 38 $links = array(); … … 41 44 42 45 // Next and last page 43 $navigation .= ' '.link_to(image_tag('next.gif', 'align=absmiddle'), $uri.$pager->getNextPage()); 44 $navigation .= link_to(image_tag('last.gif', 'align=absmiddle'), $uri.$pager->getLastPage()); 46 if ($pager->getPage() != $pager->getCurrentMaxLink()) 47 { 48 $navigation .= ' '.link_to(image_tag('next.gif', 'align=absmiddle'), $uri.$pager->getNextPage()); 49 $navigation .= link_to(image_tag('last.gif', 'align=absmiddle'), $uri.$pager->getLastPage()); 50 } 51 45 52 } 46 53 trunk/apps/frontend/modules/moderator/templates/reportedAnswersSuccess.php
r64 r74 19 19 20 20 <div id="question_pager" class="right"> 21 <?php echo pager_navigation($answer_pager, ' @') ?>21 <?php echo pager_navigation($answer_pager, 'moderator/reportedAnswers') ?> 22 22 </div> trunk/apps/frontend/modules/moderator/templates/reportedQuestionsSuccess.php
r64 r74 17 17 18 18 <div id="question_pager" class="right"> 19 <?php echo pager_navigation($question_pager, ' @') ?>19 <?php echo pager_navigation($question_pager, 'moderator/reportedQuestions') ?> 20 20 </div> trunk/lib/model/om/BaseAnswer.php
r55 r74 608 608 609 609 /** 610 * Array of ValidationFailed objects. 611 * @var array ValidationFailed[] 612 */ 613 protected $validationFailures = array(); 614 615 /** 616 * Gets any ValidationFailed objects that resulted from last call to validate(). 617 * 618 * 619 * @return array ValidationFailed[] 620 * @see validate() 621 */ 622 public function getValidationFailures() 623 { 624 return $this->validationFailures; 625 } 626 627 /** 610 628 * Validates the objects modified field values and all objects related to this table. 611 629 * … … 614 632 * 615 633 * @param mixed $columns Column name or an array of column names. 616 * 617 * @return mixed <code>true</code> if all columns pass validation 618 * or an array of <code>ValidationFailed</code> objects for columns that fail. 634 * @return boolean Whether all columns pass validation. 619 635 * @see doValidate() 636 * @see getValidationFailures() 620 637 */ 621 638 public function validate($columns = null) 622 639 { 623 if ($columns) { 624 return AnswerPeer::doValidate($this, $columns); 625 } 626 return $this->doValidate(); 640 $res = $this->doValidate($columns); 641 if ($res === true) { 642 $this->validationFailures = array(); 643 return true; 644 } else { 645 $this->validationFailures = $res; 646 return false; 647 } 627 648 } 628 649 … … 634 655 * an aggreagated array of ValidationFailed objects will be returned. 635 656 * 657 * @param array $columns Array of column names to validate. 636 658 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 637 659 */ 638 protected function doValidate( )660 protected function doValidate($columns = null) 639 661 { 640 662 if (!$this->alreadyInValidation) { … … 651 673 652 674 if ($this->aQuestion !== null) { 653 if ( ($retval = $this->aQuestion->validate()) !== true) {654 $failureMap = array_merge($failureMap, $ retval);675 if (!$this->aQuestion->validate($columns)) { 676 $failureMap = array_merge($failureMap, $this->aQuestion->getValidationFailures()); 655 677 } 656 678 } 657 679 658 680 if ($this->aUser !== null) { 659 if ( ($retval = $this->aUser->validate()) !== true) {660 $failureMap = array_merge($failureMap, $ retval);681 if (!$this->aUser->validate($columns)) { 682 $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 661 683 } 662 684 } 663 685 664 686 665 if (($retval = AnswerPeer::doValidate($this )) !== true) {687 if (($retval = AnswerPeer::doValidate($this, $columns)) !== true) { 666 688 $failureMap = array_merge($failureMap, $retval); 667 689 } … … 670 692 if ($this->collRelevancys !== null) { 671 693 foreach($this->collRelevancys as $referrerFK) { 672 if ( ($retval = $referrerFK->validate()) !== true) {673 $failureMap = array_merge($failureMap, $re tval);694 if (!$referrerFK->validate($columns)) { 695 $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 674 696 } 675 697 } … … 678 700 if ($this->collReportAnswers !== null) { 679 701 foreach($this->collReportAnswers as $referrerFK) { 680 if ( ($retval = $referrerFK->validate()) !== true) {681 $failureMap = array_merge($failureMap, $re tval);702 if (!$referrerFK->validate($columns)) { 703 $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 682 704 } 683 705 } … … 702 724 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 703 725 { 704 $names = AnswerPeer::getFieldNames($type);705 726 $pos = AnswerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 706 727 return $this->getByPosition($pos); … … 789 810 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 790 811 { 791 $names = AnswerPeer::getFieldNames($type); 792 $pos = array_search($name, $names); 812 $pos = AnswerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 793 813 return $this->setByPosition($pos, $value); 794 814 } … … 961 981 962 982 foreach($this->getRelevancys() as $relObj) { 963 $copyObj->addRelevancy($relObj->copy($deepCopy)); 983 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 984 $copyObj->addRelevancy($relObj->copy($deepCopy)); 985 } 964 986 } 965 987 966 988 foreach($this->getReportAnswers() as $relObj) { 967 $copyObj->addReportAnswer($relObj->copy($deepCopy)); 989 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 990 $copyObj->addReportAnswer($relObj->copy($deepCopy)); 991 } 968 992 } 969 993 … … 1189 1213 * 1190 1214 * @param Criteria $criteria 1215 * @param boolean $distinct 1191 1216 * @param Connection $con 1192 1217 * @throws PropelException 1193 1218 */ 1194 public function countRelevancys($criteria = null, $ con = null)1219 public function countRelevancys($criteria = null, $distinct = false, $con = null) 1195 1220 { 1196 1221 // include the Peer class … … 1206 1231 $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); 1207 1232 1208 return RelevancyPeer::doCount($criteria, $ con);1233 return RelevancyPeer::doCount($criteria, $distinct, $con); 1209 1234 } 1210 1235 … … 1344 1369 * 1345 1370 * @param Criteria $criteria 1371 * @param boolean $distinct 1346 1372 * @param Connection $con 1347 1373 * @throws PropelException 1348 1374 */ 1349 public function countReportAnswers($criteria = null, $ con = null)1375 public function countReportAnswers($criteria = null, $distinct = false, $con = null) 1350 1376 { 1351 1377 // include the Peer class … … 1361 1387 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 1362 1388 1363 return ReportAnswerPeer::doCount($criteria, $ con);1389 return ReportAnswerPeer::doCount($criteria, $distinct, $con); 1364 1390 } 1365 1391 trunk/lib/model/om/BaseAnswerPeer.php
r55 r74 104 104 * @throws PropelException Any exceptions caught during processing will be 105 105 * rethrown wrapped into a PropelException. 106 * @ todo Consider having template build the array rather than doing it at runtime.106 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 107 107 */ 108 108 public static function getPhpNameMap() … … 169 169 public static function alias($alias, $column) 170 170 { 171 return $alias . substr($column, strlen(AnswerPeer::TABLE_NAME));171 return str_replace(AnswerPeer::TABLE_NAME.'.', $alias.'.', $column); 172 172 } 173 173 … … 1083 1083 } 1084 1084 1085 return BasePeer::doValidate(AnswerPeer::DATABASE_NAME, AnswerPeer::TABLE_NAME, $columns); 1085 $res = BasePeer::doValidate(AnswerPeer::DATABASE_NAME, AnswerPeer::TABLE_NAME, $columns); 1086 if ($res !== true) { 1087 $request = sfContext::getInstance()->getRequest(); 1088 foreach ($res as $failed) { 1089 $col = AnswerPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 1090 $request->setError($col, $failed->getMessage()); 1091 } 1092 } 1093 1094 return $res; 1086 1095 } 1087 1096 trunk/lib/model/om/BaseInterest.php
r16 r74 350 350 351 351 /** 352 * Array of ValidationFailed objects. 353 * @var array ValidationFailed[] 354 */ 355 protected $validationFailures = array(); 356 357 /** 358 * Gets any ValidationFailed objects that resulted from last call to validate(). 359 * 360 * 361 * @return array ValidationFailed[] 362 * @see validate() 363 */ 364 public function getValidationFailures() 365 { 366 return $this->validationFailures; 367 } 368 369 /** 352 370 * Validates the objects modified field values and all objects related to this table. 353 371 * … … 356 374 * 357 375 * @param mixed $columns Column name or an array of column names. 358 * 359 * @return mixed <code>true</code> if all columns pass validation 360 * or an array of <code>ValidationFailed</code> objects for columns that fail. 376 * @return boolean Whether all columns pass validation. 361 377 * @see doValidate() 378 * @see getValidationFailures() 362 379 */ 363 380 public function validate($columns = null) 364 381 { 365 if ($columns) { 366 return InterestPeer::doValidate($this, $columns); 367 } 368 return $this->doValidate(); 382 $res = $this->doValidate($columns); 383 if ($res === true) { 384 $this->validationFailures = array(); 385 return true; 386 } else { 387 $this->validationFailures = $res; 388 return false; 389 } 369 390 } 370 391 … … 376 397 * an aggreagated array of ValidationFailed objects will be returned. 377 398 * 399 * @param array $columns Array of column names to validate. 378 400 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 379 401 */ 380 protected function doValidate( )402 protected function doValidate($columns = null) 381 403 { 382 404 if (!$this->alreadyInValidation) { … … 393 415 394 416 if ($this->aQuestion !== null) { 395 if ( ($retval = $this->aQuestion->validate()) !== true) {396 $failureMap = array_merge($failureMap, $ retval);417 if (!$this->aQuestion->validate($columns)) { 418 $failureMap = array_merge($failureMap, $this->aQuestion->getValidationFailures()); 397 419 } 398 420 } 399 421 400 422 if ($this->aUser !== null) { 401 if ( ($retval = $this->aUser->validate()) !== true) {402 $failureMap = array_merge($failureMap, $ retval);423 if (!$this->aUser->validate($columns)) { 424 $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 403 425 } 404 426 } 405 427 406 428 407 if (($retval = InterestPeer::doValidate($this )) !== true) {429 if (($retval = InterestPeer::doValidate($this, $columns)) !== true) { 408 430 $failureMap = array_merge($failureMap, $retval); 409 431 } … … 428 450 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 429 451 { 430 $names = InterestPeer::getFieldNames($type);431 452 $pos = InterestPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 432 453 return $this->getByPosition($pos); … … 491 512 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 492 513 { 493 $names = InterestPeer::getFieldNames($type); 494 $pos = array_search($name, $names); 514 $pos = InterestPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 495 515 return $this->setByPosition($pos, $value); 496 516 } trunk/lib/model/om/BaseInterestPeer.php
r16 r74 86 86 * @throws PropelException Any exceptions caught during processing will be 87 87 * rethrown wrapped into a PropelException. 88 * @ todo Consider having template build the array rather than doing it at runtime.88 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 89 89 */ 90 90 public static function getPhpNameMap() … … 151 151 public static function alias($alias, $column) 152 152 { 153 return $alias . substr($column, strlen(InterestPeer::TABLE_NAME));153 return str_replace(InterestPeer::TABLE_NAME.'.', $alias.'.', $column); 154 154 } 155 155 … … 1071 1071 } 1072 1072 1073 return BasePeer::doValidate(InterestPeer::DATABASE_NAME, InterestPeer::TABLE_NAME, $columns); 1073 $res = BasePeer::doValidate(InterestPeer::DATABASE_NAME, InterestPeer::TABLE_NAME, $columns); 1074 if ($res !== true) { 1075 $request = sfContext::getInstance()->getRequest(); 1076 foreach ($res as $failed) { 1077 $col = InterestPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 1078 $request->setError($col, $failed->getMessage()); 1079 } 1080 } 1081 1082 return $res; 1074 1083 } 1075 1084 trunk/lib/model/om/BaseQuestion.php
r58 r74 717 717 718 718 /** 719 * Array of ValidationFailed objects. 720 * @var array ValidationFailed[] 721 */ 722 protected $validationFailures = array(); 723 724 /** 725 * Gets any ValidationFailed objects that resulted from last call to validate(). 726 * 727 * 728 * @return array ValidationFailed[] 729 * @see validate() 730 */ 731 public function getValidationFailures() 732 { 733 return $this->validationFailures; 734 } 735 736 /** 719 737 * Validates the objects modified field values and all objects related to this table. 720 738 * … … 723 741 * 724 742 * @param mixed $columns Column name or an array of column names. 725 * 726 * @return mixed <code>true</code> if all columns pass validation 727 * or an array of <code>ValidationFailed</code> objects for columns that fail. 743 * @return boolean Whether all columns pass validation. 728 744 * @see doValidate() 745 * @see getValidationFailures() 729 746 */ 730 747 public function validate($columns = null) 731 748 { 732 if ($columns) { 733 return QuestionPeer::doValidate($this, $columns); 734 } 735 return $this->doValidate(); 749 $res = $this->doValidate($columns); 750 if ($res === true) { 751 $this->validationFailures = array(); 752 return true; 753 } else { 754 $this->validationFailures = $res; 755 return false; 756 } 736 757 } 737 758 … … 743 764 * an aggreagated array of ValidationFailed objects will be returned. 744 765 * 766 * @param array $columns Array of column names to validate. 745 767 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 746 768 */ 747 protected function doValidate( )769 protected function doValidate($columns = null) 748 770 { 749 771 if (!$this->alreadyInValidation) { … … 760 782 761 783 if ($this->aUser !== null) { 762 if ( ($retval = $this->aUser->validate()) !== true) {763 $failureMap = array_merge($failureMap, $ retval);764 } 765 } 766 767 768 if (($retval = QuestionPeer::doValidate($this )) !== true) {784 if (!$this->aUser->validate($columns)) { 785 $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 786 } 787 } 788 789 790 if (($retval = QuestionPeer::doValidate($this, $columns)) !== true) { 769 791 $failureMap = array_merge($failureMap, $retval); 770 792 } … … 773 795 if ($this->collAnswers !== null) { 774 796 foreach($this->collAnswers as $referrerFK) { 775 if ( ($retval = $referrerFK->validate()) !== true) {776 $failureMap = array_merge($failureMap, $re tval);797 if (!$referrerFK->validate($columns)) { 798 $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 777 799 } 778 800 } … … 781 803 if ($this->collInterests !== null) { 782 804 foreach($this->collInterests as $referrerFK) { 783 if ( ($retval = $referrerFK->validate()) !== true) {784 $failureMap = array_merge($failureMap, $re tval);805 if (!$referrerFK->validate($columns)) { 806 $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 785 807 } 786 808 } … … 789 811 if ($this->collQuestionTags !== null) { 790 812 foreach($this->collQuestionTags as $referrerFK) { 791 if ( ($retval = $referrerFK->validate()) !== true) {792 $failureMap = array_merge($failureMap, $re tval);813 if (!$referrerFK->validate($columns)) { 814 $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 793 815 } 794 816 } … … 797 819 if ($this->collSearchIndexs !== null) { 798 820 foreach($this->collSearchIndexs as $referrerFK) { 799 if ( ($retval = $referrerFK->validate()) !== true) {800 $failureMap = array_merge($failureMap, $re tval);821 if (!$referrerFK->validate($columns)) { 822 $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 801 823 } 802 824 } … … 805 827 if ($this->collReportQuestions !== null) { 806 828 foreach($this->collReportQuestions as $referrerFK) { 807 if ( ($retval = $referrerFK->validate()) !== true) {808 $failureMap = array_merge($failureMap, $re tval);829 if (!$referrerFK->validate($columns)) { 830 $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 809 831 } 810 832 } … … 829 851 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 830 852 { 831 $names = QuestionPeer::getFieldNames($type);832 853 $pos = QuestionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 833 854 return $this->getByPosition($pos); … … 920 941 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 921 942 { 922 $names = QuestionPeer::getFieldNames($type); 923 $pos = array_search($name, $names); 943 $pos = QuestionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 924 944 return $this->setByPosition($pos, $value); 925 945 } … … 1099 1119 1100 1120 foreach($this->getAnswers() as $relObj) { 1101 $copyObj->addAnswer($relObj->copy($deepCopy)); 1121 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1122 $copyObj->addAnswer($relObj->copy($deepCopy)); 1123 } 1102 1124 } 1103 1125 1104 1126 foreach($this->getInterests() as $relObj) { 1105 $copyObj->addInterest($relObj->copy($deepCopy)); 1127 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1128 $copyObj->addInterest($relObj->copy($deepCopy)); 1129 } 1106 1130 } 1107 1131 1108 1132 foreach($this->getQuestionTags() as $relObj) { 1109 $copyObj->addQuestionTag($relObj->copy($deepCopy)); 1133 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1134 $copyObj->addQuestionTag($relObj->copy($deepCopy)); 1135 } 1110 1136 } 1111 1137 1112 1138 foreach($this->getSearchIndexs() as $relObj) { 1113 $copyObj->addSearchIndex($relObj->copy($deepCopy)); 1139 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1140 $copyObj->addSearchIndex($relObj->copy($deepCopy)); 1141 } 1114 1142 } 1115 1143 1116 1144 foreach($this->getReportQuestions() as $relObj) { 1117 $copyObj->addReportQuestion($relObj->copy($deepCopy)); 1145 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1146 $copyObj->addReportQuestion($relObj->copy($deepCopy)); 1147 } 1118 1148 } 1119 1149 … … 1288 1318 * 1289 1319 * @param Criteria $criteria 1320 * @param boolean $distinct 1290 1321 * @param Connection $con 1291 1322 * @throws PropelException 1292 1323 */ 1293 public function countAnswers($criteria = null, $ con = null)1324 public function countAnswers($criteria = null, $distinct = false, $con = null) 1294 1325 { 1295 1326 // include the Peer class … … 1305 1336 $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); 1306 1337 1307 return AnswerPeer::doCount($criteria, $ con);1338 return AnswerPeer::doCount($criteria, $distinct, $con); 1308 1339 } 1309 1340 … … 1443 1474 * 1444 1475 * @param Criteria $criteria 1476 * @param boolean $distinct 1445 1477 * @param Connection $con 1446 1478 * @throws PropelException 1447 1479 */ 1448 public function countInterests($criteria = null, $ con = null)1480 public function countInterests($criteria = null, $distinct = false, $con = null) 1449 1481 { 1450 1482 // include the Peer class … … 1460 1492 $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); 1461 1493 1462 return InterestPeer::doCount($criteria, $ con);1494 return InterestPeer::doCount($criteria, $distinct, $con); 1463 1495 } 1464 1496 … … 1598 1630 * 1599 1631 * @param Criteria $criteria 1632 * @param boolean $distinct 1600 1633 * @param Connection $con 1601 1634 * @throws PropelException 1602 1635 */ 1603 public function countQuestionTags($criteria = null, $ con = null)1636 public function countQuestionTags($criteria = null, $distinct = false, $con = null) 1604 1637 { 1605 1638 // include the Peer class … … 1615 1648 $criteria->add(QuestionTagPeer::QUESTION_ID, $this->getId()); 1616 1649 1617 return QuestionTagPeer::doCount($criteria, $ con);1650 return QuestionTagPeer::doCount($criteria, $distinct, $con); 1618 1651 } 1619 1652 … … 1753 1786 * 1754 1787 * @param Criteria $criteria 1788 * @param boolean $distinct 1755 1789 * @param Connection $con 1756 1790 * @throws PropelException 1757 1791 */ 1758 public function countSearchIndexs($criteria = null, $ con = null)1792 public function countSearchIndexs($criteria = null, $distinct = false, $con = null) 1759 1793 { 1760 1794 // include the Peer class … … 1770 1804 $criteria->add(SearchIndexPeer::QUESTION_ID, $this->getId()); 1771 1805 1772 return SearchIndexPeer::doCount($criteria, $ con);1806 return SearchIndexPeer::doCount($criteria, $distinct, $con); 1773 1807 } 1774 1808 … … 1859 1893 * 1860 1894 * @param Criteria $criteria 1895 * @param boolean $distinct 1861 1896 * @param Connection $con 1862 1897 * @throws PropelException 1863 1898 */ 1864 public function countReportQuestions($criteria = null, $ con = null)1899 public function countReportQuestions($criteria = null, $distinct = false, $con = null) 1865 1900 { 1866 1901 // include the Peer class … … 1876 1911 $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 1877 1912 1878 return ReportQuestionPeer::doCount($criteria, $ con);1913 return ReportQuestionPeer::doCount($criteria, $distinct, $con); 1879 1914 } 1880 1915 trunk/lib/model/om/BaseQuestionPeer.php
r55 r74 107 107 * @throws PropelException Any exceptions caught during processing will be 108 108 * rethrown wrapped into a PropelException. 109 * @ todo Consider having template build the array rather than doing it at runtime.109 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 110 110 */ 111 111 public static function getPhpNameMap() … … 172 172 public static function alias($alias, $column) 173 173 { 174 return $alias . substr($column, strlen(QuestionPeer::TABLE_NAME));174 return str_replace(QuestionPeer::TABLE_NAME.'.', $alias.'.', $column); 175 175 } 176 176 … … 746 746 } 747 747 748 return BasePeer::doValidate(QuestionPeer::DATABASE_NAME, QuestionPeer::TABLE_NAME, $columns); 748 $res = BasePeer::doValidate(QuestionPeer::DATABASE_NAME, QuestionPeer::TABLE_NAME, $columns); 749 if ($res !== true) { 750 $request = sfContext::getInstance()->getRequest(); 751 foreach ($res as $failed) { 752 $col = QuestionPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 753 $request->setError($col, $failed->getMessage()); 754 } 755 } 756 757 return $res; 749 758 } 750 759 trunk/lib/model/om/BaseQuestionTag.php
r55 r74 422 422 423 423 /** 424 * Array of ValidationFailed objects. 425 * @var array ValidationFailed[] 426 */ 427 protected $validationFailures = array(); 428 429 /** 430 * Gets any ValidationFailed objects that resulted from last call to validate(). 431 * 432 * 433 * @return array ValidationFailed[] 434 * @see validate() 435 */ 436 public function getValidationFailures() 437 { 438 return $this->validationFailures; 439 } 440 441 /** 424 442 * Validates the objects modified field values and all objects related to this table. 425 443 * … … 428 446 * 429 447 * @param mixed $columns Column name or an array of column names. 430 * 431 * @return mixed <code>true</code> if all columns pass validation 432 * or an array of <code>ValidationFailed</code> objects for columns that fail. 448 * @return boolean Whether all columns pass validation. 433 449 * @see doValidate() 450 * @see getValidationFailures() 434 451 */ 435 452 public function validate($columns = null) 436 453 { 437 if ($columns) { 438 return QuestionTagPeer::doValidate($this, $columns); 439 } 440 return $this->doValidate(); 454 $res = $this->doValidate($columns); 455 if ($res === true) { 456 $this->validationFailures = array(); 457 return true; 458 } else { 459 $this->validationFailures = $res; 460 return false; 461 } 441 462 } 442 463 … … 448 469 * an aggreagated array of ValidationFailed objects will be returned. 449 470 * 471 * @param array $columns Array of column names to validate. 450 472 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 451 473 */ 452 protected function doValidate( )474 protected function doValidate($columns = null) 453 475 { 454 476 if (!$this->alreadyInValidation) { … … 465 487 466 488 if ($this->aQuestion !== null) { 467 if ( ($retval = $this->aQuestion->validate()) !== true) {468 $failureMap = array_merge($failureMap, $ retval);489 if (!$this->aQuestion->validate($columns)) { 490 $failureMap = array_merge($failureMap, $this->aQuestion->getValidationFailures()); 469 491 } 470 492 } 471 493 472 494 if ($this->aUser !== null) { 473 if ( ($retval = $this->aUser->validate()) !== true) {474 $failureMap = array_merge($failureMap, $ retval);495 if (!$this->aUser->validate($columns)) { 496 $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 475 497 } 476 498 } 477 499 478 500 479 if (($retval = QuestionTagPeer::doValidate($this )) !== true) {501 if (($retval = QuestionTagPeer::doValidate($this, $columns)) !== true) { 480 502 $failureMap = array_merge($failureMap, $retval); 481 503 } … … 500 522 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 501 523 { 502 $names = QuestionTagPeer::getFieldNames($type);503 524 $pos = QuestionTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 504 525 return $this->getByPosition($pos); … … 571 592 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 572 593 { 573 $names = QuestionTagPeer::getFieldNames($type); 574 $pos = array_search($name, $names); 594 $pos = QuestionTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 575 595 return $this->setByPosition($pos, $value); 576 596 } trunk/lib/model/om/BaseQuestionTagPeer.php
r55 r74 92 92 * @throws PropelException Any exceptions caught during processing will be 93 93 * rethrown wrapped into a PropelException. 94 * @ todo Consider having template build the array rather than doing it at runtime.94 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 95 95 */ 96 96 public static function getPhpNameMap() … … 157 157 public static function alias($alias, $column) 158 158 { 159 return $alias . substr($column, strlen(QuestionTagPeer::TABLE_NAME));159 return str_replace(QuestionTagPeer::TABLE_NAME.'.', $alias.'.', $column); 160 160 } 161 161 … … 1086 1086 } 1087 1087 1088 return BasePeer::doValidate(QuestionTagPeer::DATABASE_NAME, QuestionTagPeer::TABLE_NAME, $columns); 1088 $res = BasePeer::doValidate(QuestionTagPeer::DATABASE_NAME, QuestionTagPeer::TABLE_NAME, $columns); 1089 if ($res !== true) { 1090 $request = sfContext::getInstance()->getRequest(); 1091 foreach ($res as $failed) { 1092 $col = QuestionTagPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 1093 $request->setError($col, $failed->getMessage()); 1094
