Beispiel #1
0
 public function insert()
 {
     $this->set('created', Gpf_DbEngine_Database::getDateString());
     $this->set('downloads', 0);
     $this->set('referenced', 0);
     return parent::insert();
 }
 public static function expireOldRequest()
 {
     $sql = new Gpf_SqlBuilder_UpdateBuilder();
     $sql->set->add(self::STATUS, self::STATUS_EXPIRED);
     $sql->from->add(self::getName());
     $sql->where->add(self::STATUS, '=', self::STATUS_PENDING);
     $sql->where->add(self::CREATED, '<', Gpf_DbEngine_Database::getDateString(time() - self::VALID_SECONDS));
     $sql->execute();
 }
	protected function initDate(Pap_Stats_Params $statsParams, $timeOffset) {
		$clientTime = $this->createCurrentTime() + $timeOffset;
		$lastStartDay = $this->getLastStartDay($clientTime);

		$this->dateFrom = Gpf_DbEngine_Database::getDateString(
		mktime(0,0,0,date("m",$clientTime), date("d",$clientTime) - $lastStartDay, date("Y",$clientTime)) - $timeOffset);

		$this->dateTo = Gpf_DbEngine_Database::getDateString(
		mktime(23,59,59,date("m",$clientTime), date("d",$clientTime) - $lastStartDay + 6, date("Y",$clientTime)) - $timeOffset);

		$statsParams->setDateRange($this->dateFrom, $this->dateTo);
	}
 public function saveLanguageMetadata(Gpf_Db_Language $lang)
 {
     $lang->setName($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_NAME));
     $lang->setEnglishName($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_ENG_NAME));
     $lang->setActive(true);
     $lang->setAuthor($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_AUTHOR));
     $lang->setVersion($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_VERSION));
     $lang->setImported(Gpf_DbEngine_Database::getDateString());
     $lang->setDateFormat($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_DATE_FORMAT));
     $lang->setTimeFormat($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_TIME_FORMAT));
     $lang->setThousandsSeparator($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_THOUSANDS_SEPARATOR));
     $lang->setDecimalSeparator($this->language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_DECIMAL_SEPARATOR));
     $lang->setTranslatedPercentage($this->language->getTranslationPercentage());
     $lang->setIsDefault(false);
     $lang->save();
 }
    /**
     *
     * @service click delete
     * @param ids, status
     * @return Gpf_Rpc_Action
     */
    public function deleteClicks(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        
        $date = array();
    	switch ($action->getParam("status")) {
    		case self::DATE_ONE_WEEK:
    			$filter = new Gpf_SqlBuilder_Filter(array("", "DP", "L7D"));
    	        $date = $filter->addDateValueToArray($date);
    	        $olderThan = "one week";
    			break;
    		case self::DATE_TWO_WEEKS:
    			$dateFrom = Gpf_DbEngine_Database::getDateString(
    			     Gpf_Common_DateUtils::getServerTime(
    			         mktime(0,0,0,date("m"), date("d") - 14, date("Y"))));
                $date = array("dateFrom" => $dateFrom);
                $olderThan = "two weeks";
    			break;
    		case self::DATE_ONE_MONTH:
    			$filter = new Gpf_SqlBuilder_Filter(array("", "DP", "L30D"));
                $date = $filter->addDateValueToArray($date);
                $olderThan = "one month";
    			break;
    	}
    	
    	$action->setInfoMessage($this->_("Raw clicks older than %s are deleted", $olderThan));
        $action->setErrorMessage($this->_("Failed to delete raw clicks"));
        
        $delete = new Gpf_SqlBuilder_DeleteBuilder();
        $delete->from->add(Pap_Db_Table_RawClicks::getName());
        $delete->where->add(Pap_Db_Table_RawClicks::DATETIME, "<", $date["dateFrom"]);
        

        try {
            $delete->delete();
            $action->addOk();
        } catch(Gpf_DbEngine_NoRowException $e) {
            $action->addError();
        }

        return $action;
    }
Beispiel #6
0
 private function addSessionInfoToCache()
 {
     $sessionInfo = new Gpf_Rpc_Data();
     $sessionInfo->setValue(Gpf_Rpc_Params::SESSION_ID, Gpf_Session::getInstance()->getId());
     $sessionInfo->setValue('loggedUser', Gpf_Session::getAuthUser()->getFirstName() . ' ' . Gpf_Session::getAuthUser()->getLastName());
     $sessionInfo->setValue('loggedUserEmail', Gpf_Session::getAuthUser()->getUsername());
     $sessionInfo->setValue('serverTime', Gpf_DbEngine_Database::getDateString());
     $sessionInfo->setValue('baseUrl', rtrim(Gpf_Paths::getInstance()->getBaseServerUrl(), '/'));
     $this->setSessionInfo($sessionInfo);
     Gpf_Rpc_CachedResponse::addById($sessionInfo, self::SESSION);
 }
Beispiel #7
0
 public function insert()
 {
     $this->set('created', Gpf_DbEngine_Database::getDateString());
     parent::insert();
 }
 function insert()
 {
     $this->set(Gpf_Db_Table_PasswordRequests::CREATED, Gpf_DbEngine_Database::getDateString());
     $this->setStatus(Gpf_Db_Table_PasswordRequests::STATUS_PENDING);
     parent::insert();
 }
Beispiel #9
0
 public function insert()
 {
     $this->set('imported', Gpf_DbEngine_Database::getDateString());
     $this->setId($this->generateId());
     $this->checkIsDefaultStatus();
     return parent::insert();
 }
 protected function setTimeVariableValues($timeOffset = 0)
 {
     parent::setTimeVariableValues($timeOffset);
     $this->setVariable('validUntil', Gpf_DbEngine_Database::getDateString(time() + Gpf_Db_Table_PasswordRequests::VALID_SECONDS + $timeOffset));
 }
Beispiel #11
0
 protected function getWeek($year, $month, $day, $dayFrom, $dayTo)
 {
     $w = date('w', mktime(0, 0, 0, $month, $day, $year));
     $dateRange['from'] = Gpf_DbEngine_Database::getDateString($this->getServerTime(mktime(0, 0, 0, $month, $day - $w + $dayFrom, $year)));
     $dateRange['to'] = Gpf_DbEngine_Database::getDateString($this->getServerTime(mktime(23, 59, 59, $month, $day - $w + $dayTo, $year)));
     return $dateRange;
 }