/** * Add sample category, file and document */ function installSampleData() { global $database, $my, $mosConfig_absolute_path; $dmdoc = $mosConfig_absolute_path . DS . 'dmdocuments'; $img = $mosConfig_absolute_path . DS . 'administrator' . DS . 'components' . DS . 'com_docman' . DS . 'images'; $now = date('Y-m-d H:i:s'); // get all super admins $database->setQuery("SELECT id FROM `#__users` WHERE `usertype`='Super Administrator'"); $admins = implode(',', $database->loadResultArray()); // add sample group $group = new mosDMGroups($database); $group->groups_name = _DML_SAMPLE_GROUP; $group->groups_description = _DML_SAMPLE_GROUP_DESC; $group->groups_access = 1; $group->groups_members = $admins; if (!$group->store()) { mosRedirect('index2.php?option=com_docman', 'Error: installSampleData, $groups->store()'); } $groupid = -1 * $database->insertid() + _DM_PERMIT_GROUP; // add sample license $license = new mosDMLicenses($database); $license->name = _DML_SAMPLE_LICENSE; $license->license = _DML_SAMPLE_LICENSE_DESC; if (!$license->store()) { mosRedirect('index2.php?option=com_docman', 'Error: installSampleData, $license->store()'); } $licenseid = $database->insertid(); // add a sample file if (!file_exists($dmdoc . DS . 'sample_file.png')) { @copy($img . DS . 'dm_logo.png', $dmdoc . DS . _DML_SAMPLE_FILENAME); } // add sample category $category = new mosDMCategory($database); $category->parent_id = 0; $category->title = _DML_SAMPLE_CATEGORY; $category->name = _DML_SAMPLE_CATEGORY; $category->image = 'clock.jpg'; $category->section = 'com_docman'; $category->image_position = 'left'; $category->description = _DML_SAMPLE_CATEGORY_DESC; $category->published = 1; $category->checked_out = 0; $category->checked_out_time = '0000-00-00 00:00:00'; $category->editor = NULL; $category->ordering = 1; $category->access = 0; $category->count = 0; $category->params = ''; if (!$category->store()) { mosRedirect('index2.php?option=com_docman', 'Error: installSampleData, $category->store()'); } $catid = $database->insertId(); // add sample document $doc = new mosDMDocument($database); $doc->catid = $catid; $doc->dmname = _DML_SAMPLE_DOC; $doc->dmdescription = _DML_SAMPLE_DOC_DESC; $doc->dmdate_published = $now; $doc->dmowner = -1; $doc->dmfilename = _DML_SAMPLE_FILENAME; $doc->published = 1; $doc->dmurl = ''; $doc->dmcounter = 0; $doc->checked_out = 0; $doc->checked_out_time = '0000-00-00 00:00:00'; $doc->approved = 1; $doc->dmthumbnail = ''; $doc->dmlastupdateon = $now; $doc->dmlastupdateby = $my->id; $doc->dmsubmitedby = $my->id; $doc->dmmantainedby = $groupid; $doc->dmlicense_id = $licenseid; $doc->dmlicense_display = 1; $doc->access = 0; $doc->attribs = 'crc_checksum=\\nmd5_checksum='; if (!$doc->store()) { mosRedirect('index2.php?option=com_docman', 'Error: installSampleData, $doc->store()'); } mosRedirect('index2.php?option=com_docman', _DML_SAMPLE_COMPLETED); }
/** * @desc Transform the document to a object if necessary * @param mixed object or numeric $doc * @access private * @return object a document object */ function isDocument(&$doc) { $database = JFactory::getDBO(); // check to see if we have a object if (!is_a($doc, 'mosDMDocument')) { $id = $doc; // try to create a document db object if (is_numeric($id)) { $doc = new mosDMDocument($database); $doc->load($id); } } }
function deleteDocument($uid) { DOCMAN_token::check() or die('Invalid Token'); global $database, $_DMUSER; $doc = new mosDMDocument($database); $doc->load($uid); //check user permissions $err = $_DMUSER->canPreformTask($doc, 'Delete'); if ($err) { _returnTo('cat_view', $err, $doc->catid); } //delete the docmument $doc->remove(array($uid)); _returnTo('cat_view', _DML_DOCDELETED, $doc->catid); }
function copyDocumentProcess($cid) { DOCMAN_token::check() or die('Invalid Token'); $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $my = JFactory::getUser(); // get the id of the category to copy the document to $categoryCopy = JRequest::getInt('catid', '', 'post'); // preform move $doc = new mosDMDocument($database); $doc->copy($cid, $categoryCopy); // output status message $cids = implode(',', $cid); $total = count($cid); $cat = new mosDMCategory($database); $cat->load($categoryCopy); $msg = $total . ' ' . _DML_DOCUMENTS_COPIED_TO . ' ' . $cat->name; $mainframe->redirect('index.php?option=com_docman§ion=documents', $msg); }
function copy($cid, $catid) { global $database, $my; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('" . _DML_SELECT_ITEM_COPY . " ); window.history.go(-1);</script>\n"; return false; } foreach ($cid as $id) { $docold = new mosDMDocument($database); $docnew = new mosDMDocument($database); $docold->load($id); $docnew->bind((array) $docold); $docnew->id = 0; $docnew->catid = $catid; if ($docold->catid == $docnew->catid) { $docnew->dmname = _DML_COPY_OF . ' ' . $docnew->dmname; } $docnew->store(); } return true; }
/** * Add sample category, file and document */ function installSampleData() { $database = JFactory::getDBO(); $my = JFactory::getUser(); $mainframe = JFactory::getApplication(); $dmdoc = JPATH_ROOT . DS . _DM_DEFAULT_DATA_FOLDER; $img = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_docman' . DS . 'images'; $now = date('Y-m-d H:i:s'); // get all super admins $database->setQuery("SELECT id FROM `#__users` WHERE `usertype`='Super Administrator'"); $admins = implode(',', $database->loadResultArray()); // add sample group $group = new mosDMGroups($database); $group->groups_name = _DML_SAMPLE_GROUP; $group->groups_description = _DML_SAMPLE_GROUP_DESC; $group->groups_access = 1; $group->groups_members = $admins; if (!$group->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $groups->store()'); } $groupid = -1 * $database->insertid() + _DM_PERMIT_GROUP; // add sample license $license = new mosDMLicenses($database); $license->name = _DML_SAMPLE_LICENSE; $license->license = _DML_SAMPLE_LICENSE_DESC; if (!$license->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $license->store()'); } $licenseid = $database->insertid(); // add a sample file //if ( !file_exists($dmdoc.DS.'sample_file.png')) { // @copy($img.DS.'dm_logo.png', $dmdoc.DS._DML_SAMPLE_FILENAME); //} // add sample category $category = new mosDMCategory($database); $category->parent_id = 0; $category->title = 'DOCman Sample Data'; $category->name = 'DOCman Sample Data'; $category->image = ''; $category->section = 'com_docman'; $category->image_position = 'left'; $category->description = '<p>Congratulations on installing DOCman! This is a category with some sample documents, so you can get a feel of how DOCman works. Did you know you can have unlimited nested categories? Just give it a try!</p>'; $category->published = 1; $category->checked_out = 0; $category->checked_out_time = '0000-00-00 00:00:00'; $category->editor = NULL; $category->ordering = 1; $category->access = 0; $category->count = 0; $category->params = ''; if (!$category->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $category->store()'); } $catid = $database->insertId(); // add sample document $doc = new mosDMDocument($database); $doc->catid = $catid; $doc->dmname = 'About DOCman 1.5'; $doc->dmdescription = '<p>Short presentation about DOCman 1.5</p>'; $doc->dmdate_published = $now; $doc->dmowner = -1; $doc->dmfilename = 'Link: http://www.box.net/shared/static/kvxyc2jjk0.pdf'; $doc->published = 1; $doc->dmurl = 'http://www.joomlatools.eu'; $doc->dmcounter = 0; $doc->checked_out = 0; $doc->checked_out_time = '0000-00-00 00:00:00'; $doc->approved = 1; $doc->dmthumbnail = ''; $doc->dmlastupdateon = $now; $doc->dmlastupdateby = $my->id; $doc->dmsubmitedby = $my->id; $doc->dmmantainedby = $groupid; $doc->dmlicense_id = $licenseid; $doc->dmlicense_display = 1; $doc->access = 0; $doc->attribs = ''; if (!$doc->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $doc->store()'); } // ... and another $doc = new mosDMDocument($database); $doc->catid = $catid; $doc->dmname = 'What is Nooku Framework?'; $doc->dmdescription = '<p>What is Nooku Framework? Get a very quick introduction about the new engine you can plug into Joomla. Build better extensions with less code!</p>'; $doc->dmdate_published = $now; $doc->dmowner = -1; $doc->dmfilename = 'Link: http://www.box.net/shared/static/pqsjzv0rko.pdf'; $doc->published = 1; $doc->dmurl = 'http://www.nooku.org/framework'; $doc->dmcounter = 0; $doc->checked_out = 0; $doc->checked_out_time = '0000-00-00 00:00:00'; $doc->approved = 1; $doc->dmthumbnail = ''; $doc->dmlastupdateon = $now; $doc->dmlastupdateby = $my->id; $doc->dmsubmitedby = $my->id; $doc->dmmantainedby = $groupid; $doc->dmlicense_id = $licenseid; $doc->dmlicense_display = 1; $doc->access = 0; $doc->attribs = ''; if (!$doc->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $doc->store()'); } $mainframe->redirect('index.php?option=com_docman', _DML_SAMPLE_COMPLETED); }
function copyDocumentProcess($cid) { DOCMAN_token::check() or die('Invalid Token'); global $database, $my; // get the id of the category to copy the document to $categoryCopy = mosGetParam($_POST, 'catid', ''); // preform move $doc = new mosDMDocument($database); $doc->copy($cid, $categoryCopy); // output status message $cids = implode(',', $cid); $total = count($cid); $cat = new mosDMCategory($database); $cat->load($categoryCopy); $msg = $total . ' ' . _DML_DOCUMENTS_COPIED_TO . ' ' . $cat->name; mosRedirect('index2.php?option=com_docman§ion=documents', $msg); }
/** * Add sample category, file and document */ function installSampleData() { $database = JFactory::getDBO(); $my = JFactory::getUser(); $mainframe = JFactory::getApplication(); $dmdoc = JPATH_ROOT . DS . _DM_DEFAULT_DATA_FOLDER; $img = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_docman' . DS . 'images'; $now = date('Y-m-d H:i:s'); // get all super admins $database->setQuery("SELECT id FROM `#__users` WHERE `usertype`='Super Administrator'"); $admins = implode(',', $database->loadResultArray()); // add sample group $group = new mosDMGroups($database); $group->groups_name = _DML_SAMPLE_GROUP; $group->groups_description = _DML_SAMPLE_GROUP_DESC; $group->groups_access = 1; $group->groups_members = $admins; if (!$group->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $groups->store()'); } $groupid = -1 * $database->insertid() + _DM_PERMIT_GROUP; // add sample license $license = new mosDMLicenses($database); $license->name = _DML_SAMPLE_LICENSE; $license->license = _DML_SAMPLE_LICENSE_DESC; if (!$license->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $license->store()'); } $licenseid = $database->insertid(); // add a sample file //if ( !file_exists($dmdoc.DS.'sample_file.png')) { // @copy($img.DS.'dm_logo.png', $dmdoc.DS._DML_SAMPLE_FILENAME); //} // add sample category $category = new mosDMCategory($database); $category->parent_id = 0; $category->title = 'DOCman Sample Data'; $category->name = 'DOCman Sample Data'; $category->image = ''; $category->section = 'com_docman'; $category->image_position = 'left'; $category->description = '<p>Congratulations on installing DOCman! This is a category with some sample documents, so you can get a feel of how DOCman works. Did you know you can have unlimited nested categories? Just give it a try!</p>'; $category->published = 1; $category->checked_out = 0; $category->checked_out_time = '0000-00-00 00:00:00'; $category->editor = NULL; $category->ordering = 1; $category->access = 0; $category->count = 0; $category->params = ''; if (!$category->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $category->store()'); } $catid = $database->insertId(); // add sample document $doc = new mosDMDocument($database); $doc->catid = $catid; $doc->dmname = 'About DOCman 1.5'; $doc->dmdescription = '<p>Short presentation about DOCman 1.5</p>'; $doc->dmdate_published = $now; $doc->dmowner = -1; $doc->dmfilename = 'Link: http://www.box.net/shared/static/kvxyc2jjk0.pdf'; $doc->published = 1; $doc->dmurl = 'http://www.joomlatools.eu'; $doc->dmcounter = 0; $doc->checked_out = 0; $doc->checked_out_time = '0000-00-00 00:00:00'; $doc->approved = 1; $doc->dmthumbnail = ''; $doc->dmlastupdateon = $now; $doc->dmlastupdateby = $my->id; $doc->dmsubmitedby = $my->id; $doc->dmmantainedby = $groupid; $doc->dmlicense_id = $licenseid; $doc->dmlicense_display = 1; $doc->access = 0; $doc->attribs = ''; if (!$doc->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $doc->store()'); } // ... and another $doc = new mosDMDocument($database); $doc->catid = $catid; $doc->dmname = 'Nooku Framework: A new brain for Joomla'; $doc->dmdescription = "<p>At the core of Joomla, there's a framework. It's the engine that powers all of Joomla, and a lot of the third-party extensions. It's great platform, but sites today are more demanding, and extensions require more power. We felt it was time to build <strong>a new brain for Joomla</strong>.</p><p><a href='http://nooku.org/framework'>Nooku Framework</a> can be installed in Joomla as a plugin. As a developer, you can now build your extensions using Nooku's intuitive API. Because the framework handles most of the work, you'll need only a <strong>fraction of the amount of code</strong>. You can focus on what really matters: business logic and the user experience.</p><p>But there's more: Nooku Framework provides you with excellent out-of-the-box <strong>security features</strong>. The great <strong>design patterns</strong> based architecture makes your extension very flexible: all your code automatically becomes re-usable, extensible and replaceable. We believe Nooku Framework is the boost Joomla needs to keep competing.</p>"; $doc->dmdate_published = $now; $doc->dmowner = -1; $doc->dmfilename = 'Link: http://www.box.net/shared/static/pqsjzv0rko.pdf'; $doc->published = 1; $doc->dmurl = 'http://www.nooku.org/framework'; $doc->dmcounter = 0; $doc->checked_out = 0; $doc->checked_out_time = '0000-00-00 00:00:00'; $doc->approved = 1; $doc->dmthumbnail = ''; $doc->dmlastupdateon = $now; $doc->dmlastupdateby = $my->id; $doc->dmsubmitedby = $my->id; $doc->dmmantainedby = $groupid; $doc->dmlicense_id = $licenseid; $doc->dmlicense_display = 1; $doc->access = 0; $doc->attribs = ''; if (!$doc->store()) { $mainframe->redirect('index.php?option=com_docman', 'Error: installSampleData, $doc->store()'); } $mainframe->redirect('index.php?option=com_docman', _DML_SAMPLE_COMPLETED); }