Example #1
0
 /**
  * Handles badge action
  *
  * @param sfWebRequest $request Web request object
  */
 public function executeBadge($request)
 {
     $this->jotag = TagPeer::getFromField(TagPeer::JOTAG, $request->getParameter('jotag'));
     $this->forward404Unless($this->jotag && $this->jotag->getStatus() == TagPeer::ST_ACTIVE);
     // get badge
     $this->badge = $this->jotag->getBadge();
     // is authorized
     $this->authorized = TagPrivacyPeer::allowedToView($this->getUser(), $this->jotag);
     // reload
     $this->reload = $request->getParameter('reload') ? true : false;
     // build list of contact info
     $this->contacts = array();
     $jotag =& $this->jotag;
     if ($jotag->getTagEmailsJoinEmail(EmailPeer::buildConfirmedCriteria())) {
         foreach ($jotag->getTagEmailsJoinEmail(EmailPeer::buildConfirmedCriteria()) as $k => $email) {
             $this->contacts["EMAIL"][] = $email->getEmail()->getEmail($this->authorized);
         }
     }
     if ($jotag->getTagPhonesJoinPhone()) {
         foreach ($jotag->getTagPhonesJoinPhone() as $k => $phone) {
             $this->contacts["PHONE"][] = array("number" => $phone->getPhone()->getNumber($this->authorized), "exten" => $phone->getPhone()->getExten($this->authorized));
         }
     }
     if ($jotag->getTagUrlsJoinUrl()) {
         foreach ($jotag->getTagUrlsJoinUrl() as $k => $url) {
             $this->contacts["URL"][] = $url->getUrl()->getUrl($this->authorized);
         }
     }
     if ($jotag->getTagSNsJoinSN()) {
         foreach ($jotag->getTagSNsJoinSN() as $k => $sn) {
             $this->contacts["SN"][] = array("network" => $sn->getSN()->getNetwork(), "identifier" => $sn->getSN()->getIdentifier($this->authorized));
         }
     }
     if ($jotag->getTagIMsJoinIM()) {
         foreach ($jotag->getTagIMsJoinIM() as $k => $im) {
             $this->contacts["IM"][] = array("network" => $im->getIM()->getNetwork(), "identifier" => $im->getIM()->getIdentifier($this->authorized));
         }
     }
     if ($jotag->getTagCustomsJoinCustom()) {
         foreach ($jotag->getTagCustomsJoinCustom() as $k => $custom) {
             $this->contacts["CUSTOM"][] = array("netname" => $custom->getCustom()->getNetName(), "netid" => $custom->getCustom()->getNetId($this->authorized));
         }
     }
 }
	protected function doClean($values)
	{
		$this->already_exists = null;
		
		$jotag = $values[$this->getOption('jotag')];
		$user = sfContext::getInstance()->getUser()->getSubscriber();

		$tag = TagPeer::getFromField(TagPeer::JOTAG,$jotag);
		if($tag && (!$user || ($tag->getUserId() != $user->getId())))
		{
			$this->already_exists = $tag;
			
			$error = new sfValidatorError($this,'exist',array(
							$this->getOption('jotag')=>$jotag
			));
				
			throw new sfValidatorErrorSchema($this,array($this->getOption('jotag')=>$error));
		}
		elseif($tag) $values["jotag_object"] = $tag; // renewing jotag
		else $values["jotag_object"] = null;
		
		return $values;
	}
Example #3
0
 public function executeAddInterest($request)
 {
     $user = $this->getUser()->getSubscriber();
     $jotag = TagPeer::getFromField(TagPeer::JOTAG, $request->getParameter('jotag'));
     $this->forward404Unless($jotag && $jotag->getUser()->getId() != $this->getUser()->getSubscriberId() && !$user->hasInterest($jotag) && !$jotag->getIsPrimary());
     $this->jotag = $jotag;
     $this->form = new AddInterestForm(array('jotag' => $jotag->getJotag()));
     if ($request->isMethod('post')) {
         $this->form->bind(array('confirm_jotag' => $request->getParameter('confirm_jotag'), 'jotag' => $request->getParameter('jotag')));
         if ($this->form->isValid()) {
             $user->addJotagInterest($jotag);
             // notify owner
             Mailer::sendEmail($jotag->getUser()->getPrimaryEmail(), 'interestNotifyOwner', array('user' => $user, 'jotag' => $jotag), $jotag->getUser()->getPreferedLanguage());
             $this->setMessage('ADD_INTEREST', 'SUCCESS', $jotag->getJotag());
             if (!$this->isWebserviceCall()) {
                 $this->redirect('@account');
             }
         }
     }
 }
Example #4
0
 public function executeBackOption($request)
 {
     $jotag = TagPeer::getFromField(TagPeer::JOTAG, $request->getParameter('jotag'));
     $this->jotag = $jotag;
     $this->getUser()->getAttributeHolder()->remove('nextOption');
 }