Esempio n. 1
0
 /**
  * Display Super Group Pages
  *
  * @return     array
  */
 public static function superGroupPhpPages($group)
 {
     // var to hold content
     $phpPageContent = null;
     // make sure this is a super group
     if (!$group->isSuperGroup()) {
         return $phpPageContent;
     }
     // get URI path
     $path = Request::path();
     $path = trim(str_replace('groups' . DS . $group->get('cn'), '', $path), DS);
     // make sure we have a path. if no path means were attempting to access the home page
     if ($path == '') {
         $path = 'overview';
     }
     // get group upload path
     $uploadPath = Component::params('com_groups')->get('uploadpath');
     // build path to php page in template
     $templatePhpPagePath = PATH_APP . DS . trim($uploadPath, DS) . DS . $group->get('gidNumber') . DS . 'pages' . DS . $path . '.php';
     // if the file is not a valid path
     if (!is_file($templatePhpPagePath)) {
         return $phpPageContent;
     }
     // include & render php file
     ob_start();
     include $templatePhpPagePath;
     $phpPageContent = ob_get_contents();
     ob_end_clean();
     //create new group document helper
     $groupDocument = new Document();
     // set group doc needed props
     // parse and render content
     $groupDocument->set('group', $group)->set('page', null)->set('document', $phpPageContent)->parse()->render();
     // get doc content
     $phpPageContent = $groupDocument->output();
     // run as closure to ensure no $this scope
     $eval = function () use($phpPageContent) {
         ob_start();
         eval("?>{$phpPageContent}<?php ");
         $document = ob_get_clean();
         return $document;
     };
     $phpPageContent = $eval();
     // create view object
     $view = new \Hubzero\Component\View(array('name' => 'pages', 'layout' => '_view_php'));
     // if super group add super group folder
     // to available paths
     if ($group->isSuperGroup()) {
         $base = $group->getBasePath();
         $view->addTemplatePath(PATH_APP . $base . DS . 'template');
     }
     $view->content = $phpPageContent;
     return $view->loadTemplate();
 }
Esempio n. 2
0
 /**
  * Handles the actual sending of emails (or queuing them to be sent)
  *
  * @param  int    $user     the user id to send to
  * @param  array  $posts    the posts to include in the email
  * @param  string $interval the distribution interval
  * @return bool
  **/
 private function sendEmail($user, $posts, $interval = 'daily')
 {
     $eview = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_forum' . DS . 'site', 'name' => 'emails', 'layout' => 'digest_plain'));
     $eview->option = 'com_forum';
     $eview->delimiter = '~!~!~!~!~!~!~!~!~!~!';
     $eview->posts = $posts;
     $eview->interval = $interval;
     $plain = $eview->loadTemplate();
     $plain = str_replace("\n", "\r\n", $plain);
     // HTML
     $eview->setLayout('digest_html');
     $html = $eview->loadTemplate();
     $html = str_replace("\n", "\r\n", $html);
     $user = User::getInstance($user);
     // Build message
     $message = App::get('mailer');
     $message->setSubject(Lang::txt('PLG_GROUPS_FORUM') . ': ' . Lang::txt('PLG_GROUPS_FORUM_SUBJECT_EMAIL_DIGEST'))->addFrom(Config::get('mailfrom'), Config::get('sitename'))->addTo($user->get('email'), $user->get('name'))->addHeader('X-Component', 'com_forum')->addHeader('X-Component-Object', 'groups_forum_email_digest');
     $message->addPart($plain, 'text/plain');
     $message->addPart($html, 'text/html');
     // Send mail
     if (!$message->send($this->params->get('email_transport_mechanism'))) {
         $this->setError('Failed to mail %s', $user->get('email'));
     }
     $mailed[] = $user->get('username');
 }
Esempio n. 3
0
 /**
  * Parse loaded data for further processing
  *
  * @access public
  * @return string
  */
 public function parse($dryRun = 1, $output = NULL)
 {
     // Set common props
     $this->_uid = User::get('id');
     // No errors. Let's rewind and parse
     $this->reader = new \XMLReader();
     $this->reader->XML($this->data);
     // Load classes
     $objCat = new Tables\Category($this->database);
     $objL = new Tables\License($this->database);
     // Get base type
     $base = Request::getVar('base', 'files');
     // Determine publication master type
     $mt = new Tables\MasterType($this->database);
     $choices = $mt->getTypes('alias', 1);
     $mastertype = in_array($base, $choices) ? $base : 'files';
     // Get type params
     $mType = $mt->getType($mastertype);
     // Get curation model for the type
     $curationModel = new \Components\Publications\Models\Curation($mType->curation);
     // Get defaults from manifest
     $title = $curationModel && isset($curationModel->_manifest->params->default_title) ? $curationModel->_manifest->params->default_title : 'Untitled Draft';
     $title = $title ? $title : 'Untitled Draft';
     $cat = isset($curationModel->_manifest->params->default_category) ? $curationModel->_manifest->params->default_category : 1;
     $this->curationModel = $curationModel;
     // Get element IDs
     $elementPrimeId = 1;
     $elementGalleryId = 2;
     $elementSupportId = 3;
     if ($this->curationModel) {
         $elements1 = $this->curationModel->getElements(1);
         $elements2 = $this->curationModel->getElements(2);
         $elements3 = $this->curationModel->getElements(3);
         $elementPrimeId = !empty($elements1) ? $elements1[0]->id : $elementPrimeId;
         $elementGalleryId = !empty($elements3) ? $elements3[0]->id : $elementGalleryId;
         $elementSupportId = !empty($elements2) ? $elements2[0]->id : $elementSupportId;
     }
     // Get project repo path
     $this->projectPath = $this->project->repo()->get('path');
     // Parse data
     $items = array();
     while ($this->reader->read()) {
         if ($this->reader->name === 'publication') {
             $node = new \SimpleXMLElement($this->reader->readOuterXML());
             // Check that category exists
             $category = isset($node->cat) ? $node->cat : 'dataset';
             $catId = $objCat->getCatId($category);
             $item['category'] = $category;
             $item['type'] = $mastertype;
             $item['errors'] = array();
             $item['tags'] = array();
             $item['authors'] = array();
             // Publication properties
             $item['publication'] = new Tables\Publication($this->database);
             $item['publication']->master_type = $mType->id;
             $item['publication']->category = $catId ? $catId : $cat;
             $item['publication']->project_id = $this->project->get('id');
             $item['publication']->created_by = $this->_uid;
             $item['publication']->created = Date::toSql();
             $item['publication']->access = 0;
             // Version properties
             $item['version'] = new Tables\Version($this->database);
             $item['version']->title = isset($node->title) && trim($node->title) ? trim($node->title) : $title;
             $item['version']->abstract = isset($node->synopsis) ? trim($node->synopsis) : '';
             $item['version']->description = isset($node->abstract) ? trim($node->abstract) : '';
             $item['version']->version_label = isset($node->version) ? trim($node->version) : '1.0';
             $item['version']->release_notes = isset($node->notes) ? trim($node->notes) : '';
             // Check license
             $license = isset($node->license) ? $node->license : '';
             $item['license'] = $objL->getLicenseByTitle($license);
             if (!$item['license']) {
                 $item['errors'][] = Lang::txt('COM_PUBLICATIONS_BATCH_ITEM_ERROR_LICENSE');
             } else {
                 $item['version']->license_type = $item['license']->id;
             }
             // Pick up files
             $item['files'] = array();
             if ($node->content) {
                 $i = 1;
                 foreach ($node->content->file as $file) {
                     $this->collectFileData($file, 1, $i, $item, $elementPrimeId);
                     $i++;
                 }
             }
             // Supporting docs
             if ($node->supportingmaterials) {
                 $i = 1;
                 foreach ($node->supportingmaterials->file as $file) {
                     $this->collectFileData($file, 2, $i, $item, $elementSupportId);
                     $i++;
                 }
             }
             // Gallery
             if ($node->gallery) {
                 $i = 1;
                 foreach ($node->gallery->file as $file) {
                     $this->collectFileData($file, 3, $i, $item, $elementGalleryId);
                     $i++;
                 }
             }
             // Tags
             if ($node->tags) {
                 foreach ($node->tags->tag as $tag) {
                     if (trim($tag)) {
                         $item['tags'][] = $tag;
                     }
                 }
             }
             // Authors
             if ($node->authors) {
                 $i = 1;
                 foreach ($node->authors->author as $author) {
                     $attributes = $author->attributes();
                     $uid = $attributes['uid'];
                     $this->collectAuthorData($author, $i, $uid, $item);
                     $i++;
                 }
             }
             // Set general process error
             if (count($item['errors']) > 0) {
                 $this->setError(Lang::txt('COM_PUBLICATIONS_BATCH_ERROR_MISSING_OR_INVALID'));
             }
             $items[] = $item;
             $this->reader->next();
         }
     }
     // Show what you'll get
     if ($dryRun == 1) {
         $eview = new \Hubzero\Component\View(array('name' => 'batchcreate', 'layout' => 'dryrun'));
         $eview->option = $this->_option;
         $eview->items = $items;
         $output .= $eview->loadTemplate();
     } elseif ($dryRun == 2) {
         // Get hub config
         $this->site = trim(Request::base(), DS);
         // Process batch
         $out = NULL;
         $i = 0;
         foreach ($items as $item) {
             if ($this->processRecord($item, $out)) {
                 $i++;
             }
         }
         if ($i > 0) {
             $output = '<p class="success">' . Lang::txt('COM_PUBLICATIONS_BATCH_SUCCESS_CREATED') . ' ' . $i . ' ' . Lang::txt('COM_PUBLICATIONS_BATCH_RECORDS_S') . '</p>';
         }
         if ($i != count($items)) {
             $output = '<p class="error">' . Lang::txt('COM_PUBLICATIONS_BATCH_FAILED_CREATED') . ' ' . (count($items) - $i) . ' ' . Lang::txt('COM_PUBLICATIONS_BATCH_RECORDS_S') . '</p>';
         }
         $output .= $out;
     }
     $this->reader->close();
     return $output;
 }
Esempio n. 4
0
 /**
  * Add membership request for user
  *
  * @return  array
  */
 public function dorequestTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask(Lang::txt('COM_GROUPS_INVITE_MUST_BE_LOGGED_IN_TO_REQUEST'));
         return;
     }
     Request::checkToken();
     //check to make sure we have  cname
     if (!$this->cn) {
         $this->_errorHandler(400, Lang::txt('COM_GROUPS_ERROR_NO_ID'));
     }
     // Load the group page
     $this->view->group = Group::getInstance($this->cn);
     // Ensure we found the group info
     if (!$this->view->group || !$this->view->group->get('gidNumber')) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // Get the group params
     $gparams = new Registry($this->view->group->get('params'));
     // If membership is managed in seperate place disallow action
     if ($gparams->get('membership_control', 1) == 0) {
         $this->setNotification(Lang::txt('COM_GROUPS_MEMBERSHIP_MANAGED_ELSEWHERE'), 'error');
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->view->group->get('cn')));
         return;
     }
     //make sure group has restricted policy
     if ($this->view->group->get('join_policy') != 1) {
         return;
     }
     //add user to applicants
     $this->view->group->add('applicants', array(User::get('id')));
     $this->view->group->update();
     // Instantiate the reason object and bind the incoming data
     $row = new Reason($this->database);
     $row->uidNumber = User::get('id');
     $row->gidNumber = $this->view->group->get('gidNumber');
     $row->reason = Request::getVar('reason', Lang::txt('GROUPS_NO_REASON_GIVEN'), 'post');
     $row->reason = \Hubzero\Utility\Sanitize::stripAll($row->reason);
     $row->date = Date::toSql();
     // Check and store the reason
     if (!$row->check()) {
         return App::abort(500, $row->getError());
     }
     if (!$row->store()) {
         return App::abort(500, $row->getError());
     }
     // Log the membership request
     Log::log(array('gidNumber' => $this->view->group->get('gidNumber'), 'action' => 'membership_requested', 'comments' => array(User::get('id'))));
     // Log activity
     $url = Route::url('index.php?option=' . $this->_option . '&cn=' . $this->view->group->get('cn'));
     $recipients = array(['group', $this->view->group->get('gidNumber')], ['user', User::get('id')]);
     foreach ($this->view->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => 'requested', 'scope' => 'group', 'scope_id' => $this->view->group->get('gidNumber'), 'description' => Lang::txt('COM_GROUPS_ACTIVITY_GROUP_USER_REQUESTED', '<a href="' . $url . '">' . $this->view->group->get('description') . '</a>'), 'details' => array('title' => $this->view->group->get('description'), 'url' => $url, 'cn' => $this->view->group->get('cn'), 'gidNumber' => $this->view->group->get('gidNumber'))], 'recipients' => $recipients]);
     // E-mail subject
     $subject = Lang::txt('COM_GROUPS_JOIN_REQUEST_EMAIL_SUBJECT', $this->view->group->get('cn'));
     // Build the e-mail message
     $eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'request'));
     $eview->option = $this->_option;
     $eview->sitename = Config::get('sitename');
     $eview->user = User::getInstance();
     $eview->group = $this->view->group;
     $eview->row = $row;
     $html = $eview->loadTemplate();
     $html = str_replace("\n", "\r\n", $html);
     // Get the system administrator e-mail
     $emailadmin = Config::get('mailfrom');
     // Build the "from" portion of the e-mail
     $from = array();
     $from['name'] = Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_name));
     $from['email'] = Config::get('mailfrom');
     // build array of managers
     $managers = array();
     foreach ($this->view->group->get('managers') as $m) {
         $profile = User::getInstance($m);
         if ($profile) {
             $managers[$profile->get('email')] = $profile->get('name');
         }
     }
     // create new message
     $message = new \Hubzero\Mail\Message();
     // build message object and send
     $message->setSubject($subject)->addFrom($from['email'], $from['name'])->setTo($managers)->addHeader('X-Mailer', 'PHP/' . phpversion())->addHeader('X-Component', 'com_groups')->addHeader('X-Component-Object', 'group_membership_requested')->addPart($html, 'text/plain')->send();
     //tell the user they just did good
     $this->setNotification(Lang::txt('COM_GROUPS_INVITE_REQUEST_FORWARDED'), 'passed');
     // Push through to the groups listing
     App::redirect($url);
 }
