/**
  * 修改密码
  */
 public function passAction()
 {
     if ($this->_request->isPost()) {
         $data = array('uid' => $this->_request->getPost('uid'), 'password' => $this->_request->getPost('password'), 'confirmPwd' => $this->_request->getPost('confirmPwd'));
         try {
             $this->user->updateInfo($data['uid'], $data);
             $this->view->feedback(array('title' => '设置成功', 'message' => '密码修改成功'));
         } catch (Exception $e) {
             $this->view->feedback(array('title' => '发生错误', 'message' => '密码修改失败:' . $e->getMessage()));
         }
     }
     $uid = $this->_getParam('uid');
     $this->view->info = null;
     if ($uid > 0) {
         $this->view->info = $this->user->getInfo($uid);
     }
 }
Exemple #2
0
/**
 * Smarty {form} function plugin
 *
 * Type:     function<br>
 * Name:     form<br>
 * Purpose:  generates form from database<br>
 * @author Nathan Gardner <*****@*****.**>
 */
function smarty_function_form($localparams, &$smarty)
{
    global $params;
    if (!empty($localparams['identifier'])) {
        $objForm = new FormModel();
        $objAuth = Authentication::getInstance();
        $objTemplate = new TemplatesModel();
        $objUser = new UserModel($objAuth->user_id);
        $userInfo = $objUser->getInfo();
        $form_id = $objForm->getFormId($localparams['identifier']);
        if ($form_id) {
            $formInfo = $objForm->loadForm($form_id);
            $templateInfo = $objTemplate->loadTemplateFromKeyname('form');
            // assign values if already submitted
            if (!empty($params['formSubmit']['fields']) && !empty($formInfo['fields'])) {
                foreach ($formInfo['fields'] as &$formField) {
                    foreach ($params['formSubmit']['fields'] as $submittedId => $submittedValue) {
                        if ($formField['id'] == $submittedId) {
                            if ($formField['type'] == 'checkbox' || $formField['type'] == 'radio') {
                                $formField['checked'] = 'checked';
                            } else {
                                $formField['value'] = $submittedValue;
                            }
                            break;
                        }
                    }
                }
            }
            // assign error flag and message if invalid
            if (!empty($params['formErrors']) && !empty($formInfo['fields'])) {
                foreach ($params['formErrors'] as $formError) {
                    foreach ($formInfo['fields'] as &$formField) {
                        if ($formError['field_id'] == $formField['id']) {
                            $formField['hasError'] = true;
                            $formField['errorMsg'] = $formError['errorMsg'];
                            break;
                        }
                    }
                }
            }
            // assign var to template
            if (!empty($params['formSubmitted'])) {
                $smarty->assign('formSubmitted', 1);
            }
            if (!empty($params['formErrors'])) {
                $smarty->assign('formErrors', $params['formErrors']);
            }
            $smarty->assign('formInfo', $formInfo);
            $output = $smarty->fetch('fromstring:' . $templateInfo['content']);
        } else {
            return 'Unknown form identifier';
        }
    } else {
        return 'Must pass an identifier';
    }
    return $output;
}
 public static function ActionRules()
 {
     $id = UserModel::getUserId();
     $dictionary = UserModel::getLangArray();
     $menuClass = [0 => 'active', 1 => '', 2 => '', 3 => '', 4 => '', 5 => ''];
     $view = 'templates/userProfile.php';
     $profile_content = 'templates/rules.php';
     $links = ['userProfile.css', 'webcam.css', 'rules.css'];
     $scripts = ['dragAndDropDownload.js', 'addPost.js', 'MediaAPI.js'];
     $user = UserModel::getInfo($id);
     include_once view . '/templates/template.php';
 }
Exemple #4
0
 function assignCommons()
 {
     global $params;
     ##prod info
     $this->assign('ProductTitle', PRODUCT_NAME);
     ##skin dir
     $this->assign('skin', '/' . $this->location . '/views/');
     $this->assign('bento', '/bento/');
     ##global url http/https
     if (empty($_SERVER["HTTPS"])) {
         $this->assign('httpUrl', 'http://' . URL . '/');
     } else {
         $this->assign('httpUrl', 'https://' . URL . '/');
     }
     ##site settings
     $objSettings = Settings::getInstance();
     $settings = $objSettings->getEntrys();
     $this->assign('Settings', $settings);
     $metaTitle = $settings['meta']['default-meta-title'];
     $metaDescription = $settings['meta']['default-meta-description'];
     $metaKeywords = $settings['meta']['default-meta-keywords'];
     if (!empty($params['_urlrequest'])) {
         $objUrls = new FriendlyurlModel();
         $objUrls->parseRequest($params['_urlrequest']);
         $urlMeta = $objUrls->getMetaData($objUrls->url_id);
         if (!empty($urlMeta['title'])) {
             $metaTitle = $urlMeta['title'];
         }
         if (!empty($urlMeta['description'])) {
             $metaDescription = $urlMeta['description'];
         }
         if (!empty($urlMeta['keywords'])) {
             $metaKeywords = $urlMeta['keywords'];
         }
         $this->assign('urlrequest', $params['_urlrequest']);
     }
     ##meta deta
     $this->assign('metaTitle', $metaTitle);
     $this->assign('metaDescription', $metaDescription);
     $this->assign('metaKeywords', $metaKeywords);
     ##global filesystem path
     $this->assign('fsPath', DIR);
     ##user vars
     $objAuthentication = Authentication::getInstance();
     if ($objAuthentication->loggedIn()) {
         $objUser = new UserModel($objAuthentication->user_id);
         $this->assign('loggedIn', true);
         $this->assign('UserInfo', $objUser->getInfo());
     } else {
         $this->assign('loggedIn', false);
     }
 }
Exemple #5
0
 function actionEdituser($params = '')
 {
     $objUser = new UserModel();
     $user_id = !empty($params['user_id']) ? intval($params['user_id']) : false;
     if (!empty($params['dosave'])) {
         $saveData = array();
         $saveData['id'] = !empty($params['user_id']) ? $params['user_id'] : false;
         $saveData['email'] = !empty($params['user_email']) ? $params['user_email'] : false;
         $saveData['password'] = !empty($params['user_password']) ? $params['user_password'] : false;
         $saveData['fName'] = !empty($params['user_fname']) ? $params['user_fname'] : false;
         $saveData['lName'] = !empty($params['user_lname']) ? $params['user_lname'] : false;
         $saveData['title'] = !empty($params['user_title']) ? $params['user_title'] : false;
         $saveData['type'] = !empty($params['user_type']) ? $params['user_type'] : 'user';
         $saveData['permissions'] = !empty($params['user_permissions']) ? $params['user_permissions'] : false;
         $user_id = $objUser->saveUser($saveData);
         if ($user_id) {
             $this->messages[] = array('type' => 'success', 'message' => 'User has been saved.');
             if ($params['submit'] == 'Save and Close') {
                 $this->actionIndex();
                 return;
             }
         } else {
             $this->messages[] = array('type' => 'error', 'message' => $objUser->errorMsg);
         }
     }
     if ($user_id) {
         $objUser->setUserId($user_id);
     }
     $userInfo = $objUser->getInfo();
     $this->view->assign('userInfo', $userInfo);
     $permissions = $objUser->permissions->getUserPermissionTable($user_id);
     $this->view->assign('permissions', $permissions);
     $this->view->assign('content', $this->view->fetch('tpl/administration/user.tpl'));
     $this->view->assign('messages', $this->messages);
     $this->finish();
 }
 public static function actionDialog($chatId)
 {
     $dictionary = UserModel::getLangArray();
     $menuClass = [0 => '', 1 => '', 2 => 'active', 3 => '', 4 => ''];
     $userStyle = UserModel::getUserStyle();
     $id = UserModel::getUserId();
     $user = UserModel::getInfo($id);
     $messages = ChatModel::getChatMessages($chatId);
     if (ChatModel::isUserInChat($chatId, UserModel::getUserId())) {
         $lastMessage = end($messages);
         $timestamp = $lastMessage['timestamp'];
         $view = 'templates/userProfile.php';
         $profile_content = 'templates/dialog.php';
         $links = ['userProfile.css', 'dialog.css', 'webcam.css'];
         $scripts = ['dragAndDropDownload.js', 'follow.js', 'messager.js', 'MediaAPI.js'];
         include_once view . '/templates/template.php';
     } else {
         header('Location: /rules');
     }
 }
Exemple #7
0
 function actionAccount($params = '')
 {
     $userModel = new UserModel($this->objAuthentication->user_id);
     if (!empty($params['manageAccount']) && $params['manageAccount'] == 1) {
         $objValidator = new Validator();
         $objValidator->reset();
         if (!empty($params['user_password'])) {
             $objValidator->validatePassword($params['user_password']);
             $objValidator->passwordsMatch($params['user_password'], $params['user_password2']);
         }
         if ($objValidator->hasError) {
             $this->view->assign('errorMessages', $objValidator->getError());
         } else {
             $userInfo = array();
             if (!empty($params['user_password'])) {
                 $userInfo['password'] = $params['user_password'];
                 $userInfo['email'] = $params['user_email'];
                 $userUpdated = $userModel->manageUser($userInfo);
                 if ($userUpdated) {
                     $this->view->assign('successMessage', 'Your account has been updated.');
                 } else {
                     $this->view->assign('errorMessages', array('Unable to update your account'));
                 }
             }
         }
     }
     $this->view->assign('userInfo', $userModel->getInfo());
     $this->view->assign('content', $this->view->fetch('tpl/community/account.tpl'));
     $this->finish();
 }
Exemple #8
0
 function sendOrderAdmin($order_id)
 {
     $objEmailer = new Emailer();
     $objLayout = new LayoutModel();
     $objTemplate = new TemplatesModel();
     $objOrder = new OrderModel();
     $objUser = new UserModel();
     $objSettings = Settings::getInstance();
     $adminEmail = $objSettings->getEntry('admin', 'admin-email');
     $layoutInfo = $objLayout->loadLayout(28);
     $template = $objTemplate->loadTemplateFromKeyname('email-order');
     // load order
     $orderInfo = $objOrder->getOrder($order_id);
     $objUser->setUserId($orderInfo['user_id']);
     $userInfo = $objUser->getInfo();
     // assign to template
     $this->view->assign('adminView', true);
     $this->view->assign('orderInfo', $orderInfo);
     $this->view->assign('userInfo', $userInfo);
     // render template
     $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content']));
     $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar']));
     $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar']));
     // send email
     $objEmailer->setFrom('*****@*****.**');
     $objEmailer->addTo($adminEmail, "Parks Associates");
     $objEmailer->setSubject('NEW PURCHASE');
     $objEmailer->setBody($this->view->fetch('fromstring:' . $layoutInfo['code']), true);
     $objEmailer->sendMail();
     // see if we also need to send webcast registration email
     if (!empty($orderInfo['webcasts'])) {
         foreach ($orderInfo['webcasts'] as $webcast) {
             // see if its in the future
             if (strtotime($webcast['eventDate']) > time()) {
                 // send them email
                 $this->sendWebcastRegistrationAdmin($orderInfo);
                 break;
                 // only need to send once
             }
         }
     }
     return true;
 }
Exemple #9
0
 function actionProfile($params = '')
 {
     $message = !empty($params['message']) ? $params['message'] : false;
     $this->objAuthentication->requiresAccount();
     $userModel = new UserModel($this->objAuthentication->user_id);
     $userInfo = $userModel->getInfo();
     $objLayout = new LayoutModel();
     $objTemplate = new TemplatesModel();
     $layoutInfo = $objLayout->loadLayout();
     $template = $objTemplate->loadTemplateFromKeyname('user-profile');
     $this->view->assign('message', $message);
     $this->view->assign('userInfo', $userInfo);
     $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content']));
     $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar']));
     $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar']));
     $this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code']));
     $this->finish();
 }