Beispiel #1
0
        public static ReturnValue move(double classId, double moduleId1, double classId1, UserInfo user)
        {
            ReturnValue err = new ReturnValue();

            if (classId == classId1)
            {
                err.errNo  = -1;
                err.errMsg = "移动栏目不能为父栏目";
                return(err);
            }
            bool            mtag2 = false, tag = true;
            double          dataTypeId2 = -1;
            MySqlDataReader rs;

            rs = Sql.ExecuteReader("select type,saveDataType from module where id=@id", new MySqlParameter[] { new MySqlParameter("id", moduleId1) });
            if (rs.Read())
            {
                dataTypeId2 = rs.GetDouble(1);
                mtag2       = rs.GetBoolean(0);
                if (moduleId1 == classId1 && !mtag2)
                {
                    classId1 = 7;
                }
            }
            rs.Close();
            if (dataTypeId2 == -1)
            {
                err.errNo  = -1;
                err.errMsg = "目标模块不存在";
                return(err);
            }
            ColumnInfo  column = ColumnClass.get(classId);
            Permissions p      = null;

            #region 获取要移动栏目的父栏目权限
            if (column.classId == 7)
            {
                p = user.getModulePermissions(column.moduleId);
            }
            else
            {
                p = user.getColumnPermissions(column.classId);
            }
            if (!p.all)
            {
                err.errNo  = -1;
                err.errMsg = "越权操作,移动栏目失败";
                return(err);
            }
            #endregion
            #region 获取目标位置权限
            if (classId1 == 7)
            {
                p = user.getModulePermissions(moduleId1);
            }
            else
            {
                p = user.getColumnPermissions(classId1);
            }
            if (!p.all)
            {
                err.errNo  = -1;
                err.errMsg = "越权操作,无目标栏目权限,移动栏目失败";
                return(err);
            }
            #endregion
            #region 栏目移动
            if (column.saveDataType == dataTypeId2)
            {
                string where = "";
                if (classId1 != 7)
                {
                    rs = Sql.ExecuteReader("select rootid from class where id=@id", new MySqlParameter[] { new MySqlParameter("id", classId1) });
                    if (rs.Read())
                    {
                        where = ",rootid=" + rs[0].ToString();
                    }
                    rs.Close();
                }
                Sql.ExecuteNonQuery("update class set moduleid=" + moduleId1 + ",classid=" + classId1 + where + " where id=" + classId);
                ColumnClass.reset(column.rootId);//重置旧栏目结构
            }
            else
            {
                err.errMsg = "数据类型不匹配";
                err.errNo  = -1;
                tag        = false;//移动失败,类型不匹配
            }
            #endregion
            return(err);
        }
Beispiel #2
0
        /// <summary>
        /// 获取栏目权限
        /// </summary>
        /// <param name="moduleId">模块id</param>
        /// <param name="columnId">栏目id</param>
        /// <returns></returns>
        public Permissions getColumnPermissions(double columnId)
        {
            ColumnInfo column = ColumnClass.get(columnId);

            return(getColumnPermissions(column));
        }
Beispiel #3
0
        public static void add(ColumnInfo info, UserInfo user)
        {
            ReturnValue err = new ReturnValue();

            #region 验证
            if (info.className.Trim() == "")
            {
                throw new Exception("栏目名不能为空");
            }
            if (info.dirName == "")
            {
                throw new Exception("目录名不能为空");
            }


            #endregion
            if (info.id < 1)
            {
                info.id = double.Parse(Tools.GetId());
            }
            int count = int.Parse(Sql.ExecuteScalar("select count(1) from class where classId=@classId and (dirName=@dirName or className=@className)", new MySqlParameter[] {
                new MySqlParameter("classId", info.classId),
                new MySqlParameter("dirName", info.dirName.ToLower()),
                new MySqlParameter("className", info.className)
            }).ToString());
            if (count > 0)
            {
                throw new Exception("所在栏目下栏目名或目录名已存在");
            }

            downFiles(ref info.maxIco);
            Sql.ExecuteNonQuery("insert into class " +
                                "(id,className,classId,moduleId,rootId,keyword,maxIco,skinId,contentSkinId,info,custom,thumbnailWidth,thumbnailHeight,thumbnailForce,saveRemoteImages,inherit,domainName,updateDate,createDate,userId,childId,pddir,dirPath,parentId,saveDataType,dirName,layer,orderId,titleRepeat,watermark,_domainName)" +
                                "values" +
                                "(@id,@className,@classId,@moduleId,@rootId,@keyword,@maxIco,@skinId,@contentSkinId,@info,@custom,@thumbnailWidth,@thumbnailHeight,@thumbnailForce,@saveRemoteImages,@inherit,@domainName,@updateDate,@createDate,@userId,@childId,@pddir,@dirPath,@parentId,@saveDataType,@dirName,@layer,0,@titleRepeat,@watermark,@_domainName)", new MySqlParameter[] {
                new MySqlParameter("id", info.id),
                new MySqlParameter("className", info.className),
                new MySqlParameter("classId", info.classId),
                new MySqlParameter("moduleId", info.moduleId),
                new MySqlParameter("rootId", info.rootId),
                new MySqlParameter("keyword", info.keyword),
                new MySqlParameter("maxIco", info.maxIco),
                new MySqlParameter("skinId", info.skinId),
                new MySqlParameter("contentSkinId", info.contentSkinId),
                new MySqlParameter("info", info.info),
                new MySqlParameter("custom", info.custom),
                new MySqlParameter("thumbnailWidth", info.thumbnailWidth),
                new MySqlParameter("thumbnailHeight", info.thumbnailHeight),
                new MySqlParameter("thumbnailForce", info.thumbnailForce),
                new MySqlParameter("saveRemoteImages", info.saveRemoteImages),
                new MySqlParameter("inherit", info.inherit),
                new MySqlParameter("domainName", info.domainName),
                new MySqlParameter("_domainName", info._domainName),
                new MySqlParameter("createDate", info.createDate),
                new MySqlParameter("updateDate", info.updateDate),
                new MySqlParameter("userId", user.id),
                new MySqlParameter("childId", info.childId),
                new MySqlParameter("dirPath", info.dirPath),
                new MySqlParameter("pddir", info.pddir),
                new MySqlParameter("parentId", info.parentId),
                new MySqlParameter("saveDataType", info.saveDataType),
                new MySqlParameter("dirName", info.dirName),
                new MySqlParameter("layer", info.layer),
                new MySqlParameter("titleRepeat", info.titleRepeat),
                new MySqlParameter("watermark", info.watermark)
            });
            RecordClass.addKeyword(info.id, info.keyword, 0);
            reset(info.id);
        }
