Beispiel #1
0
 public function process(Tracker_IDisplayTrackerLayout $layout, Codendi_Request $request, PFUser $current_user)
 {
     $transition = $request->get('transition');
     //TODO check that the transition belongs to the current tracker
     // Permissions
     $ugroups = $request->get('ugroups');
     permission_clear_all($this->tracker->group_id, 'PLUGIN_TRACKER_WORKFLOW_TRANSITION', $transition, false);
     if ($this->transition_factory->addPermissions($ugroups, $transition)) {
         $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('workflow_admin', 'permissions_updated'));
     } else {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('workflow_admin', 'permissions_not_updated'));
     }
     //Conditions
     $condition_manager = new Transition_ConditionManager();
     $condition_manager->process($this->transition_factory->getTransition($transition), $request, $current_user);
     // Post actions
     $tpam = new Transition_PostActionManager();
     $tpam->process($this->transition_factory->getTransition($transition), $request, $current_user);
     $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => Workflow::FUNC_ADMIN_TRANSITIONS, 'edit_transition' => $request->get('transition'))));
 }
Beispiel #2
0
                <tr><td><input type="submit" value="' . $Language->getText('global', 'btn_create') . '"></td></tr></table>	
	    </form>	
	<h3>' . $Language->getText('docman_admin_index', 'doc_group_list') . '</h3>	';
    display_groups($group_id);
}
//begin to seek out what this page has been called to do.
$func = $request->getValidated('func', 'string', '');
if (isset($func) && $func == 'update_permissions') {
    list($return_code, $feedback) = permission_process_selection_form($_POST['group_id'], $_POST['permission_type'], $_POST['object_id'], $_POST['ugroups']);
    if (!$return_code) {
        exit_error('Error', $Language->getText('docman_admin_index', 'error_updating_perm') . '<p>' . $feedback);
    }
}
if (isset($_POST['reset'])) {
    // Must reset access rights to defaults
    if (permission_clear_all($group_id, $_POST['permission_type'], $_POST['object_id'])) {
        $feedback = $Language->getText('docman_admin_index', 'perm_reset');
    } else {
        $feedback = $Language->getText('docman_admin_index', 'error_resetting perm');
    }
}
$mode = $request->getValidated('mode', 'string', '');
if (strstr($mode, "docedit")) {
    $query = "select * from doc_data,doc_groups " . "where docid='{$docid}' " . "and doc_groups.doc_group = doc_data.doc_group " . "and doc_groups.group_id = '{$group_id}'";
    $result = db_query($query);
    $row = db_fetch_array($result);
    docman_header_admin(array('title' => $Language->getText('docman_admin_index', 'title_edit')));
    echo '
	
<form name="editdata" action="index.php?mode=docdoedit&group_id=' . $group_id . '" method="POST"  enctype="multipart/form-data">
  <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="' . $sys_max_size_upload . '">
Beispiel #3
0
 /**
  * Reset access permissions.
  *
  * @return boolean  Modification status
  */
 function resetPermissions()
 {
     return permission_clear_all($this->gid, 'WIKI_READ', $this->gid);
 }
 /**
  * Save the value and return the id
  * 
  * @param Tracker_Artifact                $artifact                The artifact
  * @param int                             $changeset_value_id      The id of the changeset_value 
  * @param mixed                           $value                   The value submitted by the user
  * @param Tracker_Artifact_ChangesetValue $previous_changesetvalue The data previously stored in the db
  *
  * @return int or array of int
  */
 protected function saveValue($artifact, $changeset_value_id, $value, Tracker_Artifact_ChangesetValue $previous_changesetvalue = null)
 {
     if (empty($value)) {
         $value['use_artifact_permissions'] = 0;
         $value['u_groups'] = array();
     }
     $artifact->setUseArtifactPermissions($value['use_artifact_permissions']);
     permission_clear_all($this->getTracker()->getGroupId(), 'PLUGIN_TRACKER_ARTIFACT_ACCESS', $artifact->getId(), false);
     if (!empty($value['u_groups'])) {
         $ok = $this->addPermissions($value['u_groups'], $artifact->getId());
     }
     //save in changeset
     return $this->getValueDao()->create($changeset_value_id, $value['use_artifact_permissions'], $value['u_groups']);
 }
 /**
  * Delete a workflow
  *
  * @param Workflow $workflow
  *
  * @return boolean
  */
 public function deleteWorkflow($workflow)
 {
     $transitions = $this->getTransitions($workflow);
     $workflow_id = $workflow->getId();
     //Delete permissions
     foreach ($transitions as $transition) {
         permission_clear_all($workflow->getTracker()->getGroupId(), 'PLUGIN_TRACKER_WORKFLOW_TRANSITION', $transition->getTransitionId(), false);
     }
     //Delete postactions
     if ($this->getPostActionFactory()->deleteWorkflow($workflow_id)) {
         return $this->getDao()->deleteWorkflowTransitions($workflow_id);
     }
 }
Beispiel #6
0
 public function resetPermissions()
 {
     return permission_clear_all($this->gid, Wiki_PermissionsManager::WIKI_PERMISSION_READ, $this->id);
 }
 public function process(TrackerManager $engine, Codendi_Request $request, User $current_user)
 {
     if ($request->get('create')) {
         if ($request->existAndNonEmpty('field_id')) {
             if (WorkflowFactory::instance()->create((int) $this->tracker->id, $request->get('field_id'))) {
                 $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('workflow_admin', 'created'));
                 $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow')));
             }
         }
     } else {
         if ($request->get('edit_transition')) {
             $workflow = WorkflowFactory::instance()->getWorkflowByTrackerId($this->tracker->id);
             $transition = TransitionFactory::instance()->getTransition($request->get('edit_transition'));
             $this->displayTransitionDetails($engine, $request, $current_user, $transition);
         } else {
             if ($request->get('delete')) {
                 if (WorkflowFactory::instance()->deleteWorkflow($request->get('delete'))) {
                     $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('workflow_admin', 'deleted'));
                     $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow')));
                 }
             } else {
                 if ($request->get('create_matrix')) {
                     $k = 0;
                     $workflow = WorkflowFactory::instance()->getWorkflowByTrackerId($this->tracker->id);
                     $field = Tracker_FormElementFactory::instance()->getFormElementById($workflow->field_id);
                     $field_values = $field->getBind()->getAllValues();
                     $currMatrix = array();
                     $field_value_from = null;
                     //Add an initial state transition
                     foreach ($field_values as $field_value_id_to => $field_value_to) {
                         //$field_value_from=;
                         $transition = '_' . $field_value_id_to;
                         if ($request->existAndNonEmpty($transition)) {
                             $currMatrix[] = array('', $field_value_id_to);
                             $k += $this->addTransition($workflow, $transition, $field_value_from, $field_value_to);
                         }
                     }
                     //Add a transition
                     foreach ($field_values as $field_value_id_from => $field_value_from) {
                         foreach ($field_values as $field_value_id_to => $field_value_to) {
                             $transition = $field_value_id_from . '_' . $field_value_id_to;
                             if ($request->existAndNonEmpty($transition)) {
                                 $currMatrix[] = array($field_value_id_from, $field_value_id_to);
                                 $k += $this->addTransition($workflow, $transition, $field_value_from, $field_value_to);
                             }
                         }
                     }
                     //Delete a transition
                     $transitions_in_db = $workflow->getTransitions();
                     $nb_transitions_in_db = count($transitions_in_db);
                     for ($i = 0; $i < $nb_transitions_in_db; $i++) {
                         $field_value_from = $transitions_in_db[$i]->getFieldValueFrom();
                         $field_value_to = $transitions_in_db[$i]->getFieldValueTo();
                         //Treatment of the initial state
                         if ($field_value_from == null) {
                             $value_to_search = array('', $field_value_to->getId());
                             //$field_value_from->getId()='';
                         } else {
                             $value_to_search = array($field_value_from->getId(), $field_value_to->getId());
                         }
                         if (!in_array($value_to_search, $currMatrix)) {
                             WorkflowFactory::instance()->deleteTransition($workflow->workflow_id, $field_value_from, $field_value_to);
                             $k++;
                         }
                     }
                     if ($k > 0) {
                         $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('workflow_admin', 'updated'));
                         $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow')));
                     } else {
                         $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('workflow_admin', 'not_updated'));
                         $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow')));
                     }
                 } else {
                     if ($request->get('enable_workflow')) {
                         $workflow = WorkflowFactory::instance()->getWorkflowByTrackerId($this->tracker->id);
                         $is_used = $request->get('is_used');
                         //TODO : use $request
                         if ($is_used == 'on') {
                             $is_used = 1;
                             $feedback = $GLOBALS['Language']->getText('workflow_admin', 'workflow_enabled');
                         } else {
                             $is_used = 0;
                             $feedback = $GLOBALS['Language']->getText('workflow_admin', 'workflow_disabled');
                         }
                         if (WorkflowFactory::instance()->updateActivation((int) $workflow->workflow_id, $is_used)) {
                             $GLOBALS['Response']->addFeedback('info', $feedback);
                             $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow')));
                         }
                     } else {
                         if ($request->get('workflow_details')) {
                             $transition = $request->get('transition');
                             //TODO check that the transition belongs to the current tracker
                             // Permissions
                             $ugroups = $request->get('ugroups');
                             permission_clear_all($this->tracker->group_id, 'PLUGIN_TRACKER_WORKFLOW_TRANSITION', $transition, false);
                             if (TransitionFactory::instance()->addPermissions($ugroups, $transition)) {
                                 $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('workflow_admin', 'permissions_updated'));
                             } else {
                                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('workflow_admin', 'permissions_not_updated'));
                             }
                             // Post actions
                             $tpam = new Transition_PostActionManager();
                             $tpam->process(TransitionFactory::instance()->getTransition($transition), $request, $current_user);
                             $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow', 'edit_transition' => $request->get('transition'))));
                         } else {
                             $this->displayAdminDefineWorkflow($engine, $request, $current_user);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Delete the permissions of the repository
  *
  * @param GitRepository $repository
  *
  * @return bool true if success, false otherwise
  */
 public function deletePermissions($repository)
 {
     $group_id = $repository->getProjectId();
     $object_id = $repository->getId();
     return permission_clear_all($group_id, Git::PERM_READ, $object_id) && permission_clear_all($group_id, Git::PERM_WRITE, $object_id) && permission_clear_all($group_id, Git::PERM_WPLUS, $object_id);
 }
 /**
  * Save the value and return the id
  *
  * @param Tracker_Artifact                $artifact                The artifact
  * @param int                             $changeset_value_id      The id of the changeset_value
  * @param mixed                           $value                   The value submitted by the user
  * @param Tracker_Artifact_ChangesetValue $previous_changesetvalue The data previously stored in the db
  *
  * @return boolean
  */
 protected function saveValue($artifact, $changeset_value_id, $value, Tracker_Artifact_ChangesetValue $previous_changesetvalue = null)
 {
     if (empty($value) || !isset($value[self::USE_IT]) || $value[self::USE_IT] == 0) {
         $value[self::USE_IT] = 0;
         $value['u_groups'] = array();
     }
     $artifact->setUseArtifactPermissions($value[self::USE_IT]);
     permission_clear_all($this->getTracker()->getGroupId(), self::PERMISSION_TYPE, $artifact->getId(), false);
     if (!empty($value['u_groups'])) {
         $ok = $this->addPermissions($value['u_groups'], $artifact->getId());
     }
     //save in changeset
     return $this->getValueDao()->create($changeset_value_id, $value[self::USE_IT], $value['u_groups']);
 }
 /**
  * Delete a workflow
  *
  * @param Workflow $workflow
  *
  * @return boolean
  */
 public function deleteWorkflow($workflow)
 {
     $transitions = $this->getTransitions($workflow);
     $workflow_id = $workflow->getId();
     $this->getDao()->startTransaction();
     $field_not_empty_dao = $this->getFieldNotEmptyDao();
     //Delete permissions
     foreach ($transitions as $transition) {
         $transition_id = $transition->getTransitionId();
         permission_clear_all($workflow->getTracker()->getGroupId(), Workflow_Transition_Condition_Permissions::PERMISSION_TRANSITION, $transition_id, false);
         $field_not_empty_dao->deleteByTransitionId($transition_id);
     }
     //Delete postactions
     if ($this->getPostActionFactory()->deleteWorkflow($workflow_id)) {
         $result = $this->getDao()->deleteWorkflowTransitions($workflow_id);
     }
     $this->getDao()->commit();
     return $result;
 }
 public function restrictAccess($item, $params = array())
 {
     // Check whether there is other references to this wiki page.
     $dao = $this->_getItemDao();
     $referenced = $dao->isWikiPageReferenced($item->getPageName(), $item->getGroupId());
     if (!$referenced) {
         $dIF =& $this->_getItemFactory();
         $id_in_wiki = $dIF->getIdInWikiOfWikiPageItem($item->getPageName(), $item->getGroupId());
         // Restrict access to wiki admins if the page already exists in wiki.
         if ($id_in_wiki !== null) {
             permission_clear_all($item->getGroupId(), 'WIKIPAGE_READ', $id_in_wiki, false);
             permission_add_ugroup($item->getGroupId(), 'WIKIPAGE_READ', $id_in_wiki, $GLOBALS['UGROUP_WIKI_ADMIN']);
         }
     }
 }
Beispiel #12
0
/**
 * Updated permissions according to form generated by permission_display_selection_form()
 *
 * parameter $ugroups contains the list of ugroups to authorize for this object.
 *
 * @deprecated
 * @see PermissionsManager::savePermissions
 * @return a two elements array:
 *  - First element is 'true' or 'false', depending on whether permissions where changed
 *  - Second element is an optional message to be displayed (warning or error)
 * Exemples: (false,"Cannot combine 'any registered user' with another group)
 *           (true,"Removed 'nobody' from the list")
 */
function permission_process_selection_form($group_id, $permission_type, $object_id, $ugroups)
{
    global $Language;
    // Check that we have all parameters
    if (!$object_id) {
        return array(false, $Language->getText('project_admin_permissions', 'obj_id_missed'));
    }
    if (!$permission_type) {
        return array(false, $Language->getText('project_admin_permissions', 'perm_type_missed'));
    }
    if (!$group_id) {
        return array(false, $Language->getText('project_admin_permissions', 'g_id_missed'));
    }
    $anon_selected = 0;
    $any_selected = 0;
    // Check consistency of ugroup list
    $num_ugroups = 0;
    while (list(, $selected_ugroup) = each($ugroups)) {
        $num_ugroups++;
        if ($selected_ugroup == $GLOBALS['UGROUP_ANONYMOUS']) {
            $anon_selected = 1;
        }
        if ($selected_ugroup == $GLOBALS['UGROUP_REGISTERED']) {
            $any_selected = 1;
        }
    }
    // Reset permissions for this object, before setting the new ones
    permission_clear_all($group_id, $permission_type, $object_id, false);
    // Set new permissions
    $msg = '';
    if ($anon_selected) {
        if (permission_add_ugroup($group_id, $permission_type, $object_id, $GLOBALS['UGROUP_ANONYMOUS'])) {
            $msg .= $Language->getText('project_admin_permissions', 'all_users_added');
        } else {
            return array(false, $Language->getText('project_admin_permissions', 'cant_add_ug_anonymous', $msg));
        }
        if ($num_ugroups > 1) {
            $msg .= $Language->getText('project_admin_permissions', 'ignore_g');
        }
    } else {
        if ($any_selected) {
            if (permission_add_ugroup($group_id, $permission_type, $object_id, $GLOBALS['UGROUP_REGISTERED'])) {
                $msg .= $Language->getText('project_admin_permissions', 'all_registered_users_added') . " ";
            } else {
                return array(false, $Language->getText('project_admin_permissions', 'cant_add_ug_reg_users', $msg));
            }
            if ($num_ugroups > 1) {
                $msg .= $Language->getText('project_admin_permissions', 'ignore_g');
            }
        } else {
            reset($ugroups);
            while (list(, $selected_ugroup) = each($ugroups)) {
                if ($selected_ugroup == $GLOBALS['UGROUP_NONE']) {
                    if ($num_ugroups > 1) {
                        $msg .= $Language->getText('project_admin_permissions', 'g_nobody_ignored') . " ";
                        continue;
                    } else {
                        $msg .= $Language->getText('project_admin_permissions', 'nobody_has_no_access') . " ";
                    }
                }
                if (permission_add_ugroup($group_id, $permission_type, $object_id, $selected_ugroup)) {
                    # $msg .= "+g$selected_ugroup ";
                } else {
                    return array(false, $Language->getText('project_admin_permissions', 'cant_add_ug', array($msg, $selected_ugroup)));
                }
            }
        }
    }
    // If selected permission is the same as default, then don't store it!
    if (permission_equals_to_default($permission_type, $object_id)) {
        permission_clear_all($group_id, $permission_type, $object_id, false);
        $msg .= ' ' . $Language->getText('project_admin_permissions', 'def_val');
    }
    permission_add_history($group_id, $permission_type, $object_id);
    return array(true, $Language->getText('project_admin_permissions', 'perm_update_success', $msg));
}
Beispiel #13
0
function news_update_permissions($forum_id, $is_private, $group_id)
{
    global $Language, $UGROUP_PROJECT_MEMBERS;
    /*
    	Takes forum_id and permission, and updates the permission of the corresponding entry in 'permissions' table
    */
    if ($is_private == 3) {
        permission_clear_all($group_id, 'NEWS_READ', $forum_id, false);
        if (permission_add_ugroup($group_id, 'NEWS_READ', $forum_id, $UGROUP_PROJECT_MEMBERS)) {
            $GLOBALS['Response']->addFeedback('info', $Language->getText('news_submit', 'news_perm_update_success'));
        } else {
            $GLOBALS['Response']->addFeedback('error', $Language->getText('news_admin_index', 'update_err'));
        }
    } else {
        if (permission_clear_all($group_id, 'NEWS_READ', $forum_id, false)) {
            $GLOBALS['Response']->addFeedback('info', $Language->getText('news_submit', 'news_perm_update_success'));
        } else {
            $GLOBALS['Response']->addFeedback('error', $Language->getText('news_admin_index', 'update_err'));
        }
    }
}
 /**
  *@access public
  */
 public function resetPermissions()
 {
     return permission_clear_all($this->gid, 'PHPWIKIATTACHMENT_READ', $this->id);
 }