Xataface Email Module  0.3.2
Email/Mailmerge Module for Xataface
 All Data Structures Files Functions Variables Pages
xataface__email_newsletters.php
Go to the documentation of this file.
1 <?php
3 
4 
5 
6 
7 
21  public function getPermissions($record){
22 
23 
24  $app = Dataface_Application::getInstance();
25  $query =& $app->getQuery();
26 
27  if ( $query['-table'] == 'xataface__email_newsletters' ){
28  // Create a record for a table we know exists so we can get
29  // the default application permissions.
30  $dummy = new Dataface_Record('dataface__version', array());
31  if ( $dummy->checkPermission('email') ){
32  $perms = array(
33  'view' => 1,
34  'list' => 1,
35  'find' => 1,
36  '__partial__' => 1,
37  'edit'=>0,
38  'new' => 0,
39  'import' => 0,
40  'copy' => 0,
41  'update_set'=>0
42  );
43 
44  if ( class_exists('Dataface_AuthenticationTool') ){
45  $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName();
46  if ( $record and $username and $username == $record->val('posted_by') ){
47  $perms['cancel email job'] = 1;
48  }
49  }
50  return $perms;
51  } else {
52  return Dataface_PermissionsTool::NO_ACCESS();
53  }
54 
55  } else {
56  $table = Dataface_Table::loadTable($query['-table']);
57  $perms = $table->getPermissions();
58  if ( @$perms['email'] ){
59  $out = array('new'=>1);
60  if ( class_exists('Dataface_AuthenticationTool') ){
61  $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName();
62  if ( $record and $username and $username == $record->val('posted_by') ){
63  $out['cancel email job'] = 1;
64  }
65  }
66 
67  return $out;
68  } else {
69  return Dataface_PermissionsTool::NO_ACCESS();
70  }
71 
72  }
73  }
74 
75 
76  public function rel_log____field__permissions($record){
77 
78  if ( $record->checkPermission('view') ){
79  return Dataface_PermissionsTool::READ_ONLY();
80  } else {
81  return Dataface_PermissionsTool::NO_ACCESS();
82  }
83  }
84 
85 
86  public function rel_attachments__permissions($record){
87  $dummy = new Dataface_Record('dataface__version', array());
88  if ( $dummy->checkPermission('email') ){
89  $perms = array(
90  'add new related record' => 1,
91  'remove related record' => 1,
92  'delete related record' => 1
93  );
94 
95 
96  return $perms;
97  }
98  return null;
99  }
100 
101 
106  public function beforeInsert($record){
107 
108  if( class_exists('Dataface_AuthenticationTool') ){
109  $auth = Dataface_AuthenticationTool::getInstance();
110 
111  $record->setValue('posted_by', $auth->getLoggedInUserName());
112  }
113  }
114 
115  public function block__after_form_open_tag(){
116 
117  }
118 
119 
124  public function block__before_content_widget(){
125  Dataface_ModuleTool::getInstance()->loadModule('modules_Email')->addPaths();
126 
127  Dataface_JavascriptTool::getInstance()->import('xataface/modules/Email/email_form.js');
128  echo "<div id=\"template-instructions\"></div>";
129  }
130 
131 
132  public function block__before_main_section(){
133  //echo '<h2>Email History</h2>';
134 
135  }
136 
137  public function section__progress($record){
138 
139  ob_start();
140  $mod = Dataface_ModuleTool::getInstance()->loadModule('modules_Email');
141  $mod->addPaths();
142 
143  $job = df_get_record('xataface__email_jobs', array('email_id'=>'='.$record->val('id')));
144  if ( !$job ) return null;
145 
146  Dataface_JavascriptTool::getInstance()->import('xataface/modules/Email/email_progress.js');
147  df_display(array(
148  'jobId' => $job->val('job_id')
149  ),
150  'xataface/modules/email/email_progress_section.html'
151  );
152 
153  $contents = ob_get_contents();
154  ob_end_clean();
155 
156 
157  return array(
158  'content' => $contents,
159  'label' => 'Progress',
160  'order' => 10,
161  'class' => 'main'
162  );
163  }
164 
165 
166  function attachments__permissions($record){
167  $app = Dataface_Application::getInstance();
168  if ( @$app->_conf['modules_Email'] and @$app->_conf['modules_Email']['attachments'] ){
169  return array('view'=>1,'edit'=>1,'new'=>1);
170  } else {
171  return Dataface_PermissionsTool::NO_ACCESS();
172  }
173  }
174 
175  public function block__before_main_column(){
176  echo "<h1>Email History</h1>";
177  echo "<div class=\"portalHelp\">This section allows you to browse the history of emails that have been sent by the system.</div>";
178  echo '<div>[<a href="'.DATAFACE_SITE_HREF.'?-action=email_manage">Back to Email Management</a>]</div>';
179  }
180 
181 
182  public function start_time__display($record){
183  if ( !$record->val("start_time") ) return '';
184  else return strftime('%c', $record->val('start_time'));
185  }
186 
187  public function end_time__display($record){
188  if ( !$record->val('end_time') ) return '';
189  else return strftime('%c', $record->val('end_time'));
190  }
191 
192 
193  public function valuelist__archive_categories(){
194  return array(
195  1=>'Recent Jobs',
196  2 => 'Archived Jobs'
197  );
198  }
199 
200 
201 
202 
203 
204 }