Esempio n. 5
0
 /**
  * Email instructor course digest
  *
  * @param   object   $job  \Components\Cron\Models\Job
  * @return  boolean
  */
 public function emailInstructorDigest(\Components\Cron\Models\Job $job)
 {
     $database = \App::get('db');
     $cconfig = Component::params('com_courses');
     Lang::load('com_courses') || Lang::load('com_courses', PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'site');
     $from = array('name' => Config::get('sitename') . ' ' . Lang::txt('COM_COURSES'), 'email' => Config::get('mailfrom'));
     $subject = Lang::txt('COM_COURSES') . ': ' . Lang::txt('COM_COURSES_SUBJECT_EMAIL_DIGEST');
     require_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'courses.php';
     $course_id = 0;
     $params = $job->get('params');
     if (isset($params) && is_object($params)) {
         $course_id = $params->get('course');
     }
     $coursesObj = new \Components\Courses\Models\Courses();
     if ($course_id) {
         $courses = array($coursesObj->course($course_id));
     } else {
         $courses = $coursesObj->courses();
     }
     if (isset($courses) && count($courses) > 0) {
         foreach ($courses as $course) {
             if (!$course->isAvailable()) {
                 continue;
             }
             $mailed = array();
             $managers = $course->managers();
             $enrollments = $course->students(array('count' => true));
             $offerings = $course->offerings();
             if (isset($offerings) && count($offerings) > 0) {
                 foreach ($offerings as $offering) {
                     if (!$offering->isAvailable()) {
                         continue;
                     }
                     $offering->gradebook()->refresh();
                     $passing = $offering->gradebook()->countPassing(false);
                     $failing = $offering->gradebook()->countFailing(false);
                     if (isset($managers) && count($managers) > 0) {
                         foreach ($managers as $manager) {
                             // Get the user's account
                             $user = User::getInstance($manager->get('user_id'));
                             if (!$user->get('id')) {
                                 continue;
                             }
                             // Try to ensure no duplicates
                             if (in_array($user->get('username'), $mailed)) {
                                 continue;
                             }
                             // Only mail instructors (i.e. not managers)
                             if ($manager->get('role_alias') != 'instructor') {
                                 continue;
                             }
                             // Get discussion stats and posts
                             require_once PATH_CORE . DS . 'components' . DS . 'com_forum' . DS . 'tables' . DS . 'post.php';
                             $postsTbl = new \Components\Forum\Tables\Post($database);
                             $filters = array('scope' => 'course', 'scope_id' => $offering->get('id'), 'state' => 1, 'sort' => 'created', 'sort_Dir' => 'DESC', 'limit' => 100);
                             $posts = $postsTbl->find($filters);
                             $posts_cnt = count($posts);
                             $latest = array();
                             $latest_cnt = 0;
                             if (isset($posts) && $posts_cnt > 0) {
                                 foreach ($posts as $post) {
                                     if (strtotime($post->created) > strtotime('-1 day')) {
                                         $latest[] = $post;
                                     } else {
                                         break;
                                     }
                                 }
                                 $latest_cnt = count($latest);
                             }
                             $eview = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'site', 'name' => 'emails', 'layout' => 'digest_plain'));
                             $eview->option = 'com_courses';
                             $eview->controller = 'courses';
                             $eview->delimiter = '~!~!~!~!~!~!~!~!~!~!';
                             $eview->course = $course;
                             $eview->enrollments = $enrollments;
                             $eview->passing = $passing;
                             $eview->failing = $failing;
                             $eview->offering = $offering;
                             $eview->posts_cnt = $posts_cnt;
                             $eview->latest = $latest;
                             $eview->latest_cnt = $latest_cnt;
                             $plain = $eview->loadTemplate();
                             $plain = str_replace("\n", "\r\n", $plain);
                             // HTML
                             $eview->setLayout('digest_html');
                             $html = $eview->loadTemplate();
                             $html = str_replace("\n", "\r\n", $html);
                             // Build message
                             $message = new \Hubzero\Mail\Message();
                             $message->setSubject($subject)->addFrom($from['email'], $from['name'])->addTo($user->get('email'), $user->get('name'))->addHeader('X-Component', 'com_courses')->addHeader('X-Component-Object', 'courses_instructor_digest');
                             $message->addPart($plain, 'text/plain');
                             $message->addPart($html, 'text/html');
                             // Send mail
                             if (!$message->send()) {
                                 $this->setError('Failed to mail %s', $user->get('email'));
                             }
                             $mailed[] = $user->get('username');
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Esempio n. 6
0
 /**
  * Fetch AutoContent (from plugin) Task
  *
  * @return 	void
  */
 public function fetchAutoContentTask()
 {
     // Prevent direct access
     if (User::isGuest()) {
         return false;
     }
     // Request the source variable
     $source = Request::getVar('source', '');
     $layout = Request::getVar('layout', '');
     $itemCount = Request::getInt('itemCount', 5);
     // Make sure we have something to work with
     if ($source != '' && $layout != '') {
         // Get a list of enabled plugins
         $enabledSources = Event::trigger('newsletter.onGetEnabledDigests');
         // Get the matching source's ID, based on plugin ordering
         $matches = array_keys($enabledSources, $source);
         $key = $matches[0];
         // Get the latest content
         $obj = new stdClass();
         $obj = Event::trigger('newsletter.onGetLatest', array($itemCount));
         // Only get the portion we are working with
         $obj = $obj[$key];
         // Instantiate the desired Story Layout view
         $view = new \Hubzero\Component\View(array('name' => 'storytemplates', 'layout' => $layout));
         // Pass the data through to the view
         $view->object = $obj;
         $html = $view->display();
         echo $html;
         exit;
     } else {
         // Output a warning
         echo json_encode(array('status' => 'nothing specified'));
         exit;
     }
 }
Esempio n. 7
0
 /**
  * Build Newsletter Content
  *
  * @param   object   $campaign              Campaign Object
  * @param   boolean  $stripHtmlAndBodyTags  Strip out <html> & <body> tags?
  * @return  string   Campaign HTML
  */
 public function buildNewsletter($campaign, $stripHtmlAndBodyTags = false)
 {
     //are we overriding content with template vs using stories?
     if ($campaign->template == '-1') {
         $campaignTemplate = $campaign->html_content;
         $campaignPrimaryStories = '';
         $campaignSecondaryStories = '';
     } else {
         //instantiate objects
         $newsletterTemplate = new Template($this->_db);
         $newsletterPrimaryStory = new PrimaryStory($this->_db);
         $newsletterSecondaryStory = new SecondaryStory($this->_db);
         //get the campaign template
         $newsletterTemplate->load($campaign->template);
         $campaignTemplate = $newsletterTemplate->template;
         //get primary & secondary colors
         $primaryTitleColor = $newsletterTemplate->primary_title_color ? $newsletterTemplate->primary_title_color : '#000000';
         if (strlen($primaryTitleColor) <= 7 && !strstr($primaryTitleColor, ';')) {
             $primaryTitleColor = 'font-size:20px;font-weight:bold;color:' . $primaryTitleColor . ';font-family:arial;line-height:100%;margin-bottom:10px;';
         }
         $primaryTextColor = $newsletterTemplate->primary_text_color ? $newsletterTemplate->primary_text_color : '#444444';
         if (strlen($primaryTextColor) <= 7 && !strstr($primaryTextColor, ';')) {
             $primaryTextColor = 'font-size:14px;font-weight:normal;color:' . $primaryTextColor . ';font-family:arial;margin-bottom:50px;';
         }
         $secondaryTitleColor = $newsletterTemplate->secondary_title_color ? $newsletterTemplate->secondary_title_color : '#666666';
         if (strlen($secondaryTitleColor) <= 7 && !strstr($secondaryTitleColor, ';')) {
             $secondaryTitleColor = 'font-size:15px;font-weight:bold;color:' . $secondaryTitleColor . ';font-family:arial;line-height:150%;';
         }
         $secondaryTextColor = $newsletterTemplate->secondary_text_color ? $newsletterTemplate->secondary_text_color : '#999999';
         if (strlen($secondaryTextColor) <= 7 && !strstr($secondaryTextColor, ';')) {
             $secondaryTextColor = 'font-size:12px;color:' . $secondaryTextColor . ';font-family:arial;';
         }
         //get and format primary stories
         $campaignPrimaryStories = '';
         $primaryStories = $newsletterPrimaryStory->getStories($campaign->id);
         foreach ($primaryStories as $pStory) {
             $campaignPrimaryStories .= '<span style="display:block;page-break-inside:avoid;' . $primaryTitleColor . '">';
             $campaignPrimaryStories .= $pStory->title;
             $campaignPrimaryStories .= '</span>';
             $campaignPrimaryStories .= '<span style="display:block;page-break-inside:avoid;' . $primaryTextColor . '">';
             $campaignPrimaryStories .= $pStory->story;
             //do we have a readmore link
             if ($pStory->readmore_link) {
                 $readmore_title = $pStory->readmore_title ? $pStory->readmore_title : 'Read More &rsaquo;';
                 $campaignPrimaryStories .= "<br /><br /><a href=\"{$pStory->readmore_link}\" target=\"\">{$readmore_title}</a>";
             }
             $campaignPrimaryStories .= '</span>';
         }
         //get secondary stories
         $campaignSecondaryStories = '<br /><br />';
         $secondaryStories = $newsletterSecondaryStory->getStories($campaign->id);
         foreach ($secondaryStories as $sStory) {
             $campaignSecondaryStories .= '<span style="display:block;page-break-inside:avoid;' . $secondaryTitleColor . '">';
             $campaignSecondaryStories .= $sStory->title;
             $campaignSecondaryStories .= '</span>';
             $campaignSecondaryStories .= '<span style="display:block;page-break-inside:avoid;' . $secondaryTextColor . '">';
             $campaignSecondaryStories .= $sStory->story;
             //do we have a readmore link
             if ($sStory->readmore_link) {
                 $readmore_title = $sStory->readmore_title ? $sStory->readmore_title : 'Read More &rsaquo;';
                 $campaignSecondaryStories .= "<br /><br /><a href=\"{$sStory->readmore_link}\" target=\"\">{$readmore_title}</a>";
             }
             $campaignSecondaryStories .= '</span>';
             $campaignSecondaryStories .= '<br /><br />';
         }
     }
     //get the hub
     $hub = $_SERVER['SERVER_NAME'];
     //build link to newsletters for email
     $link = 'https://' . $hub . '/newsletter/' . $campaign->alias;
     //replace placeholders in template
     $campaignParsed = str_replace("{{LINK}}", $link, $campaignTemplate);
     $campaignParsed = str_replace("{{ALIAS}}", $campaign->alias, $campaignParsed);
     $campaignParsed = str_replace("{{TITLE}}", $campaign->name, $campaignParsed);
     $campaignParsed = str_replace("{{ISSUE}}", $campaign->issue, $campaignParsed);
     // Handle the AUTOGEN sections
     if (preg_match_all("(\\{.*?\\}\\})", $campaignPrimaryStories, $matches) !== FALSE) {
         foreach ($matches[0] as &$match) {
             // A field to hold HTML content for the section
             $html = '';
             // Hold onto the original token
             $originMatch = $match;
             // Perform some cleanup, stripping
             $match = ltrim($match, "{{");
             $match = rtrim($match, "}}");
             // Explode on the delimiter
             $parts = explode("_", $match);
             // Make sure we're doing "it" on the right token
             if ($parts[0] == "AUTOGEN") {
                 // Get the content
                 $enabledPlugins = Event::trigger('newsletter.onGetEnabledDigests');
                 // Ascertain the key, based on plugin ordering
                 $key = array_keys($enabledPlugins, strtolower($parts[1]))[0];
                 // Get the content for the desired plugin
                 $content = Event::trigger('newsletter.onGetLatest', array($parts[2]))[$key];
                 // Apply the view template
                 $view = new \Hubzero\Component\View(array());
                 // Written emphatically, set the paths and whatnot
                 $view->setName('storytemplates');
                 $view->setLayout(strtolower($parts[3]));
                 $view->setBasePath(PATH_CORE . DS . 'components' . DS . 'com_newsletter' . DS . 'admin');
                 // Pass the object through to the view
                 $view->object = $content;
                 $view->addTemplatePath(PATH_CORE . DS . 'components' . DS . 'com_newsletter' . DS . 'admin' . DS . 'views' . DS . 'storytemplates' . DS . 'tmpl');
                 // Oh, what's this a buffer hijack?
                 ob_start();
                 // Render the view within the buffer.
                 $view->display();
                 // Grab the buffer's content
                 $html = ob_get_contents();
                 // Clear and close the buffer
                 ob_end_clean();
                 // Do some string replacement on the original token.
                 $campaignPrimaryStories = str_replace($originMatch, $html, $campaignPrimaryStories);
             }
         }
     }
     $campaignParsed = str_replace("{{PRIMARY_STORIES}}", $campaignPrimaryStories, $campaignParsed);
     $campaignParsed = str_replace("{{SECONDARY_STORIES}}", $campaignSecondaryStories, $campaignParsed);
     $campaignParsed = str_replace("{{COPYRIGHT}}", date("Y"), $campaignParsed);
     $campaignParsed = str_replace('src="/site', 'src="' . substr(PATH_APP, strlen(PATH_ROOT)) . '/site', $campaignParsed);
     //replace .org, .com., .net, .edu 's
     // if ($campaign->type == 'html')
     // {
     // 	$campaignParsed = str_replace(".org", "&#8203;.org", $campaignParsed);
     // 	$campaignParsed = str_replace(".com", "&#8203;.com", $campaignParsed);
     // 	$campaignParsed = str_replace(".net", "&#8203;.net", $campaignParsed);
     // 	$campaignParsed = str_replace(".edu", "&#8203;.edu", $campaignParsed);
     // }
     //do we want to strip <html> & <body> tags
     if ($stripHtmlAndBodyTags) {
         $campaignParsed = preg_replace('/<html[^>]*>/', '', $campaignParsed);
         $campaignParsed = preg_replace('/<body[^>]*>/', '', $campaignParsed);
         $campaignParsed = str_replace('</body>', '', $campaignParsed);
         $campaignParsed = str_replace('</html>', '', $campaignParsed);
     }
     return $campaignParsed;
 }
Esempio n. 8
0
 /**
  * Delete a course
  * This method initially displays a form for confirming deletion
  * then deletes course and associated information upon POST
  *
  * @return     void
  */
 public function deleteTask()
 {
     // Build title
     $this->_buildTitle();
     // Build pathway
     $this->_buildPathway();
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask(Lang::txt('COM_COURSES_NOT_LOGGEDIN'));
         return;
     }
     // Ensure we found the course info
     if (!$this->course->exists()) {
         return App::abort(404, Lang::txt('COM_COURSES_NO_COURSE_FOUND'));
     }
     // Check authorization
     if (!$this->course->access('delete')) {
         return App::abort(403, Lang::txt('COM_COURSES_NOT_AUTH'));
     }
     // Get number of course members
     $managers = $this->course->get('managers');
     // Incoming
     $process = Request::getVar('process', '');
     $confirmdel = Request::getVar('confirmdel', '');
     $msg = trim(Request::getVar('msg', '', 'post'));
     // Did they confirm delete?
     if (!$process || !$confirmdel) {
         if ($process && !$confirmdel) {
             Notify::error(Lang::txt('COM_COURSES_ERROR_CONFIRM_DELETION'), 'courses');
         }
         $log = Lang::txt('COM_COURSES_MEMBERS_LOG', count($managers));
         // Trigger the functions that delete associated content
         // Should return logs of what was deleted
         $logs = Event::trigger('courses.onCourseDeleteCount', array($course));
         if (count($logs) > 0) {
             $log .= '<br />' . implode('<br />', $logs);
         }
         // Output HTML
         $this->view->title = Lang::txt('COM_COURSES_DELETE_COURSE') . ': ' . $this->course->get('title');
         $this->view->course = $course;
         $this->view->log = $log;
         $this->view->msg = $msg;
         $this->view->notifications = Notify::messages('courses');
         $this->view->display();
         return;
     }
     $this->course->set('state', 2);
     // Delete course
     if (!$this->course->update()) {
         $this->view->setLayout('error');
         $this->view->title = $title;
         if ($this->course->getError()) {
             Notify::error($this->course->getError(), 'courses');
         }
         $this->view->notifications = Notify::messages('courses');
         $this->view->display();
         return;
     }
     // Get and set some vars
     $date = Date::of('now');
     // Build the "from" info for e-mails
     $from = array('name' => Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_name)), 'email' => Config::get('mailfrom'));
     // E-mail subject
     $subject = Lang::txt('COM_COURSES_SUBJECT_COURSE_DELETED', $gcn);
     // Build the e-mail message
     $eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'deleted'));
     $eview->option = $this->_option;
     $eview->sitename = Config::get('sitename');
     $eview->user = User::getInstance();
     $eview->gcn = $gcn;
     $eview->msg = $msg;
     $eview->course = $deletedcourse;
     $message = $eview->loadTemplate();
     $message = str_replace("\n", "\r\n", $message);
     // Send the message
     if (!Event::trigger('xmessage.onSendMessage', array('courses_deleted', $subject, $message, $from, $members, $this->_option))) {
         Notify::error(Lang::txt('COM_COURSES_ERROR_EMAIL_MEMBERS_FAILED'));
     }
     // Log the deletion
     $xlog = new Tables\Log($this->database);
     $xlog->gid = $this->course->get('id');
     $xlog->uid = User::get('id');
     $xlog->timestamp = Date::toSql();
     $xlog->action = 'course_deleted';
     $xlog->comments = $log;
     $xlog->actorid = User::get('id');
     if (!$xlog->store()) {
         Notify::error($xlog->getError());
     }
     // Redirect back to the courses page
     App::redirect(Route::url('index.php?option=' . $this->_option), Lang::txt('COM_COURSES_COURSE_DELETED', $this->course->get('title')), 'passed');
 }
