File indexing completed on 2024-12-29 05:24:49

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  *
0022  * Created: 31.05.2017
0023  */
0024     $project = new Default_Model_Project();
0025     $member = new Default_Model_Member();
0026 
0027 
0028 ?>
0029 <style type="text/css">
0030     div.dangerous{
0031         background: red;
0032     }
0033     a.dangerous{
0034         color:red;
0035     }
0036 
0037 </style>
0038 <main id="explore-content">
0039     <section class="wrapper" id="products-wrapper">
0040         <div class="container-fluid">
0041             <div class="row">
0042                 <div class="sidebar-left col-md-2"></div>
0043                 <div class="content col-md-8">
0044                     <?php
0045                     $helperPrintDate = new Default_View_Helper_PrintDate();
0046                     $helperBuildProductUrl = new Default_View_Helper_BuildProductUrl();
0047                     $helperImage = new Default_View_Helper_Image();
0048                     $helpMemberUrl = new Default_View_Helper_BuildMemberUrl();
0049 
0050                     $this->rownum = (1 + (($this->page - 1) * 10));
0051                     $pageLimit = 10;
0052 
0053                     $modelSpam = new Default_Model_Spam();
0054                     $candidateProducts = $modelSpam->fetchSpamCandidate();
0055 
0056                     $paginator = Zend_Paginator::factory($candidateProducts);
0057                     $paginator->setItemCountPerPage($pageLimit);
0058                     $paginator->setCurrentPageNumber($this->page);
0059                     //$paginator->setTotalItemCount(count($candidateProducts));
0060 
0061                     $this->products = $paginator;
0062                     if ($paginator->count() == 0) {
0063                         echo '<div class="alert alert-success" role="alert"><p class="text-success">Congratulations. No more SPAM in sight. (For the moment)</p></div>';
0064                     }
0065                     foreach ($this->products as $this->product) {
0066                         $updateTime = $helperPrintDate->printDate($this->product['project_changed_at']);
0067                         $validProject = $project->validateDeleteProjectFromSpam($this->product['project_id']);
0068                         $validUser =    $member->validDeleteMemberFromSpam($this->product['member_id']);
0069                         
0070                         $cssvalid='';
0071                         if(!$validProject || !$validUser)         
0072                         {
0073                             $cssvalid='dangerous';
0074                         }
0075                            
0076                         ?>
0077                         <div class="explore-product col-lg-10 col-md-10 col-sm-10 col-xs-10 <?=$cssvalid?>"
0078                              style="border-top: 1px solid #ccc;font-size: 12px;padding: 10px 0;">
0079                             <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
0080                                 <div class="rownum">
0081                                     <?= intval($this->rownum) ?>.
0082                                 </div>
0083                             </div>
0084                             <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 explore-product-imgcolumn">
0085                                 <figure>
0086                                     <a href="<?= $helperBuildProductUrl->buildProductUrl($this->product['project_id'],
0087                                         ''); ?>">
0088                                         <div class="text-center">
0089                                             <img src="<?php echo $helperImage->Image($this->product['image_small'],
0090                                                 array('width' => 167, 'height' => 167)); ?>"
0091                                                  class="explore-product-image" style="max-width:95%;"/>
0092                                         </div>
0093                                     </a>
0094                                 </figure>
0095                             </div>
0096                             <div class="explore-product-details col-lg-7 col-md-7 col-sm-7 col-xs-7">
0097                                 <h3>
0098                                     <?php
0099                                     $version = Default_Model_HtmlPurify::purify($this->product['version']);
0100                                     ?>
0101                                     <a href="<?= $helperBuildProductUrl->buildProductUrl($this->product['project_id'],
0102                                         ''); ?>"><?php echo $this->product['title']; ?> <span
0103                                                 style="font-size: smaller; padding-left: 20px"><?php echo $version ?> </span></a>
0104                                 </h3>
0105 
0106                                 <b style="display: block; margin-bottom: 5px"><?php echo $this->product['cat_title'] ?></b>
0107                                 <b style="display: block; margin-bottom: 5px" class="small">by <a
0108                                             href="<?php echo $helpMemberUrl->buildMemberUrl($this->product['username']) ?>"><?php echo $this->product['username'] ?></a></b>
0109                                 <?php
0110                                 if (false === empty($this->product['package_names'])) {
0111                                     $list_packages = explode(',', $this->product['package_names']);
0112                                     $resultString = "";
0113                                     foreach ($list_packages as $item) {
0114                                         $resultString = $resultString . ' <span class="packagetypeos" > ' . stripslashes($item) . '</span>';
0115                                     }
0116                                     echo $resultString;
0117                                 }
0118                                 
0119                                 
0120                                 /*$helperPackageTypes = new Default_View_Helper_FetchProjectPackageTypes();
0121                                 $type = $helperPackageTypes->FetchProjectPackageTypes($this->product['project_id']);
0122                                 if (!empty($type)) {
0123                                     ?>
0124                                     <?= $type ?>
0125                                 <?php } */
0126                                 
0127                                 ?>
0128 
0129                                 <div class="productInfo">
0130                                     <?php
0131                                     
0132                                     $count_comments = $this->product['count_comments'];
0133                                     
0134                                     echo ($count_comments > 0 ? '<span class="cntComments">' . $count_comments
0135                                             . ' comment' : '') . ($count_comments > 1 ? 's' : '') . ($count_comments > 0
0136                                             ? '</span>' : '');
0137                                     ?>
0138                                 </div>
0139                             </div>
0140                             <div class="explore-product-plings col-lg-2 col-md-2 col-sm-2 col-xs-2">
0141                                 <!-- RATING -->
0142                                 <?php
0143                                 $this->widgetRating = new stdClass();
0144                                 $this->widgetRating->project_id = $this->product['project_id'];
0145                                 $this->widgetRating->laplace_score = $this->product['laplace_score'];
0146                                 $this->widgetRating->count_likes = $this->product['count_likes'];
0147                                 $this->widgetRating->count_dislikes = $this->product['count_dislikes'];
0148                                 // it is a trial
0149                                 include APPLICATION_PATH . '/modules/default/views/scripts/partials/widgetRating.phtml';
0150                                 //echo $this->render('partials/widgetRating.phtml'); ?>
0151                                 <!-- /RATING -->
0152 
0153                                 <div class="collected">
0154                                     <span><?php echo $updateTime ?></span>
0155                                 </div>
0156 
0157                             </div>
0158                         </div><!-- END .explore-product -->
0159                         <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 small text-right"
0160                              style="border-top: 1px solid #ccc;font-size: 12px;padding: 10px 0; ">
0161                              <?php
0162                                 if($validProject && $validUser)
0163                                 {
0164                              ?>
0165                                 
0166                                 <a href="/backend/project/delete?project_id=<?= $this->product['project_id'] ?>"
0167                                    class="delete-this dangerous" data-title="Delete this product?">delete product</a>
0168                                 <hr/>
0169                                 <a href="/backend/user/delete?member_id=<?= $this->product['member_id'] ?>"
0170                                    class="delete-this dangerous" data-title="Delete this member and all his products and comments?">delete
0171                                     user</a>
0172                                 <hr/>
0173                            
0174                            <?php }?>
0175                                                     
0176 
0177                             <a href="/backend/reportproducts/nospam?p=<?= $this->product['project_id'] ?>"
0178                                class="delete-this" data-title="Reset reports and set product spam checked?">clear
0179                                 reports (<?= $this->product['amount_reports'] ?>)</a>
0180                             <hr/>
0181                             <a href="/backend/reportproducts/validatemisuse?p=<?= $this->product['project_id'] ?>"
0182                                class="delete-this" data-title="Validate this project as misuse!">validate misuse</a>
0183                         </div>
0184                         <?php
0185                         $this->rownum++;
0186                     }
0187                     ?>
0188                 </div>
0189                 <div class="sidebar-right col-md-2"></div>
0190             </div>
0191             <section class="explore-footer text-center">
0192                 <?php echo $this->paginationControl($this->products, 'Sliding',
0193                     'partials/paginationControlWithoutAjax.phtml',
0194                     array('params' => $this->filters, 'dom_target' => 'section#products-wrapper')); ?>
0195             </section>
0196         </div>
0197     </section>
0198 </main>
0199 
0200 <script>
0201     $('.delete-this').on('click', function (event) {
0202         event.stopPropagation();
0203         var popupText = $(this).attr('data-title');
0204         var result = confirm(popupText);
0205         if (result) {
0206             var target = $(this).attr('href');
0207             $.ajax({
0208                 url: target,
0209                 success: function (results) {
0210                     location.reload();
0211                     //alert('Deleted successfully');
0212                 },
0213                 error: function () {
0214                     alert('Service is temporarily unavailable.');
0215                 }
0216             });
0217         }
0218 
0219         return false;
0220     });
0221 </script>