networking: adds a filter number for ICQ, adds a gpg icon
authorPascal Corpet <pascal.corpet@m4x.org>
Sun, 15 Jun 2008 22:01:57 +0000 (00:01 +0200)
committerPascal Corpet <pascal.corpet@m4x.org>
Sun, 15 Jun 2008 22:01:57 +0000 (00:01 +0200)
htdocs/images/networking/gpg.png [new file with mode: 0644]
modules/profile/general.inc.php
modules/profile/page.inc.php
upgrade/fusionax-0.0.1/02_networking.sql

diff --git a/htdocs/images/networking/gpg.png b/htdocs/images/networking/gpg.png
new file mode 100644 (file)
index 0000000..97a6498
Binary files /dev/null and b/htdocs/images/networking/gpg.png differ
index 066eac6..5aa0f4b 100644 (file)
@@ -112,12 +112,14 @@ class ProfileNetworking implements ProfileSetting
     private $email;
     private $pub;
     private $web;
+    private $number;
 
     public function __construct()
     {
         $this->email  = new ProfileEmail();
         $this->pub    = new ProfilePub();
         $this->web    = new ProfileWeb();
+        $this->number = new ProfileNumber();
     }
 
     public function value(ProfilePage &$page, $field, $value, &$success)
@@ -154,6 +156,8 @@ class ProfileNetworking implements ProfileSetting
                 $network['address'] = $this->web->value($page, 'address', $network['address'], $s);
             } elseif ($filters[$network['type']] == 'email') {
                 $network['address'] = $this->email->value($page, 'address', $network['address'], $s);
+            } elseif ($filters[$network['type']] == 'number') {
+                $network['address'] = $this->number->value($page, 'address', $network['address'], $s);
             }
             if (!$s) {
                 $success = false;
index 139178e..4b4df1d 100644 (file)
@@ -79,6 +79,23 @@ class ProfileEmail extends ProfileNoSave
     }
 }
 
+class ProfileNumber extends ProfileNoSave
+{
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        if (is_null($value)) {
+            return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
+        }
+        $value = trim($value);
+        $success = empty($value) || is_numeric($value);
+        if (!$success) {
+            global $page;
+            $page->trigError('Numéro invalide');
+        }
+        return $value;
+    }
+}
+
 
 class ProfileTel extends ProfileNoSave
 {
index 0da8e66..a266038 100644 (file)
@@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `profile_networking_enum` (
     `network_type` tinyint unsigned NOT NULL,
     `name` varchar(30) NOT NULL,
     `icon` varchar(50) NOT NULL COMMENT 'icon filename',
-    `filter` enum('email','web','none') NOT NULL DEFAULT 'none' COMMENT 'filter type for addresses',
+    `filter` enum('email','web','number','none') NOT NULL DEFAULT 'none' COMMENT 'filter type for addresses',
     PRIMARY KEY (`network_type`)
 ) CHARSET=utf8 COMMENT='types of networking addresses';