public function event_updateTableAlias($oldTableAlias, $newTableAlias) { parent::event_updateTableAlias($oldTableAlias, $newTableAlias); if ($oldTableAlias === $this->alias) { $this->alias = $newTableAlias; } if (isset($this->columns)) { foreach ($this->columns as $column) { $column->event_updateTableAlias($oldTableAlias, $newTableAlias); } } if (isset($this->conditions)) { foreach ($this->conditions as $condition) { $condition->event_updateTableAlias($oldTableAlias, $newTableAlias); } } }
/** * Write a paper in the DB with all its dependent objects * */ function saveAll() { $db = Zend_Db_Table::getDefaultAdapter(); // Remove invalid characters $this->title = Config::removeMSQuotes(trim($this->title)); $this->title = preg_replace("/[\n\r]/", "", $this->title); // First save the paper $this->save(); // Save abstracts. Be very careful not to erase something $currentAbstracts = $this->initAbstracts(); $asbtractSectionTbl = new AbstractSection(); $abstractSections = $asbtractSectionTbl->fetchAll(); foreach ($abstractSections as $abstractSection) { if (isset($this->_abstract[$abstractSection->id])) { $abstract = $this->_abstract[$abstractSection->id]; $abstract->content = Config::removeMSQuotes(trim($abstract->content)); $abstract->content = htmlSpecialChars($abstract->content, ENT_NOQUOTES); // Do not store optional and empty abstracts if (empty($abstract->content) and $abstractSection->mandatory == 'N') { continue; } if (isset($currentAbstracts[$abstractSection->id])) { // Already in the DB: just update $currentAbstracts[$abstractSection->id]->content = $abstract->content; $currentAbstracts[$abstractSection->id]->save(); } else { // This is a new row $abstract->id_paper = $this->id; $abstract->save(); } } } // Clean the Author table for this paper. $db->query("DELETE FROM Author WHERE id_paper='{$this->id}'"); // OK, now save the authors $user = new User(); $authorTble = new Author(); $i = 0; // echo "Contact author: " . $this->_contactAuthor . "<br/>"; foreach ($this->_authors as $author) { // Check that the user does not already exist $existingAuthor = $user->findByEmail($author->email); if (is_object($existingAuthor)) { // Change the values with those obtained from the form $existingAuthor->last_name = $author->last_name; $existingAuthor->first_name = $author->first_name; $existingAuthor->affiliation = $author->affiliation; $existingAuthor->country_code = $author->country_code; // Mark the user as an author $existingAuthor->addRole(User::AUTHOR_ROLE); $existingAuthor->save(); $idUser = $existingAuthor->id; } else { // Ok, simply save the new author $author->addRole(User::AUTHOR_ROLE); $author->save(); $idUser = $author->id; } // In all cases, insert in the Author table (link between User and Paper) $authorRow = $authorTble->createRow(); if ($this->_contactAuthor == $i) { $contact = 'Y'; } else { $contact = 'N'; } $authorRow->setFromArray(array("id_paper" => $this->id, "id_user" => $idUser, "position" => $i + 1, "contact" => $contact)); $authorRow->save(); $i++; } // Clean the PaperAnswer table for this paper. $db->query("DELETE FROM PaperAnswer WHERE id_paper='{$this->id}'"); // And, finally, save the answer to questions foreach ($this->_answers as $answer) { $answer->id_paper = $this->id; $answer->save(); } }
public function event_updateTableAlias($oldTableAlias, $newTableAlias) { parent::event_updateTableAlias($oldTableAlias, $newTableAlias); $this->value->event_updateTableAlias($oldTableAlias, $newTableAlias); }