Esempio n. 1
0
 public function doExecList()
 {
     $this->table = $table;
     if (!$this->getConfig('view', $table)) {
         M_Office_Util::refresh(ROOT_ADMIN_URL . ROOT_ADMIN_SCRIPT);
     }
     $do =& $this->doForTable($table);
     if ($this->getOption('search', $table)) {
         $doSearch =& $this->doForTable($table);
         $searchForm =& M_Office_Util::getSearchForm($doSearch);
         $this->assign('search', $searchForm);
         if (isset($_REQUEST['searchSubmit'])) {
             $do = $this->getSearchDO($searchForm);
         }
     }
     if ($this->getAndProcessActions(clone $do, $table)) {
         return;
     }
     if (isset($_REQUEST['record']) && ($this->getOption('edit', $table) || $this->getOption('view', $table))) {
         $subController = new M_Office_EditRecord($table, $_REQUEST['record']);
         $this->assign('__action', 'edit');
         return;
     }
     if ($this->getOption('view', $do->tableName()) === TRUE) {
         $dg =& new M_Office_View_DOPaging($this);
         $this->assign('__listview', 'dopaging');
     } else {
         $class = 'M_Office_View_' . $this->getOption('view', $do->tableName());
         $dg = new $class($this);
         $this->assign('__listview', $this->getOption('view', $do->tableName()));
     }
     $dg->prepare($do, true, isset($searchWhere) ? $paginate ? true : false : true);
     $this->assign('dg', $dg);
     $this->assign('total', $total);
     $this->assign('pager', $dg->getPaging());
     $this->assign('fields', $dg->getFields());
     $this->assign('__action', 'showtable');
     $deleteForm = new MyQuickForm('showTableForm', 'post', M_Office_Util::getQueryParams(array(), array(), false), '_self', null, true);
     M_Office_Util::addHiddenFields($deleteForm, array(), true);
 }
Esempio n. 2
0
 function __construct($module)
 {
     parent::__construct();
     $this->assign('module', $module);
     $this->module = $module;
     deny_unless_can('read', $module);
     if ((isset($_REQUEST['record']) || isset($_REQUEST['__record_ref'])) && ($this->getOption('edit', $module) || $this->getOption('view', $module))) {
         $subController = new M_Office_EditRecord($module, $_REQUEST['record'], $additionalFilter);
         $subController->__record_ref = $_REQUEST['__record_ref'];
         $subController->run();
         return;
     }
     if (isset($_REQUEST['addRecord']) && $this->getOption('add', $module)) {
         deny_unless_can('create', $module);
         $subController = new M_Office_AddRecord($module);
         $subController->run();
         return;
     }
     $opts = PEAR::getStaticProperty('m_office', 'options');
     $this->moduloptions = $opts['modules'][$module];
     $this->table = $this->moduloptions['table'];
     if (!$this->getOption('view', $module)) {
         M_Office_Util::refresh(ROOT_ADMIN_URL . ROOT_ADMIN_SCRIPT);
     }
     if ($this->getOption('search', $module)) {
         // 1. Url curation if needed
         // if(!key_exists('_c_',$_REQUEST) && !M_Office::isAjaxRequest()) {
         //   M_Office_Util::refresh(M_Office::cleanURL(array('_c_'=>1),array('searchSubmit','__submit__')));
         // }
         // 2. Process search
         $doSearch = M_Office_Util::doForModule($this->module);
         $searchForm = M_Office_Util::getSearchForm($doSearch, $this->module);
         $this->assign('search', $searchForm);
         $searchValues = $searchForm->exportValues();
     } else {
         $searchValues = array();
     }
     $do = $this->getSearchDO($searchValues);
     if (isset($_REQUEST['doaction']) && $this->getOption('actions', $module)) {
         $order = trim($_REQUEST['_ps'] . ' ' . $_REQUEST['_pd']);
         if ($order) {
             $do->orderBy();
             $do->orderBy($order);
         }
         $subController = new M_Office_Actions($this->getOptions());
         $subController->run($do, $_REQUEST['doaction'], 'batch');
         if ($subController->has_output) {
             return;
         }
     } elseif (isset($_REQUEST['glaction']) && $this->getOption('actions', $module)) {
         $subController = new M_Office_Actions($this->getOptions());
         $subController->run($do, $_REQUEST['glaction'], 'global');
         if ($subController->has_output) {
             return;
         }
     }
     if ($this->getAndProcessActions(clone $do, $module)) {
         return;
     }
     if ($this->getOption('view', $this->module) === TRUE) {
         $dg = new M_Office_View_DOPaging($this);
         $this->assign('__listview', 'dopaging');
     } else {
         $class = 'M_Office_View_' . $this->getOption('view', $this->module);
         $dg = new $class($this);
         $this->assign('__listview', $this->getOption('view', $this->module));
     }
     $tpl = Mreg::get('tpl');
     $do_before_fetch = clone $do;
     $tpl->assign('do_before_fetch', $do_before_fetch);
     $tpl->concat('adminTitle', $this->moduloptions['title'] . ' :: Listing');
     $tpl->assign('adminHeader', $this->moduloptions['title']);
     $pagination = $this->paginate === false ? false : true;
     $dg->prepare($do, $this->module, $pagination);
     $this->assign('dg', $dg);
     $this->assign('total', $total);
     $this->assign('pager', $dg->getPaging());
     $this->assign('fields', $dg->getFields());
     $this->assign('__action', 'showtable');
     $deleteForm = new MyQuickForm('showTableForm', 'post', M_Office_Util::getQueryParams(array(), array()), '_self', null, true);
     M_Office_Util::addHiddenFields($deleteForm, array(), true);
 }