- Timestamp:
- 03/10/10 14:37:31 (11 years ago)
- Location:
- trunk/server/www/app
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/www/app/controllers/galleries_controller.php
r301 r315 31 31 32 32 /** The models this controller uses */ 33 public $uses = array('Gallery', 'Request', 'User' );33 public $uses = array('Gallery', 'Request', 'User', 'Application'); 34 34 35 35 /** … … 139 139 'conditions' => array('Gallery.slug' => $slug), 140 140 'contain' => array( 141 'Request' ,141 'Request' => array('order' => 'Request.filename ASC'), 142 142 'Request.Validator' => array('order' => 'Validator.name ASC'), 143 143 'Request.Job' => array('order' => array( … … 155 155 )); 156 156 157 // Find out how many requests this gallery has. This determins the type of view157 // Find out if this test suite needs to be abbreviated 158 158 $requestCount = $this->Gallery->requestCount($gallery['Gallery']['id'], true); 159 $abbreviate = ($requestCount >= Configure::read('Gallery.abbreviate')); 159 $isTestsuite = $this->Gallery->isTestsuite($gallery['Gallery']['id']); 160 $abbreviate = ($requestCount >= Configure::read('Gallery.abbreviate') && !$isTestsuite); 160 161 161 162 // Get the children of this gallery … … 165 166 'Gallery.rght <' => $gallery['Gallery']['rght'], 166 167 ), 167 'contain' => array('Request'), 168 'contain' => array('Request' => array('order' => 'Request.filename ASC')), 169 'order' => array('Gallery.name ASC'), 168 170 )); 169 171 … … 201 203 unset($job['Job']); 202 204 } 205 unset($job); 203 206 } 204 207 } 205 208 } 206 209 210 // If this is a Testsuite then we need some extra information 211 if ($isTestsuite) { 212 $versions = array(); 213 $jobs = Set::extract('/Request/Job', $gallery); 214 $jobs = array_merge(Set::extract('/Request/Job', $children), $jobs); 215 216 foreach ($jobs as $job) { 217 $application = $job['Job']['application_id']; 218 if (!isset($versions[$application])) { 219 $versions[$application] = $job['Job']['version']; 220 continue; 221 } 222 223 if ($job['Job']['version'] > $versions[$application]) { 224 $versions[$application] = $job['Job']['version']; 225 } 226 } 227 unset($application); // Because we're referencing below 228 229 $applications = $this->Application->find('all', array( 230 'conditions' => array('Application.id' => array_keys($versions)), 231 'order' => array('Application.name'), 232 'recursive' => -1, 233 )); 234 235 foreach ($applications as &$application) { 236 $application['Application']['version'] = $versions[$application['Application']['id']]; 237 } 238 unset($application); // Drop the reference 239 240 $this->set(compact('applications')); 241 } 242 243 // Sort the subgalleries for display 207 244 $gallery['children'] = $this->_sortThreaded($children); 208 245 … … 214 251 $access = $this->_checkAccess($slug); 215 252 $this->set(compact('gallery', 'path', 'access', 'abbreviate')); 253 254 // Render 255 if ($isTestsuite) { 256 $this->render('testsuite'); 257 } 216 258 } 217 259 -
trunk/server/www/app/models/gallery.php
r301 r315 50 50 public function checkAccess($user_id, $id = false) 51 51 { 52 if ( $id) {52 if (!$id) { 53 53 $id = $this->id; 54 54 } … … 76 76 77 77 return false; 78 } 79 80 /** 81 * Determine if this gallery is a test suite gallery 82 * @param string $id The gallery ID 83 * @return boolean True or False 84 */ 85 public function isTestsuite($id = null) 86 { 87 if (!$id) { 88 $id = $this->id; 89 } 90 91 if (!$id) { 92 return false; 93 } 94 95 $count = $this->Testsuite->find('count', array( 96 'conditions' => array('Testsuite.gallery_id' => $id), 97 'recursive' => -1, 98 )); 99 100 return ($count > 0); 78 101 } 79 102
Note: See TracChangeset
for help on using the changeset viewer.