public static function Initialise() { self::UpdateHtaccess(); utopia::RegisterAjax('toggle_debug', 'uDashboard::toggleDebug'); uEvents::AddCallback('AfterRunModule', 'uDashboard::SetupMenu', utopia::GetCurrentModule()); self::AddParent('/'); }
public static function CreateLinkMenu($module = null) { $cm = utopia::GetCurrentModule(); if ($module === null) { $module = $cm; } if (isset(self::$done[$module])) { return; } self::$done[$module] = true; $cmAdmin = is_subclass_of($cm, 'iAdminModule'); $modules = utopia::GetChildren($module); $highestpos = 0; foreach ($modules as $mid => $children) { if ($cmAdmin && !is_subclass_of($mid, 'iAdminModule')) { continue; } if (!$cmAdmin && is_subclass_of($mid, 'iAdminModule')) { continue; } foreach ($children as $child) { if (isset($child['callback'])) { continue; } if (isset($child['fieldLinks']) && $mid !== $cm) { continue; } if (uEvents::TriggerEvent('CanAccessModule', $mid) === FALSE) { continue; } if ($module !== $cm && $child['parent'] === '/') { continue; } $parent = '_modlinks_'; if (isset($child['parent']) && $child['parent'] !== '/') { $parent .= $child['parent']; } $obj = utopia::GetInstance($mid); $position = $obj->GetSortOrder(); if (isset($child['fieldLinks']) && $mid === $cm) { $position = 0; } if ($position > $highestpos) { $highestpos = $position; } uMenu::AddItem($parent . $mid, $obj->GetTitle(), $obj->GetURL(), $parent, null, $position); } self::CreateLinkMenu($mid); } if ($module === $cm) { // add separators $i = -10001; while ($i < $highestpos) { uMenu::AddItem('_sep_' . $i, '', '', '_modlinks_', null, $i); $i = $i + 1000; } } }
static function ProcessDomDocument($obj, $event, $templateDoc) { if (is_subclass_of(utopia::GetCurrentModule(), 'iAdminModule')) { return; } $html = self::DrawAdminBar(); if (!$html) { return; } $body = $templateDoc->getElementsByTagName('body')->item(0); $node = $templateDoc->createDocumentFragment(); $node->appendXML($html); $body->appendChild($node); }
public static function csv() { $obj = utopia::GetInstance(utopia::GetCurrentModule()); $title = $obj->GetTitle(); $fields = $obj->fields; $layoutSections = $obj->layoutSections; $fullOut = ''; // field headers $out = array(); foreach ($fields as $fieldAlias => $fieldData) { if (!$fieldData['visiblename']) { continue; } $out[] = $fieldData['visiblename']; } $fullOut .= '"' . join('","', $out) . "\"\n"; // rows $dataset = $obj->GetDataset(); $pk = $obj->GetPrimaryKey(); $i = 0; while ($row = $dataset->fetch()) { $i++; $out = array(); foreach ($fields as $fieldAlias => $fieldData) { if (!$fieldData['visiblename']) { continue; } $data = strip_tags(trim($obj->PreProcess($fieldAlias, $row[$fieldAlias], $row[$pk]))); if (empty($data)) { $data = ''; } $out[] = preg_replace('/"/', '""', $data); } $fullOut .= '"' . join('","', $out) . "\"\n"; } $etag = utopia::checksum($fullOut); utopia::Cache_Output($fullOut, $etag, 'text/csv', $title . '.csv'); }
public static function getUpload() { //$module = utopia::UUIDExists($_GET['uuid']); //print_r($module); $obj = utopia::GetInstance(utopia::GetCurrentModule()); $rec = $obj->LookupRecord($_GET['p']); //print_r($rec); if (!$rec) { echo '<h1>404 File Not Found</h1>'; header('HTTP/1.1 404 File Not Found', true, 404); die; // die('<h1>404 File Not Found</h1>'); } list($path, $username, $password) = explode('¦', $rec[$_GET['f']]); if ($username) { die('auth'); } $path = realpath($path); $fileMod = filemtime($path); $etag = sha1($fileMod . '-' . filesize($path)); $cType = utopia::GetMimeType($path); utopia::Cache_Check($etag, $cType, basename($path), $fileMod); utopia::Cache_Output(file_get_contents($path), $etag, $cType, basename($path), $fileMod); }
public function GetFilterValue($uid, $refresh = FALSE) { $filterData = $this->GetFilterInfo($uid); if (!is_array($filterData)) { return NULL; } if (isset($filterData['value'])) { return $filterData['value']; } // for union modules, we cannot get a value from currentmodule because it is itself, part of the query if ($filterData['it'] === itNONE && utopia::GetCurrentModule() !== get_class($this) && (!isset($this->UNION_MODULE) || $this->UNION_MODULE !== TRUE)) { $parents = utopia::GetParents(get_class($this)); foreach ($parents as $parent => $childLinks) { if ($parent == '/') { $parent = utopia::GetCurrentModule(); } if (!$parent || !class_exists($parent)) { continue; } $parentObj = utopia::GetInstance($parent); foreach ($childLinks as $info) { if (isset($info['fieldLinks'])) { foreach ($info['fieldLinks'] as $link) { if ($link['toField'] == $filterData['fieldName']) { $row = $parentObj->GetCurrentRecord($refresh); if (!$row && !$refresh) { $row = $parentObj->GetCurrentRecord(true); } if (isset($row[$link['fromField']])) { return $row[$link['fromField']]; } $fltrLookup =& $parentObj->FindFilter($link['fromField'], ctEQ); return $parentObj->GetFilterValue($fltrLookup['uid']); } } } } } } $filters = GetFilterArray(); if (isset($filters[$uid])) { return $filters[$uid]; } return $filterData['default']; }
static function SetCurrentModule($module) { if (!self::ModuleExists($module)) { return; } $cm = utopia::GetCurrentModule(); $o = utopia::GetInstance($cm); if (flag_is_set($o->GetOptions(), PERSISTENT)) { return; } utopia::SetVar('current_module', $module); }
public static function AssertAdminUser() { // admin user exists? $obj = utopia::GetInstance('uUsersList'); $obj->BypassSecurity(true); $rec = $obj->LookupRecord(array('role' => -1, 'validated' => 1), true); $obj->BypassSecurity(false); if ($rec) { return; } // module is persist? $curr = utopia::GetInstance(utopia::GetCurrentModule()); if (flag_is_set($curr->GetOptions(), PERSISTENT)) { return; } // redirect to this module $o = utopia::GetInstance(__CLASS__); $o->AssertURL(307, false); }
static function findPage() { if (self::$currentPage) { return self::$currentPage; } $uri = $_SERVER['REQUEST_URI']; $uri = preg_replace('/(\\?.*)?/', '', $uri); if ($uri === PATH_REL_ROOT) { return self::GetHomepage(); } if (strpos($uri, PATH_REL_CORE . 'index.php') === 0) { return FALSE; } $obj = utopia::GetInstance('uCMS_View'); $cm = utopia::GetCurrentModule(); if ($cm && $cm !== __CLASS__) { $o = utopia::GetInstance(utopia::GetCurrentModule()); $uuid = $o->GetUUID(); $uuid = explode('/', $uuid); $uuid = end($uuid); $row = $obj->LookupRecord($uuid); if ($row) { self::$currentPage = $row; return $row; } return false; } preg_match('/([^\\/]+)(\\/)?(\\.php)?$/Ui', $uri, $matches); if (array_key_exists(1, $matches)) { $row = $obj->LookupRecord($matches[1]); if ($row) { self::$currentPage = $row; return $row; } } return false; }
public static function checkLogin($object) { if (flag_is_set($object->GetOptions(), PERSISTENT)) { return; } if (uEvents::TriggerEvent('CanAccessModule', $object) !== FALSE) { return; } if (self::IsLoggedIn()) { uNotices::AddNotice('Sorry, you do not have access to this feature.', NOTICE_TYPE_WARNING); return FALSE; } $parent = get_class($object); if ($parent == utopia::GetCurrentModule() && $parent !== __CLASS__ && !AjaxEcho('window.location.reload();')) { utopia::QueueLauncher(__CLASS__); //$obj = utopia::GetInstance(__CLASS__); //$obj->_RunModule(); } return FALSE; }