Esempio 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";
		}
	}
Esempio n. 2
0
    public function execute() {

       	$request = $this->getContext()->getRequest();

    	$postLoginUser = $request->getParameter('user');
    	$postLoginId = $postLoginUser['id'];

    	$id = $request->getParameter('id');

		$login = $this->getContext()->getUser()->getAttribute('Login');
    	$loginRole = $this->getLoginRole();

    	if ($loginRole == 'editor'){
    		if ($id != $login->id && $postLoginId != $login->id){

				$this->log("Unauthorized attempt edit login record. Login id: $id, user name: ". $login->name);
    					
    			$this->getContext()->getController()->forward('Default', "Secure");	
    		}
    	}

//    	$this->checkAdminAuth();

		if($request->getParameter('cancel')) {

			if ($loginRole == 'admin'){
				$this->getContext()->getController()->forward('Default', "ListLogin");
			} else {
				header("Location:Search?searchFor=Member");
			}

			return View::NONE;
		}
        
    	$form = new HTML_QuickForm("loginForm", 'post');

    	$loginDao = new BaseDao("Login");

		$affDao = new BaseDao("Affiliate"); 

    	if ($id){
    		$user = $loginDao->get($id);	

			$this->log("Editing login: "******" ,name: ".$user->name);
			$this->log("Editing login: "******" ,name: ".$user->name, true);

    		$affiliate = $affDao->getPattern();
    		$affiliate->editor = $user->id;
			$currentAffs = $affDao->search($affiliate);
			$affIds = $this->getListOfCertainFieldValues($currentAffs, 'id');

    		$form->setDefaults(array('user' => (array) $user, 
    								 "password2" => $user->password,
    								 "affiliates" => $affIds));
    	} else{
			$this->log("Creating new login.", true);

	    	$user = $loginDao->getPattern();
    	}

		$request->setAttribute('user', $user);

		$roleDao = new BaseDao("Role"); 
		$roles = $this->prepareDropdown($roleDao->search(), 'id', 'name');

		$affs = $this->prepareDropdown($affDao->searchWhereWithOrder($affDao->getPattern(), "1=1", 'name'), 'id', 'name');

		$form->addElement("text", "user[name]", "Name:", array('size' => 50, "maxlength" => 255));
		$form->addElement("text", "user[login]", "Login:"******"maxlength" => 255));
		$form->addElement("password", "user[password]", "Password:"******"maxlength" => 255));
		$form->addElement("password", "password2", "Repeat Password:"******"maxlength" => 255));
		$form->addElement('text', "user[email]", 'Email:', array('size' => 50, "maxlength" => 255));
		$form->addElement('select', "user[roleFid]", "User Role:", $roles);
		$form->addElement('select', "affiliates", "Affiliate:", $affs, array('multiple' => 'multiple', 'id' => "affDropdown") );
		$form->addElement('checkbox', "user[nationalOfficer]", "National Officer:", "", array());

		$element =& $form->getElement("affiliates");
		$element->setSize(5);
		if ($loginRole != 'admin') $element->freeze();

		$form->addElement('hidden', 'user[id]');
		$form->addElement("submit", null, "Save Changes");
		$form->addElement("submit", 'cancel', "Cancel");

		$form->addRule("user[name]", "Please enter your name.", 'required', null);
		$form->addRule("user[login]", "Login can't be blank.", 'required', null);
		$form->addRule("user[password]", "You haven't entered password.", 'required', null);
		$form->addRule("user[email]", "Please enter your email.", 'required', null);
		$form->addRule("user[email]", "Please enter valid email.", 'email', null);

		$form->addFormRule(array(&$this, "validatePassword"));
		$form->addFormRule(array(&$this, "checkEmail"));
		$form->addFormRule(array(&$this, "max5admins"));



		if (!$form->validate()) {

			$request->setAttribute("editLoginForm", $form->toHtml());

			return 'Form';
		}
		else{	
			$reqUser = $request->getParameter('user');

			$user->id = $reqUser['id'];
			$user->login = $reqUser['login'];
			$user->password = $reqUser['password'];
			$user->email = $reqUser['email'];
			$user->roleFid = $reqUser['roleFid'];
			$user->name = $reqUser['name'];

			if ($reqUser["nationalOfficer"]){
				$this->log("Assigng new national Officer: ".$user->login." ,name: ".$user->name, true);

				$user->nationalOfficer = 1;		
				$db = new PearDBStorage();
				$db->invoke("update logins set nationalOfficer=0 where nationalOfficer=1");
			}

			$loginDao->save($user);

			$affiliates = $reqUser = $request->getParameter("affiliates");
			$affText = "";
			if ($affiliates){
				foreach($affiliates as $affId){
					$affiliate = $affDao->get($affId);
					$affiliate->editor = $user->id;
					$affDao->save($affiliate);

					$affText .= $affiliate->name." ";
				}
			}

			if (!$user->id){

				$emailMessage = "Dear ".$user->name.":\n\n
				You have been assigned the role of Editor in the American Council of the Blind membership database for ".$affText.".\n
				Your User ID is ".$user->login." and your default password is ".$user->password.".  Please change this password immediately when you log into the database.\n\n
				Thank you for your work both in your affiliate and with the ACB management of the most precious resource we have:  Our members.\n\n
				Sincerely,\n\n
				The Database Management Team";

				mail($user->email, "ACB mail", $emailMessage);
			}

			if ($loginRole == 'admin'){
				$this->log("Saving login: "******" ,name: ".$user->name, true);

				$this->getContext()->getController()->forward('Default', "ListLogin");
			} else {
				$this->log("Saving login: "******" ,name: ".$user->name);

				header("Location:Search?searchFor=Member");
			}

			return View::NONE;
		}
    }
