public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     // Get view related request variables.
     $this->type = $app->input->get('type', '', 'cmd');
     $this->pid = $app->input->get('pid', 0, 'int');
     // Get model data.
     $m = $this->getModel();
     $this->state = $this->get('State');
     $this->isecure = $m->itemIsSecure($this->pid);
     $item = $m->getItem($app->input->get('nid', 0, 'int'));
     //echo'<xmp>';var_dump($item);echo'</xmp>';jexit();
     // Construct the breadcrumb
     $this->buildPathway($item ? $item->itemID : $this->pid);
     if ($item && (int) $item->secured) {
         $item->title = base64_decode($item->title);
         if ($item->contentID) {
             $cookn = UserNotesHelper::hashCookieName($item->itemID, $item->contentID);
             $cookv = $app->input->cookie->getBase64($cookn);
             if ($cookv) {
                 setcookie($cookn, '', time() - 3600);
                 $item->ephrase = UserNotesHelper::doCrypt($item->itemID . '-@:' . $item->contentID, base64_decode($cookv), true);
             } elseif ($ephrase = $app->input->post->get('ephrase', '', 'string')) {
                 $item->ephrase = $ephrase;
             } else {
                 $this->item = $item;
                 return parent::display('ephrase');
             }
             $item->serial_content = UserNotesHelper::doCrypt($item->ephrase, base64_decode($item->serial_content), true);
         }
     }
     if (!$item) {
         $item = (object) array('itemID' => 0, 'parentID' => $this->pid, 'contentID' => null, 'checked_out' => null, 'secured' => $this->isecure ? '1' : null);
     } else {
         $m->checkOut($item->itemID);
     }
     $this->item = $item;
     $this->form = $m->getForm($item);
     if ($this->type == 'f') {
         if ($this->isecure) {
             $this->form->removeField('maksec');
         } else {
             $this->form->removeField('pissec');
         }
     }
     //echo'<xmp>';var_dump($this->form);jexit();
     $this->form->setFieldAttribute('ephrase', 'type', 'password');
     // Check for errors.
     // @TODO: Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Get the current menu item
     $this->params = $app->getParams();
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareDocument();
     return parent::display($tpl);
 }
