Xataface Email Module 0.2
Email/Mailmerge Module for Xataface
tables/xataface__email_newsletters/xataface__email_newsletters.php
Go to the documentation of this file.
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         
00090         public function beforeInsert($record){
00091                 
00092                 if( class_exists('Dataface_AuthenticationTool') ){
00093                         $auth = Dataface_AuthenticationTool::getInstance();
00094                 
00095                         $record->setValue('posted_by', $auth->getLoggedInUserName());
00096                 }
00097         }
00098         
00099         public function block__after_form_open_tag(){
00100                 
00101         }
00102         
00103         
00108         public function block__before_content_widget(){
00109                 Dataface_ModuleTool::getInstance()->loadModule('modules_Email')->addPaths();
00110                 
00111                 Dataface_JavascriptTool::getInstance()->import('xataface/modules/Email/email_form.js');
00112                 echo "<div id=\"template-instructions\"></div>";
00113         }
00114         
00115         
00116         public function block__before_main_section(){
00117                 //echo '<h2>Email History</h2>';
00118         
00119         }
00120         
00121         public function section__progress($record){
00122         
00123                 ob_start();
00124                 $mod = Dataface_ModuleTool::getInstance()->loadModule('modules_Email');
00125                 $mod->addPaths();
00126                 
00127                 $job = df_get_record('xataface__email_jobs', array('email_id'=>'='.$record->val('id')));
00128                 if ( !$job ) return null;
00129                 
00130                 Dataface_JavascriptTool::getInstance()->import('xataface/modules/Email/email_progress.js');
00131                 df_display(array(
00132                                 'jobId' => $job->val('job_id')
00133                         ),
00134                         'xataface/modules/email/email_progress_section.html'
00135                 );
00136                 
00137                 $contents = ob_get_contents();
00138                 ob_end_clean();
00139         
00140         
00141                 return array(
00142                         'content' => $contents,
00143                         'label' => 'Progress',
00144                         'order' => 10,
00145                         'class' => 'main'
00146                 );
00147         }
00148         
00149         
00150         public function block__before_main_column(){
00151                 echo "<h1>Email History</h1>";
00152                 echo "<div class=\"portalHelp\">This section allows you to browse the history of emails that have been sent by the system.</div>";
00153                 echo '<div>[<a href="'.DATAFACE_SITE_HREF.'?-action=email_manage">Back to Email Management</a>]</div>';
00154         }
00155         
00156         
00157         public function start_time__display($record){
00158                 if ( !$record->val("start_time") ) return '';
00159                 else return strftime('%c', $record->val('start_time'));
00160         }
00161         
00162         public function end_time__display($record){
00163                 if ( !$record->val('end_time') ) return '';
00164                 else return strftime('%c', $record->val('end_time'));
00165         }
00166         
00167         
00168         public function valuelist__archive_categories(){
00169                 return array(
00170                         1=>'Recent Jobs',
00171                         2 => 'Archived Jobs'
00172                 );
00173         }
00174         
00175         
00176 
00177 
00178         
00179 }
 All Data Structures Files Functions Variables Enumerations