Esempio n. 1
0
 public static function tagInstancesForModel($sModelName, $iTaggedItemId)
 {
     $oCriteria = new Criteria();
     $oCriteria->add(TagInstancePeer::TAGGED_ITEM_ID, $iTaggedItemId);
     $oCriteria->add(TagInstancePeer::MODEL_NAME, $sModelName);
     return TagInstancePeer::doSelect($oCriteria);
 }
Esempio n. 2
0
 public function getListContents($iRowStart = 0, $iRowCount = null)
 {
     $aResult = array();
     foreach (TagInstancePeer::getTaggedModels() as $sModel => $sModelName) {
         $aResult[] = array('title' => $sModelName, 'tag_model_name' => $sModel);
     }
     $aResult = array_merge(self::getCustomListElements(), $aResult);
     return $aResult;
 }
Esempio n. 3
0
 public static function getTaggedModels()
 {
     $aResult = array();
     foreach (TagInstancePeer::doSelectStmt(self::getTaggedModelsCriteria())->fetchAll(PDO::FETCH_ASSOC) as $aTag) {
         $sTableName = constant($aTag['model_name'] . 'Peer::TABLE_NAME');
         $sName = TranslationPeer::getString('model.' . $sTableName, null, $sTableName);
         $aResult[$aTag['model_name']] = $sName;
     }
     return $aResult;
 }
 public function getConfigurationModes()
 {
     $aResult = array();
     $aResult['templates'] = AdminManager::getSiteTemplatesForListOutput();
     $aResult['tags'] = array();
     foreach (TagPeer::doSelect(new Criteria()) as $oTag) {
         $aResult['tags'][] = array('name' => $oTag->getName(), 'count' => $oTag->countTagInstances(), 'id' => $oTag->getId());
     }
     $aResult['types'] = TagInstancePeer::getTaggedModels();
     return $aResult;
 }
 private function handleListFiltering($oCriteria)
 {
     foreach ($this->oListSettings->aFilters as $sFilterIdentifier => $mFilterValue) {
         $sFilterType = $this->filterTypeForColumn($sFilterIdentifier);
         if ($mFilterValue === self::SELECT_ALL || $sFilterType === self::FILTER_TYPE_MANUAL) {
             continue;
         }
         $sFilterColumn = $this->getDatabaseColumnForColumn($sFilterIdentifier);
         $bInverted = $mFilterValue === self::SELECT_WITHOUT;
         $mFilterValue = $bInverted ? null : $mFilterValue;
         if ($sFilterType === self::FILTER_TYPE_IS) {
             $oCriteria->add($sFilterColumn, $mFilterValue, Criteria::EQUAL);
             //LIKE criterias are not compatible with $bInverted == true
         } else {
             if ($sFilterType === self::FILTER_TYPE_BEGINS) {
                 $oCriteria->add($sFilterColumn, "{$mFilterValue}%", Criteria::LIKE);
             } else {
                 if ($sFilterType === self::FILTER_TYPE_CONTAINS) {
                     $oCriteria->add($sFilterColumn, "%{$mFilterValue}%", Criteria::LIKE);
                 } else {
                     if ($sFilterType === self::FILTER_TYPE_IS_NULL) {
                         if ($mFilterValue) {
                             $oCriteria->add($sFilterColumn, null, Criteria::ISNULL);
                         } else {
                             $oCriteria->add($sFilterColumn, null, Criteria::ISNOTNULL);
                         }
                     } else {
                         if ($sFilterType === self::FILTER_TYPE_IN) {
                             if (!is_array($mFilterValue)) {
                                 $mFilterValue = array($mFilterValue);
                             }
                             if (count($mFilterValue) === 0) {
                                 $bInverted = true;
                             }
                             $oCriteria->add($sFilterColumn, $mFilterValue, $bInverted ? Criteria::NOT_IN : Criteria::IN);
                         } else {
                             if ($sFilterType === self::FILTER_TYPE_TAG) {
                                 $aTaggedItemIds = array();
                                 foreach (TagInstancePeer::getByModelNameAndTagName($this->sModelName, $mFilterValue) as $oTagInstance) {
                                     $aTaggedItemIds[] = $oTagInstance->getTaggedItemId();
                                 }
                                 $oCriteria->add($sFilterColumn, $aTaggedItemIds, $bInverted ? Criteria::NOT_IN : Criteria::IN);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 TagInstance A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `tag_id`, `tagged_item_id`, `model_name`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `tag_instances` WHERE `tag_id` = :p0 AND `tagged_item_id` = :p1 AND `model_name` = :p2';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
         $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
         $stmt->bindValue(':p2', $key[2], PDO::PARAM_STR);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new TagInstance();
         $obj->hydrate($row);
         TagInstancePeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2])));
     }
     $stmt->closeCursor();
     return $obj;
 }
Esempio n. 7
0
 public function mayOperate($sOperation, $oUser = false)
 {
     $oUser = TagInstancePeer::getRightsUser($oUser);
     $bIsAllowed = false;
     if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && TagInstancePeer::mayOperateOnOwn($oUser, $this, $sOperation)) {
         $bIsAllowed = true;
     } else {
         if (TagInstancePeer::mayOperateOn($oUser, $this, $sOperation)) {
             $bIsAllowed = true;
         }
     }
     FilterModule::getFilters()->handleTagInstanceOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed));
     return $bIsAllowed;
 }
