Example #1
0
 public function updateSubscription($sid, $uid, $type)
 {
     $entityManager = $this->getEntityManager();
     // Get subscription
     $subscription = $entityManager->getRepository('Janus\\ServiceRegistry\\Entity\\User\\Subscription')->findOneBy(array('id' => $sid, 'user' => $uid));
     if (!$subscription instanceof Subscription) {
         throw new \Exception("User subscription '{$sid}' for user '{$uid}' does not exist");
     }
     try {
         $subscription->update($type);
         $entityManager->persist($subscription);
         $entityManager->flush();
     } catch (\Exception $ex) {
         simplesaml_logger::error('janus: Error updating subscription - ' . var_export(array($sid, $uid, $subscription, $type), true));
         throw $ex;
     }
     return true;
 }
 public function updateSubscription($sid, $uid, $type)
 {
     $st = self::execute('UPDATE `' . self::$prefix . 'subscription` 
          SET `type` = ?, `uid` = ?, `created` = ?, `ip` = ?
          WHERE `sid` = ?;', array($type, $uid, date('c'), $_SERVER['REMOTE_ADDR'], $sid));
     if ($st === false) {
         simplesaml_logger::error('janus: Error updating subscription - ' . var_export(array($sid, $uid, $subscription, $type), true));
         return false;
     }
     return true;
 }