function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoEmaillist.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; //conexion resource $pDB = new paloDB($arrConf['dsn_conn_database']); //actions $action = getAction(); $content = ""; switch ($action) { case "new_emaillist": $content = viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "save_newList": $content = saveNewList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "new_memberlist": case "remove_memberlist": $content = viewFormMemberList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "save_newMember": case "save_removeMember": $content = saveNewMember($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "delete": $content = deleteEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "view_memberlist": $content = viewMemberList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "export": $content = exportMembers($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; default: $content = reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; } return $content; }
function _moduleContent(&$smarty, $module_name) { global $arrConf; //folder path for custom templates $local_templates_dir = getWebDirModule($module_name); //conexion resource $pDB = new paloDB($arrConf['elastix_dsn']["elastix"]); //user credentials global $arrCredentials; //actions $action = getAction(); $content = ""; switch ($action) { case "view_list": $content = viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "new_emaillist": $content = viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "save_newList": $content = saveNewList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "mailman_settings": $content = viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "saveMailmanSettings": $content = saveMailmanSettings($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "delete": $content = deleteEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "export": $content = exportMembers($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "view_memberlist": $content = reportMemberList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "new_memberlist": $content = viewFormMemberList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "save_newMember": $content = saveNewMember($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; case "remove_memberlist": $content = removeMemberList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; default: $content = reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials); break; } return $content; }
/** * Processes loading of this sample code through a web browser. * * @return void */ function runWWWVersion() { session_start(); // Note that all calls to endHTML() below end script execution! // Check to make sure that the user has set a password. $p = LOGIN_PASSWORD; if (empty($p)) { startHTML(false); displayPasswordNotSetNotice(); endHTML(); } // Grab any login credentials that might be waiting in the request if (!empty($_POST['password'])) { if ($_POST['password'] == LOGIN_PASSWORD) { $_SESSION['authenticated'] = 'true'; } else { // Invalid password. Stop and display a login screen. startHTML(false); requestUserLogin("Incorrect password."); endHTML(); } } // If the user isn't authenticated, display a login screen if (!isset($_SESSION['authenticated'])) { startHTML(false); requestUserLogin(); endHTML(); } // Try to login. If login fails, log the user out and display an // error message. try { $client = getClientLoginHttpClient(GAPPS_USERNAME . '@' . GAPPS_DOMAIN, GAPPS_PASSWORD); $gapps = new Zend_Gdata_Gapps($client, GAPPS_DOMAIN); } catch (Zend_Gdata_App_AuthException $e) { session_destroy(); startHTML(false); displayAuthenticationFailedNotice(); endHTML(); } // Success! We're logged in. // First we check for commands that can be submitted either though // POST or GET (they don't make any changes). if (!empty($_REQUEST['command'])) { switch ($_REQUEST['command']) { case 'retrieveUser': startHTML(); retrieveUser($gapps, true, $_REQUEST['user']); endHTML(true); case 'retrieveAllUsers': startHTML(); retrieveAllUsers($gapps, true); endHTML(true); case 'retrieveNickname': startHTML(); retrieveNickname($gapps, true, $_REQUEST['nickname']); endHTML(true); case 'retrieveNicknames': startHTML(); retrieveNicknames($gapps, true, $_REQUEST['user']); endHTML(true); case 'retrieveAllNicknames': startHTML(); retrieveAllNicknames($gapps, true); endHTML(true); case 'retrieveEmailLists': startHTML(); retrieveEmailLists($gapps, true, $_REQUEST['recipient']); endHTML(true); case 'retrieveAllEmailLists': startHTML(); retrieveAllEmailLists($gapps, true); endHTML(true); case 'retrieveAllRecipients': startHTML(); retrieveAllRecipients($gapps, true, $_REQUEST['emailList']); endHTML(true); } } // Now we handle the potentially destructive commands, which have to // be submitted by POST only. if (!empty($_POST['command'])) { switch ($_POST['command']) { case 'createUser': startHTML(); createUser($gapps, true, $_POST['user'], $_POST['givenName'], $_POST['familyName'], $_POST['pass']); endHTML(true); case 'updateUserName': startHTML(); updateUserName($gapps, true, $_POST['user'], $_POST['givenName'], $_POST['familyName']); endHTML(true); case 'updateUserPassword': startHTML(); updateUserPassword($gapps, true, $_POST['user'], $_POST['pass']); endHTML(true); case 'setUserSuspended': if ($_POST['mode'] == 'suspend') { startHTML(); suspendUser($gapps, true, $_POST['user']); endHTML(true); } elseif ($_POST['mode'] == 'restore') { startHTML(); restoreUser($gapps, true, $_POST['user']); endHTML(true); } else { header('HTTP/1.1 400 Bad Request'); startHTML(); echo "<h2>Invalid mode.</h2>\n"; echo "<p>Please check your request and try again.</p>"; endHTML(true); } case 'setUserAdmin': if ($_POST['mode'] == 'issue') { startHTML(); giveUserAdminRights($gapps, true, $_POST['user']); endHTML(true); } elseif ($_POST['mode'] == 'revoke') { startHTML(); revokeUserAdminRights($gapps, true, $_POST['user']); endHTML(true); } else { header('HTTP/1.1 400 Bad Request'); startHTML(); echo "<h2>Invalid mode.</h2>\n"; echo "<p>Please check your request and try again.</p>"; endHTML(true); } case 'setForceChangePassword': if ($_POST['mode'] == 'set') { startHTML(); setUserMustChangePassword($gapps, true, $_POST['user']); endHTML(true); } elseif ($_POST['mode'] == 'clear') { startHTML(); clearUserMustChangePassword($gapps, true, $_POST['user']); endHTML(true); } else { header('HTTP/1.1 400 Bad Request'); startHTML(); echo "<h2>Invalid mode.</h2>\n"; echo "<p>Please check your request and try again.</p>"; endHTML(true); } case 'deleteUser': startHTML(); deleteUser($gapps, true, $_POST['user']); endHTML(true); case 'createNickname': startHTML(); createNickname($gapps, true, $_POST['user'], $_POST['nickname']); endHTML(true); case 'deleteNickname': startHTML(); deleteNickname($gapps, true, $_POST['nickname']); endHTML(true); case 'createEmailList': startHTML(); createEmailList($gapps, true, $_POST['emailList']); endHTML(true); case 'deleteEmailList': startHTML(); deleteEmailList($gapps, true, $_POST['emailList']); endHTML(true); case 'modifySubscription': if ($_POST['mode'] == 'subscribe') { startHTML(); addRecipientToEmailList($gapps, true, $_POST['recipient'], $_POST['emailList']); endHTML(true); } elseif ($_POST['mode'] == 'unsubscribe') { startHTML(); removeRecipientFromEmailList($gapps, true, $_POST['recipient'], $_POST['emailList']); endHTML(true); } else { header('HTTP/1.1 400 Bad Request'); startHTML(); echo "<h2>Invalid mode.</h2>\n"; echo "<p>Please check your request and try again.</p>"; endHTML(true); } } } // Check for an invalid command. If so, display an error and exit. if (!empty($_REQUEST['command'])) { header('HTTP/1.1 400 Bad Request'); startHTML(); echo "<h2>Invalid command.</h2>\n"; echo "<p>Please check your request and try again.</p>"; endHTML(true); } // If a menu parameter is available, display a submenu. if (!empty($_REQUEST['menu'])) { switch ($_REQUEST['menu']) { case 'user': startHTML(); displayUserMenu(); endHTML(); case 'nickname': startHTML(); displayNicknameMenu(); endHTML(); case 'emailList': startHTML(); displayEmailListMenu(); endHTML(); case 'logout': startHTML(false); logout(); endHTML(); default: header('HTTP/1.1 400 Bad Request'); startHTML(); echo "<h2>Invalid menu selection.</h2>\n"; echo "<p>Please check your request and try again.</p>"; endHTML(true); } } // If we get this far, that means there's nothing to do. Display // the main menu. // If no command was issued and no menu was selected, display the // main menu. startHTML(); displayMenu(); endHTML(); }