Permalink
Browse files

adding report time period controls to sites roster report. #592

adding better error exceptions in entity class.
  • Loading branch information...
padams
padams committed Jan 28, 2012
1 parent 9bf4acc commit a6bf0c9623fbf99973b34685912a6f098f398a03
@@ -203,9 +203,9 @@ function isSiteAccessible( $siteId ) {
return true;
}
//if ( ! $this->isAssignedSitesListLoaded ) {
// $this->loadAssignedSites();
//}
if ( ! $this->isAssignedSitesListLoaded ) {
//$this->loadAssignedSites();
}
if ( isset( $this->assignedSites[ $siteId ] ) ) {
owa_coreAPI::debug("Site ID: $siteId in accessible list for this user.");
@@ -229,9 +229,9 @@ function isAuthenticated() {
* Loads internal $this->assignedSites member
*/
private function loadAssignedSites() {
owa_coreAPI::debug('loading assigned sites');
if ( ! $this->user->get( 'id' ) ) {
throw exception('no user object loaded!');
throw new Exception('no user object loaded!');
}
$site_ids = array();
@@ -271,7 +271,7 @@ private function setAllowedSitesList($site_ids) {
$list = array();
if ( $site_ids ) {
if ( ! empty($site_ids) ) {
foreach ($site_ids as $row) {
$siteEntity = owa_coreApi::entityFactory('base.site');
$siteEntity->load($row['site_id']);
@@ -254,7 +254,10 @@ OWA.report.prototype = {
// add new site_id to properties
var siteId = jQuery("#owa_reportSiteFilterSelect option:selected").val();
OWA.debug(this.properties['action']);
this.properties['siteId'] = siteId;
if (siteId != undefined) {
this.properties['siteId'] = siteId;
}
// reload report
var url = OWA.util.makeUrl(OWA.config.link_template, OWA.config.main_url, this.properties);
window.location.href = url;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -65,7 +65,11 @@ function render($data) {
$this->body->set('do', $this->data['do']);
// Set navigation
$this->body->set('hideReportingNavigation', $this->get('hideReportingNavigation') );
$this->body->set('top_level_report_nav', $this->get('top_level_report_nav'));
$this->body->set('hideSitesFilter', $this->get('hideSitesFilter') );
$this->body->set('currentSiteId', $this->get('currentSiteId'));
View
@@ -43,11 +43,13 @@ function __construct($params) {
function action() {
$s = owa_coreAPI::entityFactory('base.site');
$sites = $this->getSitesAllowedForCurrentUser();
$sites = $this->getSitesAllowedForCurrentUser();
$this->set('tracked_sites', $sites);
$this->setSubview('base.sites');
$this->setView('base.adminPage');
$this->setView('base.report');
$this->set('title', 'Sites Roster');
$this->hideReportingNavigation();
$this->hideSitesFilter();
}
}
@@ -71,7 +73,6 @@ function render() {
//page title
$this->t->set('page_title', 'Sites Roster');
$this->body->set_template('sites.tpl');
$this->body->set('headline', 'Web Sites Roster');
$this->body->set('tracked_sites', $this->get('tracked_sites'));
}
}
View
@@ -60,17 +60,19 @@ function action() {
// This needs form validation in a bad way.
$site = owa_coreAPI::entityFactory('base.site');
$site->set('site_id', $this->params['siteId']);
$site->set('name', $this->params['name']);
$site->set('domain', $this->params['domain']);
$site->set('description', $this->params['description']);
$site->update('site_id');
if (! $this->getParam('siteId')) {
throw exception('No siteId passed on request');
}
$site->load( $site->generateId( $this->getParam('siteId') ) );
$site->set('name', $this->getParam( 'name' ) );
$site->set('domain', $this->getParam( 'domain' ) );
$site->set('description', $this->getParam( 'description') );
$site->save();
$data['view_method'] = 'redirect';
$data['do'] = 'base.sites';
$data['status_code'] = 3201;
return $data;
//$data['view_method'] = 'redirect';
//$data['do'] = 'base.sites';
$this->setRedirectAction('base.sites');
$this->set('status_code', 3201);
}
}
@@ -6,7 +6,7 @@ OWA.items['<?php echo $dom_id;?>'].max_page_num = "<?php $this->out( $this->getV
OWA.items['<?php echo $dom_id;?>'].max_page_num = "<?php $this->out( $this->getValue( 'more_pages', 'pagination' ), false );?>";
OWA.items['<?php echo $dom_id;?>'].properties = <?php echo $this->makeJson($params);?>;
<?php if ( ! $this->get( 'hideReportingNavigation' ) ):?>
// Bind event handlers
jQuery(document).ready(function(){
@@ -15,27 +15,30 @@ jQuery(document).ready(function(){
jQuery(this).parent().siblings('.owa_admin_nav_subgroup').toggle();
});
});
<?php endif;?>
</script>
<div id="<?php echo $dom_id;?>" class="owa_reportContainer">
<table width="100%" cellpadding="0" cellspacing="0">
<TR>
<?php if ( ! $this->get( 'hideReportingNavigation' ) ):?>
<TD valign="top" class="owa_reportLeftNavColumn">
<div class="reportSectionContainer">
<div id="owa_reportNavPanel">
<?php echo $this->makeNavigationMenu($top_level_report_nav, $currentSiteId);?>
</div>
</div>
</TD>
<?php endif;?>
<TD valign="top" width="*">
<?php if ( ! $this->get( 'hideSitesFilter' ) ):?>
<div class="reportSectionContainer" style="margin-bottom:20px;">
<?php include('filter_site.tpl');?>
</div>
<?php endif;?>
<div class="reportSectionContainer">
<div id="owa_timePeriodControl" class="owa_reportPeriod" style="float:right;"></div>
<div id="liveViewSwitch" style="width:auto;float:right; padding-right:30px;"></div>
@@ -43,7 +43,6 @@
'dimensions' => 'date',
'sort' => 'date',
'format' => 'json',
'period' => 'last_thirty_days',
'constraints' => urlencode('siteId=='.$site->get('site_id'))
), true); ?>';
View
@@ -579,18 +579,22 @@ function getSetting($module, $name) {
* @return array
*/
protected function getSitesAllowedForCurrentUser() {
owa_coreAPI::debug('get Sites Allowed for user');
$currentUser = owa_coreAPI::getCurrentUser();
if ( $currentUser->isAnonymousUser() || $currentUser->isAdmin() ) {
$result = array();
$relations = owa_coreAPI::getSitesList();
foreach ($relations as $siteRow) {
$site = owa_coreAPI::entityFactory('base.site');
owa_coreAPI::debug('getSitesAllowedforuser');
$site->load($siteRow['id']);
$result[$siteRow['site_id']] = $site;
}
return $result;
} else {
View
@@ -1200,7 +1200,7 @@ public static function getSitesList() {
$db->selectFrom('owa_site');
$db->selectColumn('*');
$sites = $db->getAllRows();
if ( ! $sites ) {
$sites = array();
}
View
@@ -330,7 +330,7 @@ function delete($value = '', $col = 'id') {
}
function load($value, $col = 'id') {
return $this->getByColumn($col, $value);
}
@@ -342,10 +342,13 @@ function getByPk($col, $value) {
}
function getByColumn($col, $value) {
if ( ! $col ) {
owa_coreAPI::debug('No column name passed to getByColumn in entity:'. getName() );
return;
throw new Exception("No column name passed.");
}
if ( ! $value ) {
throw new Exception("No value passed.");
}
$cache_obj = '';
@@ -367,6 +370,7 @@ function getByColumn($col, $value) {
$db = owa_coreAPI::dbSingleton();
$db->selectFrom($this->getTableName());
$db->selectColumn('*');
owa_coreAPI::debug("Col: $col, value: $value");
$db->where($col, $value);
$properties = $db->getOneRow();
Oops, something went wrong.

0 comments on commit a6bf0c9

Please sign in to comment.