本文整理汇总了PHP中Router::assemble方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::assemble方法的具体用法?PHP Router::assemble怎么用?PHP Router::assemble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::assemble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: frosso_project_tab_handle_on_project_tabs
/**
* 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
}
示例2: frosso_estimated_cost_handle_on_reports_panel
/**
* 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
}
示例3: ac_gitolite_handle_on_inline_tabs
/**
* 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
}
示例4: __before
/**
* 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())));
}
示例5: frosso_handle_on_milestone_sections
/**
* @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
}
示例6: index
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
}
}
示例7: findForObjectsList
/**
* 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;
}
示例8: ac_gitolite_handle_on_admin_panel
/**
* 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));
}
示例9: getSetEstimateUrl
/**
* Return set estimate URL
*
* @return string
*/
function getSetEstimateUrl()
{
return Router::assemble($this->object->getRoutingContext() . '_tracking_estimate_set', $this->object->getRoutingContextParams());
}
示例10: set_percent
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("");
}
}
示例11: map_conf_user
/**
* 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')));
}
示例12: clone_source_git_repository
/**
* 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);
//.........这里部分代码省略.........
示例13: findForOutline
/**
* 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) {
//.........这里部分代码省略.........
示例14: frosso_mail_notify_handle_on_status_bar
/**
* 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)));
}
示例15: add_ftp_connections
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));
}