Caravel CMS PHP Cross Reference Content Management Systems

Source: /apps/Comments/Comments.php - 576 lines - 31238 bytes - Summary - Text - Print

   1  <?php
   2  require_once(T_CODE_BASE .'SQL/mnDB.php');
   3  
   4  class Comments extends App
   5      {
   6      
   7      var $linkid;
   8      var $app;
   9      
  10      function _connect()
  11          {
  12          if(is_readable(T_APP_BASE . "Comments/.dbrc"))
  13              $dsn = mnDB::getLoginInfo(T_APP_BASE . "Comments/.dbrc");
  14          else
  15              $dsn = mnDB::getLoginInfo('Comments');
  16          $this->db = mnDB::connect($dsn, true);
  17  
  18          if(mnDB::isError($this->db))
  19              return new mnError("Comments::connectToDB(): ". $this->db->getMessage(), __FILE__, __LINE__);
  20          }
  21  
  22      function getComments() {
  23          if ($this->httpVars['display'] == 'block' || $this->app == 'FolderViewer') {
  24              $show = true;
  25              $viewName = 'Hide Comments';
  26          } else {
  27              $show = false;
  28              $viewName = 'View Comments';
  29          }
  30  
  31          $res = Comments::fetchComments($show);
  32          if (mnError::isError($res))
  33              return new mnError("Comments::displayComments($id): ". $res->getMessage(), __FILE__, __LINE__);
  34          sort($res);
  35          $id = DN::dnToName($this->ldapDN);
  36          $tpl = new Template_PHPLIB(T_APP_BASE .'Comments');
  37          $tpl->setFile(array('main' => 'comments.tpl.html'));
  38          $tpl->setBlock('main', 'titleBlock', 'titleB');
  39          $tpl->setBlock('main', 'linkBlock', 'linkB');
  40          $tpl->setVar('titleB', '');
  41          $tpl->setVar('linkB', '');
  42  
  43          if ($this->app == 'FolderViewer')
  44              $vars = '&block__'. $this->blockID .'__dn='.$this->httpVars['dn'];
  45          if ($this->app == 'FolderViewer' && !$this->can('admin'))
  46              $vars = '?'.$vars;
  47              
  48          if ($this->app == 'FolderViewer')
  49              $link = $this->link_to_file_view(DN::dnToName($this->httpVars['dn']));
  50          else
  51              $link = Utility::link(DN::dnToSectionArray($this->pageDN));
  52          $tpl->setVar('formaction', $link . '#cvcomments_'.$id);
  53          $count = count($res);
  54  
  55          if($this->app == 'FolderViewerMain') {
  56              return $count . ' comment' . ($count == 1 ? '' : 's');
  57          } else if ($this->app == 'FolderViewer' && $count > 0) {
  58              $tpl->setVar('comment_count', $count . ' comment' . ($count == 1 ? '' : 's'));
  59              $tpl->setVar('title', $this->commentsVars['title']);
  60              $tpl->parse('titleB', 'titleBlock');
  61          }
  62          
  63          $avg_rating = 0;  
  64          if ($count > 0) {
  65              $avg_rating = 0;
  66              foreach($res as $userRating) {
  67                    $avg_rating = $avg_rating + $userRating['rating'];
  68                 }
  69              $avg_rating = $avg_rating / $count;
  70             }
  71  
  72          if ($this->settingsVars['anonPosting'] != '' || Security::isUserInGroups($_SESSION['auth']->userDN, $this->settingsVars['postingGroups'], $this->ldap))
  73          {    
  74              if($this->app == 'FolderViewer') {
  75                  $this->httpVars['addCommentVal'] = 'block';
  76              } else {
  77                  $addCommentsHTML = ' | 
  78                            <a href="#cvcommentsadd_'.$id. '"><span style="cursor:pointer;"
  79                            onclick="if (document.getElementById(\'add_comment'.$id .'\').style.display==\'block\')
  80                                         {
  81                                         document.getElementById(\''.$this->paramName('addCommentVal').'\').value=\'none\';
  82                                         }
  83                                     else
  84                                         {
  85                                         document.getElementById(\''.$this->paramName('addCommentVal').'\').value=\'block\';
  86                                         }
  87                            document.getElementById(\''. $this->paramName('display').'\').value=\''.$this->httpVars['display'].'\';
  88                            document.commentsview'.$id .'.action = \''. Utility::link(array_reverse(DN::dnToSectionPathArray($this->section->ldapDN))). $vars .'#cvcommentsadd_'.$id .'\';document.commentsview'.$id .'.submit();">
  89                            Add Comment</span></a>';
  90              }
  91  
  92              if (isset($_SESSION['auth']->userDN)) {
  93                  require_once(T_APP_BASE . 'PersonalProfile/PersonalProfile.php');
  94                  $tpl->setVar('comment_author', '<b>Author:</b> ' . PersonalProfile::getRealName(T_USER));
  95              } else
  96                  $tpl->setVar('comment_author', '<b>Author:</b> (Leave blank for anonymous)<br />'.FormWidget::text('commentAuthor', '', 20));                
  97              $tpl->setVar('comment_title', FormWidget::hidden('addRating', '').FormWidget::text('commentTitle', '', 20));
  98              $tpl->setVar('comment_text', FormWidget::hidden('moreShow',$this->httpVars['moreShow'],array('id' => $this->paramName('moreShow'))).FormWidget::textarea('commentsText', '', 8, 20, array('style' => 'width:99%;')));
  99              $tpl->setVar('submit', FormWidget::submit('submitComment', 'Submit', array('onclick' => 'document.getElementById(\''. $this->paramName('display').'\').value=\'block\';')));
 100          }
 101  
 102          $tpl->setVar('id', $id);
 103          $tpl->setVar('num_comments', $count .' Comment(s) |  
 104                        <a href="#cvcomments_'.$id. '"><span style="cursor:pointer;" 
 105                        onclick="if (document.getElementById(\'comment_body'.$id .'\').style.display==\'block\')
 106                                     {
 107                                     document.getElementById(\''. $this->paramName('display').'\').value=\'none\';
 108                                     }
 109                                 else
 110                                     {
 111                                     document.getElementById(\''. $this->paramName('display').'\').value=\'block\';
 112                                     }
 113                        document.getElementById(\''.$this->paramName('addCommentVal').'\').value=\''.$this->httpVars['addCommentVal'].'\';
 114                        document.commentsview'.$id .'.submit();">
 115                        '. $viewName .'</span></a>'. $addCommentsHTML .
 116                        FormWidget::hidden('addCommentVal','',array('id' => $this->paramName('addCommentVal'))));
 117          $tpl->setVar('display', FormWidget::hidden('display','',array('id' => $this->paramName('display'))));
 118          if ($this->settingsVars['noRating'])
 119          {              
 120              for ($i=1; $i <= 5;$i++)
 121                  {
 122                  if ($i <= $avg_rating)
 123                      $img_avg_rating .= '<img src="/.cWimg/icons/new_16.png">';
 124                  else
 125                      $img_avg_rating .= '<img src="/.cWimg/icons/newgrey_16.png">';
 126                  $rating .= '<img style="cursor:pointer;" id="ratingImg'.$id . $i .'" title="'. $i .'"
 127                                                 onclick    ="setRating(this.title);
 128                                                              document.commentsview'. $id .'.'.$this->paramName('addRating').'.value = getRating();"
 129                                                 onmouseout ="changeRating(\''. $id .'\', this, \'true\');"
 130                                                 onmouseover="changeRating(\''. $id .'\', this, \'\');"
 131                                                    src="/.cWimg/icons/newgrey_16.png">';
 132                  }
 133              $tpl->setVar('avg_rating', $img_avg_rating);
 134              $tpl->setVar('rating', $rating);
 135              $tpl->setVar('ratingtitle', 'Rating: ');
 136              if (!$this->app)
 137                $tpl->parse('linkB', 'linkBlock');
 138          }
 139          $tpl->parse('linkB', 'linkBlock');
 140          if ($this->httpVars['addCommentVal'] == 'block')
 141              $tpl->setVar('add_display', $this->httpVars['addCommentVal']);
 142          else
 143              $tpl->setVar('add_display', 'none');            
 144          if ($show)
 145              {
 146              if (count($this->httpVars['moreShow']>0))
 147                 $moreOn = array_diff(explode(';', $this->httpVars['moreShow']), array(''));
 148              $tpl->setVar('comment_display', $this->httpVars['display']);
 149              $tpl->setVar('hiddenRemove', FormWidget::hidden('removeComment', '').FormWidget::hidden('reportComment', ''));
 150              $tpl->setBlock('main', 'commentsBlock', 'commentsB');
 151              foreach ($res as $num => $field)
 152                  {
 153                      preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/', $field['date'], $t);
 154                      $date = mktime($t[4], $t[5], $t[6], $t[2], $t[3], $t[1]);
 155                      $field['date'] = date('F d, Y', $date) . ' at ' . date('g:i a', $date);
 156                      if ($field['owner'] != 'cv_anonymous' && (strpos($field['owner'], ',ou=') !== false))
 157                          {
 158                            $popupLink = Utility::link($this->pathArray, array('_single' => 'tmpPersonalProfile', 'block__tmpPersonalProfile__userDN' => $field['owner'], 'block__tmpPersonalProfile__page_from_link' => $this->ldapDN));
 159                          $onClick = "popup('$popupLink', 'Personal Profile', 350, 250); return false;";
 160                          $field['owner'] = DN::dnToName($field['owner']);
 161                          require_once(T_APP_BASE . 'PersonalProfile/PersonalProfile.php');
 162                          $field['owner'] = PersonalProfile::getRealName($field['owner']);
 163                          $field['owner'] = '<a href="" onclick="'. $onClick .'">'.$field['owner'].'</a>';
 164                          }
 165                      if ($this->can('admin'))    
 166                          $delete = '<img style="padding-top: 2px;padding-right:2px;" src="/.cWimg/icons/remov_16.png"
 167                                                  onclick="document.commentsview'. $id . '.'.$this->paramName('removeComment').'.value=\''.$field['id'].'\';document.getElementById(\''. $this->paramName('display').'\').value=\''.$this->httpVars['display'].'\';document.commentsview'. $id .'.submit();">';
 168                      else
 169                          $delete = '';
 170                      
 171                      $report = '<a href="#cvcomments_'.$id. '"><span onclick="document.commentsview'. $id . '.'.$this->paramName('reportComment').'.value=\''.$field['id'].'\';document.getElementById(\''. $this->paramName('display').'\').value=\''.$this->httpVars['display'].'\';alert(\'This comment has been reported successfully, The site administrator will take appropriate action.\');document.commentsview'. $id .'.submit();">report comment</span></a>';
 172                      if ($this->settingsVars['clipLen'] == '')
 173                            $this->settingsVars['clipLen'] = 75;
 174                      if ($this->settingsVars['clipComm'] == 'on')
 175                          {
 176                          if (in_array($num, $moreOn))
 177                              $Msg = '<div style="display:'. $full .';" id="fullMsg'. $num .'">'.$field['data'].'&nbsp;&nbsp;<a href="#cvcomments_'.$id. '" onclick="var element=document.getElementById(\''.$this->paramName('moreShow').'\');removeMoreShow(element, \''. $num .';\', \''.$this->httpVars['moreShow'].'\');document.getElementById(\''. $this->paramName('display').'\').value=\''.$this->httpVars['display'].'\';document.getElementById(\''.$this->paramName('addCommentVal').'\').value=\''.$this->httpVars['addCommentVal'].'\';document.commentsview'.$id .'.submit();">less</a></div>';
 178                          else
 179                              {
 180                              if (strlen($field['data']) > $this->settingsVars['clipLen'])
 181                                  $Msg = '<div style="display:'. $part .';" id="partMsg'. $num .'">'.substr($field['data'], 0, $this->settingsVars['clipLen']).'...<a href="#cvcomments_'.$id. '" onclick="var element=document.getElementById(\''.$this->paramName('moreShow').'\');element.value=\''. $this->httpVars['moreShow'].$num .';\';document.getElementById(\''. $this->paramName('display').'\').value=\''.$this->httpVars['display'].'\';document.getElementById(\''.$this->paramName('addCommentVal').'\').value=\''.$this->httpVars['addCommentVal'].'\';document.commentsview'.$id .'.submit();">more</a></div>';     
 182                              else
 183                                  $Msg = $field['data'];
 184                              }
 185                          
 186                          }
 187                      else
 188                          $Msg = $field['data'];
 189                          
 190                      $commentHTML = @$this->settingsVars['arrangeComments'] ? $this->settingsVars['arrangeComments'] : Comments::_default_template();
 191                      $commentHTML = str_replace('|title|', $field['title'].'', $commentHTML);
 192                      $commentHTML = str_replace('|author|', $field['owner'], $commentHTML);
 193                      $commentHTML = str_replace('|date|', $field['date'], $commentHTML);
 194                      $commentHTML = str_replace('|body|', $Msg , $commentHTML);
 195                      $commentHTML = str_replace('|report|', $report, $commentHTML);
 196                      $commentHTML = str_replace('|delete|', $delete, $commentHTML);
 197  
 198                      $tpl->setVar('commentHTML', $commentHTML);
 199                      $tpl->parse('commentsB', 'commentsBlock', true);
 200  
 201                  }
 202               }
 203          else
 204              $tpl->setVar('comment_display', 'none');
 205          return $tpl->subst('main');
 206          }
 207                  
 208      function fetchComments($show = false, $linkid = '')
 209          {
 210          if ($linkid == '')
 211              $linkid = $this->linkid;
 212              
 213          if (!$show)
 214              $sql = "SELECT rating FROM comments WHERE linkid='" . addslashes($linkid) . "'";
 215          else
 216              $sql = "SELECT * FROM comments WHERE linkid='" . addslashes($linkid) . "'";
 217              
 218          $res = $this->db->getAll($sql, null, DB_FETCHMODE_ASSOC);
 219          if (is_object($res))
 220              return new mnError("Comments::getComments($id): ". $res->getMessage(), __FILE__, __LINE__);
 221          return $res;
 222          }
 223          
 224  	function notifyAdminReported($commentID)
 225          {
 226          $sql = "SELECT * FROM comments WHERE id='$commentID'";
 227          $res = $this->db->getAll($sql, null, DB_FETCHMODE_ASSOC);
 228          if (is_object($res))
 229              return new mnError("Comments::getComments($id): ". $res->getMessage(), __FILE__, __LINE__);
 230              
 231          $subject = 'Reported Comment';      
 232          $message = 'This comment has been reported on '.DN::dnToSiteDomain(T_ORG_DN)."\r\n";
 233          $message .= 'By: '. $res[0]['owner']."\r\n";
 234          $message .= 'Title: '. $res[0]['title']."\r\n";
 235          $message .= 'Date: '. $res[0]['date']."\r\n";
 236          $message .= 'Content: '. $res[0]['data']."\r\n";
 237          $headers = 'From: noreply@'. DN::dnToSiteDomain(T_ORG_DN)  . "\r\n" . 'X-Mailer: PHP/' . phpversion();
 238          $address = T_ADMIN_EMAIL;
 239          mail($address, $subject, $message, $headers);
 240          }
 241  
 242  	function onSave()
 243          { 
 244            if ($this->httpVars['anonPosting'] == '') 
 245                {
 246                $postingGroups = array();
 247                  $groups = Security::getSiteGroups(T_ORG_DN, $this->ldap);
 248                  foreach ($groups as $groupdn => $group)
 249                        {
 250                          $groupName = str_replace(' ', '', $group);
 251                          if (isset($this->httpVars['option'.$groupName]))
 252                              {
 253                              $postingGroups[$groupName] = $groupdn;
 254                              }
 255                        }
 256                $this->settingsVars['postingGroups'] = $postingGroups;
 257                  }
 258            $this->settingsVars['arrangeComments'] = $this->httpVars['arrangeComments'];
 259            $this->settingsVars['anonPosting'] = $this->httpVars['anonPosting'];
 260            $this->settingsVars['FileAttach'] = $this->httpVars['FileAttach'];
 261            $this->settingsVars['noRating'] = $this->httpVars['noRating'];
 262            $this->settingsVars['advanced'] = $this->httpVars['advanced'];
 263            $this->settingsVars['reportNotify'] = $this->httpVars['reportNotify'];
 264            $this->settingsVars['clipComm'] = $this->httpVars['clipComm'];
 265            if ($this->httpVars['clipLen'] == '')
 266                $this->httpVars['clipLen'] = 75;
 267            $this->settingsVars['clipLen'] = $this->httpVars['clipLen'];
 268            $this->saveSettings($this->settingsVars);
 269          }
 270  
 271  	function getContent($app = '')
 272          {
 273          if ($app == 'FolderViewer' || $app == 'FolderViewerMain')
 274              {
 275              $this->linkid = $this->httpVars['dn'];
 276              $this->app = $app;
 277              }
 278          if ($app == '')
 279              {
 280              if ($this->settingsVars['FileAttach'] != '')
 281                  {
 282                  $this->linkid = $this->section->blocks[DN::dnToName($this->section->blocks[DN::dnToName($this->ldapDN)]->parentDN)];
 283                  $this->linkid = $this->linkid->app->params['fileDN'];
 284                  }
 285              else
 286                   $this->linkid = $this->section->blocks[DN::dnToName($this->ldapDN)]->parentDN;
 287              }
 288                $res = Comments::_connect();
 289                if(mnError::isError($res))
 290                    { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }                                                                                       
 291  
 292            if ($this->httpVars['reportComment'] != '')
 293                {
 294                $sql = 'UPDATE COMMENTS SET reported=\'y\'WHERE ID=\''.$this->httpVars['reportComment'].'\'';
 295                $res = $this->db->query($sql);
 296                if(mnError::isError($res))
 297                    { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }
 298                    
 299                if ($this->settingsVars['reportNotify'])
 300                    $this->notifyAdminReported($this->httpVars['reportComment']);
 301                }
 302  
 303            if ($this->httpVars['removeComment'] != '')
 304                {
 305                $sql = 'DELETE FROM COMMENTS WHERE ID=\''.$this->httpVars['removeComment'].'\'';
 306                $res = $this->db->query($sql);
 307                if(mnError::isError($res))
 308                    { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }              
 309                }
 310                  
 311            $ret = '';  
 312            if (isset($this->httpVars['submitComment']))
 313                  {
 314                      if ($this->httpVars['commentAuthor'] != '')
 315                          $author = @$this->httpVars['commentAuthor'];
 316                      else
 317                          $author = 'anonymous';
 318                      $user = isset($_SESSION['auth']->userDN) ? $_SESSION['auth']->userDN : $author;
 319                      
 320                      if (Utility::looks_like_form_spam($this->httpVars['commentTitle']) or Utility::looks_like_form_spam($this->httpVars['commentsText'])) {
 321                            $ret = Widget::getWizardHelp('Sorry, your comment appears to be spam and has been rejected.  Make sure you did not include any HTML links.');
 322                    } else {
 323                        $title = str_replace("'", "\'", strip_tags($this->httpVars['commentTitle']));
 324                        $title = str_replace('"', '\"', $title);
 325                        $data = str_replace("\n","<br />", strip_tags($this->httpVars['commentsText']));
 326                        $data = str_replace("'", "\'", $data);
 327                        $data = str_replace('"', '\"', $data);
 328                        $rating = 0;
 329                        if ($this->httpVars['addRating'] != '')
 330                            $rating = $this->httpVars['addRating'];
 331                        $linkid = $this->linkid;
 332                        $sql = "INSERT INTO COMMENTS (title, owner, data, linkid, date, rating, reported) VALUES ('$title', '$user', '$data', '$linkid', CURRENT_TIMESTAMP, '$rating', '')";
 333                        $res = $this->db->query($sql);
 334                        if(mnError::isError($res))
 335                            { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }
 336                    }
 337                  }
 338            $ret .= Comments::getComments();
 339      
 340            return $ret;
 341  
 342          }
 343  	function getConfig($app = '')
 344          {
 345            $action = $this->linkToSelf();
 346            $formname = 'comments_config';
 347            $parent = DN::dnToName($this->section->blocks[DN::dnToName($this->ldapDN)]->parentDN);
 348            if ($app == 'FolderViewer')
 349                {
 350                $f = FormWidget::init('' ,'form.noformtag.tpl.html');
 351                $formname = 'main';
 352                }
 353            else
 354                {
 355                if (strpos($action, '#') != '')
 356                  $f = FormWidget::init(substr($action, 0, strpos($action, '#')).'?&block__'. $parent .'__edit=1;#comments_edit');
 357                else
 358                  $f = FormWidget::init($action);
 359                }
 360            $f->name($formname);
 361            $res = Comments::_connect();
 362            if(mnError::isError($res))
 363                { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }
 364            $view = 'none';    
 365            $f->hidden('removeComment', '');
 366            $f->hidden('unReport', '');
 367  
 368            if ($this->httpVars['removeComment'] != '')
 369                {
 370                $view = 'block';
 371                if ($this->httpVars['removeComment'] == 'all')
 372                  $sql = 'DELETE FROM COMMENTS WHERE REPORTED=\'y\'';
 373                else
 374                    $sql = 'DELETE FROM COMMENTS WHERE ID=\''.$this->httpVars['removeComment'].'\'';
 375                $res = $this->db->query($sql);
 376                if(mnError::isError($res))
 377                    { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }              
 378                }    
 379                
 380            if ($this->httpVars['unReport'] != '')
 381                {
 382                $view = 'block';
 383                if ($this->httpVars['unReport'] == 'all')
 384                  $sql = 'UPDATE COMMENTS SET reported=\'\'';
 385                else
 386                    $sql = 'UPDATE COMMENTS SET reported=\'\' WHERE ID=\''.$this->httpVars['unReport'].'\'';
 387                $res = $this->db->query($sql);
 388                if(mnError::isError($res))
 389                    { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }
 390                }
 391                
 392            $sql = 'SELECT * FROM COMMENTS WHERE reported=\'y\'';
 393            $res = $this->db->getAll($sql, null, DB_FETCHMODE_ASSOC);
 394            
 395            $sitedn = DN::dnToOrg($this->ldapDN);
 396            foreach($res as $k => $v)
 397                {
 398                if(strpos($v['linkid'], $sitedn) != true)
 399                    unset($res[$k]);              
 400                }
 401                
 402                if(mnError::isError($res))
 403                    { return new mnError('CLASS::FUNCTION(): ' . $res->getMessage(), __FILE__, __LINE__); }
 404  
 405            $amount = count($res);
 406            $result =  '<div id=\'reportedComments\' style=\'display:'. $view .';\'>
 407                          <table cellpadding=0 cellspacing=0 style=\'width: 300px; background-color: #ffffff; border: solid 1px #000000;\'>
 408                             <tr><td style=\'text-align:center;color: #000000;border-right: solid 1px #000000; border-bottom: solid 1px #000000;background-color: #EEE;\'>Comment</td><td style=\'width: 15%;text-align:center;color: #000000; border-right: 1px solid #000000;border-bottom: solid 1px #000000;background-color: #EEE;\'>Delete</td><td style=\'width: 15%;text-align:center;color: #000000; border-bottom: solid 1px #000000;background-color: #EEE;\'>Accept</td></tr>';
 409            foreach($res as $key => $comment)
 410                 {
 411                if ($key%2 != 0)
 412                   $row_color = 'background-color: #f2f2f2;';
 413               else
 414                   $row_color = 'background-color: #ffffff;';
 415                
 416               if (!$this->ldap->dnExists($comment['owner']))
 417                   $comment['owner'] .= '(Anonymous)';
 418               else {
 419                    $popupLink = Utility::link($this->pathArray, array('_single' => 'tmpPersonalProfile', 'block__tmpPersonalProfile__userDN' => $comment['owner'], 'block__tmpPersonalProfile__page_from_link' => $this->ldapDN));
 420                    $onClick = "popup('$popupLink', 'Personal Profile', 350, 250); return false;";
 421                    $comment['owner'] = DN::dnToName($comment['owner']);
 422                    $comment['owner'] = '<a href="" onclick="'. $onClick .'">'.$comment['owner'].'</a>'; 
 423                    }
 424                  
 425                   
 426                  
 427               preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/', $comment['date'], $t);
 428               $comment['date'] = date('D, d M Y h:i:sA T', mktime($t[4], $t[5], $t[6], $t[2], $t[3], $t[1]) );
 429               $result .= '<tr><td style=\'border-bottom:1px solid #000000;border-right: solid 1px #000000;text-align:center;padding: 2px; ' . $row_color . '\'>Author: <span style="cursor:pointer;color: rgb(124, 71, 90);">' . $comment['owner'] . '</span><div style="display:block;">Content: <a href=""  onclick="var element = document.getElementById(\''. $key  .'\');if (element.style.display==\'block\')element.style.display=\'none\';else element.style.display=\'block\';return false;">View</a><br /><div id="'. $key .'" style="display:none;color: rgb(124, 71, 90);">'. $comment['data'] .'</div>Title: <span style="color: rgb(124, 71, 90);">'.$comment['title'].'</span><br />Date: <span style="color: rgb(124, 71, 90);">'.$comment['date'].'</span></div></td>
 430                              <td style=\'text-align:center;padding: 2px; border-bottom:1px solid #000000; border-right:1px solid #000000;' . $row_color . '\'>
 431                              <img onclick="document.' . $formname . '.'.$this->paramName('removeComment').'.value=\''.$comment['id'].'\';document.' . $formname . '.submit();" style=\'cursor:pointer;\' src="/.cWimg/icons/remov_16.gif"></td>
 432                              <td style="border-bottom: 1px solid #000000;' . $row_color . '"><img onclick="document.' . $formname . '.'.$this->paramName('unReport').'.value=\''.$comment['id'].'\';document.' . $formname . '.submit();" style=\'cursor:pointer;\' src="/.cWimg/icons/go_16.gif"></td></tr>';
 433  
 434               }
 435            $result .= '<tr><td style=\'border-top:solid 1px #000000;border-right: solid 1px #000000;text-align:center;padding: 2px; background-color: #ffffff;\'>All Reported Comments</td><td style=\'border-right:1px solid #000000; text-align:center;padding: 2px; background-color: #ffffff;\'><img onclick="document.' . $formname . '.'.$this->paramName('removeComment').'.value=\'all\';document.' . $formname . '.submit();" style=\'cursor:pointer;\' src="/.cWimg/icons/remov_16.gif"></td><td><img onclick="document.' . $formname . '.'.$this->paramName('unReport').'.value=\'all\';document.' . $formname . '.submit();" style=\'cursor:pointer;\' src="/.cWimg/icons/go_16.gif"></td></tr>';
 436            $result .= '</table></div>';
 437     
 438              $f->html('<a name="comments_edit"></a><div style="width:100%;text-align:center;"> '.$amount .' comment(s) have been reported.<a href="" onclick="if (document.getElementById(\'reportedComments\').style.display == \'none\')document.getElementById(\'reportedComments\').style.display = \'block \'; else document.getElementById(\'reportedComments\').style.display = \'none\';return false;"> Click Here To View</a>
 439                      <table><tr><td style="width:50%;"></td><td>'.$result .'</td><td style="width:50%;"></td></tr></table></div>');
 440            $f->html('<b><h3>Comments and Rating Application:</h3></b>');
 441            $f->section();
 442            $f->field('Notify/Email Admin of reported Comments:', '', '', array(), array('width' => '30%'));
 443            $f->checkbox('reportNotify', $this->settingsVars['reportNotify']);
 444            if ($app == '')
 445                {
 446                $f->field('Use Files Comments:');
 447                $f->checkbox('FileAttach', $this->settingsVars['FileAttach']);
 448                }
 449            $f->field('Clip long comments:');
 450            $f->checkbox('clipComm', $this->settingsVars['clipComm']);
 451            $f->field('Clip after how many characters:');
 452            $f->text('clipLen', $this->settingsVars['clipLen'], '2');
 453            $f->field('Allow Rating:');
 454            $f->checkbox('noRating', $this->settingsVars['noRating']);
 455            $f->field('Show Advanced Layout Options:');
 456            $f->checkbox('advanced', $this->settingsVars['advanced'], '', array('onclick' => '
 457                                var element = this;
 458                                var element2 = document.getElementById(\'advancedOptions\');
 459                                if (element.checked == false)
 460                                    element2.style.display = \'none\'
 461                                else
 462                                    element2.style.display = \'block\''));
 463            $f->field('Anonymous Posting:');
 464            $f->checkbox('anonPosting', $this->settingsVars['anonPosting'], '', array('onclick' => '
 465                                var element = this;
 466                                var element2 = document.getElementById(\'permDiv\');
 467                                if (element.checked == true)
 468                                    element2.style.display = \'none\'
 469                                else
 470                                    element2.style.display = \'block\''));
 471            $f->endSection();                  
 472            $groups = Security::getSiteGroups(T_ORG_DN, $this->ldap);
 473            if ($this->settingsVars['anonPosting'] != '')
 474                 $divDisplay = 'none';
 475            else
 476                 $divDisplay = 'block'; 
 477            
 478            $groupsAllow = '<div id="permDiv" style="display:'. $divDisplay  .';width:100%;">
 479                            <table><tr><td style="width:50%;"></td><td>
 480                            <table style="text-align:left;border:1px solid #000;width:250px;">
 481                              <tr><td style="text-align:center;background-color:#EEE;" colspan=2>Posting Allowed Groups:</td></tr>';
 482            $i = 0;
 483            foreach ($groups as $groupdn => $group)
 484                {
 485                 $groupName = str_replace(' ','', $group);
 486                 $postingGroups = $this->settingsVars['postingGroups'];
 487                 if ($i%2 == 0)
 488                    $groupsAllow .= '<tr><td style="border-top:1px solid #000;">'.FormWidget::checkbox('option'.$groupName, isset($postingGroups[$groupName]), $group);
 489                 else
 490                    $groupsAllow .= '</td><td style="border-top:1px solid #000;border-left:1px solid #000;">'. FormWidget::checkbox('option'.$groupName, isset($postingGroups[$groupName]), $group)  .'</td></tr>';
 491                 $i++;
 492                }
 493            if ($i%2 != 0)
 494                $groupsAllow .= '</td><td>&nbsp;</td></tr>';
 495            $groupsAllow .= '</table></td><td style="width:50%;"></td></tr></table></div>';
 496            if ($this->settingsVars['advanced'])
 497                $advancedShow = 'block';
 498            else
 499                $advancedShow = 'none';
 500            $f->html($groupsAllow .'</div><div id="advancedOptions" style="display:'. $advancedShow .';">');  
 501            $f->html('<div style="text-align:center;"><br /><b>Comments Layout and HTML:</b><br />');                    
 502            $f->select('arrangeCommentsOptions', array('title' => 'Comment Title', 'author' => 'Comment Author', 'date' => 'Comment Date', 'body' => 'Comment Body','delete' => 'Delete Comment', 'report' => 'Report Comment'), '', '', 7, array('style' => 'width:50%;height:75px;'));            
 503            $f->html('<br />');
 504            $f->button('addCommentOption', 'Add', 'cv_insertAtCursor( document.' . $formname . '.'.$this->paramName('arrangeComments').', \'|\' + document.' . $formname . '.'.$this->paramName('arrangeCommentsOptions').'.value + \'|\' );');
 505            
 506            $layout = Comments::_default_template();
 507            $f->button('defaultOption', 'Use Default', '', array('onclick' => 'confirm(\'Restoring to the default format will cause you to lose any work you have done on the current format. Are you sure you wish to continue?\');document.' . $formname . '.'.$this->paramName('arrangeComments').'.value = \''.str_replace(array("'", "\n"), array("\'", "\\n"),  $layout) .'\''));
 508  
 509            if (isset($this->settingsVars['arrangeComments']))
 510                {
 511                  $layoutHTML = $this->settingsVars['arrangeComments'];
 512                }
 513            else
 514                  $layoutHTML = $layout;
 515            $f->textarea('arrangeComments', $layoutHTML ,0, 0, array('style' => 'width:100%;height:120px;'));            
 516            $f->html('</div></div>');
 517  
 518            $f->html('<br /><br />');
 519            if ($app == '')
 520                $f->defaultButtons();
 521            return $f->get();
 522          }  
 523      function getHeader()
 524          {
 525          return '<script language="Javascript" type="text/javascript">
 526                    var rating = 0;
 527      	          function removeMoreShow(elem, item, list)
 528                      {
 529                      elem.value = list.replace(item, \'\');
 530                      }
 531      	          function setRating(rate)
 532                      {
 533                      rating = rate;
 534                      }
 535  				  function getRating()
 536                        {
 537  
 538                        return rating;
 539                        }
 540      	          function changeRating(id, img, reset)
 541                        {
 542                      for (var i = 1; i <=5; i++)
 543                          {
 544                          var rImg = \'ratingImg\'+id+i;
 545                          if (reset == \'true\')
 546                              {
 547                              if (i <= rating)
 548                                  document.getElementById(\'\'+rImg).src=\'/.cWimg/icons/new_16.png\';
 549                              else
 550                                  document.getElementById(\'\'+rImg).src=\'/.cWimg/icons/newgrey_16.png\';
 551                              }
 552                          else if (i <= img.title)
 553                              document.getElementById(\'\'+rImg).src=\'/.cWimg/icons/new_16.png\';
 554                          else
 555                              document.getElementById(\'\'+rImg).src=\'/.cWimg/icons/newgrey_16.png\';
 556                          }
 557                        }
 558                  </script>';
 559          }
 560  
 561  	function _default_template() {
 562          return <<<END
 563  <div class="cvCommentHeader">
 564    <div style="float:left;text-align:left;vertical-align:middle">|delete|</div>
 565    <div class="cvCommentTitle">|title|</div>
 566    <div class="cvCommentReportLink">|report|</div>
 567    <br />
 568    <span class="cvCommentInfo">by |author| on |date|</span>
 569  </div>
 570  <div class="cvCommentBody">|body|</div>
 571  END;
 572      }
 573  
 574  }
 575        
 576  ?>

title

Description

title

Description

title

Description

title

title

Body