Esempio n. 1
0
 /**
  * Global getter method
  *
  * @param string $name name of the property we want to retrive
  *
  * @return false|object the called property
  */
 public function __get($name)
 {
     global $log, $login;
     $forbidden = array('admin', 'staff', 'due_free', 'appears_in_list', 'active', 'row_classes');
     $virtuals = array('sadmin', 'sstaff', 'sdue_free', 'sappears_in_list', 'sactive', 'stitle', 'sstatus', 'sfullname', 'sname', 'rowclass', 'saddress');
     $rname = '_' . $name;
     if (!in_array($name, $forbidden) && isset($this->{$rname})) {
         switch ($name) {
             case 'birthdate':
             case 'creation_date':
             case 'modification_date':
             case 'due_date':
                 if ($this->{$rname} != '') {
                     try {
                         $d = new \DateTime($this->{$rname});
                         return $d->format(_T("Y-m-d"));
                     } catch (\Exception $e) {
                         //oops, we've got a bad date :/
                         Analog::log('Bad date (' . $this->{$rname} . ') | ' . $e->getMessage(), Analog::INFO);
                         return $this->{$rname};
                     }
                 }
                 break;
             default:
                 return $this->{$rname};
                 break;
         }
     } else {
         if (!in_array($name, $forbidden) && in_array($name, $virtuals)) {
             $real = '_' . substr($name, 1);
             switch ($name) {
                 case 'sadmin':
                 case 'sdue_free':
                 case 'sappears_in_list':
                 case 'sstaff':
                     return $this->{$real} ? _T("Yes") : _T("No");
                     break;
                 case 'sactive':
                     return $this->{$real} ? _T("Active") : _T("Inactive");
                     break;
                 case 'stitle':
                     if (isset($this->_title)) {
                         return $this->_title->tshort;
                     } else {
                         return null;
                     }
                     break;
                 case 'sstatus':
                     $status = new Status();
                     return $status->getLabel($this->_status);
                     break;
                 case 'sfullname':
                     $sfn = mb_strtoupper($this->_name, 'UTF-8') . ' ' . ucwords(mb_strtolower($this->_surname, 'UTF-8'));
                     if (isset($this->_title)) {
                         $sfn = $this->_title->tshort . ' ' . $sfn;
                     }
                     return $sfn;
                     break;
                 case 'saddress':
                     $address = $this->_address;
                     if ($this->_address_continuation !== '') {
                         $address .= "\n" . $this->_address_continuation;
                     }
                     return $address;
                     break;
                 case 'sname':
                     return mb_strtoupper($this->_name, 'UTF-8') . ' ' . ucwords(mb_strtolower($this->_surname, 'UTF-8'));
                     break;
             }
         } else {
             return false;
         }
     }
 }
