当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsUser类代码示例

本文整理汇总了PHP中cmsUser的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser类的具体用法?PHP cmsUser怎么用?PHP cmsUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了cmsUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run($profile_id)
 {
     if (!cmsUser::isLogged()) {
         cmsCore::error404();
     }
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $user = cmsUser::getInstance();
     $direction = $this->request->get('direction');
     $comment = $this->request->get('comment');
     //
     // Проверяем валидность
     //
     $is_valid = $user->is_logged && cmsUser::isAllowed('users', 'vote_karma') && is_numeric($profile_id) && $user->id != $profile_id && in_array($direction, array('up', 'down')) && (!$this->options['is_karma_comments'] || $comment);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         cmsTemplate::getInstance()->renderJSON($result);
     }
     $profile = $this->model->getUser($profile_id);
     if (!$profile || !$this->model->isUserCanVoteKarma($user->id, $profile_id, $this->options['karma_time'])) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         cmsTemplate::getInstance()->renderJSON($result);
     }
     //
     // Сохраняем оценку
     //
     $vote = array('user_id' => $user->id, 'profile_id' => $profile_id, 'points' => $direction == 'up' ? 1 : -1, 'comment' => $comment);
     $vote_id = $this->model->addKarmaVote($vote);
     $value = $profile['karma'] + $vote['points'];
     $result = array('error' => $vote_id ? false : true, 'value' => html_signed_num($value), 'css_class' => html_signed_class($value));
     cmsTemplate::getInstance()->renderJSON($result);
 }
开发者ID:asphix,项目名称:icms2,代码行数:33,代码来源:karma_vote.php

示例2: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!$this->cms_user->is_logged) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     if (cmsUser::isPermittedLimitHigher('comments', 'karma', $this->cms_user->karma)) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     $target_controller = $this->request->get('tc', '');
     $target_subject = $this->request->get('ts', '');
     $target_id = $this->request->get('ti', 0);
     $is_track = $this->request->get('is_track', 0);
     if (!$target_controller || !$target_subject || !$target_id) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     $is_valid = $this->validate_sysname($target_controller) === true && $this->validate_sysname($target_subject) === true && is_numeric($target_id) && is_numeric($is_track);
     if (!$is_valid) {
         return $this->cms_template->renderJSON(array('error' => true));
     }
     $success = $this->model->filterEqual('target_controller', $target_controller)->filterEqual('target_subject', $target_subject)->filterEqual('target_id', $target_id)->toggleTracking($is_track, $this->cms_user->id, $target_controller, $target_subject, $target_id);
     return $this->cms_template->renderJSON(array('error' => !$success));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:25,代码来源:track.php

示例3: run

 public function run($id)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $form = $this->getForm('preset', array('edit'));
     $is_submitted = $this->request->has('submit');
     $preset = $original_preset = $this->model->getPreset($id);
     if ($preset['is_internal']) {
         $form->removeFieldset('basic');
     }
     if ($is_submitted) {
         $preset = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $preset);
         if (!$errors) {
             $this->model->updatePreset($id, $preset);
             $this->createDefaultImages(array_merge($original_preset, $preset));
             $this->redirectToAction('presets');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('backend/preset', array('do' => 'edit', 'preset' => $preset, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:pin-git,项目名称:icms2,代码行数:25,代码来源:presets_edit.php

示例4: polls

function polls()
{
    $model = new cms_model_polls();
    global $_LANG;
    $do = cmsCore::getInstance()->do;
    //========================================================================================================================//
    //========================================================================================================================//
    if ($do == 'view') {
        $answer = cmsCore::request('answer', 'str', '');
        $poll_id = cmsCore::request('poll_id', 'int');
        if (!$answer || !$poll_id) {
            if (cmsCore::isAjax()) {
                cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['SELECT_THE_OPTION']));
            } else {
                cmsCore::error404();
            }
        }
        $poll = $model->getPoll($poll_id);
        if (!$poll) {
            cmsCore::jsonOutput(array('error' => true, 'text' => ''));
        }
        if ($model->isUserVoted($poll_id)) {
            cmsCore::jsonOutput(array('error' => true, 'text' => ''));
        }
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::halt();
        }
        $model->votePoll($poll, $answer);
        cmsCore::jsonOutput(array('error' => false, 'text' => $_LANG['VOTE_ACCEPTED']));
    }
}
开发者ID:4uva4ek,项目名称:svato,代码行数:31,代码来源:frontend.php

