$contenu_cor = str_replace("\\n", "", $contenu_cor);
        //$contenu_cor = stripslashes($contenu_cor);
        if ($contenu_cor == "" or $contenu_cor == "<br>") {
            $contenu_cor = "...";
        }
        $sql = "INSERT INTO ct_private_entry SET date_ct='{$date_devoir}', heure_entry='" . strftime("%H:%M:%S") . "', id_login='******'login'] . "', id_groupe='{$id_groupe}', contenu='<b>COPIE DE SAUVEGARDE</b><br />{$contenu_cor}';";
        $insert = mysqli_query($GLOBALS["mysqli"], $sql);
        echo "Erreur enregistrement de devoir : formulaire dejà posté précédemment.\nUne copie de sauvegarde a été créée en notice privée.";
    } else {
        echo "Erreur enregistrement de devoir : formulaire dejà posté précédemment.";
    }
    die;
}
$_SESSION['uid_prime'] = $uid_post;
//récupération du compte rendu
$ctTravailAFaire = CahierTexteTravailAFairePeer::retrieveByPK($id_devoir);
if ($ctTravailAFaire != null) {
    $groupe = $ctTravailAFaire->getGroupe();
    if ($groupe == null) {
        echo "Erreur enregistrement de devoir : Pas de groupe associé au devoir";
        die;
    }
    if (!$groupe->belongsTo($utilisateur)) {
        echo "Erreur edition de compte rendu : le groupe n'appartient pas au professeur";
        die;
    }
}
//si pas  du compte rendu trouvé, récupération du groupe dans la requete et création d'un nouvel objet CahierTexteCompteRendu
if ($ctTravailAFaire == null) {
    $groupe = GroupePeer::retrieveByPK($id_groupe);
    if ($groupe == null) {
	/**
	 * 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 = CahierTexteTravailAFairePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setIdCt($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setDateCt($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setContenu($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setVise($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setIdGroupe($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setIdLogin($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setIdSequence($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setDateVisibiliteEleve($arr[$keys[7]]);
	}
Example #3
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;
	}
Example #4
0
require_once "../lib/initialisationsPropel.inc.php";
require_once "../lib/initialisations.inc.php";
$utilisateur = UtilisateurProfessionnelPeer::getUtilisateursSessionEnCours();
if ($utilisateur == null) {
    header("Location: ../logout.php?auto=1");
    die;
}
check_token();
//récupération des paramètres de la requète
$id_ct = isset($_POST["id_ct"]) ? $_POST["id_ct"] : (isset($_GET["id_ct"]) ? $_GET["id_ct"] : NULL);
$date_duplication = isset($_POST["date_duplication"]) ? $_POST["date_duplication"] : (isset($_GET["date_duplication"]) ? $_GET["date_duplication"] : NULL);
$id_groupe = isset($_POST["id_groupe_duplication"]) ? $_POST["id_groupe_duplication"] : (isset($_GET["id_groupe_duplication"]) ? $_GET["id_groupe_duplication"] : NULL);
$type = isset($_POST["type"]) ? $_POST["type"] : (isset($_GET["type"]) ? $_GET["type"] : NULL);
$ctCompteRendu = null;
if ($type == 'CahierTexteTravailAFaire') {
    $ctCompteRendu = CahierTexteTravailAFairePeer::retrieveByPK($id_ct);
} elseif ($type == 'CahierTexteCompteRendu') {
    $ctCompteRendu = CahierTexteCompteRenduPeer::retrieveByPK($id_ct);
} elseif ($type == 'CahierTexteNoticePrivee') {
    $ctCompteRendu = CahierTexteNoticePriveePeer::retrieveByPK($id_ct);
}
if ($ctCompteRendu == null) {
    echo "Erreur duplacation denotice : pas de notice trouvée.";
    die;
}
$groupe = GroupePeer::retrieveByPK($id_groupe);
if ($groupe == null) {
    echo "Pas de groupe spécifié";
    die;
}
$deepcopy = 1;
	/**
	 * 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(CahierTexteTravailAFairePeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria(CahierTexteTravailAFairePeer::DATABASE_NAME);
			$criteria->add(CahierTexteTravailAFairePeer::ID_CT, $pks, Criteria::IN);
			$objs = CahierTexteTravailAFairePeer::doSelect($criteria, $con);
		}
		return $objs;
	}
	/**
	 * Selects a collection of CahierTexteTravailAFaireFichierJoint 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 CahierTexteTravailAFaireFichierJoint 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);
		}

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

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

		$criteria->addJoin(CahierTexteTravailAFaireFichierJointPeer::ID_CT_DEVOIR, CahierTexteTravailAFairePeer::ID_CT, $join_behavior);

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

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = CahierTexteTravailAFaireFichierJointPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = CahierTexteTravailAFaireFichierJointPeer::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 = CahierTexteTravailAFaireFichierJointPeer::getOMClass(false);

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

			// Add objects for joined CahierTexteTravailAFaire rows

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

					$cls = CahierTexteTravailAFairePeer::getOMClass(false);

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

				// Add the $obj1 (CahierTexteTravailAFaireFichierJoint) to the collection in $obj2 (CahierTexteTravailAFaire)
				$obj2->addCahierTexteTravailAFaireFichierJoint($obj1);
			} // if joined row not null

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}
	/**
	 * 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();
	}
	/**
	 * 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    CahierTexteTravailAFaire A model object, or null if the key is not found
	 */
	protected function findPkSimple($key, $con)
	{
		$sql = 'SELECT ID_CT, DATE_CT, CONTENU, VISE, ID_GROUPE, ID_LOGIN, ID_SEQUENCE, DATE_VISIBILITE_ELEVE FROM ct_devoirs_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 CahierTexteTravailAFaire();
			$obj->hydrate($row);
			CahierTexteTravailAFairePeer::addInstanceToPool($obj, (string) $key);
		}
		$stmt->closeCursor();

		return $obj;
	}
	/**
	 * 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();
	}
Example #10
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();