コード例 #1
0
ファイル: Basekvote.php プロジェクト: kubrickfr/server
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->akshowRelatedByKshowId !== null) {
             if ($this->akshowRelatedByKshowId->isModified() || $this->akshowRelatedByKshowId->isNew()) {
                 $affectedRows += $this->akshowRelatedByKshowId->save($con);
             }
             $this->setkshowRelatedByKshowId($this->akshowRelatedByKshowId);
         }
         if ($this->aentry !== null) {
             if ($this->aentry->isModified() || $this->aentry->isNew()) {
                 $affectedRows += $this->aentry->save($con);
             }
             $this->setentry($this->aentry);
         }
         if ($this->akshowRelatedByKuserId !== null) {
             if ($this->akshowRelatedByKuserId->isModified() || $this->akshowRelatedByKuserId->isNew()) {
                 $affectedRows += $this->akshowRelatedByKuserId->save($con);
             }
             $this->setkshowRelatedByKuserId($this->akshowRelatedByKuserId);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = kvotePeer::ID;
         }
         // If this object has been modified, then save it to the database.
         $this->objectSaved = false;
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = kvotePeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
                 $this->objectSaved = true;
             } else {
                 $affectedObjects = kvotePeer::doUpdate($this, $con);
                 if ($affectedObjects) {
                     $this->objectSaved = true;
                 }
                 $affectedRows += $affectedObjects;
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #2
0
ファイル: kshow.php プロジェクト: DBezemer/server
 public static function create($partner_id, $subp_id, $producer_id, $kshow_type)
 {
     $kshow = new kshow();
     $kshow->setPartnerId($partner_id);
     $kshow->setSubpId($subp_id);
     $kshow->setProducerId($producer_id);
     $kshow->setType($kshow_type);
     // will make sure the intro will have a good default
     $kshow->save();
     // to create a new kshow in the DB and use its ID for the entries creation
     $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $producer_id);
     // roughcut
     $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_VIDEO, $producer_id);
     // intro
     $kshow->save();
     // to finally save
     return $kshow;
 }
コード例 #3
0
 protected function createDummyKShow()
 {
     $kshow = new kshow();
     $kshow->setName(kshow::DUMMY_KSHOW_NAME);
     $kshow->setProducerId($this->getKuser()->getId());
     $kshow->setPartnerId($this->getPartnerId());
     $kshow->setSubpId($this->getPartnerId() * 100);
     $kshow->setViewPermissions(kshow::KSHOW_PERMISSION_EVERYONE);
     $kshow->setPermissions(kshow::PERMISSIONS_PUBLIC);
     $kshow->setAllowQuickEdit(true);
     $kshow->save();
     return $kshow;
 }
