![]() |
Xataface Email Module 0.3
Email/Mailmerge Module for Xataface
|
00001 <?php 00002 class tables_xataface__email_newsletters { 00003 00004 00005 00006 00007 00021 public function getPermissions($record){ 00022 00023 00024 $app = Dataface_Application::getInstance(); 00025 $query =& $app->getQuery(); 00026 00027 if ( $query['-table'] == 'xataface__email_newsletters' ){ 00028 // Create a record for a table we know exists so we can get 00029 // the default application permissions. 00030 $dummy = new Dataface_Record('dataface__version', array()); 00031 if ( $dummy->checkPermission('email') ){ 00032 $perms = array( 00033 'view' => 1, 00034 'list' => 1, 00035 'find' => 1, 00036 '__partial__' => 1, 00037 'edit'=>0, 00038 'new' => 0, 00039 'import' => 0, 00040 'copy' => 0, 00041 'update_set'=>0 00042 ); 00043 00044 if ( class_exists('Dataface_AuthenticationTool') ){ 00045 $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName(); 00046 if ( $record and $username and $username == $record->val('posted_by') ){ 00047 $perms['cancel email job'] = 1; 00048 } 00049 } 00050 return $perms; 00051 } else { 00052 return Dataface_PermissionsTool::NO_ACCESS(); 00053 } 00054 00055 } else { 00056 $table = Dataface_Table::loadTable($query['-table']); 00057 $perms = $table->getPermissions(); 00058 if ( @$perms['email'] ){ 00059 $out = array('new'=>1); 00060 if ( class_exists('Dataface_AuthenticationTool') ){ 00061 $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName(); 00062 if ( $record and $username and $username == $record->val('posted_by') ){ 00063 $out['cancel email job'] = 1; 00064 } 00065 } 00066 00067 return $out; 00068 } else { 00069 return Dataface_PermissionsTool::NO_ACCESS(); 00070 } 00071 00072 } 00073 } 00074 00075 00076 public function rel_log____field__permissions($record){ 00077 00078 if ( $record->checkPermission('view') ){ 00079 return Dataface_PermissionsTool::READ_ONLY(); 00080 } else { 00081 return Dataface_PermissionsTool::NO_ACCESS(); 00082 } 00083 } 00084 00085 00086 public function rel_attachments__permissions($record){ 00087 $dummy = new Dataface_Record('dataface__version', array()); 00088 if ( $dummy->checkPermission('email') ){ 00089 $perms = array( 00090 'add new related record' => 1, 00091 'remove related record' => 1, 00092 'delete related record' => 1 00093 ); 00094 00095 00096 return $perms; 00097 } 00098 return null; 00099 } 00100 00101 00106 public function beforeInsert($record){ 00107 00108 if( class_exists('Dataface_AuthenticationTool') ){ 00109 $auth = Dataface_AuthenticationTool::getInstance(); 00110 00111 $record->setValue('posted_by', $auth->getLoggedInUserName()); 00112 } 00113 } 00114 00115 public function block__after_form_open_tag(){ 00116 00117 } 00118 00119 00124 public function block__before_content_widget(){ 00125 Dataface_ModuleTool::getInstance()->loadModule('modules_Email')->addPaths(); 00126 00127 Dataface_JavascriptTool::getInstance()->import('xataface/modules/Email/email_form.js'); 00128 echo "<div id=\"template-instructions\"></div>"; 00129 } 00130 00131 00132 public function block__before_main_section(){ 00133 //echo '<h2>Email History</h2>'; 00134 00135 } 00136 00137 public function section__progress($record){ 00138 00139 ob_start(); 00140 $mod = Dataface_ModuleTool::getInstance()->loadModule('modules_Email'); 00141 $mod->addPaths(); 00142 00143 $job = df_get_record('xataface__email_jobs', array('email_id'=>'='.$record->val('id'))); 00144 if ( !$job ) return null; 00145 00146 Dataface_JavascriptTool::getInstance()->import('xataface/modules/Email/email_progress.js'); 00147 df_display(array( 00148 'jobId' => $job->val('job_id') 00149 ), 00150 'xataface/modules/email/email_progress_section.html' 00151 ); 00152 00153 $contents = ob_get_contents(); 00154 ob_end_clean(); 00155 00156 00157 return array( 00158 'content' => $contents, 00159 'label' => 'Progress', 00160 'order' => 10, 00161 'class' => 'main' 00162 ); 00163 } 00164 00165 00166 function attachments__permissions($record){ 00167 $app = Dataface_Application::getInstance(); 00168 if ( @$app->_conf['modules_Email'] and @$app->_conf['modules_Email']['attachments'] ){ 00169 return array('view'=>1,'edit'=>1,'new'=>1); 00170 } else { 00171 return Dataface_PermissionsTool::NO_ACCESS(); 00172 } 00173 } 00174 00175 public function block__before_main_column(){ 00176 echo "<h1>Email History</h1>"; 00177 echo "<div class=\"portalHelp\">This section allows you to browse the history of emails that have been sent by the system.</div>"; 00178 echo '<div>[<a href="'.DATAFACE_SITE_HREF.'?-action=email_manage">Back to Email Management</a>]</div>'; 00179 } 00180 00181 00182 public function start_time__display($record){ 00183 if ( !$record->val("start_time") ) return ''; 00184 else return strftime('%c', $record->val('start_time')); 00185 } 00186 00187 public function end_time__display($record){ 00188 if ( !$record->val('end_time') ) return ''; 00189 else return strftime('%c', $record->val('end_time')); 00190 } 00191 00192 00193 public function valuelist__archive_categories(){ 00194 return array( 00195 1=>'Recent Jobs', 00196 2 => 'Archived Jobs' 00197 ); 00198 } 00199 00200 00201 00202 00203 00204 }