Exemple #1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_RateDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #2
0
 public function findUserSocre($userId, $entityType, array $entityIdList)
 {
     $score = $this->rateDao->findUserScore($userId, $entityType, $entityIdList);
     $result = array();
     foreach ($score as $val) {
         $result[$val[BOL_RateDao::ENTITY_ID]] = $val[BOL_RateDao::SCORE];
     }
     foreach (array_diff($entityIdList, array_keys($result)) as $id) {
         $result[$id] = 0;
     }
     return $result;
 }
Exemple #3
0
 public function findAlbumPhotoList($albumId, $listType, $offset, $limit, $privacy = null)
 {
     $privacySql = $privacy === null ? "1" : "`p`.`privacy`='{$privacy}'";
     switch ($listType) {
         case 'featured':
             $query = 'SELECT `p`.*
                 FROM `' . $this->getTableName() . '` AS `p`
                 INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON ( `p`.`albumId` = `a`.`id` )
                 INNER JOIN `' . PHOTO_BOL_PhotoFeaturedDao::getInstance()->getTableName() . '` AS `f` ON (`f`.`photoId`=`p`.`id`)
                 WHERE `p`.`status` = :status AND `p`.`albumId` = :albumId AND ' . $privacySql . '
                 AND `f`.`id` IS NOT NULL
                 ORDER BY `p`.`id` DESC
                 LIMIT :first, :limit';
             break;
         case 'toprated':
             $query = 'SELECT `p`.*, `r`.`' . BOL_RateDao::ENTITY_ID . '`, COUNT(`r`.id) as `ratesCount`, AVG(`r`.`score`) as `avgScore`
                 FROM `' . $this->getTableName() . '` AS `p`
                     INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON ( `p`.`albumId` = `a`.`id` )
                     INNER JOIN ' . BOL_RateDao::getInstance()->getTableName() . ' AS `r` ON (`r`.`entityId`=`p`.`id`
                         AND `r`.`' . BOL_RateDao::ENTITY_TYPE . '` = "photo_rates" AND `r`.`' . BOL_RateDao::ACTIVE . '` = 1)
                 WHERE `p`.`status` = :status AND `p`.`albumId` = :albumId AND ' . $privacySql . '
                 GROUP BY `p`.`id`
                 ORDER BY `avgScore` DESC, `ratesCount` DESC
                 LIMIT :first, :limit';
             break;
         case 'latest':
         default:
             $query = 'SELECT `p`.*
                 FROM `' . $this->getTableName() . '` AS `p`
                 INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON ( `p`.`albumId` = `a`.`id` )
                 WHERE `p`.`status` = :status AND `p`.`albumId` = :albumId AND ' . $privacySql . '
                 ORDER BY `p`.`id` DESC
                 LIMIT :first, :limit';
             break;
     }
     return $this->dbo->queryForList($query, array('albumId' => $albumId, 'first' => $offset, 'limit' => $limit, 'status' => 'approved'));
 }
