Ejemplo n.º 1
0
 function executeList()
 {
     $page = isset($this->page) ? $this->page : 1;
     $this->show_petition = false;
     $this->show_subscriber = true;
     $this->show_status = false;
     $this->show_email = false;
     $this->download_filter = null;
     $this->action = '';
     $this->route = null;
     $this->route_params = array();
     $data_owner_id = null;
     if (isset($this->campaign)) {
         $query = PetitionSigningTable::getInstance()->query(array(PetitionSigningTable::CAMPAIGN => $this->campaign, PetitionSigningTable::ORDER => PetitionSigningTable::ORDER_DESC));
         $this->form = new SigningsDownloadForm(array(), array(PetitionSigningTable::CAMPAIGN => $this->campaign, PetitionSigningTable::ORDER => PetitionSigningTable::ORDER_DESC, SigningsDownloadForm::OPTION_QUERY => $query->copy(), SigningsDownloadForm::OPTION_IS_DATA_OWNER => $this->getGuardUser()->isDataOwnerOfCampaign($this->campaign)));
         $this->form->bindSelf('c' . $this->campaign->getId());
         $this->route = 'data_campaign_pager';
         $this->route_params = array('id' => $this->campaign->getId());
         $this->show_petition = true;
         $data_owner_id = $this->campaign->getDataOwnerId();
     } elseif (isset($this->petition)) {
         $query = PetitionSigningTable::getInstance()->query(array(PetitionSigningTable::PETITION => $this->petition, PetitionSigningTable::ORDER => PetitionSigningTable::ORDER_DESC));
         $this->form = new SigningsDownloadForm(array(), array(PetitionSigningTable::PETITION => $this->petition, PetitionSigningTable::ORDER => PetitionSigningTable::ORDER_DESC, SigningsDownloadForm::OPTION_QUERY => $query->copy(), SigningsDownloadForm::OPTION_IS_DATA_OWNER => $this->getGuardUser()->isDataOwnerOfCampaign($this->petition->getCampaign())));
         $this->form->bindSelf('p' . $this->petition->getId());
         $this->route = 'data_petition_pager';
         $this->route_params = array('id' => $this->petition->getId());
         $data_owner_id = $this->petition->getCampaign()->getDataOwnerId();
     } elseif (isset($this->widget)) {
         // this is for widget owners only
         $query = PetitionSigningTable::getInstance()->query(array(PetitionSigningTable::WIDGET => $this->widget, PetitionSigningTable::USER => $this->getGuardUser(), PetitionSigningTable::ORDER => PetitionSigningTable::ORDER_DESC));
         $this->form = new SigningsDownloadForm(array(), array(PetitionSigningTable::WIDGET => $this->widget, PetitionSigningTable::USER => $this->getGuardUser(), PetitionSigningTable::ORDER => PetitionSigningTable::ORDER_DESC, SigningsDownloadForm::OPTION_QUERY => $query->copy(), SigningsDownloadForm::OPTION_IS_DATA_OWNER => true));
         $this->form->bindSelf('w' . $this->widget->getId());
         $this->route = 'data_widget_pager';
         $this->route_params = array('id' => $this->widget->getId());
         $data_owner_id = $this->widget->getCampaign()->getDataOwnerId();
     }
     $this->can_delete = $this->getUser()->getUserId() == $data_owner_id;
     $this->signings = new policatPager($query, $page, $this->route, $this->route_params, true, 20, $this->form);
     if ($this->form->isValid()) {
         $this->count = $this->form->getCount();
         $this->pages = UtilExport::pages($this->count);
         $this->pending = $this->form->getPending();
         $this->download_filter = array($this->form->getName() => $this->form->getValues());
         $this->show_subscriber = !$this->form->getSubscriber();
         $this->show_email = $this->form->getSubscriber();
     }
 }
Ejemplo n.º 2
0
 public function executeDownload(sfWebRequest $request)
 {
     $download = new Download();
     $query = $this->buildQueryByRequest($request, $download);
     if (!$query instanceof Doctrine_Query) {
         return $query;
     }
     $this->ajax()->remove('#prepare-download')->appendPartial('body', 'prepare_modal', array('submit' => array('pages' => UtilExport::pages($download->getCount())), 'count' => $download->getCount(), 'prepare_route' => 'data_' . $download->getType() . '_prepare', 'batch' => $download->getId(), 'id' => $download->getId()))->modal('#prepare-download')->click('#prepare-download .download-prepare');
     return $this->ajax()->render();
 }