Esempio n. 9
0
 /**
  * Display collection
  *
  * @param		$cId
  * @return     	void
  */
 private function browseCollection($cId)
 {
     $view = new \Hubzero\Component\View(array('name' => 'browse', 'layout' => 'collection'));
     // Get the collection products
     $this->warehouse->addLookupCollection($cId);
     $products = $this->warehouse->getProducts();
     $view->products = $products;
     // Breadcrumbs
     //$this->pathway->addItem('Browsing collection', Route::url('index.php?id=' . '5'));
     if (Pathway::count() <= 0) {
         Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option);
     }
     Pathway::append(Lang::txt('COM_STOREFRONT_BROWSING_COLLECTION'));
     $view->display();
 }
Esempio n. 10
0
 /**
  * View publication
  *
  * @return     void
  */
 public function pageTask()
 {
     $this->view->setName('view');
     // Incoming
     $tab = Request::getVar('active', '');
     // The active tab (section)
     $no_html = Request::getInt('no_html', 0);
     // No-html display?
     // Ensure we have an ID or alias to work with
     if (!$this->_identifier) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     // Get our model and load publication data
     $this->model = new Models\Publication($this->_identifier, $this->_version);
     // Last public release
     $lastPubRelease = $this->model->lastPublicRelease();
     // Version invalid but publication exists?
     if ($this->model->masterExists() && !$this->model->exists()) {
         if ($lastPubRelease && $lastPubRelease->id) {
             // Go to last public release
             App::redirect(Route::url($this->_route . '&v=' . $lastPubRelease->version_number));
             return;
         }
     }
     // Make sure we got a result from the database
     if (!$this->model->exists() || $this->model->isDeleted()) {
         App::redirect(Route::url('index.php?option=' . $this->_option), Lang::txt('COM_PUBLICATIONS_RESOURCE_NOT_FOUND'), 'error');
         return;
     }
     // Is the visitor authorized to view this resource?
     if (!$this->model->access('view')) {
         if ($this->_version == 'default' && $lastPubRelease && $lastPubRelease->id) {
             // Go to last public release
             App::redirect(Route::url($this->_route . '&v=' . $lastPubRelease->version_number));
             return;
         } else {
             $this->_blockAccess();
             return;
         }
     }
     $authorized = $this->model->access('manage');
     $contentAccess = $this->model->access('view-all');
     $restricted = $contentAccess ? false : true;
     $this->model->setCuration(false);
     // For publications created in a non-curated flow - convert
     if ($this->model->_curationModel->convertToCuration($this->model)) {
         // Reload attachments (updated)
         $this->model->attachments(true);
     }
     // Start sections
     $sections = array();
     $cats = array();
     $tab = $tab ? $tab : 'about';
     // Show extended pub info like reviews, questions etc.
     $extended = $lastPubRelease && $lastPubRelease->id == $this->model->version->id ? true : false;
     // Trigger the functions that return the areas we'll be using
     $cats = Event::trigger('publications.onPublicationAreas', array($this->model, $this->model->versionAlias, $extended));
     // Get the sections
     $sections = Event::trigger('publications.onPublication', array($this->model, $this->_option, array($tab), 'all', $this->model->versionAlias, $extended));
     $available = array('play');
     foreach ($cats as $cat) {
         $name = key($cat);
         if ($name != '') {
             $available[] = $name;
         }
     }
     if ($tab != 'about' && !in_array($tab, $available)) {
         $tab = 'about';
     }
     $body = '';
     if ($tab == 'about') {
         // Build the HTML of the "about" tab
         $view = new \Hubzero\Component\View(array('name' => 'about', 'layout' => 'default'));
         $view->option = $this->_option;
         $view->config = $this->config;
         $view->database = $this->database;
         $view->publication = $this->model;
         $view->authorized = $authorized;
         $view->restricted = $restricted;
         $view->version = $this->model->versionAlias;
         $view->sections = $sections;
         $body = $view->loadTemplate();
         // Log page view (public pubs only)
         if ($this->_logging && $this->_task == 'view') {
             $this->model->logAccess('view');
         }
     }
     // Add the default "About" section to the beginning of the lists
     $cat = array();
     $cat['about'] = Lang::txt('COM_PUBLICATIONS_ABOUT');
     array_unshift($cats, $cat);
     array_unshift($sections, array('html' => $body, 'metadata' => ''));
     // Get filters (for series & workshops listing)
     $filters = array();
     $defaultsort = $this->model->_category->alias == 'series' ? 'date' : 'ordering';
     $defaultsort = $this->model->_category->alias == 'series' && $this->config->get('show_ranking') ? 'ranking' : $defaultsort;
     $filters['sortby'] = Request::getVar('sortby', $defaultsort);
     $filters['limit'] = Request::getInt('limit', 0);
     $filters['start'] = Request::getInt('limitstart', 0);
     $filters['id'] = $this->model->publication->id;
     // Write title & build pathway
     Document::setTitle(Lang::txt(strtoupper($this->_option)) . ': ' . stripslashes($this->model->version->title));
     // Set the pathway
     $this->_buildPathway();
     $this->view->version = $this->model->versionAlias;
     $this->view->config = $this->config;
     $this->view->option = $this->_option;
     $this->view->publication = $this->model;
     $this->view->authorized = $authorized;
     $this->view->restricted = $restricted;
     $this->view->cats = $cats;
     $this->view->tab = $tab;
     $this->view->sections = $sections;
     $this->view->database = $this->database;
     $this->view->filters = $filters;
     $this->view->lastPubRelease = $lastPubRelease;
     $this->view->contributable = $this->_contributable;
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Output HTML
     $this->view->display();
     // Insert .rdf link in the header
     \ResourceMapGenerator::putRDF($this->model->publication->id);
     return;
 }
Esempio n. 11
0
 /**
  * Format ORCID search results
  *
  * @param   array   $records
  * @param   string  $callbackPrefix
  * @return  string
  */
 private function _format($records, $callbackPrefix)
 {
     $view = new \Hubzero\Component\View(array('name' => $this->_controller, 'layout' => 'results'));
     $view->records = $records;
     $view->callbackPrefix = $callbackPrefix;
     return $view->loadTemplate();
 }
Esempio n. 12
0
 /**
  * View a resource
  *
  * @return     void
  */
 public function viewTask()
 {
     // Incoming
     $id = Request::getInt('id', 0);
     // Rsource ID (primary method of identifying a resource)
     $alias = Request::getVar('alias', '');
     // Alternate method of identifying a resource
     $fsize = Request::getVar('fsize', '');
     // A parameter to see file size without formatting
     // XSS fix. Revision gets pumped all over and dumped in URLs via plugins, easier to fix at the input instead of risking missing an output. See ticket 1416
     $revision = htmlentities(Request::getVar('rev', ''));
     // Get svk revision of a tool
     $tab = Request::getVar('active', 'about');
     // The active tab (section)
     // Ensure we have an ID or alias to work with
     if (!$id && !$alias) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     // Load the resource
     include_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'resource.php';
     $this->model = Models\Resource::getInstance($alias ? $alias : $id, $revision);
     // Make sure we got a result from the database
     if (!$this->model->exists() || $this->model->deleted()) {
         App::abort(404, Lang::txt('COM_RESOURCES_RESOURCE_NOT_FOUND'));
         return;
     }
     // Make sure the resource is published and standalone
     if (!$this->model->resource->standalone) {
         App::abort(403, Lang::txt('COM_RESOURCES_ALERTNOTAUTH'));
         return;
     }
     // Is the visitor authorized to view this resource?
     if (!$this->model->access('view')) {
         App::abort(403, Lang::txt('COM_RESOURCES_ALERTNOTAUTH'));
         return;
     }
     // // Make sure they have access to view this resource
     //if ($this->checkGroupAccess($this->model->resource))
     //{
     //	App::abort(403, \Lang::txt('COM_RESOURCES_ALERTNOTAUTH_GROUP', $this->model->resource->group_owner, Route::url('index.php?option=com_groups&cn=' . $this->model->resource->group_owner)));
     //	return;
     //}
     // Initiate a resource helper class
     $helper = new Helper($this->model->resource->id, $this->database);
     // Build the pathway
     if ($this->model->inGroup()) {
         // Alter the pathway to reflect a group owned resource
         $group = \Hubzero\User\Group::getInstance($this->model->resource->group_owner);
         if ($group) {
             Pathway::clear();
             Pathway::append('Groups', Route::url('index.php?option=com_groups'));
             Pathway::append(stripslashes($group->get('description')), Route::url('index.php?option=com_groups&cn=' . $this->model->resource->group_owner));
             Pathway::append('Resources', Route::url('index.php?option=com_groups&cn=' . $this->model->resource->group_owner . '&active=resources'));
             Pathway::append(stripslashes($this->model->type->type), Route::url('index.php?option=com_groups&cn=' . $this->model->resource->group_owner . '&active=resources&area=' . $this->model->type->alias));
         } else {
             Pathway::append(stripslashes($this->model->type->type), Route::url('index.php?option=' . $this->_option . '&type=' . $this->model->type->alias));
         }
     } else {
         Pathway::append(stripslashes($this->model->type->type), Route::url('index.php?option=' . $this->_option . '&type=' . $this->model->type->alias));
     }
     // Tool development version requested
     if (User::isGuest() && $revision == 'dev') {
         App::abort(403, Lang::txt('COM_RESOURCES_ALERTNOTAUTH'));
         return;
     }
     // Access check for tools
     if ($this->model->isTool()) {
         // if (development revision
         //   or (specific revision that is NOT published))
         if ($revision == 'dev' or !$revision && $this->model->resource->published != 1) {
             // Check if the user has access to the tool
             $objT = new \Components\Tools\Tables\Tool($this->database);
             $toolid = $objT->getToolId($this->model->resource->alias);
             if (!$this->_checkToolaccess($toolid)) {
                 // Denied, punk! How do you like them apples?!
                 App::abort(403, Lang::txt('COM_RESOURCES_ALERTNOTAUTH'));
                 return;
             }
         }
     }
     // Whew! Finally passed all the checks
     // Let's get down to business...
     // Get contribtool params
     $tconfig = \Component::params('com_tools');
     $sections = array();
     $cats = array();
     // We need to do this here because we need some stats info to pass to the body
     if (!isset($this->model->thistool) || !$this->model->thistool) {
         // Trigger the functions that return the areas we'll be using
         $cats = Event::trigger('resources.onResourcesAreas', array($this->model));
     } elseif (isset($this->model->revision) && $this->model->revision) {
         $cats = Event::trigger('resources.onResourcesAreas', array($this->model));
         $cts = array();
         foreach ($cats as $cat) {
             if (empty($cat)) {
                 $cts[] = $cat;
                 continue;
             }
             foreach ($cat as $name => $title) {
                 if ($name == 'about' || $name == 'versions' || $name == 'supportingdocs') {
                     $cts[] = $cat;
                 }
             }
         }
         $cats = $cts;
     }
     // Get the sections
     $sections = Event::trigger('resources.onResources', array($this->model, $this->_option, array($tab), 'all'));
     $available = array('play');
     foreach ($cats as $cat) {
         $name = key($cat);
         if ($name != '') {
             $available[] = $name;
         }
     }
     if ($tab != 'about' && !in_array($tab, $available)) {
         $tab = 'about';
     }
     // Display different main text if "playing" a resource
     if ($this->_task == 'play') {
         $activechild = NULL;
         if (is_object($this->activechild)) {
             $activechild = $this->activechild;
         }
         $view = new \Hubzero\Component\View(array('base_path' => $this->_base_path, 'name' => 'view', 'layout' => 'play'));
         $view->option = $this->_option;
         $view->config = $this->config;
         $view->tconfig = $tconfig;
         $view->database = $this->database;
         $view->resource = $this->model->resource;
         $view->helper = $helper;
         $view->resid = $this->resid;
         $view->activechild = $activechild;
         $view->no_html = 0;
         $view->fsize = 0;
         if ($this->getError()) {
             foreach ($this->getErrors() as $error) {
                 $view->setError($error);
             }
         }
         $body = $view->loadTemplate();
         $cats[] = array('play' => Lang::txt('COM_RESOURCES_PLAY'));
         $sections[] = array('html' => $body, 'metadata' => '', 'area' => 'play');
         $tab = 'play';
     } elseif ($this->_task == 'watch') {
         //test to make sure HUBpresenter is ready to go
         $pre = $this->preWatch();
         //get the errors
         $errors = $pre['errors'];
         //get the manifest
         $manifest = $pre['manifest'];
         //get the content path
         $content_folder = $pre['content_folder'];
         //if we have no errors
         if (count($errors) > 0) {
             // Instantiate a new view
             $this->view = new \Hubzero\Component\View(array('name' => 'view', 'layout' => 'watch_error'));
             $this->view->errors = $errors;
             $body = $this->view->loadTemplate();
         } else {
             // Instantiate a new view
             $view = new \Hubzero\Component\View(array('base_path' => $this->_base_path, 'name' => 'view', 'layout' => 'watch'));
             $view->config = $this->config;
             $view->tconfig = $tconfig;
             $view->database = $this->database;
             $view->manifest = $manifest;
             $view->content_folder = $content_folder;
             $view->pid = $id;
             $view->resid = Request::getVar('resid', '');
             $view->doc = Document::getRoot();
             // Output HTML
             if ($this->getError()) {
                 foreach ($this->getErrors() as $error) {
                     $view->setError($error);
                 }
             }
             $body = $view->loadTemplate();
         }
         $cats[] = array('watch' => Lang::txt('Watch Presentation'));
         $sections[] = array('html' => $body, 'metadata' => '', 'area' => 'watch');
         $tab = 'watch';
     }
     // Write title
     Document::setTitle(Lang::txt(strtoupper($this->_option)) . ': ' . stripslashes($this->model->resource->title));
     if ($canonical = $this->model->attribs->get('canonical', '')) {
         if (!preg_match('/^(https?:|mailto:|ftp:|gopher:|news:|file:|rss:)/i', $canonical)) {
             $canonical = rtrim(Request::base(), '/') . '/' . ltrim($canonical, '/');
         }
         Document::addHeadLink($canonical, 'canonical');
     }
     Pathway::append(stripslashes($this->model->resource->title), Route::url('index.php?option=' . $this->_option . '&id=' . $this->model->resource->id));
     // Normalize the title
     // This is so we can determine the type of resource template to display
     // For example, Learning Modules => learningmodules
     $type_alias = $this->model->type->alias ? $this->model->type->alias : $this->model->type->normalize($this->model->type->type);
     // Determine the layout we're using
     $layout = 'default';
     if ($type_alias && (is_file(PATH_CORE . DS . 'templates' . DS . App::get('template')->template . DS . 'html' . DS . $this->_option . DS . 'view' . DS . $type_alias . '.php') || is_file(dirname(__DIR__) . DS . 'views' . DS . 'view' . DS . 'tmpl' . DS . $type_alias . '.php'))) {
         $layout = $type_alias;
     }
     // Instantiate a new view
     $this->view->setLayout($layout);
     if ($this->model->isTool()) {
         $this->view->thistool = $this->model->thistool;
         $this->view->curtool = $this->model->curtool;
         $this->view->alltools = $this->model->alltools;
         $this->view->revision = $this->model->revision;
     }
     $this->view->model = $this->model;
     $this->view->tconfig = $tconfig;
     $this->view->option = $this->_option;
     $this->view->fsize = $fsize;
     $this->view->cats = $cats;
     $this->view->tab = $tab;
     $this->view->sections = $sections;
     $this->view->database = $this->database;
     $this->view->helper = $helper;
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output HTML
     $this->view->setName('view')->display();
 }
Esempio n. 13
0
 /**
  * Error view
  *
  * @param   string  $layout
  * @return  void
  */
 protected function _showError($layout = 'default')
 {
     // Need to be project creator
     $view = new \Hubzero\Component\View(array('name' => 'error', 'layout' => $layout));
     $view->error = $this->getError();
     $view->title = $this->title;
     $view->display();
     return;
 }
Esempio n. 14
0
 /**
  * Display a form for updating profile info
  *
  * @return  void
  */
 public function updateTask()
 {
     // Check if the user is logged in
     if (User::isGuest()) {
         return App::abort(500, Lang::txt('COM_MEMBERS_REGISTER_ERROR_SESSION_EXPIRED'));
     }
     $force = false;
     $updateEmail = false;
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     // Instantiate a new registration object
     $xregistration = new \Components\Members\Models\Registration();
     $xprofile = Member::oneOrFail(User::get('id'));
     $hzal = \Hubzero\Auth\Link::find_by_id(User::get('auth_link_id'));
     // Get users component config options, specifically whether or not 'simple' registration is enabled
     $method = Request::getMethod();
     $usersConfig = Component::params('com_members');
     $simpleRegistration = $usersConfig->get('simple_registration', false);
     if ($method == 'POST') {
         // Load POSTed data
         $xregistration->loadPOST();
     } else {
         // Load data from the user object
         $xregistration->loadProfile($xprofile);
         $username = User::get('username');
         $email = User::get('email');
         if ($username[0] == '-' && is_object($hzal)) {
             $sub_email = explode('@', (string) $hzal->email, 2);
             $tmp_username = Session::get('auth_link.tmp_username', $sub_email[0]);
             $xregistration->set('login', $tmp_username);
             $xregistration->set('orcid', Session::get('auth_link.tmp_orcid', ''));
             $xregistration->set('email', $hzal->email);
             $xregistration->set('confirmEmail', $hzal->email);
             if ($simpleRegistration) {
                 $force = false;
                 $method = 'POST';
             } else {
                 $force = true;
             }
         }
     }
     $check = $xregistration->check('update');
     if (!$force && $check && $method == 'GET') {
         Session::set('registration.incomplete', false);
         if ($_SERVER['REQUEST_URI'] == rtrim(Request::base(true), '/') . '/register/update' || $_SERVER['REQUEST_URI'] == rtrim(Request::base(true), '/') . '/members/register/update') {
             App::redirect(rtrim(Request::base(true), '/') . '/');
         } else {
             App::redirect($_SERVER['REQUEST_URI']);
         }
         return true;
     }
     if (!$force && $check && $method == 'POST') {
         // Before going any further, we need to do a sanity check to make sure username isn't being changed.
         // This really only happens on a race condition where someone is creating the same account
         // using a 3rd party auth service in two different browsers. Yes, it's crazy!
         if ($xregistration->get('login') && substr(User::get('username'), 0, 1) == '-') {
             // Make sure the username hasn't since been set in the database
             if (substr(User::getInstance(User::get('id'))->get('username'), 0, 1) != '-') {
                 App::redirect(Route::url('index.php?option=com_users&view=logout'), Lang::txt('This account appears to already exist. Please try logging in again.'), 'warning');
                 return;
             }
         }
         $hubHomeDir = rtrim($this->config->get('homedir'), DS);
         $updateEmail = false;
         if ($xprofile->get('homeDirectory') == '') {
             $xprofile->set('homeDirectory', $hubHomeDir . DS . $xprofile->get('username'));
         }
         if ($xprofile->get('registerIP') == '') {
             $xprofile->set('registerIP', Request::getVar('REMOTE_ADDR', '', 'server'));
         }
         if ($xprofile->get('registerDate') == '') {
             $xprofile->set('registerDate', Date::toSql());
         }
         if ($xregistration->get('email') != $xprofile->get('email')) {
             if (is_object($hzal) && $xregistration->get('email') == $hzal->email) {
                 $xprofile->set('activation', 3);
             } else {
                 $code = \Components\Members\Helpers\Utility::genemailconfirm();
                 $xprofile->set('activation', $code);
                 $updateEmail = true;
             }
         }
         if ($xregistration->get('login') != $xprofile->get('username')) {
             $xprofile->set('homeDirectory', $hubHomeDir . DS . $xregistration->get('login'));
         }
         $keys = array('email', 'name', 'surname', 'givenName', 'middleName', 'usageAgreement', 'sendEmail', 'password');
         foreach ($keys as $key) {
             if ($xregistration->get($key) !== null) {
                 $xprofile->set($key, $xregistration->get($key));
             }
         }
         $xprofile->set('username', $xregistration->get('login'));
         $xprofile->save();
         // Update current session if appropriate
         // TODO: update all session of this user
         // TODO: only update if changed
         if ($xprofile->get('id') == User::get('id')) {
             $suser = Session::get('user');
             $suser->set('username', $xprofile->get('username'));
             $suser->set('email', $xprofile->get('email'));
             $suser->set('name', $xprofile->get('name'));
             Session::set('user', $suser);
             // Get the session object
             $table = \JTable::getInstance('session');
             $table->load(Session::getId());
             $table->username = $xprofile->get('username');
             $table->update();
         }
         Session::set('registration.incomplete', false);
         // Notify the user
         if ($updateEmail) {
             \Components\Members\Helpers\Utility::sendConfirmEmail($xprofile, $xregistration);
         }
         // Notify administration
         if ($method == 'POST') {
             $subject = Config::get('sitename') . ' ' . Lang::txt('COM_MEMBERS_REGISTER_EMAIL_ACCOUNT_UPDATE');
             $eaview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'adminupdate'));
             $eaview->option = $this->_option;
             $eaview->controller = $this->_controller;
             $eaview->sitename = Config::get('sitename');
             $eaview->xprofile = $xprofile;
             $eaview->baseURL = $this->baseURL;
             $message = $eaview->loadTemplate();
             $message = str_replace("\n", "\r\n", $message);
         }
         if (!$updateEmail) {
             $suri = Request::getVar('REQUEST_URI', '/', 'server');
             if ($suri == '/register/update' || $suri == '/members/update' || $suri == '/members/register/update') {
                 $suri = Route::url('index.php?option=' . $this->_option . '&task=myaccount');
             }
             App::redirect($suri);
             return;
         } else {
             // Instantiate a new view
             $this->view->set('title', Lang::txt('COM_MEMBERS_REGISTER_UPDATE'))->set('sitename', Config::get('sitename'))->set('xprofile', $xprofile)->set('isSelf', true)->set('updateEmail', $updateEmail)->setErrors($this->getErrors())->display();
         }
         return true;
     }
     return $this->_show_registration_form($xregistration, 'update');
 }