Esempio n. 3
0
 private function insertAffiliates()
 {
     $abbrToCodes = $this->parseAbbrToCodesFile();
     $dao = new BaseDao("Affiliate");
     foreach ($abbrToCodes as $code => $aff) {
         $affiliate = $dao->getPattern();
         $affiliate->abbreviation = $aff['abbr'];
         $affiliate->name = $aff['name'];
         $dao->save($affiliate);
         $toReturn[$code] = $affiliate->id;
     }
     return $toReturn;
 }
Esempio n. 4
0
    public function execute()
    {
    	ini_set("memory_limit", "200M");

   		$request = $this->getContext()->getRequest();

		$identity = $this->getContext()->getRequest()->getParameter("id");

	    //redirect if we press Cancel button
		if($request->getParameter('cancel')) {

	    	$this->log("Cancel editing. Changes not saved.");
	    	$this->log("Cancel editing. Changes not saved.", true);

			if (!$identity){	
				$request->setParameter("searchFor", "Affiliate");
				$this->getContext()->getController()->forward('Default', "Search");
			}else{
				$this->getContext()->getController()->forward('Default', "AffiliateView");
			}

			return View::NONE;
		}


		$userRole = $this->checkAffiliateAuth($identity);
		
		$membersIds = array();

		$dao = new BaseDao("Affiliate");

		if($identity){
			$affiliate = $dao->get($identity);
			$affiliate->getLinks();
			$fullMembersInfo = $affiliate->getMembers();
			$members = $this->prepareMembersListForDropdown($fullMembersInfo); 
			$membersIds = (count($members) != 0) ? array_keys($members) : array();
			$request->setAttribute('members', $members);
		} else {
			$affiliate = $dao->getPattern();
		}
		
		$request->setAttribute("affiliate", $affiliate);

		$needToSaveChanges = !($this->isRecordModifiedBySameRolePerson($affiliate, $userRole));
		                                                                  
		$request->setAttribute("needToApproveChanges", $needToSaveChanges && $this->isRecordHasActiveTransactions($affiliate));

		if ($request->getParameter('rollback')) {

	    	$this->log("Rollback changes affiliate id: $identity; name: ".$affiliate->name);
	    	$this->log("Rollback changes affiliate id: $identity; name: ".$affiliate->name, true);

			$this->rollBackChanges($affiliate);
			$dao->save($affiliate);

		} elseif($request->getParameter('accept')){

	    	$this->log("Accepting changes affiliate id: $identity; name: ".$affiliate->name);
	    	$this->log("Accepting changes affiliate id: $identity; name: ".$affiliate->name, true);
			
			$this->acceptChanges($affiliate);	
			$dao->save($affiliate);
			
		} elseif($request->getParameter('save')){

	    	$this->log("Saving changes affiliate id: $identity; name: ".$affiliate->name);
	    	$this->log("Saving changes affiliate id: $identity; name: ".$affiliate->name, true);

			//if we're not adding affiliate
			if ($needToSaveChanges) {
				$this->saveTransaction($affiliate);
		    	$this->log("Changes made by $userRole need to be approved. Affiliate id: $identity; name: ".$affiliate->name);
			}
			
			$affiliate->name = $request->getParameter('name');
			$affiliate->abbreviation = $request->getParameter("abbreviation");
			$affiliate->president = $request->getParameter("president");
			$affiliate->vicePresident1 = $request->getParameter("vicePresident1");
			$affiliate->vicePresident2 = $request->getParameter("vicePresident2");
			$affiliate->generalSecretary = $request->getParameter("generalSecretary");
			$affiliate->correspondingSecretary = $request->getParameter("correspondingSecretary");
			$affiliate->treasurerSecretary = $request->getParameter("treasurerSecretary");
			$affiliate->treasurer = $request->getParameter("treasurer");
			$affiliate->databaseManager = $request->getParameter("dbManager");
			$affiliate->lastCertified = $request->getParameter("lastCertifiedDateYear") . "-" . $request->getParameter("lastCertifiedDateMonth") . "-" . $request->getParameter("lastCertifiedDateDay");
			$affiliate->type = $request->getParameter("type");
//			$affiliate->lastCertified = $request->getParameter("lastCertifiedY") . "-" . $request->getParameter("lastCertifiedM") . "-" . $request->getParameter("lastCertifiedD");
			$dao->save($affiliate);

			$newMembersIds = $request->getParameter("members");

			$this->saveLinks($newMembersIds, $membersIds, $affiliate->id);

			$identity = $affiliate->id;
			$redirectTo = "AffiliateView?id=$identity";

		} else {
			if($identity){
		    	$this->log("Starting editing affiliate id: $identity; name: ".$affiliate->name);
		    	$this->log("Starting editing affiliate id: $identity; name: ".$affiliate->name, true);
    		} else{
		    	$this->log("Starting inserting new affiliate.");
		    	$this->log("Starting inserting new affiliate.", true);
			}

			return 'Form';
		}

		$request->setParameter('id', $identity);
//   		header("location: $redirectTo");
		$this->getContext()->getController()->forward('Default', "AffiliateView");
		return View::NONE;

	}