コード例 #1
0
 /**
  * Get the users who've registered with this ip address.
  *
  * @param Array $ipaddress IP address to check for
  *
  * @return Array IDs of users who registered with this address.
  */
 static function usersByIP($ipaddress)
 {
     $ids = array();
     $ri = new Registration_ip();
     $ri->ipaddress = $ipaddress;
     if ($ri->find()) {
         while ($ri->fetch()) {
             $ids[] = $ri->user_id;
         }
     }
     return $ids;
 }
コード例 #2
0
 /**
  * When silencing a user, silence all other users registered from that IP
  * address.
  *
  * @param Profile $profile Person getting a new role
  * @param string  $role    Role being assigned like 'moderator' or 'silenced'
  *
  * @return boolean hook value
  */
 function onEndGrantRole($profile, $role)
 {
     if (!self::$enabled) {
         return true;
     }
     if ($role != Profile_role::SILENCED) {
         return true;
     }
     if (!$this->silenced) {
         return true;
     }
     $ri = Registration_ip::staticGet('user_id', $profile->id);
     if (empty($ri)) {
         return true;
     }
     $ids = Registration_ip::usersByIP($ri->ipaddress);
     foreach ($ids as $id) {
         if ($id == $profile->id) {
             continue;
         }
         $other = Profile::staticGet('id', $id);
         if (empty($other)) {
             continue;
         }
         if ($other->isSilenced()) {
             continue;
         }
         $old = self::$enabled;
         self::$enabled = false;
         $other->silence();
         self::$enabled = $old;
     }
 }
コード例 #3
0
 /**
  * Gets the Nth registration with the given IP address.
  *
  * @param string  $ipaddress Address to key on
  * @param integer $n         Nth address
  *
  * @return Registration_ip nth registration or null if not found.
  */
 private function _getNthReg($ipaddress, $n)
 {
     $reg = new Registration_ip();
     $reg->ipaddress = $ipaddress;
     $reg->orderBy('created DESC');
     $reg->limit($n - 1, 1);
     if ($reg->find(true)) {
         return $reg;
     } else {
         return null;
     }
 }