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


PHP Req::haspost方法代码示例

本文整理汇总了PHP中Req::haspost方法的典型用法代码示例。如果您正苦于以下问题:PHP Req::haspost方法的具体用法?PHP Req::haspost怎么用?PHP Req::haspost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Req的用法示例。


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

示例1: saveAssignees

 public function saveAssignees()
 {
     $keys = array('project', 'setting');
     if (!Req::haspost($keys)) {
         return $this->fail('Insufficient data.');
     }
     $identifier = Lib::cookie(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
     if (!$isLoggedIn || $user->role != USER_ROLE_ADMIN) {
         return $this->fail('You are not authorized.');
     }
     $project = Req::post('project');
     $setting = json_decode(Req::post('setting'));
     $projectTable = Lib::table('project');
     if ($project !== 'all' && $project !== '-1' && !$projectTable->load(array('name' => $project))) {
         return $this->fail('No such project.');
     }
     if ($project !== 'all') {
         $projectAssignee = Lib::table('project_assignee');
         $projectAssignee->load(array('user_id' => $setting->id, 'project_id' => $projectTable->id));
         if ($setting->value) {
             $projectAssignee->store();
         } else {
             $projectAssignee->delete();
         }
     }
     return $this->success();
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:29,代码来源:project.php

示例2: saveSettings

 public function saveSettings()
 {
     $keys = array('project', 'setting');
     if (!Req::haspost($keys)) {
         return $this->fail('Insufficient data.');
     }
     $identifier = Lib::cookie(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
     if (!$isLoggedIn) {
         return $this->fail('You are not authorized.');
     }
     $project = Req::post('project');
     $setting = json_decode(Req::post('setting'));
     $projectTable = Lib::table('project');
     if ($project !== 'all' && $project !== '-1' && !$projectTable->load(array('name' => $project))) {
         return $this->fail('No such project.');
     }
     if ($project !== 'all') {
         $userSettings = Lib::table('user_settings');
         if ($project === '-1') {
             $projectTable->id = '-1';
         }
         if (!$userSettings->load(array('user_id' => $user->id, 'project_id' => $projectTable->id))) {
             $userSettings->load(array('user_id' => $user->id, 'project_id' => 0));
             $userSettings->isNew = true;
             $userSettings->id = 0;
             $userSettings->project_id = $projectTable->id;
         }
         $data = $userSettings->getData();
         $data[$setting->name] = $setting->value;
         $userSettings->data = $data;
         $userSettings->store();
     } else {
         $settings = Lib::model('user_settings')->getSettings(array('user_id' => $user->id));
         $userSettings = Lib::table('user_settings');
         $userSettings->load(array('user_id' => $user->id, 'project_id' => 0));
         $data = $userSettings->getData();
         $data[$setting->name] = $setting->value;
         $userSettings->data = $data;
         $userSettings->store();
         foreach ($settings as $row) {
             $data = $row->getData();
             $data[$setting->name] = $setting->value;
             $row->data = $data;
             $row->store();
         }
     }
     return $this->success();
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:50,代码来源:user.php

示例3: create

 public function create()
 {
     $keys = array('username', 'password');
     if (!Req::haspost($keys)) {
         return $this->fail();
     }
     $referral = Req::post('referral');
     if (empty($referral) && Lib::model('admin')->hasAdmins()) {
         return $this->fail();
     }
     $post = Req::post($keys);
     extract($post);
     $admin = Lib::table('admin');
     $admin->username = $username;
     $admin->setPassword($password);
     if (!$admin->store()) {
         return $this->fail();
     }
     $admin->login();
     return $this->success();
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:21,代码来源:admin.php

示例4: update

 public function update()
 {
     if (!Req::haspost(['id', 'name'])) {
         return $this->fail('Insufficient data.');
     }
     $identifier = Lib::cookie(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(['identifier' => $identifier]);
     if (!$isLoggedIn || $user->role != USER_ROLE_ADMIN) {
         return $this->fail('You are not authorized.');
     }
     $id = Req::post('id');
     $name = Req::post('name');
     $table = Lib::table('category');
     if (!$table->load($id)) {
         return $this->false('Invalid data.');
     }
     $table->name = $name;
     $table->store();
     return $this->success();
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:21,代码来源:category.php

示例5: assign

 public function assign()
 {
     $keys = array('id', 'assigneeid');
     if (!Req::haspost($keys)) {
         return $this->fail('Insufficient data.');
     }
     $identifier = Lib::cookie(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
     if (!$isLoggedIn) {
         return $this->fail('You are not authorized.');
     }
     $post = Req::post($keys);
     $reportTable = Lib::table('report');
     if (!$reportTable->load($post['id'])) {
         return $this->fail('No such report.');
     }
     $reportTable->assignee_id = $post['assigneeid'];
     $reportTable->store();
     if (!empty($post['assigneeid']) && $post['assigneeid'] != $user->id) {
         $projectTable = Lib::table('project');
         $projectTable->load($reportTable->project_id);
         $targetUser = Lib::table('user');
         $targetUser->load($post['assigneeid']);
         $targetUserSettings = $targetUser->getSettings($projectTable)->getData();
         if ($targetUserSettings['assign']) {
             $notificationData = ['to' => $targetUser->email, 'text' => $user->nick . ' assigned you a report ticket.', 'username' => 'Project Report Assignment', 'icon_emoji' => ':gift:', 'attachments' => [['fallback' => '<' . $reportTable->getLink() . '|Report ticket ID ' . $reportTable->id . '>.', 'color' => '#00bcd4', 'title' => $projectTable->name, 'title_link' => $reportTable->getLink(), 'text' => $reportTable->content]]];
             Lib::load('helper/notification');
             NotificationHelper::send($notificationData);
             // $slackMessage = Lib::helper('slack')->newMessage();
             // $slackMessage->to($post['assigneeid']);
             // $slackMessage->message($user->nick . ' assigned you a report ticket.');
             // $slackMessage->username = 'Project Report Assignment';
             // $slackMessage->icon_emoji = ':gift:';
             // $attachment = $slackMessage->newAttachment();
             // $attachment->fallback = '<' . $reportTable->getLink() . '|Report ticket ID ' . $reportTable->id . '>.';
             // $attachment->color = '#00bcd4';
             // $attachment->title = $projectTable->name;
             // $attachment->title_link = $reportTable->getLink();
             // $attachment->text = $reportTable->content;
             // $slackMessage->send();
         }
     }
     return $this->success();
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:45,代码来源:report.php

示例6: sync

 public function sync()
 {
     if (!Req::haspost('reports', 'ids')) {
         return $this->fail('Insufficient data.');
     }
     $identifier = Lib::cookie(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
     if (!$isLoggedIn) {
         return $this->fail('You are not authorized.');
     }
     $reports = json_decode(Req::post('reports'));
     $ids = Req::post('ids');
     $updated = array();
     $commentModel = Lib::model('comment');
     $comments = $commentModel->getComments(array('report_id' => $ids));
     $commentsByReportId = array();
     foreach ($comments as $comment) {
         $commentsByReportId[$comment->report_id][$comment->id] = $comment;
     }
     foreach ($reports as $id => $report) {
         $newTotalComments = empty($commentsByReportId[$id]) ? 0 : count($commentsByReportId[$id]);
         if ($report->totalComments == $newTotalComments) {
             continue;
         }
         $updated[$id] = array('totalComments' => $newTotalComments, 'comments' => array());
         if (!$report->commentsLoaded) {
             continue;
         }
         $view = Lib::view('embed');
         foreach ($commentsByReportId[$id] as $commentid => $newComment) {
             if (in_array($commentid, $report->comments)) {
                 $updated[$id]['comments'][$commentid] = false;
                 continue;
             }
             $updated[$id]['comments'][$commentid] = $view->loadTemplate('comment-item', array('comment' => $comment, 'user' => $user));
         }
     }
     return $this->success($updated);
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:40,代码来源:comment.php


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