public function setUserPasswd() { $from = _request('from', ''); if (0 && Kernel::isDemo()) { return Kernel::noDemo(); } $comptes_service =& CopixClassesFactory::Create('comptes|ComptesService'); $userinfo = $comptes_service->checkLoginAccess(_request('login')); $passwd1 = trim(_request('passwd1')); $passwd2 = trim(_request('passwd2')); if ($passwd1 == '' || strlen($passwd1) < 6) { $urlReturn = CopixUrl::get('comptes||getUser', array('node_type' => _request('node_type'), 'node_id' => _request('node_id'), 'login' => _request('login'), 'error' => 'tooshortpassword', 'from' => $from)); return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } if ($passwd2 == '' || $passwd1 != $passwd2) { $urlReturn = CopixUrl::get('comptes||getUser', array('node_type' => _request('node_type'), 'node_id' => _request('node_id'), 'login' => _request('login'), 'error' => 'notsamepassword', 'from' => $from)); return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } $user_dao =& CopixDAOFactory::create("kernel|kernel_copixuser"); $user_new = $user_dao->getByLogin(_request('login')); $user_new[0]->password_dbuser = md5(_request('passwd1')); $user_dao->update($user_new[0]); //print_r($user_new); if ($from == 'assistance') { $urlReturn = CopixUrl::get('assistance||users'); } else { $urlReturn = CopixUrl::get('comptes||getNode', array('type' => _request('node_type'), 'id' => _request('node_id'))); } return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); }
public function noDemo() { if (Kernel::isDemo()) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nodemo'), 'TITLE_PAGE' => CopixI18N::get('kernel|kernel.error.demomode'), 'back' => CopixUrl::get('||'))); // 'back'=>'javascript:history.go(-1);' )); } }
public function setPrefs() { if (0 && Kernel::isDemo()) { return Kernel::noDemo(); } CopixHTMLHeader::addCSSLink(_resource("styles/module_prefs.css")); 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"/>'); $tpl = new CopixTpl(); // Liste des modules qui peuvent avoir des préférences... $modules = Prefs::getModules(); $arModulesPath = CopixConfig::instance()->arModulesPath; $datas = array(); $errors = array(); reset($modules); 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'); reset($_POST); // Parcours de tous les parametres passé en POST, pour chaque module. foreach ($_POST as $post_key => $post_val) { if (ereg('^' . $mod_val->rep . '_(.+)$', $post_key, $regs)) { $datas[$mod_val->rep][$regs[1]] = $post_val; } } // Appel de la fonction de vérification du module. if (method_exists($module_class, 'checkPrefs')) { $d = isset($datas[$mod_val->rep]) ? $datas[$mod_val->rep] : null; $error = $module_class->checkPrefs($mod_val->rep, $d); if (sizeof($error)) { $errors[$mod_val->rep] = $error; } } } } if (sizeof($errors)) { //print_r($errors); // $tplPrefs = new CopixTpl (); // Liste des modules disponibles... reset($modules); 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; } // Chargement de la classe... $module_class =& CopixClassesFactory::Create($mod_val->rep . '|mod' . $mod_val->rep . 'prefs'); // Récupération de la structure des prefs... $d = isset($data[$mod_val->rep]) ? $data[$mod_val->rep] : null; $pref = $module_class->getPrefs($d); $pref['code'] = $mod_val->rep; if (isset($pref['form'])) { // Protection contre les modules aux prefs vides foreach ($pref['form'] as $key => $val) { if (isset($val['code']) && isset($_POST[$pref['code'] . '_' . $val['code']])) { $pref['form'][$key]['value'] = $_POST[$pref['code'] . '_' . $val['code']]; } //print_r($val); if (isset($val['code']) && isset($errors[$pref['code']][$val['code']])) { $pref['form'][$key]['error'] = $errors[$pref['code']][$val['code']]; } } } $prefs[] = $pref; } } $tpl->assign('TITLE_PAGE', CopixI18N::get('prefs.moduleDescription')); $tpl->assign('MAIN', CopixZone::process('prefs|prefs', array('prefs' => $prefs))); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); } else { reset($modules); 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($datas[$mod_val->rep]) ? $datas[$mod_val->rep] : null; $module_class->setPrefs($mod_val->rep, $d); } } } return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('prefs|default|default', array('msg' => 'save'))); }