模块功能分析:企业服务,企业填写招聘申请表,管理审核之后,展示作为招聘通知的功能.
1.文件分布:
modules文件夹和model文件夹,这是我们的文件范围,在modules下建立qiye这个文件夹,地址:F:/www/phpcms/modules/qiye
2.实例图:
3.前台控制器 index.php(class名必须与文件名一致),路径:F:/www/phpcms/modules/qiye/index.php
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- class index {
- private $db,$ip;
- function __construct() {
- pc_base::load_app_func('global');
- $this->db = pc_base::load_model('qiye_model');
- $this->ip = ip();
- $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid();
- define("SITEID",$siteid);
- }
- public function init() {
- $siteid = SITEID;
- $page = intval($_GET['page'])<=0 ? 1 : intval($_GET['page']);
- include template('qiye', 'index');
- }
- public function lists() {
- $siteid = SITEID;
- $page = intval($_GET['page']);
- $page = max($page,1);
- $r = $this->db->select(array('siteid'=>$siteid));
- if($r) extract($r);
- include template('qiye', 'list');
- }
- public function show(){
- $siteid = SITEID;
- $comid = intval($_GET['comid']);
- if(!$comid) showmessage(L('information_does_not_exist'),'blank');
- $r = $this->db->get_one(array('comid'=>$comid));
- if(!$r) showmessage(L('info_does_not_exists'),'blank');
- extract($r);
- include template('qiye', 'show');
- }
- public function reg(){
- if(isset($_POST['comname'])){
- //如果用户提交申请
- if($_POST['comname']==''){
- showmessage(L('qiye_noname'),"?m=qiye&c=index&a=reg&siteid=$siteid");
- }
- $db = pc_base::load_model('qiye_model');//加载模型
- //接收数据并存储
- $s = array();
- $num = array();
- $num = $_POST['zp_num'];
- $s['siteid'] = SITEID;
- $s['comname'] = safe_replace($_POST['comname']);
- $s['dw_name'] = safe_replace($_POST['dw_name']);
- $s['dw_department'] = safe_replace($_POST['dw_department']);
- $s['dw_area'] = safe_replace($_POST['dw_area']);
- $s['dw_property'] = safe_replace($_POST['dw_property']);
- $s['dw_economic'] = safe_replace($_POST['dw_economic']);
- $s['dw_contact'] = safe_replace($_POST['dw_contact']);
- $s['dw_zipcode'] = safe_replace($_POST['dw_zipcode']);
- $s['dw_address'] = safe_replace($_POST['dw_address']);
- $s['dw_telphone'] = safe_replace($_POST['dw_telphone']);
- $s['dw_fax'] = safe_replace($_POST['dw_fax']);
- $s['dw_email'] = safe_replace($_POST['dw_email']);
- $s['zp_hr'] = safe_replace($_POST['zp_hr']);
- $s['zp_tel'] = safe_replace($_POST['zp_tel']);
- $s['zp_email'] = safe_replace($_POST['zp_email']);
- $s['zp_property'] = safe_replace($_POST['zp_property']);
- $s['zp_industry'] = safe_replace($_POST['zp_industry']);
- $s['zp_post'] = safe_replace($_POST['zp_post']);
- $s['zp_area'] = safe_replace($_POST['zp_area']);
- $s['zp_major'] = safe_replace($_POST['zp_major']);
- $s['zp_salary'] = safe_replace($_POST['zp_salary']);
- $s['zp_num'] = array2string($num);
- $s['attr_commercial'] = safe_replace($_POST['attr_commercial']);
- $s['attr_information'] = safe_replace($_POST['attr_information']);
- $s['url'] = 'index.php?m=qiye&c=index&a=show&id=`id`';
- $s['ip'] = $this->ip;
- $s['inputtime'] = SYS_TIME;
- $s['updatetime'] = SYS_TIME;
- $comid = $db->insert($s,true);
- if($comid){
- showmessage(L('qiye_success'), "?m=qiye&c=index&a=init&siteid=$siteid");
- }
- } else {
- //默认显示申请页面
- pc_base::load_sys_class('form', '', 0);
- $SEO = seo(SITEID, '', L('qiye_apply'), '', '');
- include template('qiye', 'register');
- }
- }
- }
- ?>
4.后台控制器 qiye.php,class名必须与文件名一致,路径:F:/www/phpcms/modules/qiye/qiye.php:
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- pc_base::load_app_class('admin','admin',0);
- class qiye extends admin {
- private $db;
- function __construct() {
- parent::__construct();
- $this->db = pc_base::load_model('qiye_model');
- $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid();
- define("SITEID",$siteid);
- }
- //默认动作
- public function init() {
- $where = array('siteid'=>$this->get_siteid(),'status'=>0);
- $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
- $infos = $this->db->listinfo($where,$order = 'listorder DESC',$page, $pages = '9');
- $pages = $this->db->pages;
- extract($infos);
- include $this->admin_tpl('list');
- }
- public function show() {
- $comid = intval($_GET['comid']);
- if(!$comid) showmessage(L('information_does_not_exist'),'blank');
- $infos = $this->db->get_one(array('comid'=>$comid));
- if(!$infos) showmessage(L('info_does_not_exists'),'blank');
- extract($infos);
- include $this->admin_tpl('show');
- }
- public function list_pass() {
- $where = array('siteid'=>$this->get_siteid(),'status'=>1);
- $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
- $infos = $this->db->listinfo($where,$order = 'listorder DESC',$page, $pages = '9');
- $pages = $this->db->pages;
- extract($infos);
- include $this->admin_tpl('list_pass');
- }
- public function pass() {
- if((!isset($_GET['comid']) || emptyempty($_GET['comid'])) && (!isset($_POST['comid']) || emptyempty($_POST['comid']))) {
- showmessage(L('illegal_parameters'), HTTP_REFERER);
- } else {
- $comid = intval($_GET['comid']);
- if($comid < 1) return false;
- $result = $this->db->update(array('status'=>'1'),array('comid'=>$comid));
- $infos = $this->db->get_one(array('comid'=>$comid));
- if($result){
- if(is_email($infos['zp_email'])){
- pc_base::load_sys_func('mail');
- $siteinfo = siteinfo(SITEID);
- $sitename = $siteinfo['site_title'];
- $toemail = $infos['zp_email']; //发送通知邮件
- $subject = '信息审核通知';
- $message .= '尊敬的'.$infos['zp_hr'].':<br /> 您好!';
- $message .= '很高兴的通知您,您在'.date('Y年m月d日',$infos['inputtime']).'在我们网站['.$sitename.']发布的信息已经通过审核。';
- $message .= '<br /><br />祝好!<br /><br />-----------------------------------------<br />';
- $message .= '<font color=green>这是一封由系统发送的邮件,请勿回复此邮件!</font>';
- sendmail($toemail,$subject,$message);
- }
- exit('1');
- } else {
- exit('0');
- }
- }
- }
- public function listorder() {
- if(isset($_POST['dosubmit'])) {
- foreach($_POST['listorders'] as $comid => $listorder) {
- $this->db->update(array('listorder'=>$listorder),array('comid'=>$comid));
- }
- showmessage(L('operation_success'),HTTP_REFERER);
- }
- }
- public function delete() {
- if((!isset($_GET['comid']) || emptyempty($_GET['comid'])) && (!isset($_POST['comid']) || emptyempty($_POST['comid']))) {
- showmessage(L('illegal_parameters'), HTTP_REFERER);
- } else {
- if(is_array($_POST['comid'])){ //1.批量删除
- foreach($_POST['comid'] as $comid) {
- $this->db->delete(array('comid'=>$comid));
- //删除附件
- if(pc_base::load_config('system','attachment_stat')) {
- $this->attachment_db = pc_base::load_model('attachment_model');
- $this->attachment_db->api_delete($comid);
- }
- }
- showmessage(L('operation_success'),'?m=qiye&c=qiye');
- }else{ //2.单条删除
- $comid = intval($_GET['comid']);
- if($comid < 1) return false;
- $result = $this->db->delete(array('comid'=>$comid));
- //删除附件
- if(pc_base::load_config('system','attachment_stat')) {
- $this->attachment_db = pc_base::load_model('attachment_model');
- $this->attachment_db->api_delete($comid);
- }
- if($result){
- exit('1');
- showmessage(L('operation_success'),'?m=qiye&c=qiye');
- }else {
- exit('0');
- showmessage(L("operation_failure"),'?m=qiye&c=qiye');
- } //开源软件:Vevb.com
- }
- showmessage(L('operation_success'), HTTP_REFERER);
- }
- }
- public function setting() {
- include $this->admin_tpl('setting');
- }
- }
- ?>
5.PC标签方法:qiye_tag.class.php,为模板数据调用而设置,路径:F:/www/phpcms/modules/qiye/classes/qiye_tag.class.php:
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- class qiye_tag {
- private $db;
- public function __construct() {
- $this->db = pc_base::load_model('qiye_model');
- }
- public function lists($data) {
- $siteid = $data['siteid'] ? intval($data['siteid']) : get_siteid();
- $sql = array('siteid'=>$siteid);
- $data = $this->db->select($sql, '*', $data['limit'], $data['order']);
- return $data;
- }
- public function pc_tag() {
- $sites = pc_base::load_app_class('sites','admin');
- $sitelist = $sites->pc_tag_list();
- return array(
- 'action'=>array('lists'=>L('lists', '', 'qiye')),
- 'lists'=>array(
- 'catid'=>array('name'=>L('catid', '', 'qiye'),'htmltype'=>'input_select_category','data'=>array('type'=>0),'validator'=>array('min'=>1)),
- 'order'=>array(
- 'name'=>L('sort', '', 'qiye'),
- 'htmltype'=>'select',
- 'data'=>array(
- 'id DESC'=>L('id_desc', '', 'qiye'),
- 'inputtime DESC'=>L('inputtime_desc', '', 'qiye'),
- 'updatetime DESC'=>L('updatetime_desc', '', 'qiye'),
- 'listorder ASC'=>L('listorder_asc', '', 'qiye')
- )
- )
- ),
- );
- }
- }
- ?>
这里设置了一个方法,lists内容列表,在模版的时候调用如下:
{pc:qiye action="lists" catid="$catid"order="listorder desc" num="8"}
6.函数方法库
functions,因为我这里都用到的是系统的方法,所以里面是空的.
7.模块安装文件夹地址 F:/www/phpcms/modules/qiye/install
7.1 语言文件 qiye.lang.php(我这里只做了中文的语言),路径:F:/www/phpcms/modules/qiye/install/languages/zh-cn/qiye.lang.php:
- <?php
- $LANG['qiye_apply'] = '企业服务申请';
- $LANG['qiye_noname'] = '企业名称不能为空!';
- $LANG['qiye_success'] = '申请填写成功!';
- $LANG['comname'] = '单位名称';
- $LANG['attr_commercial'] = '营业执照';
- $LANG['dw_name'] = '签约名称';
- $LANG['dw_department'] = '隶属部门';
- $LANG['dw_area'] = '单位地区';
- $LANG['dw_property'] = '单位性质';
- $LANG['dw_contact'] = '信息负责人';
- $LANG['dw_telphone'] = '负责人手机号';
- $LANG['zp_email'] = '负责人邮箱';
- $LANG['attr_information'] = '招聘信息';
- $LANG['qiye_download'] = '点击下载';
- $LANG['qiye_control'] = '操作';
- $LANG['qiye_look'] = '查看';
- $LANG['click_open'] = '点击下载';
- $LANG['remove_all_selected'] = '删除选择';
- $LANG['confirm_del'] = '确定删除吗?';
- $LANG['del_confirm'] = '确定删除吗?';
- $LANG['delete'] = '删除';
- $LANG['pass'] = '通过';
- $LANG['pass_true'] = '确定通过吗?';
- ?>
7.2 前台模版文件夹,路径:F:/www/phpcms/modules/qiye/install/templates
name.inc.php 模版安装文件,安装模块时把模版文件复制到默认的default目录下的控制文件:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- return array (
- 'index.html' => '企业信息首页',
- 'list.html' => '企业信息列表页',
- 'show.html' => '企业信息内容页',
- 'register.html' => '企业信息申请页',
- );
- ?>
7.3 模块配置文件 config.inc.php地址 F:/www/phpcms/modules/qiye/install/config.inc.php:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- $module = 'qiye';
- $modulename = '企业服务';
- $introduce = '企业服务模块';
- $author = 'novalue';
- $authorsite = 'http://www.liaochuanyou.name/';
- $authoremail = 'novalue@qq.com';
- ?>
7.4模块菜单扩展文件 extention.inc.php(添加后台菜单栏功能),路径:F:/www/phpcms/modules/qiye/install/extention.inc.php:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- $parentid = $menu_db->insert(array('name'=>'qiye', 'parentid'=>29, 'm'=>'qiye', 'c'=>'qiye', 'a'=>'init', 'data'=>'', 'listorder'=>0, 'display'=>'1'), true);
- $menu_db->insert(array('name'=>'qiye_list', 'parentid'=>$parentid, 'm'=>'qiye', 'c'=>'qiye', 'a'=>'list_pass', 'data'=>'', 'listorder'=>1, 'display'=>'1'));
- $menu_db->insert(array('name'=>'qiye_setting', 'parentid'=>$parentid, 'm'=>'qiye', 'c'=>'qiye', 'a'=>'setting', 'data'=>'', 'listorder'=>2, 'display'=>'1'));
- $language = array('qiye'=>'企业服务','qiye_list'=>'审核通过','qiye_setting'=>'模块配置');
- ?>
7.5 安装文件夹下的 model.php,安装模块时返回所使用的模型名,路径:F:/www/phpcms/modules/qiye/install/model.php:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- return array('qiye');
- ?>
7.6 安装文件夹下的 module.sql,里面只有一句sql语句,路径:F:/www/phpcms/modules/qiye/install/module.sql:
- INSERT INTO `phpcms_module` VALUES ('qiye', '企业服务', '', '0', '1.0', '企业服务', '', '0', '0', '2012-06-18', '2012-06-18');
7.7 企业服务模块安装数据库文件 qiye.sql,路径:F:/www/phpcms/modules/qiye/install/qiye.sql:
- DROP TABLE IF EXISTS `phpcms_qiye`;
- CREATE TABLE `phpcms_qiye` (
- `comid` int(11) NOT NULL AUTO_INCREMENT ,
- `siteid` int(11) NULL DEFAULT NULL ,
- `comname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位名称' ,
- `dw_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '签约名称' ,
- `dw_department` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '隶属部门' ,
- `dw_area` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位地区' ,
- `dw_property` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位性质' ,
- `dw_economic` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '经济类型' ,
- `dw_contact` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位联系人' ,
- `dw_zipcode` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位邮编' ,
- `dw_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位地址' ,
- `dw_telphone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位电话' ,
- `dw_fax` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位传真' ,
- `dw_email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位邮箱' ,
- `zp_hr` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '负责人' ,
- `zp_tel` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_property` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_industry` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_post` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_area` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_major` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_salary` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '招聘薪水' ,
- `zp_num` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '招聘人数' ,
- `attr_commercial` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '营业执照' ,
- `attr_information` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '招聘信息' ,
- `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `status` int(11) NULL DEFAULT 0 ,
- `listorder` int(11) NULL DEFAULT 0 ,
- `inputtime` int(11) NULL DEFAULT NULL ,
- `updatetime` int(11) NULL DEFAULT NULL ,
- PRIMARY KEY (`comid`)
- )
- ENGINE=InnoDB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=32 ROW_FORMAT=COMPACT;
8.后台管理模版文件,路径:F:/www/phpcms/modules/qiye/templates/
9.模块卸载文件,路径:F:/www/phpcms/modules/qiye/uninstall
三个文件extention.inc.php、qiye.sql、model.php里面的语句比较简单,大家可以看其他模块的写法,修改里面对应的模块名即可.
10.模型的model,这里和上面要注意了,不在同一个目录下面了,在系统的model目录了($ _ $)),路径:F:/www/phpcms/model/qiye_model.class.php:
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- pc_base::load_sys_class('model', '', 0);
- class qiye_model extends model {
- function __construct() {
- $this->db_config = pc_base::load_config('database');
- $this->db_setting = 'default';
- $this->table_name = 'qiye';
- parent::__construct();
- }
- }
- ?>
新闻热点
疑难解答