Esempio n. 2
0
 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'];
             }
         }
     }
 }
 $members = new Members($filters);
 $members_list = $members->getArrayList($filters->selected, null, false, false, $fields, true);
 $s = new Status();
 $statuses = $s->getList();
 $t = new Titles();
 $titles = $t->getList($zdb);
 foreach ($members_list as &$member) {
     if (isset($member->id_statut)) {
         //add textual status
         $member->id_statut = $statuses[$member->id_statut];
     }
     if (isset($member->titre_adh)) {
         //add textuel title
         $member->titre_adh = $titles[$member->titre_adh]->short;
     }
     //handle dates
     if (isset($member->date_crea_adh)) {
         if ($member->date_crea_adh != '' && $member->date_crea_adh != '1901-01-01') {
Esempio n. 3
0
 /**
  * Global setter method
  *
  * @param string $name  name of the property we want to assign a value to
  * @param object $value a relevant value for the property
  *
  * @return void
  */
 public function __set($name, $value)
 {
     if (in_array($name, $this->pagination_fields) || in_array($name, $this->memberslist_fields)) {
         parent::__set($name, $value);
     } else {
         Analog::log('[AdvancedMembersList] Setting property `' . $name . '`', Analog::DEBUG);
         $prop = '_' . $name;
         switch ($name) {
             case 'creation_date_begin':
             case 'creation_date_end':
             case 'modif_date_begin':
             case 'modif_date_end':
             case 'due_date_begin':
             case 'due_date_end':
             case 'birth_date_begin':
             case 'birth_date_end':
             case 'contrib_creation_date_begin':
             case 'contrib_creation_date_end':
             case 'contrib_begin_date_begin':
             case 'contrib_begin_date_end':
             case 'contrib_end_date_begin':
             case 'contrib_end_date_end':
                 if ($value !== null && trim($value) !== '') {
                     try {
                         $d = \DateTime::createFromFormat(_T("Y-m-d"), $value);
                         if ($d === false) {
                             throw new \Exception('Incorrect format');
                         }
                         $this->{$prop} = $d->format('Y-m-d');
                     } catch (\Exception $e) {
                         Analog::log('Incorrect date format for ' . $name . '! was: ' . $value, Analog::WARNING);
                     }
                 }
                 break;
             case 'contrib_min_amount':
             case 'contrib_max_amount':
                 if (is_float($value)) {
                     $this->{$prop} = $value;
                 } else {
                     if ($value !== null) {
                         Analog::log('Incorrect amount for ' . $name . '! ' . 'Should be a float (' . gettype($value) . ' given)', Analog::WARNING);
                     }
                 }
                 break;
             case 'show_public_infos':
                 if (is_numeric($value)) {
                     $this->{$prop} = $value;
                 } else {
                     Analog::log('[AdvancedMembersList] Value for property `' . $name . '` should be an integer (' . gettype($value) . ' given)', Analog::WARNING);
                 }
                 break;
             case 'status':
                 if (!is_array($value)) {
                     $value = array($value);
                 }
                 $this->_status = array();
                 foreach ($value as $v) {
                     if (is_numeric($v)) {
                         //check status existence
                         $s = new Status();
                         $res = $s->get($v);
                         if ($res !== false) {
                             $this->_status[] = $v;
                         } else {
                             Analog::log('Status #' . $v . ' does not exists!', Analog::WARNING);
                         }
                     } else {
                         Analog::log('[AdvancedMembersList] Value for status filter should be an ' . 'integer (' . gettype($v) . ' given', Analog::WARNING);
                     }
                 }
                 break;
             case 'contributions_types':
                 if (!is_array($value)) {
                     $value = array($value);
                 }
                 $this->_contributions_types = array();
                 foreach ($value as $v) {
                     if (is_numeric($v)) {
                         //check type existence
                         $s = new ContributionsTypes();
                         $res = $s->get($v);
                         if ($res !== false) {
                             $this->_contributions_types[] = $v;
                         } else {
                             Analog::log('Contribution type #' . $v . ' does not exists!', Analog::WARNING);
                         }
                     } else {
                         Analog::log('[AdvancedMembersList] Value for contribution type ' . 'filter should be an integer (' . gettype($v) . ' given', Analog::WARNING);
                     }
                 }
                 break;
             case 'payments_types':
                 if (!is_array($value)) {
                     $value = array($value);
                 }
                 $this->_payments_types = array();
                 foreach ($value as $v) {
                     if (is_numeric($v)) {
                         if ($v == Contribution::PAYMENT_OTHER || $v == Contribution::PAYMENT_CASH || $v == Contribution::PAYMENT_CREDITCARD || $v == Contribution::PAYMENT_CHECK || $v == Contribution::PAYMENT_TRANSFER || $v == Contribution::PAYMENT_PAYPAL) {
                             $this->_payments_types[] = $v;
                         } else {
                             Analog::log('Payment type #' . $v . ' does not exists!', Analog::WARNING);
                         }
                     } else {
                         Analog::log('[AdvancedMembersList] Value for payment type filter should be an ' . 'integer (' . gettype($v) . ' given', Analog::WARNING);
                     }
                 }
                 break;
             case 'free_search':
                 if (isset($this->_free_search['empty'])) {
                     unset($this->_free_search['empty']);
                 }
                 if (is_array($value)) {
                     if (isset($value['field']) && isset($value['search']) && isset($value['log_op']) && isset($value['qry_op']) && isset($value['idx'])) {
                         $id = $value['idx'];
                         unset($value['idx']);
                         $this->_free_search[$id] = $value;
                     } else {
                         Analog::log('[AdvancedMembersList] bad construct for free filter', Analog::WARNING);
                     }
                 } else {
                     Analog::log('[AdvancedMembersList] Value for free filter should be an ' . 'array (' . gettype($value) . ' given', Analog::WARNING);
                 }
                 break;
             default:
                 if (substr($name, 0, 4) === 'cds_' || substr($name, 0, 5) === 'cdsc_') {
                     if (is_array($value) || trim($value) !== '') {
                         if (isset($this->_contrib_dynamic['empty'])) {
                             unset($this->_contrib_dynamic['empty']);
                         }
                         $id = null;
                         if (substr($name, 0, 5) === 'cdsc_') {
                             $id = substr($name, 5, strlen($name));
                         } else {
                             $id = substr($name, 4, strlen($name));
                         }
                         $this->_contrib_dynamic[$id] = $value;
                     }
                 } else {
                     Analog::log('[AdvancedMembersList] Unable to set proprety `' . $name . '`', Analog::WARNING);
                 }
                 break;
         }
     }
 }