Пример #1
0
function link_to_report_answer($answer, $user)
{
    use_helper('Javascript');
    $text = '[' . __('report to moderator') . ']';
    if ($user->isAuthenticated()) {
        $has_already_reported_answer = ReportAnswerPeer::retrieveByPk($answer->getId(), $user->getSubscriberId());
        if ($has_already_reported_answer) {
            // already spam for this user
            return '[' . __('reported as spam') . ']';
        } else {
            return link_to_remote($text, array('url' => '@user_report_answer?id=' . $answer->getId(), 'update' => array('success' => 'report_answer_' . $answer->getId()), 'loading' => "Element.show('indicator')", 'complete' => "Element.hide('indicator');" . visual_effect('highlight', 'report_answer_' . $answer->getId())));
        }
    } else {
        return link_to_login($text);
    }
}
Пример #2
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ReportAnswerPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setAnswerId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCreatedAt($arr[$keys[2]]);
     }
 }
Пример #3
0
 public function getReportAnswersJoinAnswer($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseReportAnswerPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collReportAnswers === null) {
         if ($this->isNew()) {
             $this->collReportAnswers = array();
         } else {
             $criteria->add(ReportAnswerPeer::USER_ID, $this->getId());
             $this->collReportAnswers = ReportAnswerPeer::doSelectJoinAnswer($criteria, $con);
         }
     } else {
         $criteria->add(ReportAnswerPeer::USER_ID, $this->getId());
         if (!isset($this->lastReportAnswerCriteria) || !$this->lastReportAnswerCriteria->equals($criteria)) {
             $this->collReportAnswers = ReportAnswerPeer::doSelectJoinAnswer($criteria, $con);
         }
     }
     $this->lastReportAnswerCriteria = $criteria;
     return $this->collReportAnswers;
 }
Пример #4
0
 public static function retrieveByPK($answer_id, $user_id, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(ReportAnswerPeer::ANSWER_ID, $answer_id);
     $criteria->add(ReportAnswerPeer::USER_ID, $user_id);
     $v = ReportAnswerPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }