comparison admajax.php @ 795:f4b99fed50b4

Use the formatting functionality added to stChkRequestItem*().
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 21 Nov 2014 23:46:37 +0200
parents 18f88945d5f1
children b97d4b754bc0
comparison
equal deleted inserted replaced
794:18f88945d5f1 795:f4b99fed50b4
19 function stValidateRequestCompoData($full, $ctype) 19 function stValidateRequestCompoData($full, $ctype)
20 { 20 {
21 $res = TRUE; 21 $res = TRUE;
22 22
23 stChkRequestItemFail("name", $fake, $res, 23 stChkRequestItemFail("name", $fake, $res,
24 array(CHK_ISGT, VT_STR, 0, "Compo name too short"), 24 array(CHK_ISGT, VT_STR, 0, "Compo name is empty."),
25 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_NAME, "Compo name too long.")); 25 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_NAME, "Compo name too long (%1 chars, must be less than %2)."));
26 26
27 stChkRequestItemFail("description", $fake, $res, 27 stChkRequestItemFail("description", $fake, $res,
28 array(CHK_ISGT, VT_STR, 10, "Compo description too short"), 28 array(CHK_ISGT, VT_STR, 10, "Compo description too short (%1 chars, must be more than %2)"),
29 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long.")); 29 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long (%1 chars, must be less than %2)."));
30 30
31 // Not a full check? 31 // Not a full check?
32 if (!$full) 32 if (!$full)
33 return $res; 33 return $res;
34 34
45 stChkRequestItemFail("preview_type", $fake, $res, 45 stChkRequestItemFail("preview_type", $fake, $res,
46 array(CHK_TYPE, VT_INT, "Invalid data."), 46 array(CHK_TYPE, VT_INT, "Invalid data."),
47 array(CHK_RANGE, VT_INT, array(EPREV_NONE, EPREV_AUDIO), "Invalid preview type value.")); 47 array(CHK_RANGE, VT_INT, array(EPREV_NONE, EPREV_AUDIO), "Invalid preview type value."));
48 48
49 stChkRequestItemFail("cpath", $fake, $res, 49 stChkRequestItemFail("cpath", $fake, $res,
50 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long.")); 50 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long (%1 chars, must be less than %2)."));
51 break; 51 break;
52 } 52 }
53 53
54 stChkRequestItemFail("visible", $fake, $res, 54 stChkRequestItemFail("visible", $fake, $res,
55 array(CHK_TYPE, VT_BOOL, "Invalid data.")); 55 array(CHK_TYPE, VT_BOOL, "Invalid data."));
62 { 62 {
63 $res = TRUE; 63 $res = TRUE;
64 64
65 // Things common for all compo types 65 // Things common for all compo types
66 stChkRequestItemFail("name", $fake, $res, 66 stChkRequestItemFail("name", $fake, $res,
67 array(CHK_ISGT, VT_STR, 0, "Name too short."), 67 array(CHK_ISGT, VT_STR, 0, "Name is empty."),
68 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NAME, "Name too long.")); 68 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NAME, "Name too long (%1 chars, must be less than %2)."));
69 69
70 stChkRequestItemFail("notes", $fake, $res, 70 stChkRequestItemFail("notes", $fake, $res,
71 array(CHK_TYPE, VT_TEXT, "Invalid data."), 71 array(CHK_TYPE, VT_TEXT, "Invalid data."),
72 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NOTES, "Entry notes too long.")); 72 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NOTES, "Entry notes are too long (%1 chars, must be less than %2)."));
73 73
74 // Check based on compo type 74 // Check based on compo type
75 switch ($ctype) 75 switch ($ctype)
76 { 76 {
77 case COMPO_NORMAL: 77 case COMPO_NORMAL:
78 stChkRequestItemFail("compo_id", $compo_id, $res, 78 stChkRequestItemFail("compo_id", $compo_id, $res,
79 array(CHK_TYPE, VT_INT, "Invalid compo ID.")); 79 array(CHK_TYPE, VT_INT, "Invalid compo ID."));
80 80
81 stChkRequestItemFail("author", $fake, $res, 81 stChkRequestItemFail("author", $fake, $res,
82 array(CHK_ISGT, VT_STR, 0, "Author name not set."), 82 array(CHK_ISGT, VT_STR, 0, "Author name not set."),
83 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long.")); 83 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long (%1 chars, must be less than %2)."));
84 84
85 stChkRequestItemFail("filename", $fake, $res, 85 stChkRequestItemFail("filename", $fake, $res,
86 array(CHK_TYPE, VT_TEXT, "Invalid data."), 86 array(CHK_TYPE, VT_TEXT, "Invalid data."),
87 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_FILENAME, "Entry filename too long.")); 87 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_FILENAME, "Entry filename too long (%1 chars, must be less than %2)."));
88 88
89 stChkRequestItemFail("info", $fake, $res, 89 stChkRequestItemFail("info", $fake, $res,
90 array(CHK_TYPE, VT_TEXT, "Invalid data."), 90 array(CHK_TYPE, VT_TEXT, "Invalid data."),
91 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_INFO, "Entry info too long.")); 91 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_INFO, "Entry info text too long (%1 chars, must be less than %2)."));
92 92
93 if ($full) 93 if ($full)
94 { 94 {
95 stChkRequestItemFail("preview_type", $fake, $res, 95 stChkRequestItemFail("preview_type", $fake, $res,
96 array(CHK_TYPE, VT_INT, "Invalid data."), 96 array(CHK_TYPE, VT_INT, "Invalid data."),
98 } 98 }
99 break; 99 break;
100 100
101 case COMPO_POINTS: 101 case COMPO_POINTS:
102 stChkRequestItemFail("evalue", $fake, $res, 102 stChkRequestItemFail("evalue", $fake, $res,
103 array(CHK_TYPE, VT_INT, "Invalid points, must be a integer.")); 103 array(CHK_TYPE, VT_INT, "Invalid points value, must be a valid integer."));
104 break; 104 break;
105 105
106 case COMPO_ASSIGN: 106 case COMPO_ASSIGN:
107 stChkRequestItemFail("evalue", $fake, $res, 107 stChkRequestItemFail("evalue", $fake, $res,
108 array(CHK_TYPE, VT_INT, "Invalid position, must be a integer."), 108 array(CHK_TYPE, VT_INT, "Invalid position, must be a valid integer."),
109 array(CHK_GTEQ, VT_INT, 1, "Invalid position, must be > 0.")); 109 array(CHK_GTEQ, VT_INT, 1, "Invalid position, must be >= %2."));
110 break; 110 break;
111 } 111 }
112 112
113 return $res; 113 return $res;
114 } 114 }
118 { 118 {
119 $res = TRUE; 119 $res = TRUE;
120 120
121 stChkRequestItemFail("text", $fake, $res, 121 stChkRequestItemFail("text", $fake, $res,
122 array(CHK_ISGT, VT_STR, 0, "News text too short."), 122 array(CHK_ISGT, VT_STR, 0, "News text too short."),
123 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TEXT, "News text too long.")); 123 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TEXT, "News text too long (%1 chars, must be less than %2)."));
124 124
125 stChkRequestItemFail("author", $fake, $res, 125 stChkRequestItemFail("author", $fake, $res,
126 array(CHK_ISGT, VT_STR, 0, "News author name too short."), 126 array(CHK_ISGT, VT_STR, 0, "News author name not set."),
127 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_AUTHOR, "News author name too long.")); 127 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_AUTHOR, "News author name too long (%1 chars, must be less than %2)."));
128 128
129 stChkRequestItemFail("title", $fake, $res, 129 stChkRequestItemFail("title", $fake, $res,
130 array(CHK_ISGT, VT_STR, 0, "News title too short."), 130 array(CHK_ISGT, VT_STR, 0, "News title not set."),
131 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TITLE, "News title too long.")); 131 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TITLE, "News title too long (%1 chars. must be less than %2)."));
132 132
133 return $res; 133 return $res;
134 } 134 }
135 135
136 136