Esempio n. 15
0
 /**
  * Display Group Page
  *
  * @param    Object    $group    \Hubzero\User\Group Object
  * @param    Object    $page     \Components\Groups\Models\Page Object
  * @return   String
  */
 public static function displayPage($group, $page, $markHit = true)
 {
     // create view object
     $view = new \Hubzero\Component\View(array('name' => 'pages', 'layout' => '_view'));
     // if super group add super group folder
     // to available paths
     if ($group->isSuperGroup()) {
         $base = $group->getBasePath();
         $view->addTemplatePath(PATH_APP . $base . DS . 'template' . DS . 'pages');
     }
     // get needed vars
     $database = \App::get('db');
     $authorized = \Components\Groups\Helpers\View::authorize($group);
     $version = $page ? $page->approvedVersion() : null;
     // stops from displaying pages that dont exist
     if ($page === null) {
         App::abort(404, Lang::txt('Group Page Not Found'));
         return;
     }
     // stops from displaying unpublished pages
     // make sure we have approved version to display
     if ($page->get('state') == $page::APP_STATE_UNPUBLISHED || $version === null) {
         // determine which layout to use
         $layout = $version === null ? '_view_notapproved' : '_view_unpublished';
         // show unpublished or no version layout
         if ($authorized == 'manager' || \Hubzero\User\Profile::userHasPermissionForGroupAction($group, 'group.pages')) {
             $view->setLayout($layout);
             $view->group = $group;
             $view->page = $page;
             $view->version = $version;
             return $view->loadTemplate();
         }
         // show 404
         App::abort(404, Lang::txt('Group Page Not Found'));
         return;
     }
     // build page hit object
     // mark page hit
     if ($markHit) {
         $groupsTablePageHit = new PageHit($database);
         $pageHit = new stdClass();
         $pageHit->gidNumber = $group->get('gidNumber');
         $pageHit->pageid = $page->get('id');
         $pageHit->userid = User::get('id');
         $pageHit->date = date('Y-m-d H:i:s');
         $pageHit->ip = $_SERVER['REMOTE_ADDR'];
         $groupsTablePageHit->save($pageHit);
     }
     // parse old wiki content
     //$content = self::parseWiki($group, $version->get('content'), $fullparse = true);
     $content = $version->get('content');
     // parse php tags and modules
     $content = self::parse($group, $page, $content);
     // set content
     $version->set('content', trim($content));
     // set vars to view
     $view->user = User::getRoot();
     $view->group = $group;
     $view->page = $page;
     $view->version = $version;
     $view->authorized = $authorized;
     $view->config = Component::params('com_groups');
     // return rendered template
     return $view->loadTemplate();
 }
Esempio n. 16
0
								</span>
							<?php 
                }
            }
            ?>
							</span>
						</td>
					<?php 
        }
        ?>
					<?php 
        if ($item->status != 7) {
            ?>
						<td class="priority-4 voting">
							<?php 
            $view = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'site', 'name' => 'wishlists', 'layout' => '_vote'));
            $view->set('option', 'com_wishlist')->set('item', new \Components\Wishlist\Models\Wish($item))->set('listid', $this->wishlist->id)->set('plugin', 0)->set('admin', 0)->set('page', 'wishlist')->set('filters', $this->filters)->display();
            ?>
						</td>
						<td class="priority-3 ranking">
							<?php 
            /*if ($this->admin
            			|| $item->status == 1
            			|| ($item->status == 0 && $item->accepted == 1)
            			|| $item->status == 3
            			|| $item->status == 4
            		) { */
            $html = '';
            switch ($item->status) {
                case 0:
                    if (isset($item->ranked) && !$item->ranked && ($this->admin == 2 or $this->admin == 3)) {
Esempio n. 17
0
 /**
  * Display a file list and options for managing disk usage
  *
  * @param      boolean $exceeded Exceeded allowed space?
  * @return     void
  */
 public function displayTask($exceeded = false)
 {
     // Check that the user is logged in
     if (User::isGuest()) {
         $this->_login();
         return;
     }
     $this->view->setLayout('display');
     // Set the page title
     $this->_buildTitle();
     // Set the pathway
     $this->_buildPathway();
     // Get their disk space usage
     $this->percent = 0;
     $this->view->monitor = '';
     if ($this->config->get('show_storage')) {
         $this->exceeded = $exceeded;
         $this->getDiskUsage();
         $view = new \Hubzero\Component\View(array('name' => $this->_controller, 'layout' => 'diskusage'));
         $view->option = $this->_option;
         $view->amt = $this->percent;
         $view->du = '';
         $view->percent = 0;
         $view->msgs = 0;
         $view->ajax = 0;
         $view->writelink = 0;
         $view->total = $this->total;
         $this->view->monitor = $view->loadTemplate();
     }
     // Instantiate the view
     $this->view->exceeded = $exceeded;
     $this->view->output = isset($this->view->output) ? $this->view->output : null;
     $this->view->percentage = $this->percent;
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->display();
 }
Esempio n. 18
0
 /**
  * Render a tag cloud
  *
  * @param   string  $rtrn    Format to render
  * @param   array   $filters Filters to apply
  * @param   boolean $clear   Clear cached data?
  * @return  string
  */
 public function render($rtrn = 'html', $filters = array(), $clear = false)
 {
     switch (strtolower($rtrn)) {
         case 'string':
             if (!isset($this->_cache['tags_string']) || $clear) {
                 $tags = array();
                 foreach ($this->tags('list', $filters, $clear) as $tag) {
                     $tags[] = $tag->get('raw_tag');
                 }
                 $this->_cache['tags_string'] = implode(', ', $tags);
             }
             return $this->_cache['tags_string'];
             break;
         case 'array':
             return $this->tags('list', $filters, $clear);
             break;
         case 'cloud':
         case 'html':
         default:
             if (!isset($this->_cache['tags_cloud']) || $clear) {
                 $view = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'site', 'name' => 'wishlists', 'layout' => '_tags'));
                 if (isset($filters['filters'])) {
                     $view->base = $filters['base'];
                     $view->filters = $filters['filters'];
                 }
                 $view->config = $this->_config;
                 $view->tags = $this->tags('list', $filters, $clear);
                 $this->_cache['tags_cloud'] = $view->loadTemplate();
             }
             return $this->_cache['tags_cloud'];
             break;
     }
 }
Esempio n. 19
0
 public function emailOrderComplete($transactionInfo)
 {
     $params = Component::params(Request::getVar('option'));
     $items = unserialize($transactionInfo->tiItems);
     //print_r($items); die;
     // Build emails
     // Build order summary
     $summary = 'Order number: ' . $transactionInfo->tId . "\n\n";
     $summary .= "\n====================\n\n";
     $summary .= 'Subtotal: ' . '$' . number_format($transactionInfo->tiSubtotal, 2) . "\n";
     if (!$transactionInfo->tiShipping) {
         $transactionInfo->tiShipping = 0;
     }
     if ($transactionInfo->tiShipping > 0) {
         $summary .= 'Shipping and handling: ' . '$' . number_format($transactionInfo->tiShipping, 2) . "\n";
     }
     if (!$transactionInfo->tiTax) {
         $transactionInfo->tiTax = 0;
     }
     if ($transactionInfo->tiDiscounts > 0 || $transactionInfo->tiShippingDiscount > 0) {
         $summary .= 'Discounts: ' . '$' . number_format($transactionInfo->tiDiscounts + $transactionInfo->tiShippingDiscount, 2) . "\n";
     }
     if ($transactionInfo->tiTax > 0) {
         $summary .= 'Tax: ' . '$' . number_format($transactionInfo->tiTax, 2) . "\n";
     }
     $summary .= 'Total: ' . '$' . number_format($transactionInfo->tiTotal, 2) . "\n";
     if (!empty($transactionInfo->tiShippingToFirst)) {
         $summary .= "\n\nShipping address:";
         $summary .= "\n--------------------\n";
         $summary .= $transactionInfo->tiShippingToFirst . ' ' . $transactionInfo->tiShippingToLast . "\n";
         $summary .= $transactionInfo->tiShippingAddress . "\n";
         $summary .= $transactionInfo->tiShippingCity . ', ' . $transactionInfo->tiShippingState . ' ' . $transactionInfo->tiShippingZip . "\n";
     }
     $summary .= "\n\nItems ordered:";
     $summary .= "\n--------------------\n";
     require_once PATH_CORE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Warehouse.php';
     $warehouse = new \Components\Storefront\Models\Warehouse();
     foreach ($items as $k => $item) {
         $itemInfo = $item['info'];
         $cartInfo = $item['cartInfo'];
         $itemMeta = $item['meta'];
         //print_r($item); die;
         $productType = $warehouse->getProductTypeInfo($itemInfo->ptId)['ptName'];
         // If course, generate a link to the course
         $action = false;
         if ($productType == 'Course') {
             $action = ' Go to the course page at: ' . ($action .= Route::url('index.php?option=com_courses', true, -1) . $itemMeta['courseId'] . '/' . $itemMeta['offeringId']);
         } elseif ($productType == 'Software Download') {
             $action = ' Download at: ' . ($action .= Route::url('index.php?option=com_cart', true, -1) . 'download/' . $transactionInfo->tId . '/' . $itemInfo->sId);
             if (isset($itemMeta['serial']) && !empty($itemMeta['serial'])) {
                 $action .= "\n\t";
                 $action .= " Serial number: " . $itemMeta['serial'];
             }
         }
         $summary .= "{$cartInfo->qty} x ";
         $summary .= "{$itemInfo->pName}";
         if (!empty($item['options'])) {
             $summary .= '(';
             $optionCount = 0;
             foreach ($item['options'] as $option) {
                 if ($optionCount) {
                     $summary .= ', ';
                 }
                 $summary .= $option;
                 $optionCount++;
             }
             $summary .= ')';
         }
         $summary .= ' @ ' . '$' . number_format($itemInfo->sPrice, 2);
         if ($action) {
             $summary .= "\n\t";
             $summary .= $action;
         }
         $summary .= "\n";
     }
     //print_r($summary); die;
     // Get message plugin
     JPluginHelper::importPlugin('xmessage');
     // "from" info
     $from = array();
     $from['name'] = Config::get('sitename');
     $from['email'] = Config::get('mailfrom');
     // Email to admin
     $adminEmail = "There is a new online store order: \n\n";
     $adminEmail .= $summary;
     // Admin email
     $to = array($params->get('storeAdminId'));
     Event::trigger('onSendMessage', array('store_notifications', 'New order at ' . $from['name'], $adminEmail, $from, $to, '', null, '', 0, true));
     // Email to client
     $clientEmail = 'Thank you for your order at ' . Config::get('sitename') . "!\n\n";
     $clientEmail .= $summary;
     require_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'Cart.php';
     $to = array(\Components\Cart\Models\Cart::getCartUser($transactionInfo->crtId));
     Event::trigger('onSendMessage', array('store_notifications', 'Your order at ' . $from['name'], $clientEmail, $from, $to, '', null, '', 0, true));
     // Email notification extra
     $notifyTo = $params->get('sendNotificationTo');
     if (!empty($notifyTo)) {
         $notifyTo = explode(',', str_replace(' ', '', $notifyTo));
         $notifyEmail = 'There is a new online store order at ' . Config::get('sitename') . "\n\n";
         $notifyEmail .= $summary;
         // Plain text email
         $eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'order_notify'));
         $eview->option = $this->_option;
         $eview->controller = $this->_controller;
         $eview->message = $notifyEmail;
         $plain = $eview->loadTemplate();
         $plain = str_replace("\n", "\r\n", $plain);
         $message = new \Hubzero\Mail\Message();
         $message->setSubject('ORDER NOTIFICATION: New order at ' . $from['name']);
         $message->addFrom(Config::get('mailfrom'), Config::get('sitename'));
         $message->addPart($plain, 'text/plain');
         foreach ($notifyTo as $email) {
             if (\Hubzero\Utility\Validate::email($email)) {
                 $message->addTo($email);
             }
         }
         $message->setBody($plain);
         $message->send();
     }
 }
Esempio n. 20
0
 /**
  * Edit form for a resource
  *
  * @param   integer  $isnew  Flag for editing (0) or creating new (1)
  * @return  void
  */
 public function editTask($isnew = 0)
 {
     Request::setVar('hidemainmenu', 1);
     $this->view->isnew = $isnew;
     // Get the resource component config
     $this->view->rconfig = $this->config;
     // Push some needed styles to the tmeplate
     $this->css('resources.css');
     // Incoming resource ID
     $id = Request::getVar('id', array(0));
     if (is_array($id)) {
         $id = !empty($id) ? $id[0] : 0;
     }
     // Incoming parent ID - this determines if the resource is standalone or not
     $this->view->pid = Request::getInt('pid', 0);
     // Grab some filters for returning to place after editing
     $this->view->return = array();
     $this->view->return['type'] = Request::getVar('type', '');
     $this->view->return['sort'] = Request::getVar('sort', '');
     $this->view->return['status'] = Request::getVar('status', '');
     // Instantiate our resource object
     $this->view->row = new Resource($this->database);
     $this->view->row->load($id);
     // Fail if checked out not by 'me'
     if ($this->view->row->checked_out && $this->view->row->checked_out != User::get('id')) {
         $task = '';
         if ($this->view->pid) {
             $task = '&task=children&pid=' . $this->view->pid;
         }
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . $task, false), Lang::txt('COM_RESOURCES_WARNING_CHECKED_OUT'), 'notice');
         return;
     }
     // Is this a new resource?
     if (!$id) {
         $this->view->row->created = Date::toSql();
         $this->view->row->created_by = User::get('id');
         $this->view->row->modified = $this->database->getNullDate();
         $this->view->row->modified_by = 0;
         $this->view->row->publish_up = Date::toSql();
         $this->view->row->publish_down = Lang::txt('COM_RESOURCES_NEVER');
         if ($this->view->pid) {
             $this->view->row->published = 1;
             $this->view->row->standalone = 0;
         } else {
             $this->view->row->published = 3;
             // default to "new" status
             $this->view->row->standalone = 1;
         }
         $this->view->row->access = 0;
     }
     // Editing existing
     $this->view->row->checkout(User::get('id'));
     if (trim($this->view->row->publish_down) == '0000-00-00 00:00:00') {
         $this->view->row->publish_down = Lang::txt('COM_RESOURCES_NEVER');
     }
     // Get name of resource creator
     $creator = User::getInstance($this->view->row->created_by);
     $this->view->row->created_by_name = $creator->get('name');
     $this->view->row->created_by_name = $this->view->row->created_by_name ? $this->view->row->created_by_name : Lang::txt('Unknown');
     // Get name of last person to modify resource
     if ($this->view->row->modified_by) {
         $modifier = User::getInstance($this->view->row->modified_by);
         $this->view->row->modified_by_name = $modifier->get('name');
         $this->view->row->modified_by_name = $this->view->row->modified_by_name ? $this->view->row->modified_by_name : Lang::txt('Unknown');
     } else {
         $this->view->row->modified_by_name = '';
     }
     // Get params definitions
     $this->view->params = new \Hubzero\Html\Parameter($this->view->row->params, dirname(dirname(__DIR__)) . DS . 'resources.xml');
     $this->view->attribs = new \Hubzero\Config\Registry($this->view->row->attribs);
     // Build selects of various types
     $rt = new Type($this->database);
     if ($this->view->row->standalone != 1) {
         $this->view->lists['type'] = Html::selectType($rt->getTypes(30), 'type', $this->view->row->type, '', '', '', '');
         $this->view->lists['logical_type'] = Html::selectType($rt->getTypes(28), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', '');
         $this->view->lists['sub_type'] = Html::selectType($rt->getTypes(30), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', '');
     } else {
         $this->view->lists['type'] = Html::selectType($rt->getTypes(27), 'type', $this->view->row->type, '', '', '', '');
         $this->view->lists['logical_type'] = Html::selectType($rt->getTypes(21), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', '');
     }
     // Build the <select> of admin users
     $this->view->lists['created_by'] = $this->userSelect('created_by', 0, 1);
     // Build the <select> for the group access
     $this->view->lists['access'] = Html::selectAccess($this->view->rconfig->get('accesses'), $this->view->row->access);
     // Is this a standalone resource?
     if ($this->view->row->standalone == 1) {
         $this->view->lists['tags'] = '';
         // Get groups
         $filters = array('authorized' => 'admin', 'fields' => array('cn', 'description', 'published', 'gidNumber', 'type'), 'type' => array(1, 3), 'sortby' => 'description');
         $groups = \Hubzero\User\Group::find($filters);
         // Build <select> of groups
         $this->view->lists['groups'] = Html::selectGroup($groups, $this->view->row->group_owner);
         include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'profile.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'association.php';
         // Get all contributors
         $mp = new \Components\Members\Tables\Profile($this->database);
         $members = null;
         //$mp->getRecords(array('sortby'=>'surname DESC','limit'=>'all','search'=>'','show'=>''), true);
         // Get all contributors linked to this resource
         $authnames = array();
         if ($this->view->row->id) {
             $ma = new \Components\Members\Tables\Association($this->database);
             $sql = "SELECT n.uidNumber AS id, a.authorid, a.name, n.givenName, n.middleName, n.surname, a.role, a.organization\n\t\t\t\t\t\tFROM " . $ma->getTableName() . " AS a\n\t\t\t\t\t\tLEFT JOIN " . $mp->getTableName() . " AS n ON n.uidNumber=a.authorid\n\t\t\t\t\t\tWHERE a.subtable='resources'\n\t\t\t\t\t\tAND a.subid=" . $this->view->row->id . "\n\t\t\t\t\t\tORDER BY a.ordering";
             $this->database->setQuery($sql);
             $authnames = $this->database->loadObjectList();
             // Get the tags on this item
             $tagger = new Tags($this->view->row->id);
             $this->view->lists['tags'] = $tagger->render('string');
         }
         // Build <select> of contributors
         $authorslist = new \Hubzero\Component\View(array('name' => $this->_controller, 'layout' => 'authors'));
         $authorslist->authnames = $authnames;
         $authorslist->attribs = $this->view->attribs;
         $authorslist->option = $this->_option;
         $authorslist->roles = $rt->getRolesForType($this->view->row->type);
         $this->view->lists['authors'] = $authorslist->loadTemplate();
     }
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }
Esempio n. 21
0
 /**
  * Generate the primary resources button
  *
  * @param      string  $class    Class to add
  * @param      string  $href     Link url
  * @param      string  $msg      Link text
  * @param      string  $xtra     Extra parameters to add (deprecated)
  * @param      string  $title    Link title
  * @param      string  $action   Link action
  * @param      boolean $disabled Is the button disable?
  * @param      string  $pop      Pop-up content
  * @return     string
  */
 public static function primaryButton($class, $href, $msg, $xtra = '', $title = '', $action = '', $disabled = false, $pop = '')
 {
     $view = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'site', 'name' => 'view', 'layout' => '_primary'));
     $view->option = 'com_publications';
     $view->disabled = $disabled;
     $view->class = $class;
     $view->href = $href;
     $view->title = $title;
     $view->action = $action;
     $view->xtra = $xtra;
     $view->pop = $pop;
     $view->msg = $msg;
     return $view->loadTemplate();
 }
Esempio n. 22
0
 /**
  * Display a form for updating profile info
  *
  * @return  void
  */
 public function updateTask()
 {
     // Check if the user is logged in
     if (User::isGuest()) {
         return App::abort(500, Lang::txt('COM_MEMBERS_REGISTER_ERROR_SESSION_EXPIRED'));
     }
     $force = false;
     $updateEmail = false;
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     // Instantiate a new registration object
     $xregistration = new \Components\Members\Models\Registration();
     $xprofile = \Hubzero\User\Profile::getInstance(User::get('id'));
     $hzal = \Hubzero\Auth\Link::find_by_id(User::get('auth_link_id'));
     if (Request::getMethod() == 'POST') {
         // Load POSTed data
         $xregistration->loadPOST();
     } else {
         // Load data from the user object
         if (is_object($xprofile)) {
             $xregistration->loadProfile($xprofile);
         } else {
             $xregistration->loadAccount(User::getRoot());
         }
         $username = User::get('username');
         $email = User::get('email');
         if ($username[0] == '-' && is_object($hzal)) {
             $tmp_username = Session::get('auth_link.tmp_username', '');
             $xregistration->set('login', $tmp_username);
             $xregistration->set('orcid', Session::get('auth_link.tmp_orcid', ''));
             $xregistration->set('email', $hzal->email);
             $xregistration->set('confirmEmail', $hzal->email);
             $force = true;
         }
     }
     $check = $xregistration->check('update');
     if (!$force && $check && Request::getMethod() == 'GET') {
         Session::set('registration.incomplete', false);
         if ($_SERVER['REQUEST_URI'] == rtrim(Request::base(true), '/') . '/register/update' || $_SERVER['REQUEST_URI'] == rtrim(Request::base(true), '/') . '/members/register/update') {
             App::redirect(rtrim(Request::base(true), '/') . '/');
         } else {
             App::redirect($_SERVER['REQUEST_URI']);
         }
         return true;
     }
     if (!$force && $check && Request::getMethod() == 'POST') {
         // Before going any further, we need to do a sanity check to make sure username isn't being changed.
         // This really only happens on a race condition where someone is creating the same account
         // using a 3rd party auth service in two different browsers. Yes, it's crazy!
         if ($xregistration->get('login') && substr(User::get('username'), 0, 1) == '-') {
             // Make sure the username hasn't since been set in the database
             if (substr(User::getInstance(User::get('id'))->get('username'), 0, 1) != '-') {
                 App::redirect(Route::url('index.php?option=com_users&view=logout'), Lang::txt('This account appears to already exist. Please try logging in again.'), 'warning');
                 return;
             }
         }
         //$params = Component::params('com_members');
         $hubHomeDir = rtrim($this->config->get('homedir'), '/');
         $updateEmail = false;
         if ($xprofile->get('homeDirectory') == '') {
             $xprofile->set('homeDirectory', $hubHomeDir . '/' . $xprofile->get('username'));
         }
         if ($xprofile->get('regIP') == '') {
             $xprofile->set('regIP', Request::getVar('REMOTE_ADDR', '', 'server'));
         }
         if ($xprofile->get('regHost') == '') {
             if (isset($_SERVER['REMOTE_HOST'])) {
                 $xprofile->set('regHost', Request::getVar('REMOTE_HOST', '', 'server'));
             }
         }
         if ($xprofile->get('registerDate') == '') {
             $xprofile->set('registerDate', Date::toSql());
         }
         if ($xregistration->get('email') != $xprofile->get('email')) {
             if (is_object($hzal) && $xregistration->get('email') == $hzal->email) {
                 $xprofile->set('emailConfirmed', 3);
             } else {
                 $xprofile->set('emailConfirmed', -rand(1, pow(2, 31) - 1));
                 $updateEmail = true;
             }
         }
         if ($xregistration->get('login') != $xprofile->get('username')) {
             $xprofile->set('homeDirectory', $hubHomeDir . '/' . $xregistration->get('login'));
         }
         $xprofile->loadRegistration($xregistration);
         $xprofile->update();
         // Update user table
         // TODO: only update if changed
         $myuser = User::getInstance($xprofile->get('uidNumber'));
         $myuser->set('username', $xprofile->get('username'));
         $myuser->set('email', $xprofile->get('email'));
         $myuser->set('name', $xprofile->get('name'));
         $myuser->save();
         // Update current session if appropriate
         // TODO: update all session of this user
         // TODO: only update if changed
         if ($myuser->get('id') == User::get('id')) {
             $suser = Session::get('user');
             $suser->set('username', $xprofile->get('username'));
             $suser->set('email', $xprofile->get('email'));
             $suser->set('name', $xprofile->get('name'));
             Session::set('user', $suser);
             // Get the session object
             $table = \JTable::getInstance('session');
             $table->load(Session::getId());
             $table->username = $xprofile->get('username');
             $table->update();
         }
         Session::set('registration.incomplete', false);
         // Notify the user
         if ($updateEmail) {
             $subject = Config::get('sitename') . ' ' . Lang::txt('COM_MEMBERS_REGISTER_EMAIL_CONFIRMATION');
             $eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'update'));
             $eview->option = $this->_option;
             $eview->controller = $this->_controller;
             $eview->sitename = Config::get('sitename');
             $eview->xprofile = $xprofile;
             $eview->baseURL = $this->baseURL;
             $message = $eview->loadTemplate();
             $message = str_replace("\n", "\r\n", $message);
             $msg = new \Hubzero\Mail\Message();
             $msg->setSubject($subject)->addTo($xprofile->get('email'))->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' Administrator')->addHeader('X-Component', $this->_option)->setBody($message);
             if (!$msg->send()) {
                 $this->setError(Lang::txt('COM_MEMBERS_REGISTER_ERROR_EMAILING_CONFIRMATION'));
                 // @FIXME: LOG ERROR SOMEWHERE
             }
         }
         // Notify administration
         if (Request::getMethod() == 'POST') {
             $subject = Config::get('sitename') . ' ' . Lang::txt('COM_MEMBERS_REGISTER_EMAIL_ACCOUNT_UPDATE');
             $eaview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'adminupdate'));
             $eaview->option = $this->_option;
             $eaview->controller = $this->_controller;
             $eaview->sitename = Config::get('sitename');
             $eaview->xprofile = $xprofile;
             $eaview->baseURL = $this->baseURL;
             $message = $eaview->loadTemplate();
             $message = str_replace("\n", "\r\n", $message);
             /*$msg = new \Hubzero\Mail\Message();
             		$msg->setSubject($subject)
             		    ->addTo($hubMonitorEmail)
             		    ->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' Administrator')
             		    ->addHeader('X-Component', $this->_option)
             		    ->setBody($message)
             		    ->send();*/
             // @FIXME: LOG ACCOUNT UPDATE ACTIVITY SOMEWHERE
         }
         if (!$updateEmail) {
             $suri = Request::getVar('REQUEST_URI', '/', 'server');
             if ($suri == '/register/update' || $suri == '/members/update') {
                 App::redirect(Route::url('index.php?option=' . $this->_option . '&task=myaccount'));
             } else {
                 App::redirect($suri);
             }
             return;
         } else {
             // Instantiate a new view
             $this->view->title = Lang::txt('COM_MEMBERS_REGISTER_UPDATE');
             $this->view->sitename = Config::get('sitename');
             $this->view->xprofile = $xprofile;
             $this->view->self = true;
             $this->view->updateEmail = $updateEmail;
             if ($this->getError()) {
                 $this->view->setError($this->getError());
             }
             $this->view->display();
         }
         return true;
     }
     return $this->_show_registration_form($xregistration, 'update');
 }
