/** * Event call to determine if this plugin should return data * * @return array Plugin name and title */ public function &onProjectAreas($alias = NULL) { $area = array('name' => $this->_name, 'title' => Lang::txt('COM_PROJECTS_TAB_FILES'), 'submenu' => 'Assets', 'show' => true, 'icon' => 'f016'); if ($this->params->get('default_action', 'browse') == 'connections') { $model = new Components\Projects\Models\Project(Request::getVar('alias', '')); $active = Request::getInt('connection', 0); $area['children'] = array(); $area['children'][] = array('name' => 'default', 'title' => sprintf($this->params->get('default_connection_name', '%s Master Repository'), $model->get('title')), 'url' => $model->link('files') . '&action=browse', 'class' => 'filesystem default' . (Request::getVar('action') == 'browse' && !$active ? ' active' : ''), 'icon' => 'f0a0'); if ($model->exists() && $model->access('member')) { $connections = Components\Projects\Models\Orm\Project::oneOrFail($model->get('id'))->connections()->thatICanView(); if ($connections->count()) { foreach ($connections as $connection) { //$imgRel = '/plugins/filesystem/' . $connection->provider->alias . '/assets/img/icon.png'; //$img = (is_file(PATH_APP . DS . $imgRel)) ? '/app' . $imgRel : '/core' . $imgRel; $area['children'][] = array('title' => $connection->name, 'name' => $connection->provider->alias, 'url' => $model->link('files') . '&action=browse&connection=' . $connection->id, 'class' => 'filesystem ' . $connection->provider->alias . (!$connection->isShared() ? ' private' : '') . ($active == $connection->id ? ' active' : ''), 'icon' => 'f0a0'); } } } } return $area; }
/** * Save item * * @return string */ protected function _save() { if (User::isGuest()) { $this->setError(Lang::txt('MEMBERS_LOGIN_NOTICE')); return; } if (User::get('id') != $this->member->get('id')) { $this->setError(Lang::txt('PLG_MEMBERS_TODO_NOT_AUTHORIZED')); return $this->_browse(); } // Check for request forgeries Request::checkToken(); // Incoming $content = Request::getVar('content', ''); $projectid = Request::getInt('projectid', 0); $due = trim(Request::getVar('due', '')); $model = new \Components\Projects\Models\Project($projectid); if (!$content) { $this->setError(Lang::txt('PLG_MEMBERS_TODO_ERROR_PROVIDE_CONTENT')); return $this->_browse(); } if (!$model->exists() || !$model->access('content')) { $this->setError(Lang::txt('PLG_MEMBERS_TODO_ERROR_ACCESS_PROJECT')); return $this->_browse(); } // Initiate extended database class $objTD = new \Components\Projects\Tables\Todo($this->database); $content = rtrim(stripslashes($content)); $objTD->content = $content ? $content : $objTD->content; $objTD->content = \Hubzero\Utility\Sanitize::stripAll($objTD->content); $objTD->created_by = $this->member->get('id'); $objTD->created = Date::toSql(); $objTD->projectid = $model->get('id'); if (strlen($objTD->content) > 255) { $objTD->details = $objTD->content; } $objTD->content = \Hubzero\Utility\String::truncate($objTD->content, 255); if ($due && $due != 'mm/dd/yyyy') { $date = explode('/', $due); if (count($date) == 3) { $month = $date[0]; $day = $date[1]; $year = $date[2]; if (intval($month) && intval($day) && intval($year)) { if (strlen($day) == 1) { $day = '0' . $day; } if (strlen($month) == 1) { $month = '0' . $month; } if (checkdate($month, $day, $year)) { $objTD->duedate = Date::of(mktime(0, 0, 0, $month, $day, $year))->toSql(); } } } } else { $objTD->duedate = ''; } // Get last order $lastorder = $objTD->getLastOrder($model->get('id')); $objTD->priority = $lastorder ? $lastorder + 1 : 1; // Store content if (!$objTD->store()) { $this->setError($objTD->getError()); return $this->_browse(); } else { // Record activity $aid = $model->recordActivity(Lang::txt('PLG_MEMBERS_TODO_ACTIVITY_TODO_ADDED'), $objTD->id, 'to do', Route::url('index.php?option=com_projects&alias=' . $model->get('alias') . '&active=todo&action=view&todoid=' . $objTD->id), 'todo', 1); // Store activity ID if ($aid) { $objTD->activityid = $aid; $objTD->store(); } } App::redirect(Route::url($this->member->link() . '&active=' . $this->_name), Lang::txt('PLG_MEMBERS_TODO_SAVED')); }