/** * download a file attached to item */ function downloadfile() { global $db; if (!isset($this->config['allowdownloads']) || $this->config['allowdownloads'] == true) { //if ($db->selectObject('content_expFiles', 'content_type="'.$this->baseclassname.'" AND expfiles_id='.$this->params['id']) != null) { expFile::download($this->params['id']); //} } else { flash('error', gt('Downloads have not been enabled for this file')); expHistory::back(); } }
public function export() { // gather all the data $banners = $this->banner->find('all'); $out = '"Banner ID","Banner Title","Banner URL","Company Name","Impression Limit","Click Limit","Impressions","Clicks"' . "\n"; foreach ($banners as $l) { $out .= '"' . $l->id . '","' . $l->title . '","' . $l->url . '","' . $l->company->title . '","' . $l->impression_limit . '","' . $l->click_limit . '","' . $l->impressions . '","' . $l->clicks . '"' . "\n"; } // open the file $dir = BASE . 'tmp'; $filename = 'banner_export' . date("m-d-Y") . '.csv'; $fh = fopen($dir . '/' . $filename, 'w'); // Put all values from $out to export.csv. fputs($fh, $out); fclose($fh); // push the file to the user $export = new expFile(array('directory' => $dir, 'filename' => $filename)); expFile::download($export); }