/**
	 * 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    CahierTexteCompteRendu A model object, or null if the key is not found
	 */
	protected function findPkSimple($key, $con)
	{
		$sql = 'SELECT ID_CT, HEURE_ENTRY, DATE_CT, CONTENU, VISE, VISA, ID_GROUPE, ID_LOGIN, ID_SEQUENCE FROM ct_entry WHERE ID_CT = :p0';
		try {
			$stmt = $con->prepare($sql);
			$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
			$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 CahierTexteCompteRendu();
			$obj->hydrate($row);
			CahierTexteCompteRenduPeer::addInstanceToPool($obj, (string) $key);
		}
		$stmt->closeCursor();

		return $obj;
	}
Пример #2
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 = GroupePeer::doSelect($criteria, $con);
		foreach ($objects as $obj) {


			// delete related JGroupesProfesseurs objects
			$criteria = new Criteria(JGroupesProfesseursPeer::DATABASE_NAME);
			
			$criteria->add(JGroupesProfesseursPeer::ID_GROUPE, $obj->getId());
			$affectedRows += JGroupesProfesseursPeer::doDelete($criteria, $con);

			// delete related JGroupesMatieres objects
			$criteria = new Criteria(JGroupesMatieresPeer::DATABASE_NAME);
			
			$criteria->add(JGroupesMatieresPeer::ID_GROUPE, $obj->getId());
			$affectedRows += JGroupesMatieresPeer::doDelete($criteria, $con);

			// delete related JGroupesClasses objects
			$criteria = new Criteria(JGroupesClassesPeer::DATABASE_NAME);
			
			$criteria->add(JGroupesClassesPeer::ID_GROUPE, $obj->getId());
			$affectedRows += JGroupesClassesPeer::doDelete($criteria, $con);

			// delete related CahierTexteCompteRendu objects
			$criteria = new Criteria(CahierTexteCompteRenduPeer::DATABASE_NAME);
			
			$criteria->add(CahierTexteCompteRenduPeer::ID_GROUPE, $obj->getId());
			$affectedRows += CahierTexteCompteRenduPeer::doDelete($criteria, $con);

			// delete related CahierTexteTravailAFaire objects
			$criteria = new Criteria(CahierTexteTravailAFairePeer::DATABASE_NAME);
			
			$criteria->add(CahierTexteTravailAFairePeer::ID_GROUPE, $obj->getId());
			$affectedRows += CahierTexteTravailAFairePeer::doDelete($criteria, $con);

			// delete related CahierTexteNoticePrivee objects
			$criteria = new Criteria(CahierTexteNoticePriveePeer::DATABASE_NAME);
			
			$criteria->add(CahierTexteNoticePriveePeer::ID_GROUPE, $obj->getId());
			$affectedRows += CahierTexteNoticePriveePeer::doDelete($criteria, $con);

			// delete related JEleveGroupe objects
			$criteria = new Criteria(JEleveGroupePeer::DATABASE_NAME);
			
			$criteria->add(JEleveGroupePeer::ID_GROUPE, $obj->getId());
			$affectedRows += JEleveGroupePeer::doDelete($criteria, $con);

			// delete related CreditEcts objects
			$criteria = new Criteria(CreditEctsPeer::DATABASE_NAME);
			
			$criteria->add(CreditEctsPeer::ID_GROUPE, $obj->getId());
			$affectedRows += CreditEctsPeer::doDelete($criteria, $con);

			// delete related EdtEmplacementCours objects
			$criteria = new Criteria(EdtEmplacementCoursPeer::DATABASE_NAME);
			
			$criteria->add(EdtEmplacementCoursPeer::ID_GROUPE, $obj->getId());
			$affectedRows += EdtEmplacementCoursPeer::doDelete($criteria, $con);
		}
		return $affectedRows;
	}
	/**
	 * Retrieve multiple objects by pkey.
	 *
	 * @param      array $pks List of primary keys
	 * @param      PropelPDO $con the connection to use
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function retrieveByPKs($pks, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(CahierTexteCompteRenduPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria(CahierTexteCompteRenduPeer::DATABASE_NAME);
			$criteria->add(CahierTexteCompteRenduPeer::ID_CT, $pks, Criteria::IN);
			$objs = CahierTexteCompteRenduPeer::doSelect($criteria, $con);
		}
		return $objs;
	}
	/**
	 * Selects a collection of CahierTexteCompteRenduFichierJoint objects pre-filled with all related objects.
	 *
	 * @param      Criteria  $criteria
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     array Array of CahierTexteCompteRenduFichierJoint objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		$criteria = clone $criteria;

		// Set the correct dbName if it has not been overridden
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
			$criteria->setDbName(self::DATABASE_NAME);
		}

		CahierTexteCompteRenduFichierJointPeer::addSelectColumns($criteria);
		$startcol2 = CahierTexteCompteRenduFichierJointPeer::NUM_HYDRATE_COLUMNS;

		CahierTexteCompteRenduPeer::addSelectColumns($criteria);
		$startcol3 = $startcol2 + CahierTexteCompteRenduPeer::NUM_HYDRATE_COLUMNS;

		$criteria->addJoin(CahierTexteCompteRenduFichierJointPeer::ID_CT, CahierTexteCompteRenduPeer::ID_CT, $join_behavior);

		$stmt = BasePeer::doSelect($criteria, $con);
		$results = array();

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = CahierTexteCompteRenduFichierJointPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = CahierTexteCompteRenduFichierJointPeer::getInstanceFromPool($key1))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj1->hydrate($row, 0, true); // rehydrate
			} else {
				$cls = CahierTexteCompteRenduFichierJointPeer::getOMClass(false);

				$obj1 = new $cls();
				$obj1->hydrate($row);
				CahierTexteCompteRenduFichierJointPeer::addInstanceToPool($obj1, $key1);
			} // if obj1 already loaded

			// Add objects for joined CahierTexteCompteRendu rows

			$key2 = CahierTexteCompteRenduPeer::getPrimaryKeyHashFromRow($row, $startcol2);
			if ($key2 !== null) {
				$obj2 = CahierTexteCompteRenduPeer::getInstanceFromPool($key2);
				if (!$obj2) {

					$cls = CahierTexteCompteRenduPeer::getOMClass(false);

					$obj2 = new $cls();
					$obj2->hydrate($row, $startcol2);
					CahierTexteCompteRenduPeer::addInstanceToPool($obj2, $key2);
				} // if obj2 loaded

				// Add the $obj1 (CahierTexteCompteRenduFichierJoint) to the collection in $obj2 (CahierTexteCompteRendu)
				$obj2->addCahierTexteCompteRenduFichierJoint($obj1);
			} // if joined row not null

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}
Пример #5
0
}
$utilisateur = UtilisateurProfessionnelPeer::getUtilisateursSessionEnCours();
if ($utilisateur == null) {
    header("Location: ../logout.php?auto=1");
    die;
}
$tab_termes_CDT2 = get_texte_CDT2();
//récupération des parametres
//id du compte rendu
$id_ct = isset($_POST["id_ct"]) ? $_POST["id_ct"] : (isset($_GET["id_ct"]) ? $_GET["id_ct"] : NULL);
//si on vient d'enregistrer des modification, on va afficher un message de confirmation
$succes_modification = isset($_POST["succes_modification"]) ? $_POST["succes_modification"] : (isset($_GET["succes_modification"]) ? $_GET["succes_modification"] : NULL);
//si pas de compte rendu passé en paramètre, on récupère la date du jour pour se caler dessus, sinon on prendra la date du compte rendu
$today = isset($_POST["today"]) ? $_POST["today"] : (isset($_GET["today"]) ? $_GET["today"] : NULL);
$ajout_nouvelle_notice = isset($_POST["ajout_nouvelle_notice"]) ? $_POST["ajout_nouvelle_notice"] : (isset($_GET["ajout_nouvelle_notice"]) ? $_GET["ajout_nouvelle_notice"] : NULL);
$ctCompteRendu = CahierTexteCompteRenduPeer::retrieveByPK($id_ct);
if ($ctCompteRendu != null) {
    $groupe = $ctCompteRendu->getGroupe();
    $today = $ctCompteRendu->getDateCt();
    if ($groupe == null) {
        echo "Erreur enregistrement de devoir : Pas de groupe associé au compte-rendu";
        die;
    }
    // Vérification : est-ce que l'utilisateur a le droit de travailler sur ce groupe ?
    if (!$groupe->belongsTo($utilisateur)) {
        echo "Erreur edition de compte rendu : le groupe n'appartient pas au professeur";
        die;
    }
} else {
    //si pas de notice précisée, récupération du groupe dans la requete et recherche d'une notice pour la date précisée ou création d'une nouvelle notice
    $id_groupe = isset($_POST["id_groupe"]) ? $_POST["id_groupe"] : (isset($_GET["id_groupe"]) ? $_GET["id_groupe"] : NULL);
Пример #6
0
	/**
	 * Populates the object using an array.
	 *
	 * This is particularly useful when populating an object from one of the
	 * request arrays (e.g. $_POST).  This method goes through the column
	 * names, checking to see whether a matching key exists in populated
	 * array. If so the setByName() method is called for that column.
	 *
	 * You can specify the key type of the array by additionally passing one
	 * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
	 * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
	 * The default key type is the column's phpname (e.g. 'AuthorId')
	 *
	 * @param      array  $arr     An array to populate the object from.
	 * @param      string $keyType The type of keys the array uses.
	 * @return     void
	 */
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = CahierTexteCompteRenduPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setIdCt($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setHeureEntry($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setDateCt($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setContenu($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setVise($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setVisa($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setIdGroupe($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setIdLogin($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setIdSequence($arr[$keys[8]]);
	}
Пример #7
0
	/**
	 * Method to invalidate the instance pool of all tables related to ct_sequences
	 * by a foreign key with ON DELETE CASCADE
	 */
	public static function clearRelatedInstancePool()
	{
		// Invalidate objects in CahierTexteCompteRenduPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		CahierTexteCompteRenduPeer::clearInstancePool();
		// Invalidate objects in CahierTexteTravailAFairePeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		CahierTexteTravailAFairePeer::clearInstancePool();
		// Invalidate objects in CahierTexteNoticePriveePeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		CahierTexteNoticePriveePeer::clearInstancePool();
	}
	/**
	 * Method to invalidate the instance pool of all tables related to utilisateurs
	 * by a foreign key with ON DELETE CASCADE
	 */
	public static function clearRelatedInstancePool()
	{
		// Invalidate objects in JGroupesProfesseursPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		JGroupesProfesseursPeer::clearInstancePool();
		// Invalidate objects in JScolClassesPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		JScolClassesPeer::clearInstancePool();
		// Invalidate objects in CahierTexteCompteRenduPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		CahierTexteCompteRenduPeer::clearInstancePool();
		// Invalidate objects in CahierTexteTravailAFairePeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		CahierTexteTravailAFairePeer::clearInstancePool();
		// Invalidate objects in CahierTexteNoticePriveePeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		CahierTexteNoticePriveePeer::clearInstancePool();
		// Invalidate objects in JEleveCpePeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		JEleveCpePeer::clearInstancePool();
		// Invalidate objects in JEleveProfesseurPrincipalPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		JEleveProfesseurPrincipalPeer::clearInstancePool();
		// Invalidate objects in JAidUtilisateursProfessionnelsPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		JAidUtilisateursProfessionnelsPeer::clearInstancePool();
		// Invalidate objects in AbsenceEleveNotificationPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		AbsenceEleveNotificationPeer::clearInstancePool();
		// Invalidate objects in PreferenceUtilisateurProfessionnelPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		PreferenceUtilisateurProfessionnelPeer::clearInstancePool();
		// Invalidate objects in EdtEmplacementCoursPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		EdtEmplacementCoursPeer::clearInstancePool();
	}
Пример #9
0
// Vérification : est-ce que l'utilisateur a le droit de supprimer cette entrée ?
$utilisateur = UtilisateurProfessionnelPeer::getUtilisateursSessionEnCours();
if ($utilisateur == null) {
    header("Location: ../logout.php?auto=1");
    die;
}
check_token();
//récupération de la notice
$id_objet = isset($_POST["id_objet"]) ? $_POST["id_objet"] : (isset($_GET["id_objet"]) ? $_GET["id_objet"] : NULL);
$type = isset($_POST["type"]) ? $_POST["type"] : (isset($_GET["type"]) ? $_GET["type"] : NULL);
echo $id_objet . "; ";
echo $type . "; ";
$objet = null;
if ($type == 'CahierTexteTravailAFaire') {
    $objet = CahierTexteTravailAFairePeer::retrieveByPK($id_objet);
} elseif ($type == 'CahierTexteCompteRendu') {
    $objet = CahierTexteCompteRenduPeer::retrieveByPK($id_objet);
} elseif ($type == 'CahierTexteCompteRenduFichierJoint') {
    $objet = CahierTexteCompteRenduFichierJointPeer::retrieveByPK($id_objet);
} elseif ($type == 'CahierTexteTravailAFaireFichierJoint') {
    $objet = CahierTexteTravailAFaireFichierJointPeer::retrieveByPK($id_objet);
} elseif ($type == 'CahierTexteNoticePrivee') {
    $objet = CahierTexteNoticePriveePeer::retrieveByPK($id_objet);
}
//si pas d'objet trouve, erreur du script
if ($objet == null) {
    echo "Erreur : pas d'objet trouvé.";
    die;
}
$objet->delete();
$utilisateur->clearAllReferences();