/** * Edit Subscription * * @return void */ public function editTask($row = null) { Request::setVar('hidemainmenu', 1); if (!is_object($row)) { $id = Request::getInt('id', 0); $row = new Subscription($this->database); $this->view->subscription = $row->getSubscription($id); } $this->view->subscription = $row; if (!$this->view->subscription) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_SERVICES_SUBSCRIPTION_NOT_FOUND')); return; } $this->view->customer = User::getInstance($this->view->subscription->uid); // check available user funds $BTL = new \Hubzero\Bank\Teller($this->database, $this->view->subscription->uid); $balance = $BTL->summary(); $credit = $BTL->credit_summary(); $funds = $balance; $this->view->funds = $funds > 0 ? $funds : '0'; // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->setLayout('edit')->display(); }
/** * Event call to return data for a specific member * * @param object $user User * @param object $member Profile * @param string $option Component name * @param string $areas Plugins to return data * @return array Return array of html */ public function onMembers($user, $member, $option, $areas) { $returnhtml = true; $returnmeta = true; // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (!array_intersect($areas, $this->onMembersAreas($user, $member)) && !array_intersect($areas, array_keys($this->onMembersAreas($user, $member)))) { $returnhtml = false; } } $arr = array('html' => '', 'metadata' => ''); $database = App::get('db'); $tables = $database->getTableList(); $table = $database->getPrefix() . 'users_points'; if (!in_array($table, $tables)) { $arr['html'] = '<p class="error">' . Lang::txt('PLG_MEMBERS_POINTS_ERROR_MISSING_TABLE') . '</p>'; return $arr; } $BTL = new \Hubzero\Bank\Teller($member->get('id')); // Build the final HTML if ($returnhtml) { $view = $this->view('default', 'history'); $view->sum = $BTL->summary(); $view->credit = $BTL->credit_summary(); $funds = $view->sum - $view->credit; $view->funds = $funds > 0 ? $funds : 0; $view->hist = $BTL->history(0); if ($this->getError()) { $view->setError($this->getError()); } $arr['html'] = $view->loadTemplate(); } // Build the HTML meant for the "about" tab's metadata overview if ($returnmeta) { $arr['metadata'] = array(); $points = $BTL->summary(); $prefix = $user->get('id') == $member->get('id') ? 'I have' : $member->get('name') . ' has'; $title = $prefix . ' ' . $points . ' points.'; $arr['metadata']['count'] = $points; } return $arr; }
/** * Display a form for adding a question * * @param object $row * @return string */ private function _new($row = null) { // Login required if (User::isGuest()) { $rtrn = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->option . '&id=' . $this->model->resource->id . '&active=' . $this->_name, false, true), 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn)), Lang::txt('PLG_RESOURCES_QUESTIONS_LOGIN_TO_ASK_QUESTION'), 'warning'); return; } Lang::load('com_answers', PATH_ROOT) || Lang::load('com_answers', PATH_CORE . DS . 'com_answers' . DS . 'site'); $view = $this->view('new', 'question'); $view->option = $this->option; $view->resource = $this->model->resource; if (is_object($row)) { $view->row = $row; } else { $view->row = new \Components\Answers\Models\Question(0); } $view->tag = $this->filters['tag']; // Are we banking? $upconfig = Component::params('com_members'); $view->banking = $upconfig->get('bankAccounts'); $view->funds = 0; if ($view->banking) { $BTL = new \Hubzero\Bank\Teller($this->database, User::get('id')); $funds = $BTL->summary() - $BTL->credit_summary(); $view->funds = $funds > 0 ? $funds : 0; } foreach ($this->getErrors() as $error) { $view->setError($error); } return $view->loadTemplate(); }
/** * Subscription form * * @return void */ public function subscribeTask() { // Login required if (User::isGuest()) { \Notify::warning(Lang::txt('COM_JOBS_PLEASE_LOGIN_ACCESS_EMPLOYER')); $this->login(); return; } // are we viewing other person's subscription? (admins only) $uid = Request::getInt('uid', 0); if ($uid && User::get('id') != $uid && !$this->_admin) { // not authorized App::abort(403, Lang::txt('COM_JOBS_ALERTNOTAUTH')); } $uid = $uid ? $uid : User::get('id'); // Set page title $this->_buildTitle(); // Set the pathway $this->_buildPathway(); // Push some styles to the template $this->css(); // Push some scripts to the template $this->js(); // Get the member's info $profile = new \Hubzero\User\Profile(); $profile->load($uid); // load Employer $employer = new Employer($this->database); if (!$employer->loadEmployer($uid)) { $employer = new Employer($this->database); $employer->uid = $uid; $employer->subscriptionid = 0; $employer->companyName = $profile->get('organization'); $employer->companyLocation = $profile->get('countryresident'); $employer->companyWebsite = $profile->get('url'); } // do we have an active subscription already? $subscription = new Subscription($this->database); if (!$subscription->loadSubscription($employer->subscriptionid, '', '', $status = array(0, 1))) { $subscription = new Subscription($this->database); $subscription->uid = $uid; $subscription->serviceid = 0; } // get subscription options $objS = new Service($this->database); $specialgroup = $this->config->get('specialgroup', ''); if ($specialgroup) { $sgroup = \Hubzero\User\Group::getInstance($specialgroup); if (!$sgroup) { $specialgroup = ''; } } $services = $objS->getServices('jobs', 1, 1, 'ordering', 'ASC', $specialgroup); if (!$services) { // setup with default info $this->_setupServices(); } // check available user funds (if paying with points) $BTL = new \Hubzero\Bank\Teller($this->database, $subscription->uid); $balance = $BTL->summary(); $credit = $BTL->credit_summary(); $funds = $balance; $funds = $funds > 0 ? $funds : '0'; // Output HTML $this->view->title = $this->_title; $this->view->config = $this->config; $this->view->subscription = $subscription; $this->view->employer = $employer; $this->view->services = $services; $this->view->funds = $funds; $this->view->uid = $uid; $this->view->emp = $this->_emp; $this->view->admin = $this->_admin; $this->view->task = $this->_task; $this->view->option = $this->_option; // Set any errors if ($this->getError()) { \Notify::error($this->getError()); } $this->view->setName('subscribe')->setLayout('default')->display(); }
/** * Display a form for adding a question * * @param object $row * @return string */ private function _new($row = null) { // Login required if (User::isGuest()) { App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($_SERVER['REQUEST_URI'])), Lang::txt('PLG_PUBLICATIONS_QUESTIONS_LOGIN_TO_ASK_QUESTION'), 'warning'); return; } $view = $this->view('new', 'question'); $view->option = $this->option; $view->publication = $this->publication; if (!is_object($row)) { $row = new \Components\Answers\Models\Question(); } $view->row = $row; $view->tag = $this->filters['tag']; // Are we banking? $upconfig = Component::params('com_members'); $view->banking = $upconfig->get('bankAccounts'); $view->funds = 0; if ($view->banking) { $BTL = new \Hubzero\Bank\Teller($this->database, User::get('id')); $funds = $BTL->summary() - $BTL->credit_summary(); $view->funds = $funds > 0 ? $funds : 0; } foreach ($this->getErrors() as $error) { $view->setError($error); } return $view->loadTemplate(); }
/** * Display a form for adding a question * * @param object $row * @return string */ private function _new($row = null) { // Login required if (User::isGuest()) { $rtrn = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->option . '&id=' . $this->publication->id . '&active=' . $this->_name, false, true), 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn)), Lang::txt('PLG_PUBLICATIONS_QUESTIONS_LOGIN_TO_ASK_QUESTION'), 'warning'); return; } if (!is_object($row)) { $row = new \Components\Answers\Models\Question(); } // Are we banking? $banking = Component::params('com_members')->get('bankAccounts'); $funds = 0; if ($banking) { $BTL = new \Hubzero\Bank\Teller(User::get('id')); $funds = $BTL->summary() - $BTL->credit_summary(); $funds = $funds > 0 ? $funds : 0; } $view = $this->view('new', 'question')->set('option', $this->option)->set('publication', $this->publication)->set('row', $row)->set('tag', $this->filters['tag'])->set('banking', $banking)->set('funds', $funds); foreach ($this->getErrors() as $error) { $view->setError($error); } return $view->loadTemplate(); }