示例5: getWidget

 public function getWidget($title, $target, $permissions = array())
 {
     $user = cmsUser::getInstance();
     extract($target);
     $page = $this->request->get('page', 1);
     $show_id = $this->request->get('wid');
     $go_reply = $this->request->get('reply', 0);
     $show_reply_id = 0;
     if ($show_id) {
         $entry = $this->model->getEntry($show_id);
         if ($entry) {
             if ($entry['parent_id'] > 0) {
                 $show_id = $entry['parent_id'];
                 $show_reply_id = $entry['id'];
             }
             $page = $this->model->getEntryPageNumber($show_id, $target, self::$perpage);
         }
     }
     $total = $this->model->getEntriesCount($profile_type, $profile_id);
     $entries = $this->model->getEntries($profile_type, $profile_id, $page);
     $entries = cmsEventsManager::hook('wall_before_list', $entries);
     $csrf_token_seed = implode('/', array($profile_type, $profile_id));
     $template = cmsTemplate::getInstance();
     return $template->renderInternal($this, 'list', array('title' => $title, 'user' => $user, 'controller' => $controller, 'profile_type' => $profile_type, 'profile_id' => $profile_id, 'user' => $user, 'entries' => $entries, 'permissions' => $permissions, 'page' => $page, 'perpage' => wall::$perpage, 'total' => $total, 'max_entries' => $show_id ? 0 : 5, 'csrf_token_seed' => $csrf_token_seed, 'show_id' => $show_id, 'show_reply_id' => $show_reply_id, 'go_reply' => $go_reply));
 }
开发者ID:dgolovanev,项目名称:icms2,代码行数:25,代码来源:frontend.php

