function add($url) { $beforeValue = null; $ct = CopixDbFactory::getConnection(); $rq = $ct->doQuery('Select ' . $this->fields['COUNT'] . ' from ' . $this->tableName . ' where ' . $this->fields['URL'] . '=' . $ct->formatText($url)); if ($o = $rq->fetchObject()) { $beforeValue = $o->{$this->fields['COUNT']}; } if ($beforeValue !== null) { $beforeValue++; $ct->doUpdate($this->tableName, array($this->fields['COUNT'] => $beforeValue), array($this->fields['URL'] => $ct->formatText($url))); } else { $beforeValue = 0; $ct->doInsert($this->tableName, array($this->fields['COUNT'] => $beforeValue, $this->fields['URL'] => $ct->formatText($url))); } }
/** * Store data * * @access private */ function storeData($entityName) { $_entityName = $entityName; $_httpRequest =& HttpRequest::instance(); $_session =& HttpSession::instance(); $_tagged = $_session->getAttribute('TAGGED'); $_index = $_session->getAttribute('INDEX'); $_create = $_index < 0; $_next = false; if ($_httpRequest->getAttribute('accept')) { $_httpRequest->removeAttribute('accept'); $_new = $_httpRequest->getAttribute('ENTITY'); foreach ($_session->getAttribute('ENTITY') as $_key => $_value) { $_old[$_key] = $_value; } $_equal = true; foreach ($_new as $_key => $_value) { if ($_value !== $_old[$_key]) { $_updated[$_key] = $_value; $_equal = false; } else { $_updated[$_key] = $_old[$_key]; } } if (!$_equal) { $_dao =& CopixDAOFactory::create($_entityName); if ($_create) { $_entity =& CopixDAOFactory::createRecord($_entityName); foreach ($_updated as $_key => $_value) { $_entity->{$_key} = $_value; } $_dao->insert($_entity); $_connection =& CopixDbFactory::getConnection(); $_tagged[] = $_connection->lastId(); } else { // update $_dlname = 'get' . $_entityName . 'DataList'; $_dataList = $this->{$_dlname}(); $_idLabel = $_dataList['id']['var']; $_entity = $_dao->get($_updated[$_idLabel]); foreach ($_updated as $_key => $_value) { $_entity->{$_key} = $_value; } $_dao->update($_entity); } } ++$_index; // next one ? $_next = $_create || $_index < sizeOf($_tagged); } elseif ($_httpRequest->getAttribute('cancel')) { $_httpRequest->removeAttribute('cancel'); ++$_index; // next one ? $_next = !$_create && $_index < sizeOf($_tagged); } else { // always return to the list } if ($_next) { $_session->setAttribute('INDEX', $_index); $_httpRequest->removeAttribute('ENTITY'); $_forward = $_create ? 'create' : 'update'; $_httpRequest->setAttribute($_forward, $_forward); // $_httpRequest->setAttribute('TAGGED', $_tagged); // TODO: la méthode CopixUrl::getUrl ne gère pas correctement les tableaux, d'où : foreach ($_tagged as $_key => $_Id) { $_httpRequest->setAttribute('TAGGED[' . $_key . ']', $_Id); } $_requestUrl = new ProjectUrl('manage' . $_entityName . 'Data', null, 'workflow', $_httpRequest->toArray()); } else { $_requestUrl = new ProjectUrl('show' . $_entityName . 'List', null, 'workflow'); } return new CopixActionReturn(COPIX_AR_REDIRECT, $_requestUrl->getUrl(false)); }
/** * récupération de la requete avec les logins / password. * @param string $request requête SQL avec les tags login/password à remplacer * @return string requête finale */ function _getParsedRequestLoginPassword($request, $login, $password) { $ct = CopixDbFactory::getConnection(); $request = str_replace('[--LOGIN--]', $ct->quote($login), $request); return str_replace('[--PASSWORD--]', $ct->quote($this->cryptPassword($password)), $request); }
/** * Check if the login and password match * @param string $login the login * @param string $password the password (clear) */ function checkPassword($login, $password) { $ct = CopixDBFactory::getConnection(); $dbw = CopixDbFactory::getDbWidget(); $query = 'select ' . $this->passwordfield . ' from ' . $this->userTable . ' where ' . $this->loginField . '=' . $ct->quote($login); if ($r = $dbw->fetchFirst($request)) { return $r->{$this->passwordField} == $this->cryptPassword($password); } return false; }
function delete($path) { $ct = CopixDbFactory::getConnection(); $ct->doQuery('delete from copixcapacities where ID_CCAP like ' . $ct->quote($path . '%', false)); }