コード例 #1
0
ファイル: BaseEdtSemaineQuery.php プロジェクト: rhertzog/lcs
	/**
	 * Returns a new EdtSemaineQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    EdtSemaineQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof EdtSemaineQuery) {
			return $criteria;
		}
		$query = new EdtSemaineQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}
コード例 #2
0
ファイル: saisir_groupe_plan.php プロジェクト: rhertzog/lcs
				continue;
			}
			if (getSettingValue("abs2_saisie_prof_decale") != 'y' && $utilisateur->getStatut() == "professeur") {
				if ($edt_cours->getJourSemaineNumeric() != date('w')) {
				//on affiche pas ce cours car il n'est pas aujourd'hui
				continue;
				}
				if ($edt_cours->getTypeSemaine() != '' && $edt_cours->getTypeSemaine() != '0' && $edt_cours->getTypeSemaine() != $current_semaine->getTypeEdtSemaine()) {
				//on affiche pas ce cours car il n'est pas aujourd'hui
				continue;
				}
			}
		}

		if (getSettingValue("abs2_saisie_prof_decale")=='y' || $utilisateur->getStatut() != "professeur") {
			$col = EdtSemaineQuery::create()->find();
			$semaineAff = new PropelCollection();
			//on va commencer la liste à la semaine 31 (milieu des vacances d'ete)
			for ($i = 0; $i < $col->count(); $i++) {
				$pos = ($i + 30) % $col->count();
				$semaine = $col[$pos];
				$semaineAff->append($col[$pos]);
			}
		} else {
			$semaineAff = new PropelCollection();
				$semaineAff->append($current_semaine);
		}

		if ($current_cours != null && $current_cours->getTypeSemaine() != '' && $current_cours->getTypeSemaine() != '0' && $current_semaine != null && $current_cours->getTypeSemaine() != $current_semaine->getTypeEdtSemaine()) {
			$erreurSemaine=TRUE;
			$current_cours = null;
コード例 #3
0
	 	/**
	 *
	 * Renvoi la collection de cours qui correspond à l'heure donnée
	 *
	 * @param      PropelObjectCollection $edtEmplacementCours La collection d'emplacement de cours
	 * @return     PropelObjectCollection $edtEmplacementCours Un collection ordonnés d'emplacement de cours
	 * @throws     PropelException - si les types d'entrées ne sont pas bon.
	 */
	public static function getColEdtEmplacementCoursActuel(PropelObjectCollection $edtEmplacementCoursCol, $v = 'now') {
	    // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
	    // -- which is unexpected, to say the least.
	    //$dt = new DateTime();
	    if ($v === null || $v === '') {
		    $dt = null;
	    } elseif ($v instanceof DateTime) {
		    $dt = clone $v;
	    } else {
		    // some string/numeric value passed; we normalize that so that we can
		    // validate it.
		    try {
			    if (is_numeric($v)) { // if it's a unix timestamp
				    $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
				    // We have to explicitly specify and then change the time zone because of a
				    // DateTime bug: http://bugs.php.net/bug.php?id=43003
				    $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
			    } else {
				    $dt = new DateTime($v);
			    }
		    } catch (Exception $x) {
			    throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
		    }
	    }
	    
	    $result = new PropelObjectCollection();
	    
	    $num_semaine = $dt->format('W');
	    $edtSemaine = EdtSemaineQuery::create()->filterByNumEdtSemaine($num_semaine)->findOne();
	    if ($edtSemaine == null) {
		$type_semaine = '';
	    } else {
		$type_semaine = $edtSemaine->getTypeEdtSemaine();
	    }

	    // On traduit le nom du jour
	    $semaine_declaration = array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi");
	    $jour_semaine = $semaine_declaration[$dt->format("w")];

	    $timeStampNow = strtotime($dt->format('H:i:s'));
	    foreach ($edtEmplacementCoursCol as $edtCours) {
		if ($jour_semaine == $edtCours->getJourSemaine() &&
		    ($type_semaine == $edtCours->getTypeSemaine()
			|| $edtCours->getTypeSemaine() == ''
			|| $edtCours->getTypeSemaine() == '0'
			|| $edtCours->getTypeSemaine() === 0
			)) {
		    if ($edtCours->getEdtCreneau() != null && strtotime($edtCours->getHeureDebut()) <= $timeStampNow &&
			$timeStampNow < strtotime($edtCours->getHeureFin())) {
			$result->add($edtCours);
		    }
		}
	    }

	    return $result;
	}
コード例 #4
0
ファイル: BaseEdtSemaine.php プロジェクト: rhertzog/lcs
	/**
	 * Removes this object from datastore and sets delete attribute.
	 *
	 * @param      PropelPDO $con
	 * @return     void
	 * @throws     PropelException
	 * @see        BaseObject::setDeleted()
	 * @see        BaseObject::isDeleted()
	 */
	public function delete(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(EdtSemainePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		$con->beginTransaction();
		try {
			$deleteQuery = EdtSemaineQuery::create()
				->filterByPrimaryKey($this->getPrimaryKey());
			$ret = $this->preDelete($con);
			if ($ret) {
				$deleteQuery->delete($con);
				$this->postDelete($con);
				$con->commit();
				$this->setDeleted(true);
			} else {
				$con->commit();
			}
		} catch (Exception $e) {
			$con->rollBack();
			throw $e;
		}
	}