Xataface HTML Reports Module 0.2
HTML Reports Module for Xataface
tables/dataface__htmlreports_reports/dataface__htmlreports_reports.php
Go to the documentation of this file.
00001 <?php
00002 class tables_dataface__htmlreports_reports {
00003 
00004         private $tablenames = null;
00005         private $action_categories = null;
00006 
00007         
00008         function titleColumn(){
00009                 return 'actiontool_label';
00010         }
00011         
00012         function getTitle($record){
00013                 return $record->display('actiontool_label');
00014         }
00015         
00016         function getPermissions($record, $params=array()){
00017                 $table = Dataface_Table::loadTable('dataface__version');
00018                 if ( $record and $record->val('tablename') ){
00019                         $table = Dataface_Table::loadTable($record->val('tablename'));
00020                 }
00021                 $perms =& $table->getPermissions();
00022                 if ( @$perms['manage reports'] ){
00023                         return array(
00024                                 'new'=>1,
00025                                 'edit'=>1,
00026                                 'delete'=>1,
00027                                 'list'=>1,
00028                                 'find'=>1,
00029                                 'view'=>1,
00030                                 'link'=>1
00031                         );
00032                 } else {
00033                         return Dataface_PermissionsTool::NO_ACCESS();
00034                 }
00035         }
00036         
00037         function block__before_form(){
00038                 $mod = Dataface_ModuleTool::getInstance()->loadModule('modules_htmlreports');
00039                 
00040         
00041                 $jt = Dataface_JavascriptTool::getInstance();
00042                 $ct = Dataface_CSSTool::getInstance();
00043                 
00044                 $s = DIRECTORY_SEPARATOR;
00045                 
00046                 $ct->addPath(dirname(__FILE__).$s.'..'.$s.'..'.$s.'css',
00047                         $mod->getBaseURL().'/css'
00048                 );
00049                 
00050                 $jt->addPath(dirname(__FILE__).$s.'..'.$s.'..'.$s.'js',
00051                         $mod->getBaseURL().'/js');
00052                         
00053                 $jt->import('xataface/modules/htmlreports/reports_form.js');
00054         }
00055 
00056 
00057 
00058         function block__before_template_html_widget(){
00059         
00060                 $jt = Dataface_JavascriptTool::getInstance();
00061                 
00062                 $jt->import('ckeditor/plugins/insertmacro/insertmacro.js');
00063                 
00064         }
00065         
00066         
00067         
00068         
00069         function valuelist__tablenames(){
00070                 if ( !isset($this->tablenames) ){
00071                         $app = Dataface_Application::getInstance();
00072                         $tables = $app->_conf['_tables'];
00073                         $out = array();
00074                         
00075                         
00076                         if ( @$app->_conf['_htmlreports_tables'] ){
00077                                 $tables = array_merge($tables, $app->_conf['_htmlreports_tables']);
00078                         }
00079                         
00080                         foreach ($tables as $tname=>$label){
00081                                 if ( Dataface_Table::tableExists($tname) ){
00082                                         $table = Dataface_Table::loadTable($tname);
00083                                         $perms = $table->getPermissions();
00084                                         if ( @$perms['view schema'] ){
00085                                                 $out[$tname] = $label;
00086                                         }
00087                                 }
00088                         }
00089                         $this->tablenames = $out;
00090                 }
00091                 return $this->tablenames;
00092                 
00093                 
00094         }
00095         
00096         function beforeInsert($record){
00097                 if ( class_exists('Dataface_AuthenticationTool') ){
00098                         $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName();
00099                         $record->setValue('created_by', $username);
00100                 }
00101                  
00102         }
00103         
00104         
00105         function valuelist__action_categories(){
00106                 if ( !isset($this->action_categories) ){
00107                         $this->action_categories = array();
00108                         import('Dataface/ActionTool.php');
00109                         $at = Dataface_ActionTool::getInstance();
00110                         
00111                         $cats = array();
00112                         
00113                         foreach ($at->actions as $action){
00114                                 if ( @$action['category'] ){
00115                                         $cats[$action['category']] = $action['category'];
00116                                 }
00117                         }
00118                         asort($cats);
00119                         $this->action_categories = $cats;
00120                 }
00121                 return $this->action_categories;
00122         }
00123         
00124         
00125         function valuelist__action_permissions(){
00126                 if ( !isset($this->action_permissions) ){
00127                         $this->action_permissions = array();
00128                         import('Dataface/PermissionsTool.php');
00129                         $perms = Dataface_PermissionsTool::ALL();
00130                         foreach ($perms as $key=>$val){
00131                                 $perms[$key] = $key;
00132                         }
00133                         $this->action_permissions = $perms;
00134                 }
00135                 return $this->action_permissions;
00136         
00137         }
00138 
00139 }
 All Data Structures Files Functions Variables Enumerations