Code cleanups/phpdoc
authorMichael M Slusarz <slusarz@curecanti.org>
Sat, 4 Sep 2010 06:35:21 +0000 (00:35 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 6 Sep 2010 20:31:15 +0000 (14:31 -0600)
framework/Core/lib/Horde/Registry.php
horde/lib/core.php
horde/services/shares/edit.php
horde/templates/shares/edit.inc

index 1e9265b..1889aa9 100644 (file)
@@ -108,8 +108,13 @@ implements Horde_Interfaces_Registry_Auth
      * init() will be called after the initialization is completed.
      *
      * Global variables defined:
+     *   $browser - Horde_Browser object
      *   $cli - Horde_Cli object (if 'cli' is true)
+     *   $conf - Configuration array
+     *   $injector - Horde_Injector object
      *   $language - Language
+     *   $notification - Horde_Notification object
+     *   $prefs - Horde_Prefs object
      *   $registry - Horde_Registry object
      *
      * @param string $app  The application to initialize.
@@ -347,7 +352,8 @@ implements Horde_Interfaces_Registry_Auth
         $GLOBALS['registry'] = $this;
         $injector->setInstance('Horde_Registry', $this);
 
-        /* Setup autoloader instance and callbacks. */
+        /* Setup autoloader instance and callbacks.
+         * $__autoloader is defined in horde/lib/core.php */
         $injector->setInstance('Horde_Autoloader', $GLOBALS['__autoloader']);
         foreach ($callbacks as $key => $val) {
             $GLOBALS['__autoloader']->addCallback($key, array($val, 'callback'));
index b1d42a1..06059c6 100644 (file)
@@ -9,6 +9,10 @@
  *
  * See the enclosed file COPYING for license information (LGPL). If you
  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Horde
  */
 
 /* Turn PHP stuff off that can really screw things up. */
index ee3787f..44a11d7 100644 (file)
@@ -27,27 +27,24 @@ $app = Horde_Util::getFormData('app');
 $shares = $injector->getInstance('Horde_Share')->getScope($app);
 $groups = Horde_Group::singleton();
 $auth = $injector->getInstance('Horde_Auth')->getAuth();
-if ($registry->hasMethod('shareHelp', $app)) {
-    $help = $registry->callByPackage($app, 'shareHelp');
-} else {
-    $help = null;
-}
+$help = $registry->hasMethod('shareHelp', $app)
+    ? $registry->callByPackage($app, 'shareHelp')
+    : null;
 
 $form = null;
 $reload = false;
-$actionID = Horde_Util::getFormData('actionID', 'edit');
-switch ($actionID) {
+switch (Horde_Util::getFormData('actionID', 'edit')) {
 case 'edit':
     try {
-        $share = &$shares->getShareById(Horde_Util::getFormData('cid'));
+        $share = $shares->getShareById(Horde_Util::getFormData('cid'));
         $form = 'edit.inc';
-        $perm = &$share->getPermission();
+        $perm = $share->getPermission();
     } catch (Horde_Share_Exception $e) {
         if (($category = Horde_Util::getFormData('share')) !== null) {
             try {
                 $share = $shares->getShare($category);
                 $form = 'edit.inc';
-                $perm = &$share->getPermission();
+                $perm = $share->getPermission();
             } catch (Horde_Share_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
             }
@@ -55,16 +52,16 @@ case 'edit':
     }
 
     if (!$registry->getAuth() ||
-              (isset($share) &&
-               !$registry->isAdmin() &&
-               $registry->getAuth() != $share->get('owner'))) {
-        exit('permission denied');
+        (isset($share) &&
+         !$registry->isAdmin() &&
+         ($registry->getAuth() != $share->get('owner')))) {
+        throw new Horde_Exception('Permission denied.');
     }
     break;
 
 case 'editform':
     try {
-        $share = &$shares->getShareById(Horde_Util::getFormData('cid'));
+        $share = $shares->getShareById(Horde_Util::getFormData('cid'));
     } catch (Horde_Share_Exception $e) {
         $notification->push(_("Attempt to edit a non-existent share."), 'horde.error');
     }
@@ -72,10 +69,10 @@ case 'editform':
     if (!empty($share)) {
         if (!$registry->getAuth() ||
             (!$registry->isAdmin() &&
-             $registry->getAuth() != $share->get('owner'))) {
-            exit('permission denied');
+             ($registry->getAuth() != $share->get('owner')))) {
+            throw new Horde_Exception('Permission denied.');
         }
-        $perm = &$share->getPermission();
+        $perm = $share->getPermission();
 
         // Process owner and owner permissions.
         $old_owner = $share->get('owner');
@@ -258,11 +255,9 @@ case 'editform':
     break;
 }
 
-if (is_a($share, 'PEAR_Error')) {
-    $title = _("Edit permissions");
-} else {
-    $title = sprintf(_("Edit permissions for \"%s\""), $share->get('name'));
-}
+$title = ($share instanceof PEAR_Error)
+    ? _("Edit permissions")
+    : sprintf(_("Edit permissions for \"%s\""), $share->get('name'));
 
 $userList = array();
 if ($auth->hasCapability('list') &&
index 19aa853..76183d1 100644 (file)
 
 <!-- Ownership -->
 <?php
-if (isset($userperms[$owner])) {
-    $operm = $userperms[$owner];
-} else {
-    $operm = Horde_Perms::SHOW | Horde_Perms::READ | Horde_Perms::EDIT | Horde_Perms::DELETE;
-}
+$operm = isset($userperms[$owner])
+    ? $userperms[$owner]
+    : Horde_Perms::SHOW | Horde_Perms::READ | Horde_Perms::EDIT | Horde_Perms::DELETE;
 ?>
 <tr valign="middle">
   <td class="header leftAlign" colspan="6">