Пример #1
0
 /**
  * Displays a note icon.
  *
  * @param   integer  $count   The number of notes for the user
  * @param   integer  $userId  The user ID
  *
  * @return	string  A link to a modal window with the user notes
  *
  * @since   2.5
  */
 public static function notes($count, $userId)
 {
     if (empty($count)) {
         return '';
     }
     $title = Lang::txts('COM_USERS_N_USER_NOTES', $count);
     return '<a class="modal state notes"' . ' href="' . Route::url('index.php?option=com_users&view=notes&tmpl=component&layout=modal&u_id=' . (int) $userId) . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 450}}" title="' . $title . '"><span>' . Lang::txt('COM_USERS_NOTES') . '</span></a>';
 }
Пример #2
0
 /**
  * Don't allow categories to be deleted if they contain items or subcategories with items
  *
  * @param   string   $context  The context for the content passed to the plugin.
  * @param   object   $data     The data relating to the content that was deleted.
  * @return  boolean
  */
 public function onContentBeforeDelete($context, $data)
 {
     // Skip plugin if we are deleting something other than categories
     if ($context != 'com_categories.category') {
         return true;
     }
     // Check if this function is enabled.
     if (!$this->params->def('check_categories', 1)) {
         return true;
     }
     $extension = Request::getString('extension');
     // Default to true if not a core extension
     $result = true;
     $tableInfo = array('com_content' => array('table_name' => '#__content'), 'com_newsfeeds' => array('table_name' => '#__newsfeeds'));
     // Now check to see if this is a known core extension
     if (isset($tableInfo[$extension])) {
         // Get table name for known core extensions
         $table = $tableInfo[$extension]['table_name'];
         // See if this category has any content items
         $count = $this->_countItemsInCategory($table, $data->get('id'));
         // Return false if db error
         if ($count === false) {
             $result = false;
         } else {
             // Show error if items are found in the category
             if ($count > 0) {
                 $msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
                 Notify::warning(403, $msg);
                 $result = false;
             }
             // Check for items in any child categories (if it is a leaf, there are no child categories)
             if (!$data->isLeaf()) {
                 $count = $this->_countItemsInChildren($table, $data->get('id'), $data);
                 if ($count === false) {
                     $result = false;
                 } elseif ($count > 0) {
                     $msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
                     Notify::warning(403, $msg);
                     $result = false;
                 }
             }
         }
         return $result;
     }
 }
Пример #3
0
 /**
  * Method to clone an existing module.
  * @since	1.6
  */
 public function duplicate()
 {
     // Check for request forgeries
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Initialise variables.
     $pks = Request::getVar('cid', array(), 'post', 'array');
     \Hubzero\Utility\Arr::toInteger($pks);
     try {
         if (empty($pks)) {
             throw new Exception(Lang::txt('COM_MODULES_ERROR_NO_MODULES_SELECTED'));
         }
         $model = $this->getModel();
         $model->duplicate($pks);
         $this->setMessage(Lang::txts('COM_MODULES_N_MODULES_DUPLICATED', count($pks)));
     } catch (Exception $e) {
         Notify::error($e->getMessage());
     }
     $this->setRedirect(Route::url('index.php?option=com_modules&view=modules', false));
 }
Пример #4
0
 /**
  * Method for deleting one or more overrides
  *
  * @return	void
  *
  * @since		2.5
  */
 public function delete()
 {
     // Check for request forgeries
     Session::checkToken() or die(Lang::txt('JINVALID_TOKEN'));
     // Get items to dlete from the request
     $cid = Request::getVar('cid', array(), '', 'array');
     if (!is_array($cid) || count($cid) < 1) {
         $this->setMessage(Lang::txt($this->text_prefix . '_NO_ITEM_SELECTED'), 'warning');
     } else {
         // Get the model
         $model = $this->getModel('overrides');
         // Remove the items
         if ($model->delete($cid)) {
             $this->setMessage(Lang::txts($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $this->setRedirect(Route::url('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
Пример #5
0
 /**
  * Removes an item
  */
 public function delete()
 {
     // Check for request forgeries
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Get items to remove from the request.
     $cid = Request::getVar('cid', array(), '', 'array');
     if (!is_array($cid) || count($cid) < 1) {
         Notify::error(Lang::txt('COM_MENUS_NO_MENUS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         \Hubzero\Utility\Arr::toInteger($cid);
         // Remove the items.
         if (!$model->delete($cid)) {
             $this->setMessage($model->getError());
         } else {
             $this->setMessage(Lang::txts('COM_MENUS_N_MENUS_DELETED', count($cid)));
         }
     }
     $this->setRedirect('index.php?option=com_menus&view=menus');
 }
Пример #6
0
 /**
  * Method to remove a record.
  */
 public function delete()
 {
     // Check for request forgeries.
     Session::checkToken() or exit(Lang::txt('JInvalid_Token'));
     // Initialise variables.
     $ids = Request::getVar('cid', array(), '', 'array');
     if (!User::authorise('core.admin', $this->option)) {
         throw new Exception(Lang::txt('JERROR_ALERTNOAUTHOR'), 403);
     } elseif (empty($ids)) {
         throw new Exception(Lang::txt('COM_USERS_NO_LEVELS_SELECTED'), 500);
     } else {
         // Get the model.
         $model = $this->getModel();
         \Hubzero\Utility\Arr::toInteger($ids);
         // Remove the items.
         if (!$model->delete($ids)) {
             throw new Exception($model->getError(), 500);
         } else {
             $this->setMessage(Lang::txts('COM_USERS_N_LEVELS_DELETED', count($ids)));
         }
     }
     $this->setRedirect('index.php?option=com_users&view=levels');
 }
Пример #7
0
 /**
  * Upload a file
  *
  * @since 1.5
  */
 function upload()
 {
     $params = Component::params('com_media');
     // Check for request forgeries
     if (!Session::checkToken(['get', 'post'], true)) {
         $response = array('status' => '0', 'error' => Lang::txt('JINVALID_TOKEN'));
         echo json_encode($response);
         return;
     }
     // Get the user
     $log = JLog::getInstance('upload.error.php');
     // Get some data from the request
     $file = Request::getVar('Filedata', '', 'files', 'array');
     $folder = Request::getVar('folder', '', '', 'path');
     $return = Request::getVar('return-url', null, 'post', 'base64');
     if ($_SERVER['CONTENT_LENGTH'] > $params->get('upload_maxsize', 0) * 1024 * 1024 || $_SERVER['CONTENT_LENGTH'] > (int) ini_get('upload_max_filesize') * 1024 * 1024 || $_SERVER['CONTENT_LENGTH'] > (int) ini_get('post_max_size') * 1024 * 1024 || $_SERVER['CONTENT_LENGTH'] > (int) ini_get('memory_limit') * 1024 * 1024) {
         $response = array('status' => '0', 'error' => Lang::txt('COM_MEDIA_ERROR_WARNFILETOOLARGE'));
         echo json_encode($response);
         return;
     }
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     // Make the filename safe
     $file['name'] = Filesystem::clean($file['name']);
     if (isset($file['name'])) {
         // The request is valid
         $err = null;
         $filepath = \Hubzero\Filesystem\Util::normalizePath(COM_MEDIA_BASE . '/' . $folder . '/' . strtolower($file['name']));
         if (!MediaHelper::canUpload($file, $err)) {
             $log->addEntry(array('comment' => 'Invalid: ' . $filepath . ': ' . $err));
             $response = array('status' => '0', 'error' => Lang::txt($err));
             echo json_encode($response);
             return;
         }
         // Trigger the onContentBeforeSave event.
         $object_file = new \Hubzero\Base\Object($file);
         $object_file->filepath = $filepath;
         $result = Event::trigger('content.onContentBeforeSave', array('com_media.file', &$object_file, true));
         if (in_array(false, $result, true)) {
             // There are some errors in the plugins
             $log->addEntry(array('comment' => 'Errors before save: ' . $filepath . ' : ' . implode(', ', $object_file->getErrors())));
             $response = array('status' => '0', 'error' => Lang::txts('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
             echo json_encode($response);
             return;
         }
         if (Filesystem::exists($filepath)) {
             // File exists
             $log->addEntry(array('comment' => 'File exists: ' . $filepath . ' by user_id ' . User::get('id')));
             $response = array('status' => '0', 'error' => Lang::txt('COM_MEDIA_ERROR_FILE_EXISTS'));
             echo json_encode($response);
             return;
         } elseif (!User::authorise('core.create', 'com_media')) {
             // File does not exist and user is not authorised to create
             $log->addEntry(array('comment' => 'Create not permitted: ' . $filepath . ' by user_id ' . User::get('id')));
             $response = array('status' => '0', 'error' => Lang::txt('COM_MEDIA_ERROR_CREATE_NOT_PERMITTED'));
             echo json_encode($response);
             return;
         }
         $file = (array) $object_file;
         if (!Filesystem::upload($file['tmp_name'], $file['filepath'])) {
             // Error in upload
             $log->addEntry(array('comment' => 'Error on upload: ' . $filepath));
             $response = array('status' => '0', 'error' => Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_UPLOAD_FILE'));
             echo json_encode($response);
             return;
         } else {
             // Trigger the onContentAfterSave event.
             Event::trigger('content.onContentAfterSave', array('com_media.file', &$object_file, true));
             $log->addEntry(array('comment' => $folder));
             $response = array('status' => '1', 'error' => Lang::txt('COM_MEDIA_UPLOAD_COMPLETE', substr($file['filepath'], strlen(COM_MEDIA_BASE))));
             echo json_encode($response);
             return;
         }
     } else {
         $response = array('status' => '0', 'error' => Lang::txt('COM_MEDIA_ERROR_BAD_REQUEST'));
         echo json_encode($response);
         return;
     }
 }
Пример #8
0
 /** Deletes and returns correctly.
  *
  * @return	void
  * @since	2.5.12
  */
 public function delete()
 {
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Get items to remove from the request.
     $cid = Request::getVar('cid', array(), '', 'array');
     $extension = Request::getVar('extension', null);
     if (!is_array($cid) || count($cid) < 1) {
         Notify::error(Lang::txt($this->text_prefix . '_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         \Hubzero\Utility\Arr::toInteger($cid);
         // Remove the items.
         if ($model->delete($cid)) {
             $this->setMessage(Lang::txts($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $this->setRedirect(Route::url('index.php?option=' . $this->option . '&extension=' . $extension, false));
 }
Пример #9
0
        echo Html::asset('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true);
        ?>
					<?php 
    }
    ?>
				</td>
				<td class="center priority-4">
					<?php 
    if ($item->assigned > 0) {
        ?>
						<span class="state yes" title="<?php 
        echo Lang::txts('COM_TEMPLATES_ASSIGNED', $item->assigned);
        ?>
">
							<span class="text"><?php 
        echo Lang::txts('COM_TEMPLATES_ASSIGNED', $item->assigned);
        ?>
</span>
						</span>
					<?php 
    } else {
        ?>
						&#160;
					<?php 
    }
    ?>
				</td>
				<td class="priority-5 center">
					<?php 
    echo (int) $item->id;
    ?>
Пример #10
0
 /**
  * Function to convert a static time into a relative measurement
  *
  * @param   string  $date  The date to convert
  * @param   string  $unit  The optional unit of measurement to return
  *                         if the value of the diff is greater than one
  * @param   string  $time  An optional time to compare to, defaults to now
  * @return  string  The converted time string
  */
 public function relative($unit = null, $time = null)
 {
     if (is_null($time)) {
         // Get now
         $time = new self('now');
     }
     // Get the difference in seconds between now and the time
     $diff = strtotime($time) - strtotime($this);
     // Less than a minute
     if ($diff < 60) {
         return \Lang::txt('JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE');
     }
     // Round to minutes
     $diff = round($diff / 60);
     // 1 to 59 minutes
     if ($diff < 60 || $unit == 'minute') {
         return \Lang::txts('JLIB_HTML_DATE_RELATIVE_MINUTES', $diff);
     }
     // Round to hours
     $diff = round($diff / 60);
     // 1 to 23 hours
     if ($diff < 24 || $unit == 'hour') {
         return \Lang::txts('JLIB_HTML_DATE_RELATIVE_HOURS', $diff);
     }
     // Round to days
     $diff = round($diff / 24);
     // 1 to 6 days
     if ($diff < 7 || $unit == 'day') {
         return \Lang::txts('JLIB_HTML_DATE_RELATIVE_DAYS', $diff);
     }
     // Round to weeks
     $diff = round($diff / 7);
     // 1 to 4 weeks
     if ($diff <= 4 || $unit == 'week') {
         return \Lang::txts('JLIB_HTML_DATE_RELATIVE_WEEKS', $diff);
     }
     // [!] HUBZERO - Added months
     // Round to months
     /*$diff = round($diff / 4);
     
     		// 1 to 12 months
     		if ($diff <= 12 || $unit == 'month')
     		{
     			return \Lang::txt('%s months ago', $diff);
     		}*/
     // [!] HUBZERO - Changed default to format "% days ago"
     // Over a month, return the absolute time
     $text = $this->_ago(strtotime($this), strtotime($time));
     $parts = explode(' ', $text);
     $text = $parts[0] . ' ' . $parts[1];
     $text .= $parts[2] ? ' ' . $parts[2] . ' ' . $parts[3] : '';
     return sprintf('%s ago', $text);
 }
Пример #11
0
echo $this->module->module;
?>
">
	<?php 
if (count($this->unapproved) > 0) {
    ?>
		<div class="pending-users">
			<a href="<?php 
    echo Route::url('index.php?option=com_users&view=users&filter.approved=0');
    ?>
">
				<span class="count"><?php 
    echo count($this->unapproved);
    ?>
</span>
				<?php 
    echo Lang::txts('MOD_USERS_REQUIRE_APPROVAL', count($this->unapproved));
    ?>
			</a>
		</div>
	<?php 
} else {
    ?>
		<div class="none"><?php 
    echo Lang::txt('MOD_USERS_ALL_CLEAR');
    ?>
</div>
	<?php 
}
?>
</div>
Пример #12
0
 /**
  * Method to approve users
  *
  * @return  void
  */
 public function approve()
 {
     // Check for request forgeries.
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Initialise variables.
     $ids = Request::getVar('cid', array(), '', 'array');
     if (empty($ids)) {
         throw new Exception(Lang::txt('COM_USERS_USERS_NO_ITEM_SELECTED'), 500);
     } else {
         // Get the model.
         $model = $this->getModel();
         // Change the state of the records.
         if (!$model->approve($ids)) {
             throw new Exception($model->getError(), 500);
         } else {
             $this->setMessage(Lang::txts('COM_USERS_N_USERS_APPROVED', count($ids)));
         }
     }
     $this->setRedirect('index.php?option=com_users&view=users');
 }
Пример #13
0
 /**
  * Deletes paths from the current path
  *
  * @since 1.5
  */
 public function delete()
 {
     Session::checkToken(['get', 'post']);
     // Get some data from the request
     $tmpl = Request::getCmd('tmpl');
     $paths = Request::getVar('rm', array(), '', 'array');
     $folder = Request::getVar('folder', '', '', 'path');
     $redirect = 'index.php?option=com_media&folder=' . $folder;
     if ($tmpl == 'component') {
         // We are inside the iframe
         $redirect .= '&view=mediaList&tmpl=component';
     }
     $this->setRedirect($redirect);
     // Nothing to delete
     if (empty($paths)) {
         return true;
     }
     // Authorize the user
     if (!$this->authoriseUser('delete')) {
         return false;
     }
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     // Initialise variables.
     $ret = true;
     foreach ($paths as $path) {
         if ($path !== Filesystem::clean($path)) {
             // filename is not safe
             $filename = htmlspecialchars($path, ENT_COMPAT, 'UTF-8');
             Notify::warning(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', substr($filename, strlen(COM_MEDIA_BASE))));
             continue;
         }
         $fullPath = Filesystem::cleanPath(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path)));
         $object_file = new \Hubzero\Base\Object(array('filepath' => $fullPath));
         if (is_file($fullPath)) {
             // Trigger the onContentBeforeDelete event.
             $result = Event::trigger('content.onContentBeforeDelete', array('com_media.file', &$object_file));
             if (in_array(false, $result, true)) {
                 // There are some errors in the plugins
                 Notify::warning(Lang::txts('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
                 continue;
             }
             $ret &= Filesystem::delete($fullPath);
             // Trigger the onContentAfterDelete event.
             Event::trigger('content.onContentAfterDelete', array('com_media.file', &$object_file));
             $this->setMessage(Lang::txt('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
         } elseif (is_dir($fullPath)) {
             $contents = Filesystem::files($fullPath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html'));
             if (empty($contents)) {
                 // Trigger the onContentBeforeDelete event.
                 $result = Event::trigger('content.onContentBeforeDelete', array('com_media.folder', &$object_file));
                 if (in_array(false, $result, true)) {
                     // There are some errors in the plugins
                     Notify::warning(Lang::txts('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
                     continue;
                 }
                 $ret &= Filesystem::deleteDirectory($fullPath);
                 // Trigger the onContentAfterDelete event.
                 Event::trigger('content.onContentAfterDelete', array('com_media.folder', &$object_file));
                 $this->setMessage(Lang::txt('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
             } else {
                 // This makes no sense...
                 Notify::warning(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY', substr($fullPath, strlen(COM_MEDIA_BASE))));
             }
         }
     }
     return $ret;
 }
Пример #14
0
 /**
  * Create a folder
  *
  * @param string $path Path of the folder to create
  * @since 1.5
  */
 public function create()
 {
     // Check for request forgeries
     Session::checkToken(['get', 'post']);
     $folder = Request::getCmd('foldername', '');
     $folderCheck = Request::getVar('foldername', null, '', 'string', JREQUEST_ALLOWRAW);
     $parent = Request::getVar('folderbase', '', '', 'path');
     $this->setRedirect('index.php?option=com_media&folder=' . $parent . '&tmpl=' . Request::getCmd('tmpl', 'index'));
     if (strlen($folder) > 0) {
         if (!User::authorise('core.create', 'com_media')) {
             // User is not authorised to delete
             Notify::warning(Lang::txt('JLIB_APPLICATION_ERROR_CREATE_NOT_PERMITTED'));
             return false;
         }
         // Set FTP credentials, if given
         JClientHelper::setCredentialsFromRequest('ftp');
         Request::setVar('folder', $parent);
         if ($folderCheck !== null && $folder !== $folderCheck) {
             $this->setMessage(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_CREATE_FOLDER_WARNDIRNAME'));
             return false;
         }
         $path = \Hubzero\Filesystem\Util::normalizePath(COM_MEDIA_BASE . '/' . $parent . '/' . $folder);
         if (!is_dir($path) && !is_file($path)) {
             // Trigger the onContentBeforeSave event.
             $object_file = new \Hubzero\Base\Object(array('filepath' => $path));
             $result = Event::trigger('content.onContentBeforeSave', array('com_media.folder', &$object_file, true));
             if (in_array(false, $result, true)) {
                 // There are some errors in the plugins
                 Notify::warning(Lang::txts('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
                 return false;
             }
             Filesystem::makeDirectory($path);
             $data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
             Filesystem::write($path . "/index.html", $data);
             // Trigger the onContentAfterSave event.
             Event::trigger('content.onContentAfterSave', array('com_media.folder', &$object_file, true));
             $this->setMessage(Lang::txt('COM_MEDIA_CREATE_COMPLETE', substr($path, strlen(COM_MEDIA_BASE))));
         }
         Request::setVar('folder', $parent ? $parent . '/' . $folder : $folder);
     }
 }
Пример #15
0
    echo Html::sliders('start', 'database-sliders', array('useCookie' => 1));
    ?>

		<?php 
} else {
    ?>
			<p class="warning"><?php 
    echo Lang::txt('COM_INSTALLER_MSG_DATABASE_ERRORS');
    ?>
</p>
			<?php 
    echo Html::sliders('start', 'database-sliders', array('useCookie' => 1));
    ?>

			<?php 
    $panelName = Lang::txts('COM_INSTALLER_MSG_N_DATABASE_ERROR_PANEL', $this->errorCount);
    ?>
			<?php 
    echo Html::sliders('panel', $panelName, 'error-panel');
    ?>
			<fieldset class="panelform">
				<ul>
					<?php 
    if (!$this->filterParams) {
        ?>
						<li><?php 
        echo Lang::txt('COM_INSTALLER_MSG_DATABASE_FILTER_ERROR');
        ?>
					<?php 
    }
    ?>
Пример #16
0
 public function send()
 {
     // Initialise variables.
     $data = Request::getVar('jform', array(), 'post', 'array');
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $acl = JFactory::getACL();
     $db = $this->getDbo();
     $mode = array_key_exists('mode', $data) ? intval($data['mode']) : 0;
     $subject = array_key_exists('subject', $data) ? $data['subject'] : '';
     $grp = array_key_exists('group', $data) ? intval($data['group']) : 0;
     $recurse = array_key_exists('recurse', $data) ? intval($data['recurse']) : 0;
     $bcc = array_key_exists('bcc', $data) ? intval($data['bcc']) : 0;
     $disabled = array_key_exists('disabled', $data) ? intval($data['disabled']) : 0;
     $message_body = array_key_exists('message', $data) ? $data['message'] : '';
     // automatically removes html formatting
     if (!$mode) {
         $message_body = JFilterInput::getInstance()->clean($message_body, 'string');
     }
     // Check for a message body and subject
     if (!$message_body || !$subject) {
         $app->setUserState('com_users.display.mail.data', $data);
         $this->setError(Lang::txt('COM_USERS_MAIL_PLEASE_FILL_IN_THE_FORM_CORRECTLY'));
         return false;
     }
     // get users in the group out of the acl
     $to = $acl->getUsersByGroup($grp, $recurse);
     // Get all users email and group except for senders
     $query = $db->getQuery(true);
     $query->select('email');
     $query->from('#__users');
     $query->where('id != ' . (int) $user->get('id'));
     if ($grp !== 0) {
         if (empty($to)) {
             $query->where('0');
         } else {
             $query->where('id IN (' . implode(',', $to) . ')');
         }
     }
     if ($disabled == 0) {
         $query->where("block = 0");
     }
     $db->setQuery($query);
     $rows = $db->loadColumn();
     // Check to see if there are any users in this group before we continue
     if (!count($rows)) {
         $app->setUserState('com_users.display.mail.data', $data);
         if (in_array($user->id, $to)) {
             $this->setError(Lang::txt('COM_USERS_MAIL_ONLY_YOU_COULD_BE_FOUND_IN_THIS_GROUP'));
         } else {
             $this->setError(Lang::txt('COM_USERS_MAIL_NO_USERS_COULD_BE_FOUND_IN_THIS_GROUP'));
         }
         return false;
     }
     // Get the Mailer
     $mailer = JFactory::getMailer();
     $params = Component::params('com_users');
     // Build email message format.
     $mailer->setSender(array($app->getCfg('mailfrom'), $app->getCfg('fromname')));
     $mailer->setSubject($params->get('mailSubjectPrefix') . stripslashes($subject));
     $mailer->setBody($message_body . $params->get('mailBodySuffix'));
     $mailer->IsHTML($mode);
     // Add recipients
     if ($bcc) {
         $mailer->addBCC($rows);
         $mailer->addRecipient($app->getCfg('mailfrom'));
     } else {
         $mailer->addRecipient($rows);
     }
     // Send the Mail
     $rs = $mailer->Send();
     // Check for an error
     if ($rs instanceof Exception) {
         $app->setUserState('com_users.display.mail.data', $data);
         $this->setError($rs->getError());
         return false;
     } elseif (empty($rs)) {
         $app->setUserState('com_users.display.mail.data', $data);
         $this->setError(Lang::txt('COM_USERS_MAIL_THE_MAIL_COULD_NOT_BE_SENT'));
         return false;
     } else {
         // Fill the data (specially for the 'mode', 'group' and 'bcc': they could not exist in the array
         // when the box is not checked and in this case, the default value would be used instead of the '0'
         // one)
         $data['mode'] = $mode;
         $data['subject'] = $subject;
         $data['group'] = $grp;
         $data['recurse'] = $recurse;
         $data['bcc'] = $bcc;
         $data['message'] = $message_body;
         $app->setUserState('com_users.display.mail.data', array());
         $app->enqueueMessage(Lang::txts('COM_USERS_MAIL_EMAIL_SENT_TO_N_USERS', count($rows)), 'message');
         return true;
     }
 }
Пример #17
0
 /**
  * Method to save the form data.
  *
  * @param	array	The form data.
  * @return	boolean	True on success.
  */
 public function save($data)
 {
     // Detect disabled extension
     $extension = JTable::getInstance('Extension');
     if ($extension->load(array('enabled' => 0, 'type' => 'template', 'element' => $data['template'], 'client_id' => $data['client_id']))) {
         $this->setError(Lang::txt('COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE'));
         return false;
     }
     // Initialise variables;
     $table = $this->getTable();
     $pk = !empty($data['id']) ? $data['id'] : (int) $this->getState('style.id');
     $isNew = true;
     // Load the row if saving an existing record.
     if ($pk > 0) {
         $table->load($pk);
         $isNew = false;
     }
     if (Request::getVar('task') == 'save2copy') {
         $data['title'] = $this->generateNewTitle(null, null, $data['title']);
         $data['home'] = 0;
         $data['assigned'] = '';
     }
     // Bind the data.
     if (!$table->bind($data)) {
         $this->setError($table->getError());
         return false;
     }
     // Prepare the row for saving
     $this->prepareTable($table);
     // Check the data.
     if (!$table->check()) {
         $this->setError($table->getError());
         return false;
     }
     // Trigger the onExtensionBeforeSave event.
     $result = Event::trigger('extension.onExtensionBeforeSave', array('com_templates.style', &$table, $isNew));
     if (in_array(false, $result, true)) {
         $this->setError($table->getError());
         return false;
     }
     // Store the data.
     if (!$table->store()) {
         $this->setError($table->getError());
         return false;
     }
     if (User::authorise('core.edit', 'com_menus') && $table->client_id == 0) {
         $n = 0;
         $db = App::get('db');
         if (!empty($data['assigned']) && is_array($data['assigned'])) {
             \Hubzero\Utility\Arr::toInteger($data['assigned']);
             // Update the mapping for menu items that this style IS assigned to.
             $query = $db->getQuery(true);
             $query->update('#__menu');
             $query->set('template_style_id=' . (int) $table->id);
             $query->where('id IN (' . implode(',', $data['assigned']) . ')');
             $query->where('template_style_id!=' . (int) $table->id);
             $query->where('checked_out in (0,' . (int) User::get('id') . ')');
             $db->setQuery($query);
             $db->query();
             $n += $db->getAffectedRows();
         }
         // Remove style mappings for menu items this style is NOT assigned to.
         // If unassigned then all existing maps will be removed.
         $query = $db->getQuery(true);
         $query->update('#__menu');
         $query->set('template_style_id=0');
         if (!empty($data['assigned'])) {
             $query->where('id NOT IN (' . implode(',', $data['assigned']) . ')');
         }
         $query->where('template_style_id=' . (int) $table->id);
         $query->where('checked_out in (0,' . (int) User::get('id') . ')');
         $db->setQuery($query);
         $db->query();
         $n += $db->getAffectedRows();
         if ($n > 0) {
             Notify::success(Lang::txts('COM_TEMPLATES_MENU_CHANGED', $n));
         }
     }
     // Clean the cache.
     $this->cleanCache();
     // Trigger the onExtensionAfterSave event.
     Event::trigger('extension.onExtensionAfterSave', array('com_templates.style', &$table, $isNew));
     $this->setState('style.id', $table->id);
     return true;
 }
Пример #18
0
 /**
  * Method to set the home property for a list of items
  *
  * @since	1.6
  */
 function setDefault()
 {
     // Check for request forgeries
     Session::checkToken('request') or die(Lang::txt('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = Request::getVar('cid', array(), '', 'array');
     $data = array('setDefault' => 1, 'unsetDefault' => 0);
     $task = $this->getTask();
     $value = \Hubzero\Utility\Arr::getValue($data, $task, 0, 'int');
     if (empty($cid)) {
         throw new Exception(Lang::txt($this->text_prefix . '_NO_ITEM_SELECTED'), 500);
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         \Hubzero\Utility\Arr::toInteger($cid);
         // Publish the items.
         if (!$model->setHome($cid, $value)) {
             throw new Exception($model->getError(), 500);
         } else {
             if ($value == 1) {
                 $ntext = 'COM_MENUS_ITEMS_SET_HOME';
             } else {
                 $ntext = 'COM_MENUS_ITEMS_UNSET_HOME';
             }
             $this->setMessage(Lang::txts($ntext, count($cid)));
         }
     }
     $this->setRedirect(Route::url('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
Пример #19
0
 /**
  * Method to start the password reset process.
  *
  * @since	1.6
  */
 public function processResetRequest($data)
 {
     // Get the form.
     $form = $this->getForm();
     // Check for an error.
     if ($form instanceof Exception) {
         return $form;
     }
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data);
     // Check for an error.
     if ($return instanceof Exception) {
         return $return;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $message) {
             $this->setError($message);
         }
         return false;
     }
     // Find the user id for the given username
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from($db->quoteName('#__users'));
     $query->where($db->quoteName('username') . ' = ' . $db->Quote($data['username']));
     // Get the user object.
     $db->setQuery((string) $query);
     $userId = $db->loadResult();
     // Check for an error.
     if ($db->getErrorNum()) {
         $this->setError(Lang::txt('COM_USERS_DATABASE_ERROR', $db->getErrorMsg()), 500);
         return false;
     }
     // Check for a user.
     if (empty($userId)) {
         $this->setError(Lang::txt('COM_USERS_INVALID_USERNAME'));
         return false;
     }
     // Get the user object.
     $user = JUser::getInstance($userId);
     // Make sure the user isn't blocked.
     if ($user->block) {
         $this->setError(Lang::txt('COM_USERS_USER_BLOCKED'));
         return false;
     }
     // Make sure the user isn't a Super Admin.
     if ($user->authorise('core.admin')) {
         $this->setError(Lang::txt('COM_USERS_REMIND_SUPERADMIN_ERROR'));
         return false;
     }
     // Make sure the user has not exceeded the reset limit
     if (!$this->checkResetLimit($user)) {
         $resetLimit = (int) JFactory::getApplication()->getParams()->get('reset_time');
         $this->setError(Lang::txts('COM_USERS_REMIND_LIMIT_ERROR_N_HOURS', $resetLimit));
         return false;
     }
     // Set the confirmation token.
     $token = App::hash(JUserHelper::genRandomPassword());
     $salt = JUserHelper::getSalt('crypt-md5');
     $hashedToken = md5($token . $salt) . ':' . $salt;
     $user->activation = $hashedToken;
     // Save the user to the database.
     if (!$user->save(true)) {
         return new Exception(Lang::txt('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500);
     }
     // Assemble the password reset confirmation link.
     $mode = Config::get('force_ssl', 0) == 2 ? 1 : -1;
     $itemid = UsersHelperRoute::getLoginRoute();
     $itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
     $link = 'index.php?option=com_users&view=reset&layout=confirm' . $itemid;
     // Put together the email template data.
     $data = $user->getProperties();
     $data['fromname'] = Config::get('fromname');
     $data['mailfrom'] = Config::get('mailfrom');
     $data['sitename'] = Config::get('sitename');
     $data['link_text'] = Route::url($link, false, $mode);
     $data['link_html'] = Route::url($link, true, $mode);
     $data['token'] = $token;
     $subject = Lang::txt('COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', $data['sitename']);
     $body = Lang::txt('COM_USERS_EMAIL_PASSWORD_RESET_BODY', $data['sitename'], $data['token'], $data['link_text']);
     // Send the password reset request email.
     $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $user->email, $subject, $body);
     // Check for an error.
     if ($return !== true) {
         return new Exception(Lang::txt('COM_USERS_MAIL_FAILED'), 500);
     }
     // Push the user data into the session.
     $app = JFactory::getApplication();
     $app->setUserState('com_users.reset.user', $user->id);
     return true;
 }
Пример #20
0
        echo Route::url('index.php?option=' . $this->option . '&controller=notes&filter_search=uid:' . (int) $row->get('id'));
        ?>
" title="<?php 
        echo Lang::txt('COM_USERS_FILTER_NOTES');
        ?>
">
								<span><?php 
        echo Lang::txt('COM_USERS_NOTES');
        ?>
</span>
							</a>
							<a class="modal state notes" href="<?php 
        echo Route::url('index.php?option=' . $this->option . '&controller=notes&tmpl=component&task=modal&id=' . (int) $row->get('id'));
        ?>
" rel="{handler: 'iframe', size: {x: 800, y: 450}}" title="<?php 
        echo Lang::txts('COM_MEMBERS_N_USER_NOTES', $count);
        ?>
">
								<span><?php 
        echo Lang::txt('COM_USERS_NOTES');
        ?>
</span>
							</a>
						<?php 
    }
    ?>
						<a class="state notes" href="<?php 
    echo Route::url('index.php?option=' . $this->option . '&controller=notes&task=add&user_id=' . (int) $row->get('id'));
    ?>
" title="<?php 
    echo Lang::txt('COM_USERS_ADD_NOTE');