示例6: run

 public function run($profile)
 {
     // проверяем наличие доступа
     if ($profile['id'] != $this->cms_user->id && !$this->cms_user->is_admin) {
         cmsCore::error404();
     }
     $form = $this->getForm('password');
     $is_submitted = $this->request->has('submit');
     $data = array();
     if ($is_submitted) {
         cmsCore::loadControllerLanguage('auth');
         $data = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $data);
         if (!$errors) {
             $password_hash = md5(md5($data['password']) . $this->cms_user->password_salt);
             if ($password_hash != $this->cms_user->password) {
                 $errors = array('password' => LANG_OLD_PASS_INCORRECT);
             }
         }
         if (!$errors) {
             $profile = array_merge($profile, $data);
             $result = $this->model->updateUser($profile['id'], $profile);
             if ($result['success']) {
                 cmsUser::addSessionMessage(LANG_PASS_CHANGED, 'success');
                 $this->redirectTo('users', $profile['id']);
             } else {
                 $errors = $result['errors'];
             }
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return $this->cms_template->render('profile_edit_password', array('id' => $profile['id'], 'profile' => $profile, 'data' => $data, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:35,代码来源:profile_edit_password.php

示例7: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $template = cmsTemplate::getInstance();
     $entry_id = $this->request->get('id');
     // Проверяем валидность
     $is_valid = is_numeric($entry_id);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         $template->renderJSON($result);
     }
     $user = cmsUser::getInstance();
     $entry = $this->model->getEntry($entry_id);
     $replies = $this->model->getReplies($entry_id);
     if (!$replies) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         $template->renderJSON($result);
     }
     $permissions = array('add' => $user->is_logged, 'delete' => $user->is_admin || $user->id == $entry['profile_id']);
     $html = $template->renderInternal($this, 'entry', array('entries' => $replies, 'user' => $user, 'permissions' => $permissions));
     // Формируем и возвращаем результат
     $result = array('error' => false, 'html' => $html);
     $template->renderJSON($result);
 }
开发者ID:asphix,项目名称:icms2,代码行数:26,代码来源:get_replies.php

示例8: parseHide

 private function parseHide($text, $hidden = false)
 {
     $inUser = cmsUser::getInstance();
     global $_LANG;
     $pattern = '/\\[hide(?:=?)([0-9]*)\\](.*?)\\[\\/hide\\]/sui';
     preg_match($pattern, $text, $matches);
     if (!$matches) {
         return $text;
     }
     if ($hidden) {
         $replacement = '<noindex>' . $_LANG['P_HIDE_TEXT_MOD'] . '</noindex>';
     } else {
         if (!$inUser->id) {
             $replacement = '<noindex><div class="bb_tag_hide">' . $_LANG['P_HIDE_TEXT'] . '</div></noindex>';
         } else {
             if (!$matches[1]) {
                 $replacement = '<div class="bb_tag_hide">${2}</div>';
             } elseif ($inUser->rating > $matches[1] || $inUser->is_admin) {
                 $replacement = '<div class="bb_tag_hide">${2}</div>';
             } else {
                 $replacement = '<div class="bb_tag_hide">' . sprintf($_LANG['P_HIDE_TEXT_RATING'], cmsCore::spellCount($matches[1], $_LANG['P_ITEM1'], $_LANG['P_ITEM2'], $_LANG['P_ITEM10'])) . '</div>';
             }
         }
     }
     return preg_replace($pattern, $replacement, $text);
 }
开发者ID:deltas1,项目名称:icms1,代码行数:26,代码来源:plugin.php

示例9: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $orfo = $this->request->get('orfo');
     $url = $this->request->get('url');
     $comment = $this->request->get('comment', false);
     $author = !cmsUser::isLogged() ? cmsUser::getIp() : cmsUser::get('nickname');
     $form = $this->getForm('orfo');
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         $data = $form->parse($this->request, $is_submitted);
         $data['date'] = date('Y-m-d H:i:s');
         $errors = $form->validate($this, $data);
         dump($errors);
         if (!$errors) {
             $this->model->addComplaints($data);
             $messenger = cmsCore::getController('messages');
             $messenger->addRecipient(1);
             $notice = array('content' => sprintf(LANG_COMPLAINTS_ADD_NOTICE, $url, $orfo), 'options' => array('is_closeable' => true));
             $messenger->ignoreNotifyOptions()->sendNoticePM($notice, 'complaints_add');
         }
         cmsTemplate::getInstance()->renderJSON(array('errors' => false, 'callback' => 'formSuccess'));
     }
     $data = array('orfo' => $orfo, 'url' => $url, 'author' => $author, 'comment' => $comment);
     return cmsTemplate::getInstance()->render('orfo', array('form' => $form, 'data' => $data));
 }
开发者ID:mafru,项目名称:icms2,代码行数:28,代码来源:orfo.php

示例10: mod_calendar_eventview

