Subversion Repositories wimsdev

Rev

Rev 15414 | Rev 15875 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15414 Rev 15874
Line 160... Line 160...
160
#define ac_exam  0x200/* work during an exam */
160
#define ac_exam  0x200/* work during an exam */
161
 
161
 
162
/* Check site or class access policy. */
162
/* Check site or class access policy. */
163
void access_check(int isclass)
163
void access_check(int isclass)
164
{
164
{
165
  char *p, *p1, *p2, *p3, *pp1, *pp2;
165
  char *p, *p1, *p2, *p3, *pp1, *pp2, *name;
166
  char cbuf[MAX_LINELEN+1];
166
  char cbuf[MAX_LINELEN+1];
167
  long int thisaccess, lineaccess, linepol, thispol;
167
  long int thisaccess, lineaccess, linepol, thispol;
168
  int non, refuse;
168
  int non, refuse;
169
 
169
 
170
  if(manageable>=2 || robot_access) return;
170
  if(manageable>=2 || robot_access) return;
Line 217... Line 217...
217
      pp2=find_word_end(pp1); if(*pp2) *pp2++=0;
217
      pp2=find_word_end(pp1); if(*pp2) *pp2++=0;
218
      if(strncmp(pp1,"non",3)==0) {
218
      if(strncmp(pp1,"non",3)==0) {
219
        pp1=find_word_start(pp1+3); non=1;
219
        pp1=find_word_start(pp1+3); non=1;
220
      }  else non=0;
220
      }  else non=0;
221
      thispol=0;
221
      thispol=0;
222
      if(strcmp(pp1,"class")==0) {thispol=ac_class; goto nxt;}
222
      if(strcmp(pp1,"class")==0) {thispol=ac_class; name="class"; goto nxt;}
223
      if(strcmp(pp1,"exo")==0) {thispol=ac_exo; goto nxt;}
223
      if(strcmp(pp1,"exo")==0) {thispol=ac_exo; name="exo"; goto nxt;}
224
      if(strcmp(pp1,"exercise")==0) {thispol=ac_exo; goto nxt;}
224
      if(strcmp(pp1,"exercise")==0) {thispol=ac_exo; name="exo"; goto nxt;}
225
      if(strcmp(pp1,"tool")==0) {thispol=ac_tool; goto nxt;}
225
      if(strcmp(pp1,"tool")==0) {thispol=ac_tool; name="tool"; goto nxt;}
226
      if(strcmp(pp1,"recre")==0) {thispol=ac_recre; goto nxt;}
226
      if(strcmp(pp1,"recre")==0) {thispol=ac_recre; name="recre"; goto nxt;}
227
      if(strcmp(pp1,"recreation")==0) {thispol=ac_recre; goto nxt;}
227
      if(strcmp(pp1,"recreation")==0) {thispol=ac_recre; name="recre"; goto nxt;}
228
      if(strcmp(pp1,"doc")==0) {thispol=ac_doc; goto nxt;}
228
      if(strcmp(pp1,"doc")==0) {thispol=ac_doc; name="doc"; goto nxt;}
229
      if(strcmp(pp1,"document")==0) {thispol=ac_doc; goto nxt;}
229
      if(strcmp(pp1,"document")==0) {thispol=ac_doc; name="doc"; goto nxt;}
230
      if(strcmp(pp1,"local")==0) {thispol=ac_local; goto nxt;}
230
      if(strcmp(pp1,"local")==0) {thispol=ac_local; name="local"; goto nxt;}
231
      if(strcmp(pp1,"com")==0) {thispol=ac_com; goto nxt;}
231
      if(strcmp(pp1,"com")==0) {thispol=ac_com; name="com"; goto nxt;}
232
      if(strcmp(pp1,"hint")==0) {thispol=ac_hint; goto nxt;}
232
      if(strcmp(pp1,"hint")==0) {thispol=ac_hint; name="hint"; goto nxt;}
233
      nxt:
233
      nxt:
234
      if(thispol==0) continue;
234
      if(thispol==0) continue;
235
      if(non) lineaccess^=thispol;
235
      if(non) lineaccess^=thispol;
236
      linepol|=thispol;
236
      linepol|=thispol;
237
    }
237
    }
238
    if(linepol==0 || (linepol&lineaccess)!=linepol) continue;
238
    if(linepol==0 || (linepol&lineaccess)!=linepol) continue;
-
 
239
    char msg[200]; snprintf(msg,200,"no_access_class %s",name);
239
    if(refuse)
240
    if(refuse)
240
      if (isclass) user_error("no_access_class"); else user_error("no_access");
241
      if (isclass) user_error(msg); else user_error("no_access");
241
    else return;
242
    else return;
242
  }
243
  }
243
  /* end of limited access */
244
  /* end of limited access */
244
}
245
}