Example #2
0
 public function __construct($config = array())
 {
     $udbPath = UserNotesHelper::userDataPath() . '/usernotes.db3';
     $db = JDatabaseDriver::getInstance(array('driver' => 'sqlite', 'database' => $udbPath));
     $config['dbo'] = $db;
     parent::__construct($config);
 }
 public function convertDb()
 {
     $sdp = UserNotesHelper::getStorageBase();
     $cids = $this->input->get('cid', array(), 'array');
     $view = $this->input->get('view');
     $tc = $view == 'usernotes' ? '@' : '_';
     foreach ($cids as $cid) {
         UserNotesHelperDb::convertDb(JPATH_ROOT . '/' . $sdp . '/' . $tc . $cid . '/' . JApplicationHelper::getComponentName());
     }
     $this->setRedirect('index.php?option=com_usernotes&view=' . $view, JText::_('COM_USERSCHED_MSG_COMPLETE'));
 }
 private function buildBranch($id, $ind, &$rows, &$tree)
 {
     foreach ($rows as $row) {
         if ($row->parentID == $id) {
             if ($row->secured) {
                 $row->title = base64_decode($row->title);
             }
             $tree[$row->itemID] = $ind . UserNotesHelper::fs_db($row->title);
             $this->buildBranch($row->itemID, $ind . '-&nbsp;', $rows, $tree);
         }
     }
 }
 public function begin()
 {
     if (!$this->uid) {
         return;
     }
     $htm = '<!DOCTYPE html><title></title>';
     $udp = UserNotesHelper::userDataPath();
     mkdir($udp . '/attach', 0777, true);
     file_put_contents($udp . '/index.html', $htm);
     file_put_contents($udp . '/attach/index.html', $htm);
     $this->setRedirect(JRoute::_('index.php?option=com_usernotes', false));
 }
 public function getItems()
 {
     //return array();
     // Get a storage key.
     $store = $this->getStoreId('list');
     // Try to load the data from internal storage.
     if (isset($this->cache[$store])) {
         return $this->cache[$store];
     }
     $unotes = array();
     $folds = UserNotesHelper::getDbPaths($this->relm, 'usernotes');
     foreach ($folds as $fold) {
         $userid = (int) substr($fold, 1);
         if ($this->relm == 'u') {
             $user = JUser::getInstance($userid);
             $unotes[] = array('name' => $user->name, 'uname' => $user->username, 'uid' => $userid);
         } else {
             $unotes[] = array('uname' => UserNotesHelper::getGroupTitle($userid), 'name' => 'group', 'uid' => $userid);
         }
     }
     $this->_total = count($unotes);
     $start = $this->getState('list.start');
     $limit = $this->getState('list.limit');
     $listOrder = $this->getState('list.ordering');
     $listDirn = $this->getState('list.direction');
     //	echo $listOrder;echo $listDirn;
     foreach ($unotes as $key => $row) {
         $name[$key] = $row['name'];
         $uname[$key] = $row['uname'];
         $uid[$key] = $row['uid'];
     }
     if ($this->_total) {
         // Sort the data with volume descending, edition ascending
         // Add $data as the last parameter, to sort by the common key
         switch ($listOrder) {
             case 'username':
                 array_multisort($uname, SORT_ASC, $name, SORT_ASC, $uid, SORT_ASC, $unotes);
                 break;
             case 'fullname':
                 array_multisort($name, SORT_ASC, $uname, SORT_ASC, $uid, SORT_ASC, $unotes);
                 break;
             case 'userid':
                 array_multisort($uid, SORT_ASC, $uname, SORT_ASC, $name, SORT_ASC, $unotes);
                 break;
         }
     }
     // Add the items to the internal cache.
     $this->cache[$store] = array_slice($unotes, $start, $limit ? $limit : null);
     return $this->cache[$store];
 }
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $canDo = UserNotesHelper::getActions();
     JToolBarHelper::title(JText::_('COM_USERNOTES_MENU') . ' : ' . JText::_('COM_USERNOTES_MANAGER_UNOTES'), 'stack usernotes');
     JToolBarHelper::deleteList(JText::_('COM_USERNOTES_MANAGER_DELETEOK'));
     //JToolBarHelper::trash('usernotes.trash');
     //	if ($canDo->get('core.edit.state')) {
     //		JToolBarHelper::custom('notes.reset', 'refresh.png', 'refresh_f2.png', 'JUSERSCHED_RESET', false);
     //	}
     JToolBarHelper::divider();
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_usernotes');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('user_schedulers', true);
 }
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     // Get view related request variables.
     $this->down = $app->input->get('down', 0, 'int');
     $cat = explode('|', $app->input->getString('cat'), 2);
     $this->fnam = $cat[1];
     // Get path to file
     $udp = UserNotesHelper::userDataPath();
     $this->fpath = JPATH_BASE . '/' . $udp . '/attach/' . $cat[0] . '/' . $cat[1];
     // Get file mime type
     if (file_exists($this->fpath)) {
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         $this->mime = finfo_file($finfo, $this->fpath);
     }
     return parent::display($tpl);
 }
