function link_to_user_interested($user, $question)
{
    if ($user->isAuthenticated()) {
        $interested = InterestPeer::retrieveByPk($question->getId(), $user->getSubscriberId());
        if ($interested) {
            // already interested
            return __('interested!');
        } else {
            // didn't declare interest yet
            return link_to_remote(__('interested?'), array('url' => 'user/interested?id=' . $question->getId(), 'update' => array('success' => 'block_' . $question->getId()), 'loading' => "Element.show('indicator')", 'complete' => "Element.hide('indicator');" . visual_effect('pulsate', 'mark_' . $question->getId())));
        }
    } else {
        return link_to_login(__('interested?'));
    }
}
Example #2
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = InterestPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setQuestionId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCreatedAt($arr[$keys[2]]);
     }
 }
Example #3
0
 public function getInterestsJoinUser($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseInterestPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collInterests === null) {
         if ($this->isNew()) {
             $this->collInterests = array();
         } else {
             $criteria->add(InterestPeer::QUESTION_ID, $this->getId());
             $this->collInterests = InterestPeer::doSelectJoinUser($criteria, $con);
         }
     } else {
         $criteria->add(InterestPeer::QUESTION_ID, $this->getId());
         if (!isset($this->lastInterestCriteria) || !$this->lastInterestCriteria->equals($criteria)) {
             $this->collInterests = InterestPeer::doSelectJoinUser($criteria, $con);
         }
     }
     $this->lastInterestCriteria = $criteria;
     return $this->collInterests;
 }
Example #4
0
 public static function retrieveByPK($question_id, $user_id, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(InterestPeer::QUESTION_ID, $question_id);
     $criteria->add(InterestPeer::USER_ID, $user_id);
     $v = InterestPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }