- Timestamp:
- 12/20/05 11:44:03 (3 years ago)
- Files:
-
- trunk/lib/model/Answer.php (modified) (1 diff)
- trunk/lib/model/AnswerPeer.php (modified) (2 diffs)
- trunk/lib/model/Question.php (modified) (1 diff)
- trunk/lib/model/QuestionPeer.php (modified) (1 diff)
- trunk/lib/model/QuestionTagPeer.php (modified) (1 diff)
- trunk/lib/model/ReportAnswer.php (added)
- trunk/lib/model/ReportAnswerPeer.php (added)
- trunk/lib/model/ReportQuestion.php (added)
- trunk/lib/model/ReportQuestionPeer.php (added)
- trunk/lib/model/UserPeer.php (modified) (1 diff)
- trunk/lib/model/map/AnswerMapBuilder.php (modified) (1 diff)
- trunk/lib/model/map/QuestionMapBuilder.php (modified) (1 diff)
- trunk/lib/model/map/QuestionTagMapBuilder.php (modified) (2 diffs)
- trunk/lib/model/map/ReportAnswerMapBuilder.php (added)
- trunk/lib/model/map/ReportQuestionMapBuilder.php (added)
- trunk/lib/model/map/UserMapBuilder.php (modified) (1 diff)
- trunk/lib/model/om/BaseAnswer.php (modified) (16 diffs)
- trunk/lib/model/om/BaseAnswerPeer.php (modified) (5 diffs)
- trunk/lib/model/om/BaseQuestion.php (modified) (16 diffs)
- trunk/lib/model/om/BaseQuestionPeer.php (modified) (5 diffs)
- trunk/lib/model/om/BaseQuestionTag.php (modified) (3 diffs)
- trunk/lib/model/om/BaseQuestionTagPeer.php (modified) (5 diffs)
- trunk/lib/model/om/BaseReportAnswer.php (added)
- trunk/lib/model/om/BaseReportAnswerPeer.php (added)
- trunk/lib/model/om/BaseReportQuestion.php (added)
- trunk/lib/model/om/BaseReportQuestionPeer.php (added)
- trunk/lib/model/om/BaseUser.php (modified) (16 diffs)
- trunk/lib/model/om/BaseUserPeer.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/model/Answer.php
r23 r55 39 39 $this->setHtmlBody(markdown($v)); 40 40 } 41 42 public function deleteReports() 43 { 44 $reports = $this->getReportQuestions(); 45 foreach ($reports as $report) 46 { 47 $report->delete(); 48 } 49 50 $this->setReports(0); 51 } 52 53 public function deleteSpam($moderator) 54 { 55 $con = Propel::getConnection(); 56 try 57 { 58 $con->begin(); 59 60 $user = $this->getUser(); 61 if ($user->getNickname() != 'anonymous') 62 { 63 $user->setDeletions($user->getDeletions() + 1); 64 $user->save(); 65 } 66 67 $this->delete(); 68 69 $con->commit(); 70 71 $log = 'moderator "%s" deleted answer "%s" for question "%s" (%s)'; 72 $log = sprintf($log, $moderator->getNickname(), $this->getId(), $this->getQuestion()->getTitle(), substr($this->getBody(), 0, 50)); 73 sfContext::getInstance()->getLogger()->warning($log); 74 } 75 catch (PropelException $e) 76 { 77 $con->rollback(); 78 throw $e; 79 } 80 } 41 81 } 42 82 trunk/lib/model/AnswerPeer.php
r40 r55 50 50 } 51 51 52 public function getRecent($max = 10)52 public static function getRecent($max = 10) 53 53 { 54 54 $c = new Criteria(); … … 58 58 59 59 return self::doSelectJoinUser($c); 60 } 61 62 public static function getReportedSpamPager($page) 63 { 64 $pager = new sfPager('Answer', APP_PAGER_HOMEPAGE_MAX); 65 $c = new Criteria(); 66 $c->add(self::REPORTS, 0, Criteria::GREATER_THAN); 67 $c->setLimit(20); 68 $c->addDescendingOrderByColumn(self::REPORTS); 69 $c->addAscendingOrderByColumn(self::CREATED_AT); 70 $c = self::addPermanentTagToCriteria($c); 71 $pager->setCriteria($c); 72 $pager->setPage($page); 73 $pager->setPeerMethod('doSelectJoinUser'); 74 $pager->init(); 75 76 return $pager; 77 } 78 79 public static function getReportCount() 80 { 81 $c = new Criteria(); 82 $c->add(self::REPORTS, 0, Criteria::GREATER_THAN); 83 $c = self::addPermanentTagToCriteria($c); 84 85 return self::doCount($c); 60 86 } 61 87 trunk/lib/model/Question.php
r42 r55 145 145 $c->addAsColumn('relevancy', AnswerPeer::RELEVANCY_UP.' / ('.AnswerPeer::RELEVANCY_UP.' + '.AnswerPeer::RELEVANCY_DOWN.')'); 146 146 $c->addDescendingOrderByColumn('relevancy'); 147 $c->addDescendingOrderByColumn(AnswerPeer::RELEVANCY_UP); 147 148 148 149 return AnswerPeer::doSelect($c); 150 } 151 152 public function deleteReports() 153 { 154 $reports = $this->getReportQuestions(); 155 foreach ($reports as $report) 156 { 157 $report->delete(); 158 } 159 160 $this->setReports(0); 161 } 162 163 public function deleteSpam($moderator) 164 { 165 $con = Propel::getConnection(); 166 try 167 { 168 $con->begin(); 169 170 $user = $this->getUser(); 171 $user->setDeletions($user->getDeletions() + 1); 172 $user->save(); 173 174 $this->delete(); 175 176 $con->commit(); 177 178 $log = 'moderator "%s" deleted question "%s"'; 179 $log = sprintf($log, $moderator->getNickname(), $this->getTitle()); 180 sfContext::getInstance()->getLogger()->warning($log); 181 } 182 catch (PropelException $e) 183 { 184 $con->rollback(); 185 throw $e; 186 } 149 187 } 150 188 } trunk/lib/model/QuestionPeer.php
r42 r55 103 103 } 104 104 105 public static function getReportedSpamPager($page) 106 { 107 $pager = new sfPager('Question', APP_PAGER_HOMEPAGE_MAX); 108 $c = new Criteria(); 109 $c->add(self::REPORTS, 0, Criteria::GREATER_THAN); 110 $c->setLimit(20); 111 $c->addDescendingOrderByColumn(self::REPORTS); 112 $c->addAscendingOrderByColumn(self::CREATED_AT); 113 $c = self::addPermanentTagToCriteria($c); 114 $pager->setCriteria($c); 115 $pager->setPage($page); 116 $pager->setPeerMethod('doSelectJoinUser'); 117 $pager->init(); 118 119 return $pager; 120 } 121 122 public static function getReportCount() 123 { 124 $c = new Criteria(); 125 $c->add(self::REPORTS, 0, Criteria::GREATER_THAN); 126 $c = self::addPermanentTagToCriteria($c); 127 128 return self::doCount($c); 129 } 130 105 131 private static function addPermanentTagToCriteria($criteria) 106 132 { trunk/lib/model/QuestionTagPeer.php
r40 r55 147 147 return $tags; 148 148 } 149 150 public static function getUnpopularTags() 151 { 152 $tags = array(); 153 154 $con = Propel::getConnection(); 155 $query = ' 156 SELECT t1.normalized_tag AS tag, 157 COUNT(t1.normalized_tag) AS count 158 FROM '.QuestionTagPeer::TABLE_NAME.' AS t1'; 159 160 if (defined('APP_PERMANENT_TAG')) 161 { 162 $query .= ' 163 INNER JOIN '.QuestionTagPeer::TABLE_NAME.' AS t2 ON t1.question_id = t2.question_id 164 WHERE t2.normalized_tag = ? AND t1.normalized_tag != ? 165 AND count < 5 166 '; 167 } 168 169 $query .= ' 170 GROUP BY t1.normalized_tag 171 ORDER BY count ASC 172 '; 173 174 $stmt = $con->prepareStatement($query); 175 if (defined('APP_PERMANENT_TAG')) 176 { 177 $stmt->setString(1, APP_PERMANENT_TAG); 178 $stmt->setString(2, APP_PERMANENT_TAG); 179 } 180 $rs = $stmt->executeQuery(); 181 while ($rs->next()) 182 { 183 $tags[$rs->getString('tag')] = $rs->getInt('count'); 184 } 185 186 return $tags; 187 } 188 189 public static function getByNormalizedTag($tag) 190 { 191 $c = new Criteria(); 192 $c->add(self::NORMALIZED_TAG, Tag::normalize($tag)); 193 194 return self::doSelect($c); 195 } 196 197 public static function deleteSpam($moderator, $tag, $question_id = null) 198 { 199 if ($question_id === null) 200 { 201 $tags = self::getByNormalizedTag($tag); 202 } 203 else 204 { 205 $c = new Criteria(); 206 $c->add(self::NORMALIZED_TAG, Tag::normalize($tag)); 207 $c->add(self::QUESTION_ID, $question_id); 208 209 $tags = self::doSelect($c); 210 } 211 212 $con = Propel::getConnection(); 213 try 214 { 215 $con->begin(); 216 217 foreach ($tags as $tag) 218 { 219 $user = $tag->getUser(); 220 $user->setDeletions($user->getDeletions() + 1); 221 $user->save(); 222 223 $tag->delete(); 224 } 225 226 $con->commit(); 227 228 $log = 'moderator "%s" deleted tag "%s"'; 229 $log = sprintf($log, $moderator->getNickname(), $tag->getNormalizedTag()); 230 sfContext::getInstance()->getLogger()->warning($log); 231 } 232 catch (PropelException $e) 233 { 234 $con->rollback(); 235 throw $e; 236 } 237 } 149 238 } 150 239 trunk/lib/model/UserPeer.php
r48 r55 45 45 return null; 46 46 } 47 48 public static function getModeratorCandidatesCount() 49 { 50 $c = new Criteria(); 51 $c->add(self::WANT_TO_BE_MODERATOR, true); 52 53 return self::doCount($c); 54 } 55 56 public static function getModeratorCandidates() 57 { 58 $c = new Criteria(); 59 $c->add(self::WANT_TO_BE_MODERATOR, true); 60 $c->addAscendingOrderByColumn(self::CREATED_AT); 61 62 return self::doSelect($c); 63 } 64 65 public static function getModerators() 66 { 67 $c = new Criteria(); 68 $c->add(self::IS_MODERATOR, true); 69 $c->addAscendingOrderByColumn(self::CREATED_AT); 70 71 return self::doSelect($c); 72 } 73 74 public static function getAdministrators() 75 { 76 $c = new Criteria(); 77 $c->add(self::IS_ADMINISTRATOR, true); 78 $c->addAscendingOrderByColumn(self::CREATED_AT); 79 80 return self::doSelect($c); 81 } 82 83 public static function getProblematicUsersCount() 84 { 85 $c = new Criteria(); 86 $c->add(self::DELETIONS, 0, Criteria::GREATER_THAN); 87 88 return self::doCount($c); 89 } 90 91 public static function getProblematicUsers() 92 { 93 $c = new Criteria(); 94 $c->add(self::DELETIONS, 0, Criteria::GREATER_THAN); 95 $c->addDescendingOrderByColumn(self::DELETIONS); 96 97 return self::doSelect($c); 98 } 47 99 } 48 100 trunk/lib/model/map/AnswerMapBuilder.php
r23 r55 79 79 $tMap->addColumn('RELEVANCY_DOWN', 'RelevancyDown', 'int', CreoleTypes::INTEGER, false); 80 80 81 $tMap->addColumn('REPORTS', 'Reports', 'int', CreoleTypes::INTEGER, false); 82 81 83 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 82 84 trunk/lib/model/map/QuestionMapBuilder.php
r23 r55 79 79 $tMap->addColumn('INTERESTED_USERS', 'InterestedUsers', 'int', CreoleTypes::INTEGER, false); 80 80 81 $tMap->addColumn('REPORTS', 'Reports', 'int', CreoleTypes::INTEGER, false); 82 81 83 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 82 84 trunk/lib/model/map/QuestionTagMapBuilder.php
r31 r55 65 65 $tMap->setUseIdGenerator(false); 66 66 67 $tMap->addForeign Key('QUESTION_ID', 'QuestionId', 'int', CreoleTypes::INTEGER, 'ask_question', 'ID', false, null);67 $tMap->addForeignPrimaryKey('QUESTION_ID', 'QuestionId', 'int' , CreoleTypes::INTEGER, 'ask_question', 'ID', true, null); 68 68 69 $tMap->addForeign Key('USER_ID', 'UserId', 'int', CreoleTypes::INTEGER, 'ask_user', 'ID', false, null);69 $tMap->addForeignPrimaryKey('USER_ID', 'UserId', 'int' , CreoleTypes::INTEGER, 'ask_user', 'ID', true, null); 70 70 71 71 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); … … 73 73 $tMap->addColumn('TAG', 'Tag', 'string', CreoleTypes::VARCHAR, false); 74 74 75 $tMap->add Column('NORMALIZED_TAG', 'NormalizedTag', 'string', CreoleTypes::VARCHAR, false);75 $tMap->addPrimaryKey('NORMALIZED_TAG', 'NormalizedTag', 'string', CreoleTypes::VARCHAR, true, 100); 76 76 77 77 } // doBuild() trunk/lib/model/map/UserMapBuilder.php
r44 r55 81 81 $tMap->addColumn('HAS_PAYPAL', 'HasPaypal', 'boolean', CreoleTypes::BOOLEAN, false); 82 82 83 $tMap->addColumn('WANT_TO_BE_MODERATOR', 'WantToBeModerator', 'boolean', CreoleTypes::BOOLEAN, false); 84 85 $tMap->addColumn('IS_MODERATOR', 'IsModerator', 'boolean', CreoleTypes::BOOLEAN, false); 86 87 $tMap->addColumn('IS_ADMINISTRATOR', 'IsAdministrator', 'boolean', CreoleTypes::BOOLEAN, false); 88 89 $tMap->addColumn('DELETIONS', 'Deletions', 'int', CreoleTypes::INTEGER, false); 90 83 91 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 84 92 trunk/lib/model/om/BaseAnswer.php
r23 r55 79 79 80 80 /** 81 * The value for the reports field. 82 * @var int 83 */ 84 protected $reports = 0; 85 86 87 /** 81 88 * The value for the created_at field. 82 89 * @var int … … 105 112 */ 106 113 private $lastRelevancyCriteria = null; 114 115 /** 116 * Collection to store aggregation of collReportAnswers. 117 * @var array 118 */ 119 protected $collReportAnswers; 120 121 /** 122 * The criteria used to select the current contents of collReportAnswers. 123 * @var Criteria 124 */ 125 private $lastReportAnswerCriteria = null; 107 126 108 127 /** … … 195 214 196 215 return $this->relevancy_down; 216 } 217 218 /** 219 * Get the [reports] column value. 220 * 221 * @return int 222 */ 223 public function getReports() 224 { 225 226 return $this->reports; 197 227 } 198 228 … … 349 379 350 380 /** 381 * Set the value of [reports] column. 382 * 383 * @param int $v new value 384 * @return void 385 */ 386 public function setReports($v) 387 { 388 389 if ($this->reports !== $v || $v === 0) { 390 $this->reports = $v; 391 $this->modifiedColumns[] = AnswerPeer::REPORTS; 392 } 393 394 } // setReports() 395 396 /** 351 397 * Set the value of [created_at] column. 352 398 * … … 403 449 $this->relevancy_down = $rs->getInt($startcol + 6); 404 450 405 $this->created_at = $rs->getTimestamp($startcol + 7, null); 451 $this->reports = $rs->getInt($startcol + 7); 452 453 $this->created_at = $rs->getTimestamp($startcol + 8, null); 406 454 407 455 $this->resetModified(); … … 410 458 411 459 // FIXME - using NUM_COLUMNS may be clearer. 412 return $startcol + 8; // 8= AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS).460 return $startcol + 9; // 9 = AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS). 413 461 414 462 } catch (Exception $e) { … … 546 594 } 547 595 596 if ($this->collReportAnswers !== null) { 597 foreach($this->collReportAnswers as $referrerFK) { 598 if (!$referrerFK->isDeleted()) { 599 $affectedRows += $referrerFK->save($con); 600 } 601 } 602 } 603 548 604 $this->alreadyInSave = false; 549 605 } … … 620 676 } 621 677 678 if ($this->collReportAnswers !== null) { 679 foreach($this->collReportAnswers as $referrerFK) { 680 if (($retval = $referrerFK->validate()) !== true) { 681 $failureMap = array_merge($failureMap, $retval); 682 } 683 } 684 } 685 622 686 623 687 $this->alreadyInValidation = false; … … 675 739 break; 676 740 case 7: 741 return $this->getReports(); 742 break; 743 case 8: 677 744 return $this->getCreatedAt(); 678 745 break; … … 704 771 $keys[5] => $this->getRelevancyUp(), 705 772 $keys[6] => $this->getRelevancyDown(), 706 $keys[7] => $this->getCreatedAt(), 773 $keys[7] => $this->getReports(), 774 $keys[8] => $this->getCreatedAt(), 707 775 ); 708 776 return $result; … … 759 827 break; 760 828 case 7: 829 $this->setReports($value); 830 break; 831 case 8: 761 832 $this->setCreatedAt($value); 762 833 break; … … 791 862 if (array_key_exists($keys[5], $arr)) $this->setRelevancyUp($arr[$keys[5]]); 792 863 if (array_key_exists($keys[6], $arr)) $this->setRelevancyDown($arr[$keys[6]]); 793 if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); 864 if (array_key_exists($keys[7], $arr)) $this->setReports($arr[$keys[7]]); 865 if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); 794 866 } 795 867 … … 810 882 if ($this->isColumnModified(AnswerPeer::RELEVANCY_UP)) $criteria->add(AnswerPeer::RELEVANCY_UP, $this->relevancy_up); 811 883 if ($this->isColumnModified(AnswerPeer::RELEVANCY_DOWN)) $criteria->add(AnswerPeer::RELEVANCY_DOWN, $this->relevancy_down); 884 if ($this->isColumnModified(AnswerPeer::REPORTS)) $criteria->add(AnswerPeer::REPORTS, $this->reports); 812 885 if ($this->isColumnModified(AnswerPeer::CREATED_AT)) $criteria->add(AnswerPeer::CREATED_AT, $this->created_at); 813 886 … … 876 949 877 950 $copyObj->setRelevancyDown($this->relevancy_down); 951 952 $copyObj->setReports($this->reports); 878 953 879 954 $copyObj->setCreatedAt($this->created_at); … … 887 962 foreach($this->getRelevancys() as $relObj) { 888 963 $copyObj->addRelevancy($relObj->copy($deepCopy)); 964 } 965 966 foreach($this->getReportAnswers() as $relObj) { 967 $copyObj->addReportAnswer($relObj->copy($deepCopy)); 889 968 } 890 969 … … 1193 1272 } 1194 1273 1274 /** 1275 * Temporary storage of collReportAnswers to save a possible db hit in 1276 * the event objects are add to the collection, but the 1277 * complete collection is never requested. 1278 * @return void 1279 */ 1280 public function initReportAnswers() 1281 { 1282 if ($this->collReportAnswers === null) { 1283 $this->collReportAnswers = array(); 1284 } 1285 } 1286 1287 /** 1288 * If this collection has already been initialized with 1289 * an identical criteria, it returns the collection. 1290 * Otherwise if this Answer has previously 1291 * been saved, it will retrieve related ReportAnswers from storage. 1292 * If this Answer is new, it will return 1293 * an empty collection or the current collection, the criteria 1294 * is ignored on a new object. 1295 * 1296 * @param Connection $con 1297 * @param Criteria $criteria 1298 * @throws PropelException 1299 */ 1300 public function getReportAnswers($criteria = null, $con = null) 1301 { 1302 // include the Peer class 1303 include_once 'model/om/BaseReportAnswerPeer.php'; 1304 if ($criteria === null) { 1305 $criteria = new Criteria(); 1306 } 1307 elseif ($criteria instanceof Criteria) 1308 { 1309 $criteria = clone $criteria; 1310 } 1311 1312 if ($this->collReportAnswers === null) { 1313 if ($this->isNew()) { 1314 $this->collReportAnswers = array(); 1315 } else { 1316 1317 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 1318 1319 ReportAnswerPeer::addSelectColumns($criteria); 1320 $this->collReportAnswers = ReportAnswerPeer::doSelect($criteria, $con); 1321 } 1322 } else { 1323 // criteria has no effect for a new object 1324 if (!$this->isNew()) { 1325 // the following code is to determine if a new query is 1326 // called for. If the criteria is the same as the last 1327 // one, just return the collection. 1328 1329 1330 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 1331 1332 ReportAnswerPeer::addSelectColumns($criteria); 1333 if (!isset($this->lastReportAnswerCriteria) || !$this->lastReportAnswerCriteria->equals($criteria)) { 1334 $this->collReportAnswers = ReportAnswerPeer::doSelect($criteria, $con); 1335 } 1336 } 1337 } 1338 $this->lastReportAnswerCriteria = $criteria; 1339 return $this->collReportAnswers; 1340 } 1341 1342 /** 1343 * Returns the number of related ReportAnswers. 1344 * 1345 * @param Criteria $criteria 1346 * @param Connection $con 1347 * @throws PropelException 1348 */ 1349 public function countReportAnswers($criteria = null, $con = null) 1350 { 1351 // include the Peer class 1352 include_once 'model/om/BaseReportAnswerPeer.php'; 1353 if ($criteria === null) { 1354 $criteria = new Criteria(); 1355 } 1356 elseif ($criteria instanceof Criteria) 1357 { 1358 $criteria = clone $criteria; 1359 } 1360 1361 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 1362 1363 return ReportAnswerPeer::doCount($criteria, $con); 1364 } 1365 1366 /** 1367 * Method called to associate a ReportAnswer object to this object 1368 * through the ReportAnswer foreign key attribute 1369 * 1370 * @param ReportAnswer $l ReportAnswer 1371 * @return void 1372 * @throws PropelException 1373 */ 1374 public function addReportAnswer(ReportAnswer $l) 1375 { 1376 $this->collReportAnswers[] = $l; 1377 $l->setAnswer($this); 1378 } 1379 1380 1381 /** 1382 * If this collection has already been initialized with 1383 * an identical criteria, it returns the collection. 1384 * Otherwise if this Answer is new, it will return 1385 * an empty collection; or if this Answer has previously 1386 * been saved, it will retrieve related ReportAnswers from storage. 1387 * 1388 * This method is protected by default in order to keep the public 1389 * api reasonable. You can provide public methods for those you 1390 * actually need in Answer. 1391 */ 1392 public function getReportAnswersJoinUser($criteria = null, $con = null) 1393 { 1394 // include the Peer class 1395 include_once 'model/om/BaseReportAnswerPeer.php'; 1396 if ($criteria === null) { 1397 $criteria = new Criteria(); 1398 } 1399 elseif ($criteria instanceof Criteria) 1400 { 1401 $criteria = clone $criteria; 1402 } 1403 1404 if ($this->collReportAnswers === null) { 1405 if ($this->isNew()) { 1406 $this->collReportAnswers = array(); 1407 } else { 1408 1409 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 1410 1411 $this->collReportAnswers = ReportAnswerPeer::doSelectJoinUser($criteria, $con); 1412 } 1413 } else { 1414 // the following code is to determine if a new query is 1415 // called for. If the criteria is the same as the last 1416 // one, just return the collection. 1417 1418 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 1419 1420 if (!isset($this->lastReportAnswerCriteria) || !$this->lastReportAnswerCriteria->equals($criteria)) { 1421 $this->collReportAnswers = ReportAnswerPeer::doSelectJoinUser($criteria, $con); 1422 } 1423 } 1424 $this->lastReportAnswerCriteria = $criteria; 1425 1426 return $this->collReportAnswers; 1427 } 1428 1195 1429 } // BaseAnswer trunk/lib/model/om/BaseAnswerPeer.php
r23 r55 25 25 26 26 /** The total number of columns. */ 27 const NUM_COLUMNS = 8;27 const NUM_COLUMNS = 9; 28 28 29 29 /** The number of lazy-loaded columns. */ … … 52 52 const RELEVANCY_DOWN = 'ask_answer.RELEVANCY_DOWN'; 53 53 54 /** the column name for the REPORTS field */ 55 const REPORTS = 'ask_answer.REPORTS'; 56 54 57 /** the column name for the CREATED_AT field */ 55 58 const CREATED_AT = 'ask_answer.CREATED_AT'; … … 66 69 */ 67 70 private static $fieldNames = array ( 68 BasePeer::TYPE_PHPNAME => array ('Id', 'QuestionId', 'UserId', 'Body', 'HtmlBody', 'RelevancyUp', 'RelevancyDown', ' CreatedAt', ),69 BasePeer::TYPE_COLNAME => array (AnswerPeer::ID, AnswerPeer::QUESTION_ID, AnswerPeer::USER_ID, AnswerPeer::BODY, AnswerPeer::HTML_BODY, AnswerPeer::RELEVANCY_UP, AnswerPeer::RELEVANCY_DOWN, AnswerPeer:: CREATED_AT, ),70 BasePeer::TYPE_FIELDNAME => array ('id', 'question_id', 'user_id', 'body', 'html_body', 'relevancy_up', 'relevancy_down', ' created_at', ),71 BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )71 BasePeer::TYPE_PHPNAME => array ('Id', 'QuestionId', 'UserId', 'Body', 'HtmlBody', 'RelevancyUp', 'RelevancyDown', 'Reports', 'CreatedAt', ), 72 BasePeer::TYPE_COLNAME => array (AnswerPeer::ID, AnswerPeer::QUESTION_ID, AnswerPeer::USER_ID, AnswerPeer::BODY, AnswerPeer::HTML_BODY, AnswerPeer::RELEVANCY_UP, AnswerPeer::RELEVANCY_DOWN, AnswerPeer::REPORTS, AnswerPeer::CREATED_AT, ), 73 BasePeer::TYPE_FIELDNAME => array ('id', 'question_id', 'user_id', 'body', 'html_body', 'relevancy_up', 'relevancy_down', 'reports', 'created_at', ), 74 BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) 72 75 ); 73 76 … … 79 82 */ 80 83 private static $fieldKeys = array ( 81 BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'QuestionId' => 1, 'UserId' => 2, 'Body' => 3, 'HtmlBody' => 4, 'RelevancyUp' => 5, 'RelevancyDown' => 6, ' CreatedAt' => 7, ),82 BasePeer::TYPE_COLNAME => array (AnswerPeer::ID => 0, AnswerPeer::QUESTION_ID => 1, AnswerPeer::USER_ID => 2, AnswerPeer::BODY => 3, AnswerPeer::HTML_BODY => 4, AnswerPeer::RELEVANCY_UP => 5, AnswerPeer::RELEVANCY_DOWN => 6, AnswerPeer:: CREATED_AT => 7, ),83 BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'question_id' => 1, 'user_id' => 2, 'body' => 3, 'html_body' => 4, 'relevancy_up' => 5, 'relevancy_down' => 6, ' created_at' => 7, ),84 BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )84 BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'QuestionId' => 1, 'UserId' => 2, 'Body' => 3, 'HtmlBody' => 4, 'RelevancyUp' => 5, 'RelevancyDown' => 6, 'Reports' => 7, 'CreatedAt' => 8, ), 85 BasePeer::TYPE_COLNAME => array (AnswerPeer::ID => 0, AnswerPeer::QUESTION_ID => 1, AnswerPeer::USER_ID => 2, AnswerPeer::BODY => 3, AnswerPeer::HTML_BODY => 4, AnswerPeer::RELEVANCY_UP => 5, AnswerPeer::RELEVANCY_DOWN => 6, AnswerPeer::REPORTS => 7, AnswerPeer::CREATED_AT => 8, ), 86 BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'question_id' => 1, 'user_id' => 2, 'body' => 3, 'html_body' => 4, 'relevancy_up' => 5, 'relevancy_down' => 6, 'reports' => 7, 'created_at' => 8, ), 87 BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) 85 88 ); 86 89 … … 196 199 197 200 $criteria->addSelectColumn(AnswerPeer::RELEVANCY_DOWN); 201 202 $criteria->addSelectColumn(AnswerPeer::REPORTS); 198 203 199 204 $criteria->addSelectColumn(AnswerPeer::CREATED_AT); trunk/lib/model/om/BaseQuestion.php
r31 r55 79 79 80 80 /** 81 * The value for the reports field. 82 * @var int 83 */ 84 protected $reports = 0; 85 86 87 /** 81 88 * The value for the created_at field. 82 89 * @var int … … 131 138 */ 132 139 private $lastQuestionTagCriteria = null; 140 141 /** 142 * Collection to store aggregation of collReportQuestions. 143 * @var array 144 */ 145 protected $collReportQuestions; 146 147 /** 148 * The criteria used to select the current contents of collReportQuestions. 149 * @var Criteria 150 */ 151 private $lastReportQuestionCriteria = null; 133 152 134 153 /** … … 221 240 222 241 return $this->interested_users; 242 } 243 244 /** 245 * Get the [reports] column value. 246 * 247 * @return int 248 */ 249 public function getReports() 250 { 251 252 return $this->reports; 223 253 } 224 254 … … 402 432 403 433 /** 434 * Set the value of [reports] column. 435 * 436 * @param int $v new value 437 * @return void 438 */ 439 public function setReports($v) 440 { 441 442 if ($this->reports !== $v || $v === 0) { 443 $this->reports = $v; 444 $this->modifiedColumns[] = QuestionPeer::REPORTS; 445 } 446 447 } // setReports() 448 449 /** 404 450 * Set the value of [created_at] column. 405 451 * … … 480 526 $this->interested_users = $rs->getInt($startcol + 6); 481 527 482 $this->created_at = $rs->getTimestamp($startcol + 7, null); 483 484 $this->updated_at = $rs->getTimestamp($startcol + 8, null); 528 $this->reports = $rs->getInt($startcol + 7); 529 530 $this->created_at = $rs->getTimestamp($startcol + 8, null); 531 532 $this->updated_at = $rs->getTimestamp($startcol + 9, null); 485 533 486 534 $this->resetModified(); … … 489 537 490 538 // FIXME - using NUM_COLUMNS may be clearer. 491 return $startcol + 9; // 9= QuestionPeer::NUM_COLUMNS - QuestionPeer::NUM_LAZY_LOAD_COLUMNS).539 return $startcol + 10; // 10 = QuestionPeer::NUM_COLUMNS - QuestionPeer::NUM_LAZY_LOAD_COLUMNS). 492 540 493 541 } catch (Exception $e) { … … 635 683 } 636 684 685 if ($this->collReportQuestions !== null) { 686 foreach($this->collReportQuestions as $referrerFK) { 687 if (!$referrerFK->isDeleted()) { 688 $affectedRows += $referrerFK->save($con); 689 } 690 } 691 } 692 637 693 $this->alreadyInSave = false; 638 694 } … … 719 775 } 720 776 777 if ($this->collReportQuestions !== null) { 778 foreach($this->collReportQuestions as $referrerFK) { 779 if (($retval = $referrerFK->validate()) !== true) { 780 $failureMap = array_merge($failureMap, $retval); 781 } 782 } 783 } 784 721 785 722 786 $this->alreadyInValidation = false; … … 774 838 break; 775 839 case 7: 840 return $this->getReports(); 841 break; 842 case 8: 776 843 return $this->getCreatedAt(); 777 844 break; 778 case 8:845 case 9: 779 846 return $this->getUpdatedAt(); 780 847 break; … … 806 873 $keys[5] => $this->getHtmlBody(), 807 874 $keys[6] => $this->getInterestedUsers(), 808 $keys[7] => $this->getCreatedAt(), 809 $keys[8] => $this->getUpdatedAt(), 875 $keys[7] => $this->getReports(), 876 $keys[8] => $this->getCreatedAt(), 877 $keys[9] => $this->getUpdatedAt(), 810 878 ); 811 879 return $result; … … 862 930 break; 863 931 case 7: 932 $this->setReports($value); 933 break; 934 case 8: 864 935 $this->setCreatedAt($value); 865 936 break; 866 case 8:937 case 9: 867 938 $this->setUpdatedAt($value); 868 939 break; … … 897 968 if (array_key_exists($keys[5], $arr)) $this->setHtmlBody($arr[$keys[5]]); 898 969 if (array_key_exists($keys[6], $arr)) $this->setInterestedUsers($arr[$keys[6]]); 899 if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); 900 if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); 970 if (array_key_exists($keys[7], $arr)) $this->setReports($arr[$keys[7]]); 971 if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); 972 if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); 901 973 } 902 974 … … 917 989 if ($this->isColumnModified(QuestionPeer::HTML_BODY)) $criteria->add(QuestionPeer::HTML_BODY, $this->html_body); 918 990 if ($this->isColumnModified(QuestionPeer::INTERESTED_USERS)) $criteria->add(QuestionPeer::INTERESTED_USERS, $this->interested_users); 991 if ($this->isColumnModified(QuestionPeer::REPORTS)) $criteria->add(QuestionPeer::REPORTS, $this->reports); 919 992 if ($this->isColumnModified(QuestionPeer::CREATED_AT)) $criteria->add(QuestionPeer::CREATED_AT, $this->created_at); 920 993 if ($this->isColumnModified(QuestionPeer::UPDATED_AT)) $criteria->add(QuestionPeer::UPDATED_AT, $this->updated_at); … … 984 1057 985 1058 $copyObj->setInterestedUsers($this->interested_users); 1059 1060 $copyObj->setReports($this->reports); 986 1061 &