Esempio n. 23
0
<section class="main section">
	<h3><?php 
echo Lang::txt('COM_JOBS_LATEST_POSTINGS');
?>
</h3>
	<form method="get" action="<?php 
echo Route::url('index.php?option=' . $this->option . '&task=browse');
?>
">
	<?php 
if (count($this->jobs) > 0) {
    ?>
		<?php 
    // Display List of items
    $view = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_jobs' . DS . 'site', 'name' => 'jobs', 'layout' => '_list'));
    $view->set('option', $this->option)->set('filters', $this->filters)->set('config', $this->config)->set('task', $this->task)->set('emp', $this->emp)->set('mini', 1)->set('jobs', $this->jobs)->set('admin', $this->admin)->display();
    ?>
		<?php 
} else {
    ?>
		<p><?php 
    echo Lang::txt('COM_JOBS_NO_JOBS_FOUND');
    ?>
</p>
		<?php 
}
?>
	</form>
</section>
Esempio n. 24
0
 /**
  * Serve publication content
  * Determine how to render depending on master type, attachment type and user choice
  * Defaults to download
  *
  * @return  void
  */
 public function serveTask()
 {
     // Incoming
     $aid = Request::getInt('a', 0);
     // Attachment id
     $elementId = Request::getInt('el', 1);
     // Element id
     $render = Request::getVar('render', '');
     $vid = Request::getInt('vid', '');
     $file = Request::getVar('file', '');
     $disp = Request::getVar('disposition');
     $disp = in_array($disp, array('inline', 'attachment')) ? $disp : 'attachment';
     // Get our model and load publication data
     $this->model = new Models\Publication($this->_identifier, $this->_version, $vid);
     if (!$this->model->exists() || $this->model->isDeleted()) {
         App::redirect(Route::url('index.php?option=' . $this->_option), Lang::txt('COM_PUBLICATIONS_RESOURCE_NOT_FOUND'), 'error');
         return;
     }
     // Is the visitor authorized to view content?
     if (!$this->model->access('view-all')) {
         $this->_blockAccess();
         return true;
     }
     // Set curation
     $this->model->setCuration();
     // Bundle requested?
     if ($render == 'archive') {
         // Produce archival package
         if ($this->model->_curationModel->package()) {
             // Log access
             if ($this->model->isPublished()) {
                 $this->model->logAccess('primary');
             }
             $this->model->_curationModel->serveBundle();
             return;
         } else {
             throw new Exception(Lang::txt('COM_PUBLICATIONS_ERROR_FINDING_ATTACHMENTS'), 404);
             return;
         }
     }
     // Bundle requested?
     if ($render == 'showcontents') {
         // Produce archival package
         if ($this->model->_curationModel->package()) {
             // Build the HTML of the "about" tab
             $view = new \Hubzero\Component\View(['name' => 'view', 'layout' => '_contents']);
             $view->model = $this->model;
             $view->option = $this->_option;
             $view->display();
             return;
         } else {
             throw new Exception(Lang::txt('COM_PUBLICATIONS_ERROR_FINDING_ATTACHMENTS'), 404);
             return;
         }
     }
     // Serving data file (dataview)
     if ($file) {
         // Ensure the file exist
         if (!file_exists($this->model->path('data', true) . DS . trim($file))) {
             throw new Exception(Lang::txt('COM_PUBLICATIONS_ERROR_FINDING_ATTACHMENTS'), 404);
             return;
         }
         // Initiate a new content server and serve up the file
         $server = new \Hubzero\Content\Server();
         $server->filename($this->model->path('data', true) . DS . trim($file));
         $server->disposition($disp);
         $server->acceptranges(true);
         $server->saveas(basename($file));
         if (!$server->serve()) {
             // Should only get here on error
             throw new Exception(Lang::txt('COM_PUBLICATIONS_SERVER_ERROR'), 404);
         } else {
             exit;
         }
     }
     $this->model->attachments();
     // Individual attachment is requested? Find element ID
     if ($aid) {
         $elementId = $this->model->_curationModel->getElementIdByAttachment($aid);
     }
     // We do need attachments
     if (!isset($this->model->_attachments['elements'][$elementId]) || empty($this->model->_attachments['elements'][$elementId])) {
         throw new Exception(Lang::txt('COM_PUBLICATIONS_ERROR_FINDING_ATTACHMENTS'), 404);
         return;
     }
     // Get element manifest to deliver content as intended
     $curation = $this->model->_curationModel->getElementManifest($elementId);
     // We do need manifest!
     if (!$curation || !isset($curation->element) || !$curation->element) {
         return false;
     }
     // Get attachment type model
     $attModel = new Models\Attachments($this->database);
     // Log access
     if ($this->model->isPublished()) {
         $aType = $curation->element->params->role == 1 ? 'primary' : 'support';
         $this->model->logAccess($aType);
     }
     // Serve content
     $content = $attModel->serve($curation->element->params->type, $curation->element, $elementId, $this->model, $curation->block->params, $aid);
     // No content served
     if ($content === NULL || $content == false) {
         throw new Exception(Lang::txt('COM_PUBLICATIONS_ERROR_FINDING_ATTACHMENTS'), 404);
     }
     // Do we need to redirect to content?
     if ($attModel->get('redirect')) {
         App::redirect($attModel->get('redirect'));
         return;
     }
     return $content;
 }
Esempio n. 25
0
 *
 * @package   hubzero-cms
 * @author    Ilya Shunko <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access
defined('_HZEXEC_') or die;
$this->css()->js('spin.min.js')->js('autosubmit.js');
?>

<header id="content-header">
	<h2>Payment confirmation</h2>
</header>

<section class="section">
	<?php 
$view = new \Hubzero\Component\View(array('name' => 'shared', 'layout' => 'messages'));
$errors = $this->getError();
$view->setError($this->getError());
$view->display();
if (empty($errors)) {
    ?>
		<p>
			Please click the button below to proceed with payment.
		</p>
		<?php 
    print_r($this->paymentCode);
}
?>
</section>
Esempio n. 26
0
 /**
  *  Permanently delete group
  *
  * @return 		void
  */
 public function doDeleteTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask(Lang::txt('COM_GROUPS_DELETE_MUST_BE_LOGGED_IN'));
         return;
     }
     //check to make sure we have  cname
     if (!$this->cn) {
         $this->_errorHandler(400, Lang::txt('COM_GROUPS_ERROR_NO_ID'));
     }
     // Load the group page
     $this->view->group = Group::getInstance($this->cn);
     // Ensure we found the group info
     if (!$this->view->group || !$this->view->group->get('gidNumber')) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // Check authorization
     if ($this->_authorize() != 'manager') {
         $this->_errorHandler(403, Lang::txt('COM_GROUPS_ERROR_NOT_AUTH'));
     }
     //get request vars
     $confirm_delete = Request::getInt('confirmdel', '');
     $message = trim(Request::getVar('msg', '', 'post'));
     //check to make sure we have confirmed
     if (!$confirm_delete) {
         $this->setNotification(Lang::txt('COM_GROUPS_DELETE_MISSING_CONFIRM_MESSAGE'), 'error');
         $this->deleteTask();
         return;
     }
     // Start log
     $log = Lang::txt('COM_GROUPS_DELETE_MESSAGE_SUBJECT', $this->view->group->get('cn')) . "\n";
     $log .= Lang::txt('COM_GROUPS_GROUP_ID') . ': ' . $this->view->group->get('gidNumber') . "\n";
     $log .= Lang::txt('COM_GROUPS_GROUP_CNAME') . ': ' . $this->view->group->get('cn') . "\n";
     $log .= Lang::txt('COM_GROUPS_GROUP_TITLE') . ': ' . $this->view->group->get('description') . "\n";
     $log .= Lang::txt('COM_GROUPS_GROUP_DISCOVERABILITY') . ': ' . $this->view->group->get('discoverability') . "\n";
     $log .= Lang::txt('COM_GROUPS_GROUP_PUBLIC_TEXT') . ': ' . stripslashes($this->view->group->get('public_desc')) . "\n";
     $log .= Lang::txt('COM_GROUPS_GROUP_PRIVATE_TEXT') . ': ' . stripslashes($this->view->group->get('private_desc')) . "\n";
     $log .= Lang::txt('COM_GROUPS_GROUP_RESTRICTED_MESSAGE') . ': ' . stripslashes($this->view->group->get('restrict_msg')) . "\n";
     // Get number of group members
     $members = $this->view->group->get('members');
     $managers = $this->view->group->get('managers');
     // Log ids of group members
     if ($members) {
         $log .= Lang::txt('COM_GROUP_MEMBERS') . ': ';
         foreach ($members as $gu) {
             $log .= $gu . ' ';
         }
         $log .= '' . "\n";
     }
     $log .= Lang::txt('COM_GROUP_MANAGERS') . ': ';
     foreach ($managers as $gm) {
         $log .= $gm . ' ';
     }
     $log .= '' . "\n";
     // Trigger the functions that delete associated content
     // Should return logs of what was deleted
     $logs = Event::trigger('groups.onGroupDelete', array($this->view->group));
     if (count($logs) > 0) {
         $log .= implode('', $logs);
     }
     // Build the file path
     $path = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/groups'), DS) . DS . $this->view->group->get('gidNumber');
     if (is_dir($path)) {
         // Attempt to delete the file
         if (!Filesystem::deleteDirectory($path)) {
             $this->setNotification(Lang::txt('UNABLE_TO_DELETE_DIRECTORY'), 'error');
         }
     }
     //clone the deleted group
     $deletedgroup = clone $this->view->group;
     // Delete group
     if (!$this->view->group->delete()) {
         $this->setNotification($this->view->group->error, 'error');
         $this->deleteTask();
         return;
     }
     // Build the "from" info for e-mails
     $from = array();
     $from['name'] = Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_name));
     $from['email'] = Config::get('mailfrom');
     // E-mail subject
     $subject = Lang::txt('COM_GROUPS_DELETE_MESSAGE_SUBJECT', $deletedgroup->get('cn'));
     // Build the e-mail message
     $eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'deleted'));
     $eview->option = $this->_option;
     $eview->sitename = Config::get('sitename');
     $eview->user = User::getRoot();
     $eview->gcn = $deletedgroup->get('cn');
     $eview->msg = $message;
     $eview->group = $deletedgroup;
     $html = $eview->loadTemplate();
     $html = str_replace("\n", "\r\n", $html);
     // build array of email recipients
     $groupMembers = array();
     foreach ($members as $member) {
         $profile = \Hubzero\User\Profile::getInstance($member);
         if ($profile) {
             $groupMembers[$profile->get('email')] = $profile->get('name');
         }
     }
     // create new message
     $message = new \Hubzero\Mail\Message();
     // build message object and send
     $message->setSubject($subject)->addFrom($from['email'], $from['name'])->setTo($groupMembers)->addHeader('X-Mailer', 'PHP/' . phpversion())->addHeader('X-Component', 'com_groups')->addHeader('X-Component-Object', 'group_deleted')->addHeader('X-Component-ObjectId', $deletedgroup->get('gidNumber'))->addPart($html, 'text/plain')->send();
     // log deleted group
     Log::log(array('gidNumber' => $deletedgroup->get('gidNumber'), 'action' => 'group_deleted', 'comments' => $log));
     // Redirect back to the groups page
     $this->setNotification(Lang::txt('COM_GROUPS_DELETE_SUCCESS', $deletedgroup->get('description')), 'passed');
     App::redirect(Route::url('index.php?option=' . $this->_option));
     return;
 }
