Пример #1
0
 public function deleteAction()
 {
     $feature = $this->byId();
     $this->featureService->deleteFeature($feature);
     if (!$this->_getParam('_ajax')) {
         $this->redirect('project', 'view', array('id' => $feature->projectid, '#features'));
     }
 }
Пример #2
0
 /**
  * 根据特性ID获取商品特性
  *
  * @param integer $feature_id
  * @return array
  */
 public static function get($feature_id)
 {
     $feature = FeatureService::get_instance()->get($feature_id);
     $feature = coding::decode_feature($feature);
     $options = FeatureoptionService::get_instance()->index(array('where' => array('feature_id' => $feature['id']), 'orderby' => 'order'));
     $feature['options'] = array();
     foreach ($options as $option) {
         unset($option['feature_id']);
         unset($option['order']);
         $feature['options'][$option['id']] = $option;
     }
     return $feature;
 }
Пример #3
0
 /**
  * 根据 featureoption_id 获取该 featureoption 的兄弟记录
  * 
  * @param $featureoption_id  int
  * @param $clear_self  bool
  * @return array
  */
 public function get_brothers_by_featureoption_id($featureoption_id, $clear_self = FALSE)
 {
     try {
         $featureoption = self::get_instance()->get($featureoption_id);
         $feature_id = $featureoption['feature_id'];
         $featureoptions = FeatureService::get_instance()->get_featureoptions_by_feature_id($feature_id);
         if ($clear_self == TRUE) {
             foreach ($featureoptions as $index => $featureoption) {
                 if ($featureoption['id'] == $featureoptions_id) {
                     unset($featureoptions[$index]);
                 }
             }
         }
         return $featureoptions;
     } catch (MyRuntimeException $ex) {
         throw $ex;
     }
 }
Пример #4
0
 /**
  * Override the edit action to supply some selectable relationships
  *
  * @param MappedObject $model
  */
 public function prepareForEdit($model = null)
 {
     if ($this->view->model == null) {
         $this->flash("Invalid request specified");
         $this->redirect('error');
         return;
     }
     $this->view->issueHistory = $this->issueService->getIssueHistory($this->view->model);
     $pid = (int) $this->_getParam('projectid');
     $cid = (int) $this->_getParam('clientid');
     if ($this->view->model->projectid) {
         $pid = $this->view->model->projectid;
     }
     if ($this->view->model->clientid) {
         $cid = $this->view->model->clientid;
     }
     // Which one?
     if ($pid) {
         $this->view->project = $this->projectService->getProject($pid);
         $this->view->client = $this->clientService->getClient($this->view->project->clientid);
         // figure out the releases available for this project
         $this->view->releases = $this->issueService->getProjectReleases($this->view->project);
     } else {
         if ($cid) {
             $this->view->client = $this->clientService->getClient($cid);
             $this->view->releases = array();
         }
     }
     if ($this->view->client != null) {
         $this->view->categories = $this->issueService->getIssueCategoriesForCompany($this->view->client);
     } else {
         $this->view->categories = array();
     }
     // if it's a new issue, and it's a normal user set it to be private by default
     // User can always specify a different one though
     if (!$this->view->model->id && za()->getUser()->hasRole(User::ROLE_USER)) {
         $this->view->model->isprivate = true;
     }
     $this->view->users = $this->userService->getUserList();
     $this->view->severities = $this->view->model->constraints['severity']->getValues();
     $this->view->types = $this->view->model->constraints['issuetype']->getValues();
     $this->view->statuses = $this->view->model->constraints['status']->getValues();
     if ($this->view->model->id) {
         $this->view->notes = $this->notificationService->getNotesFor($this->view->model);
         $this->view->existingWatch = $this->notificationService->getWatch(za()->getUser(), $this->view->model->id, 'Issue');
         $this->view->userStatuses = $this->view->model->getUserStatuses();
         $clientUsers = $this->userService->getUsersForClient($this->view->model->clientid);
         foreach ($this->view->users as $user) {
             $clientUsers->append($user);
         }
         $this->view->allUsers = $clientUsers;
         $this->view->subscribers = $this->notificationService->getSubscribers($this->view->model->id, 'Issue');
         $this->view->project = $this->projectService->getProject($this->view->model->projectid);
         $this->view->client = $this->clientService->getClient($this->view->model->clientid);
         $this->view->files = $this->issueService->getIssueFiles($this->view->model);
         $path = 'Clients/' . $this->view->client->title . '/Issues/' . $this->view->model->id;
         $this->view->filePath = $path;
         // Get all the features for this project
         $this->view->projectFeatures = $this->featureService->getFeatures(array('projectid=' => $this->view->model->projectid));
         $this->view->projectTasks = $this->projectService->getTasks(array('projectid=' => $this->view->project->id), 'title asc');
         $this->view->linkedTasks = $this->itemLinkService->getLinkedItems($this->view->model, 'from', 'Task');
         $this->view->linkedToFeatures = $this->itemLinkService->getLinkedItems($this->view->model, 'from', 'Feature');
         $this->view->linkedFromFeatures = $this->itemLinkService->getLinkedItems($this->view->model, 'to', 'Feature');
     }
     $this->view->clients = $this->clientService->getClients();
     if ($this->view->client) {
         $this->view->projects = $this->projectService->getProjectsForClient($this->view->client->id);
     }
 }
