コード例 #1
0
 public function getCustomListElements()
 {
     if (SubscriberGroupQuery::create()->count() > 0) {
         return array(array('id' => CriteriaListWidgetDelegate::SELECT_ALL, 'readable_name' => TranslationPeer::getString('wns.subscriber_group.select_all_title'), 'magic_column' => 'all'), array('id' => CriteriaListWidgetDelegate::SELECT_WITHOUT, 'readable_name' => TranslationPeer::getString('wns.subscriber_group.select_without_title'), 'magic_column' => 'without'));
     }
     return array();
 }
コード例 #2
0
 public function saveData($aSubscriberGroupData)
 {
     if ($this->iSubscriberGroupId) {
         $oSubscriberGroup = SubscriberGroupQuery::create()->findPk($this->iSubscriberGroupId);
     } else {
         $oSubscriberGroup = new SubscriberGroup();
         $oSubscriberGroup->setCreatedBy(Session::getSession()->getUserId());
         $oSubscriberGroup->setCreatedAt(date('c'));
     }
     $oSubscriberGroup->setName($aSubscriberGroupData['name']);
     $oSubscriberGroup->setDisplayName($aSubscriberGroupData['display_name'] == null ? null : $aSubscriberGroupData['display_name']);
     $this->validate($aSubscriberGroupData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $oSubscriberGroup->save();
     $oResult = new stdClass();
     $oResult->id = $oSubscriberGroup->getId();
     if ($this->iSubscriberGroupId === null) {
         $oResult->inserted = true;
     } else {
         $oResult->updated = true;
     }
     $this->iSubscriberGroupId = $oResult->id;
     return $oResult;
 }
コード例 #3
0
 public function subscriberGroups()
 {
     $aSubscriberGroups = SubscriberGroupQuery::create()->orderByName()->select(array('Id', 'Name'))->find()->toKeyValue('Id', 'Name');
     // @todo: handle external mail groups
     // FilterModule::getFilters()->handleMailGroups(&$aSubscriberGroups));
     return $aSubscriberGroups;
 }
 public function getSubscriberGroups()
 {
     if (SubscriberGroupQuery::create()->count() === 0) {
         $oSubscriberGroup = new SubscriberGroup();
         $oSubscriberGroup->setName(TranslationPeer::getString('wns.subscriber_group.default.name'));
         $oSubscriberGroup->setDisplayName(TranslationPeer::getString('wns.subscriber_group.default.display_name'));
         $oSubscriberGroup->save();
     }
     return SubscriberGroupQuery::create()->select(array('Id', 'Name'))->orderByName()->find()->toKeyValue('Id', 'Name');
 }
コード例 #5
0
 public function getSubscriberGroupName()
 {
     if (is_numeric($this->oDelegateProxy->getSubscriberGroupId())) {
         $oSubscriberGroup = SubscriberGroupQuery::create()->findPk($this->oDelegateProxy->getSubscriberGroupId());
         if ($oSubscriberGroup) {
             return $oSubscriberGroup->getName();
         }
     }
     if ($this->oDelegateProxy->getSubscriberGroupId() === CriteriaListWidgetDelegate::SELECT_WITHOUT) {
         return TranslationPeer::getString('wns.subscriber_group.without');
     }
     return $this->oDelegateProxy->getSubscriberGroupId();
 }
コード例 #6
0
 public function listMailGroups($bIncludeExternalMailGroups = true, $bIncludeGeneratedMailGroups = true)
 {
     // Get subscriber groups with membership count in not used for subscriber import
     $bUsedForSubscriberImport = $bIncludeExternalMailGroups === false && ($bIncludeGeneratedMailGroups = false);
     $oQuery = SubscriberGroupQuery::create()->excludeTemporary($bIncludeGeneratedMailGroups)->orderByName();
     $aMailGroups = array();
     foreach ($oQuery->find() as $oSubscriberGroup) {
         $sId = (string) $oSubscriberGroup->getId();
         $aMailGroups[$sId] = $oSubscriberGroup->getName() . (!$bUsedForSubscriberImport ? ' (' . $oSubscriberGroup->countSubscriberGroupMemberships() . ')' : '');
     }
     // If filter is implemented in project this allows to add on-the-fly mail groups
     // E.g. a group of recipients that have registered for an event and there for create a temporary mail group
     if ($bIncludeExternalMailGroups) {
         FilterModule::getFilters()->handleMailGroups(array(&$aMailGroups));
     }
     return $aMailGroups;
 }
コード例 #7
0
 /**
  * newsletterSubscribe()
  *
  * @param int/array subscriber group
  *
  * Description
  * • validate post subscribe action
  * • process post and display confirm message
  *
  * @return Template object
  */
 private function newsletterSubscribe($mSubscriberGroupId)
 {
     /**
      * @todo: consider array to become scalar as there is no need for multiple values, or is there?
      * could this subscribe form provide also multiple (checkboxes) subscriptions?
      */
     if (is_array($mSubscriberGroupId) && count($mSubscriberGroupId) > 0) {
         $mSubscriberGroupId = $mSubscriberGroupId[0];
     }
     if (!SubscriberGroupQuery::create()->findPk($mSubscriberGroupId)) {
         throw new Exception(__CLASS__ . ': configured subscriber_group_id ' . $mSubscriberGroupId . ' does not exist!');
     }
     $oTemplate = $this->constructTemplate("newsletter_subscribe");
     // Process form
     if (Manager::isPost() && isset($_POST['newsletter_subscribe'])) {
         $this->processSubscribe($mSubscriberGroupId, $oTemplate);
     }
     return $oTemplate;
 }
コード例 #8
0
 private function getNewsletterMailings()
 {
     $aResult = array();
     $aSubscriberGroups = SubscriberGroupQuery::create()->distinct()->joinNewsletterMailing(null, Criteria::INNER_JOIN)->orderByName()->find();
     foreach ($aSubscriberGroups as $oSubscriberGroup) {
         $aNewsletterMailing = NewsletterMailingQuery::create()->filterByNewsletterId($this->iNewsletterId)->orderByCreatedAt(Criteria::DESC)->filterBySubscriberGroup($oSubscriberGroup)->find();
         $iCountMailings = count($aNewsletterMailing);
         $bHasMailing = $iCountMailings > 0;
         if ($bHasMailing) {
             $aSubscriberGroup = array('UserInitials' => array(), 'DateSent' => array(), 'RecipientCount' => array());
             foreach ($aNewsletterMailing as $i => $oNewsletterMailing) {
                 $sAdditionalMailingCount = '';
                 // Fill Groupname only once
                 if ($i === 0) {
                     if ($oNewsletterMailing->getSubscriberGroupName()) {
                         $aSubscriberGroup['MailGroupName'] = $oNewsletterMailing->getSubscriberGroupName();
                         $aSubscriberGroup['MailGroupType'] = TranslationPeer::getString('wns.mail_group.subscribers');
                     } else {
                         $aSubscriberGroup['MailGroupName'] = $oNewsletterMailing->getMailGroupId();
                         $aSubscriberGroup['MailGroupType'] = TranslationPeer::getString('wns.mail_group.external');
                     }
                     if ($iCountMailings - 1 > 0) {
                         $sAdditionalMailingCount = ' (+' . ($iCountMailings - 1) . ')';
                     }
                 } else {
                     continue;
                 }
                 // Fill all mailing infos
                 $aSubscriberGroup['UserInitials'][] = $oNewsletterMailing->getUserRelatedByCreatedBy() ? $oNewsletterMailing->getUserRelatedByCreatedBy()->getInitials() : '';
                 $aSubscriberGroup['DateSent'][] = $oNewsletterMailing->getDateSentFormatted('H:i') . $sAdditionalMailingCount;
                 $aSubscriberGroup['RecipientCount'][] = $oNewsletterMailing->getRecipientCount();
                 $aSubscriberGroup['CountAdditionalMailings'] = null;
             }
             $aResult[] = $aSubscriberGroup;
         }
     }
     return $aResult;
 }
コード例 #9
0
 /**
  * Get the associated SubscriberGroup object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return SubscriberGroup The associated SubscriberGroup object.
  * @throws PropelException
  */
 public function getSubscriberGroup(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aSubscriberGroup === null && $this->subscriber_group_id !== null && $doQuery) {
         $this->aSubscriberGroup = SubscriberGroupQuery::create()->findPk($this->subscriber_group_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aSubscriberGroup->addNewsletterMailings($this);
            */
     }
     return $this->aSubscriberGroup;
 }
コード例 #10
0
 /**
  * Returns a new SubscriberGroupQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   SubscriberGroupQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return SubscriberGroupQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof SubscriberGroupQuery) {
         return $criteria;
     }
     $query = new SubscriberGroupQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
コード例 #11
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(SubscriberGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = SubscriberGroupQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // denyable behavior
         if (!(SubscriberGroupPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "subscriber_groups")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }