Esempio n. 1
0
 public function migrate()
 {
     $app = JFactory::getApplication();
     $passed = JRequest::getUint('check_passed');
     if (!$passed) {
         $app->enqueueMessage(JText::_('COM_PFMIGRATOR_WARNING_CHECK'), 'error');
         $app->redirect('index.php?option=com_pfmigrator&view=intro');
         return $this;
     }
     $data = PFmigratorHelper::getCustomData();
     if ($data->get('run')) {
         $app->enqueueMessage(JText::_('COM_PFMIGRATOR_WARNING_RERUN'), 'error');
         $app->redirect('index.php?option=com_pfmigrator&view=intro');
         return $this;
     }
     $data->set('run', 1);
     PFmigratorHelper::setCustomData($data);
     $app->enqueueMessage(JText::_('COM_PFMIGRATOR_WARNING_NO_LEAVE'));
     $app->redirect('index.php?option=com_pfmigrator&view=migrate');
     return $this;
 }
Esempio n. 2
0
 protected function migrate($title, $alias)
 {
     $config = JFactory::getConfig();
     $model = JModelLegacy::getInstance('Category', 'CategoriesModel');
     $model->setState('category.new', true);
     $model->setState('category.id', null);
     $data = array();
     $data['title'] = $title;
     $data['alias'] = $alias;
     $data['extension'] = 'com_pfprojects';
     $data['access'] = $config->get('access', 1);
     $data['parent_id'] = 1;
     $data['published'] = 1;
     if (!$model->save($data)) {
         $this->log[] = $model->getError();
         return false;
     }
     $cdata = PFmigratorHelper::getCustomData();
     $cdata->set('cat-' . $alias, $model->getState('category.id'));
     PFmigratorHelper::setCustomData($cdata);
     return true;
 }
Esempio n. 3
0
 public function process($limitstart = 0)
 {
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models', 'UsersModel');
     $this->data = PFmigratorHelper::getCustomData();
     $pf_group = (int) $this->data->get('pf_group');
     // Create Projectfork container group
     if (!$pf_group) {
         $group = array();
         $model = JModelLegacy::getInstance('Group', 'UsersModel');
         $group['id'] = null;
         $group['title'] = 'Projectfork';
         $group['parent_id'] = 1;
         if (!$model->save($group)) {
             $this->success = false;
             $this->log[] = JText::_('COM_PFMIGRATOR_CREATE_BASE_GROUP_FAILED');
             return false;
         }
         $pf_group = (int) $model->getState('group.id');
         $this->data->set('pf_group', $pf_group);
         PFmigratorHelper::setCustomData($this->data);
         $this->log[] = JText::_('COM_PFMIGRATOR_CREATE_BASE_GROUP_SUCCESS');
     }
     return true;
 }
Esempio n. 4
0
 protected function getUploadPath()
 {
     static $path = null;
     if (!is_null($path)) {
         return $path;
     }
     if (PFmigratorHelper::fmProInstalled()) {
         $cfg_path = PFmigratorHelper::getConfig('upload_path', 'filemanager_pro');
         if (empty($cfg_path)) {
             $cfg_path = PFmigratorHelper::getConfig('upload_path', 'filemanager');
         }
     } else {
         $cfg_path = PFmigratorHelper::getConfig('upload_path', 'filemanager');
     }
     if (empty($cfg_path)) {
         $path = false;
         return $path;
     }
     if (substr($cfg_path, 0, 1) != '/' && substr($cfg_path, 0, 1) != '\\') {
         $cfg_path = '/' . $cfg_path;
     }
     if (substr($cfg_path, -1) == '/' || substr($cfg_path, -1) == '\\') {
         $cfg_path = substr($cfg_path, 0, -1);
     }
     $path = JPath::clean(JPATH_SITE . $cfg_path);
     if (!JFolder::exists($path)) {
         if (!JFolder::create($path)) {
             $path = false;
         }
     }
     return $path;
 }
Esempio n. 5
0
 protected function getLogoPath()
 {
     static $path = null;
     if (!is_null($path)) {
         return $path;
     }
     $cfg_path = PFmigratorHelper::getConfig('logo_save_path', 'projects');
     if (empty($cfg_path)) {
         $path = false;
         return $path;
     }
     if (JFolder::exists(JPATH_SITE . $cfg_path)) {
         $path = JPATH_SITE . $cfg_path;
         return $path;
     } elseif (JFolder::exists(JPATH_SITE . '/' . $cfg_path)) {
         $path = JPATH_SITE . '/' . $cfg_path;
         return $path;
     } else {
         $path = false;
         return $path;
     }
 }
