Changeset 446

Show
Ignore:
Timestamp:
01/06/08 21:03:23 (12 months ago)
Author:
padams
Message:

- updated Galery plugin to properly handle OWA post actions, not log ItemAdmin? page views, and strip nounce from url.
- added timeout to fetching owa news RSS
- fixed bug in cache where entities were being added to the dirty list twice if a SQL UPDATE occured. Fixed with proper replace method.

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/module.inc

    r439 r446  
    7474                $owa_config['authentication'] = 'gallery'; 
    7575                $owa_config['site_id'] = md5($gallery_base_url); 
     76                $owa_config['query_string_filters'] = 'g2_fromNavId'; 
    7677                $owa_config['is_embedded'] = 'true'; 
    7778                 
     
    175176                global $gallery; 
    176177                 
    177                 // get instance of owa 
    178                 $owa = owa_factory(); 
    179                  
    180                 // set user priviledges of the request for OWA to log 
    181                 owa_set_priviledges(); 
    182  
    183                 // Setup OWA request params 
    184                 $params = array(); 
    185                  
    186                 // get user gallery's object to set request variables 
    187                 $params['user_name']= $u->userName; 
    188         $params['user_email'] = $u->email;       
     178                 
    189179        if (GalleryUtilities::hasRequestVariable('view')): 
    190180                $viewName = GalleryUtilities::getRequestVariables('view'); 
     181                 
     182                 
    191183                // ensure this is not a Gallery admin screen 
    192                 if ($viewName != "core.SiteAdmin"): 
     184                if ($viewName == "core.SiteAdmin" || $viewName == "core.ItemAdmin"): 
     185                        return; 
     186                else: 
     187                         
     188                        // get instance of owa 
     189                                $owa = owa_factory(); 
     190                                 
     191                                // set user priviledges of the request for OWA to log 
     192                                owa_set_priviledges(); 
     193                 
     194                                // Setup OWA request params 
     195                                $params = array(); 
     196                                 
     197                                // get user gallery's object to set request variables 
     198                                //$params['user_name']= $u->userName; 
     199                                //$params['user_email'] = $u->email;     
    193200                         
    194201                                // get information on current view       
     
    224231        } 
    225232         
     233         
     234        /** 
     235         * Check to see if OWA is installed and activated 
     236         * 
     237         */ 
     238        function owa_isActivated() { 
     239         
     240                list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'owa'); 
     241                 
     242                if (!empty($params)): 
     243                        return true; 
     244                else: 
     245                        return false; 
     246                endif; 
     247        } 
     248         
     249         
    226250        /** 
    227251     * @see GalleryModule::getSiteAdminViews 
     
    231255        global $gallery; 
    232256         
    233         $owa = owa_factory(); 
    234                  
    235                 // set user priviledges of the request for OWA 
    236                 owa_set_priviledges(); 
    237          
     257        // this is needed becasue on the plugins page this callback is triggered 
     258        // whether then plugin is active or not for some reason. 
     259        //if ($this->owa_isActivated()): 
     260                        // get OWA instance 
     261                //      $owa = owa_factory(); 
     262                        // set user priviledges of the request for OWA 
     263                //      owa_set_priviledges(); 
     264                //endif; 
     265                                         
    238266                $data = array(array('name' => $this->translate('Dashboard'), 'view' => 'owa.owaDashboard'), 
    239267                                          array('name' => $this->translate('Admin Settings'), 'view' => 'owa.owaOptions'));                  
     
    292320                 
    293321                $params = array(); 
    294                 $params['view'] = 'base.options'; 
    295                 $params['subview'] = 'base.optionsGeneral';         
     322                 
     323                 if (empty($owa->params['do'])): 
     324                if (empty($owa->params['view'])):                
     325                                $params['view'] = 'base.options'; 
     326                                $params['subview'] = 'base.optionsGeneral';  
     327                        endif; 
     328                endif; 
     329                        
    296330                $page = $owa->handleRequest($params); 
    297331                $template->setVariable('owa', array('content' => $page)); 
    298332                return array(null, array('body' => 'modules/owa/modules/base/templates/gallery.tpl')); 
    299333    } 
     334     
     335    /** 
     336     * Does this view change any data? Only controllers should change data, but AJAX and some 
     337     * immediate views are handled in views in Gallery. 
     338     * @return bool true if the view changes data 
     339     */ 
     340    function isControllerLike() { 
     341                return true; 
     342    } 
     343 
    300344                 
    301345} 
     
    343387                return array(null, array('body' => 'modules/owa/modules/base/templates/gallery.tpl')); 
    344388    } 
    345                  
     389         
     390        /** 
     391     * Does this view change any data? Only controllers should change data, but AJAX and some 
     392     * immediate views are handled in views in Gallery. 
     393     * @return bool true if the view changes data 
     394     */ 
     395    function isControllerLike() { 
     396                return true; 
     397    } 
     398                 
     399} 
     400 
     401class owaControlController extends GalleryController { 
     402 
     403        /** 
     404     * @see GalleryController::handleRequest 
     405     */ 
     406    function handleRequest($form) { 
     407     
     408        $result = array('delegate' => array('view' => 'owa.owaGeneric'), 
     409                        'status' => 1, 'error' => ''); 
     410        return array(null, $result); 
     411     
     412    } 
     413 
    346414} 
    347415 
     
    395463                $viewName = GalleryUtilities::getRequestVariables('view'); 
    396464                // ensure this is not a Gallery admin screen 
    397                 if ($viewName != "core.SiteAdmin"): 
    398  
    399                  
     465                 
     466                if ($viewName == "core.SiteAdmin" || $viewName == "core.ItemAdmin"): 
     467                        return; 
     468                else: 
    400469                                /* 2. Load the requested data */ 
     470                                 
    401471                                $owa = owa_factory(); 
    402472                                $tags = $owa->placeHelperPageTags(false); 
  • trunk/modules/base/classes/cache.php

    r444 r446  
    107107        function replace($collection, $key, $value) { 
    108108         
    109                 return $this->set($collection, $key, $value); 
     109                $hkey = $this->hash($key); 
     110                $this->cache[$collection][$hkey] = $value; 
     111                $this->debug(sprintf('Replacing Object in Cache - Collection: %s, id: %s', $collection, $hkey)); 
     112                $this->statistics['replaced']++; 
     113                 
     114                if (!in_array($collection, $this->non_persistant_collections)): 
     115                        if (!in_array($hkey, $this->dirty_objs[$collection])): 
     116                                $this->dirty_objs[$collection][] = $hkey; 
     117                                //$this->debug(print_r($this->dirty_objs, true)); 
     118                                $this->dirty_collections[$collection] = true;  
     119                                $this->debug(sprintf('Added Object to Dirty List - Collection: %s, id: %s', $collection, $hkey)); 
     120                                $this->statistics['dirty']++; 
     121                        endif; 
     122                // check to see if cache file exists and remove it just in case the collection 
     123                // was recently added to the non persistant list. 
     124                else: 
     125                        $this->removeCacheFile($this->makeCollectionDirPath($collection).$hkey.'.php'); 
     126                endif; 
     127 
     128                 
     129                return; 
    110130        } 
    111131         
     
    189209                                                  Total Miss: %s 
    190210                                                  Total Added to Cache: %s 
     211                                                  Total Replaced: %s 
    191212                                                  Total Persisted: %s 
    192213                                                  Total Removed: %s", 
     
    196217                                                  $this->statistics['miss'], 
    197218                                                  $this->statistics['added'], 
     219                                                  $this->statistics['replaced'], 
    198220                                                  $this->statistics['dirty'], 
    199221                                                  $this->statistics['removed']); 
  • trunk/modules/base/classes/entityManager.php

    r438 r446  
    145145                if ($status == true): 
    146146                        if ($this->config['cache_objects'] == true): 
    147                                 $this->cache->set(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity); 
     147                                $this->cache->replace(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity); 
    148148                        endif; 
    149149                endif; 
  • trunk/modules/base/templates/gallery.tpl

    r438 r446  
     1<input type="hidden" name="{g->formVar var="controller"}" value="owa.owaControl"/> 
    12{$owa.content} 
  • trunk/modules/base/templates/options_general.tpl

    r435 r446  
    33<div class="subview_content"> 
    44 
    5 <form method="post"> 
     5<form method="post" name="owa_options"> 
    66 
    77        <fieldset name="owa-options" class="options"> 
  • trunk/owa_news.php

    r435 r446  
    5757                $this->e = &owa_coreAPI::errorSingleton(); 
    5858                $this->crawler = new owa_http; 
     59                $this->crawler->read_timeout = 10; 
    5960                $this->cache_dir = ''; 
    6061                $this->date_format = "F j, Y";