public function getCustomListElements()
 {
     if (JournalQuery::create()->count() > 0) {
         return array(array('journal_id' => CriteriaListWidgetDelegate::SELECT_ALL, 'name' => TranslationPeer::getString('wns.sidebar.select_all'), 'magic_column' => 'all'));
     }
     return array();
 }
 public function listJournals($iJournalIdsConfigured = null)
 {
     $oQuery = JournalQuery::create()->distinct();
     if ($iJournalIdsConfigured !== null) {
         $oQuery->filterById($iJournalIdsConfigured);
     }
     $aResult = $oQuery->orderByName()->find()->toKeyValue('Id', 'Name');
     return $aResult;
 }
 public function postUp($manager)
 {
     foreach (PageQuery::create()->filterByPageType('journal')->find() as $oJournalPage) {
         $sCommentMode = $oJournalPage->getPagePropertyValue('blog_comment_mode', 'on');
         $aJournalIds = explode(',', $oJournalPage->getPagePropertyValue('blog_journal_id', ''));
         $bCaptchaEnabled = !!$oJournalPage->getPagePropertyValue('blog_captcha_enabled', true);
         foreach (JournalQuery::create()->filterById($aJournalIds)->find() as $oJournal) {
             $oJournal->setEnableComments($sCommentMode === 'on' || $sCommentMode === 'notified');
             $oJournal->setNotifyComments($sCommentMode === 'moderated' || $sCommentMode === 'notified');
             $oJournal->setUseCaptcha($bCaptchaEnabled);
             $oJournal->save();
         }
         $oJournalPage->updatePageProperty('blog_comment_mode', null);
         $oJournalPage->updatePageProperty('blog_captcha_enabled', null);
     }
     // add the post-migration code here
 }
 public function renderBackend()
 {
     $oTemplate = $this->constructTemplate('config');
     // Display options
     $aDisplayOptions = array();
     foreach (self::$DISPLAY_OPTIONS as $sDisplayMode) {
         $aDisplayOptions[$sDisplayMode] = TranslationPeer::getString('journal.display_mode.' . $sDisplayMode, null, StringUtil::makeReadableName($sDisplayMode));
     }
     $oTemplate->replaceIdentifier('display_options', TagWriter::optionsFromArray($aDisplayOptions, null, null, array()));
     // Journal pages and journal options
     $aJournalOptions = array();
     foreach (PageQuery::create()->filterByPageType('journal')->orderByName()->find() as $oPage) {
         $aJournalOptions['page' . self::PAGE_SEPARATOR . $oPage->getId()] = TranslationPeer::getString('wns.journal.journal_page_name', null, null, array('name' => $oPage->getLinkText()));
     }
     foreach (JournalQuery::create()->orderByName()->find() as $oJournal) {
         $aJournalOptions[$oJournal->getId()] = TranslationPeer::getString('wns.journal.journal_name', null, null, array('name' => $oJournal->getName()));
     }
     $oTemplate->replaceIdentifier('journal_options', TagWriter::optionsFromArray($aJournalOptions));
     return $oTemplate;
 }
 public function saveData($aJournalData)
 {
     if ($this->iJournalId === null) {
         $oJournal = new Journal();
     } else {
         $oJournal = JournalQuery::create()->findPk($this->iJournalId);
     }
     $this->validate($aJournalData);
     $oJournal->setName($aJournalData['name']);
     $oJournal->setDescription($aJournalData['description']);
     $oJournal->setUseCaptcha($aJournalData['use_captcha']);
     $sCommentMode = $aJournalData['comment_mode'];
     $oJournal->setEnableComments($sCommentMode === 'on' || $sCommentMode === 'notified');
     $oJournal->setNotifyComments($sCommentMode === 'moderated' || $sCommentMode === 'notified');
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $oJournal->save();
     return $oJournal->getId();
 }
Example #6
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(JournalPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = JournalQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // denyable behavior
         if (!(JournalPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "journals")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 public function listJournals()
 {
     return JournalQuery::create()->orderByName()->find()->toKeyValue('Id', 'Name');
 }
 /**
  * Get the associated Journal object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Journal The associated Journal object.
  * @throws PropelException
  */
 public function getJournal(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aJournal === null && $this->journal_id !== null && $doQuery) {
         $this->aJournal = JournalQuery::create()->findPk($this->journal_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aJournal->addJournalEntrys($this);
            */
     }
     return $this->aJournal;
 }
 /**
  * Returns a new JournalQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   JournalQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return JournalQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof JournalQuery) {
         return $criteria;
     }
     $query = new JournalQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 public function getJournalName()
 {
     $iId = $this->oDelegateProxy->getJournalId();
     if (is_array($iId)) {
         $iId = @$iId[0];
     }
     $oJournal = JournalQuery::create()->findPk($iId);
     if ($oJournal) {
         return $oJournal->getName();
     }
     return $this->oDelegateProxy->getJournalId();
 }
 public static function getRecentPosts($iBlogId, $sUserName, $sPassword, $iCount)
 {
     if (!self::checkLogin($sUserName, $sPassword)) {
         return self::loginError();
     }
     $oQuery = JournalEntryQuery::create()->filterByJournalId($iBlogId)->mostRecentFirst()->limit($iCount);
     $oJournalPage = JournalQuery::create()->findPk($iBlogId)->getJournalPage();
     $aResult = array();
     foreach ($oQuery->find() as $oJournalEntry) {
         $aResult[] = $oJournalEntry->getRssAttributes($oJournalPage, true);
     }
     return $aResult;
 }