Example #1
0
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     // prevent XSS
     $filter = \SpoonFilter::arrayMapRecursive('htmlspecialchars', $this->filter);
     $this->tpl->assign($filter);
 }
Example #2
0
 /**
  * Loads the datagrid with the clicked link
  */
 private function loadDataGrid()
 {
     // no statistics found
     if (empty($this->statistics['clicked_links'])) {
         return false;
     }
     // map urlencode to clicked links stack
     $this->statistics['clicked_links'] = \SpoonFilter::arrayMapRecursive('urlencode', $this->statistics['clicked_links']);
     // create a new source-object
     $source = new \SpoonDatagridSourceArray($this->statistics['clicked_links']);
     // call the parent, as in create a new datagrid with the created source
     $this->dataGrid = new BackendDataGrid($source);
     $this->dataGrid->setURL(BackendModel::createURLForAction() . '&offset=[offset]&order=[order]&sort=[sort]&id=' . $this->id);
     // set headers values
     $headers['link'] = strtoupper(BL::lbl('URL'));
     $headers['clicks'] = \SpoonFilter::ucfirst(BL::msg('ClicksAmount'));
     // set headers
     $this->dataGrid->setHeaderLabels($headers);
     // sorting columns
     $this->dataGrid->setSortingColumns(array('link', 'clicks'), 'link');
     // set column functions
     $this->dataGrid->setColumnFunction('urldecode', array('[link]'), 'link', true);
     $this->dataGrid->setColumnFunction('urldecode', array('[link]'), 'link', true);
     // set paging limit
     $this->dataGrid->setPagingLimit(self::PAGING_LIMIT);
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('StatisticsLink')) {
         // add edit column
         $this->dataGrid->addColumnAction('users', null, BL::lbl('Who'), BackendModel::createURLForAction('StatisticsLink') . '&url=[link]&mailing_id=' . $this->id, BL::lbl('Who'));
     }
 }
Example #3
0
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     // prevent XSS
     $filter = \SpoonFilter::arrayMapRecursive('htmlspecialchars', $this->filter);
     // parse filter
     $this->tpl->assign($filter);
     $this->tpl->assign('filterQuery', $this->filterQuery);
     // assign id, name
     $this->tpl->assign('name', $this->record['name']);
     $this->tpl->assign('id', $this->record['id']);
 }
Example #4
0
 /**
  * Retrieve the form method or the submitted data.
  *
  * @return	string
  * @param	bool[optional] $array	Should we return the submitted data?
  */
 public function getMethod($array = false)
 {
     // we want to get the actual $_GET or $_POST data
     if ($array) {
         // $_POST array
         if ($this->method == 'post') {
             return $_POST;
         }
         // $_GET array
         return SpoonFilter::arrayMapRecursive('urldecode', $_GET);
     }
     // submitted via met get or post
     return $this->method;
 }
 public function testArrayMapRecursive()
 {
     /* without allowedKeys parameter */
     // test array
     $testArray = array(0 => array('string1' => 'This%20is%20a%20string'), 1 => array('string2' => 'This%20is%20a%20string'));
     // expected result
     $testResult = array(0 => array('string1' => 'This is a string'), 1 => array('string2' => 'This is a string'));
     // perform test
     $this->assertEquals($testResult, SpoonFilter::arrayMapRecursive('urldecode', $testArray));
     /* with allowedKeys parameter */
     // test array
     $testArray = array(0 => serialize(array('string1' => 'spoon')), 1 => serialize(array('string2' => 'rocks')));
     // expected result
     $testResult = array(0 => 'a:1:{s:7:"string1";s:5:"spoon";}', 1 => array('string2' => 'rocks'));
     // perform test
     $this->assertEquals($testResult, SpoonFilter::arrayMapRecursive('unserialize', $testArray, '1'));
     /* with allowedKeys parameter, depth of 4 */
     // test array
     $testArray = array(0 => array('array1' => array(array('spoon' => serialize('kicks'), 'serious' => serialize('ass')))), 1 => serialize(array('string2' => 'ass')));
     // expected result
     $testResult = array(0 => array('array1' => array(array('spoon' => 's:5:"kicks";', 'serious' => 'ass'))), 1 => array('string2' => 'ass'));
     // perform test
     $this->assertEquals($testResult, SpoonFilter::arrayMapRecursive('unserialize', $testArray, array('serious', '1')));
 }
Example #6
0
 /**
  * Exports the statistics of a given mailing in CSV format. This function will send headers to download the CSV and exit your script after use.
  *
  * @param int $id The ID of the mailing.
  */
 public static function exportStatistics($id)
 {
     // fetch the addresses by group
     $records = array();
     $records[] = BackendMailmotorCMHelper::getStatistics($id, true);
     // fetch separate arrays
     $statsClickedLinks = isset($records[0]['clicked_links']) ? $records[0]['clicked_links'] : array();
     $statsClickedLinksBy = isset($records[0]['clicked_links_by']) ? $records[0]['clicked_links_by'] : array();
     // unset multi-dimensional arrays
     unset($records[0]['clicked_links'], $records[0]['clicked_links_by'], $records[0]['opens'], $records[0]['clicks'], $records[0]['clicks_percentage'], $records[0]['clicks_total'], $records[0]['recipients_total'], $records[0]['recipients_percentage'], $records[0]['online_version']);
     // set columns
     $columns = array();
     $columns[] = BL::msg('MailingCSVRecipients');
     $columns[] = BL::msg('MailingCSVUniqueOpens');
     $columns[] = BL::msg('MailingCSVUnsubscribes');
     $columns[] = BL::msg('MailingCSVBounces');
     $columns[] = BL::msg('MailingCSVUnopens');
     $columns[] = BL::msg('MailingCSVBouncesPercentage');
     $columns[] = BL::msg('MailingCSVUniqueOpensPercentage');
     $columns[] = BL::msg('MailingCSVUnopensPercentage');
     // set start of the CSV
     $csv = BackendCSV::arrayToString($records, $columns);
     // check set links
     if (!empty($statsClickedLinks)) {
         // urldecode the clicked URLs
         $statsClickedLinks = SpoonFilter::arrayMapRecursive('urldecode', $statsClickedLinks);
         // fetch CSV strings
         $csv .= PHP_EOL . BackendCSV::arrayToString($statsClickedLinks);
     }
     // set the filename and path
     $filename = 'statistics-' . SpoonDate::getDate('YmdHi') . '.csv';
     // set headers for download
     $headers = array();
     $headers[] = 'Content-type: application/octet-stream';
     $headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
     // overwrite the headers
     SpoonHTTP::setHeaders($headers);
     // output the CSV string
     echo $csv;
     // exit here
     exit;
 }