Exemplo n.º 1
0
 public function deleteRow($aRowData, $oCriteria)
 {
     $oLanguage = LanguagePeer::doSelectOne($oCriteria);
     if ($oLanguage->getIsDefault()) {
         throw new LocalizedException('wns.language.delete_default.denied');
     }
     if ($oLanguage->getIsDefaultEdit()) {
         throw new LocalizedException('wns.language.delete_default.denied');
     }
     if (LanguagePeer::doCount(new Criteria()) < 2) {
         throw new LocalizedException('wns.language.delete_last.denied');
     }
     $sLanguageId = $oLanguage->getId();
     foreach (LanguageObjectQuery::create()->filterByLanguageId($sLanguageId)->find() as $oLanguageObject) {
         $oHistory = $oLanguageObject->newHistory();
         $oHistory->save();
         $oLanguageObject->delete();
     }
     $iResult = $oLanguage->delete();
     $oReplacementLanguage = LanguageQuery::create()->findOne();
     if (AdminManager::getContentLanguage() === $sLanguageId) {
         AdminManager::setContentLanguage(Settings::getSetting("session_default", AdminManager::CONTENT_LANGUAGE_SESSION_KEY, $oReplacementLanguage->getId()));
     }
     if (Session::language() === $sLanguageId) {
         Session::getSession()->setLanguage(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, $oReplacementLanguage->getId()));
     }
 }
Exemplo n.º 2
0
 public function __construct($aRequestPath)
 {
     parent::__construct($aRequestPath);
     if (!isset($this->aPath[1])) {
         throw new Exception("Error in FormFileModule->__construct: no object ID or no language ID given");
     }
     $this->sLanguageId = $this->aPath[0];
     $this->iObjectId = $this->aPath[1];
     $oFormDataLanguageObject = LanguageObjectQuery::create()->findPk(array($this->iObjectId, $this->sLanguageId));
     if ($oFormDataLanguageObject == null || $oFormDataLanguageObject->getContentObject()->getObjectType() !== 'form') {
         throw new Exception("Error in FormFileModule->__construct: object ID does not correspond to form object in given language");
     }
     $this->oFormStorage = unserialize(stream_get_contents($oFormDataLanguageObject->getData()));
     $this->sPageName = $oFormDataLanguageObject->getContentObject()->getPage()->getName();
     if ($this->oFormStorage->getFormType() !== 'email') {
         throw new Exception("Error in FormFileModule->renderFile(): form type {$this->oFormStorage->getFormType()} is not supported");
     }
     $this->sEmailAddress = $this->oFormStorage->getFormOption('email_address');
     $sTemplateName = $this->oFormStorage->getFormOption('template_addition');
     if ($sTemplateName) {
         $sTemplateName = 'e_mail_form_output_' . $sTemplateName;
     } else {
         $sTemplateName = 'e_mail_form_output';
     }
     $this->oEmailTemplate = $this->constructTemplate($sTemplateName);
     $this->oEmailItemTemplate = $this->constructTemplate('e_mail_form_item');
 }
Exemplo n.º 3
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Language is new, it will return
  * an empty collection; or if this Language has previously
  * been saved, it will retrieve related LanguageObjects from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Language.
  *
  * @param Criteria $criteria optional Criteria object to narrow the query
  * @param PropelPDO $con optional connection object
  * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return PropelObjectCollection|LanguageObject[] List of LanguageObject objects
  */
 public function getLanguageObjectsJoinUserRelatedByUpdatedBy($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = LanguageObjectQuery::create(null, $criteria);
     $query->joinWith('UserRelatedByUpdatedBy', $join_behavior);
     return $this->getLanguageObjects($query, $con);
 }
Exemplo n.º 4
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(LanguageObjectPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = LanguageObjectQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // denyable behavior
         if (!(LanguageObjectPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.backend_user", array("role_key" => "language_objects")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Exemplo n.º 5
0
 /**
  * Returns a new LanguageObjectQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   LanguageObjectQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return LanguageObjectQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof LanguageObjectQuery) {
         return $criteria;
     }
     $query = new LanguageObjectQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }