Exemplo n.º 1
0
 /**
  * get section details
  */
 public function readSection()
 {
     /**
      * all sections 
      */
     if ($this->all) {
         //get section by id
         $res = fetchSections();
         unset($this->all);
         //remove from result array
     } elseif ($this->id) {
         //id must be set and numberic
         if (is_null($this->id) || !is_numeric($this->id)) {
             throw new Exception('Section id not existing - ' . $this->id);
         }
         //get section by id
         $res = getSectionDetailsById($this->id);
         unset($this->id);
         //remove from result array
         //throw new exception if not existing
         if (sizeof($res) == 0) {
             throw new Exception('Section not existing');
         }
     } elseif ($this->name) {
         //id must be set and numberic
         if (is_null($this->name) || strlen($this->name) == 0) {
             throw new Exception('Invalid section name - ' . $this->name);
         }
         //get section by id
         $res = getSectionDetailsByName($this->name);
         unset($this->name);
         //remove from result array
         //throw new exception if not existing
         if (sizeof($res) == 0) {
             throw new Exception('Section not existing');
         }
     } else {
         throw new Exception('Selector missing');
     }
     //create object from results
     foreach ($res as $key => $line) {
         $this->{$key} = $line;
     }
     //convert object to array
     $result = $this->toArray($this);
     //return result
     return $result;
 }
Exemplo n.º 2
0
<?php

/**
 * Script to manage sections
 *************************************************/
/* verify that user is admin */
checkAdmin();
$sections = fetchSections(true);
# ets do some reordering to show slaves!
foreach ($sections as $s) {
    if ($s['masterSection'] == "0") {
        # it is master
        $s['class'] = "master";
        $sectionssorted[] = $s;
        # check for slaves
        foreach ($sections as $ss) {
            if ($ss['masterSection'] == $s['id']) {
                $ss['class'] = "slave";
                $sectionssorted[] = $ss;
            }
        }
    }
}
$sections = $sectionssorted;
?>

<h4><?php 
print _('Section management');
?>
</h4>
<hr>
Exemplo n.º 3
0
/**
 *	Delete all users from group
 */
function deleteGroupFromSections($gid)
{
    # get all users
    $sections = fetchSections();
    # check if $gid in array
    foreach ($sections as $s) {
        $g = json_decode($s['permissions'], true);
        if (sizeof($g) > 0) {
            if (array_key_exists($gid, $g)) {
                unset($g[$gid]);
                $ng = json_encode($g);
                updateSectionGroups($s['id'], $ng);
            }
        }
    }
    # return
    return $out;
}
Exemplo n.º 4
0
</td>
    </tr>  

    <?php 
if ($_POST['action'] != "add") {
    ?>
    <!-- section -->
    <tr>
        <td class="middle"><?php 
    print _('Section');
    ?>
</td>
        <td>
        	<select name="sectionIdNew" class="form-control input-sm input-w-auto">
            	<?php 
    $sections = fetchSections();
    foreach ($sections as $section) {
        /* selected? */
        if ($_POST['sectionId'] == $section['id']) {
            print '<option value="' . $section['id'] . '" selected>' . $section['name'] . '</option>' . "\n";
        } else {
            print '<option value="' . $section['id'] . '">' . $section['name'] . '</option>' . "\n";
        }
    }
    ?>
            </select>
        	
        	</select>
        </td>
        <td class="info2"><?php 
    print _('Move to different section');