function mod_calendar_eventview($module_id)
{
    $inCore = cmsCore::getInstance();
    $inUser = cmsUser::getInstance();
    $DB = cmsDatabase::getInstance();
    $cfg = $inCore->loadComponentConfig('calendar');
    if ($inUser->id != 0 and $cfg['calendar_module'] == "user") {
        //Запрос к БД
        $sql = "\r\n\tSELECT cms_events.* ,\r\n\tcms_events_category.tx,\r\n\tcms_events_category.bg\r\n\tFROM cms_events \r\n\tLEFT JOIN cms_events_signup ON cms_events.id=cms_events_signup.event_id \r\n\tLEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\r\n\tWHERE \r\n\tcms_events.start_time > " . time() . " AND \r\n\tcms_events.author_id = " . $inUser->id . " OR \r\n\tcms_events_signup.user_id = " . $inUser->id . " AND \r\n\tcms_events.author_id <> " . $inUser->id . " AND \r\n\tcms_events.start_time > " . time() . " \r\n\tGROUP BY cms_events.id ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count'];
    } else {
        $sql = "SELECT cms_events.*,\r\n\t    cms_events_category.tx,\r\n\t    cms_events_category.bg\r\n\t    FROM cms_events\r\n\t    LEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\t    \r\n\t    WHERE cms_events.`type` = 'public' \r\n\t    AND cms_events.start_time > " . time() . " \r\n\t    ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count'];
    }
    $result = $DB->query($sql);
    if ($DB->error()) {
        return false;
    }
    $events = array();
    while ($event = $DB->fetch_assoc($result)) {
        if ($event['author_id'] == $inUser->id) {
            $event['time'] == "";
        }
        if ($event['category_id'] == 0) {
            $event['bg'] = '#C3BCB9';
            $event['tx'] = '#000000';
        }
        $events[] = $event;
    }
    $smarty = $inCore->initSmarty('modules', 'mod_calendar_eventview.tpl');
    $smarty->assign('events', $events);
    $smarty->display('mod_calendar_eventview.tpl');
    return true;
}
开发者ID:ratmir-by,项目名称:icms-calendar,代码行数:32,代码来源:module.php

示例11: run

 public function run($photo_id = null)
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!$photo_id) {
         $photo_id = $this->request->get('id');
         if (!$photo_id) {
             cmsCore::error404();
         }
     }
     $photo = $this->model->getPhoto($photo_id);
     $success = true;
     // проверяем наличие доступа
     $user = cmsUser::getInstance();
     if (!cmsUser::isAllowed('albums', 'edit')) {
         $success = false;
     }
     if (!cmsUser::isAllowed('albums', 'edit', 'all') && $photo['user_id'] != $user->id) {
         $success = false;
     }
     if (!$success) {
         cmsTemplate::getInstance()->renderJSON(array('success' => false));
     }
     $album = cmsCore::getModel('content')->getContentItem('albums', $photo['album_id']);
     $this->model->deletePhoto($photo_id);
     $this->model->setRandomAlbumCoverImage($photo['album_id']);
     cmsTemplate::getInstance()->renderJSON(array('success' => true, 'album_url' => href_to('albums', $album['slug'] . '.html')));
 }
开发者ID:asphix,项目名称:icms2,代码行数:29,代码来源:delete.php

示例12: mod_actions

function mod_actions(array $mod, $cfg)
{
    $inDB = cmsDatabase::getInstance();
    $inActions = cmsActions::getInstance();
    global $_LANG;
    if (!isset($cfg['show_target'])) {
        $cfg['show_target'] = 1;
    }
    if (!isset($cfg['limit'])) {
        $cfg['limit'] = 15;
    }
    if (!isset($cfg['show_link'])) {
        $cfg['show_link'] = 1;
    }
    if (!isset($cfg['action_types'])) {
        echo $_LANG['MODULE_NOT_CONFIGURED'];
        return true;
    }
    if (!$cfg['show_target']) {
        $inActions->showTargets(false);
    }
    $inActions->onlySelectedTypes($cfg['action_types']);
    $inDB->limitIs($cfg['limit']);
    $actions = $inActions->getActionsLog();
    if (!$actions) {
        return false;
    }
    cmsPage::initTemplate('modules', $cfg['tpl'])->assign('actions', $actions)->assign('cfg', $cfg)->assign('user_id', cmsUser::getInstance()->id)->display($cfg['tpl']);
    return true;
}
开发者ID:deltas1,项目名称:icms1,代码行数:30,代码来源:module.php

