Ejemplo n.º 1
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;
	}
Ejemplo n.º 2
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 notice_privee
$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 notice_privee passé en paramètre, on récupère la date du jour pour se caler dessus, sinon on prendra la date du notice_privee
$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);
$cahierTexteNoticePrivee = CahierTexteNoticePriveePeer::retrieveByPK($id_ct);
if ($cahierTexteNoticePrivee != null) {
    $groupe = $cahierTexteNoticePrivee->getGroupe();
    $today = $cahierTexteNoticePrivee->getDateCt();
} else {
    //si pas de notice précisé, 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
    //pas de notices, on lance une création de notice
    $id_groupe = isset($_POST["id_groupe"]) ? $_POST["id_groupe"] : (isset($_GET["id_groupe"]) ? $_GET["id_groupe"] : NULL);
    $groupe = GroupePeer::retrieveByPK($id_groupe);
    if ($groupe == null) {
        echo "Erreur edition de notice privee : pas de groupe spécifié";
        die;
    }
    // Vérification : est-ce que l'utilisateur a le droit de travailler sur ce groupe ?
    if (!$groupe->belongsTo($utilisateur)) {
        echo "Erreur edition de notice privee : le groupe n'appartient pas au professeur";
	/**
	 * 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(CahierTexteNoticePriveePeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria(CahierTexteNoticePriveePeer::DATABASE_NAME);
			$criteria->add(CahierTexteNoticePriveePeer::ID_CT, $pks, Criteria::IN);
			$objs = CahierTexteNoticePriveePeer::doSelect($criteria, $con);
		}
		return $objs;
	}
Ejemplo n.º 4
0
    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;
$nouveauCompteRendu = $ctCompteRendu->copy($deepcopy);
$nouveauCompteRendu->setGroupe($groupe);
$nouveauCompteRendu->setDateCt($date_duplication);
$nouveauCompteRendu->save();
	/**
	 * 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    CahierTexteNoticePrivee 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, ID_GROUPE, ID_LOGIN, ID_SEQUENCE FROM ct_private_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 CahierTexteNoticePrivee();
			$obj->hydrate($row);
			CahierTexteNoticePriveePeer::addInstanceToPool($obj, (string) $key);
		}
		$stmt->closeCursor();

		return $obj;
	}
Ejemplo n.º 6
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();
	}
Ejemplo n.º 8
0
function affiche_toutes_notices_privees_groupe($id_groupe)
{
    $retour = "";
    $tab_champs = array('classes');
    $current_group = get_group($id_groupe, $tab_champs);
    $info_groupe = $current_group['name'] . " (<em>" . $current_group['description'] . "</em>) en " . $current_group['classlist_string'];
    $sql = "SELECT * FROM ct_private_entry WHERE id_groupe='{$id_groupe}' AND contenu != ''\n\t\t\t\tAND date_ct != ''\n\t\t\t\tORDER BY date_ct;";
    //echo "$sql<br />\n";
    $res = mysqli_query($GLOBALS["mysqli"], $sql);
    if (mysqli_num_rows($res) > 0) {
        $id_ct_np_prec = "";
        while ($lig = mysqli_fetch_object($res)) {
            $notice_privee = CahierTexteNoticePriveePeer::retrieveByPK($lig->id_ct);
            //$retour.="<div style='border: 1px solid black; margin: 0.5em; background-color:".$couleur_cellule['p']."'>\n";
            $retour .= "<a name='liste_NP_notice_privee_" . $lig->id_ct . "'></a>\n";
            $retour .= "<div style='border: 1px solid black; margin: 0.5em; margin-left:25px; background-color: #f6f3a8'>\n";
            $retour .= "<div style='float: right; width: 4em; margin-right: 2em;'>" . date_from_timestamp($lig->date_ct) . "</div>\n";
            if (my_strtoupper($lig->id_login) == my_strtoupper($_SESSION['login'])) {
                $retour .= '<div style="margin: 0px; float: left;">';
                $retour .= "<a href=\"#\" onclick=\"javascript:\n\t\t\t\t\t\tid_groupe = '" . $lig->id_groupe . "';\n\t\t\t\t\t\tgetWinEditionNotice().setAjaxContent('ajax_edition_notice_privee.php?id_ct=" . $lig->id_ct . "',{ onComplete: function() {\tinitWysiwyg();}});\n\t\t\t\t\t\tupdateCalendarWithUnixDate(" . $lig->date_ct . ");\n\t\t\t\t\t\tgetWinListeNotices();\n\t\t\t\t\t\tnew Ajax.Updater('affichage_liste_notice', './ajax_affichages_liste_notices.php?id_groupe=" . $lig->id_groupe . "',{ onComplete:function() {updateDivModification();}});\n\t\t\t\t\t\tobject_en_cours_edition = 'notice_privee';\n\t\t\t\t\t";
                $retour .= "\">";
                $retour .= "<img style=\"border: 0px;\" src=\"../images/edit16.png\" alt=\"modifier\" title=\"modifier\" /></a>\n";
                $retour .= " ";
                if ($notice_privee != null) {
                    $retour .= "<a href=\"#\" onclick=\"javascript:\n\t\t\t\t\t\t\tcontenu_a_copier = '" . addslashes(htmlspecialchars($lig->contenu)) . "';\n\t\t\t\t\t\t\tct_a_importer_class='" . get_class($notice_privee) . "';\n\t\t\t\t\t\t\tid_ct_a_importer='" . $lig->id_ct . "';\n\t\t\t\t\t\t\tnew Ajax.Updater('affichage_liste_notice', './ajax_affichages_liste_notices.php?id_groupe=" . $lig->id_groupe . "&ct_a_importer_class=" . get_class($notice_privee) . "&id_ct_a_importer=" . $lig->id_ct . "',{ onComplete:function() {updateDivModification();} });\n\t\t\t\t\t\t\tgetWinListeNoticesPrivees().setAjaxContent('./ajax_liste_notices_privees.php?id_groupe=" . $lig->id_groupe . "&today=all#liste_NP_notice_privee_" . $id_ct_np_prec . "');\n\t\t\t\t\t\t\t\"><img style=\"border: 0px;\" src=\"";
                    if (isset($_SESSION['ct_a_importer']) && $_SESSION['ct_a_importer'] == $notice_privee) {
                        $retour .= "../images/icons/copy-16-gold.png";
                    } else {
                        $retour .= "../images/icons/copy-16.png";
                    }
                    $retour .= "\" alt=\"Copier\" title=\"Copier\" /></a>\n";
                }
                $retour .= " ";
                $retour .= "<a href=\"#\" onclick=\"javascript:\n\t\t\t\t\tsuppressionNoticePrivee('" . strftime("%A %d %B %Y", $lig->date_ct) . "','" . $lig->id_ct . "', '" . $lig->id_groupe . "','" . add_token_in_js_func() . "');\n\t\t\t\t\tnew Ajax.Updater('affichage_derniere_notice', 'ajax_affichage_dernieres_notices.php', {onComplete : function () {updateDivModification();}});\n\t\t\t\t\tgetWinListeNoticesPrivees().setAjaxContent('./ajax_liste_notices_privees.php?id_groupe=" . $lig->id_groupe . "&today=all#liste_NP_notice_privee_" . $id_ct_np_prec . "');\n\t\t\t\t\treturn false;\n\t\t\t\t\t\"><img style=\"border: 0px;\" src=\"../images/delete16.png\" alt=\"supprimer\" title=\"supprimer\" /></a>\n";
                $retour .= '</div>';
            }
            $retour .= $lig->contenu;
            $retour .= "</div>\n";
            $id_ct_np_prec = $lig->id_ct;
        }
    } else {
        $retour .= "Aucune Notice Privée pour cet enseignement (" . $info_groupe . ").";
    }
    return $retour;
}
Ejemplo n.º 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();
Ejemplo n.º 10
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 = CahierTexteNoticePriveePeer::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->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]]);
	}