Source for file class.workshop_com.php
Documentation is available at class.workshop_com.php
* @package linea21.modules
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
* Workgroup Forum Management
var $TDB_COM = T_WORK_COM; // nom de la table.
public function __call($method, $arguments)
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'workshop_com.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_com::CheckDataIntegrity()
* Vérification intégrité des données
* @param array $table contient les composants d'une discussion
* si verifié, sinon string 'message d'erreur'
if (strlen($table[0]) < 3) return _t('workshop','com_no_subject');
if (strlen($table[1]) < 10) return _t('workshop','com_no_body');
* Ajout d'une nouvelle discussion
* @param array $table_com : contient les composants d'une discussion
* @param object $sql_object
* @return integer $last_id
function AddCom($table_com, $sql_object)
$table_com= $sql_object->DBescape($table_com);
if ($table_com[2] != '') {
$this->PARENT_ID = $table_com[2];
} else $this->PARENT_ID = 0;
if ($this->PARENT_ID == 0) {
$requete = "INSERT INTO " . $this->TDB_COM . " (workcom_subject, workcom_body, workcom_parent, workcom_user_id, workcom_workshop_id, workcom_statut, workcom_date_crea, workcom_last_modify ) " . "VALUES('" . $this->SUBJECT . "', '" . $this->BODY . "', " . $this->PARENT_ID . ", " . $this->USER_ID . ", " . $this->WORKSHOP_ID . ", '" . $this->STATUT . "', NOW(), NOW());";
$last_id = $sql_object->DBInsert ($requete, 1);
$requete_root = "UPDATE " . $this->TDB_COM . " SET workcom_last_modify=NOW() WHERE workcom_id=" . $this->PARENT_ID . ";";
$result_root = $sql_object->DBQuery($requete_root);
$requete = "INSERT INTO " . $this->TDB_COM . " (workcom_subject, workcom_body, workcom_parent, workcom_user_id, workcom_workshop_id, workcom_statut, workcom_date_crea, workcom_last_modify ) " . "VALUES('" . $this->SUBJECT . "', '" . $this->BODY . "', " . $this->PARENT_ID . ", " . $this->USER_ID . ", " . $this->WORKSHOP_ID . ", '" . $this->STATUT . "', NOW(), NOW());";
$last_id = $sql_object->DBInsert ($requete, 1);
* workshop_com::DeleteCom()
* suppression d'un message
* @param int $com_id identifiant du message
* @param int $parent_id identifiant du parent
* @param object $sql_object
function DeleteCom($ID, $com_id, $parent_id, $sql_object)
$requete_son = "SELECT workcom_id FROM " . $this->TDB_COM . " WHERE workcom_statut <> 'E' AND workcom_parent=$com_id AND workcom_workshop_id=$ID";
$result_son = $sql_object->DBSelect($requete_son);
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($requete);
for($i = 0; $i < count($result_son); $i++ ) {
$requete_son_e = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=" . $result_son[$i]['workcom_id'] . ";";
$result_son_e = $sql_object->DBQuery ($requete_son_e);
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($requete);
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($requete);
* workshop_com::LockCom()
* vérouillage d'un message
* @param int $ID identifiant du workshop
* @param int $com_id identifiant du message
* @param int $parent_id identifiant du message parent
* @param object $sql_object
function LockCom($ID, $com_id, $parent_id, $lock, $sql_object)
if ($lock == 0) $statut = 'C';
$requete_son = "SELECT workcom_id FROM " . $this->TDB_COM . " WHERE workcom_statut <> 'E' AND workcom_parent=$com_id AND workcom_workshop_id=$ID";
$result_son = $sql_object->DBSelect($requete_son);
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($requete);
for($i = 0; $i < count($result_son); $i++ ) {
$requete_son_e = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=" . $result_son[$i]['workcom_id'] . ";";
$result_son_e = $sql_object->DBQuery ($requete_son_e);
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($requete);
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($requete);
* workshop_com::ModifyCom()
* modification d'un message
* @param int $ID identifiant du message
* @param array $table_com contient les composants d'un message
* @param object $sql_object
function ModifyCom($ID, $table_com, $sql_object)
$table_com= $sql_object->DBescape($table_com);
if ($table_com[0] != '') {
if ($table_com[1] != '') {
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_subject='" . $this->SUBJECT . "', workcom_body='" . $this->BODY . "' , workcom_last_modify=NOW() WHERE workcom_id=" . $ID . ";";
$result = $sql_object->DBQuery($requete);
* workshop_com::ModifyComUser()
* modification d'un message utilisateur authentifié
* @param int $ID identifiant du message
* @param array $table_com contient les composants d'un message
* @param int $user_id identifiant de l'utilisateur
* @param object $sql_object
$table_com= $sql_object->DBescape($table_com);
if ($table_com[0] != '') {
if ($table_com[1] != '') {
$result_user = $this->_CheckUser($sql_object, $ID);
if ($result_user <> $user_id) {
$result = _t('workshop','not_author');
$requete = "UPDATE " . $this->TDB_COM . " SET workcom_subject='" . $this->SUBJECT . "', workcom_body='" . $this->BODY . "' , workcom_last_modify=NOW() WHERE workcom_id=" . $ID . ";";
$result = $sql_object->DBQuery($requete);
* workshop_com::_CheckUser()
* obtention de l'id d'un auteur de message
* @param object $sql_object
* @return id_utilisateur $result[0]['workcom_user_id']
$requete = "SELECT workcom_user_id FROM " . $this->TDB_COM . " WHERE workcom_id=" . $mes_id . ";";
$result = $sql_object->DBSelect($requete);
return $result[0]['workcom_user_id'];
|