Changeset 55 for trunk/frontend

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

day 20 modifications

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 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>