示例#1
0
 /**
  * Функция получения ID категории по ID соц.позиции
  */
 private function _GetIDCategoryByIDPos($p_id_sp = null)
 {
     $v_id_sp = (int) $p_id_sp;
     if ($v_id_sp > 0) {
         $v_sp_model = new SocialModel();
         $v_row = $v_sp_model->load($v_id_sp);
         return $v_row['social_tree_id'];
         // для "Импортированные" ID Категории = 0
     }
     return -1;
     // -- Выбираемая соц.позиция с несуществующим ID
 }
示例#2
0
 public function DeleteCommentAction()
 {
     $request = Project::getRequest();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user = Project::getUser()->getDbUser();
     $isAdmin = $user->user_type_id == 1 ? true : false;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $item_id = $request->getKeyByNumber(0);
     $comment_id = $request->getKeyByNumber(1);
     $item_name = $request->getKeyByNumber(2);
     $comment_model = new CommentModel($item_name . '_comment', $item_name . '_id', $comment_id);
     switch ($item_name) {
         case 'article':
             $item_model = new ArticleModel();
             $item_controller = 'Article';
             $item_action = 'ArticleView';
             $item_name_id = $comment_model->article_id;
             break;
         case 'questions':
             $item_model = new QuestionModel();
             $item_controller = 'QuestionAnswer';
             $item_action = 'ViewQuestion';
             $item_name_id = $comment_model->questions_id;
             break;
         case 'photo':
             $item_model = new PhotoModel();
             $item_controller = 'Photo';
             $item_action = 'View';
             $item_name_id = $comment_model->photo_id;
             break;
         case 'bookmarks':
             $item_model = new BookmarksModel();
             $item_controller = 'Bookmarks';
             $item_action = 'BookmarksView';
             $item_name_id = $comment_model->bookmarks_id;
             break;
         case 'social':
             $item_model = new SocialModel();
             $item_controller = 'Social';
             $item_action = 'SocialView';
             $item_name_id = $comment_model->social_id;
             break;
         case 'blog':
             $item_model = new SocialModel();
             $item_controller = 'Blog';
             $item_action = 'Comments';
             $item_name_id = $comment_model->blog_id;
             break;
     }
     $item_model->load($item_id);
     if ($comment_model->id > 0 && $item_model->id > 0 && $item_name_id == $item_model->id) {
         if ($comment_model->user_id == $user_id || $item_model->user_id == $user_id || $isAdmin) {
             $comment_model->delete($comment_model->user_id, $comment_id);
             $item_model->comments--;
             $item_model->save();
         }
     }
     Project::getResponse()->redirect($request->createUrl($item_controller, $item_action, array($item_model->id)));
 }