public function execute(){ $request = $this->getContext()->getRequest(); $id = $request->getParameter('id'); $this->checkMemberAuth($id); $memberDao = new BaseDao('Member'); $nocDao = new BaseDao("NatureOfChange"); $nocId = $request->getParameter("deletionReason"); if ($nocId) { $memberToDelete = $memberDao->get($id); $memberToDelete->nocFid = $nocId; $member = $memberDao->getPattern(); $member = clone($memberToDelete); $member->deleted = 1; $memberDao->save($member); $this->log("Deleting member: ".$memberToDelete->firstname.", ".$memberToDelete->lastname."."); $this->log("Deleting member: ".$memberToDelete->firstname.", ".$memberToDelete->lastname.".", true); } else{ $request->setAttribute('nocList', $nocDao->search()); return "Form"; } }
public function execute() { $this->checkAdminAuth(); $loginDao = new BaseDao("Login"); $affilateDao = new BaseDao("Affiliate"); $affList = $affilateDao->search(); $loginRecordsToInsert = array(); foreach($affList as $affiliate){ $login = $loginDao->getPattern(); $login->name = $affiliate->abbreviation." admin"; $login->password = "******"; $login->login = $affiliate->abbreviation; $login->roleFid = 2; $login->email = "editme".$affiliate->abbreviation."@acbdb.org"; $id = $login->insert(); $affiliate->editor = $id; $affiliate->update(); } return View::NONE; }
public function execute() { $identity = $this->getContext()->getRequest()->getParameter("id"); $this->checkMemberAuth($identity); $dao = new BaseDao("Member"); $member = $dao->get($identity); $member->dig(); $request = $this->getContext()->getRequest(); $request->setAttribute('member', $member); return View::SUCCESS; }
public function destroy() { $atomDao = new BaseDao("CertifierTransactionAtom"); $atom = $atomDao->getPattern(); $atom->transFid = $this->getId(); $list = $atomDao->search($atom); //var_dump($list); foreach ($list as $element) { $element->delete(); } parent::destroy(); }
public function execute() { $identity = $this->getContext()->getRequest()->getParameter("id"); $this->checkAffiliateAuth($identity); $dao = new BaseDao("Affiliate"); $affiliate = $dao->get($identity); $affiliate->getLinks(); $this->log("Vieving affiliate info. Id: {$identity}; name: " . $affiliate->name); $request = $this->getContext()->getRequest(); $request->setAttribute('affiliate', $affiliate); if ($request->getAttribute('render') == 'form') { return 'EditForm'; } else { return 'ReadOnly'; } }
public function __construct() { parent::__construct(); $this->tableName = "module"; $this->table = $this->db->getTDG($this->tableName); $this->primaryKey = "id"; $this->db->init(); }
public function execute() { $this->checkAdminAuth(); $this->log("Viewing list of logins.", true); $request = $this->getContext()->getRequest(); $affDao = new BaseDao("Affiliate"); $affEx = $affDao->getPattern(); $loginDao = new BaseDao("Login"); $loginEx = $loginDao->getPattern(); $loginEx->selectAdd(); $loginEx->selectAdd("logins.*, a.abbreviation as abbr"); $loginEx->joinAdd($affEx, "LEFT", 'a'); $loginEx->find(); $loginsList = array(); while($loginEx->fetch()){ $login = $loginEx->login; if (!array_key_exists($login, $loginsList)){ $loginsList[$login] = clone($loginEx); } $loginsList[$login]->affiliates[] = $loginEx->abbr; } // $loginsList = $loginDao->search(); $request->setAttribute("loginsList", $loginsList); // print_r($loginsList); die(); return 'List'; }
public static function resume($id, $daoName = "Transaction") { $dao = new BaseDao($daoName); $ex = $dao->getPattern(); $ex->id = $id; $retvals = $dao->search($ex); if ($retvals) { $retval = $retvals[0]; $doDao = new BaseDao("DirtyObject"); $doPattern = $doDao->getPattern(); $doPattern->transactionFid = $retval->getId(); $doPattern->data = null; $res = $doDao->search($doPattern); foreach ($res as $obj) { $retval->queue[$obj->getId()] = $obj; } return $retval; } else { return false; } }
function getMembers($example = null, $certified = 'both', $orderBy = "firstname", $from = 0, $limit = 30000) { $pattern = 0; $dao = new BaseDao("Member"); if (!$example) { $pattern = $dao->getPattern(); } else { $pattern = clone $example; } $pattern->__table = " members, asc_members_affiliates "; if ($certified == 'both') { $pattern->whereAdd(" members.id = asc_members_affiliates.memberFid and asc_members_affiliates.affiliateFid = " . $this->id); } else { if ($certified) { $pattern->whereAdd(" members.id = asc_members_affiliates.memberFid and asc_members_affiliates.affiliateFid = " . $this->id . " and asc_members_affiliates.certified = 1"); } else { $pattern->whereAdd(" members.id = asc_members_affiliates.memberFid and asc_members_affiliates.affiliateFid = " . $this->id . " and asc_members_affiliates.certified = 0"); } } $pattern->orderBy($orderBy); $pattern->limit($from, $limit); return $dao->search($pattern); }
public function execute() { $request = $this->getContext()->getRequest(); $id = $request->getParameter('id'); $userRole = $this->checkAffiliateAuth($id); $dao = new BaseDao("Affiliate"); $affiliate = $dao->get($id); $members = $affiliate->getMembers(null, false); $request->setAttribute("members", $members); $request->setAttribute("affId", $id); $request->setAttribute("affiliate", $affiliate); if ($userRole == "editor"){ $this->log("Starting certification for affiliate id: $id; name: ".$affiliate->name); } else if ($userRole == 'admin'){ $this->log("Starting certification for affiliate id: $id; name: ".$affiliate->name, true); } return 'List'; }
protected function checkMemberAuth($id) { // $request = $this->getContext()->getRequest(); if (!$this->getContext()->getUser()->isAuthenticated()) { $this->getContext()->getController()->forward("Default", "Login"); die(); } else { $login = $this->getContext()->getUser()->getAttribute('Login'); if ($this->isAdmin($login)) { return 'admin'; } //if adding new if (!$id) return 'editor'; $memberDao = new BaseDao("Member"); $member = $memberDao->get($id); $member->dig(); $memberIds = $this->getListOfCertainFieldValues($member->affiliates, 'id'); $loginIds = $this->getListOfCertainFieldValues($login->affiliates, 'id'); //if member is a least in one of affiliates where logined user editor if (count(array_intersect($memberIds, $loginIds)) != 0) { return 'editor'; } else { $this->log("Unauthorized access attempt to member record. id: $id, name: " . $member->name, true); $this->getContext()->getRequest()->setParameter("message", "You are not authorized to access this member record because he isn't a member of your affiliate."); $this->getContext()->getController()->forward("Default", "Secure"); return View::NONE; } } }
public function execute() { $request = $this->getContext()->getRequest(); $username = $request->getParameter('login'); if (!$username) { return 'Form'; } else { $dao = new BaseDao("Login"); $users = $dao->searchByCriteria(new Criterion("login", CRI_FUNCTION_EQ, $username)); if ($users) { $login = $users[0]; $login->getOneRole(); $login->getAffiliates(); // print_r($login); die(); if ($login && $login->password == $request->getParameter('password')) { $this->log("User logged in. Login: {$username}."); $this->getContext()->getUser()->setAuthenticated(true); // NOTE: если поменяем тут пароль а потом случайно сохраним - то перепишем его в базе нашим волшебным активрекордом :) $login->password = ''; $this->getContext()->getUser()->setAttribute("Login", $login); $nextActionEntry = $this->getContext()->getController()->getActionStack()->getFirstEntry(); if ($nextActionEntry->getActionName() != 'Login') { $this->getContext()->getController()->forward($nextActionEntry->getModuleName(), $nextActionEntry->getActionName()); } else { return View::SUCCESS; } return View::NONE; } else { $this->log("Unsuccessfull loging attempt. Login: {$username}. Wrong password: "******"Unsuccessfull loging attempt. Wrong username: {$username}."); return 'Error'; } } }
public function __construct() { parent::__construct(); $this->tbl_name = 'jifen_log'; $this->pk = 'id'; }
public function __construct() { parent::__construct(); $this->tbl_name = 'goods_apply'; $this->pk = 'id'; }
public function __construct($db) { parent::__construct($db); }
<?php require_once 'dao/BaseDao.php'; require_once 'init/InitLog.inc.php'; require_once 'model/Tb_test.php'; echo "ffss"; $t = new BaseDao(); $t->ExecuteQuery("SELECT * FROM tb_test"); echo "ffssfff"; $m = new Tb_test(); $m->setId(123); $m->setName("helloworld"); echo "afadsfasdfas"; echo $m->toString();
private function buildBinaryCriteriaQuery($criteria) { $qStr1 = BaseDao::buildArbitraryCriteriaQuery($criteria->getValue1()); $qStr2 = BaseDao::buildArbitraryCriteriaQuery($criteria->getValue2()); switch ($criteria->getFunction()) { case CRI_LOGICAL_AND: $funcStr = "(" . $qStr1 . ") AND (" . $qStr2 . ")"; break; case CRI_LOGICAL_OR: $funcStr = "(" . $qStr1 . ") OR (" . $qStr2 . ")"; break; } return $funcStr; }
function byId($id) { return parent::byId($id, LookupDao::TABLE); }
private function parseMembers() { $memFile = fopen("./upload/members.txt", "r"); $zipDao = new BaseDao("model_Zip_codes"); $stateDao = new BaseDao("State"); while (!feof($memFile)) { $line = fgets($memFile); $fields = explode("\t", $line); $forum = strlen($fields[16]) == 4 ? 0 : 1; $cert = strlen($fields[26]) > 1 ? 1 : 0; $deleted = null; if ($fields[24]) { $deleted = strlen($fields[24]) == 6 ? 1 : 0; } $isSighted = null; if ($fields[23]) { $isSighted = strlen($fields[23]) == 6 ? 1 : 0; } //noc $noc = null; $nocLetter = strtolower($fields[25]); switch ($nocLetter) { case 'd': $noc = 4; break; case 'u': $noc = 11; break; case 'm': $noc = 9; break; case 'f': $noc = 2; break; } $middleInitial = ""; $tempName = $this->prepareName($fields[6]); if (is_array($tempName)) { $lastName = $tempName[0]; $middleInitial = $tempName[1]; } else { $lastName = $tempName; } $tempName = $this->prepareName($fields[7]); if (is_array($tempName)) { $firstName = $tempName[0]; $middleInitial = $tempName[1]; } else { $firstName = $tempName; } $curRecord = array("recnum" => $fields[0], "lastName" => $lastName, "firstName" => $firstName, "middleInitial" => $middleInitial, "address1" => $fields[8], "zipcode" => $fields[13], "city" => $this->Ufirst($fields[11]), "stateFid" => $fields[12], "added" => date('Y-m-d'), "receivesBrailleForum" => $forum, "isCertified" => $cert, "deleted" => $deleted, "nocFid" => $noc, "isSighted" => $isSighted, "notes" => $fields[22]); $zipPattern = $zipDao->getPattern(); $statePattern = $stateDao->getPattern(); $zipPattern->zip = $curRecord['zipcode']; $zips = $zipDao->search($zipPattern); if ($zips && count($zips) > 0) { $zip = $zips[0]; $curRecord['city'] = $zip->city ? $zip->city : $curRecord['city']; $statePattern->abbr = $zip->state; $state = $stateDao->search($statePattern); $curRecord['stateFid'] = $state[0]->id; } else { $statePattern->abbr = $curRecord['state']; $state = $stateDao->search($statePattern); $curRecord['stateFid'] = $state[0]->id; } $toReturn[] = $curRecord; } return $toReturn; }
function search() { return BaseDao::search("Member", $this); }
public function __construct() { parent::__construct(); $this->tbl_name = 'promote_position'; $this->pk = 'id'; }
public function getPredicate(){ $identity = $this->getContext()->getRequest()->getParameter("id"); $dao = new BaseDao("Member"); if($identity) $member = $dao->get($identity); else $member = $dao->getPattern(); $member->dig(); return new MemberEditPredicate("Editor", $member->affiliates); }
private function saveLinks($newMembersIds, $membersIds, $affiliateId){ if ($newMembersIds){ $idsToRemove = array_diff($membersIds, $newMembersIds); $idsToInsert = array_diff($newMembersIds, $membersIds); $assocDao = new BaseDao("MemberToAffiliateAssociation"); foreach($idsToRemove as $id){ $currentAssoc = $assocDao->getPattern(); $currentAssoc->memberFid = $id; $currentAssoc->affiliateFid = $affiliateId; $currentAssoc->delete(); } foreach($idsToInsert as $id){ $currentAssoc = $assocDao->getPattern(); $currentAssoc->memberFid = $id; $currentAssoc->affiliateFid = $affiliateId; $currentAssoc->insert(); } } }
public function __construct() { parent::__construct(); $this->tbl_name = 'help_category'; $this->pk = 'id'; }
private function findEditorAffiliates() { $editorId = $this->getContext()->getUser()->getAttribute('Login')->id; $affDao = new BaseDao("Affiliate"); $affEx = $affDao->getPattern(); $affEx->editor = $editorId; $editorAffiliates = $affDao->search($affEx); return $editorAffiliates; }
public function __construct() { parent::__construct(); $this->tbl_name = 'shop'; $this->pk = 'id'; }
function getOneRole() { $roleDao = new BaseDao("Role"); $this->roles[] = $roleDao->get($this->roleFid); return $this->roles; }
public function __construct() { parent::__construct(); $this->tbl_name = 'friend_link'; $this->pk = 'id'; }
function max5admins($fields){ if ($fields['user']['roleFid'] != 3) { return TRUE; } $errors = array(); $loginDao = new BaseDao("Login"); $login = $loginDao->getPattern(); $login->roleFid = 3; $loginList = $loginDao->search($login); //if user is already superadmin $id = $fields['user']['id']; if (in_array($id, $this->getListOfCertainFieldValues($loginList, 'id'))){ return TRUE; } // print_r(count($loginList)); die(); if (count($loginList) >= 5) { $errors['user[roleFid]'] = "There are already 5 superadmins exist. Remove one before."; } if (empty($errors)) return TRUE; else return $errors; }
/** * Tests BaseDao->ExecuteQuery() */ public function testExecuteQuery() { // TODO Auto-generated BaseDaoTest->testExecuteQuery() $this->markTestIncomplete("ExecuteQuery test not implemented"); $this->BaseDao->ExecuteQuery(); }