Exemple #1
0
 /**
  * Edit a category
  *
  * @return  void
  */
 public function editTask($row = null)
 {
     Request::setVar('hidemainmenu', 1);
     $this->view->wishlist = Request::getInt('wishlist', 0);
     if (!is_object($row)) {
         // Incoming
         $id = Request::getVar('id', array(0));
         if (is_array($id) && !empty($id)) {
             $id = $id[0];
         }
         // Load category
         $row = new Wish($this->database);
         $row->load($id);
     }
     $this->view->row = $row;
     if (!$this->view->row->id) {
         $this->view->row->wishlist = $this->view->wishlist;
     } else {
         if (!$this->view->wishlist) {
             $this->view->wishlist = $this->view->row->wishlist;
         }
     }
     /*
     $m = new Models\AdminWish();
     $this->view->form = $m->getForm();
     */
     $obj = new Wishlist($this->database);
     $filters = array();
     $filters['sort'] = 'title';
     $filters['sort_Dir'] = 'ASC';
     $this->view->lists = $obj->getRecords($filters);
     // who are list owners?
     $this->admingroup = $this->config->get('group', 'hubadmin');
     $objOwner = new Owner($this->database);
     $objG = new OwnerGroup($this->database);
     $this->view->ownerassignees = array();
     $this->view->ownerassignees[-1] = array();
     $none = new stdClass();
     $none->id = '-1';
     $none->name = Lang::txt('COM_WISHLIST_SELECT');
     $this->view->ownerassignees[-1][] = $none;
     $this->view->assignees = null;
     if ($this->view->lists) {
         foreach ($this->view->lists as $k => $list) {
             if ($list->category == 'resource') {
                 include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'resource.php';
                 $list->resource = new \Components\Resources\Tables\Resource($this->database);
                 $list->resource->load($list->referenceid);
             }
             $this->view->ownerassignees[$list->id] = array();
             $none = new stdClass();
             $none->id = '0';
             $none->name = Lang::txt('COM_WISHLIST_NONE');
             $this->view->ownerassignees[$list->id][] = $none;
             $owners = $objOwner->get_owners($list->id, $this->admingroup, $list);
             if (count($owners['individuals']) > 0) {
                 $query = "SELECT a.id, a.name FROM `#__users` AS a WHERE a.block = '0' AND a.id IN (" . implode(',', $owners['individuals']) . ") ORDER BY a.name";
                 $this->database->setQuery($query);
                 $users = $this->database->loadObjectList();
                 foreach ($users as $row2) {
                     $this->view->ownerassignees[$list->id][] = $row2;
                 }
                 if ($list->id == $this->view->row->wishlist) {
                     $this->view->assignees = $this->view->ownerassignees[$list->id];
                 }
             }
         }
     }
     // Get the plan for this wish
     $objPlan = new Plan($this->database);
     $plan = $objPlan->getPlan($this->view->row->id);
     $this->view->plan = $plan ? $plan[0] : $objPlan;
     // Get tags on this wish
     include_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'tags.php';
     $tagging = new Tags($this->view->row->id);
     $this->view->tags = $tagging->render('string');
     // Set any errors
     foreach ($this->getErrors() as $error) {
         \Notify::error($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }