Beispiel #1
0
 /**
  * @todo create countUnread()
  * @param GWF_User $user
  * @param string $pattern
  * @param string $default
  * @return String
  */
 public static function getUnreadPM(GWF_User $user, $pattern = '[%s]', $default = '[0]')
 {
     if (false === self::loadModuleClass('PM', 'GWF_PM.php')) {
         return '';
     }
     if (false === $user->isGuest()) {
         $read = GWF_PM::READ;
         $userid = $user->getID();
         $count = GDO::table('GWF_PM')->countRows("pm_owner={$userid} AND pm_to={$userid} AND pm_options&{$read}=0");
         if ((int) $count > 0) {
             return sprintf($pattern, $count);
         }
     }
     return '';
 }
Beispiel #2
0
 public function validate_limits(GWF_User $from, GWF_User $to)
 {
     $options = GWF_PMOptions::getPMOptions($to);
     if ($from->isGuest() && !$options->isOptionEnabled(GWF_PMOptions::ALLOW_GUEST_PM)) {
         return $this->error('err_user_no_ppm');
     }
     if ($from->isAdmin() || $from->isStaff()) {
         return false;
     }
     if (!$this->cfgIsPMLimited()) {
         return false;
     }
     if ($from->getLevel() <= $options->getVar('pmo_level')) {
         return $this->error('err_user_pmo_level', array($options->getVar('pmo_level')));
     }
     $user = GWF_Session::getUser();
     $uid = GWF_Session::getUserID();
     $within = $this->cfgLimitTimeout();
     $cut = GWF_Time::getDate(GWF_Date::LEN_SECOND, time() - $within);
     $count = GDO::table('GWF_PM')->countRows("pm_from={$uid} AND pm_date>'{$cut}'");
     $max = $this->calcPMLimit($user);
     if ($count >= $max) {
         return $this->lang('err_limit', array($max, GWF_Time::humanDuration($within)));
     }
     return false;
 }