Пример #1
0
 /**
  * Return parent folder instance
  *
  * @param void
  * @return ProjectFolder
  */
 function getFolder()
 {
     if (is_null($this->folder)) {
         $this->folder = ProjectFolders::findById($this->getFolderId());
         if ($this->folder instanceof ProjectFolder && $this->folder->getProjectId() != $this->getProjectId()) {
             $this->folder = null;
         }
         // if
     }
     // if
     return $this->folder;
 }
Пример #2
0
function files_my_tasks_dropdown()
{
    //if (logged_user()->getProjectPermission(active_project(), PermissionManager::CAN_MANAGE_FILES)) {
    echo '<li class="header"><a href="' . get_url('files', 'index') . '">' . lang('files') . '</a></li>';
    //} // if
    if (ProjectFile::canAdd(logged_user(), active_project())) {
        echo '<li><a href="' . get_url('files', 'add_file') . '">' . lang('add file') . '</a></li>';
    }
    // if
    if (ProjectFolder::canAdd(logged_user(), active_project())) {
        echo '<li><a href="' . get_url('files', 'add_folder') . '">' . lang('add folder') . '</a></li>';
    }
    // if
}
Пример #3
0
function files_my_tasks_dropdown()
{
    if (use_permitted(logged_user(), active_project(), 'files')) {
        echo '<li class="header"><a href="' . get_url('files', 'index') . '">' . lang('files') . '</a></li>';
        if (ProjectFile::canAdd(logged_user(), active_project())) {
            echo '<li><a href="' . get_url('files', 'add_file') . '">' . lang('add file') . '</a></li>';
        }
        // if
        if (ProjectFolder::canAdd(logged_user(), active_project())) {
            echo '<li><a href="' . get_url('files', 'add_folder') . '">' . lang('add folder') . '</a></li>';
        }
        // if
    }
    // if
}
Пример #4
0
 /**
  * @see ProjectItemInterface::link_item()
  * @return bool
  * @throws ProjectItemLinkException
  */
 public function link_item()
 {
     global $transaction;
     if ($this->item_id and $this->project_id) {
         $transaction_id = $transaction->begin();
         if (($project_folder_id = ProjectFolder::get_folder_by_project_id($this->project_id)) != null) {
             $project_has_item = new ProjectHasItem_Access(null);
             if ($project_has_item->create($this->project_id, $this->item_id, null) == null) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectItemLinkException(true, "Database entry failed");
             }
             if ($this->parent_item_id) {
                 if ($project_has_item->set_parent_item_id($this->parent_item_id) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectItemLinkException(true, "Parent Item-ID link failed");
                 }
             }
             $project_item_link_event = new ProjectItemLinkEvent($this->item_id, $project_folder_id);
             $event_handler = new EventHandler($project_item_link_event);
             if ($event_handler->get_success() == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectItemLinkException(true, "Event failed");
             } else {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             }
         } else {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new ProjectItemLinkException(true, "No Project-Folder were found");
         }
     } else {
         throw new ProjectItemLinkException();
     }
 }
Пример #5
0
if ($folder instanceof ProjectFolder) {
    $files_crumbs[] = array($folder->getName(), $folder->getBrowseUrl());
}
// if
$files_crumbs[] = lang('file details');
project_crumbs($files_crumbs);
if (ProjectFile::canAdd(logged_user(), active_project())) {
    if ($folder instanceof ProjectFolder) {
        add_page_action(lang('add file'), $folder->getAddFileUrl());
    } else {
        add_page_action(lang('add file'), get_url('files', 'add_file'));
    }
    // if
}
// if
if (ProjectFolder::canAdd(logged_user(), active_project())) {
    add_page_action(lang('add folder'), get_url('files', 'add_folder'));
}
// if
add_stylesheet_to_page('project/files.css');
?>
<div id="fileDetails" class="block">
<?php 
if ($file->isPrivate()) {
    ?>
  <div class="private" title="<?php 
    echo lang('private file');
    ?>
"><span><?php 
    echo lang('private file');
    ?>
Пример #6
0
 /**
  * Add folder
  *
  * @access public
  * @param void
  * @return null
  */
 function add_folder()
 {
     if (!ProjectFolder::canAdd(logged_user(), active_project())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('files'));
     }
     // if
     $folder = new ProjectFolder();
     $folder_data = array_var($_POST, 'folder');
     tpl_assign('folder', $folder);
     tpl_assign('folder_data', $folder_data);
     if (is_array($folder_data)) {
         $folder->setFromAttributes($folder_data);
         $folder->setProjectId(active_project()->getId());
         try {
             DB::beginWork();
             $folder->save();
             ApplicationLogs::createLog($folder, active_project(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             flash_success(lang('success add folder', $folder->getName()));
             $this->redirectToUrl($folder->getBrowseUrl());
         } catch (Exception $e) {
             DB::rollback();
             tpl_assign('error', $e);
         }
         // try
     }
     // if
 }
Пример #7
0
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof UserDeletePrecheckEvent) {
         $project_array = self::list_user_related_projects($event_object->get_user_id(), false);
         if (is_array($project_array)) {
             if (count($project_array) >= 1) {
                 return false;
             }
         }
     }
     if ($event_object instanceof OrganisationUnitDeletePrecheckEvent) {
         $project_array = self::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array)) {
             if (count($project_array) >= 1) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileUploadPrecheckEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $project_quota = $project->get_quota();
             $project_filesize = $project->get_filesize();
             $new_project_filesize = $project_filesize + $event_object->get_filesize();
             if ($project_quota <= $new_project_filesize and $project_quota != 0) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileUploadEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $new_project_filesize = $project->get_filesize() + $event_object->get_filesize();
             if ($project->set_filesize($new_project_filesize) == false) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileDeleteEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $new_project_filesize = $project->get_filesize() - $event_object->get_filesize();
             if ($project->set_filesize($new_project_filesize) == false) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileVersionDeleteEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $new_project_filesize = $project->get_filesize() - $event_object->get_filesize();
             if ($project->set_filesize($new_project_filesize) == false) {
                 return false;
             }
         }
     }
     return true;
 }
Пример #8
0
 /**
  * @param string $get_array
  * @return string
  * @throws ProjectIDMissingException
  */
 public static function get_project_menu($get_array)
 {
     global $project_security;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['project_id']) {
         $project = new Project($_GET['project_id']);
         $folder_id = ProjectStatusFolder::get_folder_by_project_id_and_project_status_id($_GET['project_id'], $project->get_current_status_id());
         $template = new HTMLTemplate("project/ajax/detail_menu.html");
         switch ($project->is_next_status_available()) {
             case 0:
                 if ($project->get_current_status_id() == 0) {
                     $template->set_var("proceed", 3);
                 } else {
                     $template->set_var("proceed", 4);
                 }
                 break;
             case 1:
                 if ($project_security->is_access(3, false) == true) {
                     if ($project->is_current_status_fulfilled()) {
                         $template->set_var("proceed", 1);
                     } else {
                         $template->set_var("proceed", 2);
                     }
                 }
                 break;
             case 2:
                 if ($project_security->is_access(3, false) == true) {
                     if ($project->is_current_status_fulfilled()) {
                         $template->set_var("proceed", 5);
                     } else {
                         $template->set_var("proceed", 6);
                     }
                 }
                 break;
             default:
                 $template->set_var("proceed", 7);
                 break;
         }
         $template->set_var("next_status_name", $project->get_next_status_name());
         if ($project_security->is_access(3, false) == true) {
             $project_template = new ProjectTemplate($project->get_template_id());
             $current_status_requirements = $project->get_current_status_requirements($project->get_current_status_id());
             $result = array();
             $counter = 0;
             if (is_array($current_status_requirements) and count($current_status_requirements) >= 1) {
                 foreach ($current_status_requirements as $key => $value) {
                     switch ($value['element_type']) {
                         case "item":
                             $paramquery = array();
                             $paramquery['username'] = $_GET['username'];
                             $paramquery['session_id'] = $_GET['session_id'];
                             $paramquery['nav'] = "project";
                             $paramquery['project_id'] = $_GET['project_id'];
                             require_once "core/modules/item/common/item_common.io.php";
                             $menu_element_array = ItemCommonIO::get_menu_element($value, $key, $counter, $paramquery, "Project", $_GET['project_id']);
                             $result = array_merge($result, $menu_element_array[0]);
                             $counter = $menu_element_array[1];
                             break;
                         case "extension":
                             $paramquery = array();
                             $paramquery['username'] = $_GET['username'];
                             $paramquery['session_id'] = $_GET['session_id'];
                             $paramquery['nav'] = "project";
                             $paramquery['run'] = "extension";
                             $paramquery['project_id'] = $_GET['project_id'];
                             $paramquery['extension'] = $value['extension'];
                             $paramquery['retrace'] = Retrace::create_retrace_string();
                             $params = http_build_query($paramquery, '', '&#38;');
                             $result[$counter]['name'] = "Run " . $value['name'];
                             $result[$counter]['depends'] = false;
                             $result[$counter]['params'] = $params;
                             if ($value['fulfilled'] == 1) {
                                 if ($value['occurrence'] == "multiple") {
                                     $result[$counter]['type'] = "link";
                                     $result[$counter]['image'] = "add_extension_done";
                                 } else {
                                     $result[$counter]['type'] = false;
                                     $result[$counter]['image'] = "add_extension_done_na";
                                 }
                             } elseif ($value['fulfilled'] == 0) {
                                 if ($value['occurrence'] == "multiple") {
                                     $result[$counter]['type'] = "link";
                                     $result[$counter]['image'] = "add_extension_wait";
                                 } else {
                                     $result[$counter]['type'] = false;
                                     $result[$counter]['image'] = "add_extension_wait_na";
                                 }
                             } else {
                                 $result[$counter]['type'] = "link";
                                 $result[$counter]['image'] = "add_extension";
                             }
                             if ($value['requirement'] == "optional" and $value['fulfilled'] != 0) {
                                 $result[$counter]['name'] = $result[$counter]['name'] . " (optional)";
                             }
                             $counter++;
                             break;
                     }
                 }
             }
             if ($counter > 0) {
                 $template->set_var("status_action", $result);
             }
             $template->set_var("write", true);
         } else {
             $template->set_var("write", false);
         }
         $paramquery = array();
         $paramquery['username'] = $_GET['username'];
         $paramquery['session_id'] = $_GET['session_id'];
         $paramquery['nav'] = "project";
         $paramquery['run'] = "common_dialog";
         $paramquery['folder_id'] = ProjectFolder::get_supplementary_folder($_GET['project_id']);
         $paramquery['dialog'] = "file_add";
         $paramquery['retrace'] = Retrace::create_retrace_string();
         unset($paramquery['nextpage']);
         $supplementary_params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("supplementary_params", $supplementary_params);
         $log_paramquery = $_GET;
         $log_paramquery['run'] = "log_add";
         unset($log_paramquery['nextpage']);
         $log_params = http_build_query($log_paramquery, '', '&#38;');
         $template->set_var("log_params", $log_params);
         $add_task_paramquery = $_GET;
         $add_task_paramquery['run'] = "add_task";
         unset($add_task_paramquery['nextpage']);
         $add_task_params = http_build_query($add_task_paramquery, '', '&#38;');
         $template->set_var("add_task_params", $add_task_params);
         $show_tasks_paramquery = $_GET;
         $show_tasks_paramquery['run'] = "show_tasks";
         unset($show_tasks_paramquery['nextpage']);
         $show_tasks_params = http_build_query($show_tasks_paramquery, '', '&#38;');
         $template->set_var("show_tasks_params", $show_tasks_params);
         $subproject_paramquery = $_GET;
         $subproject_paramquery['run'] = "new_subproject";
         unset($subproject_paramquery['nextpage']);
         $subproject_params = http_build_query($subproject_paramquery, '', '&#38;');
         $template->set_var("add_subproject_params", $subproject_params);
         $template->output();
     } else {
         throw new ProjectIDMissingException();
     }
 }
Пример #9
0
 /**
  * Return files by URL. Files will be ordered by filename
  *
  * @param ProjectFolder $folder
  * @param boolean $show_private
  * @return array
  */
 static function getByFolder(ProjectFolder $folder, $show_private = false)
 {
     $project = $folder->getProject();
     if (!$project instanceof Project) {
         return null;
     }
     // if
     if ($show_private) {
         $conditions = array('`project_id` =? AND `folder_id` = ?', $project->getId(), $folder->getId());
     } else {
         $conditions = array('`project_id` =? AND `folder_id` = ? AND `is_private` = ?', $project->getId(), $folder->getId(), false);
     }
     // if
     return self::findAll(array('conditions' => $conditions, 'order' => '`filename`'));
 }
Пример #10
0
 /**
  * @see ProjectPermissionInterface::set_permission()
  * @param integer $permission
  * @return bool
  */
 public function set_permission($permission)
 {
     if (is_numeric($permission) and $this->project_permission and $this->permission_id) {
         if (($user_id = $this->project_permission->get_user_id()) != null) {
             $current_permission_string = strrev(decbin($this->project_permission->get_permission()));
             $new_permission_string = strrev(decbin($permission));
             $project_folder_id = ProjectFolder::get_folder_by_project_id($this->project_permission->get_project_id());
             if ($current_permission_string[2] == 0 and $current_permission_string[3] == 0 and $current_permission_string[7] == 0) {
                 $folder_id = UserFolder::get_folder_by_user_id($user_id);
                 $virtual_folder = new VirtualFolder(null);
                 $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id);
                 foreach ($virtual_folder_array as $key => $value) {
                     $virtual_folder = new ProjectVirtualFolder($value);
                     if ($virtual_folder->is_project_vfolder() == true) {
                         $virtual_folder_id = $value;
                     }
                 }
                 if (is_numeric($virtual_folder_id)) {
                     $virtual_folder = new VirtualFolder($virtual_folder_id);
                     if ($virtual_folder->link_folder($project_folder_id) == false) {
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id);
                         }
                         return null;
                     }
                 }
             }
         }
         return $this->project_permission->set_permission($permission);
     } else {
         return false;
     }
 }
 /**
  * @see ProjectPermissionOrganisationUnitInterface::delete()
  * @return bool
  * @throws ProjectPermissionOrganisationUnitDeleteException
  * @throws ProjectPermisisonOrganisationUnitDeleteVirtualFolderException
  */
 public function delete()
 {
     global $transaction;
     if ($this->permission_id and $this->project_permission) {
         $transaction_id = $transaction->begin();
         $project_id = $this->project_permission->get_project_id();
         $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id);
         $permission_string = strrev(decbin($this->project_permission->get_permission()));
         if (ProjectPermission_Access::count_entries_with_project_id_and_organisation_unit_id($project_id, $this->project_permission->get_organisation_unit_id()) <= 1) {
             $folder_id = OrganisationUnitFolder::get_folder_by_organisation_unit_id($this->project_permission->get_organisation_unit_id());
             $virtual_folder = new VirtualFolder(null);
             $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id);
             foreach ($virtual_folder_array as $key => $value) {
                 $virtual_folder = new ProjectVirtualFolder($value);
                 if ($virtual_folder->is_project_vfolder() == true) {
                     $virtual_folder_id = $value;
                 }
             }
             if ($virtual_folder_id) {
                 $virtual_folder = new VirtualFolder($virtual_folder_id);
                 if ($virtual_folder->unlink_folder($project_folder_id) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectPermissionOrganisationUnitDeleteVirtualFolderException();
                 }
             }
         }
         if (parent::delete() == true) {
             if ($transaction_id != null) {
                 $transaction->commit($transaction_id);
             }
             return true;
         } else {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new ProjectPermissionOrganisationUnitDeleteException();
         }
     } else {
         throw new ProjectPermissionOrganisationUnitDeleteException();
     }
 }
Пример #12
0
 /**
  * @param string $alias
  * @throws BaseModuleDialogMethodNotFoundException
  * @throws BaseModuleDialogClassNotFoundException
  * @throws BaseModuleDialogFileNotFoundException
  * @throws BaseModuleDialogMissingException
  * @throws ProjectSecurityAccessDeniedException
  * @throws BaseModuleDialogNotFoundException
  * @throws ItemAddIOClassNotFoundException
  * @throws ItemAddIOFileNotFoundException
  * @throws ItemHandlerClassNotFoundException
  * @throws ItemPositionIDMissingException
  * @throws ItemParentIDMissingException
  * @throws ItemParentTypeMissingException
  * @throws ProjectStatusWithoutExtensionException
  * @throws BaseExtensionClassNotFoundException
  * @throws BaseExtensionFileNotFoundException
  * @throws BaseExtensionNotFoundException
  * @throws BaseExtensionMissingException
  */
 public static function io_handler($alias)
 {
     global $project_security, $session, $transaction;
     if (isset($_GET['project_id']) and is_numeric($_GET['project_id'])) {
         $project_security = new ProjectSecurity($_GET['project_id']);
         if ($_GET['run'] != "new_subproject") {
             require_once "io/project_common.io.php";
             ProjectCommon_IO::tab_header();
         }
     } else {
         $project_security = new ProjectSecurity(null);
     }
     if (isset($_GET['run'])) {
         switch ($_GET['run']) {
             case "new":
             case "new_subproject":
                 require_once "io/project.io.php";
                 ProjectIO::create();
                 break;
             case "myprojects":
             case "workon":
             case "accessdata":
             case "analyse":
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects(null);
                 break;
             case "userprojects":
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects($_GET['id']);
                 break;
             case "organ_unit":
                 require_once "io/project.io.php";
                 ProjectIO::list_organisation_unit_related_projects();
                 break;
             case "detail":
                 require_once "io/project.io.php";
                 ProjectIO::detail();
                 break;
             case "structure":
                 require_once "io/project.io.php";
                 ProjectIO::structure();
                 break;
                 // Project Log
             // Project Log
             case "log":
                 require_once "io/project_log.io.php";
                 ProjectLogIO::list_project_related_logs();
                 break;
                 // Tasks and Schedule
             // Tasks and Schedule
             case "add_task":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::add();
                 break;
             case "schedule":
             case "show_tasks":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::show();
                 break;
             case "task_detail":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::detail();
                 break;
             case "task_delete":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::delete();
                 break;
             case "task_edit_start":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::edit_start();
                 break;
             case "task_edit_end":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::edit_end();
                 break;
                 // Administration
             // Administration
             case "admin":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::menu();
                 break;
             case "admin_rename":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::rename();
                 break;
             case "admin_chown":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::chown();
                 break;
             case "admin_move":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::move();
                 break;
             case "admin_quota":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::quota();
                 break;
                 // Administration - Permission
             // Administration - Permission
             case "admin_permission":
                 require_once "io/project_admin.io.php";
                 $project_admin_io = new ProjectAdminIO();
                 ProjectAdminIO::permission();
                 break;
             case "admin_permission_add_user":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_user();
                 break;
             case "admin_permission_add_group":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_group();
                 break;
             case "admin_permission_add_ou":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_organisation_unit();
                 break;
             case "admin_permission_edit":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_edit();
                 break;
             case "admin_permission_delete":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_delete();
                 break;
                 // Item Lister
             // Item Lister
             case "item_list":
                 if ($project_security->is_access(1, false) == true) {
                     if ($_GET['dialog']) {
                         if ($_GET['dialog'] == "data") {
                             $path_stack_array = array();
                             $folder_id = ProjectFolder::get_folder_by_project_id($_GET['project_id']);
                             $folder = Folder::get_instance($folder_id);
                             $init_array = $folder->get_object_id_path();
                             foreach ($init_array as $key => $value) {
                                 $temp_array = array();
                                 $temp_array['virtual'] = false;
                                 $temp_array['id'] = $value;
                                 array_unshift($path_stack_array, $temp_array);
                             }
                             if (!$_GET['folder_id']) {
                                 $session->write_value("stack_array", $path_stack_array, true);
                             }
                         }
                         $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_list", $_GET['dialog']);
                         if (file_exists($module_dialog['class_path'])) {
                             require_once $module_dialog['class_path'];
                             if (class_exists($module_dialog['class'])) {
                                 if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                     $module_dialog['class']::$module_dialog['method']("project", $_GET['project_id'], true);
                                 } else {
                                     throw new BaseModuleDialogMethodNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogClassNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogFileNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Item Add
             // Item Add
             case "item_add":
             case "item_edit":
                 if ($project_security->is_access(3, false) == true) {
                     if ($_GET['dialog']) {
                         if ($_GET['run'] == "item_add") {
                             $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_add", $_GET['dialog']);
                         } elseif ($_GET['run'] == "item_edit") {
                             $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_edit", $_GET['dialog']);
                         }
                         if (is_array($module_dialog) and $module_dialog['class_path']) {
                             if (file_exists($module_dialog['class_path'])) {
                                 require_once $module_dialog['class_path'];
                                 if (class_exists($module_dialog['class'])) {
                                     if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                         $project = new Project($_GET['project_id']);
                                         $project_item = new ProjectItem($_GET['project_id']);
                                         $project_item->set_status_id($project->get_current_status_id());
                                         $project_item->set_gid($_GET['key']);
                                         $description_required = $project_item->is_description_required();
                                         $keywords_required = $project_item->is_keywords_required();
                                         if ($description_required and !$_POST['description'] and !$_GET['idk_unique_id'] or $keywords_required and !$_POST['keywords'] and !$_GET['idk_unique_id']) {
                                             require_once "core/modules/item/io/item.io.php";
                                             ItemIO::information(http_build_query($_GET), $description_required, $keywords_required);
                                         } else {
                                             $current_status_requirements = $project->get_current_status_requirements($project->get_current_status_id());
                                             if ($_GET['run'] == "item_add") {
                                                 $module_dialog['class']::$module_dialog['method']($current_status_requirements[$_GET['key']]['type_id'], $current_status_requirements[$_GET['key']]['category_id'], "Project", $_GET['project_id'], $_GET['key']);
                                             } elseif ($_GET['run'] == "item_edit") {
                                                 $module_dialog['class']::$module_dialog['method']($current_status_requirements[$_GET['key']]['fulfilled'][0]['item_id']);
                                             }
                                         }
                                     } else {
                                         throw new BaseModuleDialogMethodNotFoundException();
                                     }
                                 } else {
                                     throw new BaseModuleDialogClassNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogFileNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Sub Item Add and Edit
             // Sub Item Add and Edit
             case "sub_item_add":
             case "sub_item_edit":
                 if ($project_security->is_access(3, false) == true) {
                     if ($_GET['parent']) {
                         if (is_numeric($_GET['parent_id'])) {
                             if (is_numeric($_GET['key'])) {
                                 $item_handling_class = Item::get_handling_class_by_type($_GET['parent']);
                                 if (class_exists($item_handling_class)) {
                                     $item_io_handling_class = $item_handling_class::get_item_add_io_handling_class();
                                     if (file_exists("core/modules/" . $item_io_handling_class[0])) {
                                         require_once "core/modules/" . $item_io_handling_class[0];
                                         if (class_exists($item_io_handling_class[1])) {
                                             if ($_GET['run'] == "sub_item_add") {
                                                 $item_io_handling_class[1]::item_add_edit_handler("add");
                                             } elseif ($_GET['run'] == "sub_item_edit") {
                                                 $item_io_handling_class[1]::item_add_edit_handler("edit");
                                             }
                                         } else {
                                             throw new ItemAddIOClassNotFoundException();
                                         }
                                     } else {
                                         throw new ItemAddIOFileNotFoundException();
                                     }
                                 } else {
                                     throw new ItemHandlerClassNotFoundException();
                                 }
                             } else {
                                 throw new ItemPositionIDMissingException();
                             }
                         } else {
                             throw new ItemParentIDMissingException();
                         }
                     } else {
                         throw new ItemParentTypeMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Extension
                 /**
                  * @todo type filter
                  */
             // Extension
             /**
              * @todo type filter
              */
             case "extension":
                 if ($_GET['extension']) {
                     $extension_id = Extension::get_id_by_identifier($_GET['extension']);
                     if ($extension_id) {
                         $extension = new Extension($extension_id);
                         $main_file = constant("EXTENSION_DIR") . "/" . $extension->get_folder() . "/" . $extension->get_main_file();
                         $main_class = $extension->get_class();
                         if (file_exists($main_file)) {
                             require_once $main_file;
                             if (class_exists($main_class)) {
                                 $project = new Project($_GET['project_id']);
                                 $project_item = new ProjectItem($_GET['project_id']);
                                 $project_status_requirements = $project->get_current_status_requirements();
                                 if (is_array($project_status_requirements) and count($project_status_requirements) >= 1) {
                                     foreach ($project_status_requirements as $key => $value) {
                                         if ($value['element_type'] == "extension" and $value['extension'] == $_GET['extension']) {
                                             if (is_array($value['filter']) and count($value['filter']) >= 1) {
                                                 $filter_array = $value['filter'];
                                             } else {
                                                 $filter_array = null;
                                             }
                                             break;
                                         }
                                     }
                                 } else {
                                     throw new ProjectStatusWithoutExtensionException();
                                 }
                                 if ($filter_array) {
                                     $item_array = array();
                                     foreach ($filter_array as $key => $value) {
                                         if (is_numeric($value['status'])) {
                                             $item_array = array_merge($item_array, $project_item->get_project_status_items($value['status'], true));
                                         }
                                     }
                                 } else {
                                     $item_array = $project_item->get_project_items(true);
                                 }
                                 $event_identifier = uniqid("", true);
                                 if ($session->is_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY")) {
                                     $project_extension_event_identifier_array = $session->read_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY");
                                     $project_extension_event_identifier_array[$event_identifier] = $_GET['project_id'];
                                 } else {
                                     $project_extension_event_identifier_array = array();
                                     $project_extension_event_identifier_array[$event_identifier] = $_GET['project_id'];
                                 }
                                 $session->write_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY", $project_extension_event_identifier_array);
                                 $main_class::set_event_identifier($event_identifier);
                                 $main_class::set_target_folder_id(ProjectStatusFolder::get_folder_by_project_id_and_project_status_id($_GET['project_id'], $project->get_current_status_id()));
                                 $main_class::push_data($item_array);
                             } else {
                                 throw new BaseExtensionClassNotFoundException();
                             }
                         } else {
                             throw new BaseExtensionFileNotFoundException();
                         }
                     } else {
                         throw new BaseExtensionNotFoundException();
                     }
                 } else {
                     throw new BaseExtensionMissingException();
                 }
                 break;
                 // Common Dialogs
             // Common Dialogs
             case "common_dialog":
                 require_once "core/modules/base/common.request.php";
                 CommonRequest::common_dialog();
                 break;
                 // Default
             // Default
             default:
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects(null);
                 break;
         }
     } else {
         require_once "io/project.io.php";
         ProjectIO::list_user_related_projects(null);
     }
 }
 /**
  * Copy project
  *
  * @param void
  * @return null
  */
 function copy()
 {
     trace(__FILE__, "copy():begin");
     if (!Project::canAdd(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $this->setTemplate('copy_project');
     $this->setLayout('administration');
     $project_data = array_var($_POST, 'project');
     tpl_assign('project_data', $project_data);
     // Submitted...
     if (is_array($project_data)) {
         $source = Projects::findById($project_data['source']);
         if (!$source instanceof Project) {
             flash_error(lang('project dnx'));
             $this->redirectTo('administration', 'projects');
         }
         // if
         try {
             $shift_dates = isset($project_data['shift_dates']) ? $project_data['shift_dates'] == 'checked' : false;
             $copy_details = isset($project_data['copy_details']) ? $project_data['copy_details'] == 'checked' : false;
             $copy_tasks = isset($project_data['copy_tasks']) ? $project_data['copy_tasks'] == 'checked' : false;
             $copy_milestones = isset($project_data['copy_milestones']) ? $project_data['copy_milestones'] == 'checked' : false;
             $copy_messages = isset($project_data['copy_messages']) ? $project_data['copy_messages'] == 'checked' : false;
             $copy_links = isset($project_data['copy_links']) ? $project_data['copy_links'] == 'checked' : false;
             $copy_files = isset($project_data['copy_files']) ? $project_data['copy_files'] == 'checked' : false;
             $copy_users = isset($project_data['copy_users']) ? $project_data['copy_users'] == 'checked' : false;
             $copy_pages = isset($project_data['copy_pages']) ? $project_data['copy_pages'] == 'checked' : false;
             DB::beginWork();
             $project = new Project();
             $new_name = lang('projects copy new name', $source->getName());
             $new_name .= date(' z H:i:s');
             $project->setName($new_name);
             if ($copy_details) {
                 $project->setDescription($source->getDescription());
                 $project->setPriority($source->getPriority());
                 $project->setShowDescriptionInOverview($source->getShowDescriptionInOverview());
             }
             $project->save();
             $project_id = $project->getId();
             $add_seconds = 0;
             if (isset($project_data['add_days'])) {
                 $add_days = 0 + trim($project_data['add_days']);
                 $add_seconds = $add_days * 24 * 60 * 60;
             }
             $source_created_on = $source->getCreatedOn();
             //var_dump($source_created_on);
             $milestone_map = array(0 => 0);
             // project milestones
             if ($copy_milestones) {
                 $source_milestones = $source->getAllMilestones();
                 if (is_array($source_milestones)) {
                     foreach ($source_milestones as $source_milestone) {
                         $milestone = new ProjectMilestone();
                         //$milestone->copy($source_milestone);
                         $milestone->setName($source_milestone->getName());
                         $milestone->setDescription($source_milestone->getDescription());
                         if ($shift_dates) {
                             trace(__FILE__, "copy():shift dates");
                             $milestone->setDueDate(DateTimeValueLib::now());
                             $seconds = $source_milestone->getDueDate()->difference($source_created_on);
                             $milestone->getDueDate()->advance($seconds);
                         } else {
                             $milestone->setDueDate($source_milestone->getDueDate());
                         }
                         $milestone->getDueDate()->advance($add_seconds);
                         $milestone->setIsPrivate($source_milestone->getIsPrivate());
                         $milestone->setAssignedToUserId($source_milestone->getAssignedToUserId());
                         $milestone->setAssignedToCompanyId($source_milestone->getAssignedToCompanyId());
                         $milestone->setProjectId($project_id);
                         $milestone->save();
                         $milestone_map[$source_milestone->getId()] = $milestone->getId();
                     }
                     // foreach
                 }
                 // if
             }
             // if
             // project tasks
             if ($copy_tasks) {
                 $source_task_lists = $source->getAllTaskLists();
                 if (is_array($source_task_lists)) {
                     foreach ($source_task_lists as $source_task_list) {
                         $task_list = new ProjectTaskList();
                         //$task_list->copy($source_milestone);
                         $task_list->setName($source_task_list->getName());
                         $task_list->setPriority($source_task_list->getPriority());
                         $task_list->setDescription($source_task_list->getDescription());
                         if ($copy_milestones) {
                             $task_list->setMilestoneId($milestone_map[$source_task_list->getMilestoneId()]);
                         }
                         $task_list->setDueDate($source_task_list->getDueDate());
                         if ($task_list->getDueDate() instanceof DateTimeValue) {
                             if ($shift_dates) {
                                 trace(__FILE__, "copy():task list shift dates");
                                 $task_list->setDueDate(DateTimeValueLib::now());
                                 $seconds = $source_task_list->getDueDate()->difference($source_created_on);
                                 $task_list->getDueDate()->advance($seconds);
                             }
                             $task_list->getDueDate()->advance($add_seconds);
                         }
                         $task_list->setIsPrivate($source_task_list->getIsPrivate());
                         $task_list->setOrder($source_task_list->getOrder());
                         $task_list->setProjectId($project_id);
                         $task_list->save();
                         $source_tasks = $source_task_list->getTasks();
                         if (is_array($source_tasks)) {
                             foreach ($source_tasks as $source_task) {
                                 $task = new ProjectTask();
                                 $task->setOrder($source_task->getOrder());
                                 $task->setDueDate($source_task->getDueDate());
                                 if ($task->getDueDate() instanceof DateTimeValue) {
                                     if ($shift_dates) {
                                         trace(__FILE__, "copy():task shift dates");
                                         $task->setDueDate(DateTimeValueLib::now());
                                         $seconds = $source_task->getDueDate()->difference($source_created_on);
                                         $task->getDueDate()->advance($seconds);
                                     }
                                     $task->getDueDate()->advance($add_seconds);
                                 }
                                 $task->setText($source_task->getText());
                                 $task->getAssignedToUserId($source_task->getAssignedToUserId());
                                 $task->getAssignedToCompanyId($source_task->getAssignedToCompanyId());
                                 $task_list->attachTask($task);
                             }
                         }
                     }
                     // foreach
                 }
                 // if
             }
             // if
             // project messages
             if ($copy_messages) {
                 $source_messages = $source->getAllMessages();
                 if (is_array($source_messages)) {
                     foreach ($source_messages as $source_message) {
                         $message = new ProjectMessage();
                         //$message->copy($source_message);
                         $message->setTitle($source_message->getTitle());
                         $message->setText($source_message->getText());
                         $message->setAdditionalText($source_message->getAdditionalText());
                         if ($copy_milestones) {
                             $message->setMilestoneId($milestone_map[$source_message->getMilestoneId()]);
                         }
                         $message->setIsImportant($source_message->getIsImportant());
                         $message->setIsPrivate($source_message->getIsPrivate());
                         $message->setCommentsEnabled($source_message->getCommentsEnabled());
                         $message->setAnonymousCommentsEnabled($source_message->getAnonymousCommentsEnabled());
                         $message->setProjectId($project_id);
                         $message->save();
                     }
                     // foreach
                 }
                 // if
             }
             // if
             // project links
             if ($copy_links) {
                 $source_links = ProjectLinks::getAllProjectLinks($source);
                 if (is_array($source_links)) {
                     foreach ($source_links as $source_link) {
                         $link = new ProjectLink();
                         //$folder->copy($source_link);
                         $link->setTitle($source_link->getTitle());
                         $link->setUrl($source_link->getUrl());
                         $link->setProjectId($project_id);
                         $link->save();
                     }
                     // foreach
                 }
                 // if
             }
             // if
             // project folders & files
             if ($copy_files) {
                 $folder_map = array(0 => 0);
                 $source_folders = $source->getFolders();
                 if (is_array($source_folders)) {
                     foreach ($source_folders as $source_folder) {
                         $folder = new ProjectFolder();
                         //$folder->copy($source_folder);
                         $folder->setName($source_folder->getName());
                         $folder->setProjectId($project_id);
                         $folder->save();
                         $folder_map[$source_folder->getId()] = $folder->getId();
                     }
                     // foreach
                 }
                 // if
                 $source_files = ProjectFiles::getAllFilesByProject($source);
                 if (is_array($source_files)) {
                     foreach ($source_files as $source_file) {
                         $file = new ProjectFile();
                         $file->setProjectId($project_id);
                         $file->setFolderId($folder_map[$source_file->getFolderId()]);
                         $file->setFileName($source_file->getFileName());
                         $file->setDescription($source_file->getDescription());
                         $file->setIsPrivate($source_file->getIsPrivate());
                         $file->setIsImportant($source_file->getIsImportant());
                         $file->setIsLocked($source_file->getIsLocked());
                         $file->setIsVisible($source_file->getIsVisible());
                         $file->setExpirationTime($source_file->getExpirationTime());
                         $file->setCommentsEnabled($source_file->getCommentsEnabled());
                         $file->setAnonymousCommentsEnabled($source_file->getAnonymousCommentsEnabled());
                         $file->save();
                         $source_revision = $source_file->getLastRevision();
                         if ($source_revision instanceof ProjectFileRevision) {
                             $revision = new ProjectFileRevision();
                             $revision->setFileId($file->getId());
                             $revision->setRevisionNumber($source_revision->getRevisionNumber());
                             $revision->setRepositoryId($source_revision->getRepositoryId());
                             $revision->setFilesize($source_revision->getFilesize());
                             $revision->setFilename($source_revision->getFileName());
                             $revision->setTypeString($source_revision->getTypeString());
                             $revision->setThumbFilename($source_revision->getThumbFilename());
                             $revision->setFileTypeId($source_revision->getFileTypeId());
                             $revision->setComment($source_revision->getComment());
                             $revision->save();
                         }
                     }
                     // foreach
                 }
                 // if
             }
             // if
             if ($copy_pages) {
                 $source_pages = Wiki::getAllProjectPages($source);
                 if (is_array($source_pages)) {
                     foreach ($source_pages as $source_page) {
                         $page = new WikiPage();
                         $page->setProjectId($project_id);
                         $page->setProjectIndex($source_page->getProjectIndex());
                         $page->setProjectSidebar($source_page->getProjectSidebar());
                         if (plugin_active('tags')) {
                             //$page->setTags($source_page->getTagNames());
                         }
                         //Make a new revision of this page
                         $revision = $page->makeRevision();
                         $source_revision = $source_page->getLatestRevision();
                         //Set attributes
                         $revision->setName($source_revision->getName());
                         $revision->setContent($source_revision->getContent());
                         $revision->setLogMessage($source_revision->getLogMessage());
                         //Save the page
                         $page->save();
                     }
                     // foreach
                 }
                 // if
             }
             // if
             if ($copy_users) {
                 $source_companies = ProjectCompanies::instance()->getCompaniesByProject($source);
                 if (is_array($source_companies)) {
                     foreach ($source_companies as $source_company) {
                         $project_company = new ProjectCompany();
                         $project_company->setCompanyId($source_company->getId());
                         $project_company->setProjectId($project_id);
                         $project_company->save();
                     }
                     // foreach
                 }
                 $source_users = ProjectUsers::instance()->getUsersByProject($source);
                 if (is_array($source_users)) {
                     foreach ($source_users as $source_user) {
                         $project_user = new ProjectUser();
                         $project_user->setUserId($source_user->getId());
                         $project_user->setProjectId($project_id);
                         $project_user->save();
                     }
                     // foreach
                 }
             }
             /*
                       $permissions = array_keys(PermissionManager::getPermissionsText());
                       $auto_assign_users = owner_company()->getAutoAssignUsers();
                       
                       // We are getting the list of auto assign users. If current user is not in the list
                       // add it. He's creating the project after all...
                       if (is_array($auto_assign_users)) {
                         $auto_assign_logged_user = false;
                         foreach ($auto_assign_users as $user) {
                           if ($user->getId() == logged_user()->getId()) {
                             $auto_assign_logged_user = true;
                           }
                         } // if
                         if (!$auto_assign_logged_user) {
                           $auto_assign_users[] = logged_user();
                         }
                       } else {
                         $auto_assign_users[] = logged_user();
                       } // if
                       
                       foreach ($auto_assign_users as $user) {
                         $project_user = new ProjectUser();
                         $project_user->setProjectId($project->getId());
                         $project_user->setUserId($user->getId());
                         if (is_array($permissions)) {
                           foreach ($permissions as $permission) {
                             $user = Users::findById($project_user->getUserId());
                             $user->setProjectPermission($project,$permission,true);
                           }
                         } // if
                         $project_user->save();
                       } // foreach
             */
             ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_ADD, false, true);
             DB::commit();
             flash_success(lang('success copy project', $source->getName(), $project->getName()));
             $this->redirectToUrl($project->getPermissionsUrl());
         } catch (Exception $e) {
             echo $e->getMessage();
             tpl_assign('error', $e);
             DB::rollback();
         }
         // try
     }
     // if (submitted)
 }
 /**
  * Add project
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_project');
     $this->setLayout('administration');
     if (!Project::canAdd(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $project = new Project();
     $project_data = array_var($_POST, 'project');
     tpl_assign('project', $project);
     tpl_assign('project_data', $project_data);
     // Submited...
     if (is_array($project_data)) {
         $project->setFromAttributes($project_data);
         $default_folders_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('default_project_folders', ''));
         if (trim($default_folders_config) == '') {
             $default_folders = array();
         } else {
             $default_folders = explode("\n", $default_folders_config);
         }
         // if
         try {
             DB::beginWork();
             $project->save();
             $permissions = ProjectUsers::getPermissionColumns();
             $auto_assign_users = owner_company()->getAutoAssignUsers();
             // We are getting the list of auto assign users. If current user is not in the list
             // add it. He's creating the project after all...
             if (is_array($auto_assign_users)) {
                 $auto_assign_logged_user = false;
                 foreach ($auto_assign_users as $user) {
                     if ($user->getId() == logged_user()->getId()) {
                         $auto_assign_logged_user = true;
                     }
                 }
                 // if
                 if (!$auto_assign_logged_user) {
                     $auto_assign_users[] = logged_user();
                 }
             } else {
                 $auto_assign_users[] = logged_user();
             }
             // if
             foreach ($auto_assign_users as $user) {
                 $project_user = new ProjectUser();
                 $project_user->setProjectId($project->getId());
                 $project_user->setUserId($user->getId());
                 if (is_array($permissions)) {
                     foreach ($permissions as $permission) {
                         $project_user->setColumnValue($permission, true);
                     }
                 }
                 // if
                 $project_user->save();
             }
             // foreach
             if (count($default_folders)) {
                 $added_folders = array();
                 foreach ($default_folders as $default_folder) {
                     $folder_name = trim($default_folder);
                     if ($folder_name == '') {
                         continue;
                     }
                     // if
                     if (in_array($folder_name, $added_folders)) {
                         continue;
                     }
                     // if
                     $folder = new ProjectFolder();
                     $folder->setProjectId($project->getId());
                     $folder->setName($folder_name);
                     $folder->save();
                     $added_folders[] = $folder_name;
                 }
                 // foreach
             }
             // if
             ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_ADD, false, true);
             DB::commit();
             flash_success(lang('success add project', $project->getName()));
             $this->redirectToUrl($project->getPermissionsUrl());
         } catch (Exception $e) {
             tpl_assign('error', $e);
             DB::rollback();
         }
         // try
     }
     // if
 }
 /**
  * Creates a new Project Folder including Folder
  * @param integer $project_id
  * @return integer
  */
 public function create($project_id, $project_status_id)
 {
     if (is_numeric($project_id) and is_numeric($project_status_id)) {
         $project_status = new ProjectStatus($project_status_id);
         $project = new Project($project_id);
         $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id);
         $folder = new Folder($project_folder_id);
         $path = new Path($folder->get_path());
         $path->add_element("status-" . $project_status_id);
         if (($folder_id = parent::create($project_status->get_name(), $project_folder_id, $path->get_path_string(), $project->get_owner_id(), null)) != null) {
             $project_status_has_folder_access = new ProjectStatusHasFolder_Access(null);
             if ($project_status_has_folder_access->create($project_id, $project_status_id, $folder_id) == null) {
                 return null;
             }
             return $folder_id;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Пример #16
0
 /**
  * @see ValueVarCaseInterface::is_case()
  * @param integer $folder_id
  * @return bool
  */
 public static function is_case($folder_id)
 {
     if (is_numeric($folder_id)) {
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             return $project_id;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }