Add notifications to feed publications

This commit is contained in:
Romain Neutron
2012-03-09 15:07:18 +01:00
parent b75205a807
commit 8761e04eda
8 changed files with 408 additions and 156 deletions

View File

@@ -141,7 +141,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)
@@ -156,13 +156,13 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
$this->created_on = new DateTime($row['created_on']);
$datas = array(
'title' => $this->title
, 'subtitle' => $this->subtitle
, 'author_name' => $this->author_name
, 'author_email' => $this->author_email
, 'publisher_id' => $this->publisher_id
, 'updated_on' => $this->updated_on
, 'created_on' => $this->created_on
'title' => $this->title
, 'subtitle' => $this->subtitle
, 'author_name' => $this->author_name
, 'author_email' => $this->author_email
, 'publisher_id' => $this->publisher_id
, 'updated_on' => $this->updated_on
, 'created_on' => $this->created_on
);
$this->set_data_to_cache($datas);
@@ -175,9 +175,9 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
$registry = registry::get_instance();
$href = sprintf(
'%slightbox/feeds/entry/%d/'
, $registry->get('GV_ServerName')
, $this->get_id()
'%slightbox/feeds/entry/%d/'
, $registry->get('GV_ServerName')
, $this->get_id()
);
return new Feed_Link($href, $this->get_title(), 'text/html');
@@ -231,10 +231,10 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
if ($title === '')
throw new Exception_InvalidArgument();
$sql = 'UPDATE feed_entries
$sql = 'UPDATE feed_entries
SET title = :title, updated_on = NOW() WHERE id = :entry_id';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':title' => $title, ':entry_id' => $this->get_id()));
$stmt->execute(array(':title' => $title, ':entry_id' => $this->get_id()));
$stmt->closeCursor();
$this->title = $title;
$this->delete_data_from_cache();
@@ -251,11 +251,11 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
{
$subtitle = strip_tags($subtitle);
$sql = 'UPDATE feed_entries
$sql = 'UPDATE feed_entries
SET description = :subtitle, updated_on = NOW()
WHERE id = :entry_id';
$params = array(':subtitle' => $subtitle, ':entry_id' => $this->get_id());
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->subtitle = $subtitle;
@@ -271,14 +271,14 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
*/
public function set_author_name($author_name)
{
$sql = 'UPDATE feed_entries
$sql = 'UPDATE feed_entries
SET author_name = :author_name, updated_on = NOW()
WHERE id = :entry_id';
$params = array(
':author_name' => $author_name,
':entry_id' => $this->get_id()
':author_name' => $author_name,
':entry_id' => $this->get_id()
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->author_name = $author_name;
@@ -294,14 +294,14 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
*/
public function set_author_email($author_email)
{
$sql = 'UPDATE feed_entries
$sql = 'UPDATE feed_entries
SET author_email = :author_email, updated_on = NOW()
WHERE id = :entry_id';
$params = array(
':author_email' => $author_email,
':entry_id' => $this->get_id()
':author_email' => $author_email,
':entry_id' => $this->get_id()
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->author_email = $author_email;
@@ -312,14 +312,14 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
public function set_created_on(DateTime $datetime)
{
$sql = 'UPDATE feed_entries
$sql = 'UPDATE feed_entries
SET created_on = :created_on
WHERE id = :entry_id';
$params = array(
':created_on' => $datetime->format(DATE_ISO8601),
':entry_id' => $this->get_id()
':created_on' => $datetime->format(DATE_ISO8601),
':entry_id' => $this->get_id()
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->created_on = $datetime;
@@ -330,14 +330,14 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
public function set_updated_on(DateTime $datetime)
{
$sql = 'UPDATE feed_entries
$sql = 'UPDATE feed_entries
SET updated_on = :updated_on
WHERE id = :entry_id';
$params = array(
':updated_on' => $datetime->format(DATE_ISO8601),
':entry_id' => $this->get_id()
':updated_on' => $datetime->format(DATE_ISO8601),
':entry_id' => $this->get_id()
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->updated_on = $datetime;
@@ -411,10 +411,9 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
public function get_content()
{
if ($this->items)
return $this->items;
$rs = $this->retrieve_elements();
$rs = $this->retrieve_elements();
$items = array();
foreach ($rs as $item_id)
{
@@ -444,11 +443,11 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
}
$sql = 'SELECT id FROM feed_entry_elements
$sql = 'SELECT id FROM feed_entry_elements
WHERE entry_id = :entry_id ORDER BY ord ASC';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':entry_id' => $this->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$items = array();
@@ -474,7 +473,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
$content->delete();
}
$sql = 'DELETE FROM feed_entries WHERE id = :entry_id';
$sql = 'DELETE FROM feed_entries WHERE id = :entry_id';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':entry_id' => $this->get_id()));
$stmt->closeCursor();
@@ -515,12 +514,12 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
, :description, NOW(), NOW(), :author_name, :author_email)';
$params = array(
':feed_id' => $feed->get_id()
, ':publisher_id' => $publisher->get_id()
, ':title' => trim($title)
, ':description' => trim($subtitle)
, ':author_name' => trim($author_name)
, ':author_email' => trim($author_mail)
':feed_id' => $feed->get_id()
, ':publisher_id' => $publisher->get_id()
, ':title' => trim($title)
, ':description' => trim($subtitle)
, ':author_name' => trim($author_name)
, ':author_email' => trim($author_mail)
);
$stmt = $appbox->get_connection()->prepare($sql);
@@ -531,7 +530,12 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
$feed->delete_data_from_cache();
return new self($appbox, $feed, $entry_id);
$entry = new self($appbox, $feed, $entry_id);
$eventsmanager = \eventsmanager_broker::getInstance($appbox);
$eventsmanager->trigger('__FEED_ENTRY_CREATE__', array('entry_id' => $entry_id), $entry);
return $entry;
}
/**
@@ -542,10 +546,10 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
*/
public static function load_from_id(appbox $appbox, $id)
{
$sql = 'SELECT feed_id FROM feed_entries WHERE id = :entry_id';
$sql = 'SELECT feed_id FROM feed_entries WHERE id = :entry_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':entry_id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)

View File

@@ -21,7 +21,7 @@ class eventsmanager_broker
}
/**
* @return eventsmanager
* @return \eventsmanager_broker
*/
public static function getInstance(appbox &$appbox)
{

View File

@@ -0,0 +1,208 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
{
/**
*
* @var string
*/
public $events = array('__FEED_ENTRY_CREATE__');
/**
*
* @return string
*/
public function icon_url()
{
return '/skins/icons/rss16.png';
}
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return boolean
*/
public function fire($event, $params, &$entry)
{
$params = array(
'entry_id' => $entry->get_id()
);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$entry_id = $dom_xml->createElement('entry_id');
$entry_id->appendChild($dom_xml->createTextNode($params['entry_id']));
$root->appendChild($entry_id);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$Query = new \User_Query($this->appbox);
$Query->include_phantoms(true)->include_invite(false)->include_templates(false);
if ($entry->get_feed()->get_collection())
{
$Query->on_base_ids(array($entry->get_feed()->get_collection()->get_base_id()));
}
$start = 0;
$perLoop = 100;
$from = array(
'email' => $entry->get_author_email(),
'name' => $entry->get_author_name()
);
do
{
$results = $Query->limit($start, $perLoop)->execute()->get_results();
foreach ($results as $user_to_notif)
{
/* @var $user_to_notif \User_Adapter */
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $user_to_notif->get_id()) != '0');
if ($send_notif)
{
$email = array(
'email' => $user_to_notif->get_email(),
'name' => $user_to_notif->get_display_name()
);
$token = \random::getUrlToken(
\random::TYPE_FEED_ENTRY
, $user_to_notif->get_id()
, null
, $entry->get_id()
);
$url = $this->appbox->get_registry()->get('GV_ServerName') . 'lightbox/index.php?LOG=' . $token;
if (self::mail($email, $from, $url, $entry))
$mailed = true;
}
$this->broker->notify($user_to_notif->get_id(), __CLASS__, $datas, $mailed);
}
$start += $perLoop;
}
while (count($results) > 0);
return true;
}
/**
*
* @param Array $datas
* @param boolean $unread
* @return Array
*/
public function datas($datas, $unread)
{
$sx = simplexml_load_string($datas);
try
{
$entry = \Feed_Entry_Adapter::load_from_id($this->appbox, (int) $sx->entry_id);
}
catch (\Exception $e)
{
return array();
}
$ret = array(
'text' => sprintf(
_('%1$s has published %2$s')
, $entry->get_author_name()
, '<a href="/lightbox/feeds/entry/' . $entry->get_id() . '/" target="_blank">' . $entry->get_title() . '</a>'
)
, 'class' => ($unread == 1 ? 'reload_baskets' : '')
);
return $ret;
}
/**
*
* @return string
*/
public function get_name()
{
return _('Feeds');
}
/**
*
* @return string
*/
public function get_description()
{
return _('Recevoir des notifications lorsqu\'on me push quelque chose');
}
/**
*
* @return boolean
*/
function is_available()
{
return true;
}
/**
*
* @param Array $to
* @param Array $from
* @param string $message
* @param string $url
* @param boolean $accuse
* @return boolean
*/
function mail($to, $from, $url, \Feed_Entry_Adapter $entry)
{
$subject = sprintf(_('Nouvelle publication : %s'), $entry->get_title());
$body = "<div>"
. sprintf('%s vient de publier %s', $entry->get_author_name(), $entry->get_title())
. _('Connectez vous a l\'adresse suivante pour la consulter')
. "</div>\n";
$body .= '<div><a href="' . $url . '">' . $url . "</a></div>\n";
$body .= " <br/> ";
$body .= "<br/>\n<br/>\n<br/>\n"
. _('push::atention: ce lien est unique et son contenu confidentiel, ne divulguez pas');
return mail::send_mail($subject, $body, $to, $from, array());
}
}

View File

@@ -72,11 +72,10 @@ class gatekeeper
function check_directory()
{
$request = http_request::getInstance();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
if (http_request::is_command_line())
return;
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF']))
@@ -100,7 +99,7 @@ class gatekeeper
try
{
$cookie = Session_Handler::get_cookie('persistent');
$auth = new Session_Authentication_PersistentCookie($appbox, $cookie);
$auth = new Session_Authentication_PersistentCookie($appbox, $cookie);
$session->restore($auth->get_user(), $auth->get_ses_id());
}
catch (Exception $e)
@@ -120,9 +119,8 @@ class gatekeeper
break;
case 'thesaurus2':
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
return;
phrasea::redirect('/login/?redirect=/thesaurus2');
break;
@@ -131,7 +129,6 @@ class gatekeeper
break;
case 'admin':
if ($this->_script_name === 'runscheduler.php')
return;
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
break;
@@ -151,7 +148,6 @@ class gatekeeper
return;
case 'setup':
if ($appbox->upgradeavailable())
return;
else
phrasea::redirect('/login/');
@@ -230,7 +226,7 @@ class gatekeeper
*/
protected function give_guest_access()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance();
$request = http_request::getInstance();
$session = $appbox->get_session();
@@ -246,7 +242,7 @@ class gatekeeper
catch (Exception $e)
{
$url = '/login/?redirect=' . $parm['redirect']
. '&error=' . urlencode($e->getMessage());
. '&error=' . urlencode($e->getMessage());
phrasea::redirect($url);
}
phrasea::redirect('/' . $this->_directory . '/index.php');
@@ -262,13 +258,12 @@ class gatekeeper
*/
protected function token_access()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance();
$request = new http_request();
$session = $appbox->get_session();
$parm = $request->get_parms('LOG');
$parm = $request->get_parms('LOG');
if (is_null($parm["LOG"]))
return $this;
try
@@ -287,7 +282,19 @@ class gatekeeper
{
$datas = random::helloToken($parm['LOG']);
return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
switch ($datas['type'])
{
default:
return $this;
break;
case \random::TYPE_FEED_ENTRY:
return phrasea::redirect("/lightbox/feeds/entry/" . $datas['datas'] . "/");
break;
case \random::TYPE_VALIDATE:
case \random::TYPE_VIEW:
return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
break;
}
}
catch (Exception_NotFound $e)
{
@@ -305,7 +312,7 @@ class gatekeeper
*/
public function require_session()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
if ($session->is_authenticated())
{

View File

@@ -144,7 +144,7 @@ class mail
public static function mail_confirm_registered($email)
{
$registry = \registry::get_instance();
$subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "<div>" . _('login::register: merci d\'avoir confirme votre adresse email') . "</div>\n";

View File

@@ -11,18 +11,28 @@
class random
{
/**
*
*/
const NUMBERS = "0123456789";
const NUMBERS = "0123456789";
/**
*
*/
const LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
/**
*
*/
const LETTERS_AND_NUMBERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const TYPE_FEED_ENTRY = 'FEED_ENTRY';
const TYPE_PASSWORD = 'password';
const TYPE_DOWNLOAD = 'download';
const TYPE_MAIL_DOWNLOAD = 'mail-download';
const TYPE_EMAIL = 'email';
const TYPE_VIEW = 'view';
const TYPE_VALIDATE = 'validate';
const TYPE_RSS = 'rss';
/**
*
@@ -34,15 +44,15 @@ class random
{
$conn = connection::getPDOConnection();
$date = new DateTime();
$date = phraseadate::format_mysql($date);
$date = new DateTime();
$date = phraseadate::format_mysql($date);
$registry = registry::get_instance();
$sql = 'SELECT * FROM tokens WHERE expire_on < :date
$sql = 'SELECT * FROM tokens WHERE expire_on < :date
AND datas IS NOT NULL AND (type="download" OR type="email")';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':date' => $date));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
@@ -57,7 +67,7 @@ class random
}
}
$sql = 'DELETE FROM tokens WHERE expire_on < :date and (type="download" OR type="email")';
$sql = 'DELETE FROM tokens WHERE expire_on < :date and (type="download" OR type="email")';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':date' => $date));
$stmt->closeCursor();
@@ -85,8 +95,8 @@ class random
$password = "";
if (!in_array($possible, array(self::LETTERS_AND_NUMBERS, self::LETTERS, self::NUMBERS)))
$possible = self::LETTERS_AND_NUMBERS;
$i = 0;
$possible = self::LETTERS_AND_NUMBERS;
$i = 0;
$possible_length = strlen($possible);
while ($i < $length)
{
@@ -106,18 +116,32 @@ class random
* @param mixed content $datas
* @return boolean
*/
public static function getUrlToken($type, $usr, DateTime $end_date = null, $datas='')
public static function getUrlToken($type, $usr, DateTime $end_date = null, $datas = '')
{
self::cleanTokens();
$conn = connection::getPDOConnection();
$token = $test = false;
$conn = connection::getPDOConnection();
$token = $test = false;
if (!in_array($type, array('password', 'download', 'mail-download', 'email', 'view', 'validate', 'rss')))
throw new Exception_InvalidArgument();
switch ($type)
{
case self::TYPE_DOWNLOAD:
case self::TYPE_PASSWORD:
case self::TYPE_MAIL_DOWNLOAD:
case self::TYPE_EMAIL:
case self::TYPE_VALIDATE:
case self::TYPE_VIEW:
case self::TYPE_RSS:
case self::TYPE_FEED_ENTRY:
break;
default:
throw new Exception_InvalidArgument();
break;
}
$n = 1;
$sql = 'SELECT id FROM tokens WHERE value = :test ';
$sql = 'SELECT id FROM tokens WHERE value = :test ';
$stmt = $conn->prepare($sql);
while ($n < 100)
{
@@ -134,16 +158,16 @@ class random
if ($token)
{
$sql = 'INSERT INTO tokens (id, value, type, usr_id, created_on, expire_on, datas)
$sql = 'INSERT INTO tokens (id, value, type, usr_id, created_on, expire_on, datas)
VALUES (null, :token, :type, :usr, NOW(), :end_date, :datas)';
$stmt = $conn->prepare($sql);
$params = array(
':token' => $token
, ':type' => $type
, ':usr' => ($usr ? $usr : '-1')
, ':end_date' => ($end_date instanceof DateTime ? phraseadate::format_mysql($end_date) : null)
, ':datas' => ((trim($datas) != '') ? $datas : null)
':token' => $token
, ':type' => $type
, ':usr' => ($usr ? $usr : '-1')
, ':end_date' => ($end_date instanceof DateTime ? phraseadate::format_mysql($end_date) : null)
, ':datas' => ((trim($datas) != '') ? $datas : null)
);
$stmt->execute($params);
$stmt->closeCursor();
@@ -159,7 +183,7 @@ class random
try
{
$conn = connection::getPDOConnection();
$sql = 'DELETE FROM tokens WHERE value = :token';
$sql = 'DELETE FROM tokens WHERE value = :token';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':token' => $token));
$stmt->closeCursor();
@@ -202,12 +226,12 @@ class random
self::cleanTokens();
$conn = connection::getPDOConnection();
$sql = 'SELECT * FROM tokens
$sql = 'SELECT * FROM tokens
WHERE value = :token
AND (expire_on > NOW() OR expire_on IS NULL)';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':token' => $token));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)

View File

@@ -3816,7 +3816,7 @@
</field>
<field>
<name>type</name>
<type>enum('view','validate','password','rss','email','download')</type>
<type>enum('FEED_ENTRY', 'view','validate','password','rss','email','download')</type>
<null></null>
<extra></extra>
<collation>ascii_bin</collation>

View File

@@ -261,8 +261,8 @@ function dropOnBask(event,from,destKey)
var action = "",
from = $(from),
current_opened_sstt = $(' #baskets .ui-state-active');
if(from.hasClass("CHIM"))
action = (current_opened_sstt.hasClass('grouping')?'REG':'CHU') + "2";
else
@@ -426,7 +426,7 @@ function dropOnBask(event,from,destKey)
p4.baskSel = [];
}
}
var current_id = current_opened_sstt.length > 0 ? current_opened_sstt.attr('id').split('_').pop() : null;
if((act == 'MOV') || (current_id == ssttid_dest))
{
@@ -816,7 +816,7 @@ function initAnswerForm(){
$('#tool_navigate').empty().append(datas.navigation);
$('#proposals').empty().append(datas.phrasea_props);
if($.trim(datas.phrasea_props) !== '')
{
$('.activeproposals').show()
@@ -1466,7 +1466,7 @@ $(document).ready(function(){
$see_more = $(this).closest('.see_more');
$see_more.addClass('loading');
})
$('#answers .feed .entry').live('mouseover', function(){
$(this).addClass('hover');
});
@@ -1477,17 +1477,17 @@ $(document).ready(function(){
$('a.ajax_answers').live('click', function(event){
event.stopPropagation();
var $this = $(this);
var append = $this.hasClass('append');
var no_scroll = $this.hasClass('no_scroll');
$.ajax({
type:"GET",
url : $this.attr('href'),
dataType: 'html',
success : function(data){
var $answers = $('#answers');
if(!append)
{
$answers.empty();
@@ -1501,7 +1501,7 @@ $(document).ready(function(){
{
$('.see_more.loading', $answers).remove();
$answers.append(data);
if(!no_scroll)
{
$answers.animate({
@@ -1512,11 +1512,11 @@ $(document).ready(function(){
callback_answerselectable();
}
});
return false;
});
$('a.subscribe_rss').live('click',function(event){
@@ -1537,12 +1537,12 @@ $(document).ready(function(){
buttons[language.fermer] = function() {
$('#DIALOG').dialog('close');
};
event.stopPropagation();
var $this = $(this);
var append = $this.hasClass('append');
$.ajax({
type:"GET",
url : $this.attr('href')+(event.renew === true ? '?renew=true' : ''),
@@ -1573,7 +1573,7 @@ $(document).ready(function(){
}
}
});
return false;
});
@@ -1702,12 +1702,12 @@ $(document).ready(function(){
});
}
});
$('#idFrameA div.IMGT').live('mousedown',function(event){
evt_mdwn_obj(this, event);
return;
});
$('#idFrameA div.IMGT').live('click',function(event){
if(is_shift_key(event) || is_ctrl_key(event))
return true;
@@ -1718,22 +1718,22 @@ $(document).ready(function(){
$(this).addClass('last_selected');
return;
});
$('#idFrameC div.CHIM').live('mousedown',function(event){
baskSelection(this, event);
return;
});
$('#idFrameC div.CHIM').live('click',function(event){
if(is_shift_key(event) || is_ctrl_key(event))
return true;
p4.baskSel = new Array();
var cont = $('#idFrameC .SSTT.content:visible');
$('.CHIM.selected, .CHIM.last_selected', cont).removeClass('selected last_selected');
var k = $(this).attr('id').split('_').slice(2,4).join('_');
p4.baskSel.push(k);
$(this).addClass('selected last_selected');
@@ -1942,7 +1942,7 @@ $(document).ready(function(){
if($('.overlay').is(':visible'))
return true;
if($('.ui-widget-overlay').is(':visible'))
return true;
@@ -2139,7 +2139,7 @@ $(document).ready(function(){
resizePreview();
}
});
$('input.input_select_copy').live('focus', function(){
$(this).select();
});
@@ -2149,7 +2149,7 @@ $(document).ready(function(){
$('input.input_select_copy').live('click', function(){
$(this).select();
});
$('#answers .feed .entry a.options').live('click', function(){
var $this = $(this);
$.ajax({
@@ -2200,7 +2200,7 @@ $(document).ready(function(){
});
@@ -2581,12 +2581,12 @@ function chgStatusThis(url)
function pushThis(sstt_id, lst)
{
$('#MODALDL').attr('src','about:blank');
var $form = $('#push_form');
$('input[name="lst"]', $form).val(lst);
$('input[name="SSTTID"]', $form).val(sstt_id);
$form.submit();
var w = bodySize.x - 40;
@@ -2636,9 +2636,9 @@ function activeIcons()
{
$('.TOOL_print_btn').live('click', function(){
var value="";
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -2661,7 +2661,7 @@ function activeIcons()
}
}
}
if(value !== '')
{
printThis(value);
@@ -2673,9 +2673,9 @@ function activeIcons()
});
$('.TOOL_bridge_btn').live('click', function(){
var datas = {};
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -2698,7 +2698,7 @@ function activeIcons()
}
}
}
if(datas.ssel || datas.lst)
{
init_publicator(datas);
@@ -2708,7 +2708,7 @@ function activeIcons()
alert(language.nodocselected);
}
});
$('.TOOL_trash_btn').live('click', function(){
@@ -2742,7 +2742,7 @@ function activeIcons()
$('.TOOL_ppen_btn').live('click', function(){
var value="";
var type = "";
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -2785,11 +2785,11 @@ function activeIcons()
alert(language.nodocselected);
}
});
$('.TOOL_publish_btn').live('click', function(){
var value="";
var type = "";
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -2822,7 +2822,7 @@ function activeIcons()
}
}
}
if(value !== '')
{
feedThis(type,value);
@@ -2832,7 +2832,7 @@ function activeIcons()
alert(language.nodocselected);
}
});
function feedThis(type,value)
{
var $feed_box = $('#modal_feed');
@@ -2841,7 +2841,7 @@ function activeIcons()
ssel:'',
act:''
};
switch(type){
case "IMGT":
case "CHIM":
@@ -2856,7 +2856,7 @@ function activeIcons()
$.post("/prod/feeds/requestavailable/"
, options
, function(data){
return set_up_feed_box(data);
});
@@ -2865,7 +2865,7 @@ function activeIcons()
$('.TOOL_chgcoll_btn').live('click', function(){
var value = {};
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -2904,8 +2904,8 @@ function activeIcons()
$('.TOOL_chgstatus_btn').live('click', function(){
var value="";
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -2928,7 +2928,7 @@ function activeIcons()
}
}
}
if(value !== '')
{
chgStatusThis(value);
@@ -2975,8 +2975,8 @@ function activeIcons()
$('.TOOL_imgtools_btn').live('click', function(){
var value="";
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -2999,7 +2999,7 @@ function activeIcons()
}
}
}
if(value !== '')
{
toolThis(value);
@@ -3013,7 +3013,7 @@ function activeIcons()
$('.TOOL_disktt_btn').live('click', function(){
var datas = {};
if($(this).hasClass('results_window'))
{
if(p4.sel.length > 0)
@@ -3042,7 +3042,7 @@ function activeIcons()
}
}
}
if(datas.lst || datas.SSTTID)
downloadThis(datas);
@@ -4337,7 +4337,7 @@ function reorder(ssel_id)
function set_up_feed_box(data)
{
var $feed_box = $('#modal_feed');
$feed_box.empty().append(data).dialog({
modal:true,
width:800,
@@ -4345,10 +4345,10 @@ function set_up_feed_box(data)
resizable:false,
draggable:false
});
var $feeds_item = $('.feeds .feed', $feed_box);
var $form = $('form.main_form', $feed_box);
$feeds_item.bind('click', function(){
$feeds_item.removeClass('selected');
$(this).addClass('selected');
@@ -4358,14 +4358,14 @@ function set_up_feed_box(data)
},function(){
$(this).removeClass('hover')
});
$form.bind('submit', function(){
return false;
});
$('button.valid_form').bind('click', function(){
$('button.valid_form', $feed_box).bind('click', function(){
var error = false;
$('.required_text', $form).each(function(i, el){
if($.trim($(el).val()) === '')
{
@@ -4373,36 +4373,46 @@ function set_up_feed_box(data)
error = true;
}
});
if(error)
{
alert(language.feed_require_fields)
}
if($('input[name="feed_id"]', $form).val() === '')
{
alert(language.feed_require_feed)
error = true;
}
if(error)
{
return false;
}
$.ajax({
type: 'POST',
url: $form.attr('action'),
data: $form.serializeArray(),
dataType:'json',
beforeSend:function(){
$('button', $feed_box).attr('disabled', 'disabled');
},
error:function(){
$('button', $feed_box).removeAttr('disabled');
},
timeout:function(){
$('button', $feed_box).removeAttr('disabled');
},
success: function(data){
$('button', $feed_box).removeAttr('disabled');
if(data.error === true)
{
alert(data.message);
return;
}
if($('form.main_form', $feed_box).hasClass('entry_update'))
{
var id = $('form input[name="entry_id"]', $feed_box).val();
@@ -4420,4 +4430,3 @@ function set_up_feed_box(data)
});
return;
}