The DEDECMS background system user authorization directory is changed to unlimited level (the default is the second level authorization)

When working on a school project, there are four-level classifications, and there are more than 100 classifications in total. Because each classification corresponds to a different teacher, it is used to upload materials as assessments, but when adding system users, I found that DEDECMS only has two-level classifications, so Some codes have been modified. I don't know if the modification is complete. For the time being, the authorization function of the four-level directory can be authorized. The following is the modified code.

1. Add/modify system users - show all categories

Open dede/sys_admin_user_add.php and dede/sys_admin_user_edit.php

Introduce the file under the top, the specific use is not clear, because I also referenced other people's articles before, I guess it doesn't matter if I don't cite it, but I don't have time to test it, let's do it first

require_once(dirname(__FILE__)."/config.php");
require_once(DEDEADMIN."/inc/inc_catalog_options.php"); // import this line of code

 

modify bottom

$dsql->Execute('op');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
include DedeInclude('templets/sys_admin_user_add.htm');

Replace the middle code with

$typeOptions .= GetOptionList(0,$cuserLogin->getUserChannel(),0);

  

2. Modify the include/typeunit.class.admin.php file

turn up

while($row = $this->dsql->GetObject())
            {
                if($row->reid==0) continue;
                $topidstr .= ($topidstr=='' ? $row->reid : ','.$row->reid);
            }

Add the following code below it

/********************************Modify the code, the authorization of the third-level column of background management starts********** ********************/
          // Get all top-level column ids
          $current_id = (string)$admin_catalogs[0];
          $category_arr = [];
          $categorys = explode(',',$admin_catalog);
          foreach ($categorys as $key=>$value) {
            array_push($category_arr,$categorys[$key]);
            $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id in($categorys[$key]) group by reid ");
            $this->dsql->Execute();
            if(($reid = $this->dsql->GetObject()->reid) != 0) {
              // not a secondary category
              array_push($category_arr,$reid);
              // Continue to judge whether it is a secondary classification
              $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id in($reid) group by reid ");
              $this->dsql->Execute();
              if(($reid = $this->dsql->GetObject()->reid) != 0) {
                array_push($category_arr,$reid);
                // Continue to judge whether it is a secondary classification
                $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id in($reid) group by reid ");
                $this->dsql->Execute();
                if(($reid = $this->dsql->GetObject()->reid) != 0) {
                  array_push($category_arr,$reid);
                  // Continue to judge whether it is a secondary classification
                  $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id in($reid) group by reid ");
                  $this->dsql->Execute();
                  if(($reid = $this->dsql->GetObject()->reid) != 0) {
                    array_push($category_arr,$reid);
                    // Continue to judge whether it is a secondary classification
                    $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id in($reid) group by reid ");
                    $this->dsql->Execute();
                  }
                }
              }
            }
          }

It's a bit bad to write here, loop, because I only have four levels, I wrote it simply first

then the last

// Assign $admin_catalogs to the category id array we generated earlier
$admin_catalogs = array_unique($category_arr);

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324461475&siteId=291194637