public function getByPermission() { $system = system::Instance(); if (!empty($system->pid)) { return $this->getByRoles($system->pid); } return array(); }
/** * Constructor * * Constructs a controller based on module name * * @param string $module * module name * @param string $action * action name * @todo shouldn't need $module *and* $modules */ public function __construct($module = null, $view) { if (isset($_POST['submit_token']) && !isset($_POST['search_id'])) { // This is a form submission - check for double click! if (isset($_SESSION['submit_token'][$_POST['submit_token']])) { // First time through so delete session token and continue OK unset($_SESSION['submit_token'][$_POST['submit_token']]); } else { // Duplicate submission so go to the results page of the first submit // unless the original page had errors, in which case let it continue // to re-validate and display the error page $current = $_SESSION['submit_token']['current']; $flash = Flash::Instance(); $flash->addMessages($current['messages']); $flash->addWarnings($current['warnings']); $flash->addErrors($current['errors']); $flash->save(); if (count($current['errors']) == 0) { sendTo($current['controller'], $current['action'], $current['modules'], isset($current['other']) ? $current['other'] : null); } } } $this->module = $module; $this->view = $view; $this->name = strtolower(str_replace('Controller', '', get_class($this))); $this->view->set('controller', $this->name); $system = system::Instance(); $this->pid = $system->pid; $mod_text = 'module'; if (!empty($system->modules)) { foreach ($system->modules as $module) { if (!empty($module)) { $this->_modules[$mod_text] = $module; $mod_text = 'sub' . $mod_text; } } } else { $this->_modules[$mod_text] = $module; } if (!empty($this->_modules) && is_array($this->_modules)) { foreach ($this->_modules as $mod) { $this->_modules_string .= '/' . $mod; } } }
public function toHTML() { $html .= '<ul class="uz_breadcrumbs">'; if (count($this->breadcrumbs) > 0) { $system = system::Instance(); $uri = 'pid=' . $system->pid; foreach ($system->modules as $mkey => $mvalue) { $uri .= '&' . $mkey . '=' . $mvalue; } $uri .= '&controller=' . str_replace('controller', '', strtolower(get_class($system->controller))) . '&action=' . $system->action; foreach ($this->breadcrumbs as $value) { $params = ''; foreach ($value['data'] as $pkey => $pvalue) { $params .= '&' . $pkey . '=' . $pvalue; } $breadcrumbs[] = '<strong>' . $value['name'] . '</strong> <a href="/?' . $uri . $params . '" title="Click to see other items on this level">(Choose another ' . $value['descriptor'] . ')</a>'; } // breadcrumbs are construct backwards, lets sort them out (pun intended) sort($breadcrumbs, SORT_NUMERIC); $html .= '<li>Current Selection'; foreach ($breadcrumbs as $key => $value) { $html .= '<li> » ' . $value . '</li>'; } } else { $html .= '<li>Current Selection</li>'; $html .= '<li>» None</li>'; } $html .= '<li><select id="tree_' . $this->fieldname . '" class="tree_search" name="Search[' . $this->fieldname . ']">'; foreach ($this->options as $val => $opt) { $selected = ''; if ($this->value == $val || is_null($this->value) && $this->default == $val) { $selected = 'selected="selected"'; } $html .= '<option value="' . $val . '" ' . $selected . '>' . h(prettify($opt)) . '</option>'; } $html .= '</select></li></ul></li>'; return $this->labelHTML() . $html; }
* the Free Software Foundation, either version 3 of the License, or * any later version. * * uzERP is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with uzERP. If not, see <http://www.gnu.org/licenses/>. **/ session_start(); // define time at start of request define('START_TIME', microtime(TRUE)); require 'system.php'; $system = system::Instance(); // ******* // CONFIG // we have to load parts of system to load the config $system->check_system(); $system->load_essential(); // ************************** // ERROR REPORTING & LOGGING if (defined('SENTRY_DSN')) { // custom exception handler, sends to sentry set_exception_handler('sentry_exception_handler'); // send fatals to sentry try { $client = new Raven_Client(SENTRY_DSN, array('curl_method' => 'async', 'verify_ssl' => FALSE)); $client->tags_context(array('source' => 'fatal')); $error_handler = new Raven_ErrorHandler($client);
function loadJournals($data, &$errors = array(), &$warnings = array()) { $system = system::Instance(); $data_in = $this->convertData($data); if (is_array($data_in) && count($data_in) > 0) { $db = DB::Instance(); $docref = $db->GenID('gl_transactions_docref_seq'); $gl_transactions = array(); foreach ($data_in as $gl_data) { foreach ($gl_data as $model => $fields) { $glperiod = GLPeriod::getPeriod(fix_date($fields['transaction_date'])); if (!$glperiod || count($glperiod) == 0) { $errors[] = 'No period exists for this date'; break; } $fields['source'] = 'G'; $fields['type'] = 'J'; $fields['docref'] = $docref; $fields['glperiods_id'] = $glperiod['id']; GLTransaction::setTwinCurrency($fields); $gl_transaction = GLTransaction::Factory($fields, $errors); $gl_transactions[] = $gl_transaction; } } if (count($gl_transactions) > 0 && !GLTransaction::saveTransactions($gl_transactions, $errors)) { $errors[] = 'Failed to save journal import'; } } else { $errors[] = 'No data found or error converting data'; } if (count($errors) > 0) { return false; } return array('internal_id' => $gl_transaction->id, 'internal_identifier_field' => 'docref', 'internal_identifier_value' => $docref); }
public function Redirect() { $args = func_get_args(); $arg_array = array('controller', 'action', 'module', 'other'); $module = ''; $controller = ''; $action = ''; if (is_array($args[0])) { $args = $args[0]; } foreach ($args as $i => $arg) { ${$arg_array[$i]} = $arg; } Flash::Instance()->save(); $url = ''; $amp = ''; $ao = AccessObject::Instance(); $pid = $ao->getPermission($module, $controller, $action); if (!empty($pid)) { $url = 'pid=' . $pid; $amp = '&'; } if (isset($module) && !empty($module)) { if (!is_array($module)) { $module = array($module); } $prefix = 'module='; foreach ($module as $m) { $url .= $amp . $prefix . $m; $prefix = 'sub' . $prefix; $amp = '&'; } } if (!empty($controller)) { $url .= $amp . 'controller=' . $controller; $amp = '&'; } if (!empty($action)) { $url .= $amp . 'action=' . $action; $amp = '&'; } if (!empty($other)) { foreach ($other as $key => $value) { $url .= $amp . $key . '=' . $value; $amp = '&'; } } $location = $url; if (!empty($location) && $location[0] == '&') { $location = substr($location, 1); } debug('RedirectHandler::Redirect ' . $location); // echo 'RedirectHandler::Redirect '.$location.'<br>'; $system = system::Instance(); if (is_object($system->controller)) { if (is_array($system->controller->_data) && isset($system->controller->_data['password'])) { $system->controller->_data['password'] = '******'; } audit(print_r($system->controller->_data, true) . print_r($system->flash, true)); } audit('RedirectHandler::Redirect ' . $location); header('Location: ' . SERVER_ROOT . (!empty($location) ? '/?' . $location : '')); exit; }