Source for file class.workshop.php
Documentation is available at class.workshop.php
* @package linea21.modules
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
public function __call($method, $arguments)
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'workshop.extensible_function', array(
'arguments' => $arguments
if (!$event->isProcessed())
throw new Exception(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
return $event->getReturnValue();
* workshop::CheckDataIntegrity()
* Vérification intégrité des données
* @param array $table contient les composants d'un groupe de travail
* si verifié, sinon string 'message d'erreur'
if (strlen($table[0]) < 3) return _t('workshop','no_title');
if (strlen($table[1]) < 3) return _t('workshop','no_resume');
if ($table[2] == - 1) return _t('workshop','no_theme');
if (substr($table[6], - 1) == ',') {
$table[6] = substr($table[6], 0, - 1);
$table_organizer = @explode(',', $table[6]);
for ($i = 0;$i < count($table_organizer);$i++ ) {
$table_organizer[$i] = trim($table_organizer[$i]);
if (strlen(trim($table_organizer[$i])) < 2) $return = _t('workshop','no_author');
$result = $this->_CheckUserValidity($table_organizer[$i], $sql_object);
if (!is_numeric($result)) $return = _t('workshop','author_not_valid') . " : " . $table_organizer[$i];
$result_admin = $this->_CheckAdmin($sql_object, - 1, $table_organizer[$i]);
if ($result_admin == false) $return = _t('workshop','author_not_admin') . " : " . $table_organizer[$i];
* workshop::_CheckAdmin()
* Vérification droits d'utilisation avancé Admin ou Animateur
* @param object $sql_object
* @return integer $user_id (option)
* @param string $user_login (option)
* @return integer id de l'utilisateur si verifié, sinon false
function _CheckAdmin($sql_object, $user_id = - 1, $user_login = - 1)
$requete = "SELECT rights_workshop, U.user_id FROM " . T_USER . " AS U LEFT OUTER JOIN " . T_RIGHT . " AS R on U.user_rights=R.rights_id WHERE user_id='" . $user_id . "' AND user_validity='Y';";
$requete = "SELECT rights_workshop, U.user_id FROM " . T_USER . " AS U LEFT OUTER JOIN " . T_RIGHT . " AS R on U.user_rights=R.rights_id WHERE lower(user_login)= '" . strtolower($user_login) . "' AND user_validity='Y';";
$result = $sql_object->DBSelect($requete);
if ($result[0]['rights_workshop'] == 'A' || $result[0]['rights_workshop'] == 'O') return $result[0]['user_id'];
* workshop::_CheckUserValidity()
* Vérification validité de l'utilisateur
* @param object $sql_object
* @return integer si $login existe
function _CheckUserValidity($login, $sql_object)
$requete = "SELECT user_id FROM " . T_USER . " WHERE lower(user_login)= '" . strtolower($login) . "' AND user_validity='Y';";
$result = $sql_object->DBSelect($requete);
if ($result == 0) return false;
if (count($result) > 1) exit();
else return (int) $result[0]['user_id'];
* workshop::CheckUsersIntegrity()
* Vérification pour ajout d'utilisateurs
* @param object $sql_object
if (strlen(trim($logins)) < 2) return _t('workshop','no_author');
if (substr($logins, - 1) == ',') {
$logins = substr($logins, 0, - 1);
foreach ($users as $user) {
$result = $this->_CheckUserValidity($user, $sql_object);
if ($result== false) return _t('workshop','author_not_valid') . " : " . $user;
// check if user has rights enough
$result = $this->_CheckAdmin($sql_object, - 1, $user);
if ($result == false) return _t('workshop','author_not_admin') . " : " . $user;
// check if user is already member of the workgroup
$q = "SELECT user_id FROM " . T_USER . " WHERE lower(user_login)= '" . strtolower($user) . "' AND user_validity='Y';";
$data = $sql_object->DBSelect($q);
$q = "SELECT COUNT(jwu_id) AS nb FROM " . J_WORK_USERS . " WHERE jwu_user_id=" . $data[0]['user_id'] . " AND jwu_workshop_id=" . $id . ";";
$data = $sql_object->DBSelect($q, 'OBJECT');
if ($data[0]->nb != 0) return _t('workshop','yet_author') . " : " . $user;
* workshop::AddWorkshop()
* Ajout d'un groupe de travail
* @param array $table_workshop contient les composants d'un workshop
* @param object $sql_object
* @return integer $last_id
$table_workshop= $sql_object->DBescape($table_workshop);
if($table_workshop[4] == - 1) $table_workshop[4]= 0;
$this->THEME = $table_workshop[2];
$this->LEVEL = $table_workshop[4];
$this->STATUT = $table_workshop[5];
$requete = "INSERT INTO " . $this->TDB_WORKSHOP . " (workshop_denomination, workshop_resume, workshop_theme, workshop_comment, workshop_level, workshop_statut, workshop_date_crea) VALUES('" . $this->DENOMINATION . "', '" . $this->RESUME . "', " . $this->THEME . ", '" . $this->COMMENT . "', " . $this->LEVEL . ", '" . $this->STATUT . "', NOW());";
$last_id = $sql_object->DBInsert ($requete, 1);
* workshop::ModifyWorkshop()
* modification d'un workshop
* @param int $ID identifiant d'un workshop
* @param array $table_workshop contient les composants d'un workshop
* @param object $sql_object
$table_workshop= $sql_object->DBescape($table_workshop);
if($table_workshop[4] == - 1) $table_workshop[4]= 0;
$this->THEME = $table_workshop[2];
$this->LEVEL = $table_workshop[4];
$requete = "UPDATE " . $this->TDB_WORKSHOP . " set workshop_denomination='" . $this->DENOMINATION . "', workshop_resume='" . $this->RESUME . "' , workshop_theme=" . $this->THEME . ", workshop_level=" . $this->LEVEL . ", workshop_comment='" . $this->COMMENT . "' WHERE workshop_id=" . $this->ID . ";";
$result = $sql_object->DBQuery($requete);
* Workshop::changeRanges()
* @param array : Id (key) and ranges (value)
* @param object $sql_object
foreach ($array as $key => $value) {
$query = "UPDATE " . $this->TDB_WORKSHOP . " set workshop_range='". $value. "' WHERE workshop_id='" . $key . "';";
$result = $sql_object->DBQuery($query);
* modification du statut d'un workshop
* @param int $id identifiant du workshop
* @param string $state (facultatif) 'P' Public/'D' Draft/'AA' AdminArchive/'PA' PublicArchive/'E' Erase
* @param object $sql_object
$requete = "UPDATE " . $this->TDB_WORKSHOP . " set workshop_statut='" . $this->STATUT . "' WHERE workshop_id=" . $this->ID . ";";
$result = $sql_object->DBQuery($requete);
* suppression d'un workshop
* @param int $id identifiant du workshop a supprimer
* @param object $sql_object
* workshop::AddUserWorkshop()
* Ajout d'un ou plusieurs utilisateurs au workshop
* @param int $work_id identifiant du workshop
* @param string $user_login login(s) utilisateur(s)
* @param array $user_right droit confié a l'utilisateur sur le workshop
* @param object $sql_object
* @return integer $last_id
if (substr($user_login, - 1) == ',') {
$user_login = substr($user_login, 0, - 1);
$user_login = @explode(',', $user_login);
for ($i = 0;$i < count($user_login);$i++ ) {
$requete = "SELECT user_id FROM " . T_USER . " WHERE lower(user_login) = '" . strtolower($user_login[$i]) . "' AND user_validity='Y';";
$data = $sql_object->DBSelect($requete);
$user_id = $data[0]['user_id'];
$requete = "INSERT INTO " . J_WORK_USERS . " (jwu_workshop_id, jwu_user_id, jwu_user_right) VALUES(" . $this->ID . ", " . $user_id . ",'" . $user_right . "');";
$last_id = $sql_object->DBInsert ($requete, 1);
* workshop::DeleteUserWorkshop()
* suppression d'un utilisateur au workshop
* @param int $user_id identifiant du workshop
* @param string $work_id login de l'utilisateur
* @param object $sql_object
$requete = "DELETE FROM " . J_WORK_USERS . " WHERE jwu_workshop_id=" . $work_id . " AND jwu_user_id=" . $user_id . ";";
$result = $sql_object->DBQuery($requete);
* workshop::ModifyUserWorkshop()
* modification d'un utilisateur au workshop
* @param int $work_id identifiant du workshop
* @param string $user_login login de l'utilisateur
* @param object $sql_object
$user_id = $this->_CheckUserValidity($user_login, $sql_object);
$requete = "UPDATE " . J_WORK_USERS . " SET jwu_user_id=" . $user_id . " WHERE jwu_user_right='O' AND jwu_workshop_id=" . $work_id . " ;";
$result = $sql_object->DBQuery($requete);
* workshop::ModifyOrganizerWorkshop()
* modification des organisateurs d'un workshop
* @param int $work_id identifiant du workshop
* @param string $table_login string des organisateurs séparés par ','
* @param object $sql_object
if (substr($table_login, - 1) == ',') {
$table_login = substr($table_login, 0, - 1);
$table_login = @explode(',', $table_login);
$requete = "DELETE FROM " . J_WORK_USERS . " WHERE jwu_workshop_id=" . $work_id . " AND jwu_user_right='O';";
$result = $sql_object->DBQuery($requete);
for ($i = 0;$i < count($table_login);$i++ ) {
$user_id = $this->_CheckUserValidity(trim($table_login[$i]), $sql_object);
$requete2 = "DELETE FROM " . J_WORK_USERS . " WHERE jwu_workshop_id=" . $work_id . " AND jwu_user_id=" . $user_id . ";";
$result2 = $sql_object->DBQuery($requete2);
$requete3 = "INSERT INTO " . J_WORK_USERS . " (jwu_workshop_id, jwu_user_id, jwu_user_right) VALUES(" . $work_id . ", " . $user_id . ",'O');";
$last_id = $sql_object->DBInsert ($requete3, 1);
|