示例#1
0
 private function validate()
 {
     $this->validateDimension();
     if (false === ($this->user1 = GWF_User::getByName(Common::getRequest('user1', '')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     if (false === ($this->user2 = GWF_User::getByName(Common::getRequest('user2', '')))) {
         //			return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     // Check end date
     $this->end = sprintf('%04d%02d%02d', intval(Common::getGet('y', 0), 10), intval(Common::getGet('m', 0), 10), intval(Common::getGet('d', 0), 10));
     if (!GWF_Time::isValidDate($this->end, false, GWF_Date::LEN_DAY)) {
         return $this->module->error('err_end_date');
     }
     // Check start date
     $regdate1 = $this->user1->getVar('user_regdate');
     $regdate2 = $this->user2 === false ? $regdate1 : $this->user2->getVar('user_regdate');
     $this->start = $regdate1 < $regdate2 ? $regdate1 : $regdate2;
     $this->start = substr($this->start, 0, GWF_Date::LEN_DAY);
     if (0 < ($nm = intval(Common::getGet('nm', 0)))) {
         $time = GWF_Time::getTimestamp($this->end);
         $time -= $nm * GWF_Time::ONE_MONTH;
         $time = GWF_Time::getDate(GWF_Date::LEN_DAY, $time);
         if ($time > $this->start) {
             $this->start = $time;
         }
     }
     //		var_dump($this->start);
     // Check sites
     $sites = Common::getGetString('sites');
     if ($sites === 'all') {
         if ($this->user2 === false) {
             $this->sites = WC_Site::getLinkedSites($this->user1->getID());
         } else {
             $this->sites = WC_Site::getLinkedSitesVS2($this->user1->getID(), $this->user2->getID());
         }
         $temp = array();
         foreach ($this->sites as $site) {
             $temp[$site->getID()] = $site;
         }
         $this->sites = $temp;
     } else {
         $this->sites = array();
         $sites = explode(',', $sites);
         foreach ($sites as $siteid) {
             //				var_dump($siteid);
             $siteid = intval(trim($siteid));
             if (false !== ($site = WC_Site::getByID($siteid))) {
                 $this->sites[$siteid] = $site;
             }
         }
     }
     //		if (count($this->sites) === 0) {
     //			return $this->module->error('err_no_sites');
     //		}
     // Options
     $opts = explode(',', Common::getGet('opt', ''));
     foreach ($opts as $opt) {
         $opt = trim($opt);
         if ($opt === 'icons') {
             $this->withIcons = true;
         } elseif ($opt === 'nums') {
             $this->withNumbers = true;
         } elseif ($opt === 'zoom') {
             $this->withZoom = true;
         }
     }
     // All ok
     return false;
 }