Example #1
0
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @param array $tabs_settings
 * @param string $interface
 */
function frosso_project_tab_handle_on_project_tabs(&$tabs, &$logged_user, &$project, &$tabs_settings, $interface)
{
    if ($interface == AngieApplication::INTERFACE_DEFAULT && Tasks::canAccess($logged_user, $project, false) && in_array('fred_pt', $tabs_settings)) {
        $tabs->addBefore('fred_pt', array('text' => "Fred PT", 'url' => Router::assemble('frosso_tab_route', array('project_slug' => $project->getSlug())), 'icon' => $interface == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16x16/tasks-tab-icon.png', TASKS_MODULE) : AngieApplication::getImageUrl('icons/listviews/tasks.png', TASKS_MODULE, AngieApplication::INTERFACE_PHONE)), 'calendar');
    }
    // if
}
Example #2
0
/**
 * Handle on_reports_panel event
 *
 * @param ReportsPanel $panel
 * @param IUser $user
 */
function frosso_estimated_cost_handle_on_reports_panel(ReportsPanel &$panel, IUser &$user)
{
    if ($user->isProjectManager()) {
        $panel->defineRow('remedia_reports', new ReportsPanelRow(lang('Milestone Reports')));
        $panel->addTo('remedia_reports', 'my_projects_report', lang('Milestone ETA Report'), Router::assemble('frosso_estimated_cost_report'), AngieApplication::getImageUrl('module.png', FROSSO_EC_MODULE, AngieApplication::INTERFACE_DEFAULT));
    }
    // if
}
/**
 * Handle on inline tabs event
 *
 * @param NamedList $tabs
 * @param ApplicationObject $object
 * @param User $logged_user
 * @param string $interface
 * @return null
 */
function ac_gitolite_handle_on_inline_tabs(&$tabs, &$object, &$logged_user, $interface)
{
    if ($object instanceof User) {
        if ($object->getId() == $logged_user->getId() || $logged_user->isAdministrator() || $logged_user->isPeopleManager()) {
            $tabs->add('view_keys', array('title' => lang('Public Keys'), 'url' => Router::assemble('get_public_keys', array('company_id' => $object->getCompanyId(), 'user_id' => $object->getId()))));
        }
    }
    // if User
}
 /**
  * Prepare controller
  */
 function __before()
 {
     parent::__before();
     if (!Tasks::canAccess($this->logged_user, $this->active_project)) {
         $this->response->forbidden();
     }
     // if
     // load project tabs
     //$project_tabs = $this->active_project->getTabs($this->logged_user, AngieApplication::INTERFACE_DEFAULT);
     $this->wireframe->tabs->setCurrentTab('fred_gc');
     $this->wireframe->breadcrumbs->add('frosso_gc_route', lang('FRosso GC'), Router::assemble('frosso_gc_route', array('project_slug' => $this->active_project->getSlug())));
 }
/**
 * @param Project $project
 * @param Milestone $milestone
 * @param User $user
 * @param NamedList $sections
 * @param string $interface
 */
function frosso_handle_on_milestone_sections(&$project, &$milestone, &$user, &$sections, $interface)
{
    //uncomment these lines to add a new tab, instead
    if (Tasks::canAccess($user, $project)) {
        Router::assemble('milestone_tasks', array('project_slug' => $project->getSlug(), 'milestone_id' => $milestone->getId()));
        //   		$section = array(
        //         'text' => lang('FRed'),
        //         'url' => Router::assemble('tasks_frosso', array('project_slug' => $project->getSlug(), 'milestone_id' => $milestone->getId())),
        //         'options' => array(),
        //       );
        //       $sections->add('frosso', $section);
    }
    // if
}
 function index()
 {
     parent::index();
     if ($this->request->isWebBrowser()) {
         $milestone_tasks_per_page = 30;
         $this->response->assign('more_results_url', Router::assemble('milestone_tasks', array('project_slug' => $this->active_project->getSlug(), 'milestone_id' => $this->active_milestone->getId())));
         if ($this->request->get('paged_list')) {
             $exclude = $this->request->get('paged_list_exclude') ? explode(',', $this->request->get('paged_list_exclude')) : null;
             $timestamp = $this->request->get('paged_list_timestamp') ? (int) $this->request->get('paged_list_timestamp') : null;
             $result = DB::execute("SELECT * FROM " . TABLE_PREFIX . "project_objects WHERE milestone_id = ? AND type = 'Task' AND state >= ? AND visibility >= ? AND id NOT IN (?) AND created_on < ? ORDER BY " . Tasks::ORDER_ANY . " LIMIT {$milestone_tasks_per_page}", $this->active_milestone->getId(), STATE_VISIBLE, $this->logged_user->getMinVisibility(), $exclude, date(DATETIME_MYSQL, $timestamp));
             $this->response->respondWithData(self::getDescribedTaskArray($result, $this->active_project, $this->logged_user, $milestone_tasks_per_page));
         } else {
             $result = DB::execute("SELECT * FROM " . TABLE_PREFIX . "project_objects WHERE milestone_id = ? AND type = 'Task' AND state >= ? AND visibility >= ? ORDER BY " . Tasks::ORDER_ANY, $this->active_milestone->getId(), STATE_VISIBLE, $this->logged_user->getMinVisibility());
             $tasks = self::getDescribedTaskArray($result, $this->active_project, $this->logged_user, $milestone_tasks_per_page);
             $this->response->assign(array('tasks' => $tasks, 'milestone_tasks_per_page' => $milestone_tasks_per_page, 'total_items' => $result instanceof DBResult ? $result->count() : 0, 'milestone_id' => $this->active_milestone->getId()));
         }
         //if
     }
 }
 /**
  * Find all tasks in project, and prepare them for objects list
  *
  * @param Project $project
  * @param User $user
  * @param int $state
  * @return array
  */
 static function findForObjectsList(Project $project, User $user, $state = STATE_VISIBLE)
 {
     $result = array();
     $today = strtotime(date('Y-m-d'));
     $tasks = DB::execute("SELECT o.id, o.name,\r\n\t\t\t\t\t\to.category_id,\r\n\t\t\t\t\t\to.milestone_id,\r\n\t\t\t\t\t\to.completed_on,\r\n\t\t\t\t\t\to.integer_field_1 as task_id,\r\n\t\t\t\t\t\to.label_id,\r\n\t\t\t\t\t\to.assignee_id,\r\n\t\t\t\t\t\to.priority,\r\n\t\t\t\t\t\to.delegated_by_id,\r\n\t\t\t\t\t\to.state,\r\n\t\t\t\t\t\to.visibility,\r\n\t\t\t\t\t\to.created_on,\r\n\t\t\t\t\t\to.updated_on,\r\n\t\t\t\t\t\to.due_on,\r\n\t\t\t\t\t\trec.tracked_time\r\n\t\t\t\t\tFROM " . TABLE_PREFIX . "project_objects o \r\n\t\t\t\t\tLEFT JOIN (SELECT parent_id, sum(value) tracked_time FROM " . TABLE_PREFIX . "time_records WHERE state = ? GROUP BY(parent_id)) rec ON(o.id=rec.parent_id)\r\n\t\t\t\t\tWHERE o.type = 'Task' AND o.project_id = ? AND o.state = ? AND o.visibility >= ? ORDER BY o.id DESC", $state, $project->getId(), $state, $user->getMinVisibility());
     if (is_foreachable($tasks)) {
         $task_url = Router::assemble('project_task', array('project_slug' => $project->getSlug(), 'task_id' => '--TASKID--'));
         $project_id = $project->getId();
         $labels = Labels::getIdDetailsMap('AssignmentLabel');
         foreach ($tasks as $task) {
             list($total_subtasks, $open_subtasks) = ProjectProgress::getObjectProgress(array('project_id' => $project_id, 'object_type' => 'Task', 'object_id' => $task['id']));
             $taskObj = new Task($task['id']);
             $result[] = array('id' => $task['id'], 'name' => $task['name'], 'project_id' => $project_id, 'category_id' => $task['category_id'], 'milestone_id' => $task['milestone_id'], 'task_id' => $task['task_id'], 'is_completed' => $task['completed_on'] ? 1 : 0, 'permalink' => str_replace('--TASKID--', $task['task_id'], $task_url), 'label_id' => $task['label_id'], 'label' => $task['label_id'] ? $labels[$task['label_id']] : null, 'assignee_id' => $task['assignee_id'], 'priority' => $task['priority'], 'delegated_by_id' => $task['delegated_by_id'], 'total_subtasks' => $total_subtasks, 'open_subtasks' => $open_subtasks, 'estimated_time' => $taskObj->tracking()->canAdd($user) && $taskObj->tracking()->getEstimate() ? $taskObj->tracking()->getEstimate()->getValue() : 0, 'tracked_time' => $taskObj->tracking()->canAdd($user) ? $task['tracked_time'] : 0, 'is_favorite' => Favorites::isFavorite(array('Task', $task['id']), $user), 'is_archived' => $task['state'] == STATE_ARCHIVED ? 1 : 0, 'visibility' => $task['visibility'], 'created_on' => $task['created_on'] ? $task['created_on'] : $task['updated_on'], 'updated_on' => $task['updated_on'], 'has_attachments' => $taskObj->attachments()->has() ? true : false, 'due_on' => $task['due_on'] ? $task['due_on'] : lang('No due date set'));
         }
         // foreach
     }
     // if
     return $result;
 }
/**
 * Handle on_admin_panel event
 * 
 * @param AdminPanel $admin_panel
 */
function ac_gitolite_handle_on_admin_panel(AdminPanel &$admin_panel)
{
    $admin_panel->addToProjects("gitolite_admin_handler", lang("Gitolite Settings"), Router::assemble('gitolite_admin'), AngieApplication::getImageUrl('module.png', AC_GITOLITE_MODULE));
}
 /**
  * Return set estimate URL
  *
  * @return string
  */
 function getSetEstimateUrl()
 {
     return Router::assemble($this->object->getRoutingContext() . '_tracking_estimate_set', $this->object->getRoutingContextParams());
 }
 function set_percent()
 {
     if ($this->request->isAsyncCall() || $this->request->isSubmitted()) {
         $milestone_id = $this->request->get('milestone_id', -1);
         $milestone = new RemediaMilestone($milestone_id);
         if ($milestone) {
             if ($this->request->isSubmitted()) {
                 $percent = $this->request->post('percent', -1);
                 if ($percent >= 0 && $percent <= 100) {
                     $milestone->setPercentDone($percent);
                     $milestone->save();
                     $this->response->respondWithData($milestone, array('as' => 'milestone', 'detailed' => true));
                 } else {
                     $this->response->exception(new ValidationErrors(array('percent' => lang("Value must be between 0 and 100"))));
                 }
             }
             $this->smarty->assign(array('milestone' => $milestone, 'form_action' => Router::assemble('frosso_ec_set_milestone_percent', array('project_slug' => $this->request->get('project_slug'), 'milestone_id' => $milestone_id))));
         } else {
             $this->response->notFound();
         }
     } else {
         $this->response->badRequest("");
     }
 }
 /**
  * Map remote conf users with activeclollab users
  */
 function map_conf_user()
 {
     if (isset($_GET["user_ids"])) {
         $user_ids = $_GET["user_ids"];
         $pub_keys = $_GET["pub_keys_str"];
         $pub_key_access = $_GET["pub_key_access"];
         // start mapping keys
         try {
             DB::beginWork('Mapping keys @ ' . __CLASS__);
             foreach ($user_ids as $key => $value) {
                 if (isset($value) && $value != "na") {
                     $key_dir_file_path = GIT_FILES_PATH . "/gitolite/gitolite-admin/keydir/" . $pub_keys[$key] . ".pub";
                     if (file_exists($key_dir_file_path)) {
                         $key_content = file_get_contents($key_dir_file_path);
                         // add keys to user
                         $key_id = GitoliteAc::add_keys($value, $pub_keys[$key], array("key_name" => $pub_keys[$key], "public_keys" => $key_content));
                         if (!$key_id) {
                             throw new Exception('Cannot map keys, try again.', 0, $e);
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             DB::rollback('Mapping keys @ ' . __CLASS__);
             die("Cannot map keys, try again.");
         }
         DB::commit('Repository created @ ' . __CLASS__);
         die("ok");
     }
     $array_pub_keys_access = array();
     $get_ac_users = new Users();
     $ac_users = $get_ac_users->getIdNameMap();
     self::$ac_users = $ac_users;
     $ac_users[""] = "Select a user";
     ksort($ac_users);
     $conf_file_path = GIT_FILES_PATH . "/gitolite/gitolite-admin/conf/gitolite.conf";
     $web_user = GitoliteAdmin::get_web_user();
     if (file_exists($conf_file_path)) {
         /** get keys list * */
         $conf_file_contents = file($conf_file_path);
         $array_pub_keys = self::parse_user_keys();
         $projects = new Projects();
         $ac_projects = $projects->getIdNameMap($this->logged_user);
         $ac_projects[""] = "Select Project";
         ksort($ac_projects);
         $array_repos = self::parse_repos();
     } else {
     }
     $this->response->assign(array('ac_users' => $ac_users, 'array_pub_keys' => $array_pub_keys, 'array_pub_keys_access' => $array_pub_keys_access, 'map_users_url' => Router::assemble('map_users'), 'ac_projects' => $ac_projects, 'array_repos' => $array_repos, 'map_projects_url' => Router::assemble('map_repos'), 'render_after_clone_url' => Router::assemble('render_after_clone'), 'admin_index_url' => Router::assemble('gitolite_admin')));
 }
 /**
  * Clone remote repository independent of any project.
  * @throws ValidationErrors
  */
 function clone_source_git_repository()
 {
     $logged_user = $this->logged_user;
     $user_id = $logged_user->getId();
     $web_user = GitoliteAdmin::get_web_user();
     $webuser_pub_key = GitoliteAdmin::get_web_user_key();
     /* echo $webuser_pub_key;
        print_r($webuser_pub_key);
        //die(); */
     $this->response->assign(array('form_action' => Router::assemble('clone_source_git_repository'), 'web_user' => $web_user, 'webuser_pub_key' => $webuser_pub_key));
     if ($this->request->isSubmitted()) {
         // check for form submission
         try {
             $repository_data = $this->request->post('repository');
             $repo_name = trim($repository_data["name"]);
             $repo_url = trim($this->request->post("remoteurl"));
             $errors = new ValidationErrors();
             $post_data = $this->request->post();
             if ($repo_name == "") {
                 $errors->addError('Please enter repository name', 'repo_name');
             }
             if ($repo_url == "") {
                 $errors->addError('Please enter repository URL', 'repo_name');
             }
             $dup_cnt = ProjectGitolite::check_remote_duplication($project_id, $repository_data, $repo_url);
             if (!$errors->hasErrors()) {
                 if (!preg_match("/^[A-Za-z0-9-]+\$/", $repo_name)) {
                     $errors->addError('Please enter valid repository name.', 'repo_name');
                 }
                 /* if(preg_match('|^[a-z]?:@[a-z0-9]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url))
                    {
                    return ;
                    } */
                 if (strstr($repo_url, "http://") || strstr($repo_url, "https://")) {
                     $errors->addError('HTTP url not allowed to add remote repository', 'repo_url');
                 }
                 /* if(!strstr($repo_url,  "git://github.com/"))
                    {
                    $errors->addError('Please enter valid Git URL', 'repo_url');
                    } */
                 if (count($dup_cnt) == 0) {
                     $errors->addError('Problem occured while saving data, please try again.');
                 } elseif (is_array($dup_cnt) && count($dup_cnt) > 0) {
                     if ($dup_cnt[0]['dup_name_cnt'] > 0) {
                         $errors->addError('Repository with same name is already added');
                     }
                     if ($dup_cnt[1]['dup_name_cnt'] > 0) {
                         $errors->addError('Remote URL already cloned under this project.');
                     }
                 }
             }
             if ($errors->hasErrors()) {
                 throw $errors;
             }
             try {
                 DB::beginWork('Creating a new remote repository @ ' . __CLASS__);
                 $actual_git_repo_name = ProjectGitolite::get_actual_repo_name($repo_url);
                 if (!$actual_git_repo_name) {
                     $errors->addError('Invalid Git Repository.');
                     throw $errors;
                 }
                 // clone remote repo
                 // path with folder name which is created as same as repo name to avoid same git repo collision
                 $work_git_path = GIT_FILES_PATH . "/";
                 // path with folder name which is created after repo is cloned
                 $git_ext = strpos($actual_git_repo_name, ".git");
                 if ($git_ext) {
                     $actual_git_repo_name = substr($actual_git_repo_name, 0, -4);
                 }
                 $actual_repo_path = GIT_FILES_PATH . "/" . $repo_name . "/" . $actual_git_repo_name . "/";
                 $folder_append = "";
                 $chk_actual_name_exists_cnt = ProjectGitolite::check_actual_name_count($actual_git_repo_name);
                 if (is_array($chk_actual_name_exists_cnt) && isset($chk_actual_name_exists_cnt["actual_name_cnt"])) {
                     $cnt = $chk_actual_name_exists_cnt["actual_name_cnt"] > 0 ? $chk_actual_name_exists_cnt["actual_name_cnt"] + 1 : "";
                     $folder_append = $cnt != "" ? "-{$cnt}" : "";
                 } else {
                     $folder_append = "-1";
                 }
                 // if git repsitory name is same , we need to change the folder name while cloning the repository
                 $folder_name = $actual_git_repo_name . $folder_append;
                 $actual_repo_path = GIT_FILES_PATH . "/" . $folder_name . "/";
                 $return_status = GitoliteAdmin::clone_remote_repo($repo_url, $work_git_path, $folder_name);
                 if (!$return_status) {
                     $errors->addError('Problem occured while cloning repository.');
                     throw $errors;
                 }
                 $repository_path_url = array('repository_path_url' => $actual_repo_path);
                 //echo $work_git_path;
                 $repository_data = array_merge($repository_data, $repository_path_url);
                 $this->active_repository = new GitRepository();
                 $this->active_repository->setAttributes($repository_data);
                 $this->active_repository->setCreatedBy($this->logged_user);
                 $this->active_repository->save();
                 $repo_fk = $this->active_repository->getId();
                 if ($repo_fk) {
                     $repo_id = ProjectGitolite::add_remote_repo_details($repo_fk, $user_id, $actual_repo_path, $repo_name, $repo_url, $actual_git_repo_name);
                     if ($repo_id) {
                         DB::commit('Repository created @ ' . __CLASS__);
                         //$out = $this->update_remote_repo($repo_fk);
                         $out = GitoliteAdmin::update_remote_repo($repo_fk);
                         $this->response->respondWithData($this->active_repository, array('as' => 'repository'));
                     } else {
                         @ProjectGitolite::remove_directory($work_git_path);
                         $errors->addError('Error while saving repository.');
                         throw $errors;
                     }
                 } else {
                     @ProjectGitolite::remove_directory($work_git_path);
                     $errors->addError('Error while saving repository.');
                     throw $errors;
                 }
             } catch (Exception $e) {
                 DB::rollback('Failed to create a repository @ ' . __CLASS__);
                 $this->response->exception($e);
             }
         } catch (Exception $e) {
             DB::rollback('Failed to create a repository @ ' . __CLASS__);
             $this->response->exception($e);
         }
     }
 }
    /**
     * Find tasks for outline
     *
     * @param Project $project
     * @param User $user
     * @param int $state
     * @return array
     */
    static function findForOutline(Project $project, User $user, $state = STATE_VISIBLE)
    {
        $today = strtotime(date('Y-m-d'));
        $task_ids = DB::executeFirstColumn('SELECT id 
				FROM ' . TABLE_PREFIX . 'project_objects 
				WHERE project_id = ? 
				AND type = ? 
				AND state >= ? 
				AND visibility >= ? 
				AND completed_on IS NULL', $project->getId(), 'Task', $state, $user->getMinVisibility());
        if (!is_foreachable($task_ids)) {
            return false;
        }
        // if
        $tasks = DB::execute('SELECT o.id, 
				o.integer_field_1 AS task_id, 
				o.name, 
				o.body, 
				o.due_on, 
				o.date_field_1 AS start_on, 
				o.assignee_id, 
				o.priority, 
				o.visibility, 
				o.created_by_id, 
				o.label_id, 
				o.milestone_id,
				o.category_id, 
				o.completed_on, 
				o.delegated_by_id, 
				o.state, 
				o.created_on, 
				o.updated_on,
				o.due_on,
				u.first_name,
				u.last_name 
				FROM ' . TABLE_PREFIX . 'project_objects o LEFT JOIN ' . TABLE_PREFIX . 'users u ON(o.assignee_id=u.id) 
				WHERE o.ID IN(?) ORDER BY ' . self::$task_order_by . ' ' . self::$task_sort_by, $task_ids);
        // casting
        // 		$tasks->setCasting(array(
        // 				'due_on'        => DBResult::CAST_DATE,
        // 				'start_on'      => DBResult::CAST_DATE
        // 		));
        $tasks_id_prefix_pattern = '--TASK-ID--';
        $task_url_params = array('project_slug' => $project->getSlug(), 'task_id' => $tasks_id_prefix_pattern);
        $view_task_url_pattern = Router::assemble('project_task', $task_url_params);
        $edit_task_url_pattern = Router::assemble('project_task_edit', $task_url_params);
        $trash_task_url_pattern = Router::assemble('project_task_trash', $task_url_params);
        $subscribe_task_url_pattern = Router::assemble('project_task_subscribe', $task_url_params);
        $unsubscribe_task_url_pattern = Router::assemble('project_task_unsubscribe', $task_url_params);
        $reschedule_task_url_pattern = Router::assemble('project_task_reschedule', $task_url_params);
        $tracking_task_url_pattern = Router::assemble('project_task_tracking', $task_url_params);
        // can_manage_tasks
        $can_manage_tasks = $user->projects()->getPermission('task', $project) >= ProjectRole::PERMISSION_MANAGE;
        // all assignees
        $user_assignments_on_tasks = DB::executeFirstColumn('SELECT parent_id FROM ' . TABLE_PREFIX . 'assignments WHERE parent_id IN (?) AND parent_type = ? AND user_id = ?', $task_ids, 'Task', $user->getId());
        // all subscriptions
        $user_subscriptions_on_tasks = DB::executeFirstColumn('SELECT parent_id FROM ' . TABLE_PREFIX . 'subscriptions WHERE parent_id IN (?) AND parent_type = ? AND user_id = ?', $task_ids, 'Task', $user->getId());
        // other assignees
        $other_assignees = array();
        $raw_other_assignees = DB::execute('SELECT user_id, parent_id FROM ' . TABLE_PREFIX . 'assignments WHERE parent_type = ? AND parent_id IN (?)', 'Task', $task_ids);
        foreach ($raw_other_assignees as $raw_assignee) {
            if (!is_array($other_assignees[$raw_assignee['parent_id']])) {
                $other_assignees[$raw_assignee['parent_id']] = array();
            }
            // if
            $other_assignees[$raw_assignee['parent_id']][] = array('id' => $raw_assignee['user_id']);
        }
        // foreach
        // expenses & time
        $expenses = array();
        $time = array();
        $estimates = array();
        if (AngieApplication::isModuleLoaded('tracking')) {
            $raw_expenses = DB::execute('SELECT parent_id, SUM(value) as expense FROM ' . TABLE_PREFIX . 'expenses WHERE parent_id IN (?) AND parent_type = ? GROUP BY parent_id', $task_ids, 'Task');
            if (is_foreachable($raw_expenses)) {
                foreach ($raw_expenses as $raw_expense) {
                    $expenses[$raw_expense['parent_id']] = $raw_expense['expense'];
                }
                // if
            }
            // if
            $raw_time = DB::execute('SELECT parent_id, SUM(value) as time FROM ' . TABLE_PREFIX . 'time_records WHERE parent_id IN (?) AND parent_type = ? GROUP BY parent_id', $task_ids, 'Task');
            if (is_foreachable($raw_time)) {
                foreach ($raw_time as $raw_single_time) {
                    $time[$raw_single_time['parent_id']] = $raw_single_time['time'];
                }
                // foreach
            }
            // if
            $raw_estimates = DB::execute('SELECT parent_id, value, job_type_id FROM (SELECT * FROM ' . TABLE_PREFIX . 'estimates WHERE parent_id IN (?) AND parent_type = ? ORDER BY created_on DESC) as estimates_inverted GROUP BY parent_id', $task_ids, 'Task');
            if (is_foreachable($raw_estimates)) {
                foreach ($raw_estimates as $raw_estimate) {
                    $estimates[$raw_estimate['parent_id']] = array('value' => $raw_estimate['value'], 'job_type_id' => $raw_estimate['job_type_id']);
                }
                // foreach
            }
            // if
        }
        // if
        $task_url = Router::assemble('project_task', array('project_slug' => $project->getSlug(), 'task_id' => '--TASKID--'));
        $project_id = $project->getId();
        $labels = Labels::getIdDetailsMap('AssignmentLabel');
        $results = array();
        foreach ($tasks as $subobject) {
            $task_id = array_var($subobject, 'id');
            $task_task_id = array_var($subobject, 'task_id');
            list($total_subtasks, $open_subtasks) = ProjectProgress::getObjectProgress(array('project_id' => $project_id, 'object_type' => 'Task', 'object_id' => $subobject['id']));
            $results[] = array('id' => $task_id, 'task_id' => $task_task_id, 'name' => array_var($subobject, 'name'), 'body' => array_var($subobject, 'body'), 'priority' => array_var($subobject, 'priority'), 'milestone_id' => array_var($subobject, 'milestone_id', null), 'class' => 'Task', 'start_on' => array_var($subobject, 'start_on'), 'assignee_id' => array_var($subobject, 'assignee_id'), 'other_assignees' => array_var($other_assignees, $task_id, null), 'label_id' => array_var($subobject, 'label_id', null), 'label' => $subobject['label_id'] ? $labels[$subobject['label_id']] : null, 'project_id' => $project_id, 'category_id' => $subobject['category_id'], 'is_completed' => $subobject['completed_on'] ? 1 : 0, 'permalink' => str_replace('--TASKID--', $subobject['task_id'], $task_url), 'priority' => self::$priority_map[$subobject['priority']], 'delegated_by_id' => $subobject['delegated_by_id'], 'total_subtasks' => $total_subtasks, 'open_subtasks' => $open_subtasks, 'is_favorite' => Favorites::isFavorite(array('Task', $task_id), $user), 'is_archived' => $subobject['state'] == STATE_ARCHIVED ? 1 : 0, 'visibility' => $subobject['visibility'], 'created_on' => $subobject['created_on'] ? $subobject['created_on'] : $subobject['updated_on'], 'updated_on' => $subobject['updated_on'], 'assignee_name' => $subobject['first_name'] . " " . $subobject['last_name'], 'due_on' => $subobject['due_on'] ? $subobject['due_on'] : lang('No due date set'), 'stato' => $subobject['due_on'] ? $subobject['due_on'] >= $today ? 'orario' : 'ritardo' : 'not_set', 'user_is_subscribed' => in_array($task_id, $user_subscriptions_on_tasks), 'object_time' => array_var($time, $task_id, 0), 'object_expenses' => array_var($expenses, $task_id, 0), 'estimate' => array_var($estimates, $task_id, null), 'event_names' => array('updated' => 'task_updated'), 'urls' => array('view' => str_replace($tasks_id_prefix_pattern, $task_task_id, $view_task_url_pattern), 'edit' => str_replace($tasks_id_prefix_pattern, $task_task_id, $edit_task_url_pattern), 'trash' => str_replace($tasks_id_prefix_pattern, $task_task_id, $trash_task_url_pattern), 'subscribe' => str_replace($tasks_id_prefix_pattern, $task_task_id, $subscribe_task_url_pattern), 'unsubscribe' => str_replace($tasks_id_prefix_pattern, $task_task_id, $unsubscribe_task_url_pattern), 'reschedule' => str_replace($tasks_id_prefix_pattern, $task_task_id, $reschedule_task_url_pattern), 'tracking' => str_replace($tasks_id_prefix_pattern, $task_task_id, $tracking_task_url_pattern)), 'permissions' => array('can_edit' => can_edit_project_object($subobject, $user, $project, $can_manage_tasks, $user_assignments_on_tasks), 'can_trash' => can_trash_project_object($subobject, $user, $project, $can_manage_tasks, $user_assignments_on_tasks)));
        }
        // foreach
        return $results;
    }
Example #14
0
/**
 * Register status bar items
 *
 * @param StatusBar $status_bar
 * @param IUser $logged_user
 */
function frosso_mail_notify_handle_on_status_bar(StatusBar &$status_bar, IUser &$user)
{
    $status_bar->add('frosso_mn_updates', lang('Notifications'), Router::assemble('frosso_mail_notify'), AngieApplication::getImageUrl('icons/12x12/my-subscriptions.png', FROSSO_MAILN_MODULE), array('group' => StatusBar::GROUP_RIGHT, 'badge' => NotificationsActivityLogs::countSinceLastVisit($user)));
}
 function add_ftp_connections()
 {
     /* $cus = new CustomFields();
               //$cus->initForType("Users",2);
               $flds = $cus->getCustomFieldsByType("Users");
     
               //$cus->initForType("Project",1);
               if(is_array($flds) && count($flds) > 0)
               {
               foreach ($flds as $key => $value) {
               $settings["$key"]["label"] = "Comments";
               $settings["$key"]["is_enabled"] = "1";
               $cus->setCustomFieldsByType("Users", $settings);
     
               }
               }
               print_r($flds);
               die(); */
     //$settings["label"];
     //$cus->setCustomFieldsByType("Project", $settings);
     $repo_branches = $this->active_repository;
     $eng = $repo_branches->getEngine($this->active_project->getId());
     //print_r($eng->getBranches);
     $branches_array = $eng->getBranches();
     $repo_branches_str = implode(",", $branches_array);
     $repo_id = array_var($_GET, 'project_source_repository_id');
     //project objects id
     $repo_obj = new ProjectSourceRepository($repo_id);
     $src_repo_id = $repo_obj->getIntegerField1();
     if ($this->request->isSubmitted()) {
         // check for form submission
         $post_data = $this->request->post();
         //print_r($post_data);
         try {
             $errors = new ValidationErrors();
             $ftpdetials = $post_data["ftpdetials"];
             $fld_cnt = count($ftpdetials["ftp_domain"]);
             //print_r($ftpdetials);
             //die();
             $array_urls = array();
             for ($i = 0; $i < $fld_cnt; $i++) {
                 if ($ftpdetials["ftp_domain"][$i] == "" || $ftpdetials["ftp_port"][$i] == "" || $ftpdetials["ftp_username"][$i] == "" || $ftpdetials["ftp_password"][$i] == "" || $ftpdetials["branches"][$i] == "" || $ftpdetials["ftp_dir"][$i] == "") {
                     $errors->addError("Please fill all connection parameters.");
                 } else {
                     $arra_conn[$i] = array("ftp_domain" => $ftpdetials["ftp_domain"][$i], "ftp_port" => $ftpdetials["ftp_port"][$i], "ftp_username" => $ftpdetials["ftp_username"][$i], "ftp_password" => $ftpdetials["ftp_password"][$i], "branches" => $ftpdetials["branches"][$i], "ftp_dir" => $ftpdetials["ftp_dir"][$i]);
                 }
                 /* if(!filter_var($value, FILTER_VALIDATE_URL) && $value != "")
                    {
                    $errors->addError("$value is not a valid URL.");
                    }
                    else
                    {
                    $array_urls[] = $value;
                    } */
             }
             if ($errors->hasErrors()) {
                 throw $errors;
             }
             DB::beginWork('Add FTP Details @ ' . __CLASS__);
             if (is_array($arra_conn) && count($arra_conn) > 0) {
                 $ftp_details_exists = ProjectGitolite::ftp_connections_exists($src_repo_id);
                 if (is_array($ftp_details_exists) && $ftp_details_exists["ftp_cnt"] > 0) {
                     $ftp_table_name = TABLE_PREFIX . "rt_ftp_connections";
                     DB::execute("DELETE FROM {$ftp_table_name} where repo_fk = '" . $src_repo_id . "'");
                 }
                 for ($i = 0; $i < $fld_cnt; $i++) {
                     $ftp_details_add = ProjectGitolite::add_ftp_details($arra_conn[$i], $src_repo_id, $this->logged_user->getId());
                     if (!$ftp_details_add) {
                         $errors->addError('Problem occured while saving data, please try again.');
                         throw $errors;
                     }
                 }
                 DB::commit('FTP details Added @ ' . __CLASS__);
                 $this->response->ok();
             } else {
                 $errors->addError("Error while saving FTP details.");
                 throw $errors;
             }
         } catch (Exception $e) {
             DB::rollback('Failed to add FTP details @ ' . __CLASS__);
             $this->response->exception($e);
         }
     }
     $ftp_details_exists = ProjectGitolite::get_connection_details($src_repo_id);
     $this->response->assign(array('repo_branches_str' => $repo_branches_str, 'branches_array' => $branches_array, 'ftp_test_url' => Router::assemble('test_ftp_conn', array('project_slug' => $this->active_project->getSlug(), 'project_source_repository_id' => $repo_id)), 'form_action' => Router::assemble('add_ftp_conn', array('project_slug' => $this->active_project->getSlug(), 'project_source_repository_id' => $repo_id)), "ftp_details_exists" => $ftp_details_exists));
 }
 /**
  * Prepare controller
  */
 function __before()
 {
     parent::__before();
     $this->wireframe->breadcrumbs->add('frosso_activity', lang('Activities Updates'), Router::assemble('frosso_mail_notify'));
     $this->wireframe->tabs->add('frosso_activities', lang('Activities Updates'), Router::assemble('frosso_mail_notify'), false, true);
 }
 /**
  * Add new public key of user. Create .pub file gitolite admin directory
  * @return void
  */
 function add_public_keys()
 {
     $active_user = $this->active_user;
     $this->response->assign(array('form_action' => Router::assemble('add_public_keys', array('company_id' => $active_user->getCompanyId(), 'user_id' => $active_user->getId())), 'user_rmail' => $active_user->getEmail()));
     if ($this->request->isSubmitted()) {
         // check for form submission
         $post_data = $this->request->post();
         /* Check form with validation error */
         $errors = new ValidationErrors();
         try {
             $post_data['key_name'] = str_replace(array("\r\n", "\r", "\n"), "", $post_data['key_name']);
             $post_data['public_keys'] = str_replace(array("\r\n", "\r", "\n"), "", $post_data['public_keys']);
             $key_name = trim($post_data['key_name']);
             $public_keys = trim($post_data['public_keys']);
             if ($key_name == "") {
                 $errors->addError('Please enter key name', 'key_name');
             }
             if ($public_keys == "") {
                 $errors->addError('Please enter key', 'public_keys');
             }
             if (!preg_match("/^[A-Za-z0-9-]+\$/", $key_name)) {
                 $errors->addError('Please enter valid key name.', 'public_keys');
             }
             $fetch_actual_key = explode(" ", $public_keys);
             if (!($fetch_actual_key[0] == "ssh-rsa" || $fetch_actual_key[0] == "ssh-dss")) {
                 $errors->addError("Key is invalid. It must begin with 'ssh-rsa' or 'ssh-dss'. Check that you're copying the public half of the key", 'public_keys');
             } else {
                 $tempStr = base64_decode($fetch_actual_key[1], true);
                 if ($tempStr) {
                     if (strpos($tempStr, $fetch_actual_key[0]) === false) {
                         $errors->addError("Key is invalid. Check that you're copying the public half of the key", 'public_keys');
                     }
                 } else {
                     $errors->addError("Key is invalid. Check that you're copying the public half of the key", 'public_keys');
                 }
             }
             $actual_key = $fetch_actual_key[1];
             /* Check for duplications Key name and Key */
             if (!$errors->hasErrors()) {
                 $dup_cnt = GitoliteAc::check_duplication($active_user->getId(), $post_data, $actual_key);
                 if (count($dup_cnt) == 0) {
                     $errors->addError('Problem occured while saving data, please try again.', 'public_keys');
                 } elseif (count($dup_cnt) > 0) {
                     if ($dup_cnt[0]['dup_name_cnt'] > 0) {
                         $errors->addError('You have already added key with same name.');
                     }
                     if ($dup_cnt[1]['dup_name_cnt'] > 0) {
                         $errors->addError('Entered key is already added.');
                     }
                 }
             }
             // if errors found throw error exception
             if ($errors->hasErrors()) {
                 throw $errors;
             }
         } catch (Exception $e) {
             $this->response->exception($e);
         }
         // insert key details in database.
         $pub_file_name = $key_name . "-" . $this->request->get("user_id");
         try {
             DB::beginWork('Adding a new public key @ ' . __CLASS__);
             //print_r($post_data);
             $save_data = GitoliteAc::add_keys($active_user->getId(), $pub_file_name, $post_data);
             if ($save_data) {
                 $file = $pub_file_name . ".pub";
                 $admin_settings = GitoliteAdmin::get_admin_settings();
                 if (!isset($admin_settings['gitoliteadminpath'])) {
                     $this->response->exception("Gitolite admin path not set");
                     die;
                 }
                 $dirpath = $admin_settings['gitoliteadminpath'] . "gitolite-admin/keydir/";
                 $adminrepo = $admin_settings['gitoliteadminpath'] . "gitolite-admin/";
                 $path = $dirpath . $file;
                 $newfh = fopen($path, 'w+');
                 if (!is_writable($path)) {
                     $this->response->exception("Can't write to file public file");
                     die;
                 }
                 $res = fwrite($newfh, $post_data['public_keys']);
                 fclose($fh);
                 ProjectGitolite::update_repo_conf_on_public_key($active_user->getId());
                 $res = ProjectGitolite::render_conf_file();
                 /** Git Push Files * */
                 $command = "cd " . $adminrepo . " && git add * && git commit -am 'added key for user {$file}' && git push";
                 exec($command, $output, $return_var);
                 //cd /var/www/vhosts/web-vision.de/httpdocs/project/work/git/gitolite/gitolite-admin/ && git add * && git commit -am 'added key for user faishal-test-key-147.pub' && git push
                 DB::commit('Key added @ ' . __CLASS__);
                 $show_data['key_name'] = $post_data['key_name'];
                 $show_data['public_key'] = substr($post_data['public_keys'], 0, 25) . "....." . substr($post_data['public_keys'], -30);
                 $show_data['delete_url'] = $this->active_user->getViewUrl() . "/" . "delete-keys" . "/" . $save_data;
                 $this->response->respondWithData($show_data, array('as' => 'settings'));
             }
         } catch (Exception $e) {
             $this->response->exception("Can't save key this time, might be key you are adding is already added");
         }
     }
 }
 /**
  * Constructor
  *
  * @param Milestone $object
  */
 function __construct($object)
 {
     $this->route = Router::assemble("frosso_ec_set_milestone_percent", array("project_slug" => $object->getProject()->getSlug(), "milestone_id" => $object->getId()));
 }
 static function getTimerRoute()
 {
     return Router::assemble('timer');
 }
Example #20
0
/**
 * Handle on_admin_panel event
 *
 * @param AdminPanel $admin_panel
 */
function frosso_authentication_handle_on_admin_panel(AdminPanel &$admin_panel)
{
    $admin_panel->addToOther('frosso_authentication', lang('SSO Settings'), Router::assemble('auth_login_frosso_admin'), AngieApplication::getImageUrl('admin_panel/tasks.png', TASKS_MODULE), array('onclick' => new FlyoutFormCallback(array('success_event' => 'frosso_authentication_updated', 'success_message' => lang('SSO settings have been updated'), 'width' => 500))));
}