Esempio n. 8
0
 /**
  * Method to invalidate the instance pool of all tables related to users
  * by a foreign key with ON DELETE CASCADE
  */
 public static function clearRelatedInstancePool()
 {
     // Invalidate objects in UserGroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserGroupPeer::clearInstancePool();
     // Invalidate objects in UserRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserRolePeer::clearInstancePool();
     // Invalidate objects in PagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePeer::clearInstancePool();
     // Invalidate objects in PagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePeer::clearInstancePool();
     // Invalidate objects in PagePropertyPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePropertyPeer::clearInstancePool();
     // Invalidate objects in PagePropertyPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PagePropertyPeer::clearInstancePool();
     // Invalidate objects in PageStringPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PageStringPeer::clearInstancePool();
     // Invalidate objects in PageStringPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     PageStringPeer::clearInstancePool();
     // Invalidate objects in ContentObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ContentObjectPeer::clearInstancePool();
     // Invalidate objects in ContentObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ContentObjectPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectHistoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectHistoryPeer::clearInstancePool();
     // Invalidate objects in LanguageObjectHistoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguageObjectHistoryPeer::clearInstancePool();
     // Invalidate objects in LanguagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguagePeer::clearInstancePool();
     // Invalidate objects in LanguagePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LanguagePeer::clearInstancePool();
     // Invalidate objects in TranslationPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TranslationPeer::clearInstancePool();
     // Invalidate objects in TranslationPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TranslationPeer::clearInstancePool();
     // Invalidate objects in UserGroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserGroupPeer::clearInstancePool();
     // Invalidate objects in UserGroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserGroupPeer::clearInstancePool();
     // Invalidate objects in GroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupPeer::clearInstancePool();
     // Invalidate objects in GroupPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupPeer::clearInstancePool();
     // Invalidate objects in GroupRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupRolePeer::clearInstancePool();
     // Invalidate objects in GroupRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     GroupRolePeer::clearInstancePool();
     // Invalidate objects in RolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RolePeer::clearInstancePool();
     // Invalidate objects in RolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RolePeer::clearInstancePool();
     // Invalidate objects in UserRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserRolePeer::clearInstancePool();
     // Invalidate objects in UserRolePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     UserRolePeer::clearInstancePool();
     // Invalidate objects in RightPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RightPeer::clearInstancePool();
     // Invalidate objects in RightPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     RightPeer::clearInstancePool();
     // Invalidate objects in DocumentPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentPeer::clearInstancePool();
     // Invalidate objects in DocumentPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentPeer::clearInstancePool();
     // Invalidate objects in DocumentDataPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentDataPeer::clearInstancePool();
     // Invalidate objects in DocumentDataPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentDataPeer::clearInstancePool();
     // Invalidate objects in DocumentTypePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentTypePeer::clearInstancePool();
     // Invalidate objects in DocumentTypePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentTypePeer::clearInstancePool();
     // Invalidate objects in DocumentCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentCategoryPeer::clearInstancePool();
     // Invalidate objects in DocumentCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     DocumentCategoryPeer::clearInstancePool();
     // Invalidate objects in TagPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagPeer::clearInstancePool();
     // Invalidate objects in TagPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagPeer::clearInstancePool();
     // Invalidate objects in TagInstancePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagInstancePeer::clearInstancePool();
     // Invalidate objects in TagInstancePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     TagInstancePeer::clearInstancePool();
     // Invalidate objects in LinkPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkPeer::clearInstancePool();
     // Invalidate objects in LinkPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkPeer::clearInstancePool();
     // Invalidate objects in LinkCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkCategoryPeer::clearInstancePool();
     // Invalidate objects in LinkCategoryPeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     LinkCategoryPeer::clearInstancePool();
     // Invalidate objects in ReferencePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ReferencePeer::clearInstancePool();
     // Invalidate objects in ReferencePeer instance pool,
     // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     ReferencePeer::clearInstancePool();
 }
Esempio n. 9
0
 /**
  * Retrieve object using using composite pkey values.
  * @param   int $tag_id
  * @param   int $tagged_item_id
  * @param   string $model_name
  * @param      PropelPDO $con
  * @return TagInstance
  */
 public static function retrieveByPK($tag_id, $tagged_item_id, $model_name, PropelPDO $con = null)
 {
     $_instancePoolKey = serialize(array((string) $tag_id, (string) $tagged_item_id, (string) $model_name));
     if (null !== ($obj = TagInstancePeer::getInstanceFromPool($_instancePoolKey))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(TagInstancePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(TagInstancePeer::DATABASE_NAME);
     $criteria->add(TagInstancePeer::TAG_ID, $tag_id);
     $criteria->add(TagInstancePeer::TAGGED_ITEM_ID, $tagged_item_id);
     $criteria->add(TagInstancePeer::MODEL_NAME, $model_name);
     $v = TagInstancePeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Esempio n. 10
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = TagPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related TagInstance objects
         $criteria = new Criteria(TagInstancePeer::DATABASE_NAME);
         $criteria->add(TagInstancePeer::TAG_ID, $obj->getId());
         $affectedRows += TagInstancePeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Esempio n. 11
0
 public function fillFromRssAttributes($aAttributes)
 {
     if (isset($aAttributes['categories'])) {
         $aTags = $aAttributes['categories'];
         $aTagInstances = TagPeer::tagInstancesForObject($this);
         $aOldTags = array();
         foreach ($aTagInstances as $oTagInstance) {
             if (!in_array($oTagInstance->getTagName(), $aTags)) {
                 $oTagInstance->delete();
             } else {
                 $aOldTags[] = $oTagInstance->getTagName();
             }
         }
         foreach ($aTags as $sTagName) {
             if (!in_array($sTagName, $aOldTags)) {
                 TagInstancePeer::newTagInstanceForObject($sTagName, $this);
             }
         }
     }
     $this->setText($aAttributes['description']);
     $this->setTitle($aAttributes['title']);
 }