コード例 #4
0
ファイル: Baseentry.php プロジェクト: richhl/kalturaCE
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->akshow !== null) {
             if ($this->akshow->isModified() || $this->akshow->isNew()) {
                 $affectedRows += $this->akshow->save($con);
             }
             $this->setkshow($this->akshow);
         }
         if ($this->akuser !== null) {
             if ($this->akuser->isModified() || $this->akuser->isNew()) {
                 $affectedRows += $this->akuser->save($con);
             }
             $this->setkuser($this->akuser);
         }
         if ($this->aaccessControl !== null) {
             if ($this->aaccessControl->isModified() || $this->aaccessControl->isNew()) {
                 $affectedRows += $this->aaccessControl->save($con);
             }
             $this->setaccessControl($this->aaccessControl);
         }
         if ($this->aconversionProfile2 !== null) {
             if ($this->aconversionProfile2->isModified() || $this->aconversionProfile2->isNew()) {
                 $affectedRows += $this->aconversionProfile2->save($con);
             }
             $this->setconversionProfile2($this->aconversionProfile2);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = entryPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += entryPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collkvotes !== null) {
             foreach ($this->collkvotes as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collconversions !== null) {
             foreach ($this->collconversions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collWidgetLogs !== null) {
             foreach ($this->collWidgetLogs as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collmoderationFlags !== null) {
             foreach ($this->collmoderationFlags as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collroughcutEntrysRelatedByRoughcutId !== null) {
             foreach ($this->collroughcutEntrysRelatedByRoughcutId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collroughcutEntrysRelatedByEntryId !== null) {
             foreach ($this->collroughcutEntrysRelatedByEntryId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collwidgets !== null) {
             foreach ($this->collwidgets as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collassetParamsOutputs !== null) {
             foreach ($this->collassetParamsOutputs as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collassets !== null) {
             foreach ($this->collassets as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * Executes addComment action, which returns a form enabling the insertion of a comment
  * The request may include 1 fields: entry id.
  */
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     $kshow_id = $kshow->getId();
     if ($this->partner_id != null) {
         // this part overhere should be in a more generic place - part of the services
         $multiple_roghcuts = Partner::allowMultipleRoughcuts($this->partner_id);
         $likuser_id = $this->getLoggedInUserId();
     } else {
         // 	is the logged-in-user is not an admin or the producer - check if show can be published
         $likuser_id = $this->getLoggedInUserId();
         $multiple_roghcuts = true;
     }
     if (!$likuser_id) {
         return $this->securityViolation($kshow->getId());
     }
     $isIntro = $kshow->getIntroId() == $entry->getId();
     if ($multiple_roghcuts) {
         // create a new entry in two cases:
         // 1. the user saving the roughcut isnt the owner of the entry
         // 2. the entry is an intro and the current entry is not show (probably an image or video)
         if ($entry->getKuserId() != $likuser_id || $isIntro && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) {
             // TODO: add security check to whether multiple roughcuts are allowed
             // create a new roughcut entry by cloning the original entry
             $entry = myEntryUtils::deepClone($entry, $kshow_id, false);
             $entry->setKuserId($likuser_id);
             $entry->setCreatorKuserId($likuser_id);
             $entry->setCreatedAt(time());
             $entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
             $entry->save();
         }
     }
     /*
     		$viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id);
     		if ( $viewer_type != KshowKuser::KSHOWKUSER_VIEWER_PRODUCER && ( ! $kshow->getCanPublish() ) ) 
     		{
     			// ERROR - attempting to publish a non-publishable show
     			return $this->securityViolation( $kshow->getId() );
     		}
     */
     $this->xml_content = "<xml><EntryID>" . $entry->getId() . "</EntryID></xml>";
     if ($isIntro) {
         $kshow->setIntroId($entry->getId());
     } else {
         $kshow->setShowEntryId($entry->getId());
         $has_roughcut = @$_REQUEST["HasRoughCut"];
         if ($has_roughcut === "0") {
             $kshow->setHasRoughcut(false);
             $kshow->save();
             return;
         }
     }
     $content = @$_REQUEST["xml"];
     $update_kshow = false;
     if ($content != NULL) {
         list($xml_content, $this->comments, $update_kshow) = myMetadataUtils::setMetadata($content, $kshow, $entry);
         // Send an email alert to producer
         if ($kshow->getProducerId() != $likuser_id) {
             // don't send producer alerts when the producer is the editor
             alertPeer::sendEmailIfNeeded($kshow->getProducerId(), alert::KALTURAS_PRODUCED_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
         }
         // TODO:  efficiency: see if there is a wa to search for contributors based on some other method than full entry table scan
         // Send email alerts to contributors
         $c = new Criteria();
         $c->add(entryPeer::KSHOW_ID, $kshow_id);
         $c->add(entryPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL);
         // the current user knows they just edited
         $c->addAnd(entryPeer::KUSER_ID, $kshow->getProducerId(), Criteria::NOT_EQUAL);
         // the producer knows they just edited
         $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
         $c->addGroupByColumn(entryPeer::KUSER_ID);
         $entries = entryPeer::doSelect($c);
         $already_received_alert_array = array();
         foreach ($entries as $entry) {
             alertPeer::sendEmailIfNeeded($entry->getKuserId(), alert::KALTURAS_PARTOF_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
             $already_received_alert_array[$entry->getKuserId()] = true;
         }
         // send email alert to subscribers
         $c = new Criteria();
         $c->add(KshowKuserPeer::KSHOW_ID, $kshow_id);
         //only subsribers of this show
         $c->add(KshowKuserPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL);
         // the current user knows they just edited
         $c->add(KshowKuserPeer::SUBSCRIPTION_TYPE, KshowKuser::KSHOW_SUBSCRIPTION_NORMAL);
         // this table stores other relations too
         $subscriptions = KshowKuserPeer::doSelect($c);
         foreach ($subscriptions as $subscription) {
             if (!isset($already_received_alert_array[$subscription->getKuserId()])) {
                 // don't send emails to subscribed users who are also contributors
                 alertPeer::sendEmailIfNeeded($subscription->getKuserId(), alert::KALTURAS_SUBSCRIBEDTO_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
             }
         }
         if ($this->debug) {
             return "text/html; charset=utf-8";
         }
     } else {
         $this->comments = "";
         // if there is no xml - receive it from the user
         $this->debug = true;
         $file_name = myContentStorage::getFSContentRootPath() . "/" . $entry->getDataPath();
         //$this->xml_content = kFile::getFileContent( $file_name );
         return "text/html; charset=utf-8";
     }
 }
コード例 #6
0
ファイル: Basewidget.php プロジェクト: DBezemer/server
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @param      boolean $skipReload Whether to skip the reload for this object from database.
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con, $skipReload = false)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         $reloadObject = false;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->akshow !== null) {
             if ($this->akshow->isModified() || $this->akshow->isNew()) {
                 $affectedRows += $this->akshow->save($con);
             }
             $this->setkshow($this->akshow);
         }
         if ($this->aentry !== null) {
             if ($this->aentry->isModified() || $this->aentry->isNew()) {
                 $affectedRows += $this->aentry->save($con);
             }
             $this->setentry($this->aentry);
         }
         if ($this->auiConf !== null) {
             if ($this->auiConf->isModified() || $this->auiConf->isNew()) {
                 $affectedRows += $this->auiConf->save($con);
             }
             $this->setuiConf($this->auiConf);
         }
         // If this object has been modified, then save it to the database.
         $this->objectSaved = false;
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = widgetPeer::doInsert($this, $con);
                 if (!$skipReload) {
                     $reloadObject = true;
                 }
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
                 $this->objectSaved = true;
             } else {
                 $affectedObjects = widgetPeer::doUpdate($this, $con);
                 if ($affectedObjects) {
                     $this->objectSaved = true;
                 }
                 $affectedRows += $affectedObjects;
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
         if ($reloadObject) {
             $this->reload($con);
         }
     }
     return $affectedRows;
 }