コード例 #1
0
 public function queryByPetition(Petition $petition, $fetch_users = true)
 {
     $query = $this->createQuery('pr')->where('pr.petition_id = ?', $petition->getId());
     if ($fetch_users) {
         $query->addFrom('pr.User u');
     }
     return $query;
 }
コード例 #2
0
 public function countByPetition(Petition $petition, $timeToLive = 600)
 {
     $query = $this->queryAll()->where('w.petition_id = ? AND w.status = ?', array($petition->getId(), Widget::STATUS_ACTIVE));
     if ($timeToLive) {
         $query->useResultCache(true, $timeToLive);
     }
     return $query->count();
 }
コード例 #3
0
 /** @deprecated do not use! it is slow */
 public function countPendingMails(Petition $petition = null)
 {
     $query = self::getInstance()->createQuery('sc')->leftJoin('sc.PetitionSigning s');
     if ($petition) {
         $query->where('s.petition_id = ?', $petition->getId());
     }
     $query->leftJoin('s.PetitionSigningWave w')->andWhere('sc.wave = w.wave and w.status = ?', PetitionSigning::STATUS_PENDING);
     return $query->count();
 }
コード例 #4
0
 public function sumContactStatus($status, Petition $petition = null)
 {
     $query = self::getInstance()->createQuery('psw')->select('SUM(psw.contact_num) as contact_num_sum')->where('psw.status = ?', $status);
     if ($petition) {
         $query->leftJoin('psw.PetitionSigning ps')->andWhere('ps.petition_id = ?', $petition->getId());
     }
     $result = $query->fetchArray();
     if (isset($result[0])) {
         $num = $result[0]['contact_num_sum'];
         return $num ? $num : 0;
     }
     return 0;
 }
コード例 #5
0
 /**
  *
  * @param Petition $petition
  * @param bool $fetch_lang
  * @return Doctrine_Query
  */
 public function queryByPetition(Petition $petition, $fetch_lang = true, $status = null, $language_id = null)
 {
     $query = $this->createQuery('pt')->where('pt.petition_id = ?', $petition->getId())->orderBy('pt.id');
     if ($fetch_lang) {
         $query->leftJoin('pt.Language l')->select('pt.*, l.*');
     }
     if ($status !== null) {
         $query->andWhere('pt.status = ?', $status);
     }
     if ($language_id !== null) {
         $query->andWhere('pt.language_id = ?', $language_id);
     }
     return $query;
 }
コード例 #6
0
 /**
  *
  * @param MailingList $ml
  * @param Petition $pledges_by_petition
  * @return Doctrine_Query
  */
 public function queryByMailingList(MailingList $ml, $pledges_by_petition = null)
 {
     $query = $this->createQuery('c INDEXBY c.id')->where('c.mailing_list_id = ?', $ml->getId())->orderBy('c.id');
     if ($pledges_by_petition) {
         $query->leftJoin('c.Pledges p INDEXBY p.pledge_item_id');
         $query->select('c.*, p.*');
         $query->andWhere('p.contact_id IS NULL OR (p.pledge_item_id IN (SELECT pi.id FROM PledgeItem pi WHERE pi.petition_id = ?))', $pledges_by_petition->getId());
     } else {
         $query->select('c.*');
     }
     return $query;
 }
コード例 #7
0
 /**
  *
  * @param Petition $petition
  * @return PetitionRights
  */
 public function getRightsByPetition(Petition $petition)
 {
     if (array_key_exists($petition->getId(), $this->pr_cache)) {
         return $this->pr_cache[$petition->getId()];
     }
     return $this->pr_cache[$petition->getId()] = PetitionRightsTable::getInstance()->queryByPetitionAndUser($petition, $this)->fetchOne();
 }
コード例 #8
0
 public function queryByPetition(Petition $petition)
 {
     return $this->createQuery('t')->where('t.petition_id = ?', $petition->getId())->orderBy('t.name ASC');
 }
コード例 #9
0
 public function countPendingByPetition(Petition $petition, $timeToLive = 600)
 {
     $query = $this->queryAll('ps')->where('ps.petition_id = ? AND ps.status = ?', array($petition->getId(), PetitionSigning::STATUS_PENDING));
     if ($timeToLive) {
         $query->useResultCache(true, $timeToLive);
     }
     return $query->count();
 }
コード例 #10
0
 public function queryByActivePetitionTexts(Petition $petition)
 {
     return $this->queryAll()->leftJoin('l.PetitionText pt')->andWhere('pt.petition_id = ?', $petition->getId())->andWhere('pt.status = ?', PetitionText::STATUS_ACTIVE);
 }