Example #1
0
 /**
  * Check if input file meet requirements
  *
  * @param string $filename File name
  *
  * @return boolean
  */
 private function _check($filename)
 {
     //deal with mac e-o-l encoding -- see if needed
     //@ini_set('auto_detect_line_endings', true);
     $handle = fopen(self::DEFAULT_DIRECTORY . '/' . $filename, 'r');
     if (!$handle) {
         Analog::log('File ' . $filename . ' cannot be open!', Analog::ERROR);
         $this->addError(str_replace('%filename', $filename, _T('File %filename cannot be open!')));
         return false;
     }
     if ($handle !== false) {
         $cnt_fields = count($this->_fields);
         //check required fields
         $fc = new FieldsConfig(Adherent::TABLE, $this->_members_fields, $members_fields_cats);
         $config_required = $fc->getRequired();
         $this->_required = array();
         foreach (array_keys($config_required) as $field) {
             if (in_array($field, $this->_fields)) {
                 $this->_required[$field] = $field;
             }
         }
         $row = 0;
         while (($data = fgetcsv($handle, 1000, self::DEFAULT_SEPARATOR, self::DEFAULT_QUOTE)) !== false) {
             //check fields count
             $count = count($data);
             if ($count != $cnt_fields) {
                 $this->addError(str_replace(array('%should_count', '%count', '%row'), array($cnt_fields, $count, $row), _T("Fields count mismatch... There should be %should_count fields and there are %count (row %row)")));
                 return false;
             }
             //check required fields
             if ($row > 0) {
                 //header line is the first one. Here comes data
                 $col = 0;
                 foreach ($data as $column) {
                     if (in_array($this->_fields[$col], $this->_required) && trim($column) == '') {
                         $this->addError(str_replace(array('%field', '%row'), array($this->_fields[$col], $row), _T("Field %field is required, but missing in row %row")));
                         return false;
                     }
                     $col++;
                 }
             }
             $row++;
         }
         fclose($handle);
         if (!($row > 1)) {
             //no data in file, just headers line
             $this->addError(_T("File is empty!"));
             return false;
         } else {
             return true;
         }
     }
     return false;
 }
Example #2
0
//admins or staff members
if ($login->isAdmin() || $login->isStaff()) {
    $csv = new CsvOut();
    if (isset($session['filters']['members']) && !isset($_POST['mailing']) && !isset($_POST['mailing_new'])) {
        //CAUTION: this one may be simple or advanced, display must change
        $filters = unserialize($session['filters']['members']);
    } else {
        $filters = new MembersList();
    }
    $export_fields = null;
    if (file_exists(GALETTE_CONFIG_PATH . 'local_export_fields.inc.php')) {
        include_once GALETTE_CONFIG_PATH . 'local_export_fields.inc.php';
        $export_fields = $fields;
    }
    // fields visibility
    $fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
    $visibles = $fc->getVisibilities();
    $fields = array();
    $headers = array();
    foreach ($members_fields as $k => $f) {
        if ($k !== 'mdp_adh' && $export_fields === null || is_array($export_fields) && in_array($k, $export_fields)) {
            if ($visibles[$k] == FieldsConfig::VISIBLE) {
                $fields[] = $k;
                $labels[] = $f['label'];
            } else {
                if (($login->isAdmin() || $login->isStaff() || $login->isSuperAdmin()) && $visibles[$k] == FieldsConfig::ADMIN) {
                    $fields[] = $k;
                    $labels[] = $f['label'];
                }
            }
        }
Example #3
0
use Galette\Entity\FieldsConfig;
use Galette\Entity\Texts;
use Galette\Repository\Titles;
use Galette\Core\PasswordImage;
/** @ignore */
require_once 'includes/galette.inc.php';
if (!$preferences->pref_bool_selfsubscribe) {
    header('location:index.php');
    die;
}
$dyn_fields = new DynamicFields();
$member = new Adherent();
//mark as self membership
$member->setSelfMembership();
// flagging required fields
$fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
// flagging required fields invisible to members
$fc->setNotRequired('activite_adh');
$fc->setNotRequired('id_statut');
$required = $fc->getRequired();
// flagging fields visibility
$visibles = $fc->getVisibilities();
// disable some fields
$disabled = $member->disabled_fields;
// DEBUT parametrage des champs
// On recupere de la base la longueur et les flags des champs
// et on initialise des valeurs par defaut
$update_string = '';
$insert_string_fields = '';
$insert_string_values = '';
$has_register = false;
Example #4
0
    } elseif ($login->isStaff()) {
        $disabled = $member->adm_edit_disabled_fields + $member->staff_edit_disabled_fields;
    } else {
        $disabled = $member->adm_edit_disabled_fields + $member->staff_edit_disabled_fields + $member->disabled_fields;
    }
    if ($preferences->pref_mail_method == GaletteMail::METHOD_DISABLED) {
        $disabled['send_mail'] = 'disabled="disabled"';
    }
} else {
    $member->load($login->id);
    $adherent['id_adh'] = $login->id;
    // disable some fields
    $disabled = $member->disabled_fields + $member->edit_disabled_fields;
}
// flagging required fields
$fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
// password required if we create a new member
if ($member->id != '') {
    $fc->setNotRequired('mdp_adh');
}
//address and mail fields are not required if member has a parent
$no_parent_required = array('adresse_adh', 'adresse2_adh', 'cp_adh', 'ville_adh', 'email_adh');
if ($member->hasParent()) {
    foreach ($no_parent_required as $field) {
        if ($fc->isRequired($field)) {
            $fc->setNotRequired($field);
        } else {
            $i = array_search($field, $no_parent_required);
            unset($no_parent_required[$i]);
        }
    }
Example #5
0
    unset($session['pdf_error_msg']);
    unset($session['pdf_error']);
}
if (isset($session['lostpasswd_errors'])) {
    $error_detected = unserialize($session['lostpasswd_errors']);
    unset($session['lostpasswd_errors']);
}
if (isset($session['lostpasswd_success'])) {
    $success_detected = unserialize($session['lostpasswd_success']);
    unset($session['lostpasswd_success']);
}
$dyn_fields = new DynamicFields();
$deps = array('picture' => true, 'groups' => true, 'dues' => true, 'parent' => true, 'children' => true);
$member = new Adherent((int) $id_adh, $deps);
// flagging fields visibility
$fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
$visibles = $fc->getVisibilities();
if ($login->id != $id_adh && !$login->isAdmin() && !$login->isStaff()) {
    //check if requested member is part of managed groups
    $groups = $member->groups;
    $is_managed = false;
    foreach ($groups as $g) {
        if ($login->isGroupManager($g->getId())) {
            $is_managed = true;
            break;
        }
    }
    if ($is_managed !== true) {
        //requested member is not part of managed groups, fall back to logged
        //in member
        $member->load($login->id);
Example #6
0
use Galette\Entity\FieldsConfig;
require_once 'includes/galette.inc.php';
$authorized = array('members');
$current = isset($_GET['table']) && in_array($_GET['table'], $authorized) ? $_GET['table'] : 'members';
if (!$login->isLogged()) {
    header("location: index.php");
    die;
}
if (!$login->isAdmin()) {
    header("location: voir_adherent.php");
    die;
}
$fc = null;
switch ($current) {
    case 'members':
        $fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
        break;
    default:
        Analog::log('Trying to configure fields on unknown table (' . $current . ')', Analog::WARNING);
        break;
}
if (isset($_POST) && count($_POST) > 0) {
    $pos = 0;
    $current_cat = 0;
    $res = array();
    foreach ($_POST['fields'] as $abs_pos => $field) {
        if ($current_cat != $_POST[$field . '_category']) {
            //reset position when category has changed
            $pos = 0;
            //set new current category
            $current_cat = $_POST[$field . '_category'];