function projViewFiles()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "render/render_wiki.inc.php";
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    $project = Project::getVisibleById($id);
    if (!$project || !$project->id) {
        $PH->abortWarning(__("invalid project-id"));
        return;
    }
    ### define from-handle ###
    $PH->defineFromHandle(array('prj' => $project->id));
    ## is viewed by user ##
    $project->nowViewedByUser();
    ## next milestone ##
    $next = $project->getNextMilestone();
    $page = new Page();
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->cur_tab = 'projects';
    $page->title = $project->name;
    $page->title_minor = __("Downloads");
    if ($project->status == STATUS_TEMPLATE) {
        $page->type = __("Project Template");
    } else {
        if ($project->status >= STATUS_COMPLETED) {
            $page->type = __("Inactive Project");
        } else {
            $page->type = __("Project", "Page Type");
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    measure_stop('init2');
    measure_start('info');
    $block = new PageBlock(array('id' => 'support'));
    $block->render_blockStart();
    echo "<div class=text>";
    if ($task = Task::getVisibleById(3645)) {
        echo wikifieldAsHtml($task, 'description');
    }
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
 private function initRecipientProjects()
 {
     ### recently assigned to projects ###
     $this->projects = array();
     # keep for later reference
     $this->projects_new = array();
     foreach ($this->recipient->getProjectPeople() as $pp) {
         if ($project = Project::getVisibleById($pp->project)) {
             if ($project->state) {
                 $this->projects[] = $project;
                 if (strToGMTime($pp->created) > strToGMTime($this->recipient->notification_last)) {
                     $this->projects_new[] = $project;
                 }
             }
         }
     }
 }
function newEffortFromTimeTracking()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'db/class_effort.inc.php';
    $time_end = intval(get('effort_end_seconds'));
    if ($time_end == 0) {
        $time_end = null;
    }
    $new_effort = new Effort(array('id' => 0, 'time_start' => getGMTString(get('effort_start_seconds')), 'time_end' => getGMTString($time_end), 'name' => get('description'), 'billing' => get('billing'), 'productivity' => get('productivity')));
    ### get project ###
    $new_effort->project = get('effort_project_id');
    if (!($project = Project::getVisibleById($new_effort->project))) {
        $PH->abortWarning(__("Could not get project of effort"));
    }
    if (!$project->isPersonVisibleTeamMember($auth->cur_user)) {
        $PH->abortWarning("ERROR: Insufficient rights");
    }
    ### link to task ###
    $task_id = get('effort_task_id');
    if (!(is_null($task_id) || $task_id == 0)) {
        if ($task_id == 0) {
            $new_effort->task = 0;
        } else {
            if ($task = Task::getVisibleById($task_id)) {
                $new_effort->task = $task->id;
            }
        }
    } else {
        if (get('task_name') != "") {
            ### create new task
            $newtask = new Task(array('id' => 0, 'name' => get('task_name'), 'project' => $project->id));
            $newtask->insert();
            $new_effort->task = $newtask->id;
        }
    }
    ### get person ###
    $new_effort->person = $auth->cur_user->id;
    ### go back to from if validation fails ###
    $failure = false;
    if (strToGMTime($new_effort->time_end) - strToGMTime($new_effort->time_start) < 0) {
        $failure = true;
        new FeedbackWarning(__("Cannot start before end."));
    }
    ### write to db ###
    $new_effort->insert();
    ### display taskView ####
    if (!$PH->showFromPage()) {
        $PH->show('projView', array('prj' => $effort->project));
    }
}
Example #4
0
/**
* Returns a list of folders for the given project.
* This is used for picking the destination folder for moving tasks across
* projects.
*/
function ajaxListProjectFolders()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'std/class_changeline.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_recentchanges.inc.php';
    require_once confGet('DIR_STREBER') . 'render/render_block.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_taskfolders.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_comments.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    header("Content-type: text/html; charset=utf-8");
    ### get project ####
    $project_id = getOnePassedId('prj');
    if (!($project = Project::getVisibleById($project_id))) {
        echo __("requested invalid project");
        exit;
        //$PH->abortWarning("task without project?", ERROR_BUG);
    }
    $list = new ListBlock_tasks();
    $list->query_options['show_folders'] = true;
    $list->query_options['folders_only'] = true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    unset($list->columns['project']);
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project, NULL);
    echo __("(or select nothing to move to project root)") . "<br> ";
    echo "<input type=hidden name='project' value='{$project->id}'>";
}
Example #5
0
 /**
  * query if editable for current user
  */
 static function getEditableById($id)
 {
     $id = intval($id);
     global $auth;
     if ($auth->cur_user->user_rights & RIGHT_PROJECT_EDIT) {
         return Project::getVisibleById($id, NULL, false);
     }
     return NULL;
 }
Example #6
0
 function getLatestComment($args = array())
 {
     if ($project = Project::getVisibleById($this->project)) {
         $args['on_task'] = $this->id;
         $args['order_by'] = 'created ASC';
         #$args['limit']=    1;
         $comments = $project->getComments($args);
         if ($comments) {
             return $comments[0];
         }
         return NULL;
     }
 }
Example #7
0
 function renderListCsv($list = NULL)
 {
     if (!count($list)) {
         return;
     }
     ## header ##
     $ids = array();
     $count = 0;
     foreach ($list[0]->fields as $field_name => $field) {
         if ($field->export) {
             switch ($field->type) {
                 case 'FieldString':
                 case 'FieldInt':
                 case 'FieldDatetime':
                 case 'FieldText':
                     $ids[] = $field_name;
                     $count++;
                     break;
                 case 'FieldInternal':
                     if ($field_name == 'task') {
                         $ids[] = 'task_id';
                         $ids[] = 'task_name';
                     } else {
                         if ($field_name == 'person') {
                             $ids[] = 'person_id';
                             $ids[] = 'person_name';
                         } else {
                             if ($field_name == 'project') {
                                 $ids[] = 'project_id';
                                 $ids[] = 'project_name';
                             } else {
                                 $ids[] = $field_name;
                             }
                         }
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     ## list ##
     $values = array();
     foreach ($list as $row) {
         foreach ($list[0]->fields as $field_name => $field) {
             if ($field->export) {
                 switch ($field->type) {
                     case 'FieldText':
                     case 'FieldString':
                         $values[] = $this->cleanForCSV($row->{$field_name});
                         break;
                     case 'FieldInternal':
                         if ($field_name == 'task') {
                             $values[] = $row->{$field_name};
                             if ($task = Task::getVisibleById($row->{$field_name})) {
                                 $values[] = $this->cleanForCSV($task->name);
                             } else {
                                 $values[] = '';
                             }
                         } else {
                             if ($field_name == 'person') {
                                 $values[] = $row->{$field_name};
                                 if ($person = Person::getVisibleById($row->{$field_name})) {
                                     $values[] = $this->cleanForCSV($person->name);
                                 } else {
                                     $values[] = '-';
                                 }
                             } else {
                                 if ($field_name == 'project') {
                                     $values[] = $row->{$field_name};
                                     if ($project = Project::getVisibleById($row->{$field_name})) {
                                         $values[] = $this->cleanForCSV($project->name);
                                     } else {
                                         $values[] = '';
                                     }
                                 } else {
                                     $values[] = $row->{$field_name};
                                 }
                             }
                         }
                         break;
                     case 'FieldInt':
                     case 'FieldDatetime':
                         #$values[] = addslashes($row->$field_name,"\0..\37");
                         $values[] = $row->{$field_name};
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     ## export function ##
     exportToCSV($ids, $values);
 }
 function render_tr(&$obj, $style = "")
 {
     if (!isset($obj) || !$obj instanceof Effort) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     $sum = 0.0;
     $sum_sal = 0.0;
     $sum_all = 0.0;
     $diff_value = false;
     if ($obj->as_duration) {
         echo "<td>-</td>";
     } else {
         if ($effort_people = Effort::getEffortPeople(array('project' => $obj->project, 'task' => $obj->task))) {
             foreach ($effort_people as $ep) {
                 if ($person = Person::getVisibleById($ep->person)) {
                     /*if($obj->getStatus()){
                     			$sum_sal = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task, 'person'=>$person->id, 'status'=>$obj->status));
                     		}
                     		else{*/
                     $sum_sal = Effort::getSumEfforts(array('project' => $obj->project, 'task' => $obj->task, 'person' => $person->id));
                     #}
                     if ($sum_sal) {
                         $sum = round($sum_sal / 60 / 60, 1) * 1.0;
                         if ($project = Project::getVisibleById($obj->project)) {
                             if ($pp = $project->getProjectPeople(array('person_id' => $person->id))) {
                                 if ($pp[0]->salary_per_hour) {
                                     $sum_all = $sum * $pp[0]->salary_per_hour;
                                 } else {
                                     $sum_all = $sum * $person->salary_per_hour;
                                 }
                             } else {
                                 $sum_all = $sum * $person->salary_per_hour;
                             }
                         }
                         //$sum_all += ($sum * $person->salary_per_hour);
                     }
                 }
             }
         }
         if ($task = Task::getVisibleById($obj->task)) {
             if ($sum_all && $task->calculation) {
                 $max_length_value = 3;
                 $get_percentage = $sum_all / $task->calculation * 100;
                 if ($get_percentage > 100) {
                     $diff = $get_percentage - 100;
                     $get_percentage = 100;
                     $diff_value = true;
                 }
                 $show_rate = $get_percentage * $max_length_value;
                 echo "<td>";
                 echo "<nobr>";
                 echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#f00;'>";
                 if ($diff_value) {
                     $show_rate = $diff * $max_length_value;
                     echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#ff9900;'>";
                     echo " " . round($get_percentage, 1) . "% / " . round($diff, 1) . " %";
                 } else {
                     echo " " . round($get_percentage, 1) . "%";
                 }
                 echo "</nobr>";
                 echo "</td>";
             } else {
                 echo "<td>-</td>";
             }
         } else {
             echo "<td>-</td>";
         }
     }
 }
Example #9
0
 /**
  * returns visible object of correct type by an itemId
  *
  * this is useful, eg. if you when to access common parameters like name,
  * regardless of the object's type.
  *
  * DbProjectItem::getById() would only load to basic fields. Getting the
  * complete date required check for type.
  *
  * @NOTE: This function causes a awkward dependency to classes derived from
  * DbProjectItem. It's somehow weird, that this method is placed inside the
  * parent class.
  */
 public static function getObjectById($id)
 {
     $id = intval($id);
     if (!($item = DbProjectItem::getById($id))) {
         return NULL;
     }
     if ($type = $item->type) {
         switch ($type) {
             case ITEM_TASK:
                 require_once "db/class_task.inc.php";
                 $item_full = Task::getVisibleById($item->id);
                 break;
             case ITEM_COMMENT:
                 require_once "db/class_comment.inc.php";
                 $item_full = Comment::getVisibleById($item->id);
                 break;
             case ITEM_PERSON:
                 require_once "db/class_person.inc.php";
                 $item_full = Person::getVisibleById($item->id);
                 break;
             case ITEM_EFFORT:
                 require_once "db/class_effort.inc.php";
                 $item_full = Effort::getVisibleById($item->id);
                 break;
             case ITEM_FILE:
                 require_once "db/class_file.inc.php";
                 $item_full = File::getVisibleById($item->id);
                 break;
             case ITEM_PROJECT:
                 require_once "db/class_project.inc.php";
                 $item_full = Project::getVisibleById($item->id);
                 break;
             case ITEM_COMPANY:
                 require_once "db/class_company.inc.php";
                 $item_full = Company::getVisibleById($item->id);
                 break;
             case ITEM_VERSION:
                 require_once "db/class_task.inc.php";
                 $item_full = Task::getVisibleById($item->id);
                 break;
             default:
                 $item_full = NULL;
         }
         return $item_full;
     }
 }
Example #10
0
 function render_tr(&$task, $style = "nowrap")
 {
     global $PH;
     if (!isset($task) || !$task instanceof Task) {
         return;
     }
     ### task with zero-id is project-root ###
     if (!$task->id) {
         $link = $PH->getLink('projView', "...project...", array('prj' => $task->project));
         echo '<td><b>' . $link . "</b></td>";
     } else {
         $name = $task->name;
         if (!$name) {
             $name = __("- no name -", "in task lists");
         }
         $html_details = '';
         if ($this->parent_block->show_project_folder && ($project = Project::getVisibleById($task->project))) {
             if ($tmp = $task->getFolderLinks(true, $project)) {
                 $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
             }
         } else {
             if ($tmp = $task->getFolderLinks()) {
                 $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
             }
         }
         $isDone = $task->status >= STATUS_COMPLETED ? 'isDone' : '';
         $link = $PH->getLink('taskView', $name, array('tsk' => $task->id));
         #echo "<td class=taskwithfolder><span class='name $isDone'>{$link}</span><br><span class=sub>$html_details</span></td>";
         echo "<td class=taskwithfolder><span class='{$isDone}'>{$link}</span><br><span class=sub>{$html_details}</span></td>";
     }
     measure_stop('col_taskname');
 }
Example #11
0
/**
* Initialize a page for displaying effort related content
*
* - inits: 
*   - breadcrumps
*   - options
*   - current section
*   - navigation
*   - pageType (including task folders)
*   - pageTitle (as Task title)
*/
function initPageForEffort($page, $effort, $project = NULL)
{
    global $PH;
    $crumbs = array();
    if (!$project) {
        $project = Project::getVisibleById($effort->project);
    }
    $task = Task::getVisibleById($effort->task);
    $page->cur_crumb = 'projViewEfforts';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->cur_tab = 'projects';
    if ($effort->name) {
        $page->title = $effort->name;
    } else {
        $page->title = __('Effort');
    }
    $page->title_minor_html = $PH->getLink('effortView', sprintf('#%d', $effort->id), array('effort' => $effort->id));
    global $g_status_names;
    $type = "";
    if ($task) {
        if ($folder = $task->getFolderLinks()) {
            $type = $folder . " &gt; ";
        }
        $type .= $task->getLink() . ' &gt; ';
    }
    $type .= __('Effort');
    $page->type = $type;
}
/**
* Submit data of a newly registered person @ingroup pages
*/
function personRegisterSubmit()
{
    global $PH;
    global $auth;
    ### cancel ? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home', array());
        }
        exit;
    }
    if (!validateFormCrc()) {
        $PH->abortWarning(__('Invalid checksum for hidden form elements'));
    }
    $person = new Person(array('id' => 0));
    $person->user_rights = RIGHT_PERSON_EDIT_SELF;
    ### person category ###
    $pcategory = get('pcategory');
    if ($pcategory != NULL) {
        if ($pcategory == -1) {
            $person->category = PCATEGORY_STAFF;
        } else {
            if ($pcategory == -2) {
                $person->category = PCATEGORY_CONTACT;
            } else {
                $person->category = $pcategory;
            }
        }
    }
    $flag_ok = true;
    # update valid?
    # retrieve all possible values from post-data
    # NOTE:
    # - this could be an security-issue.
    # - TODO: as some kind of form-edit-behaviour to field-definition
    foreach ($person->fields as $f) {
        $name = $f->name;
        $f->parseForm($person);
    }
    $person->can_login = 1;
    $period = get('person_notification_period');
    ### turn off ###
    if ($period === 0 || $period === "0") {
        $person->settings &= USER_SETTING_NOTIFICATIONS ^ RIGHT_ALL;
        $person->notification_period = 0;
    } else {
        $person->settings |= USER_SETTING_NOTIFICATIONS;
        $person->notification_period = $period;
        if ($person->can_login && !$person->personal_email && !$person->office_email) {
            $flag_ok = false;
            $person->fields['office_email']->required = true;
            $person->fields['personal_email']->required = true;
            new FeedbackWarning(__("Sending notifactions requires an email-address."));
        }
    }
    if (get('person_html_mail')) {
        $person->settings |= USER_SETTING_HTML_MAIL;
    } else {
        $person->settings &= USER_SETTING_HTML_MAIL ^ RIGHT_ALL;
    }
    $zone = get('person_time_zone');
    if ($zone != NULL && $person->time_zone != 1.0 * $zone) {
        $person->time_zone = 1.0 * $zone;
        if ($zone == TIME_OFFSET_AUTO) {
            new FeedbackMessage(__("Using auto detection of time zone requires this user to relogin."));
        } else {
            $person->time_offset = $zone * 60.0 * 60.0;
            if ($person->id == $auth->cur_user->id) {
                $auth->cur_user->time_offset = $zone * 60.0 * 60.0;
            }
        }
    }
    $theme = get('person_theme');
    if ($theme != NULL) {
        $person->theme = $theme;
        ### update immediately / without page-reload ####
        if ($person->id == $auth->cur_user->id) {
            $auth->cur_user->theme = $theme;
        }
    }
    $language = get('person_language');
    global $g_languages;
    if (isset($g_languages[$language])) {
        $person->language = $language;
        ### update immediately / without page-reload ####
        if ($person->id == $auth->cur_user->id) {
            $auth->cur_user->language = $language;
            setLang($language);
        }
    }
    if (!$person->name) {
        new FeedbackWarning(__("Login-accounts require a full name."));
        $person->fields['name']->required = true;
        $person->fields['name']->invalid = true;
        $flag_ok = false;
    }
    if (!$person->office_email) {
        new FeedbackWarning(__("Please enter an e-mail address."));
        $person->fields['office_email']->required = true;
        $person->fields['office_email']->invalid = true;
        $flag_ok = false;
    }
    $t_nickname = get('person_nickname');
    if (!$person->nickname) {
        new FeedbackWarning(__("Login-accounts require a unique nickname"));
        $person->fields['nickname']->required = true;
        $person->fields['nickname']->invalid = true;
        $flag_ok = false;
    }
    ### check if changed nickname is unique
    if ($person->can_login || $person->nickname != "") {
        /**
         * \todo actually this should be mb_strtolower, but this is not installed by default
         */
        if ($person->nickname != strtolower($person->nickname)) {
            new FeedbackMessage(__("Nickname has been converted to lowercase"));
            $person->nickname = strtolower($person->nickname);
        }
        if ($p2 = Person::getByNickname($t_nickname)) {
            # another person with this nick?
            if ($p2->id != $person->id) {
                new FeedbackWarning(__("Nickname has to be unique"));
                $person->fields['nickname']->required = true;
                $flag_ok = false;
            }
        }
    }
    ### password entered? ###
    $t_password1 = get('person_password1');
    $t_password2 = get('person_password2');
    $flag_password_ok = true;
    if (($t_password1 || $t_password2) && $t_password1 != "__dont_change__") {
        ### check if password match ###
        if ($t_password1 !== $t_password2) {
            new FeedbackWarning(__("Passwords do not match"));
            $person->fields['password']->required = true;
            $flag_ok = false;
            $flag_password_ok = false;
            $person->cookie_string = $auth->cur_user->calcCookieString();
        }
    }
    ### check if password is good enough ###
    $password_length = strlen($t_password1);
    $password_count_numbers = strlen(preg_replace('/[\\d]/', '', $t_password1));
    $password_count_special = strlen(preg_replace('/[\\w]/', '', $t_password1));
    $password_value = -7 + $password_length + $password_count_numbers * 2 + $password_count_special * 4;
    if ($password_value < confGet('CHECK_PASSWORD_LEVEL')) {
        new FeedbackWarning(__("Password is too weak (please add numbers, special chars or length)"));
        $flag_ok = false;
        $flag_password_ok = false;
    }
    if ($flag_password_ok) {
        $person->password = md5($t_password1);
    }
    if (!validateFormCaptcha()) {
        new FeedbackWarning(__("Please copy the text from the image."));
        $flag_ok = false;
    }
    ### repeat form if invalid data ###
    if (!$flag_ok) {
        $PH->show('personRegister', NULL, $person);
        exit;
    }
    /**
     * store indentifier-string for login from notification & reminder - mails
     */
    $person->identifier = $person->calcIdentifierString();
    ### insert new object ###
    if ($person->settings & USER_SETTING_NOTIFICATIONS && $person->can_login) {
        $person->settings |= USER_SETTING_SEND_ACTIVATION;
        new FeedbackHint(sprintf(__("A notification / activation  will be mailed to <b>%s</b> when you log out."), $person->name) . " " . sprintf(__("Read more about %s."), $PH->getWikiLink('notifications')));
    }
    $person->notification_last = getGMTString(time() - $person->notification_period * 60 * 60 * 24 - 1);
    $person->cookie_string = $person->calcCookieString();
    if ($person->insert()) {
        new FeedbackHint(__("Thank you for registration! After your request has been approved by a moderator, you will can an email."));
        ### link to a company ###
        if ($c_id = get('company')) {
            require_once confGet('DIR_STREBER') . 'db/class_company.inc.php';
            if ($c = Company::getVisibleById($c_id)) {
                require_once confGet('DIR_STREBER') . 'db/class_employment.inc.php';
                $e = new Employment(array('id' => 0, 'person' => $person->id, 'company' => $c->id));
                $e->insert();
            }
        }
        ## assigne to project ##
        require_once confGet('DIR_STREBER') . 'db/class_projectperson.inc.php';
        $prj_num = confGet('REGISTER_NEW_USERS_TO_PROJECT');
        global $g_user_profile_names;
        if (isset($prj_num)) {
            if ($prj_num != -1) {
                if ($p = Project::getVisibleById($prj_num)) {
                    $prj_person = new ProjectPerson(array('person' => $person->id, 'project' => $p->id, 'name' => $g_user_profile_names[$person->profile]));
                    $prj_person->insert();
                }
            }
        }
        new FeedbackMessage(sprintf(__('Person %s created'), $person->getLink()));
        ### automatically login ###
        $foo = array('login_name' => $person->nickname, 'login_password_md5' => $person->password);
        addRequestVars($foo);
        $PH->show('loginFormSubmit', array());
        exit;
    } else {
        new FeedbackError(__("Could not insert object"));
    }
    ### display fromPage ####
    if (!$PH->showFromPage()) {
        $PH->show('home', array());
    }
}
Example #13
0
/**
* edit several bookmarks @ingroup pages
*/
function itemBookmarkEditMultiple($thebookmarks = NULL)
{
    global $PH;
    global $auth;
    global $g_notitychange_period;
    $is_already_bookmark = array();
    $bookmarks = array();
    $items = array();
    $edit_fields = array('notify_if_unchanged', 'notify_on_change');
    $different_fields = array();
    # hash containing fieldnames which are different in bookmarks
    if (!$thebookmarks) {
        $item_ids = getPassedIds('bookmark', 'bookmarks_*');
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            }
        }
    } else {
        $item_ids = $thebookmarks;
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 0))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = false;
                }
            } elseif ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            } else {
                $date = getGMTString();
                $bookmark = new ItemPerson(array('id' => 0, 'item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1, 'notify_if_unchanged' => 0, 'notify_on_change' => 0, 'created' => $date));
                if ($item = DbProjectItem::getById($is)) {
                    $bookmarks[] = $bookmark;
                    $items[] = $item;
                    $is_already_bookmark[$bookmark->id] = false;
                }
            }
        }
    }
    if (!$items) {
        $PH->abortWarning(__("Please select some items"));
    }
    $page = new Page();
    $page->cur_tab = 'home';
    $page->options = array(new NaviOption(array('target_id' => 'itemBookmarkEdit', 'name' => __('Edit bookmarks'))));
    $page->type = __('Edit multiple bookmarks', 'page title');
    $page->title = sprintf(__('Edit %s bookmark(s)'), count($items));
    $page->title_minor = __('Edit');
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($items as $item) {
        ## get item name ##
        $str_link = '';
        if ($type = $item->type) {
            switch ($type) {
                case ITEM_TASK:
                    require_once "db/class_task.inc.php";
                    if ($task = Task::getVisibleById($item->id)) {
                        $str_link = $task->getLink(false);
                    }
                    break;
                case ITEM_COMMENT:
                    require_once "db/class_comment.inc.php";
                    if ($comment = Comment::getVisibleById($item->id)) {
                        $str_link = $comment->getLink(false);
                    }
                    break;
                case ITEM_PERSON:
                    require_once "db/class_person.inc.php";
                    if ($person = Person::getVisibleById($item->id)) {
                        $str_link = $person->getLink(false);
                    }
                    break;
                case ITEM_EFFORT:
                    require_once "db/class_effort.inc.php";
                    if ($e = Effort::getVisibleById($item->id)) {
                        $str_link = $e->getLink(false);
                    }
                    break;
                case ITEM_FILE:
                    require_once "db/class_file.inc.php";
                    if ($f = File::getVisibleById($item->id)) {
                        $str_link = $f->getLink(false);
                    }
                    break;
                case ITEM_PROJECT:
                    require_once "db/class_project.inc.php";
                    if ($prj = Project::getVisibleById($item->id)) {
                        $str_link = $prj->getLink(false);
                    }
                    break;
                case ITEM_COMPANY:
                    require_once "db/class_company.inc.php";
                    if ($c = Company::getVisibleById($item->id)) {
                        $str_link = $c->getLink(false);
                    }
                    break;
                case ITEM_VERSION:
                    require_once "db/class_task.inc.php";
                    if ($tsk = Task::getVisibleById($item->id)) {
                        $str_link = $tsk->getLink(false);
                    }
                    break;
                default:
                    break;
            }
        }
        echo "<li>" . $str_link . "</li>";
    }
    echo "</ol>";
    foreach ($bookmarks as $bookmark) {
        foreach ($edit_fields as $field_name) {
            if ($bookmark->{$field_name} != $bookmarks[0]->{$field_name}) {
                $different_fields[$field_name] = true;
            }
        }
    }
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $b = array();
    $b[0] = __('no');
    $b[1] = __('yes');
    if (isset($different_fields['notify_on_change'])) {
        $b[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), -1));
    } else {
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), $bookmarks[0]->notify_on_change));
    }
    $a = array();
    foreach ($g_notitychange_period as $key => $value) {
        $a[$key] = $value;
    }
    if (isset($different_fields['notify_if_unchanged'])) {
        $a[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), -1));
    } else {
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), $bookmarks[0]->notify_if_unchanged));
    }
    $number = 0;
    foreach ($bookmarks as $bm) {
        $form->add(new Form_HiddenField("bookmark_id_{$number}", '', $bm->id));
        $form->add(new Form_HiddenField("bookmark_item_{$number}", '', $bm->item));
        $form->add(new Form_HiddenField("is_already_bookmark_{$number}", '', $is_already_bookmark[$bm->id]));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'itemBookmarkEditMultipleSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Example #14
0
/**
* renders a comparision between two versions of an item @ingroup pages
*/
function itemViewDiff()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
    ### get task ####
    $item_id = get('item');
    if (!($item = DbProjectItem::getObjectById($item_id))) {
        $PH->abortWarning("invalid item-id", ERROR_FATAL);
    }
    if (!($project = Project::getVisibleById($item->project))) {
        $PH->abortWarning("this item has an invalid project id", ERROR_DATASTRUCTURE);
    }
    require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php";
    $versions = ItemVersion::getFromItem($item);
    $date1 = get('date1');
    $date2 = get('date2');
    if (!$date1) {
        #if(count($versions) > 1) {
        #    if($auth->cur_user->last_logout < $versions[count($versions)-2]->date_to)
        #    {
        #        $date1 = $auth->cur_user->last_logout;
        #    }
        #    else {
        #        $date1 = $versions[count($versions)-2]->date_from;
        #    }
        #}
        #else {
        foreach (array_reverse($versions) as $v) {
            if ($v->author == $auth->cur_user->id) {
                $date1 = $v->date_from;
                break;
            }
        }
        #}
    }
    if (!$date2) {
        $date2 = getGMTString();
    }
    $page = new Page();
    $page->cur_tab = 'projects';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->title = $item->name;
    $page->title_minor = __('changes');
    $page->add_function(new PageFunction(array('target' => 'itemView', 'params' => array('item' => $item->id), 'icon' => 'edit', 'name' => __('View item'))));
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    if ($date1 > $date2) {
        new FeedbackMessage(__("date1 should be smaller than date2. Swapped"));
        $t = $date1;
        $date1 = $date2;
        $date2 = $t;
    }
    if (count($versions) == 1) {
        echo __("item has not been edited history");
    } else {
        $old_version = NULL;
        $version_right = NULL;
        $version_left = $versions[0];
        foreach ($versions as $v) {
            if ($v->date_from <= $date1) {
                $version_left = $v;
            }
            if ($v->date_from >= $date2) {
                if (isset($version_right)) {
                    if ($version_right->date_from > $v->date_from) {
                        $version_right = $v;
                    }
                } else {
                    $version_right = $v;
                }
            }
        }
        if (!isset($version_right)) {
            $version_right = $versions[count($versions) - 1];
        }
        $options_left = array();
        $options_right = array();
        ### list versions left ###
        for ($i = 0; $i < count($versions) - 1; $i++) {
            $v = $versions[$i];
            if ($person = Person::getVisibleById($v->author)) {
                $author = $person->name;
            } else {
                $author = __('unknown');
            }
            if ($v->version_number == $version_left->version_number) {
                $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                $name = ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . $v->date_from;
                $options_left[] = "<option selected=1 value='" . $str_link . "'>" . $name . "</option>";
            } else {
                if ($v->version_number > $version_left->version_number) {
                    if ($v->version_number < $version_right->version_number) {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                        $name = '&gt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    } else {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $version_right->date_to));
                        $name = '&gt;&gt;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    }
                    $options_left[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                } else {
                    $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $version_right->date_from));
                    $name = '&lt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    $options_left[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                }
            }
        }
        ### list versions right ###
        for ($i = 1; $i < count($versions); $i++) {
            $v = $versions[$i];
            if ($person = Person::getVisibleById($v->author)) {
                $author = $person->name;
            } else {
                $author = __('unknown');
            }
            if ($v->version_number == $version_right->version_number) {
                $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                $name = ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . $v->date_from;
                $options_right[] = "<option selected=1 value='" . $str_link . "'>" . $name . "</option>";
            } else {
                if ($v->version_number > $version_right->version_number) {
                    $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $version_left->date_from, 'date2' => $versions[$i]->date_from));
                    $name = '&gt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . ' -- ' . renderDate($v->date_from);
                    $options_right[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                } else {
                    if ($v->version_number > $version_left->version_number) {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $version_left->date_from, 'date2' => $versions[$i]->date_from));
                        $name = '&lt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    } else {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                        $name = '&lt;&lt;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . ' -- ' . renderDate($v->date_from);
                    }
                    $options_right[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                }
            }
        }
        ### prev ###
        if ($version_left->version_number > 1) {
            $link_prev = $PH->getLink('itemViewDiff', '&lt;&lt; ' . __('prev change'), array('item' => $item->id, 'date1' => $versions[$version_left->version_number - 2]->date_from, 'date2' => $versions[$version_left->version_number - 2]->date_to), NULL, true);
        } else {
            $link_prev = '';
        }
        ### next ###
        if ($version_right->version_number < count($versions)) {
            $link_next = $PH->getLink('itemViewDiff', __('next') . '&gt;&gt;', array('item' => $item->id, 'date1' => $versions[$version_right->version_number - 1]->date_from, 'date2' => $versions[$version_right->version_number - 1]->date_to), NULL, true);
        } else {
            $link_next = '';
        }
        ### summary ###
        $link_summary = $PH->getLink('itemViewDiff', __('summary'), array('item' => $item->id, 'date1' => $auth->cur_user->last_logout, 'date2' => getGMTString()), NULL, true);
        echo "<div class=diff>";
        echo "<table class=nav><tr>";
        echo "<td class=older>" . "<select onChange='location.href=this.options[this.selectedIndex].value'>" . join(array_reverse($options_left)) . "</select>" . '<br><b class=doclear></b>' . $link_prev . "</td>";
        echo "<td class=newer>" . "<select onChange='location.href=this.options[this.selectedIndex].value'>" . join(array_reverse($options_right)) . "</select>" . '<br><b class=doclear></b>' . $link_next . $link_summary . "</td>";
        echo "</table>";
        #if(!$date2 || !$date1) {
        #    echo sprintf(__("Item did not exists at %s"), renderTime($date2));
        #}
        if ($old_version == $version_right) {
            echo sprintf(__('no changes between %s and %s'), renderTime($date1), renderTime($date2));
        }
        ### collect changes ###
        $old_field_values = array();
        $new_field_values = array();
        foreach ($versions as $v) {
            if ($v->version_number <= $version_left->version_number) {
                foreach ($v->values as $name => $value) {
                    $old_field_values[$name] = $value;
                }
            }
            if ($v->version_number >= $version_left->version_number && $v->version_number < $version_right->version_number) {
                foreach ($v->values_next as $name => $value) {
                    $new_field_values[$name] = $value;
                }
            }
        }
        foreach ($new_field_values as $field_name => $value) {
            echo "<h2>{$field_name}</h2>";
            $old_value = isset($old_field_values[$field_name]) ? $old_field_values[$field_name] : "";
            $new_value = isset($new_field_values[$field_name]) ? $new_field_values[$field_name] : '';
            $field_type = $item->fields[$field_name]->type;
            if ($field_type == 'FieldText') {
                echo render_changes($old_value, $new_value);
            } else {
                if ($field_type == 'FieldOption') {
                    if ($field_name == 'status') {
                        global $g_status_names;
                        $old_value = isset($g_status_names[$old_value]) ? $g_status_names[$old_value] : __('undefined');
                        $new_value = isset($g_status_names[$new_value]) ? $g_status_names[$new_value] : __('undefined');
                    } else {
                        if ($field_name == 'label') {
                            if ($project = Project::getVisibleById($item->project)) {
                                $labels = explode(",", $project->labels);
                                $old_value = isset($labels[$old_value - 1]) ? $labels[$old_value - 1] : __('undefined');
                                $new_value = isset($labels[$new_value - 1]) ? $labels[$new_value - 1] : __('undefined');
                            }
                        }
                    }
                    echo render_changes($old_value, $new_value);
                } else {
                    if ($field_type == 'FieldInternal') {
                        if ($field_name == 'parent_item') {
                            if ($task_parent_old = Task::getVisibleById($old_value)) {
                                $ar = array();
                                foreach ($task_parent_old->getFolder() as $f) {
                                    $ar[] = $f->name;
                                }
                                $ar[] = $task_parent_old->name;
                                $old_value = join($ar, " > ");
                            }
                            if ($task_parent_new = Task::getVisibleById($new_value)) {
                                $ar = array();
                                foreach ($task_parent_new->getFolder() as $f) {
                                    $ar[] = $f->name;
                                }
                                $ar[] = $task_parent_new->name;
                                $new_value = join($ar, " > ");
                            }
                        } else {
                            if ($field_name == 'state') {
                                $old_value = $old_value == -1 ? __('deleted') : __('ok');
                                $new_value = $new_value == -1 ? __('deleted') : __('ok');
                            } else {
                                if ($field_name == 'pub_level') {
                                    global $g_pub_level_names;
                                    $old_value = isset($g_pub_level_names[$old_value]) ? $g_pub_level_names[$old_value] : __('undefined');
                                    $new_value = isset($g_pub_level_names[$new_value]) ? $g_pub_level_names[$new_value] : __('undefined');
                                }
                            }
                        }
                        echo render_changes($old_value, $new_value);
                    } else {
                        if ($field_type == 'FieldPercentage') {
                            echo render_changes($old_value, $new_value);
                        } else {
                            if ($field_type == 'FieldInt') {
                                echo render_changes($old_value, $new_value);
                            } else {
                                if ($field_type == 'FieldString') {
                                    echo render_changes($old_value, $new_value);
                                } else {
                                    if ($field_type == 'FieldDate') {
                                        echo render_changes(renderDate($old_value), renderDate($new_value));
                                    } else {
                                        if ($field_type == 'FieldDatetime') {
                                            echo render_changes(renderTimestamp($old_value), renderTimestamp($new_value));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    echo "</div>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Example #15
0
/**
* Show an RSS Feed of the latest changes on a project @ingroup pages
*/
function projViewAsRSS()
{
    require_once confGet('DIR_STREBER') . "std/class_rss.inc.php";
    global $PH;
    global $auth;
    $project_id = getOnePassedId('prj', 'projects_*');
    # aborts on failure
    if (!($project = Project::getVisibleById($project_id))) {
        echo "Project is not readable. Anonymous user active?";
        exit;
    }
    ### used cached? ###
    $filepath = "_rss/proj_{$project->id}.xml";
    if (file_exists($filepath) || getGMTString(filemtime($filepath)) . "<" . $project->modified) {
        RSS::updateRSS($project);
    }
    readfile_chunked($filepath);
    exit;
}
Example #16
0
/**
* Edit several efforts @ingroup pages
*/
function effortEditMultiple()
{
    global $PH;
    global $g_effort_status_names;
    $effort_ids = getPassedIds('effort', 'efforts_*');
    if (!$effort_ids) {
        $PH->abortWarning(__("Select some efforts(s) to edit"));
        exit;
    }
    $efforts = array();
    $different_fields = array();
    $edit_fields = array('status', 'pub_level', 'task');
    foreach ($effort_ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $efforts[] = $effort;
            ### check project for first task
            if (count($efforts) == 1) {
                ### make sure all are of same project ###
                if (!($project = Project::getVisibleById($effort->project))) {
                    $PH->abortWarning('could not get project');
                }
            } else {
                if ($effort->project != $efforts[0]->project) {
                    $PH->abortWarning(__("For editing all efforts must be of same project."));
                }
                foreach ($edit_fields as $field_name) {
                    if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
                        $different_fields[$field_name] = true;
                    }
                }
            }
        }
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'effort_name'));
    $page->cur_tab = 'projects';
    $page->options[] = new naviOption(array('target_id' => 'effortEdit'));
    $page->type = __("Edit multiple efforts", "Page title");
    $page->title = sprintf(__("Edit %s efforts", "Page title"), count($efforts));
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($efforts as $e) {
        echo "<li>" . $e->getLink(false) . "</li>";
    }
    echo "</ol>";
    $block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $st = array();
    foreach ($g_effort_status_names as $key => $value) {
        $st[$key] = $value;
    }
    if (isset($different_fields['status'])) {
        $st[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('effort_status', __("Status"), array_flip($st), -1));
    } else {
        $form->add(new Form_Dropdown('effort_status', __("Status"), array_flip($st), $efforts[0]->status));
    }
    ### get meta-tasks / folders ###
    $folders = Task::getAll(array('sort_hierarchical' => true, 'parent_task' => 0, 'show_folders' => true, 'folders_only' => false, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED, 'project' => $project->id));
    if ($folders) {
        $folder_list = array("undefined" => "0");
        if ($effort->task) {
            if ($task = Task::getVisibleById($effort->task)) {
                ### add, if normal task (folders will added below) ###
                if (!$task->category == TCATEGORY_FOLDER) {
                    $folder_list[$task->name] = $task->id;
                }
            }
        }
        foreach ($folders as $f) {
            $str = '';
            foreach ($f->getFolder() as $pf) {
                $str .= $pf->getShort() . " > ";
            }
            $str .= $f->name;
            $folder_list[$str] = $f->id;
        }
        if (isset($different_fields['task'])) {
            $folder_list['-- ' . __('keep different') . ' --'] = -1;
            $form->add(new Form_Dropdown('effort_task', __("For task"), $folder_list, -1));
        } else {
            $form->add(new Form_Dropdown('effort_task', __("For task"), $folder_list, $efforts[0]->task));
        }
    }
    if (($pub_levels = $effort->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        if (isset($different_fields['pub_level'])) {
            $pub_levels['-- ' . __('keep different') . ' --'] = -1;
            $form->add(new Form_Dropdown('effort_pub_level', __("Publish to"), $pub_levels, -1));
        } else {
            $form->add(new Form_Dropdown('effort_pub_level', __("Publish to"), $pub_levels, $efforts[0]->pub_level));
        }
    }
    $number = 0;
    foreach ($efforts as $e) {
        $form->add(new Form_HiddenField("effort_id_{$number}", '', $e->id));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'effortEditMultipleSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
    exit;
}
Example #17
0
/**
* Edit a task
*
* @ingroup pages
*/
function taskEdit($task = NULL)
{
    global $PH;
    ### object or from database? ###
    if (!$task) {
        $ids = getPassedIds('tsk', 'tasks_*');
        if (!$ids) {
            $PH->abortWarning(__("Select some task(s) to edit"), ERROR_NOTE);
            return;
        } else {
            if (count($ids) > 1) {
                $PH->show('taskEditMultiple');
                exit;
            } else {
                if (!($task = Task::getEditableById($ids[0]))) {
                    $PH->abortWarning(__("You do not have enough rights to edit this task"), ERROR_RIGHTS);
                }
            }
        }
    }
    ### get parent project ####
    if (!($project = Project::getVisibleById($task->project))) {
        $PH->abortWarning("FATAL error! parent project not found");
    }
    ### abort, if not enough rights ###
    $project->validateEditItem($task);
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'task_name'));
    initPageForTask($page, $task, $project);
    if ($task->id) {
        $page->title = $task->name;
        $page->title_minor = $task->short;
    } else {
        if ($task->category == TCATEGORY_MILESTONE) {
            $page->title = __("New milestone");
        } else {
            if ($task->category == TCATEGORY_VERSION) {
                $page->title = __("New version");
            } else {
                if ($task->category == TCATEGORY_DOCU) {
                    $page->title = __("New topic");
                } else {
                    if ($task->category == TCATEGORY_FOLDER) {
                        $page->title = __("New folder");
                    } else {
                        $page->title = __("New task");
                        if ($task->parent_task && ($parent_task = Task::getVisibleById($task->parent_task))) {
                            $page->title_minor = sprintf(__('for %s', 'e.g. new task for something'), $parent_task->name);
                        } else {
                            $page->title_minor = sprintf(__('for %s', 'e.g. new task for something'), $project->name);
                        }
                    }
                }
            }
        }
    }
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    global $auth;
    global $REPRODUCIBILITY_VALUES;
    global $g_prio_names;
    global $g_status_names;
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($task->fields['name']->getFormElement($task));
    $list = array();
    if ($task->category == TCATEGORY_MILESTONE || $task->category == TCATEGORY_VERSION) {
        $list = array(TCATEGORY_MILESTONE, TCATEGORY_VERSION);
        ### make sure it's valid
        if ($task->category != TCATEGORY_MILESTONE || $task->category != TCATEGORY_VERSION) {
            if ($task->is_released > RELEASED_UPCOMMING) {
                $task->category = TCATEGORY_VERSION;
            } else {
                $task->category = TCATEGORY_MILESTONE;
            }
        }
    } else {
        $list = array();
        if ($project->settings & PROJECT_SETTING_ENABLE_TASKS) {
            $list[] = TCATEGORY_TASK;
        }
        if ($project->settings & PROJECT_SETTING_ENABLE_BUGS) {
            $list[] = TCATEGORY_BUG;
        }
        $list[] = TCATEGORY_DOCU;
        $list[] = TCATEGORY_FOLDER;
    }
    global $g_tcategory_names;
    $cats = array();
    foreach ($list as $c) {
        $cats[$c] = $g_tcategory_names[$c];
    }
    $form->add(new Form_Dropdown('task_category', __("Display as"), array_flip($cats), $task->category));
    ### warning if folder with subtasks ###
    if ($task->id && $task->category == TCATEGORY_FOLDER && ($num_subtasks = count($task->getSubtasks()))) {
        $form->add(new Form_CustomHtml('<p><label></label>' . sprintf(__("This folder has %s subtasks. Changing category will ungroup them."), $num_subtasks) . '</p>'));
    }
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab('task', __("Task")));
    ### normaltasks and folders ##
    if (!$task->isMilestoneOrVersion()) {
        if ($project->settings & PROJECT_SETTING_ENABLE_MILESTONES) {
            $tab->add(new Form_DropdownGrouped('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
        }
        ### prio ###
        if ($task->category != TCATEGORY_MILESTONE && $task->category != TCATEGORY_VERSION) {
            $tab->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio));
        }
    }
    ### for existing tasks, get already assigned
    if ($task->id) {
        $assigned_people = $task->getAssignedPeople();
        #$task_assignments = $task->getAssignments();
    } else {
        ### check new assigments ###
        $count = 0;
        while ($id_new = get('task_assign_to_' . $count)) {
            $count++;
            ### check if already assigned ###
            if ($p = Person::getVisibleById($id_new)) {
                $assigned_people[] = $p;
            }
        }
        if (!$count) {
            $parents = $task->getFolder();
            if ($parents) {
                $parents = array_reverse($parents);
                foreach ($parents as $p) {
                    if ($ap = $p->getAssignedPeople()) {
                        $assigned_people = $ap;
                        break;
                    }
                }
            }
        }
    }
    $team = array(__('- select person -') => 0);
    ### create team-list ###
    foreach ($project->getPeople() as $p) {
        $team[$p->name] = $p->id;
    }
    ### create drop-down-lists ###
    $count_new = 0;
    $count_all = 0;
    if (isset($assigned_people)) {
        foreach ($assigned_people as $ap) {
            if (!($p = Person::getVisibleById($ap->id))) {
                continue;
                # skip if invalid person
            }
            if ($task->id) {
                $tab->add(new Form_Dropdown('task_assigned_to_' . $ap->id, __("Assigned to"), $team, $ap->id));
            } else {
                $tab->add(new Form_Dropdown('task_assign_to_' . $count_new, __("Assign to"), $team, $ap->id));
                $count_new++;
            }
            $count_all++;
            unset($team[$ap->name]);
        }
    }
    ### add empty drop-downlist for new assignments ###
    $str_label = $count_all == 0 ? __("Assign to", "Form label") : __("Also assign to", "Form label");
    $tab->add(new Form_Dropdown("task_assign_to_{$count_new}", $str_label, $team, 0));
    ### completion ###
    if (!$task->is_released > RELEASED_UPCOMMING) {
        #$form->add($task->fields['estimated'    ]->getFormElement($task));
        $ar = array(__('undefined') => -1, '0%' => 0, '10%' => 10, '20%' => 20, '30%' => 30, '40%' => 40, '50%' => 50, '60%' => 60, '70%' => 70, '80%' => 80, '90%' => 90, '95%' => 95, '98%' => 98, '99%' => 99, '100%' => 100);
        $tab->add(new Form_Dropdown('task_completion', __("Completed"), $ar, $task->completion));
    }
    $st = array();
    foreach ($g_status_names as $s => $n) {
        if ($s >= STATUS_NEW) {
            $st[$s] = $n;
        }
    }
    if ($task->isMilestoneOrVersion()) {
        unset($st[STATUS_NEW]);
    }
    $field_status = new Form_Dropdown('task_status', "Status", array_flip($st), $task->status);
    if ($task->fields['status']->invalid) {
        $field_status->invalid = true;
    }
    $tab->add($field_status);
    if (!$task->isMilestoneOrVersion()) {
        if ($project->settings & PROJECT_SETTING_ENABLE_MILESTONES) {
            ### resolved version ###
            $tab->add(new Form_DropdownGrouped('task_resolved_version', __('Resolved in'), $project->buildResolvedInList(), $task->resolved_version));
        }
        ### resolved reason ###
        global $g_resolve_reason_names;
        $tab->add(new Form_Dropdown('task_resolve_reason', __('Resolve reason'), array_flip($g_resolve_reason_names), $task->resolve_reason));
    }
    $tab_group->add($tab = new Page_Tab("bug", __("Bug Report")));
    ### use issue-report ###
    global $g_severity_names;
    global $g_reproducibility_names;
    ### create new one ###
    if ($task->issue_report <= 0) {
        $issue = new Issue(array('id' => 0));
        ### get recent issue-reports ###
        if ($recent_ir = Issue::getCreatedRecently()) {
            $default_version = '';
            $default_plattform = '';
            $default_production_build = '';
            $default_os = '';
            foreach ($recent_ir as $ir) {
                if ($ir->project == $project->id) {
                    if (!$issue->version && $ir->version) {
                        $issue->version = $ir->version;
                    }
                    if (!$issue->plattform && $ir->plattform) {
                        $issue->plattform = $ir->plattform;
                    }
                    if (!$issue->os && $ir->os) {
                        $issue->os = $ir->os;
                    }
                    if (!$issue->production_build && $ir->production_build) {
                        $issue->production_build = $ir->production_build;
                    }
                }
            }
        }
    } else {
        /**
         * note: if task is visible ignore visibility of issue report
         */
        $issue = Issue::getById($task->issue_report);
    }
    if ($issue) {
        $tab->add(new Form_Dropdown('issue_severity', __("Severity", "Form label, attribute of issue-reports"), array_flip($g_severity_names), $issue->severity));
        $tab->add(new Form_Dropdown('issue_reproducibility', __("Reproducibility", "Form label, attribute of issue-reports"), array_flip($g_reproducibility_names), $issue->reproducibility));
        foreach ($issue->fields as $field) {
            $tab->add($field->getFormElement($issue));
        }
        $tab->add(new Form_HiddenField('task_issue_report', '', $task->issue_report));
    } else {
        trigger_error("could not get Issue with id ({$task->issue}-report)", E_USER_NOTICE);
    }
    $tab_group->add($tab = new Page_Tab("timing", __("Timing")));
    ### estimated ###
    if (!$task->isMilestoneOrVersion()) {
        #$tab->add($task->fields['estimated'    ]->getFormElement($task));
        $ar = array(__('undefined') => 0, __('30 min') => 30 * 60, __('1 h') => 60 * 60, __('2 h') => 2 * 60 * 60, __('4 h') => 4 * 60 * 60, __('1 Day') => 1 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Days') => 2 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Days') => 3 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('4 Days') => 4 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('1 Week') => 1 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Weeks') => 2 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Weeks') => 3 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60);
        $tab->add(new Form_Dropdown('task_estimated', __("Estimated time"), $ar, $task->estimated));
        $tab->add(new Form_Dropdown('task_estimated_max', __("Estimated worst case"), $ar, $task->estimated_max));
    }
    ### planned time ###
    if (!$task->isMilestoneOrVersion()) {
        $tab->add($task->fields['planned_start']->getFormElement($task));
    }
    $tab->add($task->fields['planned_end']->getFormElement($task));
    if ($task->isMilestoneOrVersion()) {
        global $g_released_names;
        $tab->add(new Form_Dropdown('task_is_released', __("Release as version", "Form label, attribute of issue-reports"), array_flip($g_released_names), $task->is_released));
        $tab->add($task->fields['time_released']->getFormElement($task));
    }
    $tab_group->add($tab = new Page_Tab('description', __("Description")));
    $e = $task->fields['description']->getFormElement($task);
    $e->rows = 20;
    $tab->add($e);
    $tab_group->add($tab = new Page_Tab('display', __("Display")));
    ### short ###
    $tab->add($task->fields['short']->getFormElement($task));
    ### order id ###
    $tab->add($task->fields['order_id']->getFormElement($task));
    ### Shows as news ###
    $tab->add($task->fields['is_news']->getFormElement($task));
    ### Shows Folder as documentation ###
    $tab->add($task->fields['show_folder_as_documentation']->getFormElement($task));
    ### public-level ###
    if (($pub_levels = $task->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        $tab->add(new Form_Dropdown('task_pub_level', __("Publish to"), $pub_levels, $task->pub_level));
    }
    ### label ###
    if (!$task->isOfCategory(TCATEGORY_VERSION, TCATEGORY_MILESTONE, TCATEGORY_FOLDER)) {
        $labels = array(__('undefined') => 0);
        $counter = 1;
        foreach (explode(",", $project->labels) as $l) {
            $labels[$l] = $counter++;
        }
        $tab->add(new Form_Dropdown('task_label', __("Label"), $labels, $task->label));
    }
    if (confGet('INTERNAL_COST_FEATURE') && $auth->cur_user->user_rights & RIGHT_VIEWALL && $auth->cur_user->user_rights & RIGHT_EDITALL) {
        $tab_group->add($tab = new Page_Tab("internal", __("Internal")));
        $tab->add($task->fields['calculation']->getFormElement($task));
    }
    /**
     * to reduce spam, enforce captcha test for guests
     */
    global $auth;
    if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
        $form->addCaptcha();
    }
    $form->add($task->fields['parent_task']->getFormElement($task));
    #echo "<input type=hidden name='tsk' value='$task->id'>";
    $form->add(new Form_HiddenField('tsk', '', $task->id));
    #echo "<input type=hidden name='task_project' value='$project->id'>";
    $form->add(new Form_HiddenField('task_project', '', $project->id));
    ### create another task ###
    if ($task->id == 0) {
        $checked = get('create_another') ? 'checked' : '';
        $form->form_options[] = "<input id='create_another' name='create_another' type=checkbox {$checked}><label for='create_another'>" . __("Create another task after submit") . "</label>";
    }
    echo $form;
    $PH->go_submit = 'taskEditSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    $block->render_blockEnd();
    #@@@ passing project-id is an security-issue, because it might allow to add tasks to unverified projects.
    # Double-checking project-rights in taskEditSubmit() required
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Example #18
0
/**
* get recent changes for ajax request from home @ingroup pages
*
* @Params
* - prj
* - start
* - count
*
* @NOTE
* This page function was formerly a part of home.inc.php but since it will
* be used in other places as well, item_ajax might be a better place for it.
*/
function AjaxMoreChanges()
{
    require_once confGet('DIR_STREBER') . 'std/class_changeline.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_recentchanges.inc.php';
    global $auth;
    header("Content-type: text/html; charset=utf-8");
    if (!($project = Project::getVisibleById(get('prj')))) {
        return;
    }
    $start = is_null(get('start')) ? 0 : intval(get('start'));
    $count = is_null(get('count')) ? 20 : intval(get('count'));
    $options = array('project' => $project->id, 'unviewed_only' => false, 'limit_rowcount' => $count, 'limit_offset' => $start, 'type' => array(ITEM_TASK, ITEM_FILE));
    if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
        $options['not_modified_by'] = $auth->cur_user->id;
    }
    /**
     * first query all unviewed changes
     */
    if ($changes = ChangeLine::getChangeLines($options)) {
        $lines = 0;
        foreach ($changes as $c) {
            printChangeLine($c);
        }
    }
}
Example #19
0
/**
* Submit changes to multiple tasks
*
* @ingroup pages
*/
function taskEditMultipleSubmit()
{
    global $PH;
    $ids = getPassedIds('tsk', 'tasks_*');
    if (!$ids) {
        $PH->abortWarning(__("Select some task(s) to mark as approved"), ERROR_NOTE);
        return;
    }
    $count = 0;
    $errors = 0;
    $number = get('number');
    ### cancel? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    foreach ($ids as $id) {
        if ($task = Task::getEditableById($id)) {
            $count++;
            $change = false;
            $status_old = $task->status;
            ### status ###
            if ($count == 1) {
                if (!($project = Project::getVisibleById($task->project))) {
                    $PH->abortWarning('could not get project');
                }
                $team = array();
                foreach ($project->getPeople() as $p) {
                    $team[$p->id] = $p;
                }
            }
            $task_assigned_people = array();
            $task_assignments = array();
            $task_people_overwrite = array();
            $task_people_new = array();
            $task_people_delete = array();
            ## previous assigend people ##
            if ($task_people = $task->getAssignedPeople(false)) {
                foreach ($task_people as $tp) {
                    $task_assigned_people[$tp->id] = $tp;
                }
            }
            ## previous assignements ##
            if ($task_assign = $task->getAssignments()) {
                foreach ($task_assign as $ta) {
                    $task_assignments[$ta->person] = $ta;
                }
            }
            ## different assigned people ##
            ## overwrite ?? ##
            $ass1 = get('task_assignement_diff');
            if ($ass1 && $ass1 != '__dont_change__') {
                $task_people_overwrite[] = $ass1;
                foreach ($task_assignments as $key => $value) {
                    $task_people_delete[] = $value;
                }
                $change = true;
            }
            ## new ?? ##
            $ass2 = get('task_assignement_also_diff');
            if ($ass2 && $ass2 != '__select_person__') {
                $task_people_new[] = $ass2;
                $change = true;
            }
            $different = get('different_ass');
            if (isset($different) && !$different) {
                if (isset($task_assignments) && count($task_assignments) != 0) {
                    foreach ($task_assignments as $tid => $t_old) {
                        $id_new = get('task_assign_to_' . $tid);
                        ## no changes ##
                        if ($tid == $id_new) {
                            continue;
                        }
                        if ($id_new == '__none__') {
                            if (!$t_old) {
                                continue;
                            }
                            $task_people_delete[] = $t_old;
                            continue;
                        }
                        $task_people_delete[] = $t_old;
                        $task_people_overwrite[] = $id_new;
                    }
                } else {
                    $id_new = get('task_assign_to___none__');
                    if ($id_new && $id_new != '__none__') {
                        $task_people_new[] = $id_new;
                    }
                }
                $id_new = get('task_assign_to_0');
                if ($id_new != '__select_person__') {
                    if (!isset($task_assignments[$id_new])) {
                        $task_people_new[] = $id_new;
                    }
                }
                $change = true;
            }
            ### category ###
            $v = get('task_category');
            if (!is_null($v) && $v != '__dont_change__' && $v != $task->category) {
                $task->category = $v;
                $change = true;
            }
            ### status ###
            $status = get('task_status');
            if ($status && $status != '__dont_change__' && $status != $task->status) {
                $task->status = $status;
                $change = true;
            }
            ### prio ###
            $prio = get('task_prio');
            if ($prio && $prio != '__dont_change__' && $prio != $task->prio) {
                $task->prio = $prio;
                $change = true;
            }
            ### pub level ###
            $pub_level = get('task_pub_level');
            if ($pub_level && $pub_level != '__dont_change__' && $pub_level != $task->pub_level) {
                if ($pub_level > $task->getValidUserSetPublicLevel()) {
                    $PH->abortWarning('invalid data', ERROR_RIGHTS);
                }
                $task->pub_level = $pub_level;
                $change = true;
            }
            ### label ###
            $label = get('task_label');
            if ($label && $label != '__dont_change__' && $label != $task->label) {
                $task->label = $label;
                $change = true;
            }
            ### for milestone ###
            $fm = get('task_for_milestone');
            if (!is_null($fm) && $fm != '__dont_change__' && $task->for_milestone != $fm) {
                if ($fm) {
                    if (($m = Task::getVisibleById($fm)) && $m->isMilestoneOrVersion()) {
                        $task->for_milestone = $fm;
                        $change = true;
                    } else {
                        continue;
                    }
                } else {
                    $task->for_milestone = 0;
                    $change = true;
                }
            }
            ### resolve version ###
            $rv = get('task_resolved_version');
            if (!is_null($rv) && $rv != '__dont_change__' && $task->resolved_version != $rv) {
                if ($rv && $rv != -1) {
                    if ($v = Task::getVisibleById($rv)) {
                        if ($v->isMilestoneOrVersion()) {
                            $task->resolved_version = $rv;
                            $change = true;
                        }
                    } else {
                        continue;
                    }
                } else {
                    if ($rv == -1) {
                        $task->resolved_version = $rv;
                        $change = true;
                    } else {
                        $task->resolved_version = 0;
                        $change = true;
                    }
                }
            }
            ### resolve reason ###
            $rs = get('task_resolve_reason');
            if ($rs && $rs != '__dont_change__' && $rs != $rs->resolve_reason) {
                $task->resolve_reason = $rs;
                $change = true;
            }
            if ($change) {
                ### Check if now longer new ###
                if ($status_old == $task->status && $task->status == STATUS_NEW) {
                    global $auth;
                    if ($task->created < $auth->cur_user->last_login) {
                        $task->status = STATUS_OPEN;
                    }
                }
                ## overwrite assigend people ##
                if (isset($task_people_overwrite)) {
                    if (isset($task_people_delete)) {
                        foreach ($task_people_delete as $tpd) {
                            $tpd->delete();
                        }
                    }
                    foreach ($task_people_overwrite as $tpo) {
                        $task_pers_over = new TaskPerson(array('person' => $team[$tpo]->id, 'task' => $task->id, 'comment' => '', 'project' => $project->id));
                        $task_pers_over->insert();
                    }
                }
                ## add new person ##
                if (isset($task_people_new)) {
                    foreach ($task_people_new as $tpn) {
                        if (!isset($task_assigned_people[$tpn])) {
                            $task_pers_new = new TaskPerson(array('person' => $team[$tpn]->id, 'task' => $task->id, 'comment' => '', 'project' => $project->id));
                            $task_pers_new->insert();
                        }
                    }
                }
                ##update##
                $task->update();
                $task->nowChangedByUser();
            }
        } else {
            $errors++;
        }
    }
    ### compose message ###
    if ($errors) {
        new FeedbackWarning(sprintf(__('%s tasks could not be written'), $errors));
    } else {
        if ($count) {
            new FeedbackMessage(sprintf(__('Updated %s tasks tasks'), $count));
        }
    }
    ### return to from-page? ###
    if (!$PH->showFromPage()) {
        $PH->show('taskView', array('tsk' => $task->id));
    }
}
Example #20
0
/**
* view details of a version @ingroup pages
*/
function versionView()
{
    global $PH;
    global $auth;
    require_once "render/render_wiki.inc.php";
    ### get task ####
    if (!($version = Version::getVisibleById(get('version')))) {
        $PH->abortWarning("invalid version-id", ERROR_FATAL);
    }
    if (!($project = Project::getVisibleById($version->project))) {
        $PH->abortWarning("invalid project-id", ERROR_FATAL);
    }
    ### create from handle ###
    $from_handle = $PH->defineFromHandle(array('version' => $version->id));
    ## is viewed by user ##
    $version->isViewedByUser($auth->cur_user);
    $page = new Page();
    $page->cur_tab = 'projects';
    $page->cur_crumb = 'projViewTasks';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $type = __('Version', 'page type');
    if ($task) {
        $folder = $task->getFolderLinks() . "<em>&gt;</em>" . $task->getLink();
        $page->type = $folder . " > " . $type;
    } else {
        $page->type = $type;
    }
    $page->title = $version->name;
    $page->title_minor = "";
    if ($version->state == -1) {
        $page->title_minor = sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($version->deleted));
    }
    ### page functions ###
    $page->add_function(new PageFunction(array('target' => 'versionEdit', 'params' => array('version' => $version->id), 'icon' => 'edit', 'tooltip' => __('Edit this version'), 'name' => __('Edit'))));
    $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $version->id));
    if (!$item || $item[0]->is_bookmark == 0) {
        $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Mark this version as bookmark'), 'name' => __('Bookmark'))));
    } else {
        $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark'))));
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Description'), 'id' => 'description', 'noshade' => true));
    $block->render_blockStart();
    $str = wikifieldAsHtml($version, 'description');
    echo "<div class=text>";
    echo "{$str}";
    echo "</div>";
    $block->render_blockEnd();
    echo '<input type="hidden" name="prj" value="' . $version->project . '">';
    /**
     * give parameter for create of new items (subtasks, efforts, etc)
     */
    #echo '<input type="hidden" name="parent_task" value="'.$task->id.'">';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Example #21
0
 /**
  * renders the location of the file as a html string with links to project and parent tasks
  *
  */
 public function renderLocation($project = NULL, $show_project = true)
 {
     if (is_null($project)) {
         if (!($project = Project::getVisibleById($this->project))) {
             trigger_error("file without visible project?", E_USER_NOTICE);
             $show_project = false;
         }
     }
     $html = __('in');
     if ($show_project) {
         $html .= " <b>" . $project->getLink() . " </b>";
     }
     if ($this->parent_item) {
         if ($task = Task::getVisibleById($this->parent_item)) {
             if ($folders = $task->getFolderLinks()) {
                 $html .= ' &gt; ' . $folders;
             }
             $html .= ' &gt; ' . $task->getLink(false);
         }
     }
     return $html;
 }
Example #22
0
 function render_tr(&$item, $style = "")
 {
     global $PH;
     $str_url = "";
     $str_name = "";
     $str_addon = "";
     $isDone = "";
     $html_details = "";
     $link = "";
     if ($type = $item->type) {
         switch ($type) {
             case ITEM_TASK:
                 require_once "db/class_task.inc.php";
                 if ($task = Task::getVisibleById($item->id)) {
                     $str_name = asHtml($task->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $task->id));
                     if ($task->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($task->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                         if ($tmp = $task->getFolderLinks()) {
                             $html_details .= ' > ' . $tmp;
                         }
                     }
                 }
                 break;
             case ITEM_COMMENT:
                 require_once "db/class_comment.inc.php";
                 if ($comment = Comment::getVisibleById($item->id)) {
                     $str_name = asHtml($comment->name);
                     if ($comment->comment) {
                         $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                         $str_addon = __("(on comment)");
                     } else {
                         if ($comment->task) {
                             $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                             $str_addon = __("(on task)");
                         } else {
                             $str_url = $PH->getUrl('projView', array('prj' => $comment->project));
                             $str_addon = __("(on project)");
                         }
                     }
                 }
                 break;
             case ITEM_PERSON:
                 require_once "db/class_person.inc.php";
                 if ($person = Person::getVisibleById($item->id)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 break;
             case ITEM_EFFORT:
                 require_once "db/class_effort.inc.php";
                 if ($e = Effort::getVisibleById($item->id)) {
                     $str_name = asHtml($e->name);
                     $str_url = $PH->getUrl('effortEdit', array('effort' => $e->id));
                 }
                 if ($prj = Project::getVisibleById($e->project)) {
                     $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                     $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                 }
                 break;
             case ITEM_FILE:
                 require_once "db/class_file.inc.php";
                 if ($f = File::getVisibleById($item->id)) {
                     $str_name = asHtml($f->org_filename);
                     $str_url = $PH->getUrl('fileView', array('file' => $f->id));
                     if ($f->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($f->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                     }
                 }
                 break;
             case ITEM_PROJECT:
                 require_once "db/class_project.inc.php";
                 if ($prj = Project::getVisibleById($item->id)) {
                     $str_name = asHtml($prj->name);
                     $str_url = $PH->getUrl('projView', array('prj' => $prj->id));
                     if ($prj->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                 }
                 break;
             case ITEM_COMPANY:
                 require_once "db/class_company.inc.php";
                 if ($c = Company::getVisibleById($item->id)) {
                     $str_name = asHtml($c->name);
                     $str_url = $PH->getUrl('companyView', array('company' => $c->id));
                 }
                 break;
             case ITEM_VERSION:
                 require_once "db/class_task.inc.php";
                 if ($tsk = Task::getVisibleById($item->id)) {
                     $str_name = asHtml($tsk->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $tsk->id));
                     if ($tsk->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($task->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                     }
                 }
                 break;
             default:
                 break;
         }
         print "<td class='nowrap'><span {$isDone}><a href='{$str_url}'>{$str_name}</a> {$str_addon}</span>";
         if ($html_details) {
             print "<br><span class='sub who'>{$html_details}</span>";
         }
         print "</td>";
     } else {
         $PH->abortWarning("Could not get type of the element.", ERROR_BUG);
         print "<td>&nbsp;</td>";
     }
 }
Example #23
0
/**
* Submit changes to a person @ingroup pages
*/
function personEditSubmit()
{
    global $PH;
    global $auth;
    global $g_user_profile_names;
    global $g_user_profiles;
    ### cancel ? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home', array());
        }
        exit;
    }
    ### Validate form integrity
    if (!validateFormCrc()) {
        $PH->abortWarning(__('Invalid checksum for hidden form elements'));
    }
    ### get person ####
    $id = getOnePassedId('person');
    ### temporary obj, not in db
    if ($id == 0) {
        $person = new Person(array('id' => 0));
    } else {
        if (!($person = Person::getEditableById($id))) {
            $PH->abortWarning(__("Could not get person"));
            return;
        }
    }
    ### person category ###
    $pcategory = get('pcategory');
    if ($pcategory != NULL) {
        if ($pcategory == -1) {
            $person->category = PCATEGORY_STAFF;
        } else {
            if ($pcategory == -2) {
                $person->category = PCATEGORY_CONTACT;
            } else {
                $person->category = $pcategory;
            }
        }
    }
    ### validate rights ###
    if ($auth->cur_user->id == $person->id && $auth->cur_user->user_rights & RIGHT_PERSON_EDIT_SELF || $auth->cur_user->user_rights & RIGHT_PERSON_EDIT || $auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $person->id == 0) {
        $pass = true;
    } else {
        $PH->abortWarning(__("not allowed to edit"), ERROR_RIGHTS);
    }
    $flag_ok = true;
    # update valid?
    # retrieve all possible values from post-data
    # NOTE:
    # - this could be an security-issue.
    # - TODO: as some kind of form-edit-behaviour to field-definition
    foreach ($person->fields as $f) {
        $name = $f->name;
        $f->parseForm($person);
    }
    ### rights & theme & profile ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT_RIGHTS) {
        /**
         * if profile != -1, it will OVERWRITE (or reinit) user_rights
         *
         * therefore persEdit set profil to 0 if rights don't fit profile. It will
         * then be skipped here
         */
        $profile_num = get('person_profile');
        if (!is_null($profile_num)) {
            if ($profile_num != -1) {
                $person->profile = $profile_num;
                if (isset($g_user_profiles[$profile_num]['default_user_rights'])) {
                    $rights = $g_user_profiles[$profile_num]['default_user_rights'];
                    /**
                     * add warning on changed profile
                     */
                    if ($person->user_rights != $rights && $person->id) {
                        new FeedbackHint(__('The changed profile <b>does not affect existing project roles</b>! Those has to be adjusted inside the projects.'));
                    }
                    $person->user_rights = $rights;
                } else {
                    trigger_error("Undefined profile requested ({$profile_num})", E_USER_ERROR);
                }
            }
        }
    }
    ### can login ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT_RIGHTS || $auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $auth->cur_user->user_rights & RIGHT_PROJECT_ASSIGN && $person->id == 0) {
        /**
         * NOTE, if checkbox is not rendered in editForm, user-account will be disabled!
         * there seems no way the be sure the checkbox has been rendered, if it is not checked in form
         */
        if ($can_login = get('person_can_login')) {
            $person->can_login = 1;
        } else {
            $person->can_login = 0;
        }
    }
    $period = get('person_notification_period');
    ### turn off ###
    if ($period === 0 || $period === "0") {
        $person->settings &= USER_SETTING_NOTIFICATIONS ^ RIGHT_ALL;
        $person->notification_period = 0;
    } else {
        $person->settings |= USER_SETTING_NOTIFICATIONS;
        $person->notification_period = $period;
        if ($person->can_login && !$person->personal_email && !$person->office_email) {
            $flag_ok = false;
            $person->fields['office_email']->required = true;
            $person->fields['personal_email']->required = true;
            new FeedbackWarning(__("Sending notifactions requires an email-address."));
        }
    }
    if (get('person_html_mail')) {
        $person->settings |= USER_SETTING_HTML_MAIL;
    } else {
        $person->settings &= USER_SETTING_HTML_MAIL ^ RIGHT_ALL;
    }
    ### effort style ###
    if ($effort_style = get('person_effort_style')) {
        if ($effort_style == EFFORT_STYLE_TIMES) {
            $person->settings &= USER_SETTING_EFFORTS_AS_DURATION ^ RIGHT_ALL;
        } else {
            if ($effort_style == EFFORT_STYLE_DURATION) {
                $person->settings |= USER_SETTING_EFFORTS_AS_DURATION;
            } else {
                trigger_error("undefined person effort style", E_USER_WARNING);
            }
        }
    }
    ### filter own changes ###
    if (get('person_filter_own_changes')) {
        $person->settings |= USER_SETTING_FILTER_OWN_CHANGES;
    } else {
        $person->settings &= USER_SETTING_FILTER_OWN_CHANGES ^ RIGHT_ALL;
    }
    ### enable bookmarks ###
    if (get('person_enable_bookmarks')) {
        $person->settings |= USER_SETTING_ENABLE_BOOKMARKS;
    } else {
        $person->settings &= USER_SETTING_ENABLE_BOOKMARKS ^ RIGHT_ALL;
    }
    if (get('person_enable_efforts')) {
        $person->settings |= USER_SETTING_ENABLE_EFFORTS;
    } else {
        $person->settings &= USER_SETTING_ENABLE_EFFORTS ^ RIGHT_ALL;
    }
    $zone = get('person_time_zone');
    if ($zone != NULL && $person->time_zone != 1.0 * $zone) {
        $person->time_zone = 1.0 * $zone;
        if ($zone == TIME_OFFSET_AUTO) {
            new FeedbackMessage(__("Using auto detection of time zone requires this user to relogin."));
        } else {
            $person->time_offset = $zone * 60.0 * 60.0;
            if ($person->id == $auth->cur_user->id) {
                $auth->cur_user->time_offset = $zone * 60.0 * 60.0;
            }
        }
    }
    $theme = get('person_theme');
    if ($theme != NULL) {
        $person->theme = $theme;
        ### update immediately / without page-reload ####
        if ($person->id == $auth->cur_user->id) {
            $auth->cur_user->theme = $theme;
        }
    }
    $language = get('person_language');
    global $g_languages;
    if (isset($g_languages[$language])) {
        $person->language = $language;
        ### update immediately / without page-reload ####
        if ($person->id == $auth->cur_user->id) {
            $auth->cur_user->language = $language;
            setLang($language);
        }
    }
    $t_nickname = get('person_nickname');
    ### check if changed nickname is unique
    if ($person->can_login || $person->nickname != "") {
        /**
         * actually this should be mb_strtolower, but this is not installed by default
         */
        if ($person->nickname != strtolower($person->nickname)) {
            new FeedbackMessage(__("Nickname has been converted to lowercase"));
            $person->nickname = strtolower($person->nickname);
        }
        ### authentication ###
        $p_auth = get('person_auth');
        if ($p_auth) {
            $person->ldap = 1;
        } else {
            $person->ldap = 0;
        }
        if ($p2 = Person::getByNickname($t_nickname)) {
            # another person with this nick?
            if ($p2->id != $person->id) {
                new FeedbackWarning(__("Nickname has to be unique"));
                $person->fields['nickname']->required = true;
                $flag_ok = false;
            }
        }
    }
    ### password entered? ###
    $t_password1 = get('person_password1');
    $t_password2 = get('person_password2');
    $flag_password_ok = true;
    if (($t_password1 || $t_password2) && $t_password1 != "__dont_change__") {
        ### check if password match ###
        if ($t_password1 !== $t_password2) {
            new FeedbackWarning(__("Passwords do not match"));
            $person->fields['password']->required = true;
            $flag_ok = false;
            $flag_password_ok = false;
        }
        ### check if password is good enough ###
        if ($person->can_login) {
            $password_length = strlen($t_password1);
            $password_count_numbers = strlen(preg_replace('/[\\d]/', '', $t_password1));
            $password_count_special = strlen(preg_replace('/[\\w]/', '', $t_password1));
            $password_value = -7 + $password_length + $password_count_numbers * 2 + $password_count_special * 8;
            if ($password_value < confGet('CHECK_PASSWORD_LEVEL')) {
                new FeedbackWarning(__("Password is too weak (please add numbers, special chars or length)"));
                $flag_ok = false;
                $flag_password_ok = false;
            }
        }
        if ($flag_password_ok) {
            $person->password = md5($t_password1);
        }
    }
    if ($flag_ok && $person->can_login) {
        if (!$person->nickname) {
            new FeedbackWarning(__("Login-accounts require a unique nickname"));
            $person->fields['nickname']->required = true;
            $person->fields['nickname']->invalid = true;
            $flag_ok = false;
        }
    }
    ### repeat form if invalid data ###
    if (!$flag_ok) {
        $PH->show('personEdit', NULL, $person);
        exit;
    }
    /**
     * store indentifier-string for login from notification & reminder - mails
     */
    $person->identifier = $person->calcIdentifierString();
    ### insert new object ###
    if ($person->id == 0) {
        if ($person->settings & USER_SETTING_NOTIFICATIONS && $person->can_login) {
            $person->settings |= USER_SETTING_SEND_ACTIVATION;
            new FeedbackHint(sprintf(__("A notification / activation  will be mailed to <b>%s</b> when you log out."), $person->name) . " " . sprintf(__("Read more about %s."), $PH->getWikiLink('notifications')));
        }
        $person->notification_last = getGMTString(time() - $person->notification_period * 60 * 60 * 24 - 1);
        $person->cookie_string = $person->calcCookieString();
        if ($person->insert()) {
            ### link to a company ###
            if ($c_id = get('company')) {
                require_once confGet('DIR_STREBER') . 'db/class_company.inc.php';
                if ($c = Company::getVisibleById($c_id)) {
                    require_once confGet('DIR_STREBER') . 'db/class_employment.inc.php';
                    $e = new Employment(array('id' => 0, 'person' => $person->id, 'company' => $c->id));
                    $e->insert();
                }
            }
            ## assigne to project ##
            require_once confGet('DIR_STREBER') . 'db/class_projectperson.inc.php';
            $prj_num = get('assigned_prj');
            if (isset($prj_num)) {
                if ($prj_num != -1) {
                    if ($p = Project::getVisibleById($prj_num)) {
                        $prj_person = new ProjectPerson(array('person' => $person->id, 'project' => $p->id, 'name' => $g_user_profile_names[$person->profile]));
                        $prj_person->insert();
                    }
                }
            }
            new FeedbackMessage(sprintf(__('Person %s created'), $person->getLink()));
        } else {
            new FeedbackError(__("Could not insert object"));
        }
    } else {
        new FeedbackMessage(sprintf(__('Updated settings for %s.'), $person->getLink()));
        $person->update();
    }
    if ($auth->cur_user->id == $person->id) {
        $auth->cur_user = $person;
    }
    ### notify on change ###
    $person->nowChangedByUser();
    ### store cookie, if accountActivation ###
    if (get('tuid')) {
        $auth->removeUserCookie();
        $auth->storeUserCookie();
    }
    ### create another person ###
    if (get('create_another')) {
        if ($c_id = get('company')) {
            $PH->show('personNew', array('company' => $c_id));
        } else {
            $PH->show('personNew');
        }
    } else {
        ### display fromPage ####
        if (!$PH->showFromPage()) {
            $PH->show('home', array());
        }
    }
}
/**
* export selected efforts as a CSV ready for copy and paste into a spread-sheet  @ingroup pages
**
*/
function effortShowAsCSV()
{
    global $PH;
    global $g_effort_status_names;
    $effort_ids = getPassedIds('effort', 'efforts_*');
    if (!$effort_ids) {
        $PH->abortWarning(__("Select some efforts(s) to show"));
        exit;
    }
    $efforts = array();
    $different_fields = array();
    $edit_fields = array('status', 'pub_level', 'task');
    foreach ($effort_ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $efforts[] = $effort;
            ### check project for first task
            if (count($efforts) == 1) {
                ### make sure all are of same project ###
                if (!($project = Project::getVisibleById($effort->project))) {
                    $PH->abortWarning('could not get project');
                }
            } else {
                if ($effort->project != $efforts[0]->project) {
                    $PH->abortWarning(__("For editing all efforts must be of same project."));
                }
                foreach ($edit_fields as $field_name) {
                    if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
                        $different_fields[$field_name] = true;
                    }
                }
            }
        }
    }
    $page = new Page(array('use_jscalendar' => true));
    $page->cur_tab = 'projects';
    $page->options[] = new naviOption(array('target_id' => 'effortEdit'));
    $page->type = __("Edit multiple efforts", "Page title");
    $page->title = sprintf(__("%s efforts for copy and pasting into a spread-sheet", "Page title"), count($efforts));
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
    $block->render_blockStart();
    $format = "[Date][Weekday][Task][Comment][Duration]";
    preg_match_all("/\\[(.*?)\\]/", $format, $matches);
    $overallDuration = 0;
    echo "<textarea style='width:96%; height:300px;'>";
    echo join("\t", $matches[1]) . "\n";
    foreach ($efforts as $e) {
        preg_match_all("/\\[(.*?)\\]/", $format, $matches);
        $separator = "";
        foreach ($matches[1] as $matchedFormat) {
            echo $separator;
            switch ($matchedFormat) {
                case "Date":
                    echo gmstrftime("%Y-%m-%d", strToGMTime($e->time_start));
                    break;
                case "Weekday":
                    echo gmstrftime("%a", strToGMTime($e->time_start));
                    break;
                case "Task":
                    if ($t = Task::getVisibleById($e->task)) {
                        echo $t->name;
                    }
                    break;
                case "Comment":
                    echo $e->name;
                    break;
                case "Duration":
                    $durationInMinutes = round((strToGMTime($e->time_end) - strToGMTime($e->time_start)) / 60, 0);
                    $roundUpTo15 = ceil($durationInMinutes / 15) * 15 / 60;
                    $overallDuration += $roundUpTo15;
                    echo number_format($roundUpTo15, 2, $dec_point = ',', '');
                    break;
            }
            $separator = "\t";
        }
        echo "\n";
    }
    echo "</textarea>";
    echo "<br>";
    echo __("Overall Duration:") . $overallDuration . "h";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
    exit;
}
Example #25
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     if (!isset($obj) || !$obj instanceof Comment) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     global $auth;
     if ($obj->created_by == $auth->cur_user->id) {
         $column_text = '<td class="comment_text by_cur_user">';
     } else {
         $column_text = "<td class=comment_text>";
     }
     $column_text .= "<div class=comment_block style='padding-left:" . $obj->level * 2.0 . "em'>";
     if ($obj->view_collapsed) {
         $column_text .= $PH->getLink('commentToggleViewCollapsed', "<img src=\"" . getThemeFile("img/toggle_folder_closed.gif") . "\">", array('comment' => $obj->id), NULL, true);
         $column_text .= "<span class=title>" . $PH->getLink('commentView', $obj->name, array('comment' => $obj->id)) . "</span>";
         if ($obj->num_children) {
             $column_text .= "<span class=children> (";
             if ($obj->num_children == 1) {
                 $column_text .= __("1 sub comment");
             } else {
                 $column_text .= printf(__("%s sub comments"), $obj->num_children);
             }
             $column_text .= ")</span>";
         }
     } else {
         $column_text .= $PH->getLink('commentToggleViewCollapsed', "<img src=\"" . getThemeFile("img/toggle_folder_open.gif") . "\">", array('comment' => $obj->id), NULL, true);
         $column_text .= "<span class=title>" . $PH->getLink('commentView', $obj->name, array('comment' => $obj->id)) . "</span>";
         require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
         $project = Project::getVisibleById($obj->project);
         $obj->nowViewedByUser();
         ### editable? ###
         $editable = false;
         if ($obj->created_by == $auth->cur_user->id) {
             #if($pp= $obj->getProjectPerson()) {
             #    if($pp->level_edit < $obj->pub_level) {
             $editable = true;
             #   }
             #}
         }
         $diz = wikifieldAsHtml($obj, 'description');
         if ($diz) {
             $column_text .= "<div class=comment_text>{$diz}</div>";
         }
     }
     $column_text .= "</div>";
     $column_text .= "</td>";
     print $column_text;
 }