Esempio n. 6
0
JHtml::_('script', 'com_pfmigrator/pfmigrator/process.js', false, true, false, false, false);
$script = array();
$script[] = "window.addEvent('domready', function() {";
$script[] = "PFmigrator.process({";
$script[] = "txt_idle: '" . JText::_('COM_PFMIGRATOR_STATE_IDLE') . "',";
$script[] = "txt_proc: '" . JText::_('COM_PFMIGRATOR_STATE_PROC') . "',";
$script[] = "txt_err: '" . JText::_('COM_PFMIGRATOR_STATE_ERROR') . "',";
$script[] = "txt_cpl: '" . JText::_('COM_PFMIGRATOR_STATE_COMPLETE') . "',";
$script[] = "txt_upd: '" . JText::_('COM_PFMIGRATOR_STATE_UPDATE') . "'";
$script[] = "});";
$script[] = "});";
$cdata = PFmigratorHelper::getCustomData();
if (!$cdata->get('process')) {
    JFactory::getDocument()->addScriptDeclaration(implode('', $script));
    $cdata->set('process', 1);
    PFmigratorHelper::setCustomData($cdata);
}
?>
<form action="<?php 
echo JRoute::_('index.php?option=com_pfmigrator');
?>
" method="post" name="adminForm" id="adminForm" class="form-validate" autocomplete="off">
    <input type="hidden" name="view" value="migrate" />
    <input type="hidden" id="jform_task" name="task" value="" />
    <input type="hidden" id="jform_process" name="process" value="<?php 
echo $this->process;
?>
" />
    <input type="hidden" id="jform_processes" name="processes" value="<?php 
echo count($this->processes);
?>
Esempio n. 7
0
 public function process($limitstart = 0)
 {
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models', 'UsersModel');
     $this->data = PFmigratorHelper::getCustomData();
     $group_model = JModelLegacy::getInstance('Group', 'UsersModel');
     $pf_group = (int) $this->data->get('pf_group');
     $query = $this->_db->getQuery(true);
     $query->select('id, title')->from('#__pf_projects_tmp')->order('id ASC');
     $this->_db->setQuery($query, $limitstart, $this->getLimit());
     $projects = $this->_db->loadObjectList();
     if (empty($projects) || !is_array($projects)) {
         return true;
     }
     $query->clear();
     $query->select('ordering')->from('#__viewlevels')->order('ordering DESC');
     $this->_db->setQuery($query, 0, 1);
     $ordering = $this->_db->loadResult();
     $base_groups = array();
     $titles = array();
     foreach ($projects as $project) {
         // First, create a group for each project
         $group_model->setState('group.id', null);
         $group_model->setState('group.new', true);
         $group['id'] = null;
         $group['title'] = $project->title;
         $group['parent_id'] = $pf_group;
         if (!$group_model->save($group)) {
             $this->success = false;
             $this->log[] = JText::sprintf('COM_PFMIGRATOR_CREATE_PROJECT_GROUP_FAILED', $project->title);
             return false;
         }
         // Get the group id
         $base_groups[$project->id] = $group_model->getState('group.id');
         // Get all project members
         $query->clear();
         $query->select('user_id')->from('#__pf_project_members_tmp')->where('project_id = ' . (int) $base_groups[$project->id])->where('approved = 1');
         $this->_db->setQuery($query);
         $users = $this->_db->loadColumn();
         if (empty($users) || !is_array($users)) {
             $users = array();
         }
         // Add users to group
         $this->addUsersToGroup($users, $base_groups[$project->id]);
         // Get all project groups
         $query->clear();
         $query->select('id, title')->from('#__pf_groups_tmp')->where('project = ' . (int) $base_groups[$project->id]);
         $this->_db->setQuery($query);
         $groups = $this->_db->loadObjectList();
         if (empty($groups) || !is_array($groups)) {
             $groups = array();
         }
         // Process each group
         foreach ($groups as $pgroup) {
             $group_model->setState('group.id', null);
             $group_model->setState('group.new', true);
             $group['id'] = null;
             $group['title'] = $pgroup->title;
             $group['parent_id'] = $base_groups[$project->id];
             // Create the group
             if (!$group_model->save($group)) {
                 $this->success = false;
                 $this->log[] = JText::sprintf('COM_PFMIGRATOR_CREATE_PROJECT_SUB_GROUP_FAILED', $pgroup->title, $project->title);
                 return false;
             }
             $new_id = $group_model->getState('group.id');
             // Get all group members
             $query->clear();
             $query->select('user_id')->from('#__pf_group_users_tmp')->where('group_id = ' . (int) $new_id);
             $this->_db->setQuery($query);
             $gusers = $this->_db->loadColumn();
             if (empty($gusers) || !is_array($gusers)) {
                 $gusers = array();
             }
             // Add users to group
             $this->addUsersToGroup($gusers, $new_id);
         }
         // Create access level
         $ordering++;
         $lvl = new stdClass();
         $lvl->id = null;
         $lvl->title = $project->title;
         $lvl->ordering = $ordering;
         $lvl->rules = '[' . $base_groups[$project->id] . ']';
         $this->_db->insertObject('#__viewlevels', $lvl, 'id');
         // Update the access of the project
         if ($lvl->id) {
             $query->clear();
             $query->update('#__pf_projects')->set('access = ' . (int) $lvl->id)->where('id = ' . (int) $project->id);
             $this->_db->setQuery($query);
             $this->_db->execute();
         }
         $titles[] = $project->title;
     }
     $projects = implode(', ', $titles);
     $this->log[] = JText::sprintf('COM_PFMIGRATOR_MIGRATE_ACCESS_SUCCESS', $projects);
     return true;
 }