/**
  * 卸载模块
  * @author jry <*****@*****.**>
  */
 public function uninstall($id)
 {
     $system_module_object = D('SystemModule');
     $name = $system_module_object->where($map)->getFieldById($id, 'name');
     $result = $system_module_object->delete($id);
     if ($result) {
         $sql_status = execute_sql_from_file(realpath(APP_PATH . $name) . '/Sql/uninstall.sql');
         if ($sql_status) {
             $this->success('卸载成功!');
         }
     } else {
         $this->error('卸载失败');
     }
 }
예제 #2
0
 /**
  * 卸载插件
  * @author jry <*****@*****.**>
  */
 public function uninstall()
 {
     $addon_object = M('Addon');
     $id = trim(I('id'));
     $db_addons = $addon_object->find($id);
     $class = get_addon_class($db_addons['name']);
     $this->assign('jumpUrl', U('index'));
     if (!$db_addons || !class_exists($class)) {
         $this->error('插件不存在');
     }
     session('addons_uninstall_error', null);
     $addons = new $class();
     $uninstall_flag = $addons->uninstall();
     if (!$uninstall_flag) {
         $this->error('执行插件预卸载操作失败' . session('addons_uninstall_error'));
     }
     $hooks_update = D('AddonHook')->removeHooks($db_addons['name']);
     if ($hooks_update === false) {
         $this->error('卸载插件所挂载的钩子数据失败');
     }
     S('hooks', null);
     $delete = $addon_object->where("name='{$db_addons['name']}'")->delete();
     //卸载数据库
     $sql_file = realpath(THINK_ADDON_PATH . $db_addons['name']) . '/Sql/uninstall.sql';
     if (file_exists($sql_file)) {
         $sql_status = execute_sql_from_file($sql_file);
         if (!$sql_status) {
             $this->error('执行插件SQL卸载语句失败' . session('addons_uninstall_error'));
         }
     }
     if ($delete === false) {
         $this->error('卸载插件失败');
     } else {
         $this->success('卸载成功');
     }
 }
 /**
  * 设置一条或者多条数据的状态
  * @author jry <*****@*****.**>
  */
 public function setStatus($model = CONTROLLER_NAME)
 {
     $ids = I('request.ids');
     $status = I('request.status');
     if (empty($ids)) {
         $this->error('请选择要操作的数据');
     }
     $map['id'] = array('eq', $ids);
     switch ($status) {
         case 'uninstall':
             //卸载
             $name = D($model)->where($map)->getField('name');
             $result = D($model)->where($map)->delete();
             if ($result) {
                 $sql_status = execute_sql_from_file(realpath(APP_PATH . $name) . '/Sql/uninstall.sql');
                 if ($sql_status) {
                     $this->success('卸载成功!');
                 }
             } else {
                 $this->error('卸载失败');
             }
             break;
         default:
             parent::setStatus($model);
             break;
     }
 }