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'
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'workshopcom.before_datacheck', array('data' => $table)), $table);
$table = $r->getReturnValue();
if (strlen($table[0]) < 3) return _t('workshop','com_no_subject');
if (strlen($table[1]) < 10) return _t('workshop','com_no_body');
// we check if user id is numeric and belongs to the workgroup
// test to prevent SQL error if provided ID is wrong (can happen with TextBoxList js plugin
if(!is_numeric($table[3])) return _t('workshop','author_not_allowed');
$q = "SELECT * FROM l21_j_work_users where jwu_user_id = ". $table[3]. " AND jwu_workshop_id =". $table[4]. ";";
$r = $sql_object->DBSelect($q);
if(!isset ($r[0]['jwu_id'])) return _t('workshop','author_not_allowed');
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'workshopcom.after_datacheck', array('data' => $table)));
* 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)
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'workshopcom.before_add', array('data' => $table_com)), $table_com);
$table_com = $r->getReturnValue();
$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) {
$q = "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 ($q, 1);
$q_root = "UPDATE " . $this->TDB_COM . " SET workcom_last_modify=NOW() WHERE workcom_id=" . $this->PARENT_ID . ";";
$result_root = $sql_object->DBQuery($q_root);
$q = "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 ($q, 1);
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'workshopcom.after_add', array('data' => $table_com, 'id' => $last_id)));
* 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)
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'workshopcom.delete', array('id' => $ID, 'comid' => $com_id, 'parentid' => $parent_id)));
$q_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($q_son);
$q = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($q);
for($i = 0; $i < count($result_son); $i++ ) {
$q_son_e = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=" . $result_son[$i]['workcom_id'] . ";";
$result_son_e = $sql_object->DBQuery ($q_son_e);
$q = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($q);
$q = "UPDATE " . $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($q);
* 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)
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'workshopcom.lock', array('id' => $ID, 'comid' => $com_id, 'parentid' => $parent_id, 'lock' => $lock)));
if ($lock == 0) $statut = 'C';
$q_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($q_son);
$q = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($q);
for($i = 0; $i < count($result_son); $i++ ) {
$q_son_e = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=" . $result_son[$i]['workcom_id'] . ";";
$result_son_e = $sql_object->DBQuery ($q_son_e);
$q = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($q);
$q = "UPDATE " . $this->TDB_COM . " SET workcom_statut='" . $statut . "' WHERE workcom_id=$com_id;";
$result = $sql_object->DBQuery ($q);
* 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)
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'workshopcom.before_modify', array('data' => $table_com, 'id' => $ID)), $table_com);
$table_com = $r->getReturnValue();
$table_com= $sql_object->DBescape($table_com);
if ($table_com[0] != '') {
if ($table_com[1] != '') {
$q = "UPDATE " . $this->TDB_COM . " SET workcom_subject='" . $this->SUBJECT . "', workcom_body='" . $this->BODY . "', workcom_user_id=" . $this->USER_ID . " , workcom_last_modify=NOW() WHERE workcom_id=" . $ID . ";";
$result = $sql_object->DBQuery($q);
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'workshopcom.after_modify', array('data' => $table_com, 'id' => $ID)));
* 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
function ModifyComUser($ID, $table_com, $user_id, $sql_object, $hasrights)
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'workshopcom.before_modify_auth', array('data' => $table_com, 'id' => $ID, 'user_id' => $user_id)), $table_com);
$table_com = $r->getReturnValue();
$table_com= $sql_object->DBescape($table_com);
if ($table_com[0] != '') {
if ($table_com[1] != '') {
$result_user = $this->_getUserId($ID, $sql_object);
if ($result_user != $user_id && $hasrights == false) {
$result = _t('workshop','not_author');
$q = "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($q);
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'workshopcom.after_modify_auth', array('data' => $table_com, 'id' => $ID, 'user_id' => $user_id, 'is_admin' => $isadmin)));
* workshop_com::_getUserId()
* obtention de l'id d'un auteur de message
* @param object $sql_object
* @return id_utilisateur $result[0]['workcom_user_id']
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'workshopcom.get_userid', array('id' => $mes_id)));
$q = "SELECT workcom_user_id FROM " . $this->TDB_COM . " WHERE workcom_id=" . $mes_id . ";";
$result = $sql_object->DBSelect($q);
return $result[0]['workcom_user_id'];
|