1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14: class Hylax {
15:
16: function getBaseFolders()
17: {
18: return array('inbox' => _("Inbox"),
19: 'outbox' => _("Outbox"));
20:
21:
22: }
23:
24: function getStates()
25: {
26: return array('D' => _("Done"),
27: 'F' => _("Failed"),
28: 'S' => _("Sending"),
29: 'W' => _("Waiting"));
30: }
31:
32: function getStatCols()
33: {
34: return array('job_id', 'time', 'state', 'owner', 'number', 'pages', 'tot_pages', 'dials', 'duration', 'status');
35: }
36:
37: function getVFSPath($folder)
38: {
39: return '.horde/fax/' . $folder;
40: }
41:
42: function getImage($fax_id, $page, $preview = false)
43: {
44: $data = $GLOBALS['hylax_storage']->getFaxData($fax_id);
45:
46:
47: require_once HYLAX_BASE . '/lib/Image.php';
48: $image = new Hylax_Image();
49: $image->loadData($data);
50: $image->getImage($page, $preview);
51: }
52:
53: function getPDF($fax_id)
54: {
55: $data = $GLOBALS['hylax_storage']->getFaxData($fax_id);
56:
57:
58: require_once HYLAX_BASE . '/lib/Image.php';
59: $image = new Hylax_Image();
60: $image->loadData($data);
61: $image->getPDF();
62: }
63:
64: function printFax($fax_id)
65: {
66: $data = $GLOBALS['hylax_storage']->getFaxData($fax_id);
67:
68: $command = $GLOBALS['conf']['fax']['print'];
69: $descriptorspec = array(0 => array("pipe", "r"),
70: 1 => array("pipe", "w"),
71: 2 => array("pipe", "w"));
72:
73:
74: $process = proc_open($command, $descriptorspec, $pipes);
75: if (!is_resource($process)) {
76: return PEAR::raiseError('fail');
77: }
78:
79: fwrite($pipes[0], $data);
80: fclose($pipes[0]);
81:
82: $output = '';
83: while (!feof($pipes[1])) {
84: $output .= fgets($pipes[1], 1024);
85: }
86: fclose($pipes[1]);
87:
88: $stderr = '';
89: while (!feof($pipes[2])) {
90: $stderr .= fgets($pipes[2], 1024);
91: }
92: fclose($pipes[2]);
93:
94: proc_close($process);
95:
96: if ($stderr) {
97: return PEAR::raiseError($stderr);
98: }
99:
100: return true;
101: }
102:
103: function getPages($fax_id, $num_pages)
104: {
105: $pages = array();
106: $params = array('fax_id' => $fax_id,
107: 'preview' => 1);
108:
109:
110: Horde::addScriptFile('popup.js', 'horde');
111: $popup_w = 620;
112: $popup_h = 860;
113:
114: for ($i = 0; $i < $num_pages; $i++) {
115: $params['page'] = $i;
116: $url = Horde_Util::addParameter('img.php', $params);
117: $img = Horde::img($url, sprintf(_("View page %s"), $i+1), '', $GLOBALS['registry']->get('webroot'));
118:
119: $full_url = Horde::url(Horde_Util::addParameter('img.php', array('fax_id' => $fax_id, 'page' => $i)));
120:
121: $pages[] = Horde::link('', sprintf(_("View page %s"), $i+1), '', '', "popup('$full_url', $popup_w, $popup_h); return false;") . $img . '</a>';
122: }
123: return $pages;
124: }
125:
126: function ($returnType = 'object')
127: {
128: global $registry;
129:
130: $menu = new Horde_Menu();
131:
132: $menu->addArray(array('url' => Horde::url('summary.php'),
133: 'text' => _("Summary"),
134: 'icon' => 'fax.png'));
135:
136: $menu->addArray(array('url' => Horde::url('folder.php'),
137: 'text' => _("Folders"),
138: 'icon' => 'folder.png'));
139:
140: $menu->addArray(array('url' => Horde::url('compose.php'),
141: 'text' => _("Compose"),
142: 'icon' => 'compose.png'));
143:
144: if ($returnType == 'object') {
145: return $menu;
146: } else {
147: return $menu->render();
148: }
149: }
150:
151: }
152: