public static function create(array $attributes)
 {
     $model = new GroupActions();
     $model->fill($attributes);
     $model->save();
     return $model;
 }
Exemple #2
0
/**
 * Show the form to add a new group.
 *
 * @package		ProjectSend
 * @subpackage	Groups
 *
 */
$multiselect = 1;
$allowed_levels = array(9, 8);
require_once 'sys.includes.php';
$active_nav = 'groups';
$page_title = __('Add clients group', 'cftp_admin');
include 'header.php';
if ($_POST) {
    $new_group = new GroupActions();
    /**
     * Clean the posted form values to be used on the groups actions,
     * and again on the form if validation failed.
     */
    $add_group_data_name = encode_html($_POST['add_group_form_name']);
    $add_group_data_description = encode_html($_POST['add_group_form_description']);
    $add_group_data_members = $_POST['add_group_form_members'];
    /** Arguments used on validation and group creation. */
    $new_arguments = array('id' => '', 'name' => $add_group_data_name, 'description' => $add_group_data_description, 'members' => $add_group_data_members);
    /** Validate the information from the posted form. */
    $new_validate = $new_group->validate_group($new_arguments);
    /** Create the group if validation is correct. */
    if ($new_validate == 1) {
        $new_response = $new_group->create_group($new_arguments);
    }
Exemple #3
0
     $groups_to_get = implode(',', array_map('intval', array_unique($selected_groups)));
     /**
      * Make a list of groups to avoid individual queries.
      */
     $sql_grps = $dbh->prepare("SELECT id, name FROM " . TABLE_GROUPS . " WHERE FIND_IN_SET(id, :groups)");
     $sql_grps->bindParam(':groups', $groups_to_get);
     $sql_grps->execute();
     $sql_grps->setFetchMode(PDO::FETCH_ASSOC);
     while ($data_group = $sql_grps->fetch()) {
         $all_groups[$data_group['id']] = $data_group['name'];
     }
     switch ($_POST['groups_actions']) {
         case 'delete':
             $deleted_groups = 0;
             foreach ($selected_groups as $groups) {
                 $this_group = new GroupActions();
                 $delete_group = $this_group->delete_group($groups);
                 $deleted_groups++;
                 /** Record the action log */
                 $new_log_action = new LogActions();
                 $log_action_args = array('action' => 18, 'owner_id' => $global_id, 'affected_account_name' => $all_groups[$groups]);
                 $new_record_action = $new_log_action->log_action_save($log_action_args);
             }
             if ($deleted_groups > 0) {
                 $msg = __('The selected groups were deleted.', 'cftp_admin');
                 echo system_message('ok', $msg);
             }
             break;
     }
 } else {
     $msg = __('Please select at least one group.', 'cftp_admin');
/**
 * Show the form to edit an existing group.
 *
 * @package		ProjectSend
 * @subpackage	Groups
 *
 */
$multiselect = 1;
$allowed_levels = array(9, 8);
require_once 'sys.includes.php';
$active_nav = 'groups';
$page_title = __('Edit group', 'cftp_admin');
include 'header.php';
$database->MySQLDB();
/** Create the object */
$edit_group = new GroupActions();
/** Check if the id parameter is on the URI. */
if (isset($_GET['id'])) {
    $group_id = mysql_real_escape_string($_GET['id']);
    /**
     * Check if the id corresponds to a real group.
     * Return 1 if true, 2 if false.
     **/
    $page_status = group_exists_id($group_id) ? 1 : 2;
} else {
    /**
     * Return 0 if the id is not set.
     */
    $page_status = 0;
}
/**