<?php /** * Upgrade file for Core 2.8.0 to 3.0.0 (Security 1.2.0 to 1.3.0) * * The security model has been migrated into Core as of 3.0, so this script * migrates the data from the security component into Core. * * @author Charlie Powell <*****@*****.**> * @date 20131229.2033 */ // Handle conversion of the security entries to system log entries. // These are now contained in that table. $secfac = new ModelFactory('SecurityLogModel'); $stream = new \Core\Datamodel\DatasetStream($secfac->getDataset()); while ($row = $stream->getRecord()) { //$model = SystemLogModel::Construct($row['id']); $model = new SystemLogModel($row['id']); // Standard keys $model->setFromArray(['datetime' => $row['datetime'], 'session_id' => $row['session_id'], 'user_id' => $row['user_id'], 'ip_addr' => $row['ip_addr'], 'useragent' => $row['useragent'], 'code' => $row['action'], 'affected_user_id' => $row['affected_user_id'], 'message' => $row['details']]); $model->set('type', $row['status'] == 'fail' ? 'security' : 'info'); $model->save(); }
public function sitemap(){ $view = $this->getView(); $req = $this->getPageRequest(); // Give me every registered (public) page! $factory = new ModelFactory('PageModel'); $factory->where('indexable = 1'); $factory->order('title'); // Multisite? if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()){ $factory->whereGroup( 'OR', array( 'site = ' . MultiSiteHelper::GetCurrentSiteID(), 'site = -1' ) ); $site = MultiSiteHelper::GetCurrentSiteID(); } else{ $site = null; } // Run this through the streamer, just in case there are a lot of pages... $stream = new \Core\Datamodel\DatasetStream($factory->getDataset()); $user = \Core\user(); $toshow = array(); while(($record = $stream->getRecord())){ if(!$user->checkAccess( $record['access'] )){ // Skip any further operations if the user does not have access to this page continue; } if($record['published_status'] != 'published'){ // Skip any further operations if the page isn't even marked as published. continue; } $page = new PageModel(); $page->_loadFromRecord($record); if(!$page->isPublished()){ // Skip out if the page is not marked as published. // This has extended checks other than simply if the status is set as "published", // such as publish date and expiration date. continue; } $toshow[] = $page; } // Anything else? $extra = HookHandler::DispatchHook('/sitemap/getlisting'); $toshow = array_merge($toshow, $extra); // This page allows for a few content types. switch($req->ctype){ case View::CTYPE_XML: $view->contenttype = View::CTYPE_XML; break; case View::CTYPE_HTML: $view->contenttype = View::CTYPE_HTML; break; } $view->title = 'Sitemap'; $view->assign('pages', $toshow); $view->assign('site', $site); }