Example #26
0
 static function getForQuery($search_query, $project = NULL)
 {
     $count_overall = 0;
     $results = array();
     global $PH;
     require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
     $args = array('order_str' => NULL, 'has_id' => NULL, 'search' => $search_query);
     foreach ($companies = Company::getAll($args) as $company) {
         $rate = RATE_TYPE_COMPANY;
         $rate *= SearchResult::RateItem($company);
         $rate *= SearchResult::RateTitle($company, $search_query);
         $results[] = new SearchResult(array('name' => $company->name, 'rating' => $rate, 'type' => __('Company'), 'jump_id' => 'companyView', 'jump_params' => array('company' => $company->id, 'q' => $search_query), 'item' => $company));
     }
     require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
     foreach ($people = Person::getPeople(array('search' => $search_query)) as $person) {
         $rate = RATE_TYPE_PERSON;
         $rate *= SearchResult::RateItem($person);
         $rate *= SearchResult::RateTitle($person, $search_query);
         $results[] = new SearchResult(array('name' => $person->name, 'rating' => $rate, 'type' => __('Person'), 'jump_id' => 'personView', 'jump_params' => array('person' => $person->id, 'q' => $search_query), 'item' => $person));
     }
     require_once confGet('DIR_STREBER') . "db/class_project.inc.php";
     $projects = Project::getAll(array('status_min' => 0, 'status_max' => 10, 'search' => $search_query));
     if ($projects) {
         foreach ($projects as $project) {
             $rate = RATE_TYPE_PROJECT;
             if ($project->status == STATUS_TEMPLATE) {
                 $rate *= RATE_PROJECT_IS_TEMPLATE;
             } else {
                 if ($project->status < STATUS_COMPLETED) {
                     $rate *= RATE_PROJECT_IS_OPEN;
                 } else {
                     $rate *= RATE_PROJECT_IS_CLOSED;
                 }
             }
             if ($diz = SearchResult::getExtract($project, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             ### status ###
             global $g_status_names;
             $status = isset($g_status_names[$project->status]) ? $g_status_names[$project->status] : '';
             if ($project->status > STATUS_COMPLETED) {
                 $rate *= RATE_TASK_STATUS_CLOSED;
             } else {
                 if ($project->status >= STATUS_COMPLETED) {
                     $rate *= RATE_TASK_STATUS_COMPLETED;
                 }
             }
             ### for company ###
             $html_location = '';
             if ($company = Company::getVisibleById($project->company)) {
                 $html_location = __('for') . ' ' . $company->getLink();
             }
             $rate *= SearchResult::RateItem($project);
             $rate *= SearchResult::RateTitle($project, $search_query);
             $results[] = new SearchResult(array('name' => $project->name, 'rating' => $rate, 'item' => $project, 'type' => __('Project'), 'jump_id' => 'projView', 'jump_params' => array('prj' => $project->id, 'q' => $search_query), 'extract' => $diz, 'status' => $status, 'html_location' => $html_location));
         }
     }
     require_once confGet('DIR_STREBER') . "db/class_task.inc.php";
     $order_str = get('sort_' . $PH->cur_page->id . "_tasks");
     $tasks = Task::getAll(array('order_by' => $order_str, 'search' => $search_query, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED));
     if ($tasks) {
         foreach ($tasks as $task) {
             $rate = RATE_TYPE_TASK;
             $rate *= SearchResult::RateItem($task);
             $rate *= SearchResult::RateTitle($task, $search_query);
             if ($task->category == TCATEGORY_FOLDER) {
                 $rate *= RATE_TASK_IS_FOLDER;
             }
             if ($diz = SearchResult::getExtract($task, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             global $g_status_names;
             $status = isset($g_status_names[$task->status]) ? $g_status_names[$task->status] : '';
             if ($task->status > STATUS_COMPLETED) {
                 $rate *= RATE_TASK_STATUS_CLOSED;
             } else {
                 if ($task->status >= STATUS_COMPLETED) {
                     $rate *= RATE_TASK_STATUS_COMPLETED;
                 }
             }
             if ($project = Project::getVisibleById($task->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('in') . " <b>{$prj}</b> &gt; " . $task->getFolderLinks();
             $is_done = $task->status < STATUS_COMPLETED ? false : true;
             $results[] = new SearchResult(array('name' => $task->name, 'rating' => $rate, 'extract' => $diz, 'item' => $task, 'type' => $task->getLabel(), 'status' => $status, 'html_location' => $html_location, 'is_done' => $is_done, 'jump_id' => 'taskView', 'jump_params' => array('tsk' => $task->id, 'q' => $search_query)));
         }
     }
     require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
     $comments = Comment::getAll(array('search' => $search_query));
     if ($comments) {
         foreach ($comments as $comment) {
             $rate = RATE_TYPE_COMMENT;
             $rate *= SearchResult::RateItem($comment);
             $rate *= SearchResult::RateTitle($comment, $search_query);
             if ($diz = SearchResult::getExtract($comment, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             if ($project = Project::getVisibleById($comment->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('on') . " <b>{$prj}</b>";
             $is_done = false;
             if ($task = Task::getVisibleById($comment->task)) {
                 if ($folders = $task->getFolderLinks()) {
                     $html_location .= ' &gt; ' . $folders;
                 }
                 $html_location .= ' &gt; ' . $task->getLink(false);
                 if ($task->status >= STATUS_COMPLETED) {
                     $is_done = true;
                 }
             } else {
                 $html_location = '';
             }
             $results[] = new SearchResult(array('name' => $comment->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Comment'), 'html_location' => $html_location, 'jump_id' => 'commentView', 'jump_params' => array('comment' => $comment->id, 'q' => $search_query), 'item' => $comment, 'is_done' => $is_done));
         }
     }
     $count_overall += count($comments);
     require_once confGet('DIR_STREBER') . "db/class_effort.inc.php";
     $efforts = Effort::getAll(array('search' => $search_query));
     if ($efforts) {
         foreach ($efforts as $effort) {
             $rate = RATE_TYPE_EFFORT;
             $rate *= SearchResult::RateItem($effort);
             $rate *= SearchResult::RateTitle($effort, $search_query);
             if ($diz = SearchResult::getExtract($effort, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             if ($project = Project::getVisibleById($effort->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('on') . " <b>{$prj}</b>";
             $is_done = false;
             if ($task = Task::getVisibleById($effort->task)) {
                 if ($folders = $task->getFolderLinks()) {
                     $html_location .= ' &gt; ' . $folders;
                 }
                 $html_location .= ' &gt; ' . $task->getLink(false);
                 if ($task->status >= STATUS_COMPLETED) {
                     $is_done = true;
                 }
             } else {
                 $html_location = '';
             }
             $results[] = new SearchResult(array('name' => $effort->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Effort'), 'html_location' => $html_location, 'jump_id' => 'effortView', 'jump_params' => array('effort' => $effort->id, 'q' => $search_query), 'item' => $effort, 'is_done' => $is_done));
         }
     }
     $count_overall += count($efforts);
     return $results;
 }
Example #27
0
/**
* move comments to folder...
*/
function commentsMoveToFolder()
{
    global $PH;
    $comment_ids = getPassedIds('comment', 'comments_*');
    if (!$comment_ids) {
        $PH->abortWarning(__("Select some comments to move"));
        return;
    }
    /**
     * if folder was given, directly move tasks...
     */
    $target_id = -1;
    # target is unknown
    $folder_ids = getPassedIds('folder', 'folders_*');
    if (count($folder_ids) == 1) {
        if ($folder_task = Task::getVisibleById($folder_ids[0])) {
            $target_id = $folder_task->id;
        }
    } else {
        if (get('from_selection')) {
            $target_id = 0;
            # to ungrout to root?
        }
    }
    if ($target_id != -1) {
        if ($target_id != 0) {
            if (!($target_task = Task::getEditableById($target_id))) {
                $PH->abortWarning(__("insufficient rights"));
            }
        }
        $count = 0;
        foreach ($comment_ids as $id) {
            if ($comment = Comment::getEditableById($id)) {
                $comment->task = $target_id;
                /**
                 * @@@ do we have to reset ->comment as well?
                 *
                 * this splits discussions into separate comments...
                 */
                $comment->comment = 0;
                $comment->update();
            } else {
                new FeedbackWarning(sprintf(__("Can not edit comment %s"), asHtml($comment->name)));
            }
        }
        ### return to from-page? ###
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    /**
     * build page folder list to select target...
     */
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    ### get project ####
    if (!($comment = Comment::getVisibleById($comment_ids[0]))) {
        $PH->abortWarning("could not get comment", ERROR_BUG);
    }
    if (!($project = Project::getVisibleById($comment->project))) {
        $PH->abortWarning("task without project?", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'company_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit tasks");
    $page->title = $project->name;
    $page->title_minor = __("Select one folder to move comments into");
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'commentsMoveToFolder'));
    echo new PageHeader();
    echo new PageContentOpen();
    echo __("... or select nothing to move to project root");
    ### write selected comments as hidden fields ###
    foreach ($comment_ids as $id) {
        if ($comment = Comment::getEditableById($id)) {
            echo "<input type=hidden name='comments_{$id}_chk' value='1'>";
        }
    }
    $list = new ListBlock_tasks();
    $list->reduced_header = true;
    $list->query_options['show_folders'] = true;
    $list->query_options['folders_only'] = true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    unset($list->columns['project']);
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    $list->no_items_html = __("No folders in this project...");
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project);
    echo "<input type=hidden name='from_selection' value='1'>";
    # keep flag to ungroup comments
    echo "<input type=hidden name='project' value='{$project->id}'>";
    $button_name = __("Move items");
    echo "<input class=button2 type=submit value='{$button_name}'>";
    $PH->go_submit = 'commentsMoveToFolder';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
 static function getChangeLines($query_options)
 {
     global $PH;
     global $auth;
     fillMissingValues($query_options, array('alive_only' => false));
     $date_compare = isset($query_options['date_min']) ? $query_options['date_min'] : "0000-00-00";
     /**
      * get list of items touched by other people
      */
     $changed_items = DbProjectItem::getAll($query_options);
     /**
      * go through list
      */
     $changes = array();
     foreach ($changed_items as $i) {
         $change_type = NULL;
         if (!isset($query_options['project'])) {
             $project = Project::getVisibleById($i->project);
         } else {
             $project = NULL;
         }
         /**
          * get item-change-type depeding on dates
          */
         if ($i->deleted >= $i->modified) {
             $change_type = ITEM_DELETED;
         } else {
             if ($i->modified > $i->created) {
                 $change_type = ITEM_MODIFIED;
             } else {
                 $change_type = ITEM_NEW;
             }
         }
         /**
          * build up change-list
          */
         switch ($change_type) {
             case ITEM_NEW:
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     if ($task->prio != PRIO_NORMAL && $task->prio != PRIO_UNDEFINED) {
                         global $g_prio_names;
                         $html_details .= ' / ' . $g_prio_names[$task->prio];
                     }
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => '<span class=new>' . __('new') . ' ' . $task->getLabel() . '</span>', 'txt_what' => __('new') . ' ' . $task->getLabel(), 'type' => ChangeLine::NEW_TASK, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('New file'), 'txt_what' => __('New file'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_MODIFIED:
                 $timestamp_last_change = $date_compare;
                 # make sure we use the last occured change type
                 /**
                  * modified tasks
                  */
                 $type = ChangeLine::UPDATED;
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $txt_what = $html_what = __('modified');
                     $type = ChangeLine::UPDATED;
                     $html_comment = '';
                     if ($comments = Comment::getAll(array('person' => $i->modified_by, 'task' => $task->id, 'date_min' => $timestamp_last_change, 'order_by' => 'created ASC'))) {
                         $last_comment = $comments[count($comments) - 1];
                         $timestamp_last_change = $last_comment->created;
                         if ($last_comment->name && $last_comment->name != __('New Comment')) {
                             # ignore default title
                             $html_comment = strip_tags($last_comment->name) . ': ';
                         }
                         $html_comment .= strip_tags($last_comment->description);
                         $html_comment = asHtml($html_comment);
                     }
                     ### get changed fields ###
                     $changed_fields_hash = array();
                     $html_functions = false;
                     if ($changed_fields_list = ItemChange::getItemChanges(array('item' => $i->id, 'person' => $i->modified_by, 'date_min' => $date_compare))) {
                         foreach ($changed_fields_list as $cf) {
                             $changed_fields_hash[$cf->field] = $cf;
                         }
                         if (isset($changed_fields_hash['status'])) {
                             $status_old = $changed_fields_hash['status']->value_old;
                             if ($task->status == STATUS_COMPLETED && $task->status > $status_old) {
                                 $txt_what = $html_what = __('completed') . ' ' . $task->getLabel();
                                 $html_functions = $PH->getLink('tasksApproved', __('Approve Task'), array('tsk' => $task->id));
                                 unset($changed_fields_hash['status']);
                             } else {
                                 if ($task->status == STATUS_APPROVED && $task->status > $status_old) {
                                     $txt_what = $html_what = __('approved');
                                     unset($changed_fields_hash['status']);
                                 } else {
                                     if ($task->status == STATUS_CLOSED && $task->status > $status_old) {
                                         $txt_what = $html_what = __('closed');
                                         unset($changed_fields_hash['status']);
                                     } else {
                                         if ($task->status == STATUS_OPEN && $task->status < $status_old) {
                                             $txt_what = $html_what = __('reopened');
                                             unset($changed_fields_hash['status']);
                                         } else {
                                             if ($task->status == STATUS_OPEN) {
                                                 unset($changed_fields_hash['status']);
                                             } else {
                                                 if ($task->status == STATUS_BLOCKED) {
                                                     $txt_what = $html_what = __('is blocked');
                                                     unset($changed_fields_hash['status']);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (isset($changed_fields_hash['parent_task'])) {
                         $txt_what = $html_what = __('moved');
                         $type = ChangeLine::MOVED;
                         unset($changed_fields_hash['parent_task']);
                     } else {
                         if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['name'])) {
                             $txt_what = $html_what = __('renamed');
                             $type = ChangeLine::RENAMED;
                         } else {
                             if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['description'])) {
                                 $txt_what = $html_what = __('edit wiki');
                                 $type = ChangeLine::EDITED_WIKI;
                             } else {
                                 if (count($changed_fields_hash)) {
                                     # status does not count
                                     $html_details .= ' / ' . __('changed:') . ' ' . implode(', ', array_keys($changed_fields_hash));
                                 } else {
                                     if ($html_comment) {
                                         $txt_what = $html_what = __('commented');
                                         $type = ChangeLine::COMMENTED;
                                     }
                                 }
                             }
                         }
                     }
                     if ($html_comment) {
                         $html_details .= ' / ' . $html_comment;
                     }
                     /**
                      * any recents assignments ?
                      * - to avoid confusion only list assignmets if it was to last action,
                      *
                      */
                     require_once "db/class_taskperson.inc.php";
                     $count_assignments = 0;
                     if ($assignments = TaskPerson::getTaskPeople(array('task' => $task->id, 'project' => $task->project, 'date_min' => $task->modified))) {
                         $t_timestamp = '';
                         foreach ($assignments as $a) {
                             if ($a->person != $task->modified_by && $a->created_by == $task->modified_by && $a->assigntype != ASSIGNTYPE_INITIAL) {
                                 $t_timestamp = $a->created;
                                 $count_assignments++;
                             }
                         }
                         if ($count_assignments && $timestamp_last_change < $t_timestamp) {
                             $type = ChangeLine::ASSIGNED;
                             $txt_what = $html_what = __('assigned');
                             $timestamp_last_change = $t_timestamp;
                         }
                         if ($html_comment) {
                             $html_details .= ' / ' . $html_comment;
                         }
                     }
                     /**
                      * any recents attachments by last editor ?
                      */
                     require_once "db/class_file.inc.php";
                     if ($files = File::getAll(array('parent_item' => $task->id, 'project' => $task->project, 'date_min' => $date_compare, 'created_by' => $task->modified_by))) {
                         $count_attached_files = 0;
                         $html_attached = __("attached") . ": ";
                         $t_timestamp = '';
                         $separator = '';
                         foreach ($files as $f) {
                             if ($task->modified_by == $f->modified_by) {
                                 $t_timestamp = $f->created;
                                 $count_attached_files++;
                                 $html_attached .= $separator . $PH->getLink('fileView', $f->name, array('file' => $f->id));
                                 $separator = ', ';
                             }
                         }
                         if ($count_attached_files) {
                             $type = ChangeLine::ATTACHED_FILE;
                             $txt_what = $html_what = __('attached file to');
                             if ($timestamp_last_change < $t_timestamp) {
                                 $html_details .= ' / ' . $html_attached;
                                 $timestamp_last_change = $t_timestamp;
                             }
                         }
                     }
                     if (count($changed_fields_hash)) {
                         $html_details .= " / " . $PH->getLink('itemViewDiff', NULL, array('item' => $task->id, 'date1' => $date_compare, 'date2' => gmdate("Y-m-d H:i:s")));
                     }
                     if ($html_functions) {
                         $html_details .= " | " . $html_functions;
                     }
                     $change = new ChangeLine(array('person_by' => $i->modified_by, 'timestamp' => $i->modified, 'item_id' => $i->id, 'item' => $task, 'type' => $type, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('changed File'), 'txt_what' => __('changed File'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_DELETED:
                 /**
                  * deleted tasks
                  */
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $html_details .= '|' . $PH->getLink('itemsRestore', __('restore'), array('item' => $task->id));
                     $txt_what = $html_what = __('deleted');
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->deleted_by, 'timestamp' => $i->deleted, 'item_id' => $i->id, 'type' => ChangeLine::DELETED, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('deleted File'), 'txt_what' => ChangeLine::DELETED, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             default:
                 trigger_error("unknown change-type {$change_type}", E_USER_WARNING);
                 break;
         }
     }
     return $changes;
 }
Example #29
0
 /**
  * tries to build a valid a href-link to an item.
  *
  * - uses $this->name
  * - sets -this-html
  * - does all the neccessary security checks, styles and conversions
  */
 static function renderLinkFromItemId($target_id, $name = "")
 {
     global $PH;
     $target_id = intval($target_id);
     $html = "";
     if (!($item = DbProjectItem::getVisibleById($target_id))) {
         $html = '<em>' . sprintf(__("Unkwown item %s"), $target_id) . '</em>';
     } else {
         switch ($item->type) {
             case ITEM_TASK:
                 if ($task = Task::getVisibleById($item->id)) {
                     $style_isdone = $task->status >= STATUS_COMPLETED ? 'isDone' : '';
                     if ($name) {
                         $html = $PH->getLink('taskView', $name, array('tsk' => $task->id), $style_isdone, true);
                     } else {
                         $html = $task->getLink(false);
                     }
                 }
                 break;
             case ITEM_FILE:
                 require_once confGet('DIR_STREBER') . "db/class_file.inc.php";
                 if ($file = File::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('fileDownloadAsImage', $name, array('file' => $file->id), NULL, true);
                     } else {
                         $html = $PH->getLink('fileDownloadAsImage', $file->name, array('file' => $file->id));
                     }
                 }
                 break;
             case ITEM_COMMENT:
                 require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
                 if ($comment = Comment::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('commentView', $name, array('comment' => $comment->id), NULL, true);
                     } else {
                         $html = $PH->getLink('commentView', $comment->name, array('comment' => $comment->id));
                     }
                 }
                 break;
             case ITEM_PERSON:
                 if ($person = Person::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('personView', $name, array('person' => $person->id), NULL, true);
                     } else {
                         $html = $PH->getLink('personView', $person->name, array('person' => $person->id));
                     }
                 }
                 break;
             case ITEM_PROJECT:
                 if ($project = Project::getVisibleById($item->id)) {
                     if ($name == "") {
                         $name = asHtml($project->name);
                     }
                     $html = $PH->getLink('projView', $name, array('prj' => $project->id), NULL, true);
                 }
                 break;
             default:
                 $html = '<em>' . sprintf(__('Cannot link to item #%s of type %s'), intval($target_id), $item->type) . '</em>';
                 break;
         }
     }
     return $html;
 }
function ProjView()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "render/render_wiki.inc.php";
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    if ($project = Project::getEditableById($id)) {
        $editable = true;
    } else {
        if ($project = Project::getVisibleById($id)) {
            $editable = false;
        } else {
            $PH->abortWarning(__("invalid project-id"));
            return;
        }
    }
    ### define from-handle ###
    $PH->defineFromHandle(array('prj' => $project->id));
    ## is viewed by user ##
    $project->nowViewedByUser();
    ## next milestone ##
    $next = $project->getNextMilestone();
    $page = new Page();
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->cur_tab = 'projects';
    $page->title = $project->name;
    $page->title_minor = __("Project overview");
    if ($project->status == STATUS_TEMPLATE) {
        $page->type = __("Project Template");
    } else {
        if ($project->status >= STATUS_COMPLETED) {
            $page->type = __("Inactive Project");
        } else {
            $page->type = __("Project", "Page Type");
        }
    }
    ### page functions ###
    if ($project->isPersonVisibleTeamMember($auth->cur_user)) {
        if ($editable) {
            $page->add_function(new PageFunction(array('target' => 'projEdit', 'params' => array('prj' => $project->id), 'icon' => 'edit', 'tooltip' => __('Edit this project'), 'name' => __('Edit project'))));
        }
        /*
        $item = ItemPerson::getAll(array(
            'person'=>$auth->cur_user->id,
            'item'=>$project->id
        ));
        if((!$item) || ($item[0]->is_bookmark == 0)){
            $page->add_function(new PageFunction(array(
                'target'    =>'itemsAsBookmark',
                'params'    =>array('proj'=>$project->id),
                'tooltip'   =>__('Mark this project as bookmark'),
                'name'      =>__('Bookmark'),
            )));
        }
        else{
            $page->add_function(new PageFunction(array(
                'target'    =>'itemsRemoveBookmark',
                'params'    =>array('proj'=>$project->id),
                'tooltip'   =>__('Remove this bookmark'),
                'name'      =>__('Remove Bookmark'),
            )));
        }
        */
        /*
        if($project->state == 1) {
                $page->add_function(new PageFunction(array(
                    'target'=>'projDelete',
                    'params'=>array('prj'=>$project->id),
                    'icon'=>'delete',
                    'tooltip'=>__('Delete this project'),
                    'name'=>__('Delete')
                )));
        }
        */
        #$page->add_function(new PageFunctionGroup(array(
        #    'name'      => __('new')
        #)));
        /*
        $page->add_function(new PageFunction(array(
            'target'    =>'projAddPerson',
            'params'    =>array('prj'=>$project->id),
            'icon'      =>'add',
            'tooltip'   =>__('Add person as team-member to project'),
            'name'      =>__('Team member')
        )));
        */
        if ($project->settings & PROJECT_SETTING_ENABLE_TASKS) {
            $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('prj' => $project->id), 'icon' => 'new', 'tooltip' => __('Create task'), 'name' => __('New task'))));
        }
        if ($project->settings & PROJECT_SETTING_ENABLE_BUGS) {
            $page->add_function(new PageFunction(array('target' => 'taskNewBug', 'params' => array('prj' => $project->id, 'add_issue' => 1), 'icon' => 'new', 'tooltip' => __('Create task with issue-report'), 'name' => __('New bug'))));
        }
        $page->add_function(new PageFunction(array('target' => 'taskNewDocu', 'params' => array('prj' => $project->id), 'icon' => 'new', 'tooltip' => __('Create wiki documentation page or start discussion topic'), 'name' => __('New topic'))));
        if ($project->settings & PROJECT_SETTING_ENABLE_EFFORTS && $auth->cur_user->settings & USER_SETTING_ENABLE_EFFORTS) {
            $page->add_function(new PageFunction(array('target' => 'effortNew', 'params' => array('prj' => $project->id), 'icon' => 'loghours', 'tooltip' => __('Book effort for this project'), 'name' => __('Book effort'))));
        }
    }
    $url = $PH->getUrl("projViewAsRSS", array('prj' => $project->id));
    $page->extra_header_html .= '<link rel="alternate" type="application/rss+xml" title="' . asHtml($project->name) . ' ' . __("News") . '"' . ' href="' . $url . '" />';
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen_Columns();
    measure_stop('current milestone');
    require_once confGet('DIR_STREBER') . 'blocks/current_milestone_block.inc.php';
    $block = new CurrentMilestoneBlock($project);
    $block->render();
    measure_stop('current milestone');
    measure_start('team');
    require_once confGet('DIR_STREBER') . 'lists/list_docustructure.inc.php';
    if (Task::getDocuTasks($project->id, 0)) {
        $list = new Block_DocuNavigation(array('project_id' => $project->id));
        $list->print_all();
    }
    #--- list team -----------------------------------------------------------
    /*
    {
    
        $list= new ListBlock_projectTeam();
        $list->title= __('Team members');
        $list->show_icons=true;
        $list->active_block_function = 'list';
        $list->print_automatic($project);
    }
    measure_stop('team');
    */
    echo new PageContentNextCol();
    echo "<div class=description>";
    echo wikifieldAsHtml($project, 'description', array('empty_text' => "[quote]" . __("This project does not have any text yet.\nDoubleclick here to add some.") . "[/quote]"));
    echo "</div>";
    #--- news -----------------------------------------------------------
    if ($project->settings & PROJECT_SETTING_ENABLE_NEWS) {
        require_once confGet('DIR_STREBER') . './blocks/project_news_block.inc.php';
        print new ProjectNewsBlock($project);
    }
    require_once confGet('DIR_STREBER') . './lists/list_recentchanges.inc.php';
    printRecentChanges(array($project), false);
    /*
    measure_start('changes');
    {
        require_once(confGet('DIR_STREBER') . './lists/list_changes.inc.php');
    
        $list= new ListBlock_changes();
        $list->query_options['date_min']= $auth->cur_user->last_logout;
        $list->query_options['not_modified_by']= $auth->cur_user->id;
        $list->query_options['project']= $project->id;
        //$list->print_automatic($project);
        $list->print_automatic();
    }
    measure_stop('changes');
    */
    echo "<br><br>";
    # @@@ hack for firefox overflow problems
    ### HACKING: 'add new task'-field ###
    $PH->go_submit = 'taskNew';
    echo '<input type="hidden" name="prj" value="' . $project->id . '">';
    #$rss_url = confGet('SELF_PROTOCOL').'://'.confGet('SELF_URL');
    #$rss_url = str_replace("index.php", "rss/", $rss_url);
    #$prj_id  = $this->page->options[0]->target_params['prj'];
    $url = $PH->getUrl('projViewAsRSS', array('prj' => $project->id));
    echo "<a style='margin:0px; border-width:0px;' href='{$url}' target='_blank'>" . "<img style='margin:0px; border-width:0px;' src='" . getThemeFile("icons/rss_icon.gif") . "'>" . "</a>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}