/** * Add a Tag in the collection. * * @param Tag $tag * * @throws \Exception If the tag exist in the collection */ public function add(Tag $tag) { $tagId = $tag->getId(); foreach ($this->collection as $tagItem) { $tagIdTmp = $tagItem->getId(); if ($tagId == $tagIdTmp) { throw new \Exception('The tag is already included in this collection'); } } $this->collection[] = $tag; }
public static function newTagInstance($sTagName, $sModelName, $iTaggedItemId) { $sTagName = StringUtil::normalize($sTagName); $oTag = TagPeer::retrieveByName($sTagName); if ($oTag === null) { $oTag = new Tag(); $oTag->setName($sTagName); $oTag->save(); } $oTagInstance = self::retrieveByPK($oTag->getId(), $iTaggedItemId, $sModelName); if ($oTagInstance !== null) { throw new Exception("Instance of this tag does already exist"); } $oTagInstance = new TagInstance(); $oTagInstance->setTag($oTag); $oTagInstance->setModelName($sModelName); $oTagInstance->setTaggedItemId($iTaggedItemId); $oTagInstance->save(); return $oTagInstance; }
/** * Add tags for an object * * @access public * @param string $tag_name tag to be added * @param ProjectDataObject $obj * @return null */ function addObjectTag($tag_name, ApplicationDataObject $obj) { $tag_name = trim($tag_name); if (!(isset($obj) && $obj && $obj instanceof ApplicationDataObject)) { return true; } $prevTags = Tags::getTagNamesByObject($obj); if ($prevTags) { foreach ($prevTags as $tag_iter) { if (strcmp($tag_name, $tag_iter) == 0) { return true; } //tag already added } } if (strcmp($tag_name, '')) { $exists = true; if (Tags::countObjectsByTag($tag_name) <= 0) { $exists = false; } $tag = new Tag(); $tag->setTag($tag_name); $tag->setRelObjectId($obj->getId()); $tag->setRelObjectManager(get_class($obj->manager())); $tag->setIsPrivate(false); $tag->save(); if (!$exists) { $real_tag = self::findById($tag->getId()); evt_add("tag added", array("name" => $real_tag->getTag())); } } // if return true; }
/** * Add a tag to the Page given by the id */ public static function addTagTo($sPageId, $mTag) { if ($mTag instanceof TagInstance) { $mTag = $mTag->getTag(); } if ($mTag instanceof Tag) { $mTag = $mTag->getName(); } $sTagName = StringUtil::normalize($mTag); $oTag = TagQuery::create()->findOneByName($sTagName); if ($oTag === null) { $oTag = new Tag(); $oTag->setName($sTagName); $oTag->save(); } $oTagInstance = TagInstanceQuery::create()->findPk(array($oTag->getId(), $sPageId, "Page")); if ($oTagInstance !== null) { return $oTagInstance; } $oTagInstance = new TagInstance(); $oTagInstance->setTag($oTag); $oTagInstance->setModelName("Page"); $oTagInstance->setTaggedItemId($sPageId); $oTagInstance->save(); return $oTagInstance; }
/** * All the applicants in an application * @param Application $application * @param Tag $tag * @return array */ public function findTaggedByApplication(Application $application, Tag $tag) { $queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder->from('Jazzee\\Entity\\Applicant', 'applicant'); $queryBuilder->add('select', 'applicant'); $queryBuilder->leftJoin('applicant.tags', 'tags'); $queryBuilder->where('applicant.application = :applicationId'); $queryBuilder->setParameter('applicationId', $application->getId()); $queryBuilder->andWhere('applicant.deactivated=false'); $queryBuilder->andWhere(':tagId MEMBER OF applicant.tags'); $queryBuilder->setParameter('tagId', $tag->getId()); $queryBuilder->orderBy('applicant.lastName, applicant.firstName'); return $queryBuilder->getQuery()->getResult(); }
/** * Filter the query by a related Tag object * * @param Tag|PropelObjectCollection $tag The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return TagInstanceQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByTag($tag, $comparison = null) { if ($tag instanceof Tag) { return $this->addUsingAlias(TagInstancePeer::TAG_ID, $tag->getId(), $comparison); } elseif ($tag instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(TagInstancePeer::TAG_ID, $tag->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByTag() only accepts arguments of type Tag or PropelCollection'); } }
/** * Declares an association between this object and a Tag object. * * @param Tag $v * @return TagInstance The current object (for fluent API support) * @throws PropelException */ public function setTag(Tag $v = null) { if ($v === null) { $this->setTagId(NULL); } else { $this->setTagId($v->getId()); } $this->aTag = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Tag object, it will not be re-added. if ($v !== null) { $v->addTagInstance($this); } return $this; }
public function delete(Tag &$tag) { $this->db->query("delete from Tag where id=" . $tag->getId()); }
include_once "config.php"; include_once "class/Emailer.class.php"; $background_color = 'white'; include_once 'includes/header.inc.php'; $idcontact = (int) $_GET['idc']; $iduser = (int) trim($_GET['idu']); $idtag = (int) trim($_GET['idt']); $do_contact = new Contact(); $do_contact->getId($idcontact); $firstname = $do_contact->firstname; $lastname = $do_contact->lastname; $email_address = $do_contact->getDefaultEmailId($idcontact); $message = ''; $do_tag = new Tag(); if ($do_tag->isTagValidTagId($idtag) === true) { $do_tag->getId($idtag); $tag_name = $do_tag->tag_name; $do_user = new User(); $do_user->getId($iduser); $user_idcontact = $do_user->idcontact; $q_auto_resp = new sqlQuery($GLOBALS['conx']); /*$sql_auto_resp = "SELECT ar.name,arem.subject FROM autoresponder AS ar INNER JOIN autoresponder_email AS arem ON ar.idautoresponder = arem.idautoresponder WHERE ar.iduser = {$iduser} AND ar.tag_name = '{$tag_name}'";*/ $sql_auto_resp = "SELECT `name` FROM autoresponder\n WHERE iduser = {$iduser} AND tag_name = '{$tag_name}'"; $q_auto_resp->query($sql_auto_resp); $responder = ""; $resp_email_subj = ""; if ($q_auto_resp->getNumRows()) { $q_auto_resp->fetch(); $responder = $q_auto_resp->getData("name");
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Tag $obj A Tag object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null TagPeer::$instances[$key] = $obj; } }
/** * deleteTagById * Delete a tag using the tag primary key. * Used in the ajax delete in the contact.php * it fetch the tag name and call the deleteTab() * @param idtag * @param idcontact * @see deleteTab(), eventDeleteTag() */ public function deleteTagById($idtag, $idcontact = 0) { if (empty($idcontact)) { $idcontact = $this->idcontact; } $tag_to_delete = new Tag(); if ($tag_to_delete->getId($idtag)) { $this->deleteTag($tag_to_delete->tag_name, $idcontact); } else { $this->setLog("\n ContactView Tag delete: No tag found to delete"); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Tag $value A Tag object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Tag $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) { self::$instances[$key] = $obj; kMemoryManager::registerPeer('TagPeer'); } } }
/** * Exclude object from result * * @param Tag $tag Object to remove from the list of results * * @return TagQuery The current query, for fluid interface */ public function prune($tag = null) { if ($tag) { $this->addUsingAlias(TagPeer::ID, $tag->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Declares an association between this object and a Tag object. * * @param Tag $v * @return void * @throws PropelException */ public function setTag($v) { if ($v === null) { $this->setTagId(NULL); } else { $this->setTagId($v->getId()); } $this->aTag = $v; }