예제 #1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $subAdminSID = SJB_Request::getVar('subadmin', 0);
     if (!empty($subAdminSID) && ($adminInfo = SJB_SubAdminManager::getSubAdminInfoBySID($subAdminSID))) {
         $editedSubAdminInfo = $_REQUEST;
         $subAdminInfo = array_merge($adminInfo, $editedSubAdminInfo);
         // create subAdmin object
         $oSubAdmin = SJB_ObjectMother::createSubAdmin($subAdminInfo);
         $oSubAdmin->setSID($adminInfo['sid']);
         $oSubAdmin->makePropertyNotRequired("password");
         // permissions
         $acl = SJB_SubAdminAcl::getInstance();
         $type = 'subadmin';
         $resources = $acl->getResources();
         $perms = SJB_SubAdminAcl::getAllPermissions($type, $oSubAdmin->getSID());
         // /permissions
         SJB_SubAdminAcl::mergePermissionsWithResources($resources, $perms);
         $registration_form = SJB_ObjectMother::createForm($oSubAdmin);
         $action = SJB_Request::getVar('action', '');
         $registration_form->registerTags($tp);
         $errors = array();
         if ('save' == $action || $action == 'apply') {
             if ($adminInfo['username'] == $subAdminInfo['username']) {
                 $oSubAdmin->deleteProperty('username');
             }
             if ($adminInfo['email'] == $subAdminInfo['email']) {
                 $oSubAdmin->deleteProperty('email');
             }
             if ($registration_form->isDataValid($errors)) {
                 $password_value = $oSubAdmin->getPropertyValue('password');
                 if (empty($password_value['original'])) {
                     $oSubAdmin->deleteProperty('password');
                 }
                 // save subAdmin
                 SJB_SubAdminManager::saveSubAdmin($oSubAdmin);
                 $role = $oSubAdmin->getSID();
                 SJB_Acl::clearPermissions($type, $role);
                 foreach ($resources as $name => $resource) {
                     SJB_SubAdminAcl::allow($name, $type, $role, SJB_SubAdminAcl::definePermission($name), SJB_Array::get($resource, 'params', ''));
                 }
                 SJB_FlashMessages::getInstance()->addMessage('CHANGES_SAVED');
                 if ($action == 'save') {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-subadmins/");
                 }
             }
             SJB_SubAdminAcl::mergePermissionsWithRequest($resources);
         }
         SJB_SubAdminAcl::prepareSubPermissions($resources);
         $tp->assign("errors", $errors);
         $tp->assign("form_fields", $registration_form->getFormFieldsInfo());
         $tp->assign('groups', SJB_SubAdminAcl::getPermissionGroups());
         $tp->assign('resources', $resources);
         $tp->assign('type', $type);
         $tp->assign('sid', $subAdminInfo['sid']);
         $tp->display('add_subadmin.tpl');
     }
 }
예제 #2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $oSubAdmin = SJB_ObjectMother::createSubAdmin($_REQUEST);
     $registration_form = SJB_ObjectMother::createForm($oSubAdmin);
     $registration_form->registerTags($tp);
     $form_submitted = SJB_Request::getVar('action', '') == 'add';
     $errors = array();
     $acl = SJB_SubAdminAcl::getInstance();
     $type = 'subadmin';
     $resources = $acl->getResources();
     SJB_SubAdminAcl::mergePermissionsWithResources($resources);
     switch (SJB_Request::getVar('action')) {
         case 'save':
             if ($registration_form->isDataValid($errors)) {
                 SJB_SubAdminManager::saveSubAdmin($oSubAdmin);
                 $role = $oSubAdmin->getSID();
                 SJB_Acl::clearPermissions($type, $role);
                 foreach ($resources as $name => $resource) {
                     SJB_SubAdminAcl::allow($name, $type, $role, SJB_SubAdminAcl::definePermission($name), SJB_Request::getVar($name . '_params'));
                 }
                 // get new defined permissions for notification letter
                 $permissions = SJB_SubAdminAcl::getAllPermissions($type, $role);
                 $resources = $acl->getResources();
                 SJB_SubAdminAcl::mergePermissionsWithResources($resources, $permissions);
                 SJB_Notifications::sendSubAdminRegistrationLetter($oSubAdmin, SJB_Request::get(), $resources);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-subadmins/');
             }
             break;
         case 'delete':
             $subadmins = SJB_Request::getVar('subadmin', array());
             foreach ($subadmins as $subadmin_sid) {
                 $username = SJB_SubAdminManager::getUserNameBySubAdminSID($subadmin_sid);
                 SJB_SubAdminManager::deleteSubAdminByUserName($username);
             }
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-subadmins/');
             break;
         default:
             break;
     }
     $tp->assign('errors', $errors);
     $tp->assign('form_fields', $registration_form->getFormFieldsInfo());
     $aPermissionGroups = SJB_SubAdminAcl::getPermissionGroups();
     if ('save' == SJB_Request::getVar('action', '')) {
         SJB_SubAdminAcl::mergePermissionsWithRequest($resources);
     }
     SJB_SubAdminAcl::prepareSubPermissions($resources);
     $tp->assign('groups', $aPermissionGroups);
     $tp->assign('resources', $resources);
     $tp->assign('type', $type);
     $tp->assign('role', 0);
     $tp->display('add_subadmin.tpl');
 }
