public function getPrefs() { CopixHTMLHeader::addCSSLink(_resource("styles/module_prefs.css")); $tpl = new CopixTpl(); $main = ''; $prefs = array(); $modules = Prefs::getModules(); $data = Prefs::getPrefs(); $arModulesPath = CopixConfig::instance()->arModulesPath; foreach ($modules as $mod_key => $mod_val) { foreach ($arModulesPath as $modulePath) { $class_file = $modulePath . $mod_val->rep . '/' . COPIX_CLASSES_DIR . 'mod' . $mod_val->rep . 'prefs.class.php'; if (!file_exists($class_file)) { continue; } $module_class =& CopixClassesFactory::Create($mod_val->rep . '|mod' . $mod_val->rep . 'prefs'); $d = isset($data[$mod_val->rep]) ? $data[$mod_val->rep] : null; $pref = $module_class->getPrefs($d); $pref['code'] = $mod_val->rep; $prefs[] = $pref; } } //print_r($prefs); $tpl->assign('TITLE_PAGE', CopixI18N::get('prefs.moduleDescription')); $tpl->assign('MAIN', CopixZone::process('prefs|prefs', array('prefs' => $prefs, 'msg' => _request('msg')))); CopixHTMLHeader::addOthers('<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"/>'); CopixHTMLHeader::addOthers('<META HTTP-EQUIV="Expires" CONTENT="-1"/>'); CopixHTMLHeader::addOthers('<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"/>'); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * Envoie un minimail * * @author Christophe Beyer <*****@*****.**> * @since 2005/10/18 * @param string title Titre du minimail * @param string message Corps du minimail * @param integer from_id Id utilisateur de l'exp�diteur * @param array destin Id tableau avec les destinataires (cl� = id user) * @return mixed Id du message cr�� ou NULL si erreur */ public function sendMinimail($title, $message, $from_id, $destin, $format) { $res = NULL; $DAOminimail_from = _dao("minimail|minimail_from"); $DAOminimail_to = _dao("minimail|minimail_to"); $newMp = _record("minimail|minimail_from"); $newMp->title = $title; $newMp->message = $message; $newMp->format = $format; $newMp->date_send = date("Y-m-d H:i:s"); $newMp->from_id = $from_id; $newMp->is_deleted = 0; $DAOminimail_from->insert($newMp); if ($newMp->id !== NULL) { //print_r($newMp); // On parcourt chaque destinataire while (list($to_id, ) = each($destin)) { // print_r("to_id=$to_id / to_login=$to_login"); $newDest = _record("minimail|minimail_to"); $newDest->id_message = $newMp->id; $newDest->to_id = $to_id; $newDest->date_read = 0; $newDest->is_read = 0; $newDest->is_replied = 0; $newDest->is_deleted = 0; $DAOminimail_to->insert($newDest); // ======= Alerte mail =============== // On vérifie que l'envoi de mails est activé, qu'un serveur SMTP est configuré, que le destinataire a coché l'option "etre prêvenu par mail" et qu'il a renseigné un mail if ($newDest->id2 && CopixConfig::get('|mailEnabled') == 1 && CopixConfig::get('|mailSmtpHost')) { $prefs = Prefs::getPrefs($to_id); if (isset($prefs['prefs']['alerte_mail_email']) && isset($prefs['minimail']['alerte_minimail']) && $prefs['prefs']['alerte_mail_email'] && $prefs['minimail']['alerte_minimail'] == 1) { $userInfoFrom = Kernel::getUserInfo("ID", $from_id); //print_r($userInfoFrom); $to = $prefs['prefs']['alerte_mail_email']; $auteur = utf8_decode($userInfoFrom['prenom'] . ' ' . $userInfoFrom['nom'] . ' (' . $userInfoFrom['login'] . ')'); $subject = CopixI18N::get('minimail|minimail.mail.alert.subject', array($auteur)); $message = str_replace('<br />', "\n", CopixI18N::get('minimail|minimail.mail.alert.body', array($auteur, CopixUrl::get('minimail||getMessage', array('id' => $newMp->id)), CopixUrl::get()))); $from = CopixConfig::get('default|mailFrom'); $fromName = CopixConfig::get('default|mailFromName'); $cc = $cci = ''; $monMail = new CopixTextEMail($to, $cc, $cci, $subject, $message); $send = $monMail->send($from, $fromName); } } // ======= Fin alerte mail =============== } $res = $newMp->id; if ($res) { $plugStats = CopixPluginRegistry::get("stats|stats"); $plugStats->setParams(array('module' => 'minimail', 'action' => 'sendMinimail', 'objet_a' => $res)); } } return $res; }
/** * Entree dans le module * * @author Christophe Beyer <*****@*****.**> * @since 2010/08/26 * @param integer $id Id du module */ public function processGo() { $ppo = new CopixPPO(); $iId = CopixRequest::getInt('id'); $iSubmit = CopixRequest::getInt('submit'); $this->addCss('styles/module_contact.css'); $this->js->button('.button'); $getLevel = Kernel::getLevel('MOD_CONTACT', $iId); //echo "getLevel=$getLevel"; $rContact = _dao('contact|contacts')->get($iId); //print_r($rContact); if (!$rContact) { return $this->error('contact|contact.errors.param', true, CopixUrl::get('||')); } $ppo->types = _dao('contact|contacts_types')->findByContact($iId); $user = _currentUser(); $possible = CopixConfig::get('|mailEnabled') == 1 && CopixConfig::get('|mailSmtpHost'); if ($iSubmit) { // Submit du formulaire $record = _record('contact|contacts_messages'); $record->contact = $iId; $record->to_email = $rContact->email; $record->date = date("Y-m-d H:i:s"); $record->from_nom = _request('from_nom'); $record->from_email = _request('from_email'); $record->from_login = $user->getLogin(); $record->from_user_id = $user->getId(); $record->type = _request('type'); $record->message = _request('message'); $record->ip = $_SERVER["REMOTE_ADDR"]; $check = _dao('contact|contacts_messages')->check($record); $ok = false; if (!is_array($check)) { // OK, pas d'erreurs _dao('contact|contacts_messages')->insert($record); if ($record->id) { // Enregistrement bien passe $type_nom = ''; foreach ($ppo->types as $type) { if ($type->id == $record->type) { $type_nom = $type->nom; } } if ($possible) { $to = $record->to_email; $subject = $type_nom; $message = CopixI18N::get('contact.mail.date') . " : " . date("d/m/Y H:i"); $message .= "\n" . CopixI18N::get('contact.mail.ip') . " : " . $record->ip; $message .= "\n"; $message .= "\n" . CopixI18N::get('contact.mail.nom') . " : " . $record->from_nom; if ($record->from_login) { $message .= ' (' . $record->from_login . ')'; } $message .= "\n" . CopixI18N::get('contact.mail.email') . " : " . $record->from_email; $message .= "\n"; $message .= "\n" . CopixI18N::get('contact.mail.type') . " : " . $type_nom; $message .= "\n" . CopixI18N::get('contact.mail.message') . " : " . $record->message; $message .= "\n\n-- \n" . CopixUrl::get(); $from = $record->from_email; $fromName = $record->from_nom; if ($record->from_login) { $fromName .= ' (' . $record->from_login . ')'; } $cc = $cci = ''; $monMail = new CopixTextEMail($to, $cc, $cci, utf8_decode($subject), utf8_decode($message)); $send = $monMail->send(utf8_decode($from), utf8_decode($fromName)); if ($send) { $ok = true; } else { $check = array(CopixI18N::get('contact|contact.errors.mailSend')); } } else { $check = array(CopixI18N::get('contact|contact.errors.mailDisabledAfter')); } } else { $check = array(CopixI18N::get('contact|contact.errors.save')); } } $ppo->rForm = $record; $ppo->errors = $check; $ppo->ok = $ok; } else { $ppo->rForm = _record('contact|contacts_messages'); foreach ($ppo->types as $type) { if ($type->is_default) { $ppo->rForm->type = $type->id; } } $ppo->rForm->from_nom = trim($user->getExtra('prenom') . ' ' . $user->getExtra('nom')); $prefs = Prefs::getPrefs($user->getId()); if (isset($prefs['prefs']['alerte_mail_email'])) { $ppo->rForm->from_email = $prefs['prefs']['alerte_mail_email']; } if (!$possible) { $ppo->errors = array(CopixI18N::get('contact|contact.errors.mailDisabled')); } } $ppo->TITLE_PAGE = $rContact->titre; return _arPPO($ppo, 'contact.tpl'); }