/** * PrintEditForm * Prints a form to edit a user. If you pass in a userid, it will load up that user and print their information. If you pass in the details array, it will prefill the form with that information (eg if you tried to create a user with a duplicate username). Also checks whether you are allowed to edit this user. If you are not an admin, you are only allowed to edit your own account. * * @param Int $userid Userid to load up. * @param Array $details Details to prefill the form with (in case there was a problem creating the user). * * @see User_API::Admin * @see User_API::Status * @see User_API::ListAdmin * @see User_API::EditOwnSettings * @see GetUser * * @return Void Returns nothing. If you don't have access to edit a particular user, it prints an error message and exits. Otherwise it prints the correct form (either edit-own or edit) and then exits. */ function PrintEditForm($userid = 0, $details = array()) { $thisuser = IEM::getCurrentUser(); if (!$thisuser->UserAdmin()) { if ($userid != $thisuser->userid) { $this->DenyAccess(); } if (!$thisuser->EditOwnSettings()) { $this->DenyAccess(); } } $user = $this->GetApi('User'); $listapi = $this->GetApi('Lists'); $all_lists = $listapi->GetLists(0, array('SortBy' => 'name', 'Direction' => 'asc'), false, 0, 0); $segmentapi = $this->GetApi('Segment'); $all_segments = $segmentapi->GetSegments(array('SortBy' => 'segmentname', 'Direction' => 'asc'), false, 0, 'all'); $templateapi = $this->GetApi('Templates'); $all_templates = $templateapi->GetTemplates(0, array('SortBy' => 'name', 'Direction' => 'asc'), false, 0, 0); $all_groups = API_USERGROUPS::getRecords(false, false, 0, 0, 'groupname'); $GLOBALS['CustomSmtpServer_Display'] = '0'; $GLOBALS['XmlPath'] = SENDSTUDIO_APPLICATION_URL . '/xml.php'; if ($userid > 0) { $user = GetUser($userid); if ($user->Get('userid') <= 0) { $GLOBALS['ErrorMessage'] = GetLang('UserDoesntExist'); $this->DenyAccess(); return; } $GLOBALS['UserID'] = $user->Get('userid'); $GLOBALS['UserName'] = htmlspecialchars($user->Get('username'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['FullName'] = htmlspecialchars($user->Get('fullname'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['EmailAddress'] = htmlspecialchars($user->Get('emailaddress'), ENT_QUOTES, SENDSTUDIO_CHARSET); $activity = $user->GetEventActivityType(); if (!is_array($activity)) { $activity = array(); } $GLOBALS['EventActivityType'] = implode("\n", $activity); $GLOBALS['MaxLists'] = $user->group->limit_list; $GLOBALS['MaxEmails'] = $user->group->limit_totalemailslimit; $GLOBALS['PerMonth'] = $user->group->limit_emailspermonth; $GLOBALS['PerHour'] = $user->group->limit_hourlyemailsrate; $GLOBALS['DisplayMaxLists'] = ''; if ($user->Get('maxlists') == 0) { $GLOBALS['LimitListsChecked'] = ' CHECKED'; $GLOBALS['DisplayMaxLists'] = 'none'; } $GLOBALS['DisplayEmailsPerHour'] = ''; if ($user->Get('perhour') == 0) { $GLOBALS['LimitPerHourChecked'] = ' CHECKED'; $GLOBALS['DisplayEmailsPerHour'] = 'none'; } $GLOBALS['DisplayEmailsPerMonth'] = ''; if ($user->Get('permonth') == 0) { $GLOBALS['LimitPerMonthChecked'] = ' CHECKED'; $GLOBALS['DisplayEmailsPerMonth'] = 'none'; } $GLOBALS['LimitMaximumEmailsChecked'] = ' CHECKED'; $GLOBALS['DisplayEmailsMaxEmails'] = 'none'; if (!$user->hasUnlimitedCredit()) { $GLOBALS['LimitMaximumEmailsChecked'] = ''; $GLOBALS['DisplayEmailsMaxEmails'] = ''; } if ($user->Get('usewysiwyg')) { $GLOBALS['UseWysiwyg'] = ' CHECKED'; $GLOBALS['UseXHTMLDisplay'] = ' style="display:block;"'; } else { $GLOBALS['UseXHTMLDisplay'] = ' style="display:none;"'; } if ($user->Get('enableactivitylog')) { $GLOBALS['EnableActivityLog'] = ' CHECKED'; } else { $GLOBALS['EnableActivityLog'] = ''; } $GLOBALS['UseXHTMLCheckbox'] = $user->Get('usexhtml')? ' CHECKED' : ''; $GLOBALS['Xmlapi'] = $user->Get('xmlapi')? ' CHECKED' : ''; $GLOBALS['XMLTokenDisplay'] = ' style="display:none;"'; if ($user->Get('xmlapi')) { $GLOBALS['XMLTokenDisplay'] = ' style="display:block;"'; } $GLOBALS['XmlToken'] = htmlspecialchars($user->Get('xmltoken'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['TextFooter'] = $user->Get('textfooter'); $GLOBALS['HTMLFooter'] = $user->Get('htmlfooter'); $GLOBALS['SmtpServer'] = $user->Get('smtpserver'); $GLOBALS['SmtpUsername'] = $user->Get('smtpusername'); $GLOBALS['SmtpPassword'] = $user->Get('smtppassword'); $GLOBALS['SmtpPort'] = $user->Get('smtpport'); if ($GLOBALS['SmtpServer']) { $GLOBALS['CustomSmtpServer_Display'] = '1'; } $GLOBALS['googlecalendarusername'] = htmlspecialchars($user->Get('googlecalendarusername'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['googlecalendarpassword'] = htmlspecialchars($user->Get('googlecalendarpassword'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['FormAction'] = 'Action=Save&UserID=' . $user->userid; if (!$thisuser->UserAdmin()) { $smtp_access = $thisuser->HasAccess('User', 'SMTP'); $GLOBALS['ShowSMTPInfo'] = 'none'; $GLOBALS['DisplaySMTP'] = '0'; if ($smtp_access) { $GLOBALS['ShowSMTPInfo'] = ''; } if ($GLOBALS['SmtpServer']) { $GLOBALS['CustomSmtpServer_Display'] = '1'; if ($smtp_access) { $GLOBALS['DisplaySMTP'] = '1'; } } $this->ParseTemplate('User_Edit_Own'); return; } $GLOBALS['StatusChecked'] = ($user->Status()) ? ' CHECKED' : ''; $GLOBALS['ForceDoubleOptInChecked'] = ($user->Get('forcedoubleoptin')) ? ' CHECKED' : ''; $GLOBALS['ForceSpamCheckChecked'] = ($user->Get('forcespamcheck')) ? ' CHECKED' : ''; $GLOBALS['InfoTipsChecked'] = ($user->InfoTips()) ? ' CHECKED' : ''; $editown = ''; if ($user->UserAdmin()) { $editown = ' CHECKED'; } else { if ($user->EditOwnSettings()) { $editown = ' CHECKED'; } } $GLOBALS['EditOwnSettingsChecked'] = $editown; $timezone = $user->usertimezone; $GLOBALS['TimeZoneList'] = $this->TimeZoneList($timezone); $admintype = $user->AdminType(); $listadmintype = $user->ListAdminType(); $segmentadmintype = $user->SegmentAdminType(); $templateadmintype = $user->TemplateAdminType(); $admin = $user->Admin(); $listadmin = $user->ListAdmin(); $segmentadmin = $user->SegmentAdmin(); $templateadmin = $user->TemplateAdmin(); $permissions = $user->Get('permissions'); $area_access = $user->Get('access'); $GLOBALS['Heading'] = GetLang('EditUser'); $GLOBALS['Help_Heading'] = GetLang('Help_EditUser'); $GLOBALS['AdminNotifyEmailAddress'] = $user->Get('adminnotify_email'); if (empty($GLOBALS['AdminNotifyEmailAddress'])) { $GLOBALS['AdminNotifyEmailAddress'] = constant('SENDSTUDIO_EMAIL_ADDRESS'); } $GLOBALS['AdminNotifications_Send_Email'] = $user->Get('adminnotify_send_emailtext'); if (empty($GLOBALS['AdminNotifications_Send_Email'])) { $GLOBALS['AdminNotifications_Send_Email'] = GetLang('AdminNotifications_Send_Email'); } $GLOBALS['AdminNotifications_Import_Email'] = $user->Get('adminnotify_import_emailtext'); if (empty($GLOBALS['AdminNotifications_Import_Email'])) { $GLOBALS['AdminNotifications_Import_Email'] = GetLang('AdminNotifications_Import_Email'); } $GLOBALS['SendLimit'] = $user->Get('adminnotify_send_threshold'); $GLOBALS['ImportLimit'] = $user->Get('adminnotify_import_threshold'); if (empty($GLOBALS['SendLimit'])) { $GLOBALS['SendLimit'] = 1000; } if (empty($GLOBALS['ImportLimit'])) { $GLOBALS['ImportLimit'] = 1000; } $admin_flag = $user->Get('adminnotify_send_flag'); if ($user->Get('adminnotify_send_flag') == 1) { $GLOBALS['AdminNotificationsSend'] = 'CHECKED'; $GLOBALS['UseNotifySend'] = ''; } else { $GLOBALS['UseNotifySend'] = "style=display:none;"; } if ($user->Get('adminnotify_import_flag') == 1) { $GLOBALS['AdminNotificationsImport'] = 'CHECKED'; $GLOBALS['UseNotifyImport'] = ''; } else { $GLOBALS['UseNotifyImport'] = "style=display:none;"; } $GLOBALS['SmtpPort'] = $user->Get('smtpport'); // Log this to "User Activity Log" IEM::logUserActivity(IEM::urlFor('users', array('Action' => 'Edit', 'UserID' => $userid)), 'images/user.gif', $user->username); } else { $timezone = (isset($details['timezone'])) ? $details['timezone'] : SENDSTUDIO_SERVERTIMEZONE; $GLOBALS['TimeZoneList'] = $this->TimeZoneList($timezone); $activity = $thisuser->defaultEventActivityType; if (!is_array($activity)) { $activity = array(); } $GLOBALS['EventActivityType'] = implode("\n", $activity); $GLOBALS['FormAction'] = 'Action=Create'; if (!empty($details)) { foreach ($details as $area => $val) { $GLOBALS[$area] = $val; } } $GLOBALS['Heading'] = GetLang('CreateUser'); $GLOBALS['Help_Heading'] = GetLang('Help_CreateUser'); $listadmintype = 'c'; $segmentadmintype = 'c'; $admintype = 'c'; $templateadmintype = 'c'; $GLOBALS['DisplayMaxLists'] = 'none'; $GLOBALS['DisplayEmailsPerHour'] = 'none'; $GLOBALS['DisplayEmailsPerMonth'] = 'none'; $GLOBALS['DisplayEmailsMaxEmails'] = 'none'; $GLOBALS['MaxLists'] = '0'; $GLOBALS['PerHour'] = '0'; $GLOBALS['PerMonth'] = '0'; $GLOBALS['MaxEmails'] = '0'; $GLOBALS['StatusChecked'] = ' CHECKED'; $GLOBALS['ForceDoubleOptInChecked'] = ''; $GLOBALS['ForceSpamCheckChecked'] = ''; $GLOBALS['InfoTipsChecked'] = ' CHECKED'; $GLOBALS['EditOwnSettingsChecked'] = ' CHECKED'; $GLOBALS['LimitListsChecked'] = ' CHECKED'; $GLOBALS['LimitPerHourChecked'] = ' CHECKED'; $GLOBALS['LimitPerMonthChecked'] = ' CHECKED'; $GLOBALS['LimitMaximumEmailsChecked'] = ' CHECKED'; $GLOBALS['UseWysiwyg'] = ' CHECKED'; $GLOBALS['EnableLastViewed'] = ''; $GLOBALS['UseXHTMLCheckbox'] = ' CHECKED'; $GLOBALS['HTMLFooter'] = GetLang('Default_Global_HTML_Footer'); $GLOBALS['TextFooter'] = GetLang('Default_Global_Text_Footer'); $GLOBALS['EnableActivityLog'] = ' CHECKED'; $GLOBALS['Xmlapi'] = ''; $GLOBALS['XMLTokenDisplay'] = ' style="display:none;"'; $admin = $listadmin = $segmentadmin = $templateadmin = false; $permissions = array(); $area_access = array('lists' => array(), 'templates' => array(), 'segments' => array()); $GLOBALS['AdminNotifyEmailAddress'] = constant('SENDSTUDIO_EMAIL_ADDRESS'); $GLOBALS['UseNotifySend'] = "style=display:none;"; $GLOBALS['UseNotifyImport'] = "style=display:none;"; $GLOBALS['SendLimit'] = 1000; $GLOBALS['ImportLimit'] = 1000; $GLOBALS['AdminNotifications_Send_Email'] = GetLang('AdminNotifications_Send_Email'); $GLOBALS['AdminNotifications_Import_Email'] = GetLang('AdminNotifications_Import_Email'); } $agencyid = defined('IEM_SYSTEM_LICENSE_AGENCY') ? IEM_SYSTEM_LICENSE_AGENCY : ''; $available_users = $user->AvailableUsers(); $template = GetTemplateSystem(); $template->Assign('UserID', $user->userid); $template->Assign('groupid', $user->groupid); $template->Assign('canChangeUserGroup', !$user->isLastAdmin()); $template->Assign('AgencyEdition', get_agency_license_variables()); $template->Assign('EditOwn', ($user->userid != 0 && $user->userid == $thisuser->userid)); $template->Assign('TrialUser', $user->trialuser); $template->Assign('EditMode', !empty($user->userid)); $template->Assign('AvailableNormalUsers', isset($available_users['normal']) ? $available_users['normal'] : 0); $template->Assign('AvailableTrialUsers', isset($available_users['trial']) ? $available_users['trial'] : 0); $template->Assign('AvailableGroups', $all_groups); $template->Assign('record_groupid', $user->groupid); $template->Assign('DefaultIdTab', IEM::requestGetPOST('id_tab_num', 1, 'intval')); $template->Assign('showSmtpInfo', (bool) $user->smtpserver); $template->ParseTemplate('User_Form'); }
/** * This method will display a "manage user" page * * @return void * @todo phpdocs */ public function page_manageGroups() { // ----- Sanitize and declare variables that is going to be used in this function $pageRecordPP = 0; $pageCurrentIndex = $this->GetCurrentPage(); $pageSortInfo = $this->GetSortDetails(); $reqProcessPaging = IEM::requestGetGET('ProcessPaging', 0, 'intval'); $records = array(); $recordTotal = 0; $currentUser = IEM::getCurrentUser(); $page = array( 'messages' => GetFlashMessages(), 'currentuserid' => $currentUser->userid ); // ----- // Do we need to process paging? if ($reqProcessPaging) { $temp = IEM::requestGetGET('PerPageDisplay', 0, 'intval'); if ($temp) { $this->SetPerPage($temp); } } // Get "Record Per Page" if ($pageRecordPP == 0) { $pageRecordPP = $this->GetPerPage(); } $start = 0; if ($pageRecordPP != 'all') { $start = ($pageCurrentIndex - 1) * $pageRecordPP; } $recordTotal = API_USERGROUPS::getRecords(true); if (!$recordTotal) { $recordTotal = 0; } $records = API_USERGROUPS::getRecords(false, false, $pageRecordPP, $start, $pageSortInfo['SortBy'], ($pageSortInfo['Direction'] == 'desc')); if (!$records) { $records = array(); } else { for ($i = 0, $j = count($records); $i < $j; ++$i) { $records[$i]['processed_CreateDate'] = $this->PrintDate($records[$i]['createdate']); } } // ----- Calculate pagination, this is using the older method of pagination $GLOBALS['PAGE'] = 'UsersGroups'; $GLOBALS['FormAction'] = 'Action=manageGroups&ProcessPaging=1'; $this->SetupPaging($recordTotal, $pageCurrentIndex, $pageRecordPP); // ----- // ----- Print out HTML $this->PrintHeader(); $tpl = GetTemplateSystem(); $tpl->Assign('PAGE', $page); $tpl->Assign('records', $records); $tpl->ParseTemplate('UsersGroups_ManageGroups'); $this->PrintFooter(); // ----- return; }