/** * * @param Campaign $campaign * @return Doctrine_Query */ public function queryByCampaignAndUser(Campaign $campaign, sfGuardUser $user, MailingList $existing = null, $active_only = false) { $query = $this->queryByCampaign($campaign, $active_only)->leftJoin('ml.TargetListRights tr'); if ($existing) { return $query->andWhere('(tr.user_id = ? AND tr.active = 1) OR ml.id = ?', array($user->getId(), $existing->getId())); } else { return $query->andWhere('tr.user_id = ? AND tr.active = 1', $user->getId()); } }
/** * * @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; }
/** * * @param MailingList $mailing_list * @return TargetListRights */ public function getTargetListRights(MailingList $mailing_list) { if (array_key_exists($mailing_list->getId(), $this->tr_cache)) { return $this->tr_cache[$mailing_list->getId()]; } return $this->tr_cache[$mailing_list->getId()] = TargetListRightsTable::getInstance()->queryByTargetListAndUser($mailing_list, $this)->fetchOne(); }
public function countActionsDeletedByTargetList(MailingList $ml) { return $this->queryAll(true)->where('p.mailing_list_id = ?', $ml->getId())->andWhere('p.status = ?', Petition::STATUS_DELETED)->count(); }
/** * * @param MailingList $mailing_list * @return Doctrine_Query */ public function queryByMailingListChoice(MailingList $mailing_list) { return $this->createQuery('mlm')->where('mlm.mailing_list_id = ?', $mailing_list->getId())->andWhere('mlm.kind = ?', MailingListMeta::KIND_CHOICE); }
/** * * @param MailingList $target_list * @param type $user_ids * @return Doctrine_Query */ public function queryByTargetListAndUsers(MailingList $target_list, $user_ids) { return $this->createQuery('tr')->where('tr.mailing_list_id = ?', $target_list->getId())->andWhereIn('tr.user_id', $user_ids); }