Author: jaimesuez
Date: 2010-04-13 21:14:07 +0200 (Tue, 13 Apr 2010)
New Revision: 29124

Modified:
   
plugins/sfReadOnlyWidgetsPlugin/lib/widget/sfWidgetFormInputTextReadOnly.class.php
Log:
Agregado uso de credenciales


Modified: 
plugins/sfReadOnlyWidgetsPlugin/lib/widget/sfWidgetFormInputTextReadOnly.class.php
===================================================================
--- 
plugins/sfReadOnlyWidgetsPlugin/lib/widget/sfWidgetFormInputTextReadOnly.class.php
  2010-04-13 18:34:06 UTC (rev 29123)
+++ 
plugins/sfReadOnlyWidgetsPlugin/lib/widget/sfWidgetFormInputTextReadOnly.class.php
  2010-04-13 19:14:07 UTC (rev 29124)
@@ -6,15 +6,22 @@
   protected function configure($options = array(), $attributes = array())
   {
     $this->addRequiredOption("form");
+    $this->addRequiredOption("widget_name");
+    $this->addOption("credentials", false);
 
+    #sacamos el validador si corresponde
+    if($this->isDeactivated($options["form"], $options["credentials"]))
+    {
+      unset($options["form"][$options["widget_name"]]);
+    }
+
     parent::configure($options, $attributes);
   }
-  
+
   public function render($name, $value = null, $attributes = array(), $errors 
= array())
   {
-    $form = $this->getOption("form");
-
-    if (!$form->isNew())
+    #convertimos en readOnly si corresponde
+    if (self::isDeactivated($this->getOption("form"), 
$this->getOption("credentials")))
     {
       return $value;
     }
@@ -23,4 +30,30 @@
       return parent::render($name, $value, $attributes, $errors);
     }
   }
+
+  public static function isDeactivated($form, $credentials)
+  {
+    if($credentials != false)
+    {
+      if(sfContext::getInstance()->getUser()->hasCredential($credentials))
+      {
+        return false;
+      }
+      else
+      {
+        return true;
+      }
+    }
+    else
+    {
+      if (!$form->isNew())
+      {
+        return true;
+      }
+      else
+      {
+        return false;
+      }
+    }
+  }
 }
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to