00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 {
00004 header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005 echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006 echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007 exit(1);
00008 }
00016
00017
00018
00019 function isProfileFormCaptchaEnabled() {
00020 $captchaQuery = 'SELECT `form_usecaptcha` FROM `form_desc` WHERE `page_modulecomponentid` = 0';
00021 $captchaResult = mysql_query($captchaQuery);
00022 $captchaRow = mysql_fetch_row($captchaResult);
00023 if($captchaRow && isset($captchaRow[0])) {
00024 return $captchaRow[0] == 1;
00025 }
00026 return false;
00027 }
00028
00029 function profile($userId, $forEditRegistrant = false) {
00030 global $sourceFolder, $moduleFolder;
00031
00032
00033 if(isset($_POST['profileimgaction']) && $_POST['profileimgaction']=='uploadnew')
00034 {
00035 require_once("$sourceFolder/upload.lib.php");
00036
00037 $allowableTypes = array (
00038 'jpeg',
00039 'jpg',
00040 'png',
00041 'gif'
00042 );
00043 $fakeModuleComponentId=$userId;
00044 $uploadSuccess = submitFileUploadForm($fakeModuleComponentId, "profile", $userId, 512*1024, $allowableTypes, 'profileimage');
00045
00046 if(!is_array($uploadSuccess) && $uploadSuccess===false) displayerror("Profile image could not be uploaded. Maximum size should be 512 KB.");
00047 else if(is_array($uploadSuccess))
00048 {
00049
00050 $profileimgnames = getUploadedFiles($fakeModuleComponentId,'profile');
00051
00052 foreach($profileimgnames as $img)
00053 {
00054 if($img['upload_filename']!=$uploadSuccess[0])
00055 deleteFile($fakeModuleComponentId,'profile',$img['upload_filename']);
00056 }
00057 }
00058 }
00059 else if(isset($_POST['profileimgaction']) && $_POST['profileimgaction']=='noimage')
00060 {
00061 require_once("$sourceFolder/upload.lib.php");
00062 $fakeModuleComponentId=$userId;
00063 $profileimgnames = getUploadedFiles($fakeModuleComponentId,'profile');
00064
00065 foreach($profileimgnames as $img)
00066 deleteFile($fakeModuleComponentId,'profile',$img['upload_filename']);
00067 }
00068
00070 $profileQuery = 'SELECT `user_name`, `user_fullname`, `user_password` FROM `' . MYSQL_DATABASE_PREFIX . 'users` WHERE `user_id` = ' . $userId;
00071 $profileResult = mysql_query($profileQuery);
00072 if(!$profileResult) {
00073 displayerror('An error occurred while trying to process your request.<br />' . mysql_error() . '<br />' . $profileQuery);
00074 return '';
00075 }
00076 $profileRow = mysql_fetch_row($profileResult);
00077 $newUserName = $userName = $profileRow[0];
00078 $newUserFullname = $userFullname = $profileRow[1];
00079 $userPassword = $profileRow[2];
00080
00081 require_once("$sourceFolder/$moduleFolder/form/registrationformsubmit.php");
00082 require_once("$sourceFolder/$moduleFolder/form/registrationformgenerate.php");
00084 if(isset($_POST['btnSubmitProfile'])) {
00085 if($forEditRegistrant || !isProfileFormCaptchaEnabled() || submitCaptcha()) {
00086 if(!$forEditRegistrant) {
00087 $passwordValidated = false;
00088 if(isset($_POST['user_password']) && $_POST['user_password'] != '' && md5($_POST['user_password']) == $userPassword) {
00089 $passwordValidated = true;
00090 }
00091 }
00092
00093 $updates = array();
00094
00095 if (isset($_POST['user_name']) && $_POST['user_name'] != '' && $_POST['user_name'] != $userName) {
00096 $updates[] = "`user_name` = '".escape($_POST['user_name'])."'";
00097 $newUserName = escape($_POST['user_name']);
00098 }
00099 if (isset($_POST['user_fullname']) && $_POST['user_fullname'] != '' && $_POST['user_fullname'] != $userFullname) {
00100 $updates[] = "`user_fullname` = '".escape($_POST['user_fullname'])."'";
00101 $newUserFullname = escape($_POST['user_fullname']);
00102 }
00103 $errors = true;
00104 if (!$forEditRegistrant && $_POST['user_newpassword'] != '') {
00105 if(!$passwordValidated) {
00106 displayerror('Error! The current password you entered was incorrect.');
00107 }
00108 elseif ($_POST['user_newpassword'] != $_POST['user_newrepassword']) {
00109 displayerror('Error! The New Password you entered does not match the password you typed in the Confirmation Box.');
00110 }
00111 elseif ($_POST['user_newpassword'] == $_POST['user_password']) {
00112 displayerror('Error! The old and new passwords are the same.');
00113 }
00114 else {
00115 $updates[] = "`user_password` = MD5('".escape($_POST['user_newpassword'])."')";
00116 $errors = false;
00117 }
00118 }
00119 else {
00120 $errors = false;
00121 }
00122
00123 if(count($updates) > 0) {
00124 $profileQuery = 'UPDATE `' . MYSQL_DATABASE_PREFIX . 'users` SET ' . join($updates, ', ') . " WHERE `user_id` = $userId";
00125 $profileResult = mysql_query($profileQuery);
00126 if(!$profileResult) {
00127 displayerror('An error was encountered while attempting to process your request.');
00128 $errors = true;
00129 }
00130 $userName = $newUserName;
00131 $userFullname = $newUserFullname;
00132
00133 if(!$forEditRegistrant)
00134 setAuth($userId);
00135 }
00136
00137 $errors = !submitRegistrationForm(0, $userId, true, true) || $errors;
00138 if(!$errors) {
00139 displayinfo('All fields updated successfully!<br />' .
00140 '<input type="button" onclick="history.go(-2)" value="Go back" />');
00141 }
00142 }
00143 }
00144 return getProfileForm($userId, $userName, $userFullname, $forEditRegistrant);
00145 }
00146
00147
00148 function getProfileForm($userId, $userName, $userFullname, $forEditRegistrant = false) {
00149 global $urlRequestRoot, $moduleFolder, $cmsFolder,$sourceFolder, $templateFolder;
00150 require_once("$sourceFolder/$moduleFolder/form/registrationformsubmit.php");
00151 require_once("$sourceFolder/$moduleFolder/form/registrationformgenerate.php");
00152 require_once("$sourceFolder/upload.lib.php");
00153
00154 $fakeModuleComponentId=$userId;
00155
00156 $profileimgname = getUploadedFiles($fakeModuleComponentId,'profile');
00157 if($profileimgname==NULL)
00158 {
00159 $profileimgname = "$urlRequestRoot/$cmsFolder/$templateFolder/common/images/no-img.jpg";
00160 }
00161 else
00162 {
00163 $profileimgname = "./+profile&fileget={$profileimgname[0]['upload_filename']}";
00164 }
00165
00166
00167 $profileimg= "<img id=profileimg src='$profileimgname' alt='Profile Image' title='Profile Image' height=120 width=100><br/>";
00168
00169 $profileimgupload = getFileUploadField('profileimage','profile',512*1024);
00170
00171 $jsValidationFunctions = array();
00172 $containsFileUploadFields = false;
00173 $dynamicFields = getFormElementsHtmlAsArray(0, $userId, $jsValidationFunctions, $containsFileUploadFields);
00174 $dynamicFields = join($dynamicFields, "</tr>\n<tr>");
00175 if($dynamicFields != '') {
00176 $dynamicFields = "<tr>$dynamicFields</tr>";
00177 }
00178 $jsValidationFunctions = join($jsValidationFunctions, ' && ');
00179
00180 $captchaValidation = '';
00181 if(!$forEditRegistrant) {
00182 $captchaQuery = 'SELECT `form_usecaptcha` FROM `form_desc` WHERE `page_modulecomponentid` = 0';
00183 $captchaResult = mysql_query($captchaQuery);
00184 $captchaRow = mysql_fetch_row($captchaResult);
00185 if(isset($captchaRow[0]) && $captchaRow[0] == 1) {
00186 $captchaValidation = getCaptchaHtml();
00187 }
00188 }
00189
00190 $fValidatorPath = "$urlRequestRoot/$cmsFolder/$templateFolder/common/scripts/formValidator.js";
00191 $ValidatorPath = "$urlRequestRoot/$cmsFolder/$moduleFolder/form/validation.js";
00192 $calpath = "$urlRequestRoot/$cmsFolder/$moduleFolder";
00193 $formAction = './+profile';
00194 if($forEditRegistrant) {
00195 $formAction = './+admin&subaction=editsiteregistrants&subsubaction=editregistrant';
00196 }
00197 global $ICONS;
00198 global $STARTSCRIPTS;
00199 $STARTSCRIPTS.="document.getElementsByName('profileimage[]')[0].disabled=true;";
00200 $profileForm =<<<PREF
00201
00202 <script language="javscript" type="text/javascript" src="$ValidatorPath"></script>
00203 <script language="javascript" type="text/javascript" src="$fValidatorPath"></script>
00204 <link rel="stylesheet" type="text/css" media="all" href="$calpath/form/calendar/calendar.css" title="Aqua" />
00205 <script language="javascript" type="text/javascript" src="$calpath/form/calendar/calendar.js"></script>
00206 <script language="javascript" type="text/javascript">
00207 window.addEvent("domready", function() {
00208 var exValidatorA = new fValidator("registrationform");
00209 });
00210
00211 function checkPassword(inputhandler) {
00212 inputhandler2=document.getElementById("user_newpassword");
00213 if(inputhandler.value!=inputhandler2.value) {
00214 alert("The password you typed in the New Password field does not match the one in the Confirmation Box.");
00215 inputhandler.value="";
00216 inputhandler2.value="";
00217 inputhandler2.focus();
00218 return false;
00219 }
00220 return true;
00221 }
00222
00223 function checkProfileForm(inputhandler) {
00224 if(inputhandler.user_newpassword.value.length!=0) {
00225 if(inputhandler.user_password.value.length==0) {
00226 alert("Please enter your current password in order to change to a new one.");
00227 return false;
00228 }
00229 }
00230
00231 if(checkPassword(inputhandler.user_newrepassword)==false)
00232 return false;
00233
00234 return $jsValidationFunctions;
00235 }
00236
00237 function toggle_img_upform()
00238 {
00239 var obj1=document.getElementsByName('profileimage[]')[0];
00240 var obj2=document.getElementById('upnewradio');
00241 obj1.disabled=(obj2.checked==true?false:true);
00242 }
00243
00244
00245 </script>
00246 <div class="cms-registrationform">
00247 <form id="cms-registrationform" class="fValidator-form" method="POST" name="user_profile_usrFrm" onsubmit="return checkProfileForm(this)" action="$formAction" enctype="multipart/form-data">
00248 <fieldset style="width:80%">
00249 <legend>{$ICONS['User Profile']['small']}Profile Preferences</legend>
00250
00251 <table>
00252 <tr>
00253 <td colspan=2 style="text-align:center">$profileimg</td>
00254 </tr>
00255 <tr>
00256 <td><label for="user_name" class="labelrequired">Name</label></td>
00257 <td><input name="user_name" id="user_name" class="fValidate['required']" type="text" value="$userName"></td>
00258 </tr>
00259 <tr>
00260 <td><label for="user_fullname" class="labelrequired">Full Name</label></td>
00261 <td><input name="user_fullname" id="user_fullname" class="fValidate['required']" type="text" value="$userFullname"></td>
00262 </tr>
00263 <tr>
00264 <td>Profile image</td>
00265 <td>
00266 <input type="radio" name="profileimgaction" value="usecurrent" checked onclick="toggle_img_upform()"> Use existing image<br/>
00267 <input id='upnewradio' type="radio" name="profileimgaction" value="uploadnew" onclick="toggle_img_upform()"> Upload new image<br/>
00268 <input type="radio" name="profileimgaction" value="noimage" onclick="toggle_img_upform()"> Remove your image
00269 </td>
00270 <tr>
00271 <td><label for="profileimage">Upload new profile image (maximum size is 512 KB)</td>
00272 <td>$profileimgupload</td>
00273 </tr>
00274 PREF;
00275
00276 if(!$forEditRegistrant) {
00277 $profileForm .= <<<PREF
00278 <tr>
00279 <td><label for="user_password" class="labelrequired">Current Password (Only for changing password)</label></td>
00280 <td><input name="user_password" id="user_password" class="" type="password"></td>
00281 </tr>
00282 <tr>
00283 <td><label for="user_newpassword" class="labelrequired">New Password</label></td>
00284 <td> <input name="user_newpassword" id="user_newpassword" class="fValidate['']" type="password"></td>
00285 </tr>
00286 <tr> <td><label for="user_newrepassword" class="labelrequired">Re-enter New Password</label></td>
00287 <td> <input name="user_newrepassword" id="user_newrepassword" class="fValidate['=user_newpassword']" type="password"></td>
00288 </tr>
00289 PREF;
00290
00291 }
00292
00293 $profileForm .= <<<PREF
00294 $dynamicFields
00295 $captchaValidation
00296 <tr>
00297 <td colspan="2"> </td>
00298 </tr>
00299 <tr>
00300 <td><input type="submit" name="btnSubmitProfile" id="submitbutton" value="Save Profile"></td>
00301 <td></td>
00302 </tr>
00303 </table>
00304 PREF;
00305
00306 if($forEditRegistrant) {
00307 $profileForm .= '<input type="hidden" name="useremail" value="'.getUserEmail($userId).'" />';
00308 }
00309
00310 $profileForm .= <<<PREF
00311 </fieldset>
00312 </form>
00313 </div>
00314 PREF;
00315
00316
00317 return $profileForm . getProfileForms($userId).getProfileGroupsAndFormsList($userId).getFormDeadlines($userId);
00318 }
00319
00320
00321 function getProfileFormEditForm() {
00322 global $sourceFolder, $moduleFolder;
00323 $moduleComponentId = 0;
00324
00325 require_once("$sourceFolder/$moduleFolder/form/editformelement.php");
00326 require_once("$sourceFolder/$moduleFolder/form/editform.php");
00327
00331 if (isset($_GET['subaction'])) {
00332 $subAction = escape($_GET['subaction']);
00333 require_once("$sourceFolder/$moduleFolder/form/editformelement.php");
00334
00335 if (
00336 $_GET['subaction'] == 'editformelement' &&
00337 isset($_POST['elementid']) && ctype_digit($_POST['elementid']) &&
00338 isset($_POST['txtElementDesc']) && isset($_POST['selElementType']) &&
00339 isset($_POST['txtToolTip']) && isset($_POST['txtElementName'])
00340 ) {
00341 submitEditFormElementDescData($moduleComponentId, escape($_POST['elementid']));
00342 }
00343 elseif ( isset($_GET['elementid']) && ctype_digit($_GET['elementid']) ) {
00344 if ($_GET['subaction'] == 'editformelement') {
00345 return generateEditFormElementDescBody($moduleComponentId, escape($_GET['elementid']), 'admin&subsubaction=editprofileform');
00346 }
00347 elseif ($_GET['subaction'] == 'deleteformelement') {
00348 deleteFormElement($moduleComponentId, escape($_GET['elementid']));
00349 }
00350 elseif ($_GET['subaction'] == 'moveUp' || $_GET['subaction'] == 'moveDown') {
00351 moveFormElement($moduleComponentId, escape($_GET['subaction']), escape($_GET['elementid']));
00352 }
00353 }
00354 }
00355 if (isset($_POST['addformelement_descsubmit'])) {
00356 addDefaultFormElement($moduleComponentId);
00357 }
00358
00359 return generateFormElementDescBody($moduleComponentId, 'admin&subsubaction=editprofileform');
00360 }
00361
00362
00363 function deleteUserAccount($userId) {
00365 displayinfo('To be implemented');
00366 }
00367
00368 function getProfileViewRegistrantsForm() {
00369 if(isset($_GET['subsubaction'])) {
00370 if($_GET['subsubaction'] == 'editregistrant' && (isset($_GET['useremail']) || isset($_POST['useremail']))) {
00371 $email = isset($_GET['useremail']) ? escape($_GET['useremail']) : escape($_POST['useremail']);
00372 return profile(getUserIdFromEmail($email), true);
00373 }
00374 elseif($_GET['subsubaction'] == 'deleteregistrant' && isset($_GET['useremail'])) {
00375 deleteUserAccount(getUserIdFromEmail(escape($_GET['useremail'])));
00376 }
00377 }
00378
00379 return getProfileRegistrantsList($_GET['subaction'] == 'editsiteregistrants');
00380 }
00381
00382
00383 function getProfileRegistrantsList($showEditButtons = false) {
00384 global $urlRequestRoot, $cmsFolder, $moduleFolder, $templateFolder,$sourceFolder;
00385 require_once("$sourceFolder/$moduleFolder/form/viewregistrants.php");
00386
00387 $sortField = 'useremail';
00388 $sortOrder = 'asc';
00389 if(isset($_GET['sortfield'])) {
00390 $sortField = escape($_GET['sortfield']);
00391 }
00392 if(isset($_GET['sortorder']) && ($_GET['sortorder'] == 'asc' || $_GET['sortorder'] == 'desc')) {
00393 $sortOrder = escape($_GET['sortorder']);
00394 }
00395
00396 $action = './+admin&subaction=' . escape($_GET['subaction']);
00397
00398 $columnList['useremail'] = 'User Email';
00399 $columnList['username'] = 'Username';
00400 $columnList['userfullname'] = 'User Full Name';
00401 $columnList['registrationdate'] = 'Registration Date';
00402 $columnList['lastupdated'] = 'Last Updated';
00403
00404 $columnList = array_merge($columnList, getColumnList(0, false, false, false, false));
00405
00406 $normalImage = "<img alt=\"Sort by this field\" height=\"12\" width=\"12\" style=\"padding:0px\" src=\"$urlRequestRoot/$cmsFolder/$templateFolder/common/icons/16x16/actions/view-refresh.png\" />";
00407 $orderedImage = "<img alt=\"Sort by this field\" height=\"12\" width=\"12\" style=\"padding:0px\" src=\"$urlRequestRoot/$cmsFolder/$templateFolder/common/icons/16x16/actions/go-" . ($sortOrder == 'asc' ? 'up' : 'down') . ".png\" />";
00408
00409 $tableCaptions = "<tr>\n<th nowrap=\"nowrap\">S. No.</th>\n";
00410 if($showEditButtons) {
00411 $tableCaptions .= '<th nowrap="nowrap">Edit</th><th nowrap="nowrap">Delete</th>';
00412 }
00413 foreach($columnList as $columnName => $columnTitle) {
00414 $tableCaptions .= "<th nowrap=\"nowrap\">$columnTitle<a href=\"$action&sortfield=$columnName";
00415 if($sortField == $columnName) {
00416 $tableCaptions .= '&sortorder=' . ($sortOrder == 'asc' ? 'desc' : 'asc') . '">'.$orderedImage.'</a>';
00417 }
00418 else {
00419 $tableCaptions .= '">' . $normalImage. '</a>' ;
00420 }
00421 $tableCaptions .= "</th>\n";
00422 $columnNames[] = $columnName;
00423 }
00424 $tableCaptions .= "</tr>\n";
00425
00426 $userIds = getDistinctRegistrants(0, $sortField, $sortOrder);
00427 $userCount = count($userIds);
00428
00429 $editImage = "<img style=\"padding:0px\" src=\"$urlRequestRoot/$cmsFolder/$templateFolder/common/icons/16x16/apps/accessories-text-editor.png\" alt=\"Edit\" />";
00430 $deleteImage = "<img style=\"padding:0px\" src=\"$urlRequestRoot/$cmsFolder/$templateFolder/common/icons/16x16/actions/edit-delete.png\" alt=\"Delete\" />";
00431
00432 $tableBody = '';
00433 for($i = 0; $i < $userCount; $i++) {
00434 $tableBody .= '<tr><td>'.($i + 1).'</td>';
00435 if($showEditButtons) {
00436 $tableBody .= '<td align="center"><a href="./+admin&subaction=editsiteregistrants&subsubaction=editregistrant&useremail='.getUserEmail($userIds[$i]).'" />' . $editImage . '</a></td>';
00437 $tableBody .= '<td align="center"><a href="./+admin&subaction=editsiteregistrants&subsubaction=deleteregistrant&useremail='.getUserEmail($userIds[$i]).'" />' . $deleteImage . '</a></td>';
00438 }
00439 $tableBody .= '<td>' . join(generateFormDataRow(0, $userIds[$i], $columnNames), '</td><td>') . "</td></tr>\n";
00440 }
00441
00442 return '<br /><br /><br /><table border="1">' . $tableCaptions . $tableBody . '</table>';
00443 }
00444
00445 function getProfileForms($userId) {
00446 global $ICONS,$urlRequestRoot;
00447 $regforms ="<fieldset style=\"padding: 8px\"><legend>{$ICONS['User Groups']['small']}Forms I Have Registered To</legend>";
00448 $regforms .= '<ol>';
00449 $query = "SELECT DISTINCT `page_modulecomponentid` FROM `form_elementdata` WHERE `user_id` = $userId";
00450 $result2 = mysql_query($query);
00451 while($result = mysql_fetch_row($result2)) {
00452 if($result[0]!=0){
00453 $formPath = getPagePath(getPageIdFromModuleComponentId('form', $result[0]));
00454 $formPathLink = $urlRequestRoot . $formPath;
00455 $query1 = "SELECT `form_heading` FROM `form_desc` WHERE `page_modulecomponentid` =". $result[0];
00456 $result1 = mysql_query($query1);
00457 $result1 = mysql_fetch_row($result1);
00458 $regforms .= '<li> <a href="'.$formPathLink.'">'.$result1[0].'</a></li>';
00459 }
00460 }
00461 $regforms .= '</ol></fieldset> ';
00462 return $regforms;
00463 }
00464 function getFormDeadlines($userId) {
00465 global $ICONS,$urlRequestRoot;
00466 $regforms ="<fieldset style=\"padding: 8px\"><legend>{$ICONS['User Groups']['small']}Forms Nearing Deadline</legend>";
00467 $regforms .= '<ol>';
00468 $query = "SELECT * FROM `".MYSQL_DATABASE_PREFIX."global`";
00469 $result = mysql_query($query);
00470 while($res = mysql_fetch_row($result)) {
00471 if($res[0] == 'deadline_notify')
00472 {
00473 $deadline = $res[1] * 24 * 3600;
00474 }
00475
00476 }
00477 $query = "SELECT DISTINCT `page_modulecomponentid` FROM `form_desc` WHERE HOUR(TIMEDIFF(`form_expirydatetime`,NOW( )))*3600+MINUTE(TIMEDIFF(`form_expirydatetime`,NOW( )))*60+SECOND(TIMEDIFF(`form_expirydatetime`,NOW( )))*60 <= ".$deadline;
00478 $result2 = mysql_query($query);
00479 while($result = mysql_fetch_row($result2)) {
00480 if($result[0]!=0){
00481 $formPath = getPagePath(getPageIdFromModuleComponentId('form', $result[0]));
00482 $formPathLink = $urlRequestRoot . $formPath;
00483 $query1 = "SELECT `form_heading` FROM `form_desc` WHERE `page_modulecomponentid` =". $result[0];
00484 $result1 = mysql_query($query1);
00485 $result1 = mysql_fetch_row($result1);
00486 $regforms .= '<li> <a href="'.$formPathLink.'">'.$result1[0].'</a></li>';
00487 }
00488 }
00489 $regforms .= '</ol></fieldset> ';
00490 return $regforms;
00491 }
00492 function getProfileGroupsAndFormsList($userId) {
00493 global $sourceFolder;
00494 require_once("$sourceFolder/group.lib.php");
00495
00496 $groupRows = getGroupsFromUserId($userId);
00497 $groupRowsCount = count($groupRows);
00498
00499 $associatedGroups = array();
00500 $unassociatedGroups = array();
00501
00502 for($i = 0; $i < $groupRowsCount; $i++) {
00503 if($groupRows[$i]['form_id'] == 0) {
00504 $unassociatedGroups[] = '<tr><td>' . $groupRows[$i]['group_name'] . '</td><td>' . $groupRows[$i]['group_description'] . '</td></tr>';
00505 }
00506 else {
00507 $formPath = getPagePath(getPageIdFromModuleComponentId('form', $groupRows[$i]['form_id']));
00508 global $urlRequestRoot;
00509 $formPathLink = $urlRequestRoot . $formPath;
00510 $associatedGroups[] = '<tr><td><a href="' . $formPathLink . '">' . $formPath . '</a></td><td>' . $groupRows[$i]['group_name'] . '</td><td><a href="' . $formPathLink . '&subaction=unregister" onclick="return confirm(\'Are you sure you wish to unregister from this form?\')">Unregister</a></td></tr>';
00511 }
00512 }
00513
00514 if(count($associatedGroups) == 0 && count($unassociatedGroups) == 0)
00515 return false;
00516 global $ICONS;
00517 $retVal = "<fieldset style=\"padding: 8px\"><legend>{$ICONS['User Groups']['small']}Groups I Belong To</legend>";
00518 if(count($associatedGroups) > 0) {
00519 $retVal .= '<strong>Groups associated with forms:</strong><br /><br /><table style="margin-left: 8px" border="1" cellpadding="4px" cellspacing="4px">' .
00520 '<tr><th>Form Path</th><th>Group Name</th><th>Unregister</th></tr>' .
00521 implode("\n", $associatedGroups) . '</table><br /><br />';
00522 }
00523 if(count($unassociatedGroups) > 0) {
00524 $retVal .= '<strong>Groups not associated with any form:</strong><br /><table style="margin-left: 8px" border="1" cellpadding="4px" cellspacing="4px">' . '<tr><th>Group Name</th><th>Group Description</th></tr>' . implode("\n", $unassociatedGroups) . '</table><br />';
00525 }
00526 $retVal .= '</fieldset>';
00527 return $retVal;
00528 }
00529
00530 function getProfileNewsletterList($userId) {
00531 $retVal = '<fieldset style="padding: 8px"><legend>My Newsletters</legend>';
00532 global $urlRequestRoot, $cmsFolder, $sourceFolder, $moduleFolder, $templateFolder;
00533 include_once("$sourceFolder/$moduleFolder/newsletter.lib.php");
00534 $subscribableLists = newsletter::getSubscribableLists($userId);
00535 $subscribedLists = '';
00536 $unsubscribedLists = '';
00537
00538 for ($i = 0; $i < count($subscribableLists); ++$i) {
00539 if ($subscribableLists[$i][2] === true)
00540 $subscribedLists .= '<span class="newsletterlistitem"><a href="' . $subscribableLists[$i][1] . '" />' . $subscribableLists[$i][0] . '</a></span>';
00541 else
00542 $unsubscribedLists .= '<span class="newsletterlistitem"><a href="' . $subscribableLists[$i][1] . '" />' . $subscribableLists[$i][0] . '</a></span>';
00543 }
00544
00545 $imageDir = "$urlRequestRoot/$cmsFolder/$templateFolder/common/icons/16x16/actions/";
00546 $retVal .= '<table border="0" cellpadding="4" cellspacing="4"><tr><th>Available Lists</th><th></th><th>Lists I\'ve subscribed to</th><tr><td width="45%">';
00547 $retVal .= '<span class="newsletterlist" style="float: left" id="unsubscribedLists">' . $unsubscribedLists . '</span>';
00548 $retVal .= '</td><td style="vertical-align: center; text-align: center"><img src="' . $imageDir .'go-next.gif" /><br /><br /><img src="' . $imageDir . 'go-previous.gif" /></td><td width="45%">';
00549 $retVal .= '<span class="newsletterlist" style="float: right" id="subscribedLists">' . $subscribedLists . '</span>';
00550 $retVal .= '</td></tr></table>';
00551 $retVal .= '</fieldset>';
00552
00553 return $retVal;
00554 }