Exemple #4
0
 public function onBeforeRender()
 {
     $id_user = OW::getUser()->getId();
     //citent login user (uwner)
     $is_admin = OW::getUser()->isAdmin();
     $curent_url = 'http';
     if (isset($_SERVER["HTTPS"])) {
         $curent_url .= "s";
     }
     $curent_url .= "://";
     $curent_url .= $_SERVER["SERVER_NAME"] . "/";
     $curent_url = OW_URL_HOME;
     /*
     $from_config=$curent_url;
     $from_config=str_replace("https://","",$from_config);
     $from_config=str_replace("http://","",$from_config);
     $trash=explode($from_config,$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
     $url_detect=$trash[1];
     //print_r($trash);
     //echo $url_detect;
     */
     $pageURL = 'http';
     if (isset($_SERVER["HTTPS"])) {
         $pageURL .= "s";
     }
     $pageURL .= "://";
     $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
     $content = "";
     /*
             if (!$this->userId){
                 echo "UKNOW!!";
             }else if ($this->userId==$this->feed_working_Id){
                 echo "OWNER!!!!";
             }else{
                 echo "GUEST!!!";
             }
     */
     $del_link = "";
     //        if ($this->userId==$this->feed_working_Id){//is owner
     if ($is_admin) {
         //is owner
         //$content .="<a href=\"html/editpage/0\"><b style=\"color:#080;\">[+] ADD NEW PAGE</b></a><a name=\"add_new_page\"></a>";
         $content .= "<a href=\"" . $curent_url . "pages/editpage/0?returl=" . urlencode($pageURL) . "\">";
         //            $content .="<b style=\"color:#080;\">[+] ".OW::getLanguage()->text('pages', 'main_menu_addpage')."</b>";
         $content .= "<div class=\"clearfix ow_submit ow_smallmargin\">\n                <div class=\"ow_center\">\n                    <span class=\"ow_button\">\n                        <span class=\" ow_positive\">\n                            <input type=\"submit\" name=\"ok\" value=\"" . OW::getLanguage()->text('pages', 'main_menu_addpage') . "\" class=\"ow_ic_add ow_positive\">\n                        </span>\n                    </span>\n                </div>\n            </div>";
         $content .= "</a>";
         $content .= "<a name=\"add_new_page\">";
         $content .= "</a>";
         $content .= "<hr>";
     }
     //        if ($this->feed_working_Id>0){
     $menu_list = "";
     $rateDao = BOL_RateDao::getInstance();
     if ($is_admin) {
         $add = "";
     } else {
         if ($id_user > 0 and !$is_admin) {
             $add = " WHERE active='1' AND is_visibleinmenu='1' AND (can_watch_groups='1' OR can_watch_groups='0') ";
             //for users
         } else {
             $add = " WHERE active='1' AND is_visibleinmenu='1' AND (can_watch_groups='2' OR can_watch_groups='0') ";
             //for guests
         }
     }
     $pluginStaticDir = OW::getPluginManager()->getPlugin('pages')->getStaticUrl();
     $query = "SELECT * FROM " . OW_DB_PREFIX . "pages " . $add . " ORDER BY order_main ASC, title";
     $arr = OW::getDbo()->queryForList($query);
     $resultArray = array();
     foreach ($arr as $value) {
         $seo_title = stripslashes($value['title']);
         $seo_title = str_replace(" ", "_", $seo_title);
         $seo_title = preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $seo_title);
         $seo_title = strtolower($seo_title);
         $del_link = "";
         $edit_link = "";
         //            if ($this->userId==$this->feed_working_Id){//is owner
         if ($is_admin) {
             //is owner
             $del_link = "&nbsp;<a href=\"" . $curent_url . "pages/editpage/" . $value['id'] . "/?delit=true&returl=" . urlencode($pageURL) . "\" onclick=\"return confirm('Are you sure you want to delete?');\" title=\"Delete this page\">";
             //                $del_link .="<b style=\"color:#f00;font-size:10px;\">[-]</b>";
             $del_link .= "<img src=\"" . $pluginStaticDir . "delete.gif\">";
             $del_link .= "</a>&nbsp;";
             $edit_link = "<a href=\"" . $curent_url . "pages/editpage/" . $value['id'] . "?returl=" . urlencode($pageURL) . "\" title=\"Edit this page\">";
             //                $edit_link .="<b style=\"color:#080;font-size:10px;\">[*]</b>";
             $edit_link .= "<img src=\"" . $pluginStaticDir . "edit3.gif\">";
             $edit_link .= "</a>";
         }
         if (!isset($value['is_localurl'])) {
             $value['is_localurl'] = 0;
         }
         if (!isset($value['url_external'])) {
             $value['url_external'] = "";
         }
         if ($value['is_localurl'] and $value['url_external'] != "" and $value['url_external'] != "http://" and $value['url_external'] != "https://") {
             /*
                                 $from_config=$curent_url;
                                 $from_config=str_replace("https://","",$from_config);
                                 $from_config=str_replace("http://","",$from_config);
                                 $trash=explode($from_config,$curent_url);
                                 $url_detect=$trash[1];
             */
             $linkpage_url = $value['url_external'];
         } else {
             $linkpage_url = $curent_url . "page/" . $value['id'] . "/" . $seo_title . ".html";
         }
         $link_text = mb_substr(stripslashes($value['title']), 0, 40);
         if (strlen(stripslashes($value['title'])) > 40) {
             $link_text .= "..";
         }
         $menu_list .= "<li>";
         $menu_list .= $edit_link . $del_link;
         $menu_list .= "<a href=\"" . $linkpage_url . "\" alt=\"" . stripslashes($value['title']) . "\" title=\"" . stripslashes($value['title']) . "\">" . $link_text . "</a>";
         $menu_list .= "</li>";
         //            echo $value['title'];
         //            echo "<br>";
         //            echo $value['content'];
     }
     if ($menu_list) {
         $content .= "<ul>" . $menu_list . "</ul>";
     } else {
         /*
         if ($this->userId!=$this->feed_working_Id){//is NOT owner
         $content  ="<script>\n";
         $content .="\$(document).ready(function(){\n";
         $content .="\$(\".profile-MAP_CMP_MenuWidget\").empty().remove();\n";
         $content .="    });\n";
         $content .="</script>";
         }
         */
     }
     //        }else{
     /*
     if ($this->userId!=$this->feed_working_Id){//is NOT owner
     $content  ='<script>\n';
     $content .='$(document).ready(function(){\n';
     $content .='$(".profile-MAP_CMP_MenuWidget").empty().remove();\n';
     $content .='    });\n';
     $content .='</script>';
     }
     */
     //        }
     $this->assign('content', $content);
 }
