linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file display.php

Documentation is available at display.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage comment
  5.  * @author Simon Georget <simon@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. include_once(override('../comment/'.SQL.'.inc.php'));
  12. include_once('../class/class.comment.php');
  13.  
  14. if(!function_exists('getPostCommentAnchor')) {
  15.  
  16.   function getPostCommentAnchor() {
  17.  
  18.     $str =     '<a id="anchor-post-comment" href="'.str_replace('&', '&amp;', $_SERVER["REQUEST_URI"]).'#add-comment" title="'._t('comment', 'add').'">'._t('comment', 'add').'</a>';
  19.     return $str;
  20.   }
  21. }
  22.  
  23. if(!function_exists('getCommentsAnchor')) {
  24.  
  25.   function getCommentsAnchor($a) {
  26.     $nb = getNbComments($a);
  27.     $str =     '<a id="anchor-comment" href="'.str_replace('&', '&amp;', $_SERVER["REQUEST_URI"]).'#comments" title="'._t('comment', 'go_to').'">'.sprintf(_t('comment', 'number'), '<span id="cc">'.$nb.'</span>').'</a>';
  28.     return $str;
  29.   }
  30. }
  31.  
  32. if(!function_exists('getNbComments')) {
  33.  
  34.   function getNbComments($a) {
  35.     $data = $GLOBALS['sql_object']->DBSelect(SQL_getCommentsNumber($a));
  36.     return $data[0]['nb'];
  37.   }
  38.  
  39. }
  40.  
  41. if(!function_exists('displayComments')) {
  42.  
  43.   function displayComments($a, $moderation = false, $get_permalink = false) {
  44.     echo getComments($a, $moderation, $get_permalink);
  45.   }
  46. }
  47.  
  48. if(!function_exists('getComments')) {
  49.  
  50.   function getComments($a, $moderation = false, $get_permalink = false) {
  51.  
  52.     $comm = new comment;
  53.     $comments = $comm->get($a, $GLOBALS['sql_object']);
  54.  
  55.     if(count($comments) == 0 || $comments == 0) {
  56.       return '<p>' . _t('comment', 'nocomment_yet') . '</p>';
  57.     }
  58.  
  59.     return getMarkup($comments, $moderation, $get_permalink);
  60.  
  61.   }
  62.  
  63. }
  64.  
  65. if(!function_exists('postCommentAction')) {
  66.  
  67.   function postCommentAction($a) {
  68.  
  69.     // comment submit
  70.     if(isset($_POST['cbody'])) {
  71.       $arr = array();
  72.  
  73.       isset($_SESSION['userlogin']) ? $arr['user_id'] = base64_decode($_SESSION['userid']) : $arr['user_id'] = '';
  74.       $arr['module'] = $a['module'];
  75.       $arr['module_id'] = $a['module_id'];
  76.       isset($_POST['cname']) ? $arr['name'] = $_POST['cname'] : $arr['name'] = '';
  77.       isset($_POST['cemail']) ? $arr['email'] = $_POST['cemail'] : $arr['email'] = '';
  78.       isset($_POST['curl']) ? $arr['url'] = $_POST['curl'] : $arr['url'] = '';
  79.       isset($_POST['cbody']) ? $arr['body'] = $_POST['cbody'] : $arr['body'] = '';
  80.       isset($_POST['cnotification']) ? $arr['notification'] = 'Y' : $arr['notification'] = 'N';
  81.  
  82.       $comm = new comment;
  83.       
  84.       // prevent spam if user not authenticated
  85.       if(!isset($_SESSION['authenticated']) && $_SESSION['securityaction']!=md5($_POST['securitycode'])) {
  86.           $passed =_t('security','message');
  87.       }
  88.       
  89.       if(!isset($passed))  $passed = $comm->checkDataIntegrity($arr);
  90.  
  91.       // errors on input
  92.       if(is_string($passed)) {
  93.         $msg = '<p class="error">'. $passed .'</p>';
  94.         // everything is OK
  95.       } else {
  96.         $r = $comm->add($arr, $GLOBALS['sql_object']);
  97.         if(!is_numeric($r)) system_error('adding comment on ' . $arr['module'] . '/' . $arr['module_id']);
  98.         // we send an email to default user for moderation if needed
  99.         emailModerators($arr, $r, $comm);
  100.         // we notify users if needed
  101.         notifyUsers($arr, $r, $comm);
  102.         $msg = '<b>' . _t('comment', 'successful') . '</b>';
  103.         (COMMENT_MODERATION == 1) ? $msg .= '<br />'._t('comment', 'moderation_msg') : '';
  104.         $msg = '<p class="confirm">'. $msg .'</p>';
  105.         echo '<script type="text/javascript">
  106.                   $(function() {
  107.                       setTimeout(\'jQuery.smoothScroll({scrollTarget: "#com-'.$r.'"});\', '.SCROLL_DELAY.');
  108.                   });
  109.               </script>';
  110.         footerAddJS('../lib/js/jquery.smooth-scroll.min.js');
  111.       }
  112.  
  113.       echo $msg;
  114.       return true;
  115.     }
  116.  
  117.     return false;
  118.   }
  119. }
  120.  
  121. if(!function_exists('displayCommentForm')) {
  122.  
  123.   function displayCommentForm($a) {
  124.  
  125.     // prepare vars fo form
  126.     isset($a['module']) ? $rub = $a['module'] : $rub = $_REQUEST['rub'];
  127.     isset($a['module_id']) ? $id = $a['module_id'] : $id = $_REQUEST['id'];
  128.  
  129.     // prepare name var
  130.     $fullname ='';
  131.     if(isset($_SESSION['userfirstname'])) $fullname = $_SESSION['userfirstname'];
  132.     if(isset($_SESSION['userlastname'])) $fullname .= ' '. $_SESSION['userlastname'];
  133.     if(!empty($fullname)) $fullname = ' ('.$fullname.')';
  134.     
  135.     $f_name = '';
  136.     $f_email = '';
  137.     $f_url = '';
  138.     $f_body = '';
  139.     $f_notification ='';
  140.  
  141.     // comment submit
  142.     if(isset($_POST['cbody'])) {
  143.       $arr = array();
  144.  
  145.       isset($_SESSION['userlogin']) ? $arr['user_id'] = base64_decode($_SESSION['userid']) : $arr['user_id'] = '';
  146.       $arr['module'] = $a['module'];
  147.       $arr['module_id'] = $a['module_id'];
  148.       isset($_POST['cname']) ? $arr['name'] = $_POST['cname'] : $arr['name'] = '';
  149.       isset($_POST['cemail']) ? $arr['email'] = $_POST['cemail'] : $arr['email'] = '';
  150.       isset($_POST['curl']) ? $arr['url'] = $_POST['curl'] : $arr['url'] = '';
  151.       isset($_POST['cbody']) ? $arr['body'] = $_POST['cbody'] : $arr['body'] = '';
  152.       isset($_POST['cnotification']) ? $arr['notification'] = 'Y' : $arr['notification'] = 'N';
  153.  
  154.       
  155.       $comm = new comment;
  156.       $passed = $comm->checkDataIntegrity($arr);
  157.  
  158.       // errors on input
  159.       if(is_string($passed)) {
  160.         if(isset($_POST['cname'])) $f_name = $_POST['cname'];
  161.         if(isset($_POST['cemail'])) $f_email = $_POST['cemail'];
  162.         if(isset($_POST['curl'])) $f_url = $_POST['curl'];
  163.         if(isset($_POST['cbody'])) $f_body = $_POST['cbody'];
  164.         if(isset($_POST['cnotification'])) $f_notification = ' checked="checked"';
  165.       }
  166.  
  167.     }
  168.  
  169.  
  170.  
  171.     if(COMMENT_ONLY_REGISTERED == 1 && !isset($_SESSION['userlogin'])) {
  172.       $link = HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['user-prefs']['linkvalue']));
  173.       $content = '<p class="info" id="add-comment">'.sprintf(_t('comment', 'only_registered'), $link).'</p>';
  174.     } else {
  175.       $content = '<div id="add-comment">
  176.                       <h3>'._t('comment', 'add').'</h3>
  177.                       <form id="add-comment-form" method="post" action="index.php">
  178.                       <div>';
  179.       if(!isset($_SESSION['authenticated'])) {
  180.         $content .= '<p><label for="cname" class="labelised">'._t('comment', 'name').' : </label>
  181.                         <input type="text" name="cname" id="cname" class="shorttextfield" value="' . $f_name . '" /></p>
  182.                       <p><label for="cemail" class="labelised">'._t('comment', 'email').' : </label>
  183.                       <input type="text" name="cemail" id="cemail" class="shorttextfield" value="' . $f_email . '" /></p>
  184.                       <p><label for="curl" class="labelised">'._t('comment', 'website').' ('._t('divers', 'optional').') : </label>
  185.                       <input type="text" name="curl" id="curl" class="shorttextfield" value="' . $f_url . '" /></p>
  186.                                     <p class="antispam">
  187.                                     <span class="labelmargin labelised">' . _t('security','info2') . ' : </span>
  188.                                     <img src="../lib/securitycode.php" alt="' . _t('security','info2') .'" id="securityimg"  />
  189.                                     </p>
  190.                                     <p><label for="securitycode" class="labelised">' . _t('antispam','info') . ' * : </label>
  191.                                     <input type="text" class="textfield" id="securitycode" maxlength="5" name="securitycode" /></p> ';
  192.       } else {
  193.         $content .= '<p class="label-leftmargin">'.sprintf(_t('comment', 'logged-in_post'), '<strong>'.$_SESSION['userlogin'].'</strong> '.$fullname).'</p>';
  194.       }
  195.       $content .= '<p><label for="cbody" class="labelised">'._t('comment', 'body').' : </label>
  196.                       <textarea name="cbody" id="cbody" cols="30"  class="shorttextfield" rows="5">' . $f_body . '</textarea></p>';
  197.       // no ability to subscribe on 'contribute' module
  198.       if(COMMENT_NOTIFICATION == 1 && $a['module']!='contribute') {
  199.         $content .= '<p class="label-leftmargin"><input type="checkbox" name="cnotification" id="cnotification" value="1"'.$f_notification.' /><label for="cnotification" class="labelised autowidth">' . _t('comment', 'email_notification') . '</label></p>';
  200.       }
  201.       $content .= '<input type="hidden" name="module" id="module" value="'.$a['module'].'" />
  202.                       <input type="hidden" name="rub" id="rub" value="'.$rub.'" />
  203.                       <input type="hidden" name="id" id="id" value="'.$id.'" />';
  204.       if(COMMENT_MODERATION == 1) {
  205.         if(!isset($_SESSION['userlogin']) || (isset($_SESSION['userlogin']) && COMMENT_MODERATE_REGISTERED == 1))
  206.         $content .= '<p class="info">'._t('comment', 'moderation_msg').'</p>';
  207.       }
  208.       $content .= '<input type="submit" class="submitbut" value="'._t('btn','valid').'" />
  209.                   </div>
  210.               </form>
  211.           </div>';
  212.     }
  213.     // for ajax implementation
  214.     footerAddJS('../lib/js/comment_submit.js');
  215.  
  216.     echo $content;
  217.  
  218.   }
  219.  
  220. }
  221.  
  222. if(!function_exists('getMarkup')) {
  223.  
  224.   function getMarkup($comments, $moderation = false, $get_permalink = false) {
  225.  
  226.     $str = '';
  227.     $registered ='';
  228.     $class= 'odd';
  229.  
  230.     foreach($comments as $c) {
  231.       $cdate       = $c['comment_date_crea_display'];
  232.       $cdateshort  = substr($c['comment_date_crea_display'], 0, 10);
  233.       $cbody       = formatText($c['comment_body']);
  234.       (trim($class) == 'odd') ? $class = '' : $class = ' odd';
  235.       
  236.       // get fullname
  237.       if(!empty($c['profile_firstname']) || !empty($c['profile_lastname'])) {
  238.           $fullname = '('.$c['profile_firstname']. ' '.$c['profile_lastname'].')';
  239.       } else {
  240.           $fullname = '';
  241.       }
  242.  
  243.       if(!empty($c['profile_avatar'])) {
  244.         $avatar = '../'. $c['profile_avatar'];
  245.       } else {
  246.         $avatar = THEME_PUBLIC_PATH. 'images/no_avatar.png';
  247.       }
  248.       if($c['comment_status']=='D') {
  249.         $extraclass = ' to-moderate';
  250.         if(CURRENT_APP != 'admin') {
  251.           $tomoderate = '<p class="moderation">'._t('comment', 'to_moderate').'</p>';
  252.         } else {
  253.           $tomoderate = '';
  254.         }
  255.       } else {
  256.         $extraclass = '';
  257.         $tomoderate = '';
  258.       }
  259.       if($c['comment_user_id']!=0) {
  260.         if(CURRENT_APP == 'admin') {
  261.           $link = 'index.php?rub=user&amp;todo=det&amp;id='.$c['comment_user_id'];
  262.           $data = $GLOBALS['sql_object']->DBSelect(SQL_getUserInfo($c['comment_user_id']));
  263.           $cemail = ' - <a href="mailto:'.$data[0]['profile_email'].'">'.$data[0]['profile_email'].'</a>';
  264.           $registered = ' '._t('comment', 'registered_user').' ';
  265.         } else {
  266.           $link = HrefMaker(array('rub' => $GLOBALS['links'][U_L]['user-profile']['linkvalue'], 'id' => $c['user_id'], 'name' => $c['user_login']));
  267.           $cemail = '';
  268.         }
  269.         $cname = '<a href="'. $link.'" title="' . $GLOBALS['links'][U_L]['user-profile']['desc'].'">'.$c['user_login'].'</a>' . ' ' .$fullname;
  270.         $cname_raw = $c['user_login'];
  271.       } else {
  272.         if(CURRENT_APP == 'admin') {
  273.           $cemail = ' - <a href="mailto:'.$c['comment_email'].'">'.$c['comment_email'].'</a>';
  274.           $registered = '';
  275.         } else {
  276.           $cemail = '';
  277.         }
  278.         if(!empty($c['comment_url']))
  279.         $cname = '<a href="'.$c['comment_url'].'">'.$c['comment_name'].'</a>';
  280.         else {
  281.           $cname = $c['comment_name'];
  282.         }
  283.         $cname_raw = $c['comment_name'];
  284.       }
  285.  
  286.       $item = itemMapping($c['comment_module']);
  287.  
  288.       if($get_permalink == true) {
  289.         $permalink = '<a href="'.str_replace('&', '&amp;', $_SERVER["REQUEST_URI"]).'#com-'.$c['comment_id'].'">#'.$c['comment_id'].'</a>';
  290.       } else {
  291.         $permalink = '#'.$c['comment_id'];
  292.       }
  293.       if($c['comment_status']== 'E') {
  294.         $marker = _t('comment', 'disapproved');
  295.         $cmarker = ' disapprove';
  296.       }
  297.       if($c['comment_status']== 'P') {
  298.         $marker = _t('comment', 'approved');
  299.         $cmarker = ' approve';
  300.       }
  301.       if($c['comment_status']== 'D') {
  302.         $marker = _t('comment', 'awaiting');
  303.         $cmarker = ' awaiting';
  304.       }
  305.       $str .= '<div class="comment'.$class.$extraclass.'" id="com-'.$c['comment_id'].'">
  306.                   
  307.                 <div class="avatar">
  308.                     <img src="'.$avatar.'" alt="'.$cname_raw.'" />
  309.                 </div>
  310.                 <div class="name">' . $cname . $registered . $cemail.'</div>
  311.                 <div class="date" title="'. $cdate .'">'. $permalink .' - '. $cdateshort .'</div>
  312.                 <div class="body">'. formatText($cbody, '2HTML') .'</div>'.$tomoderate;
  313.       if($moderation === true || ( $moderation == 'smart' && $c['comment_status'] == 'D') ) {
  314.         $str .= '<div class="comment-actions">
  315.             <div class="iconetab">
  316.                     <a href="../comment/_ajax_admin.php?todo=approve&amp;id='.$c['comment_id'].'" class="ico_approve" title="'.ucfirst(_t('comment', 'approve')).'"><i class="icon-ok"></i><span>'.ucfirst(_t('comment', 'approve')).'</span></a>
  317.                     <a href="../comment/_ajax_admin.php?todo=disapprove&amp;id='.$c['comment_id'].'" class="ico_disapprove" title="'.ucfirst(_t('comment', 'disapprove')).'"><i class="icon-cancel"></i><span>'.ucfirst(_t('comment', 'disapprove')).'</span></a>
  318.                     <a href="../comment/_ajax_admin.php?todo=del&amp;id='.$c['comment_id'].'" class="ico_sup" title="'.ucfirst(_t('comment', 'delete')).'"><i class="icon-trash"></i><span>'.ucfirst(_t('comment', 'delete')).'</span></a>
  319.                     
  320.                     </div><br style="clear:both" />
  321.                     <div class="action-marker'.$cmarker.'">'.$marker.'</div>
  322.                 </div>
  323.                 ';
  324.       }
  325.       if(CURRENT_APP == 'admin') {
  326.         if($item['link'] == 'library') {
  327.           $key = 'expandedFolder';
  328.         } else {
  329.           $key = 'id';
  330.         }
  331.         if($item['link'] != 'contribute') {
  332.           $str .= '<p class="item">'. _t('comment', 'posted_in') .' <a href="../admin/index.php?rub='.$item['link'].'&amp;todo=det&amp;'.$key.'='.$c['comment_module_id'].'" title="'.$c['item_title'].'">'.$c['item_title'].'</a> ('. $item['name']. ')</p>';
  333.         } else {
  334.           // no link to item for 'contribute' module
  335.           $str .= '<p class="item">'. _t('comment', 'posted_in') .' '. $item['name']. '</p>';
  336.         }
  337.       }
  338.       $str .= '</div>';
  339.     }
  340.     return $str;
  341.   }
  342.  
  343. }
  344.  
  345. /**
  346.  * notifyUsers()
  347.  * @param array 
  348.  * @param integer 
  349.  * @param object 
  350.  * @param bool 
  351.  *  $arr : array of needed data
  352.  *  $id : inserted comment id
  353.  *  $o : comment object
  354.  *  $overpass : to overpass tests
  355.  */
  356. if(!function_exists('notifyUsers')) {
  357.   function notifyUsers($arr, $id, $o, $overpass = false) {
  358.  
  359.     $pass = false;
  360.  
  361.     // we prepare values
  362.     $arr['cid'] = $id;
  363.     $a = getValues($arr);
  364.     $data = $o->getCommentItem($arr, $GLOBALS['sql_object']);
  365.  
  366.     $a['item_title'] = $data[0]['item_title'];
  367.     $a['action'] = 'notify_comment';
  368.  
  369.     if(COMMENT_NOTIFICATION == 1) {
  370.  
  371.       // we send it only if new comment is automatically approved
  372.       if(COMMENT_MODERATION == 0 || (COMMENT_MODERATE_REGISTERED == 0 && !empty($arr['user_id']))) {
  373.         $pass = true;
  374.       }
  375.  
  376.       if($pass === true || $overpass === true) {
  377.         $users_email = $o->getSubscribers($arr, $GLOBALS['sql_object']);
  378.         
  379.         $a['recipients'] = array();
  380.  
  381.         foreach($users_email as $email) {
  382.           // we don't send mail to author
  383.           if($email != $a['author_email']) {
  384.               array_push($a['recipients'], $email);
  385.           }
  386.         }
  387.         include(override('../comment/mail_actions.php'));
  388.         include_once(override('../mail/template.php'));
  389.       }
  390.     }
  391.     // if $overpass we stop there
  392.     if($overpass === true) return true;
  393.  
  394.     // in any case we send an email to the admin when message is posted
  395.     // if moderation is disabled
  396.     if(COMMENT_MODERATION == 0 || (COMMENT_MODERATE_REGISTERED == 0 && !empty($arr['user_id']))) {
  397.       $a['recipient'] = SITE_MAIL;
  398.       $a['adminuser'] = true;
  399.       include(override('../comment/mail_actions.php'));
  400.       include_once(override('../mail/template.php'));
  401.     }
  402.  
  403.   }
  404. }
  405.  
  406. /**
  407.  * emailModerators()
  408.  * @param array 
  409.  * @param integer 
  410.  * @param object 
  411.  *  $arr : array of needed data
  412.  *  $id : inserted comment id
  413.  *  $o : comment object
  414.  */
  415. if(!function_exists('emailModerators')) {
  416.   function emailModerators($arr, $id, $o) {
  417.  
  418.     if(COMMENT_MODERATION == 1) {
  419.       // if logged-in user and no moderation on registered user, we exit
  420.       if(!empty($arr['user_id']) && COMMENT_MODERATE_REGISTERED == 0) return true;
  421.  
  422.       $arr['cid'] = $r;
  423.       $a = getValues($arr);
  424.  
  425.       if($arr['module'] != 'contribute') {
  426.         $data = $o->getCommentItem($arr, $GLOBALS['sql_object']);
  427.       } else {
  428.         $data[0]['item_title'] = _t('comment', 'contribute_item');
  429.       }
  430.  
  431.       $a['item_title'] = $data[0]['item_title'];
  432.       $a['action'] = 'moderate_comment';
  433.       $a['recipient'] = SITE_MAIL;
  434.       //      print_r($a);
  435.       include(override('../comment/mail_actions.php'));
  436.       include_once(override('../mail/template.php'));
  437.     }
  438.  
  439.   }
  440. }
  441.  
  442. if(!function_exists('getValues')) {
  443.   function getValues($a) {
  444.  
  445.     $output = array();
  446.  
  447.     if(!empty($a['user_id'])) {
  448.       $data = $GLOBALS['sql_object']->DBSelect(SQL_getUserInfo($a['user_id']));
  449.       $output['name'] = $data[0]['user_login'];
  450.       $output['author_email'] = $data[0]['profile_email'];
  451.     } else {
  452.       $output['name'] = $a['name'];
  453.       $output['author_email'] = $a['email'];
  454.     }
  455.     $output['body'] = $a['body'];
  456.     $output['moderate_link'] = SITE_ROOT_URL . 'admin/index.php?rub=comment&todo=list&module=all&statut=D';
  457.  
  458.     $item = itemMapping($a['module']);
  459.     $output['item_type'] = $item['name'];
  460.     $output['admin_link'] = SITE_ROOT_URL  . 'admin/index.php?rub='.$item['link'].'&todo=det&id='. $a['module_id'];
  461.     $output['item_link'] = SITE_ROOT_URL  . 'public/index.php?rub='.$GLOBALS['links'][U_L][$item['link']]['linkvalue'].'&id='.$a['module_id'];
  462.  
  463.     if($a['module']=='files') {
  464.       $wg = explode('/', $a['module_id']);
  465.       if($wg[1] == 'shared') {
  466.         $output['item_link'] = SITE_ROOT_URL  . 'public/index.php?rub='.$GLOBALS['links'][U_L]['workgroup']['linkvalue'];
  467.       } else {
  468.         $output['item_link'] = SITE_ROOT_URL  . 'public/index.php?rub='.$GLOBALS['links'][U_L]['workgroup']['linkvalue'].'&id='.$wg[1];
  469.       }
  470.       $output['item_link_comments'] = $output['item_link'];
  471.       $output['item_link_the_comment'] = $output['item_link'];
  472.     } else {
  473.       $output['item_link'] = SITE_ROOT_URL  . 'public/index.php?rub='.$GLOBALS['links'][U_L][$item['link']]['linkvalue'].'&id='.$a['module_id'];
  474.       $output['item_link_comments'] = $output['item_link'].'#comments';
  475.       if(isset($a['cid'])) $output['item_link_the_comment'] = $output['item_link'].'#com-'.$a['cid'];
  476.     }
  477.     $output['unsubscribe_link'] = SITE_ROOT_URL  . 'public/index.php?rub='.$GLOBALS['links'][U_L]['comment-unsubscribe']['linkvalue'].'&name='.$a['module'].'&id='.$a['module_id'];
  478.     $output['item_link_comments'] = $output['item_link'].'#comments';
  479.  
  480.     return $output;
  481.   }
  482. }
  483.  
  484. if(!function_exists('getAjaxFunction')) {
  485.   function getAjaxFunction($data = '') {
  486.     $str = '<script type="text/javascript">
  487.                   $(function() {
  488.                       $(".comment-actions a").click(function() {
  489.                           var url = $(this).attr("href");
  490.  
  491.                         $.ajax({
  492.                             type: "GET",
  493.                           url: url,
  494.                           data: "call=ajax",
  495.                           dataType: "json",
  496.                           success: function(data){
  497.                               if(data.status == 1) {
  498.                                   if(data.page != "comment") {
  499.                                       $(data.el).addClass(data.action).fadeOut("slow");
  500.                                       // we update the comment counter
  501.                                                                 $("#cc").text( parseInt($("#cc").text()) - 1);
  502.                                   } else {
  503.                                       if(data.action == "del") {
  504.                                           $(data.el).addClass(data.action).fadeOut("slow");
  505.                                       } else {
  506.                                           $(data.el).removeClass("to-moderate");
  507.                                           var col = $(data.el).css("background-color");
  508.                                           
  509.                                           $(data.el + " div.action-marker").removeClass("awaiting approve disapprove").addClass(data.action).empty().text(data.msg);
  510.                                           // $(data.el).css("background-color","#F2F2F2").animate({backgroundColor: col}, 1500 ); // @todo fix - cause problem with new jquery version
  511.                                           $(data.el).css("background-color","#F2F2F2");
  512.                                       }
  513.                                   }
  514.                               }
  515.                           }
  516.                         });
  517.                         return false;
  518.                     });
  519.                 
  520.                   });
  521.           </script>';
  522.  
  523.     footerAddJS('../lib/js/jquery.color.js');
  524.  
  525.     return $str;
  526.   }
  527. }
  528.  
  529. if(!function_exists('itemMapping')) {
  530.  
  531.   function itemMapping($module) {
  532.  
  533.     $a = array();
  534.     $a['name'] = _t('comment_map', $module);
  535.  
  536.     switch ($module) {
  537.       case 'news':
  538.         $a['link'] = 'news';
  539.         break;
  540.       case 'project':
  541.         $a['link'] = 'project';
  542.         break;
  543.       case 'workgroups':
  544.         $a['link'] = 'workshop';
  545.         break;
  546.       case 'indicator':
  547.         $a['link'] = 'dashboard';
  548.         break;
  549.       case 'publication':
  550.         $a['link'] = 'publication';
  551.         break;
  552.       case 'report':
  553.         $a['link'] = 'workshoprep';
  554.         break;
  555.       case 'files':
  556.         $a['link'] = 'library';
  557.         break;
  558.       case 'contribute':
  559.         $a['link'] = 'contribute';
  560.         break;
  561.       default:
  562.         die($module . ' is not a valid option.');
  563.       break;
  564.     }
  565.     return $a;
  566.   }
  567.  
  568. }
  569.  
  570.  
  571. ?>

Documentation generated on Thu, 20 Mar 2014 16:47:41 +0100 by phpDocumentor 1.4.1