Ejemplo n.º 1
0
function getProfileForm($userId, $userName, $userFullname, $forEditRegistrant = false)
{
    global $urlRequestRoot, $moduleFolder, $cmsFolder, $sourceFolder, $templateFolder;
    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php";
    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformgenerate.php";
    require_once "{$sourceFolder}/upload.lib.php";
    $fakeModuleComponentId = $userId;
    $profileimgname = getUploadedFiles($fakeModuleComponentId, 'profile');
    if ($profileimgname == NULL) {
        $profileimgname = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/images/no-img.jpg";
    } else {
        $profileimgname = "./+profile&fileget={$profileimgname[0]['upload_filename']}";
    }
    $profileimg = "<img id=profileimg src='{$profileimgname}' alt='Profile Image' title='Profile Image' height=120 width=100><br/>";
    $profileimgupload = getFileUploadField('profileimage', 'profile', 512 * 1024);
    $jsValidationFunctions = array();
    $containsFileUploadFields = false;
    $dynamicFields = getFormElementsHtmlAsArray(0, $userId, $jsValidationFunctions, $containsFileUploadFields);
    $dynamicFields = join($dynamicFields, "</tr>\n<tr>");
    if ($dynamicFields != '') {
        $dynamicFields = "<tr>{$dynamicFields}</tr>";
    }
    $jsValidationFunctions = join($jsValidationFunctions, ' && ');
    $captchaValidation = '';
    if (!$forEditRegistrant) {
        $captchaQuery = 'SELECT `form_usecaptcha` FROM `form_desc` WHERE `page_modulecomponentid` = 0';
        $captchaResult = mysql_query($captchaQuery);
        $captchaRow = mysql_fetch_row($captchaResult);
        if (isset($captchaRow[0]) && $captchaRow[0] == 1) {
            $captchaValidation = getCaptchaHtml();
        }
    }
    $fValidatorPath = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/scripts/formValidator.js";
    $ValidatorPath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/form/validation.js";
    $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}";
    $formAction = './+profile';
    if ($forEditRegistrant) {
        $formAction = './+admin&subaction=editsiteregistrants&subsubaction=editregistrant';
    }
    global $ICONS;
    global $STARTSCRIPTS;
    $STARTSCRIPTS .= "document.getElementsByName('profileimage[]')[0].disabled=true;";
    $profileForm = <<<PREF

<script language="javscript" type="text/javascript" src="{$ValidatorPath}"></script>
<script language="javascript" type="text/javascript" src="{$fValidatorPath}"></script>
<link rel="stylesheet" type="text/css" media="all" href="{$calpath}/form/calendar/calendar.css" title="Aqua" />
<script language="javascript" type="text/javascript" src="{$calpath}/form/calendar/calendar.js"></script>
<script language="javascript" type="text/javascript">
\twindow.addEvent("domready", function() {
\t\tvar exValidatorA = new fValidator("registrationform");
\t});

\tfunction checkPassword(inputhandler) {
\t\tinputhandler2=document.getElementById("user_newpassword");
\t\tif(inputhandler.value!=inputhandler2.value)\t{
\t\t\talert("The password you typed in the New Password field does not match the one in the Confirmation Box.");
\t\t\tinputhandler.value="";
\t\t\tinputhandler2.value="";
\t\t\tinputhandler2.focus();
\t\t\treturn false;
\t\t}
\t\treturn true;
\t}

\tfunction checkProfileForm(inputhandler) {
\t\tif(inputhandler.user_newpassword.value.length!=0) {
\t\t\tif(inputhandler.user_password.value.length==0) {
\t\t\t\talert("Please enter your current password in order to change to a new one.");
\t\t\t\treturn false;
\t\t\t}
\t\t}

\t\tif(checkPassword(inputhandler.user_newrepassword)==false)
\t\t\treturn false;

\t\treturn {$jsValidationFunctions};
\t}
\t
\tfunction toggle_img_upform()
\t{
\t\tvar obj1=document.getElementsByName('profileimage[]')[0];
\t\tvar obj2=document.getElementById('upnewradio');
\t\tobj1.disabled=(obj2.checked==true?false:true); 
\t}
\t

</script>
<div class="cms-registrationform">
\t<form id="cms-registrationform" class="fValidator-form" method="POST" name="user_profile_usrFrm" onsubmit="return checkProfileForm(this)" action="{$formAction}" enctype="multipart/form-data">
\t\t<fieldset style="width:80%">
\t\t\t<legend>{$ICONS['User Profile']['small']}Profile Preferences</legend>

\t\t\t<table>
\t\t\t\t<tr>
\t\t\t\t<td colspan=2 style="text-align:center">{$profileimg}</td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_name" class="labelrequired">Name</label></td>
\t\t\t\t\t<td><input name="user_name" id="user_name" class="fValidate['required']" type="text" value="{$userName}"></td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_fullname" class="labelrequired">Full Name</label></td>
\t\t\t\t\t<td><input name="user_fullname" id="user_fullname" class="fValidate['required']" type="text" value="{$userFullname}"></td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td>Profile image</td>
\t\t\t\t\t<td>
\t\t\t\t\t<input type="radio" name="profileimgaction" value="usecurrent" checked onclick="toggle_img_upform()"> Use existing image<br/>
\t\t\t\t\t<input id='upnewradio' type="radio" name="profileimgaction" value="uploadnew" onclick="toggle_img_upform()"> Upload new image<br/>
\t\t\t\t\t<input type="radio" name="profileimgaction" value="noimage" onclick="toggle_img_upform()"> Remove your image
\t\t\t\t\t</td>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="profileimage">Upload new profile image (maximum size is 512 KB)</td>
\t\t\t\t\t<td>{$profileimgupload}</td>
\t\t\t\t</tr>
PREF;
    if (!$forEditRegistrant) {
        $profileForm .= <<<PREF
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_password" class="labelrequired">Current Password (Only for changing password)</label></td>
\t\t\t\t\t<td><input name="user_password" id="user_password" class="" type="password"></td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_newpassword" class="labelrequired">New Password</label></td>
\t\t\t\t\t<td>  <input name="user_newpassword" id="user_newpassword" class="fValidate['']" type="password"></td>
\t\t\t\t</tr>
\t\t\t\t<tr> <td><label for="user_newrepassword" class="labelrequired">Re-enter New Password</label></td>
\t\t\t\t\t<td> <input name="user_newrepassword" id="user_newrepassword" class="fValidate['=user_newpassword']" type="password"></td>
\t\t\t\t</tr>
PREF;
    }
    $profileForm .= <<<PREF
\t\t\t\t\t{$dynamicFields}
\t\t\t\t\t{$captchaValidation}
\t\t\t\t<tr>
\t\t\t\t\t<td colspan="2">&nbsp;</td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><input type="submit" name="btnSubmitProfile" id="submitbutton" value="Save Profile"></td>
\t\t\t\t\t<td></td>
\t\t\t\t</tr>
\t\t\t</table>
PREF;
    if ($forEditRegistrant) {
        $profileForm .= '<input type="hidden" name="useremail" value="' . getUserEmail($userId) . '" />';
    }
    $profileForm .= <<<PREF
\t\t</fieldset>
\t</form>
</div>
PREF;
    // TODO: implement getProfileNewsletterList completely. return $profileForm . getProfileGroupsAndFormsList($userId) . getProfileNewsletterList($userId);
    return $profileForm . getProfileForms($userId) . getProfileGroupsAndFormsList($userId) . getFormDeadlines($userId);
}
Ejemplo n.º 2
0
/**
 * @package pragyan
 * @author Boopathi Rajaa, balanivash
 * @copyright (c) 2011 Pragyan Team
 * @license http://www.gnu.org/licenses/ GNU Public License
 * For more details, see README
 */
function generatePublicProfile($userProfileId, $accessUserId)
{
    $userId = $userProfileId;
    global $urlRequestRoot, $moduleFolder, $cmsFolder, $sourceFolder, $templateFolder;
    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php";
    require_once "{$sourceFolder}/{$moduleFolder}/form/viewregistrants.php";
    require_once "{$sourceFolder}/upload.lib.php";
    require_once "{$sourceFolder}/profile.lib.php";
    $profileQuery = 'SELECT `user_name`, `user_fullname`, `user_email` FROM `' . MYSQL_DATABASE_PREFIX . 'users` WHERE `user_id` = \'' . $userId . "'";
    $profileResult = mysql_query($profileQuery);
    if (!$profileResult) {
        displayerror('An error occurred while trying to process your request.<br />' . mysql_error() . '<br />' . $profileQuery);
        return '';
    }
    if (mysql_num_rows($profileResult) == 0) {
        displayerror("The Requested user is not found.");
        return "Click <a href='" . $urlRequestRoot . "'>here </a> to return to the home page";
    }
    $profileRow = mysql_fetch_row($profileResult);
    $userName = $profileRow[0];
    $userFullname = $profileRow[1];
    $userEmail = $profileRow[2];
    $fakeModuleComponentId = $userId;
    $profileimgname = getUploadedFiles($fakeModuleComponentId, 'profile');
    if ($profileimgname == NULL) {
        $profileimgname = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/images/no-img.jpg";
    } else {
        $profileimgname = "./+profile&fileget={$profileimgname[0]['upload_filename']}&mcid={$userId}";
    }
    $profileimg = "<img id=profileimg src='{$profileimgname}' alt='Profile Image' title='Profile Image' height=120 width=100><br/>";
    $dynamicFields = getFormElementsHtmlAsArrayForView(0, $userId);
    $dynamicFields = join($dynamicFields, "</tr>\n<tr>");
    if ($dynamicFields != '') {
        $dynamicFields = "<tr>{$dynamicFields}</tr>";
    }
    global $ICONS;
    $profileForm = <<<PREF


<div class="cms-profile">
\t\t<fieldset>
\t\t\t<legend>{$ICONS['User Profile']['small']}  User Profile</legend>

\t\t\t<table style="width:75%;">
\t\t\t\t<tr>
\t\t\t\t<td colspan=2 style="text-align:center">{$profileimg}</td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_name" class="labelrequired">Name</label></td>
\t\t\t\t\t<td>{$userName}</td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_fullname" class="labelrequired">Full Name</label></td>
\t\t\t\t\t<td>{$userFullname}</td>
\t\t\t\t</tr>

\t\t\t\t\t{$dynamicFields}
PREF;
    if ($userId == $accessUserId) {
        $profileForm .= "<tr>\n\t\t\t\t\t<td colspan=2 style='text-align:center'><a href=./+profile>{$ICONS['Edit']['small']} Edit Profile</a></td>\n\t\t\t\t</tr>";
    }
    $profileForm .= <<<PREF
\t\t\t</table>
\t\t</fieldset>
\t</form>
</div>
PREF;
    return $profileForm . "<br />" . getProfileGroupsAndFormsList($userId);
}