Exemple #5
0
 public function findMostRatedEntityList($entityType, $first, $count)
 {
     $rateDao = BOL_RateDao::getInstance();
     $query = "SELECT `" . BOL_RateDao::ENTITY_ID . "` AS `id`, COUNT(*) as `ratesCount`, AVG(`score`) as `avgScore`\n            FROM " . $rateDao->getTableName() . "\n                        WHERE `" . BOL_RateDao::ENTITY_TYPE . "` = :entityType AND `" . BOL_RateDao::ACTIVE . "` = 1\n            GROUP BY `" . BOL_RateDao::ENTITY_ID . "`\n                        ORDER BY `avgScore` DESC, `ratesCount` DESC\n                        LIMIT :first, :count";
     $arr = OW::getDbo()->queryForList($query, array('entityType' => $entityType, 'first' => (int) $first, 'count' => (int) $count));
     $resultArray = array();
     foreach ($arr as $value) {
         $resultArray[$value['id']] = $value;
     }
     return $resultArray;
 }
Exemple #6
0
 public function updateEntityStatus($entityType, $entityId, $status = true)
 {
     $this->rateDao->updateEntityStatus($entityType, (int) $entityId, (int) $status);
 }
Exemple #7
0
 public function findAlbumPhotoList($albumId, $listType, $offset, $limit, $privacy = null)
 {
     $condition = PHOTO_BOL_PhotoService::getInstance()->getQueryCondition(sprintf('findAlbumPhotoList.%s', $listType), array('photo' => 'p', 'featured' => 'f', 'album' => 'a'), array('albumId' => $albumId, 'listType' => $listType, 'offset' => $offset, 'limit' => $limit, 'privacy' => $privacy));
     $privacySql = $privacy === null ? "1" : "`p`.`privacy`='{$privacy}'";
     switch ($listType) {
         case 'featured':
             $query = 'SELECT `p`.*
                 FROM `' . $this->getTableName() . '` AS `p`
                 INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON ( `p`.`albumId` = `a`.`id` )
                 INNER JOIN `' . PHOTO_BOL_PhotoFeaturedDao::getInstance()->getTableName() . '` AS `f` ON (`f`.`photoId`=`p`.`id`)
                 ' . $condition['join'] . '
                 WHERE `p`.`status` = :status AND `p`.`albumId` = :albumId AND ' . $privacySql . '
                 AND `f`.`id` IS NOT NULL AND ' . $condition['where'] . '
                 ORDER BY `p`.`id` DESC
                 LIMIT :first, :limit';
             break;
         case 'toprated':
             $query = 'SELECT `p`.*, `r`.`' . BOL_RateDao::ENTITY_ID . '`, COUNT(`r`.id) as `ratesCount`, AVG(`r`.`score`) as `avgScore`
                 FROM `' . $this->getTableName() . '` AS `p`
                     INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON ( `p`.`albumId` = `a`.`id` )
                     INNER JOIN ' . BOL_RateDao::getInstance()->getTableName() . ' AS `r` ON (`r`.`entityId`=`p`.`id`
                         AND `r`.`' . BOL_RateDao::ENTITY_TYPE . '` = "photo_rates" AND `r`.`' . BOL_RateDao::ACTIVE . '` = 1)
                     ' . $condition['join'] . '
                 WHERE `p`.`status` = :status AND `p`.`albumId` = :albumId AND ' . $privacySql . ' AND ' . $condition['where'] . '
                 GROUP BY `p`.`id`
                 ORDER BY `avgScore` DESC, `ratesCount` DESC
                 LIMIT :first, :limit';
             break;
         case 'latest':
         default:
             $query = 'SELECT `p`.*
                 FROM `' . $this->getTableName() . '` AS `p`
                 INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON ( `p`.`albumId` = `a`.`id` )
                 ' . $condition['join'] . '
                 WHERE `p`.`status` = :status AND `p`.`albumId` = :albumId AND ' . $privacySql . ' AND ' . $condition['where'] . '
                 ORDER BY `p`.`id` DESC
                 LIMIT :first, :limit';
             break;
     }
     return $this->dbo->queryForList($query, array_merge(array('albumId' => $albumId, 'first' => $offset, 'limit' => $limit, 'status' => self::STATUS_APPROVED), $condition['params']));
 }
