Ejemplo n.º 1
0
	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";
		}
	}
Ejemplo n.º 2
0
    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;
        
    }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
    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';
        
    }
Ejemplo n.º 5
0
 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;
     }
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
    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;
    }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
 function getAffiliates()
 {
     $affDao = new BaseDao("Affiliate");
     $affExample = $affDao->getPattern();
     $this->affiliates = $affDao->searchWhere($affExample, "editor=" . $this->id);
     return $this->affiliates;
 }
Ejemplo n.º 10
0
 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;
 }
Ejemplo n.º 11
0
	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);
	}
Ejemplo n.º 12
0
	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();
			}
		}
	}
Ejemplo n.º 13
0
 public static function find($affiliateList)
 {
     $affDao = new BaseDao("EditorTransactionAtom");
     $pattern = $affDao->getPattern();
     $inText = "";
     if ($affiliateList) {
         foreach ($affiliateList as $aff) {
             $inText .= $aff . ", ";
         }
         $inText .= "-1";
     }
     $pattern->whereAdd(" affiliateFid IN ( " . $inText . " )");
     $trans_results = $affDao->search($pattern);
     $result = array();
     foreach ($trans_results as $res) {
         array_push($result, EditorTransaction::resume($res->transFid));
     }
     return $result;
 }