/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { $template = new Gpf_Templates_Template($row->get($this->columnName), '', Gpf_Templates_Template::FETCH_TEXT); if (!$template->isValid()) { $this->throwException(); } }
public function execute(Gpf_DbEngine_Row $dbRow) { if (!$this->isLastUserWithAuthID($dbRow->get(Gpf_Db_Table_Users::AUTHID))) { return; } parent::execute($dbRow); }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { if ($row->get(Pap_Db_Table_Users::TYPE) != Pap_Application::ROLETYPE_AFFILIATE) { return; } return parent::validate($row); }
protected function validateRefid(Gpf_DbEngine_Row $row) { if ($row->get(Pap_Db_Table_Users::TYPE) == Pap_Application::ROLETYPE_AFFILIATE && !$this->codeValidator->validate($row->get(Pap_Db_Table_Users::REFID))) { throw new Gpf_DbEngine_Row_ConstraintException(Pap_Db_Table_Users::REFID, $this->_('Refid must be in format "%s". Format definition: {9} - will be replaced by any character in range [0-9], {z} - will be replaced by any character in range [a-z], {Z} - will be replaced by any character in range [A-Z], {X} - will be replaced by any character in range [0-9a-zA-Z], all other characters will be unchanged. Example of good format is e.g. {ZZZ}-{XXXXX}-{999}', Gpf_Settings::get(CustomRefid_Config::CUSTOM_REFID_FORMAT))); } }
/** * @throws Gpf_Exception */ protected function doOneRowLoaded(Gpf_DbEngine_Row $row, $tempRow) { $primaryColumns = $row->getPrimaryColumns(); foreach ($primaryColumns as $column) { if ($tempRow->get($column->getName()) != $row->get($column->getName())) { $this->throwException(); } } }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { $value = $row->get($this->columnName); if ($value === null || $value == '') { return; } if (!is_numeric($value)) { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->_("Column %s must be number (%s given)", $this->columnName, $value)); } }
public function execute(Gpf_DbEngine_Row $dbRow) { $updateBuilder = new Gpf_SqlBuilder_UpdateBuilder(); $updateBuilder->from->add($this->foreignDbRow->getTable()->name()); for ($i = 0; $i < count($this->selfColumns); $i++) { $updateBuilder->set->add($this->foreignColumns[$i], 'NULL', false); $updateBuilder->where->add($this->foreignColumns[$i], "=", $dbRow->get($this->selfColumns[$i])); } $updateBuilder->execute(); }
public function execute(Gpf_DbEngine_Row $dbRow) { for ($i = 0; $i < count($this->selfColumns); $i++) { $this->foreignDbRow->set($this->foreignColumns[$i], $dbRow->get($this->selfColumns[$i])); } $rowCollection = $this->foreignDbRow->loadCollection($this->foreignColumns); if ($rowCollection->getSize() > 0) { throw new Gpf_DbEngine_RestrictDeleteException($dbRow); } }
private function isAddingExactlyOneRow(Gpf_DbEngine_Row $row) { foreach ($this->uniqueColumnNames as $columnName => $value) { if ($value === false) { continue; } if ($row->get($columnName) != $value) { return false; } } return true; }
protected function loadRow(Gpf_DbEngine_Row $row) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->from->add($row->getTable()->name()); $selectBuilder->select->addAll($row->getTable()); foreach ($this->uniqueColumnNames as $columnName=>$value) { if ($value === false) { $selectBuilder->where->add($columnName,'=',$row->get($columnName)); continue; } $selectBuilder->where->add($columnName,'=',$value); } return $selectBuilder->getOneRow(); }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { $value = $row->get($this->columnName); if ($value == null || $value == "") { return; } if (preg_match($this->regExp, $value) != 1) { if ($this->message == "") { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->_("Column %s contains unallowed characters", $this->columnName)); } throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, Gpf_Lang::_replaceArgs($this->message, $value)); } }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { foreach ($this->columnMapping as $column => $parentColumn) { $this->parentRow->set($parentColumn, $row->get($column)); } if ($this->parentRow->isPrimaryKeyEmpty() && !$this->mandatoryParent) { return; } try { $this->parentRow->load(); } catch (Gpf_Exception $e) { //TODO: create new Exception class throw new Gpf_DbEngine_Row_ConstraintException('', $this->message); } }
public function delete() { $this->load(); if (!strlen($this->getAccountId())) { throw new Gpf_Exception($this->_('Default role can not be deleted!')); } return parent::delete(); }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('COUNT(*)', 'cnt'); $select->from->add($row->getTable()->name()); foreach ($row->getPrimaryColumns() as $primaryColumn) { $select->where->add($primaryColumn->getName(), '<>', $row->get($primaryColumn->getName())); } $conditionNotEqalColumns = new Gpf_SqlBuilder_CompoundWhereCondition(); foreach ($this->columnsNotEqualNames as $columnNotEqualName) { $conditionNotEqalColumns->add($columnNotEqualName, '=', $row->get($this->columnName), 'OR'); } $select->where->addCondition($conditionNotEqalColumns); $select->limit->set(0, 1); if ($select->getOneRow()->get('cnt') > 0) { $this->throwException(); } }
public function execute(Gpf_DbEngine_Row $dbRow) { if (count($this->foreignDbRow->getTable()->getDeleteConstraints()) == 0) { $deleteBuilder = new Gpf_SqlBuilder_DeleteBuilder(); $deleteBuilder->from->add($this->foreignDbRow->getTable()->name()); for ($i = 0; $i < count($this->selfColumns); $i++) { $deleteBuilder->where->add($this->foreignColumns[$i], "=", $dbRow->get($this->selfColumns[$i])); } $deleteBuilder->execute(); return; } for ($i = 0; $i < count($this->selfColumns); $i++) { $this->foreignDbRow->set($this->foreignColumns[$i], $dbRow->get($this->selfColumns[$i])); } $rowCollection = $this->foreignDbRow->loadCollection($this->foreignColumns); foreach ($rowCollection as $row) { $row->delete(); } }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { if ($this->minLength == 0 && $this->maxLength == 0) { return; } if ($this->minLength > 0 && strlen($row->get($this->columnName)) < $this->minLength) { if ($this->minMessage == '') { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->_('Minimum length of %s in %s is %s', $this->columnName, get_class($row), $this->minLength - 1)); } else { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, Gpf_Lang::_replaceArgs($this->minMessage, $this->minLength - 1)); } } if ($this->maxLength > 0 && strlen($row->get($this->columnName)) > $this->maxLength) { if ($this->maxMessage == '') { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->_('Maximum length of %s in %s is %s', $this->columnName, get_class($row), $this->maxLength)); } else { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, Gpf_Lang::_replaceArgs($this->maxMessage, $this->maxLength)); } } }
public function insert() { $this->set('wordlength', strlen($this->get('wordtext'))); $qgrams = Gpf_Search_SearchEngine::getQGramPairsArray($this->get('wordtext')); foreach ($qgrams as $id => $qgram) { if ($id < Gpf_Search_SearchEngine::QGRAM_COUNT) { $this->set('w' . ($id + 1), $qgram); } } parent::insert(); }
public function delete($filterId) { $this->set('filterid', $filterId); $this->load(); if ($this->getPreset() == Gpf::YES) { throw new Gpf_Exception("You cannot delete preset filter!"); } $conditionsTable = Gpf_Db_Table_FilterConditions::getInstance(); $conditionsTable->deleteAll($filterId); return parent::delete(); }
public function insert() { if (!$this->get('scheduled_at')) { $this->set('scheduled_at', $this->createDatabase()->getDateString()); } if (!$this->get('status')) { $this->set('status', Gpf_Db_Table_MailOutbox::STATUS_PENDING); } $this->set('retry_nr', 0); $this->set('error_msg', ''); parent::insert(); }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { $role = new Gpf_Db_Role(); $role->setId($row->getRoleId()); $role->load(); $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('r.' . Gpf_Db_Table_Roles::TYPE); $select->from->add(Gpf_Db_Table_Users::getName(), 'u'); $select->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), 'r', 'u.' . Gpf_Db_Table_Users::ROLEID . '=r.' . Gpf_Db_Table_Roles::ID); $select->where->add('u.' . Gpf_Db_Table_Users::AUTHID, '=', $row->getAuthId()); $select->where->add('u.' . Gpf_Db_Table_Users::ACCOUNTID, '=', $row->getAccountId()); $select->where->add('r.' . Gpf_Db_Table_Roles::TYPE, '=', $role->getRoleType()); $select->where->add('u.' . Gpf_Db_Table_Users::ID, '<>', $row->getPrimaryKeyValue()); try { $select->getOneRow(); } catch (Gpf_DbEngine_NoRowException $e) { return; } catch (Gpf_DbEngine_TooManyRowsException $e) { } throw new Gpf_DbEngine_Row_ConstraintException('username', $this->_('Selected username already exists')); }
protected function init() { $this->setAccountId(Gpf_Db_Account::DEFAULT_ACCOUNT_ID); $this->setBannerId(''); $this->setCampaignId(''); $this->setUserId(''); $this->setParentBannerId(''); $this->setCountryCode(''); $this->setChannel(''); $this->setData1(''); $this->setData2(''); parent::init(); }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { if (Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_MIN_LENGTH) > Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_MAX_LENGTH)) { return; } if (strlen($row->get($this->passwordField)) < Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_MIN_LENGTH)) { throw new Gpf_DbEngine_Row_PasswordConstraintException($this->passwordField, $this->_('Minimum length of password is %s characters', Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_MIN_LENGTH))); } if (strlen($row->get($this->passwordField)) > Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_MAX_LENGTH)) { throw new Gpf_DbEngine_Row_PasswordConstraintException($this->passwordField, $this->_('Maximum length of password is %s characters', Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_MAX_LENGTH))); } if (Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_LETTERS) == Gpf::YES) { if (preg_match('/[a-zA-Z]/', $row->get($this->passwordField)) == 0) { throw new Gpf_DbEngine_Row_PasswordConstraintException($this->passwordField, $this->_('Password has to contain at least one letter (a-z, A-Z)')); } } if (Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_DIGITS) == Gpf::YES) { if (preg_match('/[0-9]/', $row->get($this->passwordField)) == 0) { throw new Gpf_DbEngine_Row_PasswordConstraintException($this->passwordField, $this->_('Password has to contain at least one digit (0-9)')); } } if (Gpf_Settings::get(Gpf_Settings_Gpf::PASSWORD_SPECIAL) == Gpf::YES) { if (preg_match('/[' . preg_quote(Gpf_Common_String::SPECIAL_CHARS) . ']/', $row->get($this->passwordField)) == 0) { throw new Gpf_DbEngine_Row_PasswordConstraintException($this->passwordField, $this->_('Password has to contain at least one special character (%s)', Gpf_Common_String::SPECIAL_CHARS)); } } }
/** * Deletes row. Primary key value must be set before this function is called */ public function delete() { if ($this->isPrimaryKeyEmpty()) { throw new Gpf_Exception("Could not delete Row. Primary key values are empty"); } $this->load(); if ($this->getFileId() != "") { try { $file = new Gpf_Db_File(); $file->setFileId($this->getFileId()); $file->removeReference(); } catch (Gpf_DbEngine_Driver_Mysql_SqlException $e) { } } return parent::delete(); }
protected function beforeSaveCheck() { parent::beforeSaveCheck(); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.CommissionType.beforeSaveCheck', $this); }
function init() { $this->setTable(Pap_Db_Table_BannersCategories::getInstance()); parent::init(); }
function init() { $this->setTable(Gpf_Db_Table_FileContents::getInstance()); parent::init(); }
/** * @param Gpf_DbEngine_Row $dbRow */ protected function setDefaultDbRowObjectValues(Gpf_DbEngine_Row $dbRow) { $dbRow->set('isdefault', '0'); }
public function init() { $this->setTable(Gpf_Db_Table_RecurrencePresets::getInstance()); parent::init(); }
public function init() { $this->setTable(Pap_Db_Table_UserInCommissionGroup::getInstance()); parent::init(); }
protected function init() { $this->setTable(Pap_Db_Table_VisitorAffiliates::getInstance()); parent::init(); }