public static function subscribe($kshow_id, $kuser_id, &$message) { // first check if user already subscribed to this show $kshowKuser = self::isSubscribed($kshow_id, $kuser_id); if ($kshowKuser != NULL) { $message = "You are already subscribed to this Kaltura"; return false; } $kshow = kshowPeer::retrieveByPK($kshow_id); if (!$kshow) { $message = "Kaltura {$kshow_id} doesn't exist"; return false; } $kuser = kuserPeer::retrieveByPK($kuser_id); if (!$kuser) { $message = "User {$user_id} doesn't exist"; return false; } $showname = $kshow->getName(); $subscriberscreenname = $kuser->getScreenName(); // subscribe $kshowKuser = new KshowKuser(); $kshowKuser->setKshowId($kshow_id); $kshowKuser->setKuserId($kuser_id); $kshowKuser->setSubscriptionType(KshowKuser::KSHOW_SUBSCRIPTION_NORMAL); $kshowKuser->setAlertType(alert::KALTURAS_PRODUCED_ALERT_TYPE_SUBSCRIBER_ADDED); $kshowKuser->save(); $message = "You are now subscribed to {$showname}. You can receive updates and join the discussion."; return true; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param KshowKuser $value A KshowKuser object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(KshowKuser $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
public static function addSubscriber(KshowKuser $kushow_kuser) { $type = $kushow_kuser->getAlertType(); if ($type == KshowKuser::KSHOW_SUBSCRIPTION_NORMAL) { $kshow = $kushow_kuser->getkshow(); if ($kshow) { $v = $kshow->getSubscribers(); self::inc($v); $kshow->setSubscribers($v); } self::add($kshow); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param KshowKuser $value A KshowKuser object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(KshowKuser $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) { self::$instances[$key] = $obj; kMemoryManager::registerPeer('KshowKuserPeer'); } } }