예제 #3
0
 public static function writeToLog($payment, $result = false)
 {
     if (SJB_Settings::getSettingByName('notification_payment') != $payment->recipient_payment) {
         $username = SJB_UserManager::getUserSIDbyPayment($payment->recipient_payment);
     }
     if (!$username) {
         $admin = SJB_SubAdminManager::getUserSIDbyPayment($payment->recipient_payment);
         $admin = $admin ? $admin : 'admin';
     }
     $status = 'Delivered';
     if (!$result) {
         $status = 'Undelivered';
     }
     SJB_DB::query("INSERT INTO `payment_log` (`date`, `gateway`, `message`, `status`) VALUES (NOW(), ?s, ?s, ?s, ?s, ?s, ?s)", $payment->gateway, $payment->text, $status);
 }
예제 #4
0
 public static function writeToLog($email, $result = false, $error_msg = false)
 {
     $username = '';
     $admin = '';
     if (SJB_Settings::getSettingByName('notification_email') != $email->recipient_email) {
         $username = SJB_UserManager::getUserSIDbyEmail($email->recipient_email);
     }
     if (!$username) {
         $admin = SJB_SubAdminManager::getUserSIDbyEmail($email->recipient_email);
         $admin = $admin ? $admin : 'admin';
     }
     $status = 'Delivered';
     if (!$result) {
         $status = 'Undelivered';
     } elseif ('Not Sent' === $result) {
         $status = $result;
     }
     SJB_DB::query("INSERT INTO `email_log` (`date`, `subject`, `email`, `message`, `username`, `admin`, `status`, `error_msg`) VALUES (NOW(), ?s, ?s, ?s, ?s, ?s, ?s, ?s)", $email->subject, $email->recipient_email, $email->text, $username, $admin, $status, $error_msg);
 }
