Secondary development of Zen

In the near future, we need to make some modifications to Zen. We installed a bunch of php environment, but we still don't know how to run the project locally. We simply deployed a new open source Zen on the test server, directly connected to the database, copied the code in the folder / opt/zbox/app/zentao, and directly modified it. Restart the server to see the effect. The following are the records of the modification process.

1, windows installation environment

1. Integrated environment php environment phpStudy installation

After phpStudy is installed, G: \ PHP \ phpStudy \ extensions \ PHP \ php7 3.4nts

It can be directly used to configure php environment variables( https://www.xp.cn/ phpStudy_64.zip), and other required packages such as Apache and mysql can be installed and used through phpstudy.

2. Editor (PhpStorm2020.3_129854)

Similar to idea, phpstorm2020 3_ 129854.rar after downloading and decompressing, you can activate and install the localization package according to the instructions

Baidu online disk link: https://pan.baidu.com/s/10Xe6JtXQ1uUtAJm8KaHzHg
Extraction code: 2v15

2, centos Zen installation modification

1. Install, connect to database

Zen official (recommended) linux one click installation package document: https://www.zentao.net/book/zentaopmshelp/90.html

The modified version zentaopms is used in this paper 12.5. 3.zbox_ 64.tar. gz:

Baidu online disk link: https://pan.baidu.com/s/10Xe6JtXQ1uUtAJm8KaHzHg
Extraction code: 2v15

Common commands:

1,Unzip the installation package directly to/opt Directory sudo tar -zxvf ZenTaoPMS.12.5.3.zbox_64.tar.gz  -C /opt
2, Apache and Mysql Common commands
 implement/opt/zbox/zbox start Command on Apache and Mysql. 
implement/opt/zbox/zbox stop Command stop Apache and Mysql. 
implement/opt/zbox/zbox restart Command restart Apache and Mysql. 

3,modify Apache port
 If port 80 of the server is not open or the port conflicts:
/opt/zbox/zbox  -h   //View help commands for zbox
/opt/zbox/zbox  -ap  8080  //Modify the port number of Apache server to 8080
/opt/zbox/zbox  restart    //Restart the Apache server
 After completing the above operations, the port number of Zen path is changed to 8080

4,modify mysql port
 modify mysql Port:       
/opt/zbox/zbox  -mp  8090  //Modify the port number of mysql server to 8090
/opt/zbox/zbox  restart    //Restart the Apache server
 To modify a profile:
/opt/zbox/app/zentao/config
 Then find it inside my.php,use vi Command to modify:
$config->db->port

After installation and normal startup, you can use navicat connection to operate Zen database to delete and modify data. There may be problems with port security direct connection. First connect to the server through SSH channel, and then connect to Zen database. The open source version library name is zentao

2. Modify code

2.1. Copy the code into git

Because the rectification zentao directory contains other service files, the overall size is large. Generally, if the requirements are met, you only need to copy the code under the module folder and put it into git for modification. After each change, you can overwrite the corresponding folder to the corresponding path of the server. If some codes do not take effect, you can restart and refresh with the / opt/zbox/zbox restart command.

2.2. Directory structure

Before modification, you can first understand the following code directory and official documents:

https://www.zentao.net/book/zentaopmshelp/225.html

The main modification is the module directory. There are more than 30 modules under the module directory, which correspond to a function module in Zen. The function of the whole Zen path is composed of these modules.

  • The language file of the current module stored under the lang directory. ZH CN corresponds to simplified Chinese, Zh TW corresponds to traditional Chinese, and so on. If you need to modify the name or configuration of some fields in Zen, you need to open the corresponding file for modification.
  • The template file corresponding to each page is stored under the view directory. For example, for a bug browsing page, the corresponding template is browse html. php.
  • config.php stores the corresponding configuration items of the current module.
  • control.php is the entrance to all pages of the whole bug module. In other words, the corresponding method definitions can be found in this file for bug related page browsing.
  • model.php is a list of methods for bug related database operations.

2.3. Modify entry

For each page to be modified, you can find the corresponding entry through the browser request address. For example, the product plan (productplan-browse-1-0-all.html) can find the browse method in the control.php file in the productplan directory to view the source of page data

2.4. Create, edit and query

From this list, there is a corresponding browse. Net in the view directory html. The PHP file is the planned page. For example, the type in the th tag is the newly added release status field in the list (as for why the type is simply lazy to change after adding fields to the lazy library table),

Corresponding fields shall also be added to the corresponding simplified Chinese zh CN file, and the title shall be displayed normally

After adding in the list, the corresponding new and edit pages also correspond to the file name create. In the view folder html. php,edit.html.php, the following is a screenshot of modifying the corresponding file location and some code understanding comments.

<tr>
    // zh-cn. The type field in PHP corresponds to the Chinese name of the publishing status
    <th><?php echo $lang->productplan->type;?></th>
    <td>
        // I went to this line. I copied it from the bug module. It should be useless. I forgot to delete it ignore
        <span class='input-group-addon fix-border'><?php echo $lang->bug->type?></span>
        // This is the content in the drop-down box, which needs to be in Zh CN Add a configuration content in PHP, and the return value of $plan - > type ensures that it is the current data value when editing
        <?php echo html::select('type', $lang->productplan->pubList, $plan->type, "class='form-control'");?>
    </td>
</tr>

2.5. Tab switching query

There are all written in the block module and traversing the unexpired and expired status, so you only need to add the required published and unpublished status in $Lang - > Product Plan - > feature bar ['browse'] to display normally

However, after clicking, it has no effect. It is still the original data and will not be filtered by status. The last parameter of the observation request is the newly added status

So follow the request to find control and find that the $browseType type parameter is passed to the getList method

Then in the model getList is found in the PHP file. This file is similar to xml in java. You can splice and modify sql to form the desired result

2.6 batch editing

After selecting a single piece of data, the batch Edit button will appear. You do not need to modify the data one by one, so this status is also added to the batch edit page

You can find the corresponding file in the view by accessing the address and copy the code of the editing page in the corresponding position. The parameter [$plan - > id] must be added because the parameter format is followed by an id, otherwise the corresponding data cannot be found in batch modification

After the page parameters are consistent, it is found that they are not effective, so it is found that the batch update needs to copy the parameters again through the control. After that, the batch editing is successful.

2.7. Add menu

Because I wrote a new bug statistics before, I only used the pages generated by other services and did not add them to the Zen path, so I saw that the menu can be added here and tried

Menu modify document: https://www.zentao.net/book/zentaopmshelp/40.html#0 , it has been added temporarily, which can be accessed in a new window. The permission page will be optimized in the future. The bug statistics sql is described below.

Suppose we want to hang a Sina website in the Zen top menu and open it in a new window.

1. Create a new file footer. In module/common/ext/view sina. html. hook. php

2. After the following contents are added and saved, you can open the Zen path to see the new link in the top-level menu, which is opened in a new window:

<script> 
$(document).ready(function()
{
    $("#navbar ul. nav").append('<li><a id="menusina" href=" http://www.sina.com.cn "  target="_ Blank "> bug statistics < / a > < \ / Li >);
});
</script>

3, Zen sql

1. bug statistics for a specified time period

-- openedDate Creation time
-- resolvedDate Solution time
-- active  activation
-- resolved resolved
-- closed   Closed
select tmp.* from(
select zpd.id,zpd.name as 'entry name','' as 'Space',

-- Statistics can be made according to the creation time, such as XX one XX Number of issues in creation time
(
SELECT count(*) FROM `zt_bug`  where 1=1 
and openedDate>='2021-10-25 00:00:0' 
and openedDate<='2021-11-01 00:00:0'
and deleted='0'
and zpd.id=product
) as 'newly added',

-- Statistics XX Belong to in creation time bug Number of
-- Code error&Design defect&production accident&Demand omission
(
SELECT count(*) FROM `zt_bug`  where 1=1
and openedDate>='2021-10-25 00:00:0' 
and openedDate<='2021-11-01 00:00:0'
and deleted='0'
and type in ('codeerror','designdefect','accident','demand')
and zpd.id=product
) as 'bug number',

-- -- Statistics XX The status is active at creation time bug number
(
SELECT count(*) FROM `zt_bug`  where 1=1
and openedDate>='2021-10-25 00:00:0' 
and openedDate<='2021-11-01 00:00:0'
and `status`='active'
and deleted='0'
and zpd.id=product
) as 'Which is not resolved',

-- -- Count the number of problems in all active states
(
SELECT count(*) FROM `zt_bug`  where 1=1
and `status`='active'
and deleted='0'
and zpd.id=product
) as 'All unresolved',

-- -- Statistics xx The status is not equal to closed during the creation time bug number
(
SELECT count(*) FROM `zt_bug`  where 1=1
and `status`='resolved'
and zpd.id=product

and deleted='0'
) as 'Resolved pending closure',

-- -- According to the settlement time, for example, the settlement date is xX one xX Interval
(
SELECT count(*) FROM `zt_bug`  where 1=1
and resolvedDate>='2021-10-25 00:00:0' 
and resolvedDate<='2021-11-01 00:00:0'
and zpd.id=product
and deleted='0'
) as 'Resolved this week'
from zt_bug as zb
left join zt_project as zp on zp.id=zb.product
left join zt_product as zpd on zpd.id=zb.product
GROUP BY zb.product
) as tmp
where tmp.newly added!=0

2. Count project bug s by week

-- openedDate Creation time
-- resolvedDate Solution time
-- active  activation
-- resolved resolved
-- closed   Closed

select 
str_to_date(concat(tmp.weeks, " ", 'Monday'), '%X%V %W') as fristWeek,str_to_date(concat(tmp.weeks+1, " ", 'Sunday'), '%X%V %W') as endWeek
,tmp.* from(
select DATE_FORMAT(zb.openedDate,'%Y%u') weeks,zpd.id,zpd.name as 'entry name','' as 'Space',

-- Statistics can be made according to the creation time, such as XX one XX Number of issues in creation time
(
SELECT count(*) FROM `zt_bug`  where 1=1 
and openedDate>=concat(str_to_date(concat(weeks, " ", 'Monday'), '%X%V %W'),' ','00:00:0') 
and openedDate<=concat(str_to_date(concat(weeks+1, " ", 'Sunday'), '%X%V %W'),' ','23:59:59') 
and DATE_FORMAT(openedDate,'%Y%u') =weeks
and deleted='0'
and zpd.id=product
) as 'newly added',

-- Statistics XX Belong to in creation time bug Number of
-- Code error&Design defect&production accident&Demand omission
(
SELECT count(*) FROM `zt_bug`  where 1=1
and openedDate>=concat(str_to_date(concat(weeks, " ", 'Monday'), '%X%V %W'),' ','00:00:0') 
and openedDate<=concat(str_to_date(concat(weeks+1, " ", 'Sunday'), '%X%V %W'),' ','23:59:59') 
and DATE_FORMAT(openedDate,'%Y%u') =weeks
and deleted='0'
and type in ('codeerror','designdefect','accident','demand')
and zpd.id=product
) as 'bug number',

-- -- Statistics XX The status is active at creation time bug number
(
SELECT count(*) FROM `zt_bug`  where 1=1
and openedDate>=concat(str_to_date(concat(weeks, " ", 'Monday'), '%X%V %W'),' ','00:00:0') 
and openedDate<=concat(str_to_date(concat(weeks+1, " ", 'Sunday'), '%X%V %W'),' ','23:59:59') 
and DATE_FORMAT(openedDate,'%Y%u') =weeks
and `status`='active'
and deleted='0'
and zpd.id=product
) as 'Which is not resolved',

-- -- Count the number of problems in all active states
(
SELECT count(*) FROM `zt_bug`  where 1=1
and `status`='active'
and deleted='0'
-- and DATE_FORMAT(openedDate,'%Y%u') =weeks
and zpd.id=product
) as 'All unresolved',

-- -- Statistics xx The status is not equal to closed during the creation time bug number
(
SELECT count(*) FROM `zt_bug`  where 1=1
and `status`='resolved'
and zpd.id=product
-- and DATE_FORMAT(openedDate,'%Y%u') =weeks
and deleted='0'
) as 'Resolved pending closure',

-- -- According to the settlement time, for example, the settlement date is xX one xX Interval
(
SELECT count(*) FROM `zt_bug`  where 1=1
and resolvedDate>=concat(str_to_date(concat(weeks, " ", 'Monday'), '%X%V %W'),' ','00:00:0') 
and resolvedDate<=concat(str_to_date(concat(weeks+1, " ", 'Sunday'), '%X%V %W'),' ','23:59:59') 
-- and DATE_FORMAT(resolvedDate,'%Y%u') =weeksR
and zpd.id=product
and deleted='0'
) as 'Resolved this week'
from zt_bug as zb
left join zt_project as zp on zp.id=zb.product
left join zt_product as zpd on zpd.id=zb.product
GROUP BY zb.product,weeks
) as tmp
where tmp.newly added!=0

3. Common table

-- Project table
select * from zt_product order by id desc limit 100;
-- bug surface
select * from zt_bug  order by id desc  limit 100;
-- The dynamic record table can be deleted if there are debugging records
select * from zt_action  order by id desc  limit 100;

roject as zp on zp.id=zb.product
left join zt_product as zpd on zpd.id=zb.product
GROUP BY zb.product,weeks
) as tmp
where tmp. Add= 0

# 3. Common table

– project list
select * from zt_product order by id desc limit 100;
– bug table
select * from zt_bug order by id desc limit 100;
– dynamic record table. If there are commissioning records, they can be deleted
select * from zt_action order by id desc limit 100;



The above are some records and understandings of Zen modification, which will be updated continuously. Welcome to give some suggestions~

Keywords: PHP CentOS server

Added by fordiman on Mon, 03 Jan 2022 07:34:06 +0200