Author: ggrekhov
Date: Fri Jul 13 04:13:53 2012
New Revision: 1361040

URL: http://svn.apache.org/viewvc?rev=1361040&view=rev
Log:
Teambox: correct organizations-projects structure

Added:
    incubator/openmeetings/trunk/plugins/teambox/TeamboxUtils.php
Removed:
    incubator/openmeetings/trunk/plugins/teambox/openmeetings.js
Modified:
    incubator/openmeetings/trunk/plugins/teambox/index.php

Added: incubator/openmeetings/trunk/plugins/teambox/TeamboxUtils.php
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/teambox/TeamboxUtils.php?rev=1361040&view=auto
==============================================================================
--- incubator/openmeetings/trunk/plugins/teambox/TeamboxUtils.php (added)
+++ incubator/openmeetings/trunk/plugins/teambox/TeamboxUtils.php Fri Jul 13 
04:13:53 2012
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function isArchivedProject($project) {
+    if (null == $project->archived) {
+        return false;
+    } else {
+        return $project->archived;
+    }
+}
+
+function getFilteredOrganizationProjects($organization, $projects) {
+    $result = array();
+    foreach ($projects as $project) {
+        if (isArchivedProject($project)) {
+            continue;
+        }
+        if ($project->organization_id === $organization->id) {
+            $idx = strtoupper($project->name . $project->id);
+            $result[$idx] = $project;
+        }
+    }
+
+    ksort($result);
+    return $result;
+}
+
+function getSortedOrganizations($organizations) {
+    $result = array();
+    foreach ($organizations as $org) {
+        $idx = strtoupper($org->name . $org->id);
+        $result[$idx] = $org;
+    }
+
+    ksort($result);
+    return $result;
+}
+
+?>

Modified: incubator/openmeetings/trunk/plugins/teambox/index.php
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/teambox/index.php?rev=1361040&r1=1361039&r2=1361040&view=diff
==============================================================================
--- incubator/openmeetings/trunk/plugins/teambox/index.php (original)
+++ incubator/openmeetings/trunk/plugins/teambox/index.php Fri Jul 13 04:13:53 
2012
@@ -25,6 +25,7 @@ $CFG = parse_ini_file('config/settings.i
 require_once('rest_lib/TeamBoxRestService.php');
 require_once('rest_lib/OpenMeetingsRestService.php');
 require_once('oauthLogin.php');
+require_once('TeamboxUtils.php');
 
 $token = getTeamBoxAccessToken();
 
@@ -38,7 +39,7 @@ $logged = $omService->loginAdmin();
 if (!$logged) {
     print 'OpenMeetings internal error. Ask your system administrator.';
     exit(0);
-} 
+}
 
 ?>
 
@@ -46,10 +47,10 @@ if (!$logged) {
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 </head>
-<body>
-<link rel="stylesheet" type="text/css" 
href="https://d238xsvyykqg39.cloudfront.net/assets/application-37543c3d9d17e9c1f80cadeffa6f73bf.css";
 media="screen" />
-<link rel="stylesheet" type="text/css" 
href="https://d238xsvyykqg39.cloudfront.net/assets/public-61885d5db2e6b3192d52d9e3c742ba00.css";
 media="screen" />
+<!--link rel="stylesheet" type="text/css" 
href="https://d238xsvyykqg39.cloudfront.net/assets/application-37543c3d9d17e9c1f80cadeffa6f73bf.css";
 media="screen" />
+<link rel="stylesheet" type="text/css" 
href="https://d238xsvyykqg39.cloudfront.net/assets/public-61885d5db2e6b3192d52d9e3c742ba00.css";
 media="screen" /-->
 <link rel="stylesheet" type="text/css" href="css/index.css" media="screen" />
+<body>
 
 <div style="text-align: center;">
 <?php
@@ -65,22 +66,26 @@ if (0 == count($organizations)) {
         echo '<td>Projects:</td>';
     echo '</tr>';
 
-    foreach ($organizations as $organization) {
+    $sortedOrgs = getSortedOrganizations($organizations);
+
+    foreach ($sortedOrgs as $organization) {
+        $orgProjs = getFilteredOrganizationProjects($organization, $projects);
         $url = $omService->getInvitationForOrganization($organization, 
$account);
 
         echo '<tr>';
-        echo '<td>';
-        echo '<a class="button button-primary" 
href="'.$url.'"><span>'.$organization->name.'</span></a>';
-        echo '</td>';
-
-        echo '<td>';
-        foreach ($projects as $project) {
-            if ($project->organization_id === $organization->id) {
-                $url = $omService->getInvitationForProject($organization, 
$project, $account);
-                echo '<p><a class="button" 
href="'.$url.'"><span>'.$project->name.'</span></a></p>';
-            }
-        }
-        echo '</td>';
+            echo '<td>';
+                echo '<a class="button button-primary" 
href="'.$url.'"><span>'.$organization->name.'</span></a>';
+            echo '</td>';
+
+            echo '<td>';
+                if (0 == count($orgProjs)) {
+                    echo '&nbsp';
+                }
+                foreach ($orgProjs as $project) {
+                    $url = $omService->getInvitationForProject($organization, 
$project, $account);
+                    echo '<p><a class="button" 
href="'.$url.'"><span>'.$project->name.'</span></a></p>';
+                }
+            echo '</td>';
         echo '</tr>';
     }
     echo '</table>';


Reply via email to