/** * @since v3.0.3 */ public function runActions() { $action = null; $action_index = 1; if (count($_GET) > 1) { $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 1, 1, true)))); if ($requested_action == OSCOM::getSiteApplication()) { $requested_action = null; if (count($_GET) > 2) { $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 2, 1, true)))); $action_index = 2; } } if (!empty($requested_action) && self::siteApplicationActionExists($requested_action)) { $this->_current_action = $action = $requested_action; } } if (isset($action)) { call_user_func(array('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action, 'execute'), $this); $action_index++; if ($action_index < count($_GET)) { $action = array($action); for ($i = $action_index, $n = count($_GET); $i < $n; $i++) { $subaction = HTML::sanitize(basename(key(array_slice($_GET, $i, 1, true)))); if (!in_array($subaction, $this->_ignored_actions) && self::siteApplicationActionExists(implode('\\', $action) . '\\' . $subaction)) { call_user_func(array('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . implode('\\', $action) . '\\' . $subaction, 'execute'), $this); $action[] = $subaction; $this->_current_action = $subaction; } else { break; } } } } }
function __construct($group) { $OSCOM_Cache = Registry::get('Cache'); $OSCOM_Template = Registry::get('Template'); $OSCOM_Database = Registry::get('Database'); $this->_group = $group; if ($OSCOM_Cache->read('templates_' . $this->_group . '_layout-' . $OSCOM_Template->getCode() . '-' . OSCOM::getSiteApplication() . '-' . $OSCOM_Template->getPageContentsFilename())) { $data = $OSCOM_Cache->getCache(); } else { $data = array(); $Qspecific = $OSCOM_Database->query('select b2p.boxes_group, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.page_specific = 1 and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order'); $Qspecific->bindInt(':templates_id', $OSCOM_Template->getID()); $Qspecific->bindRaw(':content_page', '"*", "' . OSCOM::getSiteApplication() . '/*", "' . OSCOM::getSiteApplication() . '/' . substr($OSCOM_Template->getPageContentsFilename(), 0, strrpos($OSCOM_Template->getPageContentsFilename(), '.')) . '"'); $Qspecific->bindValue(':modules_group', $this->_group); $Qspecific->execute(); if ($Qspecific->numberOfRows()) { while ($Qspecific->next()) { $data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code'); } } else { $_data = array(); $Qmodules = $OSCOM_Database->query('select b2p.boxes_group, b2p.content_page, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order'); $Qmodules->bindInt(':templates_id', $OSCOM_Template->getID()); $Qmodules->bindRaw(':content_page', '"*", "' . OSCOM::getSiteApplication() . '/*", "' . OSCOM::getSiteApplication() . '/' . substr($OSCOM_Template->getPageContentsFilename(), 0, strrpos($OSCOM_Template->getPageContentsFilename(), '.')) . '"'); $Qmodules->bindValue(':modules_group', $this->_group); $Qmodules->execute(); while ($Qmodules->next()) { $_data[$Qmodules->value('boxes_group')][] = array('code' => $Qmodules->value('code'), 'page' => $Qmodules->value('content_page')); } foreach ($_data as $groups => $modules) { $clean = array(); foreach ($modules as $module) { if (isset($clean[$module['code']])) { if (substr_count($module['page'], '/') > substr_count($clean[$module['code']]['page'], '/')) { unset($clean[$module['code']]); } } $clean[$module['code']] = $module; } $_data[$groups] = $clean; } foreach ($_data as $groups => $modules) { foreach ($modules as $module) { $data[$groups][] = $module['code']; } } } $OSCOM_Cache->write($data); } $this->_modules = $data; }
/** * Return the Administration Tool Application modules the administrator has access to * * @param int $id The ID of the administrator * @access public * @return array */ public static function getUserLevels($id, $site = null) { if (empty($site)) { $site = OSCOM::getSite(); } $data = array('id' => $id); $applications = array(); foreach (OSCOM::callDB('GetAccessUserLevels', $data, 'Core') as $am) { $applications[] = $am['module']; } if (in_array('*', $applications)) { $applications = array(); $DLapps = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/' . $site . '/Application'); $DLapps->setIncludeFiles(false); foreach ($DLapps->getFiles() as $file) { if (preg_match('/[A-Z]/', substr($file['name'], 0, 1)) && !in_array($file['name'], call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'getGuestApplications'))) && file_exists($DLapps->getDirectory() . '/' . $file['name'] . '/Controller.php')) { // HPDL remove preg_match $applications[] = $file['name']; } } } $shortcuts = array(); foreach (OSCOM::callDB('GetAccessUserShortcuts', $data, 'Core') as $as) { $shortcuts[] = $as['module']; } $levels = array(); foreach ($applications as $app) { $application_class = 'osCommerce\\OM\\Core\\Site\\' . $site . '\\Application\\' . $app . '\\Controller'; if (class_exists($application_class)) { if (Registry::exists('Application') && $app == OSCOM::getSiteApplication()) { $OSCOM_Application = Registry::get('Application'); } else { Registry::get('Language')->loadIniFile($app . '.php'); $OSCOM_Application = new $application_class(false); } $levels[$app] = array('module' => $app, 'icon' => $OSCOM_Application->getIcon(), 'title' => $OSCOM_Application->getTitle(), 'group' => $OSCOM_Application->getGroup(), 'linkable' => $OSCOM_Application->canLinkTo(), 'shortcut' => in_array($app, $shortcuts), 'sort_order' => $OSCOM_Application->getSortOrder()); } } return $levels; }
/** * Returns the page module name * * @access public * @return string */ function getModule() { return OSCOM::getSiteApplication(); }
function setLogging($module = null, $id = null) { $this->logging = true; if (empty($module)) { $module = OSCOM::getSiteApplication(); } $this->logging_module = $module; $this->logging_module_id = $id; }
/** * Return the Administration Tool Application modules the administrator has access to * * @param int $id The ID of the administrator * @access public * @return array */ public static function getUserLevels($id, $site = null) { $OSCOM_Database = Registry::get('Database'); if (empty($site)) { $site = OSCOM::getSite(); } $applications = array(); $Qaccess = $OSCOM_Database->query('select module from :table_administrators_access where administrators_id = :administrators_id'); $Qaccess->bindInt(':administrators_id', $id); $Qaccess->execute(); while ($Qaccess->next()) { $applications[] = $Qaccess->value('module'); } if (in_array('*', $applications)) { $applications = array(); $DLapps = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/' . $site . '/Application'); $DLapps->setIncludeFiles(false); foreach ($DLapps->getFiles() as $file) { if (preg_match('/[A-Z]/', substr($file['name'], 0, 1)) && !in_array($file['name'], call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'getGuestApplications'))) && file_exists($DLapps->getDirectory() . '/' . $file['name'] . '/Controller.php')) { // HPDL remove preg_match $applications[] = $file['name']; } } } $shortcuts = array(); $Qshortcuts = $OSCOM_Database->query('select module from :table_administrator_shortcuts where administrators_id = :administrators_id'); $Qshortcuts->bindInt(':administrators_id', $id); $Qshortcuts->execute(); while ($Qshortcuts->next()) { $shortcuts[] = $Qshortcuts->value('module'); } $levels = array(); foreach ($applications as $app) { $application_class = 'osCommerce\\OM\\Core\\Site\\' . $site . '\\Application\\' . $app . '\\Controller'; if (class_exists($application_class)) { if (Registry::exists('Application') && $app == OSCOM::getSiteApplication()) { $OSCOM_Application = Registry::get('Application'); } else { Registry::get('Language')->loadIniFile($app . '.php'); $OSCOM_Application = new $application_class(false); } $levels[$app] = array('module' => $app, 'icon' => $OSCOM_Application->getIcon(), 'title' => $OSCOM_Application->getTitle(), 'group' => $OSCOM_Application->getGroup(), 'linkable' => $OSCOM_Application->canLinkTo(), 'shortcut' => in_array($app, $shortcuts), 'sort_order' => $OSCOM_Application->getSortOrder()); } } return $levels; }
/** * Get the number of messages belonging to a group * * @param string $group The name of the group to check * @access public */ public function size($group = null) { if (empty($group)) { $group = OSCOM::getSiteApplication(); } $size = 0; if ($this->exists($group)) { $size = sizeof($this->_data[$group]); } return $size; }