예제 #5
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $form_submitted = SJB_Request::getVar('action');
     $page = SJB_Request::getVar('page');
     if ($form_submitted) {
         if (SJB_System::getSystemSettings("isDemo")) {
             $errors[] = "You don't have permissions for it. This is a Demo version of the software.";
         } else {
             if (!empty($_REQUEST['bad_words'])) {
                 $_REQUEST['bad_words'] = trim($_REQUEST['bad_words']);
             }
             SJB_Settings::updateSettings($_REQUEST);
         }
         if ($form_submitted == 'apply_settings') {
             $tp->assign("page", $page);
         }
     }
     $i18n = SJB_I18N::getInstance();
     $tp->assign("settings", SJB_Settings::getSettings());
     $ds = DIRECTORY_SEPARATOR;
     $path = SJB_BASE_DIR . "system{$ds}cache{$ds}agents_bots.txt";
     $disable_bots = file_get_contents($path);
     $tp->assign("disable_bots", $disable_bots);
     $tp->assign("timezones", timezone_identifiers_list());
     if (!SJB_SubAdmin::getSubAdminSID()) {
         $tp->assign("subadmins", SJB_SubAdminManager::getAllSubAdminsInfo());
     }
     $tp->assign("errors", $errors);
     $tp->assign("i18n_domains", $i18n->getDomainsData());
     $tp->assign("i18n_languages", $i18n->getActiveLanguagesData());
     $tp->assign("countries", SJB_CountriesManager::getAllCountriesCodesAndNames());
     $tp->assign('listingEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_LISTING));
     $tp->assign('productEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_PRODUCT));
     $tp->assign('userEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_USER));
     $tp->assign('otherEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_OTHER));
     $tp->display("settings.tpl");
 }
예제 #6
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign("subadmins", SJB_SubAdminManager::getAllSubAdminsInfo());
     $tp->display("manage_subadmins.tpl");
 }
예제 #7
0
 public static function getUserSIDbyUsername($username)
 {
     $user_info = SJB_SubAdminManager::getUserInfoByUserName($username);
     if (!empty($user_info)) {
         return $user_info['sid'];
     }
     return null;
 }
예제 #8
0
 public static function isSubAdminNotifiedOnUserContractExpiration($groupId)
 {
     return SJB_SubAdminManager::getIfSubAdminsNotifiedOn('get_notifications_on_' . strtolower($groupId) . '_subscription_expiration');
 }
예제 #9
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $subAdminSID = SJB_SubAdmin::getSubAdminSID();
     if (!empty($subAdminSID) && ($adminInfo = SJB_SubAdmin::getSubAdminInfo())) {
         // save sub admin notifications via ajax;
         SJB_SubAdminManager::SaveSubAdminNotifications($subAdminSID, SJB_Request::getVar('name', ''), SJB_Request::getVar('value'));
         $message = '';
         $editedSubAdminInfo = $_REQUEST;
         $subAdminNewInfo = array_merge($adminInfo, $editedSubAdminInfo);
         // create subAdmin object
         $oSubAdmin = SJB_ObjectMother::createSubAdmin($subAdminNewInfo);
         $oSubAdmin->setSID($adminInfo['sid']);
         $oSubAdmin->makePropertyNotRequired("username");
         $oSubAdmin->makePropertyNotRequired("email");
         $oSubAdmin->makePropertyNotRequired("password");
         $oSubAdmin->addProperty(array('id' => 'password_cur', 'caption' => 'Current Password', 'type' => 'password', 'length' => '20', 'is_system' => true, 'order' => 1));
         $oSubAdmin->setPropertyValue('password_cur', SJB_Request::getVar('password_cur', ''));
         // permissions
         $acl = SJB_SubAdminAcl::getInstance();
         $type = 'subadmin';
         $resources = $acl->getResources();
         $perms = SJB_SubAdminAcl::getAllPermissions($type, $oSubAdmin->getSID());
         // /permissions
         SJB_SubAdminAcl::mergePermissionsWithResources($resources, $perms);
         $errors = array();
         $action = SJB_Request::getVar('action', '');
         if ('save' == $action) {
             $registration_form = SJB_ObjectMother::createForm($oSubAdmin);
             $registration_form->registerTags($tp);
             if ($adminInfo['email'] == $subAdminNewInfo['email']) {
                 $oSubAdmin->deleteProperty('email');
             }
             $password_value = $oSubAdmin->getPropertyValue('password');
             if (!empty($password_value['original'])) {
                 $currentPass = $oSubAdmin->getPropertyValue('password_cur');
                 if (!empty($currentPass)) {
                     if (!SJB_SubAdmin::checkCurrentPassword($currentPass)) {
                         $oSubAdmin->deleteProperty('password');
                         $errors['CurrentPassword'] = '******';
                     }
                 } else {
                     $oSubAdmin->deleteProperty('password');
                     $errors['CurrentPassword'] = '******';
                 }
             } else {
                 $oSubAdmin->deleteProperty('password');
             }
             $oSubAdmin->deleteProperty('password_cur');
             if (empty($errors) && $registration_form->isDataValid($errors)) {
                 SJB_SubAdminManager::saveSubAdmin($oSubAdmin);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-profile/?saved=1');
             }
         }
         $oSubAdmin->deleteProperty('password');
         $oSubAdmin->deleteProperty('password_cur');
         $oSubAdmin->addProperty(array('id' => 'password_cur', 'caption' => 'Current Password', 'type' => 'password_cur', 'length' => '20', 'is_system' => true, 'order' => 1));
         $oSubAdmin->addProperty(array('id' => 'password', 'caption' => 'New Password', 'type' => 'password', 'length' => '20', 'is_system' => true, 'order' => 1));
         $registration_form = SJB_ObjectMother::createForm($oSubAdmin);
         $registration_form->registerTags($tp);
         $registration_form->makeDisabled('username');
         $tp->assign("saved", SJB_Request::getVar('saved', false));
         $tp->assign("errors", $errors);
         $tp->assign("form_fields", $registration_form->getFormFieldsInfo());
         $tp->assign('groups', SJB_SubAdminAcl::getPermissionGroups());
         $tp->assign('notifications', SJB_SubAdminAcl::getSubAdminNotifications($resources, $perms));
         $tp->assign('resources', $resources);
         $tp->assign('type', $type);
         $tp->assign('sid', $subAdminNewInfo['sid']);
         $tp->assign('message', $message);
         $tp->display("edit_subadmin_profile.tpl");
     }
 }
예제 #10
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $restore = SJB_Request::getVar('restore', false);
     $action = SJB_Request::getVar('action_name', 'view_log');
     $action = $action == 'search' ? 'view_log' : $action;
     $paginator = new SJB_EmailLogPagination();
     $display_error = SJB_Request::getVar('display_error', false);
     $savedErrors = SJB_Session::getValue(self::EMAIL_ERRORS);
     SJB_Session::unsetValue(self::EMAIL_ERRORS);
     $this->errors = $savedErrors ? $savedErrors : array();
     $message = SJB_Session::getValue(self::EMAIL_LOG_MESSAGE);
     SJB_Session::unsetValue(self::EMAIL_LOG_MESSAGE);
     switch ($action) {
         case 'display_message':
             $sid = SJB_Request::getVar('sid', false);
             $email = SJB_EmailLogManager::getEmailInfoBySID($sid);
             $tp->assign('display_error', $display_error);
             $tp->assign('email', $email);
             $tp->display('display_log_message.tpl');
             return true;
             break;
         case 'resend':
             try {
                 SJB_Settings::saveSetting(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION, SJB_Request::getVar(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION));
                 $this->resendEmails();
                 SJB_Session::setValue(self::EMAIL_LOG_MESSAGE, 'The message(s) were successfully resent.');
             } catch (Exception $e) {
                 array_push($this->errors, $e->getMessage());
             }
             SJB_Session::setValue(self::EMAIL_ERRORS, $this->errors);
             $searchFields = SJB_Request::getVar('searchFields');
             SJB_HelperFunctions::redirect(SJB_HelperFunctions::getSiteUrl() . '/email-log/?sorting_field=' . $paginator->sortingField . '&sorting_order=' . $paginator->sortingOrder . '&items_per_page=' . $paginator->itemsPerPage . $searchFields);
             break;
         case 'view_log':
             $userSID = SJB_Request::getVar('user_sid', false);
             if ($userSID) {
                 $template = 'user_email_log.tpl';
                 $_REQUEST['username']['equal'] = $userSID;
                 $userInfo = SJB_UserManager::getUserInfoBySID($userSID);
                 $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']);
                 $tp->assign('userGroupInfo', $userGroupInfo);
                 $tp->assign('display_error', $display_error);
                 $tp->assign('user_info', $userInfo);
                 $tp->assign('user_sid', $userSID);
             }
             $email = new SJB_EmailLog($_REQUEST);
             $search_form_builder = new SJB_SearchFormBuilder($email);
             $criteria_saver = new SJB_EmailLogCriteriaSaver();
             if ($restore) {
                 $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
             }
             $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $email);
             if (!$userSID) {
                 $template = 'email_log.tpl';
                 $search_form_builder->setCriteria($criteria);
                 $search_form_builder->registerTags($tp);
                 $tp->display("email_log_search_form.tpl");
             }
             $order_info = array('sorting_field' => $paginator->sortingField, 'sorting_order' => $paginator->sortingOrder);
             $criteria_saver->setSessionForOrderInfo($order_info);
             $criteria_saver->setSessionForCurrentPage($paginator->currentPage);
             $criteria_saver->setSessionForListingsPerPage($paginator->itemsPerPage);
             $searcher = new SJB_EmailLogSearcher(array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage), $paginator->sortingField, $paginator->sortingOrder);
             $found_emails = $searcher->getObjectsSIDsByCriteria($criteria);
             $criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
             foreach ($found_emails as $id => $emailSID) {
                 $emailInfo = SJB_EmailLogManager::getEmailInfoBySID($emailSID);
                 $found_emails[$id] = $emailInfo;
                 $found_emails[$id]['user'] = !empty($emailInfo['username']) ? SJB_UserManager::getUserInfoBySID($emailInfo['username']) : array();
                 $found_emails[$id]['admin'] = array();
                 if (!empty($emailInfo['admin'])) {
                     if (is_numeric($emailInfo['admin'])) {
                         $found_emails[$id]['admin'] = SJB_SubAdminManager::getSubAdminInfoBySID($emailInfo['admin']);
                     } else {
                         $found_emails[$id]['admin']['username'] = '******';
                     }
                 }
             }
             $paginator->setItemsCount($searcher->getAffectedRows());
             $searchFields = '';
             foreach ($_REQUEST as $key => $val) {
                 if (is_array($val)) {
                     foreach ($val as $fieldName => $fieldValue) {
                         $searchFields .= "&{$key}[{$fieldName}]={$fieldValue}";
                     }
                 }
             }
             $tp->assign(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION, SJB_Settings::getSettingByName(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION));
             $tp->assign('message', $message);
             $tp->assign('errors', $this->errors);
             $tp->assign("searchFields", $searchFields);
             $tp->assign('paginationInfo', $paginator->getPaginationInfo());
             $tp->assign("found_emails", $found_emails);
             $tp->display($template);
             break;
     }
 }