static function getPermissionsBySource()
 {
     $sources = array();
     $permissions = Permissions::findAll();
     //findAll
     if (is_array($permissions)) {
         foreach ($permissions as $permission) {
             if (!isset($sources[$permission->getSource()])) {
                 $sources[$permission->getSource()] = array();
             }
             // if
             $sources[$permission->getSource()][] = array($permission->getName(), $permission->getId());
         }
         // foreach
     }
     // if
     return $sources;
 }
 static function removeSource($source)
 {
     $permissions = Permissions::findAll(array('conditions' => "`source` = '" . $source . "'"));
     if (is_array($permissions)) {
         foreach ($permissions as $permission) {
             $userpermissions = ProjectUserPermissions::findAll(array('conditions' => "`permission_id` = '" . $permission->getId() . "'"));
             foreach ($userpermissions as $userpermission) {
                 $userpermission->delete();
             }
             $permission->delete();
         }
         return true;
         // permission already exists
     }
     return false;
     // permission source does not exist
 }
 static function removeSource($source)
 {
     $permissions = Permissions::findAll(array('conditions' => "`source` = '" . $source . "'"));
     if (is_array($permissions)) {
         foreach ($permissions as $permission) {
             PermissionManager::removeUserPermissions($permission);
             $permission->delete();
         }
         return true;
         // permission source removed
     }
     return false;
     // permission source does not exist
 }
Esempio n. 4
0
<?php

$page_title = lang('permissions');
set_page_title($page_title);
project_crumbs(lang('permissions'));
add_stylesheet_to_page('project/permissions.css');
$source = array();
$names = array();
$source_id = 0;
$name_id = 0;
$xpermissions = Permissions::findAll();
// findAll
if (is_array($permissions)) {
    foreach ($xpermissions as $permission) {
        $source_id++;
        $sources[$permission->getSource()] = option_tag($permission->getSource(), $source_id);
        $name_id++;
        $names[$permission->getName()] = option_tag($permission->getName(), $name_id);
    }
    // foreach
}
// if
$this->includeTemplate(get_template_path('project/pageactions'));
$quoted_permissions = array();
foreach ($permissions as $permission_id => $permission_text) {
    $quoted_permissions[] = "'{$permission_id}'";
}
// foreach
if (isset($companies) && is_array($companies) && count($companies)) {
    ?>
<form action="<?php