Example #9
0
 protected function _prepareDocument()
 {
     if ($this->userID) {
         if (UserNotesHelper::userAuth($this->userID) > 1) {
             if ($this->item && $this->item->checked_out && $this->item->checked_out != $this->userID) {
                 $this->footMsg = 'Checked out by ' . JFactory::getUser($this->item->checked_out)->get('username') . '.';
             } else {
                 $this->access = 15;
             }
         }
     }
     // Get a notes instance identifier for ajax/upload
     $this->notesID = UserNotesHelper::getInstanceID();
     //	$this->attached = @unserialize($this->item->attached);
     if (isset($this->item->attached)) {
         $this->attached = $this->item->attached;
     }
 }
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     // Get view related request variables.
     // Get model data.
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     //var_dump($this->item);
     // Construct the breadcrumb
     $this->buildPathway($this->item->itemID);
     //		if ($this->state->secured && !$app->input->post->get('ephrase','','string')) {
     if ($this->item->secured && !$app->input->post->get('ephrase', '', 'string')) {
         return parent::display('ephrase');
     }
     //echo'<xmp>';var_dump($app->input->post->get('ephrase','','string'), $this->item, UserNotesHelper::hashCookieName($this->item->itemID, $this->item->contentID));echo'</xmp>';
     //		if ($this->state->secured) {
     if ($this->item->secured) {
         $cookn = UserNotesHelper::hashCookieName($this->item->itemID, $this->item->contentID);
         $ephrase = $app->input->post->get('ephrase', '', 'string');
         $this->item->serial_content = UserNotesHelper::doCrypt($ephrase, base64_decode($this->item->serial_content), true);
         $cookv = UserNotesHelper::doCrypt($this->item->itemID . '-@:' . $this->item->contentID, $ephrase);
         setcookie($cookn, base64_encode($cookv), 0, '', '', true);
     }
     // Check for errors.
     // @TODO: Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Get the component parameters
     $cparams = JComponentHelper::getParams('com_usernotes');
     // Get the current menu item
     $this->params = $app->getParams();
     // Meld the params
     if (!$this->params->get('maxUpload')) {
         $this->params->set('maxUpload', $cparams->get('maxUpload', UserNotesHelper::phpMaxUp()));
     }
     // establish the max file upload size
     $this->maxUploadBytes = min($this->params->get('maxUpload'), UserNotesHelper::phpMaxUp());
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareDocument();
     return parent::display($tpl);
 }
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     // Get view related request variables.
     // Get model data.
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->item = $this->getModel()->getItem();
     $this->parentID = $this->state->get('parent.id');
     // If at the root, check storage useage and queue a message if near quota
     if (!$this->parentID) {
         $mparams = $app->getParams();
         $storQuota = (int) $mparams->get('storQuota', 0);
         if (!$storQuota) {
             $storQuota = (int) $this->state->cparams->get('storQuota', 0);
         }
         if ($storQuota) {
             $storSize = $this->get('StorSize');
             $posq = $storSize / $storQuota;
             if ($posq > 0.9) {
                 $svty = 'notice';
                 $msg = JText::sprintf('COM_USERNOTES_NOTICE_QUOTA', UserNotesHelper::formatBytes($storSize, 1, ''), $posq * 100);
                 if ($posq > 0.95) {
                     $svty = 'warning';
                     $msg = '<span style="color:red">' . $msg . '</span>';
                 }
                 $app->enqueueMessage($msg, $svty);
             }
         }
     }
     // Create breadcrumbs to this item
     $this->buildPathway($this->parentID);
     // Check for errors.
     // @TODO: Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Get the component parameters
     $this->cparams = JComponentHelper::getParams('com_usernotes');
     $this->_prepareDocument();
     return parent::display($tpl);
 }