Esempio n. 27
0
 /**
  * Upload a file to the wiki via AJAX
  *
  * @return  string
  */
 public function ajaxUploadTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         echo json_encode(array('error' => Lang::txt('COM_COLLECTIONS_ERROR_LOGIN_REQUIRED')));
         return;
     }
     // Ensure we have an ID to work with
     $listdir = strtolower(Request::getVar('dir', ''));
     if (!$listdir) {
         echo json_encode(array('error' => Lang::txt('COM_COLLECTIONS_NO_ID')));
         return;
     }
     if (substr($listdir, 0, 3) == 'tmp') {
         $item = new Item($listdir);
         if (!$item->exists()) {
             $item->set('state', 0);
             $item->set('title', $listdir);
             if (!$item->store()) {
                 echo json_encode(array('error' => $item->getError()));
                 return;
             }
         }
         $listdir = $item->get('id');
     }
     //max upload size
     $sizeLimit = $this->config->get('maxAllowed', 40000000);
     // get the file
     if (isset($_GET['qqfile'])) {
         $stream = true;
         $file = $_GET['qqfile'];
         $size = (int) $_SERVER["CONTENT_LENGTH"];
     } elseif (isset($_FILES['qqfile'])) {
         $stream = false;
         $file = $_FILES['qqfile']['name'];
         $size = (int) $_FILES['qqfile']['size'];
     } else {
         echo json_encode(array('error' => Lang::txt('COM_COLLECTIONS_FILE_NOT_FOUND')));
         return;
     }
     $asset = new Asset();
     //define upload directory and make sure its writable
     $path = $asset->filespace() . DS . $listdir;
     if (!is_dir($path)) {
         if (!Filesystem::makeDirectory($path)) {
             echo json_encode(array('error' => Lang::txt('COM_COLLECTIONS_ERROR_UNABLE_TO_CREATE_UPLOAD_DIR')));
             return;
         }
     }
     if (!is_writable($path)) {
         echo json_encode(array('error' => Lang::txt('COM_COLLECTIONS_ERROR_UPLOAD_DIR_NOT_WRITABLE')));
         return;
     }
     //check to make sure we have a file and its not too big
     if ($size == 0) {
         echo json_encode(array('error' => Lang::txt('COM_COLLECTIONS_ERROR_EMPTY_FILE')));
         return;
     }
     if ($size > $sizeLimit) {
         $max = preg_replace('/<abbr \\w+=\\"\\w+\\">(\\w{1,3})<\\/abbr>/', '$1', \Hubzero\Utility\Number::formatBytes($sizeLimit));
         echo json_encode(array('error' => Lang::txt('COM_COLLECTIONS_ERROR_FILE_TOO_LARGE', $max)));
         return;
     }
     // don't overwrite previous files that were uploaded
     $pathinfo = pathinfo($file);
     $filename = $pathinfo['filename'];
     // Make the filename safe
     $filename = urldecode($filename);
     $filename = Filesystem::clean($filename);
     $filename = str_replace(' ', '_', $filename);
     $ext = $pathinfo['extension'];
     while (file_exists($path . DS . $filename . '.' . $ext)) {
         $filename .= rand(10, 99);
     }
     $file = $path . DS . $filename . '.' . $ext;
     if ($stream) {
         //read the php input stream to upload file
         $input = fopen("php://input", "r");
         $temp = tmpfile();
         $realSize = stream_copy_to_stream($input, $temp);
         fclose($input);
         //move from temp location to target location which is user folder
         $target = fopen($file, "w");
         fseek($temp, 0, SEEK_SET);
         stream_copy_to_stream($temp, $target);
         fclose($target);
     } else {
         move_uploaded_file($_FILES['qqfile']['tmp_name'], $file);
     }
     // Create database entry
     $asset->set('item_id', intval($listdir));
     $asset->set('filename', $filename . '.' . $ext);
     $asset->set('description', Request::getVar('description', '', 'post'));
     $asset->set('state', 1);
     $asset->set('type', 'file');
     if (!$asset->store()) {
         echo json_encode(array('error' => $asset->getError()));
         return;
     }
     $view = new \Hubzero\Component\View(array('name' => 'media', 'layout' => '_asset'));
     $view->i = Request::getInt('i', 0);
     $view->option = $this->_option;
     $view->controller = $this->_controller;
     $view->asset = $asset;
     $view->no_html = 1;
     //echo result
     echo json_encode(array('success' => true, 'file' => $filename . '.' . $ext, 'directory' => str_replace(PATH_APP, '', $path), 'id' => $listdir, 'html' => str_replace('>', '&gt;', $view->loadTemplate())));
 }
Esempio n. 28
0
 /**
  * Save profile
  *
  * @return  void
  */
 private function _saveEntryData()
 {
     $isNew = !$this->_profile->get('uidNumber');
     if (!isset($this->raw->password)) {
         $this->raw->password = null;
     }
     if ($isNew) {
         if (!$this->_profile->get('username')) {
             $valid = false;
             // Try to create from name
             $username = preg_replace('/[^a-z9-0_]/i', '', strtolower($this->_profile->get('name')));
             if (\Hubzero\Utility\Validate::username($username)) {
                 if (!$this->_usernameExists($username)) {
                     $valid = true;
                 }
             }
             // Try to create from portion preceeding @ in email address
             if (!$valid) {
                 $username = strstr($this->_profile->get('email'), '@', true);
                 if (\Hubzero\Utility\Validate::username($username)) {
                     if ($this->_usernameExists($username)) {
                         $valid = true;
                     }
                 }
             }
             // Try to create from whole email address
             if (!$valid) {
                 for ($i = 0; $i <= 99; $i++) {
                     $username = preg_replace('/[^a-z9-0_]/i', '', strtolower($this->_profile->get('name'))) . $i;
                     if (\Hubzero\Utility\Validate::username($username)) {
                         if ($this->_usernameExists($username)) {
                             $valid = true;
                             break;
                         }
                     }
                 }
             }
             if ($valid) {
                 $this->_profile->set('username', $username);
             }
         }
         if (!$this->raw->password) {
             //\Hubzero\User\Helper::random_password();
             $this->raw->password = $this->_profile->get('username');
         }
         $usersConfig = Component::params('com_users');
         $newUsertype = $usersConfig->get('new_usertype');
         if (!$newUsertype) {
             $db = \App::get('db');
             $query = $db->getQuery(true)->select('id')->from('#__usergroups')->where('title = "Registered"');
             $db->setQuery($query);
             $newUsertype = $db->loadResult();
         }
         $user = User::getRoot();
         $user->set('username', $this->_profile->get('username'));
         $user->set('name', $this->_profile->get('name'));
         $user->set('email', $this->_profile->get('email'));
         $user->set('id', 0);
         $user->set('groups', array($newUsertype));
         $user->set('registerDate', Date::of('now')->toSql());
         $user->set('password', $this->raw->password);
         $user->set('password_clear', $this->raw->password);
         $user->save();
         $user->set('password_clear', '');
         // Attempt to get the new user
         $profile = \Hubzero\User\Profile::getInstance($user->get('id'));
         $result = is_object($profile);
         // Did we successfully create an account?
         if ($result) {
             if (!$this->record->entry->get('emailConfirmed', null)) {
                 $this->_profile->set('emailConfirmed', -rand(1, pow(2, 31) - 1));
             }
             $this->_profile->set('uidNumber', $user->get('id'));
             $this->_profile->set('gidNumber', $profile->get('gidNumber'));
             if (!$this->_profile->get('homeDirectory')) {
                 $this->_profile->set('homeDirectory', $profile->get('homeDirectory'));
             }
             if (!$this->_profile->get('loginShell')) {
                 $this->_profile->set('loginShell', $profile->get('loginShell'));
             }
             if (!$this->_profile->get('ftpShell')) {
                 $this->_profile->set('ftpShell', $profile->get('ftpShell'));
             }
             if (!$this->_profile->get('jobsAllowed')) {
                 $this->_profile->set('jobsAllowed', $profile->get('jobsAllowed'));
             }
         }
     }
     if (!$this->_profile->store()) {
         throw new Exception(Lang::txt('Unable to save the entry data.'));
     }
     if ($password = $this->raw->password) {
         /*if ($isNew)
         		{
         			// We need to bypass any hashing
         			$this->raw->password = '******';
         			\Hubzero\User\Password::changePasshash($this->_profile->get('uidNumber'), $password);
         		}
         		else
         		{*/
         \Hubzero\User\Password::changePassword($this->_profile->get('uidNumber'), $password);
         //}
     }
     \Hubzero\User\Password::expirePassword($this->_profile->get('uidNumber'));
     if ($isNew && $this->_options['emailnew'] == 1) {
         $eview = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'site', 'name' => 'emails', 'layout' => 'confirm'));
         $eview->option = 'com_members';
         $eview->controller = 'register';
         $eview->sitename = Config::get('sitename');
         $eview->login = $this->_profile->get('username');
         $eview->name = $this->_profile->get('name');
         $eview->registerDate = $this->_profile->get('registerDate');
         $eview->confirm = $this->_profile->get('emailConfirmed');
         $eview->baseURL = Request::base();
         $msg = new \Hubzero\Mail\Message();
         $msg->setSubject(Config::get('sitename') . ' ' . Lang::txt('COM_MEMBERS_REGISTER_EMAIL_CONFIRMATION'))->addTo($this->_profile->get('email'))->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' Administrator')->addHeader('X-Component', 'com_members');
         $message = $eview->loadTemplate();
         $message = str_replace("\n", "\r\n", $message);
         $msg->addPart($message, 'text/plain');
         $eview->setLayout('confirm_html');
         $message = $eview->loadTemplate();
         $message = str_replace("\n", "\r\n", $message);
         $msg->addPart($message, 'text/html');
         if (!$msg->send()) {
             array_push($this->record->errors, Lang::txt('COM_MEMBERS_REGISTER_ERROR_EMAILING_CONFIRMATION'));
         }
     }
 }
Esempio n. 29
0
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access
defined('_HZEXEC_') or die;
$states = Cart_Helper::getUsStates();
$this->css();
?>

<header id="content-header">
	<h2>Checkout: shipping information</h2>
</header>

<?php 
if (!empty($this->notifications)) {
    $view = new \Hubzero\Component\View(array('name' => 'shared', 'layout' => 'notifications'));
    $view->notifications = $this->notifications;
    $view->display();
}
?>

<section class="main section">
	<div class="section-inner">
		<?php 
$errors = $this->getError();
if (!empty($errors)) {
    foreach ($errors as $error) {
        echo '<p class="error">' . $error . '</p>';
    }
}
?>
Esempio n. 30
0
    ?>
	<p class="contrib-options">
		<?php 
    echo Lang::txt('PLG_PROJECTS_PUBLICATIONS_NEED_A_PROJECT');
    ?>
		<a href="<?php 
    echo Route::url('index.php?option=com_projects&alias=' . $this->project->get('alias') . '&action=activate');
    ?>
">
		<?php 
    echo Lang::txt('PLG_PROJECTS_PUBLICATIONS_LEARN_MORE');
    ?>
 &raquo;</a>
	</p>
<?php 
}
?>

<?php 
// Display status message
$view = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'site', 'name' => 'projects', 'layout' => '_statusmsg'));
$view->error = $this->getError();
$view->msg = $this->msg;
echo $view->loadTemplate();
?>

<section id="contrib-section" class="section">
	<?php 
echo $this->content;
?>
</section><!-- / .section -->