Source for file class.publication.php
Documentation is available at class.publication.php
* @package linea21.modules
* @subpackage publication
* @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, 'publication.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();
* publication::CheckDataIntegrity()
* Vérification intégrité des données
* @param array $table : contient les composants d'une publication
* si verifié, sinon string 'message d'erreur'
if (strlen($table[0]) < 3) return _t('publication','no_title');
if (strlen($table[1]) < 3) return _t('publication','no_resume');
if ($table[2] == - 1) return _t('publication','no_theme');
if ($table[3] == - 1) return _t('publication','no_scale');
if (strlen(trim($table[5])) < 2) return _t('publication','no_author');
$result = $this->_CheckUserValidity($table[5], $sql_object);
if (!is_numeric($result['user_id'])) return _t('publication','author_not_valid');
if ($result['publi_right'] == 'U') return _t('publication','author_not_rights');
* publication::_CheckUserValidity()
* Vérification validité de l'utilisateur
* @param object $sql_object
* @return array contenant $user_id et droit si login associé au workshop
function _CheckUserValidity($login, $sql_object)
$user = array('user_id' => '', 'publi_right' => '');
$requete = "SELECT user_id, rights_publication FROM " . T_USER . " LEFT OUTER JOIN " . T_RIGHT . " ON user_rights=rights_id WHERE user_login= '" . $login . "' AND user_validity='Y';";
$result = $sql_object->DBSelect($requete);
if ($result == 0) return false;
if (count($result) > 1) exit();
$user['user_id'] = $result[0]['user_id'];
$user['publi_right'] = $result[0]['rights_publication'];
* publication::AddPublication()
* Ajout d'une nouvelle publication/dossier
* @param array $table_publi contient les composants d'une publication
* @param object $sql_object
* @return integer $last_id
$table_publi= $sql_object->DBescape($table_publi);
if($table_publi[4] == - 1) $table_publi[4]= 0;
$this->THEME = $table_publi[2];
$this->SCALE = $table_publi[3];
$this->LEVEL = $table_publi[4];
if ($table_publi[7] != '') {
$requete = "INSERT INTO " . $this->TDB_PUBLI . " (publi_title, publi_resume, publi_theme, publi_scale, publi_level, publi_posted_by, publi_published_date, publi_comment, publi_statut, publi_date_crea) VALUES('" . $this->TITLE . "', '" . $this->RESUME . "', " . $this->THEME . ", " . $this->SCALE . ", " . $this->LEVEL . ", " . $this->POSTED_BY . ", " . $this->PUBLISHED_DATE . ", '" . $this->COMMENT . "', '" . $this->STATUT . "', NOW());";
$last_id = $sql_object->DBInsert ($requete, 1);
* publication::ModifyPublication()
* modification d'une publication
* @param int $ID identifiant de la publication
* @param array $table_publi contient les composants d'une publication
* @param object $sql_object
$table_publi= $sql_object->DBescape($table_publi);
if($table_publi[4] == - 1) $table_publi[4]= 0;
$this->THEME = $table_publi[2];
$this->SCALE = $table_publi[3];
$this->LEVEL = $table_publi[4];
$this->STATUT = $table_publi[7];
$mask = $this->_HavePublishedDate($table_publi[8]);
$requete = "UPDATE " . $this->TDB_PUBLI . " set publi_title='" . $this->TITLE . "', publi_resume='" . $this->RESUME . "' , publi_theme='" . $this->THEME . "', publi_scale='" . $this->SCALE . "', publi_level='" . $this->LEVEL . "', publi_comment='" . $this->COMMENT . "', publi_posted_by='" . $this->POSTED_BY . "', publi_last_modify=NOW(), publi_statut='" . $this->STATUT . "'" . $mask . " WHERE publi_id='" . $this->ID . "';";
$result = $sql_object->DBQuery($requete);
* publication::changeRanges()
* @param array : Id (key) and ranges (value)
* @param object $sql_object
foreach ($array as $key => $value) {
$query = "UPDATE " . $this->TDB_PUBLI . " set publi_range='". $value. "' WHERE publi_id='" . $key . "';";
$result = $sql_object->DBQuery($query);
* publication::_HavePublishedDate()
* Détermine la date de publication a inserer dans la bdd
* @param string $current_status : statut actuel de la publication
* @return string $sql_mask
function _HavePublishedDate($current_status)
if ($current_status == 'D') $sql_mask = ", publi_published_date= NOW()";
$sql_mask = ", publi_published_date= '0001-01-01'";
* publication::DeletePublication()
* suppression d'une publication
* @param int $ID identifiant de la publication a supprimer
* @param object $sql_object
$requete = "UPDATE " . $this->TDB_PUBLI . " set publi_statut='E', publi_last_modify=NOW() WHERE publi_id=" . $this->ID . ";";
$result = $sql_object->DBQuery($requete);
|