Ejemplo n.º 1
0
$return = array('module' => 'ACLRoles', 'action' => 'index', 'record' => '');
if (!empty($_REQUEST['record'])) {
    $role->retrieve($_REQUEST['record']);
    $categories = ACLRole::getRoleActions($_REQUEST['record']);
    $role_name = $role->name;
    if (!empty($_REQUEST['isDuplicate'])) {
        //role id is stripped here in duplicate so anything using role id after this will not have it
        $role->id = '';
    } else {
        $return['record'] = $role->id;
        $return['action'] = 'DetailView';
    }
} else {
    $categories = ACLRole::getRoleActions('');
}
$sugar_smarty->assign('ROLE', $role->toArray());
$tdwidth = 10;
if (isset($_REQUEST['return_module'])) {
    $return['module'] = $_REQUEST['return_module'];
    if (isset($_REQUEST['return_action'])) {
        $return['action'] = $_REQUEST['return_action'];
    }
    if (isset($_REQUEST['return_record'])) {
        $return['record'] = $_REQUEST['return_record'];
    }
}
$sugar_smarty->assign('RETURN', $return);
$names = ACLAction::setupCategoriesMatrix($categories);
if (!empty($names)) {
    $tdwidth = 100 / sizeof($names);
}
Ejemplo n.º 2
0
 /**
  * static getAllRoles($returnAsArray = false)
  *
  * @param boolean $returnAsArray - should it return the results as an array of arrays or as an array of ACLRoles
  *
  * @return either an array of array representations of acl roles or an array of ACLRoles
  */
 function getAllRoles($returnAsArray = false)
 {
     $db = DBManagerFactory::getInstance();
     $query = "SELECT acl_roles.* FROM acl_roles\n                    WHERE acl_roles.deleted=0 ORDER BY name";
     $result = $db->query($query);
     $roles = [];
     while ($row = $db->fetchByAssoc($result)) {
         $role = new ACLRole();
         $role->populateFromRow($row);
         if ($returnAsArray) {
             $roles[] = $role->toArray();
         } else {
             $roles[] = $role;
         }
     }
     return $roles;
 }
Ejemplo n.º 3
0
 public function testtoArray()
 {
     $aclRole = new ACLRole();
     //wihout any fields set
     $expected = array('id' => '', 'name' => '', 'description' => '');
     $actual = $aclRole->toArray();
     $this->assertSame($expected, $actual);
     //with fileds pre populated
     $aclRole->id = '1';
     $aclRole->name = 'test';
     $aclRole->description = 'some description text';
     $expected = array('id' => '1', 'name' => 'test', 'description' => 'some description text');
     $actual = $aclRole->toArray();
     $this->assertSame($expected, $actual);
 }