Пример #5
0
 function get_site_data()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //$profiler = new Profiler;
         //* 初始化返回数据 */
         $return_data = array('brand_list' => NULL, 'attribute_list' => NULL, 'feature_list' => NULL);
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         //* 实现功能后屏蔽此异常抛出 */
         //throw new MyRuntimeException('Not Implemented',501);
         //必须为ajax请求
         if (!$this->is_ajax_request()) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         //* 权限验证 */
         $site_id_list = role::check('product_classify', 0, 0);
         if (empty($site_id_list)) {
             throw new MyRuntimeException('Access Denied', 403);
         }
         if (isset($request_data['site_id']) && is_numeric($request_data['site_id'])) {
             if (!in_array($request_data['site_id'], $site_id_list)) {
                 throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
             }
         }
         //数据验证
         if (!isset($request_data['site_id']) || !is_numeric($request_data['site_id'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         // 调用底层服务
         $classify_service = ClassifyService::get_instance();
         //请求站点品牌列表
         $brands = BrandService::get_instance()->get_brands_by_site_id($request_data['site_id']);
         foreach ($brands as $val) {
             $return_data['brand_list'] .= '<option value=' . $val['id'] . '>' . $val['name'] . '</option>';
         }
         //请求站点规格列表
         $attributes = AttributeService::get_instance()->get_attributes_by_site_id($request_data['site_id']);
         foreach ($attributes as $val) {
             $return_data['attribute_list'] .= '<option value=' . $val['id'] . '>' . $val['name'] . '</option>';
         }
         //请求站点规格列表
         $features = FeatureService::get_instance()->get_features_by_site_id($request_data['site_id']);
         foreach ($features as $val) {
             $return_data['feature_list'] .= '<option value=' . $val['id'] . '>' . $val['name'] . '</option>';
         }
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '';
         $return_struct['content'] = $return_data;
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             //* 模板输出 */
             $content = new View($this->package . '/' . $this->class_name . '/' . __FUNCTION__);
             //* 变量绑定 */
             $this->template->title = Kohana::config('site.name');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Пример #6
0
 protected function getChildDataProject(Project $project, $options = null)
 {
     $data = array();
     switch ($options) {
         case 'subprojects':
             $children = $project->getSubProjects();
             foreach ($children as $child) {
                 $item = new stdClass();
                 $item->id = get_class($child) . '-' . $child->id;
                 $item->text = $child->title . ' <a href="' . build_url('project', 'view', array('id' => $child->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>';
                 $item->expanded = false;
                 $item->classes = "project-item iconed";
                 $item->hasChildren = true;
                 $data[] = $item;
             }
             break;
         case 'milestones':
             $children = $project->getMilestones();
             foreach ($children as $child) {
                 $item = new stdClass();
                 $item->id = get_class($child) . '-' . $child->id . '-tasks';
                 $item->text = $child->title . ' <a href="' . build_url('project', 'view', array('id' => $child->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>';
                 $item->expanded = false;
                 $item->classes = "tree-milestone iconed";
                 $item->hasChildren = true;
                 $data[] = $item;
             }
             break;
         case 'features':
             $items = $this->featureService->getFeatures(array('projectid=' => $project->id));
             foreach ($items as $child) {
                 $item = new stdClass();
                 $item->id = get_class($child) . '-' . $child->id . '-tasks';
                 $item->text = $child->title . ' <a href="' . build_url('feature', 'edit', array('id' => $child->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>';
                 $item->expanded = false;
                 $item->classes = "tree-feature iconed";
                 $item->hasChildren = true;
                 $data[] = $item;
             }
             break;
         case 'requests':
             $items = $this->issueService->getIssues(array('projectid=' => $project->id, 'status <> ' => Issue::STATUS_CLOSED));
             foreach ($items as $child) {
                 $item = new stdClass();
                 $item->id = get_class($child) . '-' . $child->id . '-tasks';
                 $item->text = $child->title . ' <a href="' . build_url('issue', 'edit', array('id' => $child->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>';
                 $item->expanded = false;
                 $item->classes = "tree-request iconed";
                 $item->hasChildren = true;
                 $data[] = $item;
             }
             break;
         case 'tasks':
             $items = $this->projectService->getTasks(array('projectid=' => $project->id, 'complete=' => 0));
             foreach ($items as $child) {
                 $item = new stdClass();
                 $item->id = get_class($child) . '-' . $child->id . '';
                 ob_start();
                 $this->view->percentageBar($child->getPercentage());
                 $bar = ob_get_clean();
                 $item->text = $bar . $child->title . ' <a href="' . build_url('task', 'edit', array('id' => $child->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>';
                 $item->expanded = false;
                 $item->classes = "tree-task iconed";
                 $item->hasChildren = false;
                 $data[] = $item;
             }
             break;
         default:
             $subProjects = $project->getSubProjects();
             if (count($subProjects)) {
                 $option = new stdClass();
                 $option->text = 'Sub Projects';
                 $option->id = get_class($project) . '-' . $project->id . '-subprojects';
                 $option->classes = "tree-folder iconed";
                 $option->hasChildren = true;
                 $data[] = $option;
             }
             if ($project->hasMilestones()) {
                 $option = new stdClass();
                 $option->text = 'Milestones';
                 $option->id = get_class($project) . '-' . $project->id . '-milestones';
                 $option->classes = "tree-folder iconed";
                 $option->hasChildren = true;
                 $data[] = $option;
             }
             // see if there are features
             $items = $this->featureService->getFeatures(array('projectid=' => $project->id));
             if (count($items)) {
                 $option = new stdClass();
                 $option->text = 'Features';
                 $option->id = get_class($project) . '-' . $project->id . '-features';
                 $option->classes = "tree-folder iconed";
                 $option->hasChildren = true;
                 $data[] = $option;
             }
             // see if there are requests
             $items = $this->issueService->getIssues(array('projectid=' => $project->id, 'status <> ' => Issue::STATUS_CLOSED));
             if (count($items)) {
                 $option = new stdClass();
                 $option->text = 'Requests';
                 $option->id = get_class($project) . '-' . $project->id . '-requests';
                 $option->classes = "tree-folder iconed";
                 $option->hasChildren = true;
                 $data[] = $option;
             }
             break;
     }
     return $data;
 }