示例13: run

 public function run()
 {
     $user = cmsUser::getInstance();
     $id = $this->request->get('id', 0);
     if (!$id) {
         cmsCore::error404();
     }
     $folder = $this->model->getContentFolder($id);
     if (!$folder) {
         cmsCore::error404();
     }
     if ($folder['user_id'] != $user->id && !$user->is_admin) {
         cmsCore::error404();
     }
     $ctype = $this->model->getContentType($folder['ctype_id']);
     $form = $this->getForm('folder');
     // Форма отправлена?
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         // Парсим форму и получаем поля записи
         $updated_folder = $form->parse($this->request, $is_submitted);
         // Проверям правильность заполнения
         $errors = $form->validate($this, $updated_folder);
         if (!$errors) {
             // Обновляем папку и редиректим на ее просмотр
             $this->model->updateContentFolder($id, $updated_folder);
             $this->redirect(href_to('users', $folder['user_id'], array('content', $ctype['name'], $folder['id'])));
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('folder_form', array('ctype' => $ctype, 'folder' => $folder, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:34,代码来源:folder_edit.php

示例14: store

 public function store($value, $is_submitted, $old_value = null)
 {
     $config = cmsConfig::getInstance();
     $files_model = cmsCore::getModel('files');
     if ($value) {
         $file = cmsModel::yamlToArray($old_value);
         $path = $config->upload_path . $file['path'];
         @unlink($path);
         $files_model->deleteFile($file['id']);
         $old_value = null;
     }
     $uploader = new cmsUploader();
     if (!$uploader->isUploaded($this->name)) {
         return $old_value;
     }
     $allowed_extensions = $this->getOption('extensions');
     $max_size_mb = $this->getOption('max_size_mb');
     if (!trim($allowed_extensions)) {
         $allowed_extensions = false;
     }
     if (!$max_size_mb) {
         $max_size_mb = 0;
     }
     $result = $uploader->upload($this->name, $allowed_extensions, $max_size_mb * 1048576);
     if (!$result['success']) {
         if (!empty($result['path'])) {
             $uploader->remove($result['path']);
         }
         cmsUser::addSessionMessage($result['error'], 'error');
         return null;
     }
     $file = $files_model->registerFile($result['url'], $result['name']);
     return array('id' => $file['id'], 'url_key' => $file['url_key'], 'name' => $result['name'], 'size' => $result['size'], 'path' => $result['url']);
 }
开发者ID:asphix,项目名称:icms2,代码行数:34,代码来源:file.php

示例15: run

 public function run()
 {
     $new_values = $this->request->get('value', array());
     $group_id = $this->request->get('group_id', 0);
     if (!$new_values || !$group_id) {
         cmsCore::error404();
     }
     $controllers = cmsPermissions::getControllersWithRules();
     $owners = array();
     foreach ($controllers as $controller_name) {
         $controller = cmsCore::getController($controller_name);
         $subjects = $controller->getPermissionsSubjects();
         $rules = cmsPermissions::getRulesList($controller_name);
         $values = array();
         foreach ($subjects as $subject) {
             $values[$subject['name']] = cmsPermissions::getPermissions($subject['name']);
         }
         $owners[$controller_name] = array('subjects' => $subjects, 'rules' => $rules, 'values' => $values);
     }
     foreach ($owners as $controller_name => $controller) {
         foreach ($controller['subjects'] as $subject) {
             $formatted_values = array();
             foreach ($controller['rules'] as $rule) {
                 $value = isset($new_values[$rule['id']][$subject['name']]) ? $new_values[$rule['id']][$subject['name']] : null;
                 $formatted_values[$rule['id']][$group_id] = $value;
             }
             cmsPermissions::savePermissions($subject['name'], $formatted_values);
         }
     }
     cmsUser::addSessionMessage(LANG_CP_PERMISSIONS_SUCCESS, 'success');
     $this->redirectBack();
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:32,代码来源:users_group_perms_save.php


注:本文中的cmsUser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。