Beispiel #4
0
        public static ReturnValue add(ModuleInfo info, UserInfo user)
        {
            ReturnValue err = new ReturnValue();

            #region 验证
            if (info.moduleName.Trim() == "")
            {
                err.errNo  = -1;
                err.errMsg = "栏目名不能为空";
                return(err);
            }
            if (info.dirName.Trim() == "")
            {
                err.errNo  = -1;
                err.errMsg = "目录名不能为空";
                return(err);
            }
            #endregion
            info.id = double.Parse(Tools.GetId());
            int count = int.Parse(Sql.ExecuteScalar("select count(1) from module where dirName=@dirName", new MySqlParameter[] {
                new MySqlParameter("dirName", info.dirName.ToLower())
            }).ToString());
            if (count > 0)
            {
                throw new Exception("频道目录名已存在");
            }

            if (info.type)
            {
                ColumnInfo column = new ColumnInfo();
                column.id               = info.id;
                column.className        = info.moduleName;
                column.classId          = 7;
                column.moduleId         = info.id;
                column.custom           = info.custom;
                column.thumbnailWidth   = info.thumbnailWidth;
                column.thumbnailHeight  = info.thumbnailHeight;
                column.thumbnailForce   = info.thumbnailForce;
                column.saveRemoteImages = info.saveRemoteImages;
                column.inherit          = info.inherit;
                column.dirName          = info.dirName;
                column.saveDataType     = info.saveDataType;
                column.titleRepeat      = info.titleRepeat;
                ColumnClass.add(column, user);
            }
            Sql.ExecuteNonQuery("insert into module " +
                                "(id,moduleName,type,saveDataType,dirName,createDate,updateDate,custom,thumbnailWidth,thumbnailHeight,thumbnailForce,saveRemoteImages,orderId,titleRepeat,watermark)" +
                                "values" +
                                "(@id,@moduleName,@type,@saveDataType,@dirName,@createDate,@updateDate,@custom,@thumbnailWidth,@thumbnailHeight,@thumbnailForce,@saveRemoteImages,@orderId,@titleRepeat,@watermark)"
                                , new MySqlParameter[] {
                new MySqlParameter("id", info.id),
                new MySqlParameter("moduleName", info.moduleName),
                new MySqlParameter("type", info.type),
                new MySqlParameter("saveDataType", info.saveDataType),
                new MySqlParameter("dirName", info.dirName),
                new MySqlParameter("createDate", info.createDate),
                new MySqlParameter("updateDate", info.updateDate),
                new MySqlParameter("custom", info.custom),
                new MySqlParameter("thumbnailWidth", info.thumbnailWidth),
                new MySqlParameter("thumbnailHeight", info.thumbnailHeight),
                new MySqlParameter("thumbnailForce", info.thumbnailForce),
                new MySqlParameter("saveRemoteImages", info.saveRemoteImages),
                new MySqlParameter("orderId", info.orderId),
                new MySqlParameter("titleRepeat", info.titleRepeat),
                new MySqlParameter("watermark", info.watermark)
            }
                                );
            err.userData = info.id;
            return(err);
        }