Merge branch 'xorg/maint' into xorg/master
[platal.git] / classes / userfilter / conditions.inc.php
index c689f0b..cb99cfb 100644 (file)
@@ -663,8 +663,9 @@ class UFC_NameTokens extends UserFilterCondition
     private $flags;
     private $soundex;
     private $exact;
+    private $general_type;
 
-    public function __construct($tokens, $flags = array(), $soundex = false, $exact = false)
+    public function __construct($tokens, $flags = array(), $soundex = false, $exact = false, $general_type = '')
     {
         if (is_array($tokens)) {
             $this->tokens = $tokens;
@@ -678,6 +679,7 @@ class UFC_NameTokens extends UserFilterCondition
         }
         $this->soundex = $soundex;
         $this->exact = $exact;
+        $this->general_type = $general_type;
     }
 
     public function buildCondition(PlFilter $uf)
@@ -695,6 +697,9 @@ class UFC_NameTokens extends UserFilterCondition
             if ($this->flags != null) {
                 $c .= XDB::format(' AND ' . $sub . '.flags IN {?}', $this->flags);
             }
+            if ($this->general_type) {
+                $c .= XDB::format(' AND ' . $sub . '.general_type = {?}', $this->general_type);
+            }
             $conds[] = $c;
         }
 
@@ -907,6 +912,30 @@ class UFC_Group extends UserFilterCondition
     }
 }
 // }}}
+// {{{ class UFC_GroupFormerMember
+/** Filters users based on group former membership
+ * @param $group Group whose former members we are selecting
+ */
+class UFC_GroupFormerMember extends UserFilterCondition
+{
+    private $group;
+
+    public function __construct($group)
+    {
+        $this->group = $group;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        // Groups are only visible for users with perm 'groups'.
+        if (!S::user()->checkPerms(User::PERM_GROUPS)) {
+            return self::COND_FALSE;
+        }
+        $sub = $uf->addGroupFormerMemberFilter();
+        return XDB::format('gpfm' . $sub . '.asso_id = {?}', $this->group);
+    }
+}
+// }}}
 // {{{ class UFC_Binet
 /** Selects users based on their belonging to a given (list of) binet
  * @param $binet either a binet_id or an array of binet_ids
@@ -988,7 +1017,7 @@ class UFC_Email extends UserFilterCondition
 
         if (count($foreign) > 0) {
             $sub = $uf->addEmailRedirectFilter($foreign);
-            $cond[] = XDB::format('ra' . $sub . '.redirect IS NOT NULL OR ra' . $sub . '.redirect IN {?}', $foreign);
+            $cond[] = XDB::format('ra' . $sub . '.redirect IS NOT NULL OR ra' . $sub . '.redirect IN {?} OR a.email IN {?}', $foreign, $foreign);
         }
         if (count($local) > 0) {
             $sub = $uf->addAliasFilter($local);
@@ -1428,7 +1457,7 @@ class UFC_Phone extends UserFilterCondition
     {
         $phone = new Phone(array('display' => $number));
         $phone->format();
-        $this->number = $phone->search();
+        $this->number = $phone->search;
         $this->num_type = $num_type;
         $this->phone_type = $phone_type;
     }
@@ -1579,6 +1608,36 @@ abstract class UFC_UserRelated extends UserFilterCondition
     }
 }
 // }}}
+// {{{ class UFC_DeltaTen
+class UFC_DeltaTen extends UserFilterCondition
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addDeltaTenFilter(UserFilter::DELTATEN);
+        return $sub . '.message IS NOT NULL';
+    }
+}
+// }}}
+// {{{ class UFC_DeltaTen_Message
+/** Filters users by deltaten message
+ * @param $message Message for the DeltaTen program
+ */
+class UFC_DeltaTen_Message extends UserFilterCondition
+{
+    private $message;
+
+    public function __construct($message)
+    {
+        $this->message = $message;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addDeltaTenFilter(UserFilter::DELTATEN_MESSAGE);
+        return $sub . '.message ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->message);
+    }
+}
+// }}}
 // {{{ class UFC_Contact
 /** Filters users who belong to selected user's contacts
  */