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


PHP Lib::model方法代码示例

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


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

示例1: filter

 public function filter()
 {
     $keys = array('state', 'assignee', 'sort', 'project');
     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);
     $projectTable = Lib::table('project');
     if ($post['project'] !== 'all' && !$projectTable->load(array('name' => $post['project']))) {
         return $this->fail('No such project.');
     }
     $cookie = Lib::cookie();
     foreach ($keys as $key) {
         $cookie->set('filter-' . $key, $post[$key]);
     }
     $reportModel = Lib::model('report');
     $reports = $reportModel->getItems(array('state' => constant('STATE_' . strtoupper($post['state'])), 'assignee_id' => $post['assignee'], 'order' => 'date', 'direction' => $post['sort'], 'project_id' => $projectTable->id));
     $userModel = Lib::model('user');
     $assignees = $userModel->getProjectAssignees($projectTable->id);
     $html = '';
     $view = Lib::view('embed');
     foreach ($reports as $report) {
         $html .= $view->loadTemplate('report-item', array('report' => $report, 'assignees' => $assignees, 'user' => $user));
     }
     return $this->success($html);
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:32,代码来源:report.php

示例2: main

 public function main()
 {
     $this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com');
     $cookie = Lib::cookie();
     $identifier = $cookie->get(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
     $this->set('user', $user);
     $this->set('isLoggedIn', $isLoggedIn);
     $this->js[] = $isLoggedIn ? 'inbox' : 'login';
     if ($isLoggedIn) {
         array_shift($this->js);
         $id = Req::get('id');
         if (empty($id)) {
             Lib::redirect('index');
         }
         $report = Lib::table('report');
         if (!$report->load($id)) {
             $this->template = 'no-report';
             return;
         }
         $report->init();
         $assignees = Lib::model('user')->getProjectAssignees($report->project_id);
         $projectTable = Lib::table('project');
         $projectTable->load($report->project_id);
         $this->set('report', $report);
         $this->set('assignees', $assignees);
         $this->set('project', $projectTable);
     }
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:30,代码来源:report.php

示例3: main

 public function main()
 {
     $filterProject = Req::get('project');
     if (empty($filterProject)) {
         $this->template = 'empty-project';
         return;
     }
     $projectTable = Lib::table('project');
     if (!$projectTable->load(array('name' => $filterProject))) {
         $this->set('name', $filterProject);
         $this->template = 'new-project';
         return;
     }
     $this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com');
     $cookie = Lib::cookie();
     $identifier = $cookie->get(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
     $this->set('user', $user);
     $this->set('filterProject', $filterProject);
     $this->set('filterSettingsProject', $filterProject);
     $this->set('isLoggedIn', $isLoggedIn);
     if (!$isLoggedIn) {
         $this->js[] = 'login';
     }
     if ($isLoggedIn) {
         $this->js[] = 'inbox';
         $this->js[] = 'settings';
         array_shift($this->js);
         $userModel = Lib::model('user');
         $assignees = $userModel->getProjectAssignees($projectTable->id);
         $users = $userModel->getUsers();
         $filterState = $cookie->get('filter-state', 'pending');
         $filterAssignee = $cookie->get('filter-assignee', empty($assignees[$user->id]) ? 'all' : $user->id);
         $filterSort = $cookie->get('filter-sort', 'asc');
         $reportModel = Lib::model('report');
         $reports = $reportModel->getItems(array('state' => constant('STATE_' . strtoupper($filterState)), 'assignee_id' => $filterAssignee, 'order' => 'date', 'direction' => $filterSort, 'project_id' => $projectTable->id));
         $userSettingsTable = Lib::table('user_settings');
         if (!$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => $projectTable->id))) {
             $userSettingsTable->load(array('user_id' => $user->id, 'project_id' => 0));
         }
         $userSettings = $userSettingsTable->getData();
         if ($userSettings['color'] !== 'cyan' && $userSettings['color'] !== 'custom') {
             $this->css[] = 'theme-' . str_replace(' ', '', $userSettings['color']);
         }
         $categories = Lib::model('category')->getCategories(['projectid' => $projectTable->id]);
         $this->set('filterState', $filterState);
         $this->set('filterAssignee', $filterAssignee);
         $this->set('filterSort', $filterSort);
         $this->set('reports', $reports);
         $this->set('assignees', $assignees);
         $this->set('userSettings', $userSettings);
         $this->set('users', $users);
         $this->set('projectTable', $projectTable);
         $this->set('categories', $categories);
     }
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:57,代码来源:embed.php

示例4: form

 public function form()
 {
     $ref = Req::get('ref');
     $this->set('ref', $ref);
     $model = Lib::model('admin');
     if (!$model->hasAdmins()) {
         $this->template = 'formcreate';
         return;
     }
     $this->template = 'form';
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:11,代码来源:admin.php

示例5: init

 public function init()
 {
     $owner = Lib::table('user');
     $owner->load($this->user_id);
     $this->picture = $owner->picture;
     $this->nick = $owner->nick;
     $this->initial = $owner->initial;
     if (!empty($this->assignee_id)) {
         $assignee = Lib::table('user');
         $assignee->load($this->assignee_id);
         $this->assignee = $assignee;
     }
     $screenshots = Lib::model('report')->getScreenshotsByReportId($this->id);
     $this->screenshots = array();
     foreach ($screenshots as $screenshot) {
         $this->screenshots[] = $screenshot->filename;
     }
     $this->comments = Lib::model('comment')->getComments(array('report_id' => $this->id));
     $this->totalcomments = count($this->comments);
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:20,代码来源:report.php

示例6: 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

示例7: 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

示例8: 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


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