Example #12
0
/**
 * @package    com_usernotes
 *
 * @copyright  Copyright (C) 2016 RJCreations - All rights reserved.
 * @license    GNU General Public License version 3 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
//var_dump('vdf',$this);jexit();
$listOrder = $this->state('list.ordering');
$listDirn = $this->state('list.direction');
$canDo = UserNotesHelper::getActions();
?>
<form action="<?php 
echo JRoute::_('index.php?option=com_usernotes&view=usernotes');
?>
" method="post" name="adminForm" id="adminForm">
	<div id="j-sidebar-container" class="span2">
		<?php 
echo $this->sidebar;
?>
	</div>
	<div id="j-main-container" class="span10">
		<table class="table table-striped adminlist">
			<thead>
				<tr>
					<th width="1%"></th>
Example #13
0
 * @license    GNU General Public License version 3 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
JHtml::stylesheet('components/com_usernotes/static/css/oopim.css');
JHtml::_('jquery.framework', false);
$jdoc = JFactory::getDocument();
$jdoc->addScript('components/com_usernotes/static/js/oopim.js');
$jdoc->addScript('components/com_usernotes/static/js/notesview.js');
if ($this->item && $this->item->secured && $_SERVER['SERVER_PORT'] != 443) {
    //JError::raiseNotice(100, 'You do not have a secure connection!', 'error');
    JFactory::getApplication()->enqueueMessage('<span style="color:red">' . JText::_('COM_USERNOTES_NOTICE_INSECURE') . '</span>', 'warning');
    //echo '<div style="background-color:red;color:white;">WARNING: You do not have a secure connection!</div>';
}
if (isset($this->posq)) {
    $svty = 'notice';
    $msg = JText::sprintf('COM_USERNOTES_NOTICE_QUOTA', UserNotesHelper::formatBytes($this->storSize, 1, ''), $this->posq * 100);
    if ($this->posq > 0.95) {
        $svty = 'warning';
        $msg = '<span style="color:red">' . $msg . '</span>';
    }
    JFactory::getApplication()->enqueueMessage($msg, $svty);
}
//JFactory::getApplication()->enqueueMessage('<span style="color:red">'.JText::_('Storage usage is at 90% of quota!').'</span>', 'warning');
//JError::raiseNotice(100, 'Storage usage is at 90% of quota!');
//var_dump($this->params);echo'<br /><br />';var_dump(JComponentHelper::getParams('com_usernotes'));
if ($this->state->secured && $_SERVER['SERVER_PORT'] != 443) {
    $securl = $this->cparams->get('secureurl', '');
    if (!$securl) {
        $hostname = php_uname('n');
        $hostaddr = $_SERVER['SERVER_ADDR'];
        $paths = explode('/', __FILE__);
 private static function getTypeOwner()
 {
     if (is_null(self::$instanceType)) {
         $app = JFactory::getApplication();
         $notesid = $app->input->getBase64('unID');
         if ($notesid) {
             $nids = explode(':', base64_decode($notesid));
             self::$instanceType = $nids[0];
             self::$ownerID = $nids[1];
         } else {
             $params = $app->getParams();
             self::$instanceType = $params->get('notes_type');
             switch (self::$instanceType) {
                 case 0:
                     self::$ownerID = JFactory::getUser()->get('id');
                     if (!self::$ownerID) {
                         self::$ownerID = -1;
                     }
                     break;
                 case 1:
                     self::$ownerID = $params->get('group_auth');
                     break;
                 case 2:
                     self::$ownerID = $params->get('site_auth');
                     break;
             }
         }
         //var_dump(self::$instanceType,self::$ownerID);
     }
 }
Example #15
0
 public function add_attached($contentID = 0, $files = NULL, $notesid = null)
 {
     if (!$contentID || !$files) {
         return;
     }
     $path = JPATH_BASE . '/' . UserNotesHelper::userDataPath() . '/attach/' . $contentID;
     $msg = '';
     $fns = array();
     foreach ($files as $file) {
         if ($file['error'] == UPLOAD_ERR_OK) {
             $tmp_name = $file['tmp_name'];
             if (is_uploaded_file($tmp_name)) {
                 @mkdir($path);
                 $name = $file['name'];
                 move_uploaded_file($tmp_name, $path . '/' . $name);
                 $fns[] = $name;
             } else {
                 $msg .= 'failed to upload';
             }
         } elseif ($file['error'] != UPLOAD_ERR_NO_FILE) {
             $msg .= "Error: {$file['error']}";
         }
     }
     if ($fns) {
         try {
             $db = $this->getDbo();
             foreach ($fns as $fn) {
                 $fsz = filesize($path . '/' . $fn);
                 $db->setQuery('SELECT attached FROM fileatt WHERE contentID=' . $contentID . ' AND attached=' . $db->quote($fn));
                 $r = $db->loadResult();
                 if ($r) {
                     $db->setQuery('UPDATE fileatt SET fsize=' . $fsz . ' WHERE contentID=' . $contentID . ' AND attached=' . $db->quote($fn));
                     $db->execute();
                 } else {
                     $db->setQuery('INSERT INTO fileatt (contentID,fsize,attached) VALUES (' . $contentID . ',' . $fsz . ',' . $db->quote($fn) . ')');
                     $db->execute();
                 }
             }
         } catch (Exception $e) {
             $this->setError($e);
         }
     }
     if ($msg) {
         var_dump($contentID, $msg);
     }
 }
Example #16
0
		<li><a href="#" onclick="toolAct(event,'unfrac')" title="Return HTML fractions to text">un-Fractionize</a></li>
<?php 
    if ($this->attached) {
        ?>
		<li><a href="#" onclick="toolAct(event,'delatts')" title="Delete all attachments" data-sure="delete all attachments"><?php 
        echo JText::_('Delete attachments');
        ?>
</a></li>
<?php 
    }
    ?>
	</ul>
</div>
<div id="filupld" class="uplddlog" style="display:none;">
	<span style="color:#36C;">Max file upload size: <?php 
    echo UserNotesHelper::formatBytes($this->maxUploadBytes);
    ?>
</span>
	<input type="file" id="upload_field" name="attm[]" multiple="multiple" />
	<div id="dropArea">Or drop files here</div>
	<div id="result"></div>
	<div id="totprogress"></div>
	<div id="fprogress"></div>
	<hr />
	<button onclick="this.parentNode.style.display='none'">Close</button>
</div>
<?php 
}
if ($this->attached) {
    ?>
<iframe id="dnldf" style="display:none;"></iframe>