/** * Logs in user. * * @param string $user user's login * @param string $passe user's password * * @return boolean */ public function logIn($user, $passe) { global $zdb, $i18n, $session; try { $select = $zdb->select(self::TABLE, 'a'); $select->columns(array('id_adh', 'bool_admin_adh', 'nom_adh', 'prenom_adh', 'mdp_adh', 'pref_lang', 'activite_adh', 'bool_exempt_adh', 'date_echeance'))->join(array('b' => PREFIX_DB . Status::TABLE), 'a.' . Status::PK . '=b.' . Status::PK, array('priorite_statut')); $select->where(array(self::PK => $user)); $results = $zdb->execute($select); if ($results->count() == 0) { Analog::log('No entry found for login `' . $user . '`', Analog::WARNING); return false; } else { $row = $results->current(); //check if pawwsord matches $pw_checked = password_verify($passe, $row->mdp_adh); if (!$pw_checked) { //if password did not match, we try old md5 method $pw_checked = md5($passe) === $row->mdp_adh; } if ($pw_checked === false) { //Passwords mismatch. Log and return. Analog::log('Passwords mismatch for login `' . $user . '`', Analog::WARNING); return false; } Analog::log('User `' . $user . '` logged in.', Analog::INFO); $this->id = $row->id_adh; $this->login = $user; $this->passe = $row->mdp_adh; $this->admin = $row->bool_admin_adh; $this->name = $row->nom_adh; $this->surname = $row->prenom_adh; $this->lang = $row->pref_lang; $i18n->changeLanguage($this->lang); $session['lang'] = serialize($i18n); $this->active = $row->activite_adh; $this->logged = true; if ($row->priorite_statut < Members::NON_STAFF_MEMBERS) { $this->staff = true; } //check if member is up to date if ($row->bool_exempt_adh == true) { //member is due free, he's up to date. $this->uptodate = true; } else { //let's check from end date, if present if ($row->date_echeance == null) { $this->uptodate = false; } else { $ech = new \DateTime($row->date_echeance); $now = new \DateTime(); $now->setTime(0, 0, 0); $this->uptodate = $ech >= $now; } } //staff members and admins are de facto groups managers. For all //others, get managed groups if (!$this->isSuperAdmin() && !$this->isAdmin() && !$this->isStaff()) { $this->managed_groups = Groups::loadManagedGroups($this->id, false); } return true; } } catch (AdapterException $e) { Analog::log('An error occured: ' . $e->getChainedException()->getMessage(), Analog::WARNING); Analog::log($e->getTrace(), Analog::ERROR); return false; } catch (\Exception $e) { Analog::log('An error occured: ' . $e->getMessage(), Analog::WARNING); Analog::log($e->getTrace(), Analog::ERROR); return false; } }
} } $doc_title = _T("Members by groups"); $pdf = new GroupsPdf($preferences); // Set document information $pdf->SetTitle($doc_title); $pdf->showPagination(); $pdf->setMargins(10, 20); $pdf->setHeaderMargin(10); $pdf->SetAutoPageBreak(true, 20); $pdf->Open(); $pdf->AddPage(); $pdf->PageHeader($doc_title); $pdf->SetFont(Pdf::FONT, '', SHEET_FONT); $pdf->SetTextColor(0, 0, 0); $groups = new Groups(); $groups_list = null; if (isset($_GET['gid'])) { $groups_list = $groups->getList(true, $_GET['gid']); } else { $groups_list = $groups->getList(); } //var_dump($groups_list); $first = true; foreach ($groups_list as $group) { $id = $group->getId(); if (!$login->isGroupManager($id)) { Analog::log('Trying to display group ' . $id . ' without appropriate permissions', Analog::INFO); continue; } // Header
/** * Load member groups * * @return void */ public function loadGroups() { $this->_groups = Groups::loadGroups($this->_id); $this->_managed_groups = Groups::loadManagedGroups($this->_id); }
$tpl->assign('member', $member); $tpl->assign('data', $adherent); $tpl->assign('self_adh', false); $tpl->assign('dynamic_fields', $dynamic_fields); $tpl->assign('error_detected', $error_detected); $tpl->assign('success_detected', $success_detected); if (isset($session['mail_warning'])) { //warning will be showed here, no need to keep it longer into session unset($session['mail_warning']); } $tpl->assign('warning_detected', $warning_detected); $tpl->assign('languages', $i18n->getList()); $tpl->assign('require_calendar', true); // pseudo random int $tpl->assign('time', time()); // genre $tpl->assign('titles_list', Titles::getList($zdb)); //Status $statuts = new Galette\Entity\Status(); $tpl->assign('statuts', $statuts->getList()); //Groups $groups = new Groups(); $groups_list = $groups->getSimpleList(true); $tpl->assign('groups', $groups_list); $form_elements = $fc->getFormElements(); $tpl->assign('fieldsets', $form_elements['fieldsets']); $tpl->assign('hidden_elements', $form_elements['hiddens']); // page generation $content = $tpl->fetch('member.tpl'); $tpl->assign('content', $content); $tpl->display('page.tpl');
$disabled['dyn'] = array(); $dynamic_fields = $dyn_fields->prepareForDisplay('adh', $adherent['dyn'], $disabled['dyn'], 0); if (isset($error_detected)) { $tpl->assign('error_detected', $error_detected); } $tpl->assign('page_title', _T("Member Profile")); $tpl->assign('require_dialog', true); $tpl->assign('member', $member); $tpl->assign('children', $children); $tpl->assign('data', $adherent); $tpl->assign('navigate', $navigate); $tpl->assign('pref_lang_img', $i18n->getFlagFromId($member->language)); $tpl->assign('pref_lang', ucfirst($i18n->getNameFromId($member->language))); $tpl->assign('pref_card_self', $preferences->pref_card_self); $tpl->assign('dynamic_fields', $dynamic_fields); $tpl->assign('groups', Groups::getSimpleList()); $tpl->assign('visibles', $visibles); $tpl->assign('time', time()); $display_elements = $fc->getDisplayElements(); $tpl->assign('display_elements', $display_elements); //if we got a mail warning when adding/editing a member, //we show it and delete it from session if (isset($session['mail_warning'])) { $warning_detected[] = $session['mail_warning']; unset($session['mail_warning']); } $tpl->assign('warning_detected', $warning_detected); if (isset($session['account_success'])) { $success_detected = unserialize($session['account_success']); unset($session['account_success']); }
*/ use Analog\Analog; use Galette\Entity\Group; use Galette\Entity\Adherent; use Galette\Repository\Members; use Galette\Repository\Groups; require_once 'includes/galette.inc.php'; if (!$login->isLogged()) { header('location: index.php'); die; } if (!$login->isAdmin() && !$login->isStaff() && !$login->isGroupManager()) { header('location: voir_adherent.php'); die; } $groups = new Groups(); $group = new Group(); $error_detected = array(); $success_detected = array(); $id = get_numeric_form_value(Group::PK, null); if ($id !== null) { if ($login->isGroupManager($id)) { $group->load($id); } else { Analog::log('Trying to display group ' . $id . ' without appropriate permissions', Analog::INFO); die; } } if (isset($_POST['pdf'])) { $qstring = 'groups_list.php'; if (isset($_POST['id_group'])) {
/** * Remove specified members * * @param integer|array $ids Members identifiers to delete * * @return boolean */ public function removeMembers($ids) { global $zdb, $hist; $list = array(); if (is_numeric($ids)) { //we've got only one identifier $list[] = $ids; } else { $list = $ids; } if (is_array($list)) { try { $zdb->connection->beginTransaction(); //Retrieve some informations $select = $zdb->select(self::TABLE); $select->columns(array(self::PK, 'nom_adh', 'prenom_adh'))->where->in(self::PK, $list); $results = $zdb->execute($select); $infos = null; foreach ($results as $member) { $str_adh = $member->id_adh . ' (' . $member->nom_adh . ' ' . $member->prenom_adh . ')'; $infos .= $str_adh . "\n"; $p = new Picture($member->id_adh); if ($p->hasPicture()) { if (!$p->delete(false)) { Analog::log('Unable to delete picture for member ' . $str_adh, Analog::ERROR); throw new \Exception('Unable to delete picture for member ' . $str_adh); } else { $hist->add(_T("Member Picture deleted"), $str_adh); } } } //delete contributions $del_qry = $zdb->delete(Contribution::TABLE); $del_qry->where->in(self::PK, $list); $del = $zdb->execute($del_qry); //delete transactions $del_qry = $zdb->delete(Transaction::TABLE); $del_qry->where->in(self::PK, $list); $del = $zdb->execute($del_qry); //delete groups membership/mamagmentship $del = Groups::removeMemberFromGroups((int) $member->id_adh); //delete reminders $del_qry = $zdb->delete(Reminder::TABLE); $del_qry->where->in('reminder_dest', $list); $del = $zdb->execute($del_qry); //delete members $del_qry = $zdb->delete(self::TABLE); $del_qry->where->in(self::PK, $list); $del = $zdb->execute($del_qry); //commit all changes $zdb->connection->commit(); //add an history entry $hist->add(_T("Delete members cards, transactions and dues"), $infos); return true; } catch (\Exception $e) { $zdb->connection->rollBack(); if ($e instanceof \Zend_Db_Statement_Exception && $e->getCode() == 23000) { Analog::log('Member still have existing dependencies in the ' . 'database, maybe a mailing or some content from a ' . 'plugin. Please remove dependencies before trying ' . 'to remove him.', Analog::ERROR); $this->_errors[] = _T("Cannot remove a member who still have dependencies (mailings, ...)"); } else { Analog::log('Unable to delete selected member(s) |' . $e->getMessage(), Analog::ERROR); } return false; } } else { //not numeric and not an array: incorrect. Analog::log('Asking to remove members, but without providing an array or a single numeric value.', Analog::WARNING); return false; } }