Esempio n. 1
0
    protected function migrateAddFilePermissions()
    {
        $db = Loader::db();
        $tables = $db->MetaTables();
        if (!in_array('FileSetPermissions', $tables)) {
            return false;
        }
        $r = $db->Execute('select canAdd, gID, uID, fsID from FileSetPermissions where canAdd > 0 order by fsID asc');
        $pko = FileSetPermissionKey::getByHandle('add_file');
        while ($row = $r->FetchRow()) {
            $pe = $this->migrateAccessEntity($row);
            if (!$pe) {
                continue;
            }
            if ($row['fsID'] > 0) {
                $fs = FileSet::getByID($row['fsID']);
            } else {
                $fs = FileSet::getGlobal();
            }
            if (is_object($fs)) {
                $pko->setPermissionObject($fs);
                $pt = $pko->getPermissionAssignmentObject();
                $pa = $pko->getPermissionAccessObject();
                if (!is_object($pa)) {
                    $pa = PermissionAccess::create($pko);
                } else {
                    if ($pa->isPermissionAccessInUse()) {
                        $pa = $pa->duplicate();
                    }
                }
                $pa->addListItem($pe, false, FileSetPermissionKey::ACCESS_TYPE_INCLUDE);
                $args = array();
                if ($row['canAdd'] == 10) {
                    $args['fileTypesIncluded'][$pe->getAccessEntityID()] = 'A';
                } else {
                    $args['fileTypesIncluded'][$pe->getAccessEntityID()] = 'C';
                    $extensions = $db->GetCol('select extension from FilePermissionFileTypes where
						fsID = ? and gID = ? and uID = ?', array($row['fsID'], $row['gID'], $row['uID']));
                    foreach ($extensions as $ext) {
                        $args['extensionInclude'][$pe->getAccessEntityID()][] = $ext;
                    }
                }
                $pa->save($args);
                $pt->assignPermissionAccess($pa);
            }
        }
    }
Esempio n. 2
0
 }
 if ($_REQUEST['task'] == 'remove_access_entity' && Loader::helper("validation/token")->validate('remove_access_entity')) {
     $pk = FileSetPermissionKey::getByID($_REQUEST['pkID']);
     $pk->setPermissionObject($fs);
     $pa = PermissionAccess::getByID($_REQUEST['paID'], $pk);
     $pe = PermissionAccessEntity::getByID($_REQUEST['peID']);
     $pa->removeListItem($pe);
 }
 if ($_REQUEST['task'] == 'save_permission' && Loader::helper("validation/token")->validate('save_permission')) {
     $pk = FileSetPermissionKey::getByID($_REQUEST['pkID']);
     $pk->setPermissionObject($fs);
     $pa = PermissionAccess::getByID($_REQUEST['paID'], $pk);
     $pa->save($_POST);
 }
 if ($_REQUEST['task'] == 'save_workflows' && Loader::helper("validation/token")->validate('save_workflows')) {
     $pk = FileSetPermissionKey::getByID($_REQUEST['pkID']);
     $pk->setPermissionObject($fs);
     $pk->clearWorkflows();
     foreach ($_POST['wfID'] as $wfID) {
         $wf = Workflow::getByID($wfID);
         if (is_object($wf)) {
             $pk->attachWorkflow($wf);
         }
     }
 }
 if ($_REQUEST['task'] == 'display_access_cell' && Loader::helper("validation/token")->validate('display_access_cell')) {
     $pk = PermissionKey::getByID($_REQUEST['pkID']);
     $pk->setPermissionObject($fs);
     $pa = PermissionAccess::getByID($_REQUEST['paID'], $pk);
     Loader::element('permission/labels', array('pk' => $pk, 'pa' => $pa));
 }