Changeset 55

Show
Ignore:
Timestamp:
12/20/05 11:44:03 (6 years ago)
Author:
fabien
Message:

day 20 modifications

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config/schema.xml

    r44 r55  
    1212     <column name="html_body" type="longvarchar" /> 
    1313     <column name="interested_users" type="integer" default="0" /> 
     14     <column name="reports" type="integer" default="0" /> 
    1415     <column name="created_at" type="timestamp" /> 
    1516     <column name="updated_at" type="timestamp" /> 
     
    1920     <column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" /> 
    2021     <column name="question_id" type="integer" /> 
    21      <foreign-key foreignTable="ask_question"
     22     <foreign-key foreignTable="ask_question" onDelete="cascade"
    2223       <reference local="question_id" foreign="id"/> 
    2324     </foreign-key> 
     
    3031     <column name="relevancy_up" type="integer" default="0" /> 
    3132     <column name="relevancy_down" type="integer" default="0" /> 
     33     <column name="reports" type="integer" default="0" /> 
    3234     <column name="created_at" type="timestamp" /> 
    3335   </table> 
     
    4244     <column name="salt" type="varchar" size="32" /> 
    4345     <column name="has_paypal" type="boolean" default="0" /> 
     46     <column name="want_to_be_moderator" type="boolean" default="0" /> 
     47     <column name="is_moderator" type="boolean" default="0" /> 
     48     <column name="is_administrator" type="boolean" default="0" /> 
     49     <column name="deletions" type="integer" default="0" /> 
    4450     <column name="created_at" type="timestamp" /> 
    4551   </table> 
     
    4753   <table name="ask_interest" phpName="Interest"> 
    4854     <column name="question_id" type="integer" primaryKey="true" /> 
    49      <foreign-key foreignTable="ask_question"
     55     <foreign-key foreignTable="ask_question" onDelete="cascade"
    5056       <reference local="question_id" foreign="id"/> 
    5157     </foreign-key> 
     
    5965   <table name="ask_relevancy" phpName="Relevancy"> 
    6066     <column name="answer_id" type="integer" primaryKey="true" /> 
    61      <foreign-key foreignTable="ask_answer"
     67     <foreign-key foreignTable="ask_answer" onDelete="cascade"
    6268       <reference local="answer_id" foreign="id"/> 
    6369     </foreign-key> 
     
    7177 
    7278   <table name="ask_question_tag" phpName="QuestionTag"> 
    73      <column name="question_id" type="integer" /> 
    74      <foreign-key foreignTable="ask_question"
     79     <column name="question_id" type="integer" primaryKey="true" /> 
     80     <foreign-key foreignTable="ask_question" onDelete="cascade"
    7581       <reference local="question_id" foreign="id" /> 
    7682     </foreign-key> 
    77      <column name="user_id" type="integer" /> 
     83     <column name="user_id" type="integer" primaryKey="true" /> 
    7884     <foreign-key foreignTable="ask_user"> 
    7985       <reference local="user_id" foreign="id" /> 
     
    8187     <column name="created_at" type="timestamp" /> 
    8288     <column name="tag" type="varchar" size="100" /> 
    83      <column name="normalized_tag" type="varchar" size="100" /> 
     89     <column name="normalized_tag" type="varchar" size="100" primaryKey="true" /> 
    8490     <index name="normalized_tag_index"> 
    8591       <index-column name="normalized_tag" /> 
    8692     </index> 
    87      <unique name="pk"> 
    88        <unique-column name="question_id" /> 
    89        <unique-column name="user_id" /> 
    90        <unique-column name="normalized_tag" /> 
    91      </unique> 
     93   </table> 
     94 
     95   <table name="ask_report_question" phpName="ReportQuestion"> 
     96     <column name="question_id" type="integer" primaryKey="true" /> 
     97     <foreign-key foreignTable="ask_question" onDelete="cascade"> 
     98       <reference local="question_id" foreign="id" /> 
     99     </foreign-key> 
     100     <column name="user_id" type="integer" primaryKey="true" /> 
     101     <foreign-key foreignTable="ask_user"> 
     102       <reference local="user_id" foreign="id" /> 
     103     </foreign-key> 
     104     <column name="created_at" type="timestamp" /> 
     105   </table> 
     106 
     107   <table name="ask_report_answer" phpName="ReportAnswer"> 
     108     <column name="answer_id" type="integer" primaryKey="true" /> 
     109     <foreign-key foreignTable="ask_answer" onDelete="cascade"> 
     110       <reference local="answer_id" foreign="id" /> 
     111     </foreign-key> 
     112     <column name="user_id" type="integer" primaryKey="true" /> 
     113     <foreign-key foreignTable="ask_user"> 
     114       <reference local="user_id" foreign="id" /> 
     115     </foreign-key> 
     116     <column name="created_at" type="timestamp" /> 
    92117   </table> 
    93118 
  • trunk/data/fixtures/test_data.yml

    r38 r55  
    1111    password:   symfony 
    1212    email:      fp@example.com 
     13    is_administrator: on 
    1314 
    1415  francois: 
  • trunk/data/sql/schema.sql

    r44 r55  
    1616    `html_body` TEXT ,  
    1717    `interested_users` INTEGER default 0 ,  
     18    `reports` INTEGER default 0 ,  
    1819    `created_at` DATETIME ,  
    1920    `updated_at` DATETIME ,   
     
    3839    `relevancy_up` INTEGER default 0 ,  
    3940    `relevancy_down` INTEGER default 0 ,  
     41    `reports` INTEGER default 0 ,  
    4042    `created_at` DATETIME ,   
    4143    PRIMARY KEY(`id`),   
     
    4446      FOREIGN KEY (`question_id`) 
    4547      REFERENCES `ask_question` (`id`) 
    46 ,  
     48      ON DELETE CASCADE,  
    4749    INDEX `ask_answer_FI_2` (`user_id`),  
    4850    CONSTRAINT `ask_answer_FK_2`  
     
    6567    `salt` VARCHAR(32) ,  
    6668    `has_paypal` INTEGER default 0 ,  
     69    `want_to_be_moderator` INTEGER default 0 ,  
     70    `is_moderator` INTEGER default 0 ,  
     71    `is_administrator` INTEGER default 0 ,  
     72    `deletions` INTEGER default 0 ,  
    6773    `created_at` DATETIME ,   
    6874    PRIMARY KEY(`id`)) 
     
    8187      FOREIGN KEY (`question_id`) 
    8288      REFERENCES `ask_question` (`id`) 
    83 ,  
     89      ON DELETE CASCADE,  
    8490    INDEX `ask_interest_FI_2` (`user_id`),  
    8591    CONSTRAINT `ask_interest_FK_2`  
     
    102108      FOREIGN KEY (`answer_id`) 
    103109      REFERENCES `ask_answer` (`id`) 
    104 ,  
     110      ON DELETE CASCADE,  
    105111    INDEX `ask_relevancy_FI_2` (`user_id`),  
    106112    CONSTRAINT `ask_relevancy_FK_2`  
     
    115121 
    116122CREATE TABLE `ask_question_tag`( 
    117     `question_id` INTEGER ,  
    118     `user_id` INTEGER ,  
     123    `question_id` INTEGER NOT NULL ,  
     124    `user_id` INTEGER NOT NULL ,  
    119125    `created_at` DATETIME ,  
    120126    `tag` VARCHAR(100) ,  
    121     `normalized_tag` VARCHAR(100) ,   
    122     UNIQUE KEY `pk` (`question_id`,`user_id`,`normalized_tag`),   
     127    `normalized_tag` VARCHAR(100) NOT NULL ,   
     128    PRIMARY KEY(`question_id`,`user_id`,`normalized_tag`),   
    123129    KEY `normalized_tag_index` (`normalized_tag`),   
    124130    CONSTRAINT `ask_question_tag_FK_1`  
    125131      FOREIGN KEY (`question_id`) 
    126132      REFERENCES `ask_question` (`id`) 
    127 ,  
     133      ON DELETE CASCADE,  
    128134    INDEX `ask_question_tag_FI_2` (`user_id`),  
    129135    CONSTRAINT `ask_question_tag_FK_2`  
     
    132138) 
    133139Type=InnoDB; 
     140# ----------------------------------------------------------------------- 
     141# ask_report_question  
     142# ----------------------------------------------------------------------- 
     143DROP TABLE IF EXISTS `ask_report_question`; 
     144 
     145CREATE TABLE `ask_report_question`( 
     146    `question_id` INTEGER NOT NULL ,  
     147    `user_id` INTEGER NOT NULL ,  
     148    `created_at` DATETIME ,   
     149    PRIMARY KEY(`question_id`,`user_id`),   
     150    CONSTRAINT `ask_report_question_FK_1`  
     151      FOREIGN KEY (`question_id`) 
     152      REFERENCES `ask_question` (`id`) 
     153      ON DELETE CASCADE,  
     154    INDEX `ask_report_question_FI_2` (`user_id`),  
     155    CONSTRAINT `ask_report_question_FK_2`  
     156      FOREIGN KEY (`user_id`) 
     157      REFERENCES `ask_user` (`id`) 
     158) 
     159Type=InnoDB; 
     160# ----------------------------------------------------------------------- 
     161# ask_report_answer  
     162# ----------------------------------------------------------------------- 
     163DROP TABLE IF EXISTS `ask_report_answer`; 
     164 
     165CREATE TABLE `ask_report_answer`( 
     166    `answer_id` INTEGER NOT NULL ,  
     167    `user_id` INTEGER NOT NULL ,  
     168    `created_at` DATETIME ,   
     169    PRIMARY KEY(`answer_id`,`user_id`),   
     170    CONSTRAINT `ask_report_answer_FK_1`  
     171      FOREIGN KEY (`answer_id`) 
     172      REFERENCES `ask_answer` (`id`) 
     173      ON DELETE CASCADE,  
     174    INDEX `ask_report_answer_FI_2` (`user_id`),  
     175    CONSTRAINT `ask_report_answer_FK_2`  
     176      FOREIGN KEY (`user_id`) 
     177      REFERENCES `ask_user` (`id`) 
     178) 
     179Type=InnoDB; 
     180   
     181   
    134182   
    135183   
  • trunk/frontend/config/logging.yml

    r2 r55  
    11prod: 
    2   level:  err 
     2  level:  warning 
    33 
    44dev: 
  • trunk/frontend/config/routing.yml

    r44 r55  
    5353  url:   /password_request 
    5454  param: { module: user, action: passwordRequest } 
     55 
     56user_report_question: 
     57  url:   /report_question/:id 
     58  param: { module: user, action: reportQuestion } 
     59 
     60user_report_answer: 
     61  url:   /report_answer/:id 
     62  param: { module: user, action: reportAnswer } 
    5563 
    5664# login 
  • trunk/frontend/config/view.yml

    r20 r55  
    1919  slots: 
    2020    sidebar:      [sidebar, default] 
     21 
     22  use_default_slots: on 
     23 
  • trunk/frontend/lib/helper/AnswerHelper.php

    r39 r55  
    4949} 
    5050 
     51function link_to_report_answer($answer, $user) 
     52{ 
     53  use_helper('Javascript'); 
     54 
     55  $text = '[report to moderator]'; 
     56  if ($user->isAuthenticated()) 
     57  { 
     58    $has_already_reported_answer = ReportAnswerPeer::retrieveByPk($answer->getId(), $user->getSubscriberId()); 
     59    if ($has_already_reported_answer) 
     60    { 
     61      // already spam for this user 
     62      return '[reported as spam]'; 
     63    } 
     64    else 
     65    { 
     66      return link_to_remote($text, array( 
     67        'url'      => '@user_report_answer?id='.$answer->getId(), 
     68        'update'   => array('success' => 'report_answer_'.$answer->getId()), 
     69        'loading'  => "Element.show('indicator')", 
     70        'complete' => "Element.hide('indicator');".visual_effect('highlight', 'report_answer_'.$answer->getId()), 
     71      )); 
     72    } 
     73  } 
     74  else 
     75  { 
     76    return link_to_login($text); 
     77  } 
     78} 
     79 
    5180?> 
  • trunk/frontend/lib/helper/QuestionHelper.php

    r38 r55  
    1818} 
    1919 
     20function link_to_report_question($question, $user) 
     21{ 
     22  use_helper('Javascript'); 
     23 
     24  $text = '[report to moderator]'; 
     25  if ($user->isAuthenticated()) 
     26  { 
     27    $has_already_reported_question = ReportQuestionPeer::retrieveByPk($question->getId(), $user->getSubscriberId()); 
     28    if ($has_already_reported_question) 
     29    { 
     30      // already spam for this user 
     31      return '[reported as spam]'; 
     32    } 
     33    else 
     34    { 
     35      return link_to_remote($text, array( 
     36        'url'      => '@user_report_question?id='.$question->getId(), 
     37        'update'   => array('success' => 'report_question_'.$question->getId()), 
     38        'loading'  => "Element.show('indicator')", 
     39        'complete' => "Element.hide('indicator');".visual_effect('highlight', 'report_question_'.$question->getId()), 
     40      )); 
     41    } 
     42  } 
     43  else 
     44  { 
     45    return link_to_login($text); 
     46  } 
     47} 
     48 
    2049?> 
  • trunk/frontend/lib/myUser.class.php

    r44 r55  
    99 
    1010    $this->addCredential('subscriber'); 
     11 
     12    if ($user->getIsModerator()) 
     13    { 
     14      $this->addCredential('moderator'); 
     15    } 
     16 
     17    if ($user->getIsAdministrator()) 
     18    { 
     19      $this->addCredential('administrator'); 
     20    } 
     21 
    1122    $this->setAttribute('nickname', $user->getNickname(), 'subscriber'); 
    1223  } 
  • trunk/frontend/modules/answer/templates/_answer.php

    r40 r55  
    88  <?php echo $answer->getHtmlBody() ?> 
    99  <div class="subtitle" style="margin-top: -8px">answered by <?php echo link_to_profile($answer->getUser()) ?> on <?php echo format_date($answer->getCreatedAt(), 'f') ?></div> 
     10  <div class="options" id="report_answer_<?php echo $answer->getId() ?>"> 
     11    <?php echo link_to_report_answer($answer, $user) ?> 
     12    <?php echo include_partial('moderator/answer_options', array('answer' => $answer)) ?> 
     13  </div> 
    1014</div> 
    1115 
  • trunk/frontend/modules/question/templates/_question_list.php

    r38 r55  
    1414    <?php echo truncate_text(strip_tags($question->getHtmlBody()), 200) ?> 
    1515 
    16     <div class="tags"> 
     16    <div class="options"> 
    1717 
    1818    <?php if ($question->getAnswers()): ?> 
     
    3030    </div> 
    3131 
     32    <div class="options" id="report_question_<?php echo $question->getId() ?>"> 
     33      <?php echo link_to_report_question($question, $user) ?> 
     34      <?php include_partial('moderator/question_options', array('question' => $question)) ?> 
     35    </div> 
     36 
    3237  </div> 
    3338</div> 
  • trunk/frontend/modules/question/templates/showSuccess.php

    r48 r55  
    1 <?php use_helpers('Date', 'Answer') ?> 
     1<?php use_helpers('Date', 'Answer', 'Question') ?> 
    22 
    33<h1></h1> 
     
    1414  <div class="question_body"> 
    1515    <?php echo $question->getHtmlBody() ?> 
     16    <div class="options" id="report_question_<?php echo $question->getId() ?>"> 
     17      <?php echo link_to_report_question($question, $user) ?> 
     18      <?php include_partial('moderator/question_options', array('question' => $question)) ?> 
     19    </div> 
    1620  </div> 
    1721</div> 
  • trunk/frontend/modules/sidebar/templates/defaultSuccess.php

    r38 r55  
    1111<h2>browse askeet</h2> 
    1212<?php echo include_partial('rss_links') ?> 
     13 
     14<?php echo include_partial('sidebar/moderation') ?> 
     15 
     16<?php echo include_partial('sidebar/administration') ?> 
  • trunk/frontend/modules/sidebar/templates/questionSuccess.php

    r38 r55  
    2828  </div> 
    2929<?php endif ?> 
     30 
     31<?php echo include_partial('sidebar/moderation') ?> 
     32 
     33<?php echo include_partial('sidebar/administration') ?> 
  • trunk/frontend/modules/tag/actions/actions.class.php

    r53 r55  
    4141 
    4242    // clear the question tag list fragment in cache 
    43     $this->getContext()->getViewCacheManager()->remove('@question?stripped_title='.$this->question->getStrippedTitle(), 'fragment_question_tags'); 
     43    if (SF_CACHE) 
     44    { 
     45      $this->getContext()->getViewCacheManager()->remove('@question?stripped_title='.$this->question->getStrippedTitle(), 'fragment_question_tags'); 
     46    } 
    4447  } 
    4548 
     
    6164 
    6265    // clear the question tag list fragment in cache 
    63     $this->getContext()->getViewCacheManager()->remove('@question?stripped_title='.$this->question->getStrippedTitle(), 'fragment_question_tags'); 
     66    if (SF_CACHE) 
     67    { 
     68      $this->getContext()->getViewCacheManager()->remove('@question?stripped_title='.$this->question->getStrippedTitle(), 'fragment_question_tags'); 
     69    } 
    6470  } 
    6571 
  • trunk/frontend/modules/tag/templates/_question_tags.php

    r53 r55  
    1717        <?php echo link_to($tag, '@tag?tag='.$tag, 'rel=tag') ?> 
    1818      <?php endif ?> 
     19 
     20      <?php if ($user->hasCredential('moderator')): ?> 
     21        &nbsp;<?php echo link_to('[remove tag]', 'moderator/deleteTagForQuestion?tag='.$tag.'&question_id='.$question->getId(), 'confirm=Are you sure you want to delete this tag for this question?') ?> 
     22      <?php endif ?> 
    1923    </li> 
    2024  <?php endforeach ?> 
  • trunk/frontend/modules/user/actions/actions.class.php

    r48 r55  
    166166  } 
    167167 
     168  public function executeReportQuestion() 
     169  { 
     170    $this->question = QuestionPeer::retrieveByPk($this->getRequestParameter('id')); 
     171    $this->forward404Unless($this->question); 
     172 
     173    $spam = new ReportQuestion(); 
     174    $spam->setQuestionId($this->question->getId()); 
     175    $spam->setUserId($this->getUser()->getSubscriberId()); 
     176    $spam->save(); 
     177  } 
     178 
     179  public function executeReportAnswer() 
     180  { 
     181    $this->answer = AnswerPeer::retrieveByPk($this->getRequestParameter('id')); 
     182    $this->forward404Unless($this->answer); 
     183 
     184    $spam = new ReportAnswer(); 
     185    $spam->setAnswerId($this->answer->getId()); 
     186    $spam->setUserId($this->getUser()->getSubscriberId()); 
     187    $spam->save(); 
     188  } 
     189 
    168190  public function handleErrorLogin() 
    169191  { 
     
    200222    $this->subscriber->setEmail($this->getRequestParameter('email')); 
    201223    $this->subscriber->setHasPaypal($this->getRequestParameter('has_paypal'), 0); 
     224    $this->subscriber->setWantToBeModerator($this->getRequestParameter('want_to_be_moderator')); 
    202225  } 
    203226 
  • trunk/frontend/modules/user/config/view.yml

    r20 r55  
    44interestedSuccess: 
    55  has_layout: off 
     6 
     7reportQuestionSuccess: 
     8  has_layout: off 
     9 
     10reportAnswerSuccess: 
     11  has_layout: off 
  • trunk/frontend/modules/user/templates/showSuccess.php

    r46 r55  
    11<?php use_helpers('Date', 'Question', 'Text', 'Object') ?> 
    22 
    3 <h1><?php echo $subscriber ?>'s profile</h1> 
     3<h1><?php echo $subscriber ?>'s profile 
     4<?php if ($subscriber->getIsModerator()): ?> [moderator]<?php endif ?> 
     5<?php if ($subscriber->getIsAdministrator()): ?> [administrator]<?php endif ?> 
     6</h1> 
     7 
     8<?php echo include_partial('administrator/user_options', array('subscriber' => $subscriber)) ?> 
    49 
    510<?php if ($subscriber->getId() == $user->getSubscriberId()): ?> 
     
    2631    <br class="clearleft" /> 
    2732 
    28     <?php echo form_error('has_paypal') ?> 
    2933    <label for="has_paypal">paypal account?</label> 
    3034    <?php echo object_checkbox_tag($subscriber, 'getHasPaypal') ?> 
     
    4044    <?php echo input_password_tag('password_bis', '', 'size=30') ?> 
    4145    <br class="clearleft" /> 
     46 
     47    <?php if (!$subscriber->getIsModerator()): ?> 
     48      <label for="want_to_be_moderator">do you want to be a moderator?</label> 
     49      <?php echo object_checkbox_tag($subscriber, 'getWantToBeModerator') ?> 
     50      <br class="clearleft" /> 
     51    <?php endif ?> 
    4252 
    4353    </fieldset> 
  • trunk/frontend/templates/layout.php

    r40 r55  
    2727    <ul> 
    2828      <?php if ($user->isAuthenticated()): ?> 
     29        <li><?php echo link_to($user->getAttribute('nickname', '', 'subscriber').' profile', '@current_user_profile') ?></li> 
    2930        <li><?php echo link_to('sign out', '@logout') ?></li> 
    30         <li><?php echo link_to($user->getAttribute('nickname', '', 'subscriber').' profile', '@current_user_profile') ?></li> 
    3131      <?php else: ?> 
    3232        <li><?php echo link_to('sign in/register', '@login') ?></li> 
  • trunk/lib/model/Answer.php

    r23 r55  
    3939    $this->setHtmlBody(markdown($v)); 
    4040  } 
     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  } 
    4181} 
    4282 
  • trunk/lib/model/AnswerPeer.php

    r40 r55  
    5050  } 
    5151 
    52   public function getRecent($max = 10) 
     52  public static function getRecent($max = 10) 
    5353  { 
    5454    $c = new Criteria(); 
     
    5858 
    5959    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); 
    6086  } 
    6187 
  • trunk/lib/model/Question.php

    r42 r55  
    145145    $c->addAsColumn('relevancy', AnswerPeer::RELEVANCY_UP.' / ('.AnswerPeer::RELEVANCY_UP.' + '.AnswerPeer::RELEVANCY_DOWN.')'); 
    146146    $c->addDescendingOrderByColumn('relevancy'); 
     147    $c->addDescendingOrderByColumn(AnswerPeer::RELEVANCY_UP); 
    147148 
    148149    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    } 
    149187  } 
    150188} 
  • trunk/lib/model/QuestionPeer.php

    r42 r55  
    103103  } 
    104104 
     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 
    105131  private static function addPermanentTagToCriteria($criteria) 
    106132  { 
  • trunk/lib/model/QuestionTagPeer.php

    r40 r55  
    147147    return $tags; 
    148148  } 
     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  } 
    149238} 
    150239 
  • trunk/lib/model/UserPeer.php

    r48 r55  
    4545    return null; 
    4646  } 
     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  } 
    4799} 
    48100 
  • trunk/lib/model/map/AnswerMapBuilder.php

    r23 r55  
    7979        $tMap->addColumn('RELEVANCY_DOWN', 'RelevancyDown', 'int', CreoleTypes::INTEGER, false); 
    8080 
     81        $tMap->addColumn('REPORTS', 'Reports', 'int', CreoleTypes::INTEGER, false); 
     82 
    8183        $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 
    8284                 
  • trunk/lib/model/map/QuestionMapBuilder.php

    r23 r55  
    7979        $tMap->addColumn('INTERESTED_USERS', 'InterestedUsers', 'int', CreoleTypes::INTEGER, false); 
    8080 
     81        $tMap->addColumn('REPORTS', 'Reports', 'int', CreoleTypes::INTEGER, false); 
     82 
    8183        $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 
    8284 
  • trunk/lib/model/map/QuestionTagMapBuilder.php

    r31 r55  
    6565        $tMap->setUseIdGenerator(false); 
    6666 
    67         $tMap->addForeignKey('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); 
    6868 
    69         $tMap->addForeignKey('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); 
    7070 
    7171        $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 
     
    7373        $tMap->addColumn('TAG', 'Tag', 'string', CreoleTypes::VARCHAR, false); 
    7474 
    75         $tMap->addColumn('NORMALIZED_TAG', 'NormalizedTag', 'string', CreoleTypes::VARCHAR, false); 
     75        $tMap->addPrimaryKey('NORMALIZED_TAG', 'NormalizedTag', 'string', CreoleTypes::VARCHAR, true, 100); 
    7676                 
    7777    } // doBuild() 
  • trunk/lib/model/map/UserMapBuilder.php

    r44 r55  
    8181        $tMap->addColumn('HAS_PAYPAL', 'HasPaypal', 'boolean', CreoleTypes::BOOLEAN, false); 
    8282 
     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 
    8391        $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 
    8492                 
  • trunk/lib/model/om/BaseAnswer.php

    r23 r55  
    7979 
    8080    /** 
     81     * The value for the reports field. 
     82     * @var int 
     83     */ 
     84    protected $reports = 0; 
     85 
     86 
     87    /** 
    8188     * The value for the created_at field. 
    8289     * @var int 
     
    105112     */ 
    106113    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; 
    107126 
    108127    /** 
     
    195214 
    196215        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; 
    197227    } 
    198228 
     
    349379 
    350380    /** 
     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    /** 
    351397     * Set the value of [created_at] column. 
    352398     *  
     
    403449            $this->relevancy_down = $rs->getInt($startcol + 6); 
    404450 
    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); 
    406454 
    407455            $this->resetModified(); 
     
    410458 
    411459            // 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). 
    413461 
    414462        } catch (Exception $e) { 
     
    546594            } 
    547595 
     596            if ($this->collReportAnswers !== null) { 
     597                foreach($this->collReportAnswers as $referrerFK) { 
     598                    if (!$referrerFK->isDeleted()) { 
     599                        $affectedRows += $referrerFK->save($con); 
     600                    } 
     601                } 
     602            } 
     603 
    548604            $this->alreadyInSave = false; 
    549605        } 
     
    620676                } 
    621677 
     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 
    622686 
    623687            $this->alreadyInValidation = false; 
     
    675739                break; 
    676740            case 7: 
     741                return $this->getReports(); 
     742                break; 
     743            case 8: 
    677744                return $this->getCreatedAt(); 
    678745                break; 
     
    704771            $keys[5] => $this->getRelevancyUp(), 
    705772            $keys[6] => $this->getRelevancyDown(), 
    706             $keys[7] => $this->getCreatedAt(), 
     773            $keys[7] => $this->getReports(), 
     774            $keys[8] => $this->getCreatedAt(), 
    707775        ); 
    708776        return $result; 
     
    759827                break; 
    760828            case 7: 
     829                $this->setReports($value); 
     830                break; 
     831            case 8: 
    761832                $this->setCreatedAt($value); 
    762833                break; 
     
    791862        if (array_key_exists($keys[5], $arr)) $this->setRelevancyUp($arr[$keys[5]]); 
    792863        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]]); 
    794866    } 
    795867 
     
    810882        if ($this->isColumnModified(AnswerPeer::RELEVANCY_UP)) $criteria->add(AnswerPeer::RELEVANCY_UP, $this->relevancy_up); 
    811883        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); 
    812885        if ($this->isColumnModified(AnswerPeer::CREATED_AT)) $criteria->add(AnswerPeer::CREATED_AT, $this->created_at); 
    813886 
     
    876949 
    877950        $copyObj->setRelevancyDown($this->relevancy_down); 
     951 
     952        $copyObj->setReports($this->reports); 
    878953 
    879954        $copyObj->setCreatedAt($this->created_at); 
     
    887962            foreach($this->getRelevancys() as $relObj) { 
    888963                $copyObj->addRelevancy($relObj->copy($deepCopy)); 
     964            } 
     965 
     966            foreach($this->getReportAnswers() as $relObj) { 
     967                $copyObj->addReportAnswer($relObj->copy($deepCopy)); 
    889968            } 
    890969 
     
    11931272    } 
    11941273 
     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 
    11951429} // BaseAnswer 
  • trunk/lib/model/om/BaseAnswerPeer.php

    r23 r55  
    2525 
    2626    /** The total number of columns. */ 
    27     const NUM_COLUMNS = 8
     27    const NUM_COLUMNS = 9
    2828 
    2929    /** The number of lazy-loaded columns. */ 
     
    5252    const RELEVANCY_DOWN = 'ask_answer.RELEVANCY_DOWN'; 
    5353 
     54    /** the column name for the REPORTS field */ 
     55    const REPORTS = 'ask_answer.REPORTS'; 
     56 
    5457    /** the column name for the CREATED_AT field */ 
    5558    const CREATED_AT = 'ask_answer.CREATED_AT'; 
     
    6669     */ 
    6770    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,
    7275    ); 
    7376 
     
    7982     */ 
    8083    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,
    8588    ); 
    8689 
     
    196199 
    197200        $criteria->addSelectColumn(AnswerPeer::RELEVANCY_DOWN); 
     201 
     202        $criteria->addSelectColumn(AnswerPeer::REPORTS); 
    198203 
    199204        $criteria->addSelectColumn(AnswerPeer::CREATED_AT); 
  • trunk/lib/model/om/BaseQuestion.php

    r31 r55  
    7979 
    8080    /** 
     81     * The value for the reports field. 
     82     * @var int 
     83     */ 
     84    protected $reports = 0; 
     85 
     86 
     87    /** 
    8188     * The value for the created_at field. 
    8289     * @var int 
     
    131138     */ 
    132139    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; 
    133152 
    134153    /** 
     
    221240 
    222241        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; 
    223253    } 
    224254 
     
    402432 
    403433    /** 
     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    /** 
    404450     * Set the value of [created_at] column. 
    405451     *  
     
    480526            $this->interested_users = $rs->getInt($startcol + 6); 
    481527 
    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); 
    485533 
    486534            $this->resetModified(); 
     
    489537 
    490538            // 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). 
    492540 
    493541        } catch (Exception $e) { 
     
    635683            } 
    636684 
     685            if ($this->collReportQuestions !== null) { 
     686                foreach($this->collReportQuestions as $referrerFK) { 
     687                    if (!$referrerFK->isDeleted()) { 
     688                        $affectedRows += $referrerFK->save($con); 
     689                    } 
     690                } 
     691            } 
     692 
    637693            $this->alreadyInSave = false; 
    638694        } 
     
    719775                } 
    720776 
     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 
    721785 
    722786            $this->alreadyInValidation = false; 
     
    774838                break; 
    775839            case 7: 
     840                return $this->getReports(); 
     841                break; 
     842            case 8: 
    776843                return $this->getCreatedAt(); 
    777844                break; 
    778             case 8
     845            case 9
    779846                return $this->getUpdatedAt(); 
    780847                break; 
     
    806873            $keys[5] => $this->getHtmlBody(), 
    807874            $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(), 
    810878        ); 
    811879        return $result; 
     
    862930                break; 
    863931            case 7: 
     932                $this->setReports($value); 
     933                break; 
     934            case 8: 
    864935                $this->setCreatedAt($value); 
    865936                break; 
    866             case 8
     937            case 9
    867938                $this->setUpdatedAt($value); 
    868939                break; 
     
    897968        if (array_key_exists($keys[5], $arr)) $this->setHtmlBody($arr[$keys[5]]); 
    898969        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]]); 
    901973    } 
    902974 
     
    917989        if ($this->isColumnModified(QuestionPeer::HTML_BODY)) $criteria->add(QuestionPeer::HTML_BODY, $this->html_body); 
    918990        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); 
    919992        if ($this->isColumnModified(QuestionPeer::CREATED_AT)) $criteria->add(QuestionPeer::CREATED_AT, $this->created_at); 
    920993        if ($this->isColumnModified(QuestionPeer::UPDATED_AT)) $criteria->add(QuestionPeer::UPDATED_AT, $this->updated_at); 
     
    9841057 
    9851058        $copyObj->setInterestedUsers($this->interested_users); 
     1059 
     1060        $copyObj->setReports($this->reports); 
    9861061 
    9871062        $copyObj->setCreatedAt($this->created_at); 
     
    10051080            foreach($this->getQuestionTags() as $relObj) { 
    10061081                $copyObj->addQuestionTag($relObj->copy($deepCopy)); 
     1082            } 
     1083 
     1084            foreach($this->getReportQuestions() as $relObj) { 
     1085                $copyObj->addReportQuestion($relObj->copy($deepCopy)); 
    10071086            } 
    10081087 
     
    15701649    } 
    15711650 
     1651    /** 
     1652     * Temporary storage of collReportQuestions to save a possible db hit in 
     1653     * the event objects are add to the collection, but the 
     1654     * complete collection is never requested. 
     1655     * @return void 
     1656     */ 
     1657    public function initReportQuestions() 
     1658    { 
     1659        if ($this->collReportQuestions === null) { 
     1660            $this->collReportQuestions = array(); 
     1661        } 
     1662    } 
     1663 
     1664    /** 
     1665     * If this collection has already been initialized with 
     1666     * an identical criteria, it returns the collection. 
     1667     * Otherwise if this Question has previously 
     1668     * been saved, it will retrieve related ReportQuestions from storage. 
     1669     * If this Question is new, it will return 
     1670     * an empty collection or the current collection, the criteria 
     1671     * is ignored on a new object. 
     1672     * 
     1673     * @param Connection $con 
     1674     * @param Criteria $criteria 
     1675     * @throws PropelException 
     1676     */ 
     1677    public function getReportQuestions($criteria = null, $con = null) 
     1678    { 
     1679        // include the Peer class 
     1680        include_once 'model/om/BaseReportQuestionPeer.php'; 
     1681        if ($criteria === null) { 
     1682            $criteria = new Criteria(); 
     1683        } 
     1684        elseif ($criteria instanceof Criteria) 
     1685        { 
     1686            $criteria = clone $criteria; 
     1687        } 
     1688 
     1689        if ($this->collReportQuestions === null) { 
     1690            if ($this->isNew()) { 
     1691               $this->collReportQuestions = array(); 
     1692            } else { 
     1693 
     1694                $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 
     1695 
     1696                ReportQuestionPeer::addSelectColumns($criteria); 
     1697                $this->collReportQuestions = ReportQuestionPeer::doSelect($criteria, $con); 
     1698            } 
     1699        } else { 
     1700            // criteria has no effect for a new object 
     1701            if (!$this->isNew()) { 
     1702                // the following code is to determine if a new query is 
     1703                // called for.  If the criteria is the same as the last 
     1704                // one, just return the collection. 
     1705 
     1706 
     1707                $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 
     1708 
     1709                ReportQuestionPeer::addSelectColumns($criteria); 
     1710                if (!isset($this->lastReportQuestionCriteria) || !$this->lastReportQuestionCriteria->equals($criteria)) { 
     1711                    $this->collReportQuestions = ReportQuestionPeer::doSelect($criteria, $con); 
     1712                } 
     1713            } 
     1714        } 
     1715        $this->lastReportQuestionCriteria = $criteria; 
     1716        return $this->collReportQuestions; 
     1717    } 
     1718 
     1719    /** 
     1720     * Returns the number of related ReportQuestions. 
     1721     * 
     1722     * @param Criteria $criteria 
     1723     * @param Connection $con 
     1724     * @throws PropelException 
     1725     */ 
     1726    public function countReportQuestions($criteria = null, $con = null) 
     1727    { 
     1728        // include the Peer class 
     1729        include_once 'model/om/BaseReportQuestionPeer.php'; 
     1730        if ($criteria === null) { 
     1731            $criteria = new Criteria(); 
     1732        } 
     1733        elseif ($criteria instanceof Criteria) 
     1734        { 
     1735            $criteria = clone $criteria; 
     1736        } 
     1737 
     1738        $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 
     1739 
     1740        return ReportQuestionPeer::doCount($criteria, $con); 
     1741    } 
     1742 
     1743    /** 
     1744     * Method called to associate a ReportQuestion object to this object 
     1745     * through the ReportQuestion foreign key attribute 
     1746     * 
     1747     * @param ReportQuestion $l ReportQuestion 
     1748     * @return void 
     1749     * @throws PropelException 
     1750     */ 
     1751    public function addReportQuestion(ReportQuestion $l) 
     1752    { 
     1753        $this->collReportQuestions[] = $l; 
     1754        $l->setQuestion($this); 
     1755    } 
     1756 
     1757 
     1758    /** 
     1759     * If this collection has already been initialized with 
     1760     * an identical criteria, it returns the collection. 
     1761     * Otherwise if this Question is new, it will return 
     1762     * an empty collection; or if this Question has previously 
     1763     * been saved, it will retrieve related ReportQuestions from storage. 
     1764     * 
     1765     * This method is protected by default in order to keep the public 
     1766     * api reasonable.  You can provide public methods for those you 
     1767     * actually need in Question. 
     1768     */ 
     1769    public function getReportQuestionsJoinUser($criteria = null, $con = null) 
     1770    { 
     1771        // include the Peer class 
     1772        include_once 'model/om/BaseReportQuestionPeer.php'; 
     1773        if ($criteria === null) { 
     1774            $criteria = new Criteria(); 
     1775        } 
     1776        elseif ($criteria instanceof Criteria) 
     1777        { 
     1778            $criteria = clone $criteria; 
     1779        } 
     1780 
     1781        if ($this->collReportQuestions === null) { 
     1782            if ($this->isNew()) { 
     1783                $this->collReportQuestions = array(); 
     1784            } else { 
     1785 
     1786                $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 
     1787 
     1788                $this->collReportQuestions = ReportQuestionPeer::doSelectJoinUser($criteria, $con); 
     1789            } 
     1790        } else { 
     1791            // the following code is to determine if a new query is 
     1792            // called for.  If the criteria is the same as the last 
     1793            // one, just return the collection. 
     1794 
     1795            $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 
     1796 
     1797            if (!isset($this->lastReportQuestionCriteria) || !$this->lastReportQuestionCriteria->equals($criteria)) { 
     1798                $this->collReportQuestions = ReportQuestionPeer::doSelectJoinUser($criteria, $con); 
     1799            } 
     1800        } 
     1801        $this->lastReportQuestionCriteria = $criteria; 
     1802 
     1803        return $this->collReportQuestions; 
     1804    } 
     1805 
    15721806} // BaseQuestion 
  • trunk/lib/model/om/BaseQuestionPeer.php

    r23 r55  
    2525 
    2626    /** The total number of columns. */ 
    27     const NUM_COLUMNS = 9
     27    const NUM_COLUMNS = 10
    2828 
    2929    /** The number of lazy-loaded columns. */ 
     
    5252    const INTERESTED_USERS = 'ask_question.INTERESTED_USERS'; 
    5353 
     54    /** the column name for the REPORTS field */ 
     55    const REPORTS = 'ask_question.REPORTS'; 
     56 
    5457    /** the column name for the CREATED_AT field */ 
    5558    const CREATED_AT = 'ask_question.CREATED_AT'; 
     
    6972     */ 
    7073    private static $fieldNames = array ( 
    71         BasePeer::TYPE_PHPNAME => array ('Id', 'UserId', 'Title', 'StrippedTitle', 'Body', 'HtmlBody', 'InterestedUsers', 'CreatedAt', 'UpdatedAt', ), 
    72         BasePeer::TYPE_COLNAME => array (QuestionPeer::ID, QuestionPeer::USER_ID, QuestionPeer::TITLE, QuestionPeer::STRIPPED_TITLE, QuestionPeer::BODY, QuestionPeer::HTML_BODY, QuestionPeer::INTERESTED_USERS, QuestionPeer::CREATED_AT, QuestionPeer::UPDATED_AT, ), 
    73         BasePeer::TYPE_FIELDNAME => array ('id', 'user_id', 'title', 'stripped_title', 'body', 'html_body', 'interested_users', 'created_at', 'updated_at', ), 
    74         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8,
     74        BasePeer::TYPE_PHPNAME => array ('Id', 'UserId', 'Title', 'StrippedTitle', 'Body', 'HtmlBody', 'InterestedUsers', 'Reports', 'CreatedAt', 'UpdatedAt', ), 
     75        BasePeer::TYPE_COLNAME => array (QuestionPeer::ID, QuestionPeer::USER_ID, QuestionPeer::TITLE, QuestionPeer::STRIPPED_TITLE, QuestionPeer::BODY, QuestionPeer::HTML_BODY, QuestionPeer::INTERESTED_USERS, QuestionPeer::REPORTS, QuestionPeer::CREATED_AT, QuestionPeer::UPDATED_AT, ), 
     76        BasePeer::TYPE_FIELDNAME => array ('id', 'user_id', 'title', 'stripped_title', 'body', 'html_body', 'interested_users', 'reports', 'created_at', 'updated_at', ), 
     77        BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
    7578    ); 
    7679 
     
    8285     */ 
    8386    private static $fieldKeys = array ( 
    84         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'UserId' => 1, 'Title' => 2, 'StrippedTitle' => 3, 'Body' => 4, 'HtmlBody' => 5, 'InterestedUsers' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), 
    85         BasePeer::TYPE_COLNAME => array (QuestionPeer::ID => 0, QuestionPeer::USER_ID => 1, QuestionPeer::TITLE => 2, QuestionPeer::STRIPPED_TITLE => 3, QuestionPeer::BODY => 4, QuestionPeer::HTML_BODY => 5, QuestionPeer::INTERESTED_USERS => 6, QuestionPeer::CREATED_AT => 7, QuestionPeer::UPDATED_AT => 8, ), 
    86         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_id' => 1, 'title' => 2, 'stripped_title' => 3, 'body' => 4, 'html_body' => 5, 'interested_users' => 6, 'created_at' => 7, 'updated_at' => 8, ), 
    87         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8,
     87        BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'UserId' => 1, 'Title' => 2, 'StrippedTitle' => 3, 'Body' => 4, 'HtmlBody' => 5, 'InterestedUsers' => 6, 'Reports' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), 
     88        BasePeer::TYPE_COLNAME => array (QuestionPeer::ID => 0, QuestionPeer::USER_ID => 1, QuestionPeer::TITLE => 2, QuestionPeer::STRIPPED_TITLE => 3, QuestionPeer::BODY => 4, QuestionPeer::HTML_BODY => 5, QuestionPeer::INTERESTED_USERS => 6, QuestionPeer::REPORTS => 7, QuestionPeer::CREATED_AT => 8, QuestionPeer::UPDATED_AT => 9, ), 
     89        BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_id' => 1, 'title' => 2, 'stripped_title' => 3, 'body' => 4, 'html_body' => 5, 'interested_users' => 6, 'reports' => 7, 'created_at' => 8, 'updated_at' => 9, ), 
     90        BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
    8891    ); 
    8992 
     
    199202 
    200203        $criteria->addSelectColumn(QuestionPeer::INTERESTED_USERS); 
     204 
     205        $criteria->addSelectColumn(QuestionPeer::REPORTS); 
    201206 
    202207        $criteria->addSelectColumn(QuestionPeer::CREATED_AT); 
  • trunk/lib/model/om/BaseQuestionTag.php

    r31 r55  
    662662        $criteria = new Criteria(QuestionTagPeer::DATABASE_NAME); 
    663663 
     664        $criteria->add(QuestionTagPeer::QUESTION_ID, $this->question_id); 
     665        $criteria->add(QuestionTagPeer::USER_ID, $this->user_id); 
     666        $criteria->add(QuestionTagPeer::NORMALIZED_TAG, $this->normalized_tag); 
    664667 
    665668        return $criteria; 
     
    667670 
    668671    /** 
    669      * Returns NULL since this table doesn't have a primary key
    670      * This method exists only for BC and is deprecated! 
    671      * @return null 
     672     * Returns the composite primary key for this object
     673     * The array elements will be in same order as specified in XML. 
     674     * @return array 
    672675     */ 
    673676    public function getPrimaryKey() 
    674677    { 
    675         return null; 
    676     } 
    677  
    678     /** 
    679      * Dummy primary key setter. 
    680      * 
    681      * This function only exists to preserve backwards compatibility.  It is no longer 
    682      * needed or required by the Persistent interface.  It will be removed in next BC-breaking 
    683      * release of Propel. 
    684      * 
    685      * @deprecated 
    686      */ 
    687      public function setPrimaryKey($pk) 
    688      { 
    689          // do nothing, because this object doesn't have any primary keys 
    690      } 
     678        $pks = array(); 
     679 
     680        $pks[0] = $this->getQuestionId(); 
     681 
     682        $pks[1] = $this->getUserId(); 
     683 
     684        $pks[2] = $this->getNormalizedTag(); 
     685 
     686        return $pks; 
     687    } 
     688 
     689    /** 
     690     * Set the [composite] primary key. 
     691     * 
     692     * @param array $keys The elements of the composite key (order must match the order in XML file). 
     693     * @return void 
     694     */ 
     695    public function setPrimaryKey($keys) 
     696    { 
     697 
     698        $this->setQuestionId($keys[0]); 
     699 
     700        $this->setUserId($keys[1]); 
     701 
     702        $this->setNormalizedTag($keys[2]); 
     703 
     704    } 
    691705 
    692706    /** 
     
    703717    { 
    704718 
    705         $copyObj->setQuestionId($this->question_id); 
    706  
    707         $copyObj->setUserId($this->user_id); 
    708  
    709719        $copyObj->setCreatedAt($this->created_at); 
    710720 
    711721        $copyObj->setTag($this->tag); 
    712722 
    713         $copyObj->setNormalizedTag($this->normalized_tag); 
    714  
    715723 
    716724        $copyObj->setNew(true); 
     725 
     726        $copyObj->setQuestionId(NULL); // this is a pkey column, so set to default value 
     727 
     728        $copyObj->setUserId(NULL); // this is a pkey column, so set to default value 
     729 
     730        $copyObj->setNormalizedTag(NULL); // this is a pkey column, so set to default value 
    717731 
    718732    } 
  • trunk/lib/model/om/BaseQuestionTagPeer.php

    r31 r55  
    186186    } 
    187187 
    188     const COUNT = 'COUNT(*)'; 
    189     const COUNT_DISTINCT = 'COUNT(DISTINCT *)'; 
     188    const COUNT = 'COUNT(ask_question_tag.QUESTION_ID)'; 
     189    const COUNT_DISTINCT = 'COUNT(DISTINCT ask_question_tag.QUESTION_ID)'; 
    190190 
    191191    /** 
     
    942942            $criteria = clone $values; // rename for clarity 
    943943 
     944            $comparison = $criteria->getComparison(QuestionTagPeer::QUESTION_ID); 
     945            $selectCriteria->add(QuestionTagPeer::QUESTION_ID, $criteria->remove(QuestionTagPeer::QUESTION_ID), $comparison); 
     946 
     947            $comparison = $criteria->getComparison(QuestionTagPeer::USER_ID); 
     948            $selectCriteria->add(QuestionTagPeer::USER_ID, $criteria->remove(QuestionTagPeer::USER_ID), $comparison); 
     949 
     950            $comparison = $criteria->getComparison(QuestionTagPeer::NORMALIZED_TAG); 
     951            $selectCriteria->add(QuestionTagPeer::NORMALIZED_TAG, $criteria->remove(QuestionTagPeer::NORMALIZED_TAG), $comparison); 
     952 
    944953        } else { // $values is QuestionTag object 
    945954            $criteria = $values->buildCriteria(); // gets full criteria 
     
    9981007        } elseif ($values instanceof QuestionTag) { 
    9991008 
    1000             $criteria = $values->buildCriteria(); 
     1009            $criteria = $values->buildPkeyCriteria(); 
    10011010        } else { 
    10021011            // it must be the primary key 
     
    10141023            { 
    10151024 
    1016             } 
    1017  
     1025                $vals[0][] = $value[0]; 
     1026                $vals[1][] = $value[1]; 
     1027                $vals[2][] = $value[2]; 
     1028            } 
     1029 
     1030            $criteria->add(QuestionTagPeer::QUESTION_ID, $vals[0], Criteria::IN); 
     1031            $criteria->add(QuestionTagPeer::USER_ID, $vals[1], Criteria::IN); 
     1032            $criteria->add(QuestionTagPeer::NORMALIZED_TAG, $vals[2], Criteria::IN); 
    10181033        } 
    10191034 
     
    10741089    } 
    10751090 
     1091    /** 
     1092     * Retrieve object using using composite pkey values. 
     1093     * @param int $question_id 
     1094       @param int $user_id 
     1095       @param string $normalized_tag 
     1096        
     1097     * @param Connection $con 
     1098     * @return QuestionTag 
     1099     */ 
     1100    public static function retrieveByPK( $question_id, $user_id, $normalized_tag, $con = null) { 
     1101        if ($con === null) { 
     1102            $con = Propel::getConnection(self::DATABASE_NAME); 
     1103        } 
     1104        $criteria = new Criteria(); 
     1105        $criteria->add(QuestionTagPeer::QUESTION_ID, $question_id); 
     1106        $criteria->add(QuestionTagPeer::USER_ID, $user_id); 
     1107        $criteria->add(QuestionTagPeer::NORMALIZED_TAG, $normalized_tag); 
     1108        $v = QuestionTagPeer::doSelect($criteria, $con); 
     1109        return !empty($v) ? $v[0] : null; 
     1110    } 
    10761111} // BaseQuestionTagPeer 
    10771112 
  • trunk/lib/model/om/BaseUser.php

    r44 r55  
    8686 
    8787    /** 
     88     * The value for the want_to_be_moderator field. 
     89     * @var boolean 
     90     */ 
     91    protected $want_to_be_moderator = false; 
     92 
     93 
     94    /** 
     95     * The value for the is_moderator field. 
     96     * @var boolean 
     97     */ 
     98    protected $is_moderator = false; 
     99 
     100 
     101    /** 
     102     * The value for the is_administrator field. 
     103     * @var boolean 
     104     */ 
     105    protected $is_administrator = false; 
     106 
     107 
     108    /** 
     109     * The value for the deletions field. 
     110     * @var int 
     111     */ 
     112    protected $deletions = 0; 
     113 
     114 
     115    /** 
    88116     * The value for the created_at field. 
    89117     * @var int 
     
    150178     */ 
    151179    private $lastQuestionTagCriteria = null; 
     180 
     181    /** 
     182     * Collection to store aggregation of collReportQuestions. 
     183     * @var array 
     184     */ 
     185    protected $collReportQuestions; 
     186     
     187    /** 
     188     * The criteria used to select the current contents of collReportQuestions. 
     189     * @var Criteria 
     190     */ 
     191    private $lastReportQuestionCriteria = null; 
     192 
     193    /** 
     194     * Collection to store aggregation of collReportAnswers. 
     195     * @var array 
     196     */ 
     197    protected $collReportAnswers; 
     198     
     199    /** 
     200     * The criteria used to select the current contents of collReportAnswers. 
     201     * @var Criteria 
     202     */ 
     203    private $lastReportAnswerCriteria = null; 
    152204 
    153205    /** 
     
    251303 
    252304        return $this->has_paypal; 
     305    } 
     306 
     307    /** 
     308     * Get the [want_to_be_moderator] column value. 
     309     *  
     310     * @return boolean 
     311     */ 
     312    public function getWantToBeModerator() 
     313    { 
     314 
     315        return $this->want_to_be_moderator; 
     316    } 
     317 
     318    /** 
     319     * Get the [is_moderator] column value. 
     320     *  
     321     * @return boolean 
     322     */ 
     323    public function getIsModerator() 
     324    { 
     325 
     326        return $this->is_moderator; 
     327    } 
     328 
     329    /** 
     330     * Get the [is_administrator] column value. 
     331     *  
     332     * @return boolean 
     333     */ 
     334    public function getIsAdministrator() 
     335    { 
     336 
     337        return $this->is_administrator; 
     338    } 
     339 
     340    /** 
     341     * Get the [deletions] column value. 
     342     *  
     343     * @return int 
     344     */ 
     345    public function getDeletions() 
     346    { 
     347 
     348        return $this->deletions; 
    253349    } 
    254350 
     
    413509 
    414510    /** 
     511     * Set the value of [want_to_be_moderator] column. 
     512     *  
     513     * @param boolean $v new value 
     514     * @return void 
     515     */ 
     516    public function setWantToBeModerator($v) 
     517    { 
     518 
     519        if ($this->want_to_be_moderator !== $v || $v === false) { 
     520            $this->want_to_be_moderator = $v; 
     521            $this->modifiedColumns[] = UserPeer::WANT_TO_BE_MODERATOR; 
     522        } 
     523 
     524    } // setWantToBeModerator() 
     525 
     526    /** 
     527     * Set the value of [is_moderator] column. 
     528     *  
     529     * @param boolean $v new value 
     530     * @return void 
     531     */ 
     532    public function setIsModerator($v) 
     533    { 
     534 
     535        if ($this->is_moderator !== $v || $v === false) { 
     536            $this->is_moderator = $v; 
     537            $this->modifiedColumns[] = UserPeer::IS_MODERATOR; 
     538        } 
     539 
     540    } // setIsModerator() 
     541 
     542    /** 
     543     * Set the value of [is_administrator] column. 
     544     *  
     545     * @param boolean $v new value 
     546     * @return void 
     547     */ 
     548    public function setIsAdministrator($v) 
     549    { 
     550 
     551        if ($this->is_administrator !== $v || $v === false) { 
     552            $this->is_administrator = $v; 
     553            $this->modifiedColumns[] = UserPeer::IS_ADMINISTRATOR; 
     554        } 
     555 
     556    } // setIsAdministrator() 
     557 
     558    /** 
     559     * Set the value of [deletions] column. 
     560     *  
     561     * @param int $v new value 
     562     * @return void 
     563     */ 
     564    public function setDeletions($v) 
     565    { 
     566 
     567        if ($this->deletions !== $v || $v === 0) { 
     568            $this->deletions = $v; 
     569            $this->modifiedColumns[] = UserPeer::DELETIONS; 
     570        } 
     571 
     572    } // setDeletions() 
     573 
     574    /** 
    415575     * Set the value of [created_at] column. 
    416576     *  
     
    469629            $this->has_paypal = $rs->getBoolean($startcol + 7); 
    470630 
    471             $this->created_at = $rs->getTimestamp($startcol + 8, null); 
     631            $this->want_to_be_moderator = $rs->getBoolean($startcol + 8); 
     632 
     633            $this->is_moderator = $rs->getBoolean($startcol + 9); 
     634 
     635            $this->is_administrator = $rs->getBoolean($startcol + 10); 
     636 
     637            $this->deletions = $rs->getInt($startcol + 11); 
     638 
     639            $this->created_at = $rs->getTimestamp($startcol + 12, null); 
    472640 
    473641            $this->resetModified(); 
     
    476644 
    477645            // FIXME - using NUM_COLUMNS may be clearer. 
    478             return $startcol + 9; // 9 = UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS). 
     646            return $startcol + 13; // 13 = UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS). 
    479647 
    480648        } catch (Exception $e) { 
     
    624792            } 
    625793 
     794            if ($this->collReportQuestions !== null) { 
     795                foreach($this->collReportQuestions as $referrerFK) { 
     796                    if (!$referrerFK->isDeleted()) { 
     797                        $affectedRows += $referrerFK->save($con); 
     798                    } 
     799                } 
     800            } 
     801 
     802            if ($this->collReportAnswers !== null) { 
     803                foreach($this->collReportAnswers as $referrerFK) { 
     804                    if (!$referrerFK->isDeleted()) { 
     805                        $affectedRows += $referrerFK->save($con); 
     806                    } 
     807                } 
     808            } 
     809 
    626810            $this->alreadyInSave = false; 
    627811        } 
     
    712896                } 
    713897 
     898                if ($this->collReportQuestions !== null) { 
     899                    foreach($this->collReportQuestions as $referrerFK) { 
     900                        if (($retval = $referrerFK->validate()) !== true) { 
     901                            $failureMap = array_merge($failureMap, $retval); 
     902                        } 
     903                    } 
     904                } 
     905 
     906                if ($this->collReportAnswers !== null) { 
     907                    foreach($this->collReportAnswers as $referrerFK) { 
     908                        if (($retval = $referrerFK->validate()) !== true) { 
     909                            $failureMap = array_merge($failureMap, $retval); 
     910                        } 
     911                    } 
     912                } 
     913 
    714914 
    715915            $this->alreadyInValidation = false; 
     
    770970                break; 
    771971            case 8: 
     972                return $this->getWantToBeModerator(); 
     973                break; 
     974            case 9: 
     975                return $this->getIsModerator(); 
     976                break; 
     977            case 10: 
     978                return $this->getIsAdministrator(); 
     979                break; 
     980            case 11: 
     981                return $this->getDeletions(); 
     982                break; 
     983            case 12: 
    772984                return $this->getCreatedAt(); 
    773985                break; 
     
    8001012            $keys[6] => $this->getSalt(), 
    8011013            $keys[7] => $this->getHasPaypal(), 
    802             $keys[8] => $this->getCreatedAt(), 
     1014            $keys[8] => $this->getWantToBeModerator(), 
     1015            $keys[9] => $this->getIsModerator(), 
     1016            $keys[10] => $this->getIsAdministrator(), 
     1017            $keys[11] => $this->getDeletions(), 
     1018            $keys[12] => $this->getCreatedAt(), 
    8031019        ); 
    8041020        return $result; 
     
    8581074                break; 
    8591075            case 8: 
     1076                $this->setWantToBeModerator($value); 
     1077                break; 
     1078            case 9: 
     1079                $this->setIsModerator($value); 
     1080                break; 
     1081            case 10: 
     1082                $this->setIsAdministrator($value); 
     1083                break; 
     1084            case 11: 
     1085                $this->setDeletions($value); 
     1086                break; 
     1087            case 12: 
    8601088                $this->setCreatedAt($value); 
    8611089                break; 
     
    8911119        if (array_key_exists($keys[6], $arr)) $this->setSalt($arr[$keys[6]]); 
    8921120        if (array_key_exists($keys[7], $arr)) $this->setHasPaypal($arr[$keys[7]]); 
    893         if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); 
     1121        if (array_key_exists($keys[8], $arr)) $this->setWantToBeModerator($arr[$keys[8]]); 
     1122        if (array_key_exists($keys[9], $arr)) $this->setIsModerator($arr[$keys[9]]); 
     1123        if (array_key_exists($keys[10], $arr)) $this->setIsAdministrator($arr[$keys[10]]); 
     1124        if (array_key_exists($keys[11], $arr)) $this->setDeletions($arr[$keys[11]]); 
     1125        if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); 
    8941126    } 
    8951127 
     
    9111143        if ($this->isColumnModified(UserPeer::SALT)) $criteria->add(UserPeer::SALT, $this->salt); 
    9121144        if ($this->isColumnModified(UserPeer::HAS_PAYPAL)) $criteria->add(UserPeer::HAS_PAYPAL, $this->has_paypal); 
     1145        if ($this->isColumnModified(UserPeer::WANT_TO_BE_MODERATOR)) $criteria->add(UserPeer::WANT_TO_BE_MODERATOR, $this->want_to_be_moderator); 
     1146        if ($this->isColumnModified(UserPeer::IS_MODERATOR)) $criteria->add(UserPeer::IS_MODERATOR, $this->is_moderator); 
     1147        if ($this->isColumnModified(UserPeer::IS_ADMINISTRATOR)) $criteria->add(UserPeer::IS_ADMINISTRATOR, $this->is_administrator); 
     1148        if ($this->isColumnModified(UserPeer::DELETIONS)) $criteria->add(UserPeer::DELETIONS, $this->deletions); 
    9131149        if ($this->isColumnModified(UserPeer::CREATED_AT)) $criteria->add(UserPeer::CREATED_AT, $this->created_at); 
    9141150 
     
    9791215 
    9801216        $copyObj->setHasPaypal($this->has_paypal); 
     1217 
     1218        $copyObj->setWantToBeModerator($this->want_to_be_moderator); 
     1219 
     1220        $copyObj->setIsModerator($this->is_moderator); 
     1221 
     1222        $copyObj->setIsAdministrator($this->is_administrator); 
     1223 
     1224        $copyObj->setDeletions($this->deletions); 
    9811225 
    9821226        $copyObj->setCreatedAt($this->created_at); 
     
    10061250            foreach($this->getQuestionTags() as $relObj) { 
    10071251                $copyObj->addQuestionTag($relObj->copy($deepCopy)); 
     1252            } 
     1253 
     1254            foreach($this->getReportQuestions() as $relObj) { 
     1255                $copyObj->addReportQuestion($relObj->copy($deepCopy)); 
     1256            } 
     1257 
     1258            foreach($this->getReportAnswers() as $relObj) { 
     1259                $copyObj->addReportAnswer($relObj->copy($deepCopy)); 
    10081260            } 
    10091261 
     
    17812033    } 
    17822034 
     2035    /** 
     2036     * Temporary storage of collReportQuestions to save a possible db hit in 
     2037     * the event objects are add to the collection, but the 
     2038     * complete collection is never requested. 
     2039     * @return void 
     2040     */ 
     2041    public function initReportQuestions() 
     2042    { 
     2043        if ($this->collReportQuestions === null) { 
     2044            $this->collReportQuestions = array(); 
     2045        } 
     2046    } 
     2047 
     2048    /** 
     2049     * If this collection has already been initialized with 
     2050     * an identical criteria, it returns the collection. 
     2051     * Otherwise if this User has previously 
     2052     * been saved, it will retrieve related ReportQuestions from storage. 
     2053     * If this User is new, it will return 
     2054     * an empty collection or the current collection, the criteria 
     2055     * is ignored on a new object. 
     2056     * 
     2057     * @param Connection $con 
     2058     * @param Criteria $criteria 
     2059     * @throws PropelException 
     2060     */ 
     2061    public function getReportQuestions($criteria = null, $con = null) 
     2062    { 
     2063        // include the Peer class 
     2064        include_once 'model/om/BaseReportQuestionPeer.php'; 
     2065        if ($criteria === null) { 
     2066            $criteria = new Criteria(); 
     2067        } 
     2068        elseif ($criteria instanceof Criteria) 
     2069        { 
     2070            $criteria = clone $criteria; 
     2071        } 
     2072 
     2073        if ($this->collReportQuestions === null) { 
     2074            if ($this->isNew()) { 
     2075               $this->collReportQuestions = array(); 
     2076            } else { 
     2077 
     2078                $criteria->add(ReportQuestionPeer::USER_ID, $this->getId()); 
     2079 
     2080                ReportQuestionPeer::addSelectColumns($criteria); 
     2081                $this->collReportQuestions = ReportQuestionPeer::doSelect($criteria, $con); 
     2082            } 
     2083        } else { 
     2084            // criteria has no effect for a new object 
     2085            if (!$this->isNew()) { 
     2086                // the following code is to determine if a new query is 
     2087                // called for.  If the criteria is the same as the last 
     2088                // one, just return the collection. 
     2089 
     2090 
     2091                $criteria->add(ReportQuestionPeer::USER_ID, $this->getId()); 
     2092 
     2093                ReportQuestionPeer::addSelectColumns($criteria); 
     2094                if (!isset($this->lastReportQuestionCriteria) || !$this->lastReportQuestionCriteria->equals($criteria)) { 
     2095                    $this->collReportQuestions = ReportQuestionPeer::doSelect($criteria, $con); 
     2096                } 
     2097            } 
     2098        } 
     2099        $this->lastReportQuestionCriteria = $criteria; 
     2100        return $this->collReportQuestions; 
     2101    } 
     2102 
     2103    /** 
     2104     * Returns the number of related ReportQuestions. 
     2105     * 
     2106     * @param Criteria $criteria 
     2107     * @param Connection $con 
     2108     * @throws PropelException 
     2109     */ 
     2110    public function countReportQuestions($criteria = null, $con = null) 
     2111    { 
     2112        // include the Peer class 
     2113        include_once 'model/om/BaseReportQuestionPeer.php'; 
     2114        if ($criteria === null) { 
     2115            $criteria = new Criteria(); 
     2116        } 
     2117        elseif ($criteria instanceof Criteria) 
     2118        { 
     2119            $criteria = clone $criteria; 
     2120        } 
     2121 
     2122        $criteria->add(ReportQuestionPeer::USER_ID, $this->getId()); 
     2123 
     2124        return ReportQuestionPeer::doCount($criteria, $con); 
     2125    } 
     2126 
     2127    /** 
     2128     * Method called to associate a ReportQuestion object to this object 
     2129     * through the ReportQuestion foreign key attribute 
     2130     * 
     2131     * @param ReportQuestion $l ReportQuestion 
     2132     * @return void 
     2133     * @throws PropelException 
     2134     */ 
     2135    public function addReportQuestion(ReportQuestion $l) 
     2136    { 
     2137        $this->collReportQuestions[] = $l; 
     2138        $l->setUser($this); 
     2139    } 
     2140 
     2141 
     2142    /** 
     2143     * If this collection has already been initialized with 
     2144     * an identical criteria, it returns the collection. 
     2145     * Otherwise if this User is new, it will return 
     2146     * an empty collection; or if this User has previously 
     2147     * been saved, it will retrieve related ReportQuestions from storage. 
     2148     * 
     2149     * This method is protected by default in order to keep the public 
     2150     * api reasonable.  You can provide public methods for those you 
     2151     * actually need in User. 
     2152     */ 
     2153    public function getReportQuestionsJoinQuestion($criteria = null, $con = null) 
     2154    { 
     2155        // include the Peer class 
     2156        include_once 'model/om/BaseReportQuestionPeer.php'; 
     2157        if ($criteria === null) { 
     2158            $criteria = new Criteria(); 
     2159        } 
     2160        elseif ($criteria instanceof Criteria) 
     2161        { 
     2162            $criteria = clone $criteria; 
     2163        } 
     2164 
     2165        if ($this->collReportQuestions === null) { 
     2166            if ($this->isNew()) { 
     2167                $this->collReportQuestions = array(); 
     2168            } else { 
     2169 
     2170                $criteria->add(ReportQuestionPeer::USER_ID, $this->getId()); 
     2171 
     2172                $this->collReportQuestions = ReportQuestionPeer::doSelectJoinQuestion($criteria, $con); 
     2173            } 
     2174        } else { 
     2175            // the following code is to determine if a new query is 
     2176            // called for.  If the criteria is the same as the last 
     2177            // one, just return the collection. 
     2178 
     2179            $criteria->add(ReportQuestionPeer::USER_ID, $this->getId()); 
     2180 
     2181            if (!isset($this->lastReportQuestionCriteria) || !$this->lastReportQuestionCriteria->equals($criteria)) { 
     2182                $this->collReportQuestions = ReportQuestionPeer::doSelectJoinQuestion($criteria, $con); 
     2183            } 
     2184        } 
     2185        $this->lastReportQuestionCriteria = $criteria; 
     2186 
     2187        return $this->collReportQuestions; 
     2188    } 
     2189 
     2190    /** 
     2191     * Temporary storage of collReportAnswers to save a possible db hit in 
     2192     * the event objects are add to the collection, but the 
     2193     * complete collection is never requested. 
     2194     * @return void 
     2195     */ 
     2196    public function initReportAnswers() 
     2197    { 
     2198        if ($this->collReportAnswers === null) { 
     2199            $this->collReportAnswers = array(); 
     2200        } 
     2201    } 
     2202 
     2203    /** 
     2204     * If this collection has already been initialized with 
     2205     * an identical criteria, it returns the collection. 
     2206     * Otherwise if this User has previously 
     2207     * been saved, it will retrieve related ReportAnswers from storage. 
     2208     * If this User is new, it will return 
     2209     * an empty collection or the current collection, the criteria 
     2210     * is ignored on a new object. 
     2211     * 
     2212     * @param Connection $con 
     2213     * @param Criteria $criteria 
     2214     * @throws PropelException 
     2215     */ 
     2216    public function getReportAnswers($criteria = null, $con = null) 
     2217    { 
     2218        // include the Peer class 
     2219        include_once 'model/om/BaseReportAnswerPeer.php'; 
     2220        if ($criteria === null) { 
     2221            $criteria = new Criteria(); 
     2222        } 
     2223        elseif ($criteria instanceof Criteria) 
     2224        { 
     2225            $criteria = clone $criteria; 
     2226        } 
     2227 
     2228        if ($this->collReportAnswers === null) { 
     2229            if ($this->isNew()) { 
     2230               $this->collReportAnswers = array(); 
     2231            } else { 
     2232 
     2233                $criteria->add(ReportAnswerPeer::USER_ID, $this->getId()); 
     2234 
     2235                ReportAnswerPeer::addSelectColumns($criteria); 
     2236                $this->collReportAnswers = ReportAnswerPeer::doSelect($criteria, $con); 
     2237            } 
     2238        } else { 
     2239            // criteria has no effect for a new object 
     2240            if (!$this->isNew()) { 
     2241                // the following code is to determine if a new query is 
     2242                // called for.  If the criteria is the same as the last 
     2243                // one, just return the collection. 
     2244 
     2245 
     2246                $criteria->add(ReportAnswerPeer::USER_ID, $this->getId()); 
     2247 
     2248                ReportAnswerPeer::addSelectColumns($criteria); 
     2249                if (!isset($this->lastReportAnswerCriteria) || !$this->lastReportAnswerCriteria->equals($criteria)) { 
     2250                    $this->collReportAnswers = ReportAnswerPeer::doSelect($criteria, $con); 
     2251                } 
     2252            } 
     2253        } 
     2254        $this->lastReportAnswerCriteria = $criteria; 
     2255        return $this->collReportAnswers; 
     2256    } 
     2257 
     2258    /** 
     2259     * Returns the number of related ReportAnswers. 
     2260     * 
     2261     * @param Criteria $criteria 
     2262     * @param Connection $con 
     2263     * @throws PropelException 
     2264     */ 
     2265    public function countReportAnswers($criteria = null, $con = null) 
     2266    { 
     2267        // include the Peer class 
     2268        include_once 'model/om/BaseReportAnswerPeer.php'; 
     2269        if ($criteria === null) { 
     2270            $criteria = new Criteria(); 
     2271        } 
     2272        elseif ($criteria instanceof Criteria) 
     2273        { 
     2274            $criteria = clone $criteria; 
     2275        } 
     2276 
     2277        $criteria->add(ReportAnswerPeer::USER_ID, $this->getId()); 
     2278 
     2279        return ReportAnswerPeer::doCount($criteria, $con); 
     2280    } 
     2281 
     2282    /** 
     2283     * Method called to associate a ReportAnswer object to this object 
     2284     * through the ReportAnswer foreign key attribute 
     2285     * 
     2286     * @param ReportAnswer $l ReportAnswer 
     2287     * @return void 
     2288     * @throws PropelException 
     2289     */ 
     2290    public function addReportAnswer(ReportAnswer $l) 
     2291    { 
     2292        $this->collReportAnswers[] = $l; 
     2293        $l->setUser($this); 
     2294    } 
     2295 
     2296 
     2297    /** 
     2298     * If this collection has already been initialized with 
     2299     * an identical criteria, it returns the collection. 
     2300     * Otherwise if this User is new, it will return 
     2301     * an empty collection; or if this User has previously 
     2302     * been saved, it will retrieve related ReportAnswers from storage. 
     2303     * 
     2304     * This method is protected by default in order to keep the public 
     2305     * api reasonable.  You can provide public methods for those you 
     2306     * actually need in User. 
     2307     */ 
     2308    public function getReportAnswersJoinAnswer($criteria = null, $con = null) 
     2309    { 
     2310        // include the Peer class 
     2311        include_once 'model/om/BaseReportAnswerPeer.php'; 
     2312        if ($criteria === null) { 
     2313            $criteria = new Criteria(); 
     2314        } 
     2315        elseif ($criteria instanceof Criteria) 
     2316        { 
     2317            $criteria = clone $criteria; 
     2318        } 
     2319 
     2320        if ($this->collReportAnswers === null) { 
     2321            if ($this->isNew()) { 
     2322                $this->collReportAnswers = array(); 
     2323            } else { 
     2324 
     2325                $criteria->add(ReportAnswerPeer::USER_ID, $this->getId()); 
     2326 
     2327                $this->collReportAnswers = ReportAnswerPeer::doSelectJoinAnswer($criteria, $con); 
     2328            } 
     2329        } else { 
     2330            // the following code is to determine if a new query is 
     2331            // called for.  If the criteria is the same as the last 
     2332            // one, just return the collection. 
     2333 
     2334            $criteria->add(ReportAnswerPeer::USER_ID, $this->getId()); 
     2335 
     2336            if (!isset($this->lastReportAnswerCriteria) || !$this->lastReportAnswerCriteria->equals($criteria)) { 
     2337                $this->collReportAnswers = ReportAnswerPeer::doSelectJoinAnswer($criteria, $con); 
     2338            } 
     2339        } 
     2340        $this->lastReportAnswerCriteria = $criteria; 
     2341 
     2342        return $this->collReportAnswers; 
     2343    } 
     2344 
    17832345} // BaseUser 
  • trunk/lib/model/om/BaseUserPeer.php

    r44 r55  
    2525 
    2626    /** The total number of columns. */ 
    27     const NUM_COLUMNS = 9
     27    const NUM_COLUMNS = 13
    2828 
    2929    /** The number of lazy-loaded columns. */ 
     
    5555    const HAS_PAYPAL = 'ask_user.HAS_PAYPAL'; 
    5656 
     57    /** the column name for the WANT_TO_BE_MODERATOR field */ 
     58    const WANT_TO_BE_MODERATOR = 'ask_user.WANT_TO_BE_MODERATOR'; 
     59 
     60    /** the column name for the IS_MODERATOR field */ 
     61    const IS_MODERATOR = 'ask_user.IS_MODERATOR'; 
     62 
     63    /** the column name for the IS_ADMINISTRATOR field */ 
     64    const IS_ADMINISTRATOR = 'ask_user.IS_ADMINISTRATOR'; 
     65 
     66    /** the column name for the DELETIONS field */ 
     67    const DELETIONS = 'ask_user.DELETIONS'; 
     68 
    5769    /** the column name for the CREATED_AT field */ 
    5870    const CREATED_AT = 'ask_user.CREATED_AT'; 
     
    6981     */ 
    7082    private static $fieldNames = array ( 
    71         BasePeer::TYPE_PHPNAME => array ('Id', 'Nickname', 'FirstName', 'LastName', 'Email', 'Sha1Password', 'Salt', 'HasPaypal', 'CreatedAt', ), 
    72         BasePeer::TYPE_COLNAME => array (UserPeer::ID, UserPeer::NICKNAME, UserPeer::FIRST_NAME, UserPeer::LAST_NAME, UserPeer::EMAIL, UserPeer::SHA1_PASSWORD, UserPeer::SALT, UserPeer::HAS_PAYPAL, UserPeer::CREATED_AT, ), 
    73         BasePeer::TYPE_FIELDNAME => array ('id', 'nickname', 'first_name', 'last_name', 'email', 'sha1_password', 'salt', 'has_paypal', 'created_at', ), 
    74         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8,
     83        BasePeer::TYPE_PHPNAME => array ('Id', 'Nickname', 'FirstName', 'LastName', 'Email', 'Sha1Password', 'Salt', 'HasPaypal', 'WantToBeModerator', 'IsModerator', 'IsAdministrator', 'Deletions', 'CreatedAt', ), 
     84        BasePeer::TYPE_COLNAME => array (UserPeer::ID, UserPeer::NICKNAME, UserPeer::FIRST_NAME, UserPeer::LAST_NAME, UserPeer::EMAIL, UserPeer::SHA1_PASSWORD, UserPeer::SALT, UserPeer::HAS_PAYPAL, UserPeer::WANT_TO_BE_MODERATOR, UserPeer::IS_MODERATOR, UserPeer::IS_ADMINISTRATOR, UserPeer::DELETIONS, UserPeer::CREATED_AT, ), 
     85        BasePeer::TYPE_FIELDNAME => array ('id', 'nickname', 'first_name', 'last_name', 'email', 'sha1_password', 'salt', 'has_paypal', 'want_to_be_moderator', 'is_moderator', 'is_administrator', 'deletions', 'created_at', ), 
     86        BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
    7587    ); 
    7688 
     
    8294     */ 
    8395    private static $fieldKeys = array ( 
    84         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nickname' => 1, 'FirstName' => 2, 'LastName' => 3, 'Email' => 4, 'Sha1Password' => 5, 'Salt' => 6, 'HasPaypal' => 7, 'CreatedAt' => 8, ), 
    85         BasePeer::TYPE_COLNAME => array (UserPeer::ID => 0, UserPeer::NICKNAME => 1, UserPeer::FIRST_NAME => 2, UserPeer::LAST_NAME => 3, UserPeer::EMAIL => 4, UserPeer::SHA1_PASSWORD => 5, UserPeer::SALT => 6, UserPeer::HAS_PAYPAL => 7, UserPeer::CREATED_AT => 8, ), 
    86         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nickname' => 1, 'first_name' => 2, 'last_name' => 3, 'email' => 4, 'sha1_password' => 5, 'salt' => 6, 'has_paypal' => 7, 'created_at' => 8, ), 
    87         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8,
     96        BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nickname' => 1, 'FirstName' => 2, 'LastName' => 3, 'Email' => 4, 'Sha1Password' => 5, 'Salt' => 6, 'HasPaypal' => 7, 'WantToBeModerator' => 8, 'IsModerator' => 9, 'IsAdministrator' => 10, 'Deletions' => 11, 'CreatedAt' => 12, ), 
     97        BasePeer::TYPE_COLNAME => array (UserPeer::ID => 0, UserPeer::NICKNAME => 1, UserPeer::FIRST_NAME => 2, UserPeer::LAST_NAME => 3, UserPeer::EMAIL => 4, UserPeer::SHA1_PASSWORD => 5, UserPeer::SALT => 6, UserPeer::HAS_PAYPAL => 7, UserPeer::WANT_TO_BE_MODERATOR => 8, UserPeer::IS_MODERATOR => 9, UserPeer::IS_ADMINISTRATOR => 10, UserPeer::DELETIONS => 11, UserPeer::CREATED_AT => 12, ), 
     98        BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nickname' => 1, 'first_name' => 2, 'last_name' => 3, 'email' => 4, 'sha1_password' => 5, 'salt' => 6, 'has_paypal' => 7, 'want_to_be_moderator' => 8, 'is_moderator' => 9, 'is_administrator' => 10, 'deletions' => 11, 'created_at' => 12, ), 
     99        BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
    88100    ); 
    89101 
     
    201213 
    202214        $criteria->addSelectColumn(UserPeer::HAS_PAYPAL); 
     215 
     216        $criteria->addSelectColumn(UserPeer::WANT_TO_BE_MODERATOR); 
     217 
     218        $criteria->addSelectColumn(UserPeer::IS_MODERATOR); 
     219 
     220        $criteria->addSelectColumn(UserPeer::IS_ADMINISTRATOR); 
     221 
     222        $criteria->addSelectColumn(UserPeer::DELETIONS); 
    203223 
    204224        $criteria->addSelectColumn(UserPeer::CREATED_AT); 
  • trunk/web/css/main.css

    r42 r55  
    261261div#content_bar li 
    262262{ 
     263  padding: 0 0 5px 5px; 
    263264  list-style:none; 
    264265} 
     
    315316} 
    316317 
     318.clearright 
     319{ 
     320  clear: right; 
     321} 
     322 
    317323.form input 
    318324{ 
     
    392398} 
    393399 
    394 #rss_links li 
    395 { 
    396   padding: 0 0 5px 5px; 
    397 } 
    398  
    399400#add_question 
    400401{ 
     
    412413} 
    413414 
    414 .tags 
     415.options, .options :link, .options :visited 
    415416{ 
    416417  color: #aaa; 
    417418} 
    418419 
    419 .right 
    420 { 
    421   text-align: right; 
    422 } 
    423  
    424420.small 
    425421{