/** * Will search for a kshow for the specific partner & key. * The key can be combined from the kuser_id and the group_id * If not found - will create one * If both the kuser_id & group_id are null - always create one */ public static function getDefaultKshow($partner_id, $subp_id, $puser_kuser, $group_id = null, $allow_quick_edit = null, $create_anyway = false, $default_name = null) { $kuser_id = null; // make sure puser_kuser object exists so function will not exit with FATAL if ($puser_kuser) { $kuser_id = $puser_kuser->getKuserId(); } $key = $group_id != null ? $group_id : $kuser_id; if (!$create_anyway) { $c = new Criteria(); myCriteria::addComment($c, "myKshowUtils::getDefaultKshow"); $c->add(kshowPeer::GROUP_ID, $key); $kshow = kshowPeer::doSelectOne($c); if ($kshow) { return $kshow; } // no kshow - create using the service $name = "{$key}'s generated show'"; } else { $name = "a generated show'"; } if ($default_name) { $name = $default_name; } $extra_params = array("kshow_groupId" => $key, "kshow_allowQuickEdit" => $allow_quick_edit); // set the groupId with the key so we'll find it next time round $kshow = myPartnerServicesClient::createKshow("", $puser_kuser->getPuserId(), $name, $partner_id, $subp_id, $extra_params); return $kshow; }
public function getLastKshowUrl() { // return the last kshow_id created by this kuser $c = new Criteria(); $c->add(kshowPeer::PRODUCER_ID, $this->getId()); $c->addDescendingOrderByColumn(kshowPeer::ID); $kshow = kshowPeer::doSelectOne($c); $host = requestUtils::getHost() . "/"; if ($kshow) { return "<a href='" . $host . "/id/" . $kshow->getId() . "'>" . $kshow->getName() . "</a>"; } else { // This should never happen return "<a href='" . $host . "'>Kaltura</a>"; } }
/** * select kshow.id,concat('http://www.kaltura.com/index.php/browse/bands?band_id=',indexed_custom_data_1),concat('http://profile.myspace.com/index.cfm?fuseaction=user.viewpr ofile&friendID=',indexed_custom_data_1) , kuser.screen_name , indexed_custom_data_1 from kshow ,kuser where kshow.partner_id=5 AND kuser.id=kshow.producer_id AND kshow. id>=10815 order by kshow.id ; ~ */ public function execute() { $this->forceSystemAuthentication(); $kshow_id = $this->getRequestParameter("kshow_id", null); $band_id = $this->getRequestParameter("band_id", null); $kuser_name = $this->getRequestParameter("kuser_name", null); $this->other_kshows_by_producer = null; $error = ""; $kshow = null; $kuser = null; $entries = null; $this->kuser_count = 0; $should_delete = $this->getRequestParameter("deleteme", "false") == "true"; if ($kuser_name) { $c = new Criteria(); $c->add(kuserPeer::SCREEN_NAME, "%" . $kuser_name . "%", Criteria::LIKE); $this->kuser_count = kuserPeer::doCount($c); $kuser = kuserPeer::doSelectOne($c); if ($kuser) { $this->other_kshows_by_producer = $this->getKshowsForKuser($kuser, null); } else { $error .= "Cannot find kuser with name [{$kuser_name}]<br>"; } $other_kshow_count = count($this->other_kshows_by_producer); if ($other_kshow_count < 1) { // kuser has no kshow - delete him ! if ($should_delete) { $kuser->delete(); } } else { if ($other_kshow_count == 1) { $kshow_id = $this->other_kshows_by_producer[0]->getId(); } else { // kuser has more than one kshow - let user choose $error .= "[{$kuser_name}] has ({$other_kshow_count}) shows.<br>"; } } } if ($band_id) { $c = new Criteria(); $c->add(kshowPeer::INDEXED_CUSTOM_DATA_1, $band_id); $c->add(kshowPeer::PARTNER_ID, 5); $kshow = kshowPeer::doSelectOne($c); } else { if ($kshow_id) { $kshow = kshowPeer::retrieveByPK($kshow_id); } } if ($kshow) { if (!$kuser) { $kuser = kuserPeer::retrieveByPK($kshow->getProducerId()); } if ($kuser) { $this->other_kshows_by_producer = $this->getKshowsForKuser($kuser, $kshow); if ($should_delete) { if (count($this->other_kshows_by_producer) == 0) { $kuser->delete(); } } } $entries = $kshow->getEntrys(); if ($should_delete) { $id_list = array(); foreach ($entries as $entry) { $id_list[] = $entry->getId(); } if ($id_list) { $d = new Criteria(); $d->add(entryPeer::ID, $id_list, Criteria::IN); entryPeer::doDelete($d); } } if ($should_delete) { $kshow->delete(); } } else { $error .= "Cannot find kshow [{$kshow_id}]<br>"; } $this->kshow_id = $kshow_id; $this->kuser_name = $kuser_name; $this->kshow = $kshow; $this->kuser = $kuser; $this->entries = $entries; $this->should_delete = $should_delete; $this->error = $error; }