コード例 #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()));
     }
 }
コード例 #2
0
ファイル: FormFileModule.php プロジェクト: rapila/cms-base
 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');
 }
コード例 #3
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;
     }
 }
コード例 #4
0
ファイル: BaseLanguage.php プロジェクト: rapila/cms-base
 /**
  * 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);
 }