51ff3226 |
1 | <?php |
2 | |
3 | function masterlist() { |
fd15ea3a |
4 | global $db,$error,$node; |
51ff3226 |
5 | $node_id=$node['node_id']; |
6 | if (($node['node_permission']!='owner') && ($node['node_permission']!='master')) { |
7 | $error=$error_messages['EVENT_PERMISSION_ERROR']; |
8 | return false; |
9 | } |
10 | $masters=explode(";",$_POST['masterlist']); |
11 | $db->query("update node_access set node_permission='' where node_id=$node_id and node_permission='master'"); |
12 | foreach ($masters as $master) { |
13 | $set=$db->query("select user_id from users where login='$master'"); |
14 | $set->next(); |
15 | if ($set->getString('user_id')) { |
16 | $q="update node_access set node_permission='master' where node_id=$node_id and user_id='".$set->getString('user_id')."'"; |
17 | $changed=$db->update($q); |
18 | if (!$changed) { |
19 | $q="insert into node_access set node_permission='master',node_id=$node_id,user_id=".$set->getString('user_id'); |
20 | $db->query($q); |
fd15ea3a |
21 | logger::log('add master',$node_id,'ok',$master); |
51ff3226 |
22 | |
23 | } |
24 | } |
25 | else { $error .= "$master does not exist..."; } |
26 | } |
27 | } |
28 | ?> |