Exemple #8
0
 public function getAlbumPhotoList($albumId, $listType, $offset, $limit)
 {
     $albumDao = PHOTO_BOL_PhotoAlbumDao::getInstance();
     switch ($listType) {
         case 'featured':
             $photoFeaturedDao = PHOTO_BOL_PhotoFeaturedDao::getInstance();
             $query = "\n                    SELECT `p`.*\n                    FROM `" . $this->getTableName() . "` AS `p`\n                    INNER JOIN `" . $albumDao->getTableName() . "` AS `a` ON ( `p`.`albumId` = `a`.`id` )\n                    LEFT JOIN `" . $photoFeaturedDao->getTableName() . "` AS `f` ON (`f`.`photoId`=`p`.`id`)\n                    WHERE `p`.`status` = 'approved' AND `p`.`albumId` = :albumId\n                    AND `f`.`id` IS NOT NULL\n                    ORDER BY `p`.`addDatetime` DESC\n                    LIMIT :first, :limit";
             break;
         case 'toprated':
             $query = "SELECT `p`.*, `r`.`" . BOL_RateDao::ENTITY_ID . "`,\n                    COUNT(`r`.id) as `ratesCount`, AVG(`r`.`score`) as `avgScore`\n                    FROM `" . $this->getTableName() . "` AS `p`\n                        INNER JOIN `" . $albumDao->getTableName() . "` AS `a` ON ( `p`.`albumId` = `a`.`id` )\n                        LEFT JOIN " . BOL_RateDao::getInstance()->getTableName() . " AS `r` ON (`r`.`entityId`=`p`.`id`\n                            AND `r`.`" . BOL_RateDao::ENTITY_TYPE . "` = 'photo_rates' AND `r`.`" . BOL_RateDao::ACTIVE . "` = 1)\n                    WHERE `p`.`status` = 'approved' AND `p`.`albumId` = :albumId\n                    GROUP BY `p`.`id`\n                    ORDER BY `avgScore` DESC, `ratesCount` DESC\n                    LIMIT :first, :limit";
             break;
         case 'latest':
         default:
             $query = "\n\t\t            SELECT `p`.*\n\t\t            FROM `" . $this->getTableName() . "` AS `p`\n\t\t            INNER JOIN `" . $albumDao->getTableName() . "` AS `a` ON ( `p`.`albumId` = `a`.`id` )\n\t\t            WHERE `p`.`status` = 'approved' AND `p`.`albumId` = :albumId\n\t\t            ORDER BY `p`.`addDatetime` DESC\n\t\t            LIMIT :first, :limit";
             break;
     }
     return $this->dbo->queryForList($query, array('albumId' => $albumId, 'first' => $offset, 'limit' => $limit));
 }
Exemple #9
0
 public function onBeforeRender()
 {
     $curent_url = OW_URL_HOME;
     $is_admin = OW::getUser()->isAdmin();
     $content = "";
     /*
             if (!$this->userId){
                 echo "UKNOW!!";
             }else if ($this->userId==$this->feed_working_Id){
                 echo "OWNER!!!!";
             }else{
                 echo "GUEST!!!";
             }
     */
     $del_link = "";
     if ($this->userId == $this->feed_working_Id) {
         //is owner
         //$content .="<a href=\"online/editpage/0\"><b style=\"color:#080;\">[+] ADD NEW PAGE</b></a><a name=\"add_new_page\"></a>";
         $content .= "<a href=\"" . $curent_url . "online/editpage/0\">";
         //                        $content .="<b style=\"color:#080;\">[+] ".OW::getLanguage()->text('online', 'main_menu_addpage')."</b>";
         $content .= "<div class=\"clearfix ow_submit ow_smallmargin\">\n                <div class=\"ow_center\">\n                    <span class=\"ow_button\">\n                        <span class=\" ow_positive\">\n                            <input type=\"submit\" name=\"ok\" value=\"" . OW::getLanguage()->text('online', 'main_menu_addpage') . "\" class=\"ow_ic_add ow_positive\">\n                        </span>\n                    </span>\n                </div>\n            </div>";
         $content .= "</a>";
         $content .= "<a name=\"add_new_page\"></a>";
         $content .= "<hr>";
     }
     if ($this->feed_working_Id > 0) {
         $menu_list = "";
         $rateDao = BOL_RateDao::getInstance();
         $query = "SELECT * FROM " . OW_DB_PREFIX . "online  \n                        WHERE id_owner  = '" . addslashes($this->feed_working_Id) . "' ";
         //$arr = OW::getDbo()->queryForList($query, array('id' => (int) $id, 'order_main' => (int) $order_main, 'title' => $title, 'url_external' => $url_external, 'content' => $content));
         $arr = OW::getDbo()->queryForList($query);
         $resultArray = array();
         //$pluginStaticDir = OW_DIR_STATIC .'plugins'.DS.$plname.DS;
         $pluginStaticDir = OW::getPluginManager()->getPlugin('online')->getStaticUrl();
         foreach ($arr as $value) {
             $seo_title = stripslashes($value['title']);
             $seo_title = str_replace(" ", "_", $seo_title);
             $seo_title = preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $seo_title);
             $seo_title = strtolower($seo_title);
             if ($this->userId == $this->feed_working_Id) {
                 //is owner
                 $del_link = "&nbsp;<a href=\"" . $curent_url . "online/editpage/" . $value['id'] . "/?delit=true\" onclick=\"return confirm('Are you sure you want to delete?');\" title=\"Delete this page\">";
                 //                $del_link="<b style=\"color:#f00;\">[-]</b>";
                 $del_link .= "<img src=\"" . $pluginStaticDir . "delete.gif\">";
                 $del_link .= "</a>&nbsp;";
                 $edit_link = "<a href=\"" . $curent_url . "online/editpage/" . $value['id'] . "\" title=\"Edit this page\">";
                 //                $edit_link="<b style=\"color:#080;\">[*]</b>";
                 $edit_link .= "<img src=\"" . $pluginStaticDir . "edit3.gif\">";
                 $edit_link .= "</a>";
             } else {
                 if ($is_admin) {
                     $del_link = "&nbsp;<a href=\"" . $curent_url . "online/editpage/" . $value['id'] . "/?delit=true\" onclick=\"return confirm('Are you sure you want to delete?');\" title=\"Delete this page\">";
                     //                $del_link .="<b style=\"color:#f00;\">[-]</b>";
                     $del_link .= "<img src=\"" . $pluginStaticDir . "delete.gif\">";
                     $del_link .= "</a>";
                 }
             }
             //                $menu_list .="<li><a href=\"".$curent_url."/online/".$this->feed_working_Id."/".$value['id']."/".$seo_title.".wall\" alt=\"".stripslashes($value['title'])."\" title=\"".stripslashes($value['title'])."\">".stripslashes($value['title'])."</a>".$del_link.$edit_link."</li>";
             $menu_list .= "<li>" . $edit_link . $del_link . "<a href=\"" . $curent_url . "/online/" . $this->feed_working_Id . "/" . $value['id'] . "/" . $seo_title . ".online\" alt=\"" . stripslashes($value['title']) . "\" title=\"" . stripslashes($value['title']) . "\">" . stripslashes($value['title']) . "</a></li>";
             //            echo $value['title'];
             //            echo "<br>";
             //            echo $value['content'];
         }
         if ($menu_list) {
             $content .= "<ul>" . $menu_list . "</ul>";
         } else {
             if ($this->userId != $this->feed_working_Id) {
                 //is NOT owner
                 $content = "<script>\n";
                 $content .= "\$(document).ready(function(){\n";
                 $content .= "\$(\".profile-NOTEPAD_CMP_MenuWidget\").empty().remove();\n";
                 $content .= "    });\n";
                 $content .= "</script>";
             }
         }
     } else {
         if ($this->userId != $this->feed_working_Id) {
             //is NOT owner
             $content = '<script>\\n';
             $content .= '$(document).ready(function(){\\n';
             $content .= '$(".profile-NOTEPAD_CMP_MenuWidget").empty().remove();\\n';
             $content .= '    });\\n';
             $content .= '</script>';
         }
     }
     $this->assign('content', $content);
 }