How to allow Discuz to use DIY to call posts with reading permissions greater than 0
useddiscuzAll of our friends know that even if you are just a technical white. DZ's DIY function allows a webmaster who doesn't understand code to perform various call operations. For example, you can directly call data from the front desk inside the station, while you can directly use the API provided in the background outside the station to call data. For example, you can call data from the DZ forum on a separate program you write. In addition to rewriting SQL, you can also call it directly through the DZ backend API.
But here comes the problem. We will find that some posts have reading permissions set, such as 10, 100, 255, etc. If we want to call such posts DIY, we cannot call them. In fact, this is DZ's consideration in programming. This is what they think. Since you have set permissions, which means that the posts are not allowed to be accessed by others, there is no need to display them in the list. In fact, this consideration is relatively complete. But some webmasters have such needs. For example, if you set the permission of 10, most users of my website still need to read it.

Let's start the topic of discussion here with this need. In fact, when DIY calls data, or calls directly in the background, you still need to retrieve data from the database. It's just that DZ may have adopted an object-oriented development mechanism architecturally and encapsulated these into the methods of certain classes. For example, if reading permissions greater than 0 are not displayed in the list of DIY call data, it is discovered through the micro-architecture network that it is restricted in a block_thread in source/class/block/forum/block_thread.php. This class inherits the parent class discuz_block. And it is written in the getdata() method. Through analysis, there is the following code in line 357 (X3.2 version)
$sqlfrom WHERE {$maxwhere}t.readperm=’0′
WHERE {$maxwhere}t.readperm='0' is a restriction condition, that is, only posts with reading permission of 0 will be displayed. If we want to display everything, then obviously we can change it to WHERE {$maxwhere}t.readperm ='0'. Of course, it can also be other methods, such as modifying other places to remove part of this where condition.
At this point, we can naturally make further optimizations, such as displaying posts with reading permissions of 100 and below, so we just need to modify the code to
$sqlfrom WHERE {$maxwhere}t.readperm<=’100′
can
© Website copyright and disclaimer
1.[honmau Media] independently owns the copyright of all materials on relevant pages of this website;
2. No one is allowed to copy it without the express written permission of [honmau Media];
3. The articles that do not indicate "honmau Media" on this website are all from the Internet and are only for everyone to learn and refer;
4. If there is any infringement/violation/irregularity, please contact customer service QQ or email to delete it, please understand;
5.[honmau Media] reserves the right to correct, modify and update this statement at any time.legal notice