public function __toString()
 {
     global $PH;
     $news = $this->project->getTasks(array('is_news' => 1, 'order_by' => 'created DESC'));
     if (!$news) {
         return '';
     }
     #--- news -----------------------------------------------------------
     $this->render_blockStart();
     $count = 0;
     foreach ($news as $n) {
         if ($count++ >= $this->max_news) {
             break;
         }
         echo "<div class='post_list_entry'>";
         if ($creator = Person::getVisibleById($n->created_by)) {
             $link_creator = ' by ' . $creator->getLink();
         } else {
             $link_creator = '';
         }
         echo "<h3>" . asHtml($n->name) . "</h3>";
         echo "<p class= details>";
         echo sprintf(__("%s by %s", "time ago by nickname"), renderTimeAgo($n->created), asHtml($creator->nickname));
         if ($comments = $n->getComments()) {
             echo " / ";
             echo $PH->getLink('taskViewAsDocu', sprintf(__("%s comments"), count($comments)), array('tsk' => $n->id));
         }
         echo " / ";
         echo $PH->getLink("commentNew", __("Add comment"), array('parent_task' => $n->id));
         echo "</p>";
         echo wikifieldAsHtml($n, 'description');
         echo "</div>";
     }
     $this->render_blockEnd();
     return '';
 }
/**
* Edit a team member @ingroup pages
*/
function projectPersonEdit($pp = NULL)
{
    global $PH;
    global $auth;
    if (!$pp) {
        $id = getOnePassedId('projectperson', 'projectpeople_*', true, 'No team member selected?');
        # WARNS if multiple; ABORTS if no id found
        if (!($pp = ProjectPerson::getEditableById($id))) {
            $PH->abortWarning("ERROR: could not get Project Person");
            return;
        }
    }
    ### get project ###
    if (!($project = Project::getVisibleById($pp->project))) {
        $PH->abortWarning("ERROR: could not get project");
    }
    ### get person ###
    if (!($person = Person::getVisibleById($pp->person))) {
        $PH->abortWarning("ERROR: could not get person");
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'projectperson_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit Team Member");
    $page->title = sprintf(__("role of %s in %s", "edit team-member title"), $person->name, $project->name);
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'projectPersonEdit'));
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab("details", __("Details")));
    global $g_theme_names;
    global $g_user_profile_names;
    global $g_user_profiles;
    ### display "undefined" profile if rights changed ###
    $profile_num = 0;
    # will be skipped when submitting
    $reset = "";
    $check = array_keys($g_user_profile_names);
    $number = count($g_user_profile_names);
    $count = 0;
    for ($i = 0; $i < $number; $i++) {
        if ($pp->role == $check[intval($i)]) {
            $profile_num = $count;
            break;
        }
        $count++;
    }
    /*$profile_settings= $g_user_profiles[intval($profile_num)];
    
                $count=0;
    			echo "LevelV: " . $pp->level_view . "<br>";
    			echo "SetV: " . $profile_settings['level_view'] . "<br>";
    			echo "LevelC: " . $pp->level_create . "<br>";
    			echo "SetC: " . $profile_settings['level_create'] . "<br>";
    			echo "LevelE: " . $pp->level_edit . "<br>";
    			echo "SetE: " . $profile_settings['level_edit'] . "<br>";
    			echo "LevelD: " . $pp->level_delete . "<br>";
    			echo "SetV: " . $profile_settings['level_delete'] . "<br>";
                foreach($g_user_profiles as $profile_id => $profile_settings) {
                    if($pp->level_view          == $profile_settings['level_view']
                        && $pp->level_create    == $profile_settings['level_create']
                        && $pp->level_edit      == $profile_settings['level_edit']
                        && $pp->level_delete    == $profile_settings['level_delete']
                    ){
                        $profile_num=$count;
                        break;
                    }
                    $count++;
                }*/
    /*$form->add(new Form_Dropdown('person_profile',
                                  __("Role in this project"),
                                  array_flip($g_user_profile_names),
                                  $profile_num
      ));*/
    $tab->add(new Form_Dropdown('person_profile', __("Role in this project"), array_flip($g_user_profile_names), $profile_num));
    //$form->add($pp->fields['name']->getFormElement($pp));
    $tab->add($pp->fields['name']->getFormElement($pp));
    ### public-level ###
    if (($pub_levels = $pp->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        //$form->add(new Form_Dropdown('projectperson_pub_level',  __("Publish to"),$pub_levels,$pp->pub_level));
        $tab->add(new Form_Dropdown('projectperson_pub_level', __("Publish to"), $pub_levels, $pp->pub_level));
    }
    ### effort-style ###
    $effort_styles = array(__("start times and end times") => 1, __("duration") => 2);
    //$form->add(new Form_Dropdown('projectperson_effort_style',  __("Log Efforts as"), $effort_styles, $pp->adjust_effort_style));
    $tab->add(new Form_Dropdown('projectperson_effort_style', __("Log Efforts as"), $effort_styles, $pp->adjust_effort_style));
    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($pp->fields['salary_per_hour']->getFormElement($pp));
    }
    echo $form;
    $PH->go_submit = 'projectPersonEditSubmit';
    echo "<input type=hidden name='projectperson' value='{$pp->id}'>";
    echo "<input type=hidden name='projectperson_project' value='{$pp->project}'>";
    echo new PageContentClose();
}
/**
* revert changes of a person
*
* Notes:
* - This function is only available of people with RIGHT_PROJECT_EDIT.
* - This will only effect changes to fields.
* - Following changes will not be reverted:
*   - Creation of new items (Tasks, Topis, Efforts, Projects, etc.)
*   - Task-assignments
*   - Uploading of files
* 
* person - id of person who did the changes
* data - date to with revert changes
* delete_history  (Default off) - Reverting can't be undone! The person's modification are lost forever!
*                                 This can be useful on massive changes to avoid sending huge
*                                 notification mails.
*/
function personRevertChanges()
{
    global $PH;
    global $auth;
    ### check rights ###
    if (!$auth->cur_user->user_rights & RIGHT_PROJECT_EDIT) {
        $PH->abortWarning("You require the right to edit projects.");
    }
    ### get person ###
    $person_id = getOnePassedId('person', 'people_*');
    if (!($person = Person::getVisibleById($person_id))) {
        $PH->abortWarning(sprintf(__("invalid Person #%s"), $person_id));
        return;
    }
    $page = new Page();
    $page->tabs['admin'] = array('target' => "index.php?go=systemInfo", 'title' => __('Admin', 'top navigation tab'), 'bg' => "misc");
    $page->cur_tab = 'admin';
    $page->crumbs[] = new NaviCrumb(array('target_id' => 'systemInfo'));
    $page->title = __("Reverting user changes");
    $page->type = __("Admin");
    #$page->title_minor=get('go');
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Overview'), 'id' => 'overview'));
    $block->render_blockStart();
    echo "<div class=text>";
    echo "<ul>";
    ### get changes of person ###
    $count_reverted_fields = 0;
    $changes = ItemChange::getItemChanges(array('person' => $person_id, 'order_by' => 'id DESC'));
    foreach ($changes as $c) {
        if (!($project_item = DbProjectItem::getObjectById($c->item))) {
            #print "unable to get item %s" % $c->item;
        } else {
            ### Only revert changes, if item has not be editted by other person
            if ($project_item->modified_by == $person_id) {
                $field_name = $c->field;
                echo "<li>" . "<strong>" . asHtml($project_item->name) . "." . asHtml($field_name) . "</strong>" . " '" . asHtml($project_item->{$field_name}) . "' = '" . asHtml($c->value_old) . "'" . "</li>";
                $count_reverted_fields++;
                if ($field_name == 'state') {
                    if ($project_item->state == -1 && $c->value_old == 1) {
                        $project_item->deleted_by = "0";
                        $project_item->deleted = "0000-00-00 00-00-00";
                    }
                }
                $project_item->{$field_name} = $c->value_old;
                $project_item->update(array($field_name, 'deleted_by', 'deleted'), false, false);
            } else {
                echo "<li>" . sprintf(__("Skipped recently editted item #%s: <b>%s<b>"), $project_item->id, asHtml($project_item->name)) . "</li>";
            }
            $c->deleteFull();
        }
    }
    echo "</ul>";
    echo "<p>" . sprintf(__("Reverted all changes (%s) of user %s"), $count_reverted_fields, asHtml($person->nickname)) . "</p>";
    echo "<p>" . __("newly created items by this user remain unaffected.") . "</p>";
    echo "</div>";
    $block->render_blockEnd();
    ### close page
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
 /**
  * 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 render_tr(&$item, $style = "")
 {
     global $PH;
     $str_date = '';
     $str_name = '';
     $str_url = '';
     if ($i = DbProjectItem::getById($item->id)) {
         if ($i->modified) {
             $mod_date = $i->modified;
             $str_date = renderDateHtml($mod_date);
             if ($i->modified_by) {
                 if ($person = Person::getVisibleById($i->modified_by)) {
                     $str_name = asHtml($person->name);
                     $str_url = $person->getLink();
                 }
             }
             print '<td><span class=date>' . $str_date . '</span><br><span class="sub who">' . __('by') . ' ' . $str_url . '</span></td>';
         } else {
             print "<td class='nowrap'>&nbsp;</td>";
         }
     } else {
         $PH->abortWarning("Could not get modification date of the element.", ERROR_BUG);
         print "<td class='nowrap'>&nbsp;</td>";
     }
 }
 function render_tr(&$obj, $style = "")
 {
     if (!isset($obj) || !$obj instanceof Project) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     $sum = 0.0;
     $sum_sal = 0.0;
     $sum_all = 0.0;
     $sum_cal = 0.0;
     $diff_value = false;
     if ($effort_people = Effort::getEffortPeople(array('project' => $obj->id))) {
         foreach ($effort_people as $ep) {
             if ($person = Person::getVisibleById($ep->person)) {
                 /*if($obj->getStatus()){
                 			$sum_sal = Effort::getSumEfforts(array('project'=>$obj->id, 'person'=>$person->id, 'status'=>$obj->status));
                 		}
                 		else{*/
                 $sum_sal = Effort::getSumEfforts(array('project' => $obj->id, 'person' => $person->id));
                 #}
                 if ($sum_sal) {
                     $sum = round($sum_sal / 60 / 60, 1) * 1.0;
                     if ($pp = $obj->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 ($effort_tasks = Effort::getEffortTasks(array('project' => $obj->id))) {
         foreach ($effort_tasks as $et) {
             if ($task = Task::getById($et->task)) {
                 if ($task->calculation) {
                     $sum_cal += $task->calculation;
                 }
             }
         }
     }
     if ($sum_all && $sum_cal) {
         $max_length_value = 3;
         $get_percentage = $sum_all / $sum_cal * 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>";
     }
 }
Exemple #7
0
 /**
  * records history events in rss/rss_$project->id.xml
  *
  * must be called from a project-related page!
  *
  *
  * @param project - current project object used in: proj.inc.php <- function call
  */
 static function updateRSS($project)
 {
     global $PH;
     global $auth;
     if (!$project) {
         return NULL;
     }
     /**
      * only show changes by others
      */
     if (Auth::isAnonymousUser()) {
         $not_modified_by = NULL;
     } else {
         $not_modified_by = $auth->cur_user->id;
     }
     ### get all the changes (array of history items) ##
     $changes = ChangeLine::getChangeLines(array('project' => $project->id, 'unviewed_only' => false, 'limit_rowcount' => 20, 'type' => array(ITEM_TASK, ITEM_FILE), 'limit_offset' => 0));
     /*
     $changes= DbProjectItem::getAll(array(
         'project'           => $project->id,        # query only this project history
         'alive_only'        => false,               # get deleted entries
         'visible_only'      => false,               # ignore user viewing rights
         'limit_rowcount'    => 20,                  # show only last 20 entries in rss feed
         #'show_assignments'  => false,              # ignore simple assignment events
     ));
     */
     $url = confGet('SELF_PROTOCOL') . '://' . confGet('SELF_URL');
     # url part of the link to the task
     $from_domain = confGet('SELF_DOMAIN');
     # domain url
     if (confGet('USE_MOD_REWRITE')) {
         $url = str_replace('index.php', '', $url);
     }
     ### define general rss file settings ###
     $rss = new UniversalFeedCreator();
     $rss->title = "StreberPM: " . $project->name;
     $rss->description = "Latest Project News";
     $rss->link = "{$url}?go=projView&prj={$project->id}";
     $rss->syndicationURL = $url;
     # go through all retrieved changes and create rss feed
     foreach ($changes as $ch) {
         $item = $ch->item;
         $name_author = __('???');
         if ($person = Person::getVisibleById($item->modified_by)) {
             $name_author = $person->name;
         }
         $str_updated = '';
         if ($new = $ch->item->isChangedForUser()) {
             if ($new == 1) {
                 $str_updated = __('New');
             } else {
                 $str_updated = __('Updated');
             }
         }
         $feeditem = new FeedItem();
         $feeditem->title = $item->name . " (" . $ch->txt_what . ' ' . __("by") . ' ' . $name_author . ")";
         $feeditem->link = $url . "?go=itemView&item={$item->id}";
         $feeditem->date = gmdate("r", strToGMTime($item->modified));
         $feeditem->source = $url;
         $feeditem->author = $name_author;
         switch ($ch->type) {
             case ChangeLine::COMMENTED:
                 $feeditem->description = $ch->html_details;
                 break;
             case ChangeLine::NEW_TASK:
                 $feeditem->description = str_replace("\n", "<br>", $item->description);
                 break;
             default:
                 $feeditem->description = $ch->type . " " . str_replace("\n", "<br>", $item->description);
                 break;
         }
         $rss->addItem($feeditem);
     }
     /**
      * all history items processed ...
      * save the rss 2.0 feed to rss/rss_$project->id.xml ...
      * false stands for not showing the resulting feed file -> create in background
      */
     $rss->saveFeed("RSS2.0", "_rss/proj_{$project->id}.xml", false);
 }
Exemple #8
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;
     }
 }
Exemple #9
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();
}
/**
* Submit new teammember to a project @ingroup pages
*/
function projAddPersonSubmit()
{
    global $PH;
    require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
    $id = getOnePassedId('project', '');
    if (!($project = Project::getEditableById($id))) {
        $PH->abortWarning("Could not get object...", ERROR_FATAL);
    }
    ### get people ###
    $person_ids = getPassedIds('person', 'people*');
    if (!$person_ids) {
        $PH->abortWarning(__("No people selected..."), ERROR_NOTE);
    }
    ### get team (including inactive members)  ###
    $ppeople = $project->getProjectPeople(array('alive_only' => false, 'visible_only' => false, 'person_id' => NULL));
    ### go through selected people ###
    foreach ($person_ids as $pid) {
        if (!($person = Person::getVisibleById($pid))) {
            $PH->abortWarning(__("Could not access person by id"));
            return;
        }
        #### person already employed? ###
        $already_in = false;
        $pp = NULL;
        foreach ($ppeople as $pp) {
            if ($pp->person == $person->id) {
                $already_in = true;
                break;
            }
        }
        ### effort-style
        $adjust_effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? EFFORT_STYLE_DURATION : EFFORT_STYLE_TIMES;
        ### add ###
        if (!$already_in) {
            $pp_new = new ProjectPerson(array('id' => 0, 'person' => $person->id, 'project' => $project->id, 'adjust_effort_style' => $adjust_effort_style, 'salary_per_hour' => $person->salary_per_hour));
            ### add project-right ###
            global $g_user_profile_names;
            if ($g_user_profile_names[$person->profile]) {
                $profile_id = $person->profile;
                $pp_new->initWithUserProfile($profile_id);
            } else {
                trigger_error("person '{$person->name}' has undefined profile", E_USER_WARNING);
            }
            $pp_new->insert();
        } else {
            if ($pp->state != 1) {
                $pp->state = 1;
                $pp->update();
                new FeedbackMessage(sprintf(__("Reanimated person %s as team-member"), asHtml($person->name)));
            } else {
                new FeedbackMessage(sprintf(__("Person %s already in project"), asHtml($person->name)));
            }
        }
    }
    ### display taskView ####
    if (!$PH->showFromPage()) {
        $PH->show('projView', array('prj' => $project->id));
    }
}
Exemple #11
0
 public function storeUserCookie()
 {
     if ($this->cur_user) {
         #log_message("storeUserCookie(".$this->cur_user->cookie_string.")", LOG_MESSAGE_DEBUG);
         /**
          * since the user might have been edited, the auth->cur_user object might no longer
          * be up to date. So first get it fresh from db...
          */
         if (!($this->cur_user = Person::getVisibleById($this->cur_user->id))) {
             trigger_error("storeUserCookie() could not get current person from db?", E_USER_ERROR);
             exit;
         }
         if (!setcookie('NORD_UID', $this->cur_user->cookie_string, time() + confGet('COOKIE_LIFETIME'), '', '', 0)) {
             global $PH;
             new FeedbackError(__('Could not set cookie.'));
             log_message("storeUserCookie(" . $this->cur_user->cookie_string . ") Failed", LOG_MESSAGE_DEBUG);
             return false;
         }
     }
 }
Exemple #12
0
/**
* Submit changes to an effort  @ingroup pages
*/
function effortEditSubmit()
{
    global $PH;
    global $auth;
    ### Validate form crc
    if (!validateFormCrc()) {
        $PH->abortWarning(__('Invalid checksum for hidden form elements'));
    }
    ### get effort ####
    $id = getOnePassedId('effort');
    if ($id == 0) {
        $effort = new Effort(array('id' => 0));
    } else {
        $effort = Effort::getEditableById($id);
        if (!$effort) {
            $PH->abortWarning(__("Could not get effort"));
            return;
        }
        $effort->validateEditRequestTime();
    }
    ### cancel ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('projView', array('prj' => $effort->project));
        }
        exit;
    }
    ### get project ###
    $effort->project = get('effort_project');
    if (!($project = Project::getVisibleById($effort->project))) {
        $PH->abortWarning(__("Could not get project of effort"));
    }
    if (!$project->isPersonVisibleTeamMember($auth->cur_user)) {
        $PH->abortWarning("ERROR: Insufficient rights");
    }
    ### get person ###
    if ($effort->person = get('effort_person')) {
        if (!($person = Person::getVisibleById($effort->person))) {
            $PH->abortWarning(__("Could not get person of effort"));
        }
    }
    # 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 ($effort->fields as $f) {
        $name = $f->name;
        $f->parseForm($effort);
    }
    ### times as duration ###
    if ($as_duration = get('effort_as_duration')) {
        $effort->as_duration = $as_duration;
        ### make sure day of time_end stays the same if date changes... ###
        if (($time_start = $effort->time_start) && ($time_end = $effort->time_end)) {
            $effort->time_end = gmdate("Y-m-d", strToClientTime($time_end)) . " " . gmdate("H:i:s", strToClientTime($time_end));
            $effort->time_start = gmdate("Y-m-d", strToClientTime($time_end)) . " " . gmdate("00:00:00", strToClientTime($time_end));
        } else {
            trigger_error("Getting time_start and time_end failed", E_USER_WARNING);
        }
    }
    ### pub level ###
    if ($pub_level = get('effort_pub_level')) {
        ### not a new effort ###
        if ($effort->id) {
            if ($pub_level > $effort->getValidUserSetPublicLevels()) {
                $PH->abortWarning('invalid data', ERROR_RIGHTS);
            }
        }
        #else {
        #  #@@@ check for person create rights
        #}
        $effort->pub_level = $pub_level;
    }
    ## effort status ##
    if ($effort_status = get('effort_status')) {
        $effort->status = $effort_status;
    }
    if ($effort_billing = get('effort_billing')) {
        $effort->billing = intval($effort_billing);
    }
    if ($effort_productivity = get('effort_productivity')) {
        $effort->productivity = intval($effort_productivity);
    }
    ### link to task ###
    $task_id = get('effort_task');
    if (!is_null($task_id)) {
        if ($task_id == 0) {
            $effort->task = 0;
        } else {
            if ($task = Task::getVisibleById($task_id)) {
                $effort->task = $task->id;
            }
        }
    }
    ### go back to from if validation fails ###
    $failure = false;
    if (!$effort->name) {
        $failure = true;
        new FeedbackWarning(__("Name required"));
    }
    if (strToGMTime($effort->time_end) - strToGMTime($effort->time_start) < 0) {
        $failure = true;
        new FeedbackWarning(__("Cannot start before end."));
    }
    ### validation of the Datetime fields###
    if (!$as_duration) {
        if (strToGMTime($effort->time_start) == 0) {
            $failure = true;
            $name = $effort->fields['time_start']->name;
            $field_id = $effort->_type . '_' . $name;
            $value_time = get($field_id . '_time');
            new FeedbackWarning(sprintf(__("<b>%s</b> is not a valid value for start time."), $value_time));
            $effort->time_start = getGMTString();
        }
        if (strToGMTime($effort->time_end) == 0) {
            $failure = true;
            $name = $effort->fields['time_end']->name;
            $field_id = $effort->_type . '_' . $name;
            $value_time = get($field_id . '_time');
            new FeedbackWarning(sprintf(__("<b>%s</b> is not a valid value for end time."), $value_time));
            $effort->time_end = getGMTString();
        }
    } else {
        ##As duration
        if (strToGMTime($effort->time_end) == 0) {
            $failure = true;
            $name = $effort->fields['time_end']->name;
            $field_id = $effort->_type . '_' . $name;
            $value_time = get($field_id . '_time');
            new FeedbackWarning(sprintf(__("<b>%s</b> is not a valid value for hours."), $value_time));
            $effort->time_end = gmdate("Y-m-d", time()) . " 00:00:00";
        }
    }
    if ($failure) {
        $PH->show('effortEdit', NULL, $effort);
        exit;
    }
    ### write to db ###
    if ($effort->id == 0) {
        $effort->insert();
    } else {
        $effort->update();
    }
    ### display taskView ####
    if (!$PH->showFromPage()) {
        $PH->show('projView', array('prj' => $effort->project));
    }
}
 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);
 }
Exemple #14
0
/**
* Submit change to a company
*
* @ingroup pages
*/
function companyEditSubmit()
{
    global $PH;
    global $auth;
    ### cancel ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home', array());
        }
        exit;
    }
    ### Validate integrety ###
    if (!validateFormCrc()) {
        $PH->abortWarning(__('Invalid checksum for hidden form elements'));
    }
    ### get company ####
    $id = getOnePassedId('company');
    ### temporary object ###
    if ($id == 0) {
        $company = new Company(array());
    } else {
        $company = Company::getEditableById($id);
        if (!$company) {
            $PH->abortWarning("Could not get company");
            return;
        }
        ### Validate item has not been editted since
        $company->validateEditRequestTime();
    }
    ### company category ###
    $ccategory = get('ccategory');
    if ($ccategory != NULL) {
        $company->category = $ccategory;
    }
    # 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 ($company->fields as $f) {
        $name = $f->name;
        $f->parseForm($company);
    }
    ### write to db ###
    if ($company->id == 0) {
        if ($company->insert()) {
            ### link to a company ###
            if ($p_id = get('person')) {
                require_once confGet('DIR_STREBER') . 'db/class_person.inc.php';
                if ($p = Person::getVisibleById($p_id)) {
                    require_once confGet('DIR_STREBER') . 'db/class_employment.inc.php';
                    $e = new Employment(array('id' => 0, 'person' => $p->id, 'company' => $company->id));
                    $e->insert();
                }
            }
        }
        ### show 'create another' -form
        if (get('create_another')) {
            $PH->show('companyNew', array());
            exit;
        }
    } else {
        $company->update();
    }
    ### notify on change/unchange ###
    $company->nowChangedByUser();
    ### display taskView ####
    if (!$PH->showFromPage()) {
        $PH->show('home', array());
    }
}
Exemple #15
0
 public function render_quickedit($task)
 {
     global $PH;
     $editable = false;
     ### make sure it's editable ###
     if (Task::getEditableById($task->id)) {
         $editable = true;
     } else {
         if (!Task::getVisibleById($task->id)) {
             return false;
         }
     }
     ### get parent project ####
     if (!($project = Project::getVisibleById($task->project))) {
         return;
     }
     $this->render_blockStart();
     require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
     global $REPRODUCIBILITY_VALUES;
     global $g_prio_names;
     global $g_status_names;
     $form = new PageForm();
     $form->button_cancel = false;
     $form->add($tab_group = new Page_TabGroup());
     $tab_group->add($tab = new Page_Tab("comment", __("Add comment")));
     ### Comment ###
     $comment_name = '';
     $comment = new Comment(array('id' => 0, 'name' => $comment_name));
     $tab->add($comment->fields['name']->getFormElement($comment, __('Comment')));
     $e = $comment->fields['description']->getFormElement($comment);
     $e->rows = 8;
     $tab->add($e);
     ### request feedback
     $tab->add(buildRequestFeedbackInput($project));
     ### update ###
     if ($editable && $task->isOfCategory(array(TCATEGORY_TASK, TCATEGORY_BUG))) {
         $tab_group->add($tab = new Page_Tab("update", __("Update")));
         #$tab->add(new Form_Dropdown('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
         $tab->add(new Form_DropdownGrouped('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
         $tab->add(new Form_DropdownGrouped('task_resolved_version', __('Resolved in'), $project->buildResolvedInList(), $task->resolved_version));
         global $g_resolve_reason_names;
         $tab->add(new Form_Dropdown('task_resolve_reason', __('Resolve reason'), array_flip($g_resolve_reason_names), $task->resolve_reason));
         ### for existing tasks, get already assigned
         if ($task->id) {
             $assigned_people = $task->getAssignedPeople();
         } else {
             trigger_error("view a task with zero id?");
         }
         $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));
         if (!$task->isMilestoneOrVersion()) {
             $tab->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio));
         }
         $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));
         $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));
         $tab->add($task->fields['parent_task']->getFormElement($task));
         $st = array();
         foreach ($g_status_names as $s => $n) {
             if ($s >= STATUS_NEW) {
                 $st[$s] = $n;
             }
         }
         if ($task->isMilestoneOrVersion()) {
             unset($st[STATUS_NEW]);
         }
         $tab->add(new Form_Dropdown('task_status', "Status", array_flip($st), $task->status));
     }
     /**
      * to reduce spam, enforce captcha test for guests
      */
     global $auth;
     if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
         $form->addCaptcha();
     }
     ### some required hidden fields for correct data passing ###
     $form->add(new Form_HiddenField('tsk', '', $task->id));
     $form->add(new Form_HiddenField('comment', '', $comment->id));
     if ($return = get('return')) {
         $form->add(new Form_HiddenField('return', '', asHtml($return)));
     }
     echo $form;
     $PH->go_submit = 'taskEditSubmit';
     $this->render_blockEnd();
 }
Exemple #16
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();
}
function renderRemovalPreviewTask($task)
{
    $name = asHtml($task->name);
    if (!$name) {
        $name = __("Untitled");
    }
    echo "<li>";
    echo "<input checked type=checkbox value='{$task->id}' name='item_{$task->id}'>";
    echo "<label for='item_{$task->id}'>";
    echo $task->getLink();
    if ($creator = Person::getVisibleById($task->created_by)) {
        echo sprintf(__("by %s", "as in created by"), $creator->getLink());
    }
    echo "<br>";
    echo " <small>" . asHtml($task->description) . "</small>";
    echo "</label>";
    echo "</li>";
}
Exemple #18
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();
}
Exemple #19
0
function personViewChanges()
{
    global $PH;
    global $auth;
    ### get current project ###
    $id = getOnePassedId('person', 'people_*');
    if (!($person = Person::getVisibleById($id))) {
        $PH->abortWarning("invalid person-id");
        return;
    }
    ### sets the presets ###
    $presets = array('all_changes' => array('name' => __('all'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_UNDEFINED, 'max' => STATUS_CLOSED)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_logout' => array('name' => __('last logout'), 'filters' => array('last_logout' => array('id' => 'last_logout', 'visible' => true, 'active' => true, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_week' => array('name' => __('1 week'), 'filters' => array('last_week' => array('id' => 'last_week', 'visible' => true, 'active' => true, 'factor' => 7, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_two_weeks' => array('name' => __('2 weeks'), 'filters' => array('last_two_weeks' => array('id' => 'last_two_weeks', 'visible' => true, 'active' => true, 'factor' => 14, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))));
    ## set preset location ##
    $preset_location = 'personViewChanges';
    $preset_id = 'last_two_weeks';
    # default value
    if ($tmp_preset_id = get('preset')) {
        if (isset($presets[$tmp_preset_id])) {
            $preset_id = $tmp_preset_id;
        }
        ### set cookie
        setcookie('STREBER_personViewChanges_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0);
    } else {
        if ($tmp_preset_id = get('STREBER_personViewChanges_preset')) {
            if (isset($presets[$tmp_preset_id])) {
                $preset_id = $tmp_preset_id;
            }
        }
    }
    ### create from handle ###
    $PH->defineFromHandle(array('person' => $person->id, 'preset_id' => $preset_id));
    $page = new Page();
    $page->cur_tab = 'people';
    $page->title = $person->name;
    $page->title_minor = __('Changes', 'Page title add on');
    $page->type = __("Person");
    $page->crumbs = build_person_crumbs($person);
    $page->options = build_person_options($person);
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . './lists/list_changes.inc.php';
    $list = new ListBlock_changes();
    $list->no_items_html = __('no changes yet');
    $list->filters[] = new ListFilter_changes();
    $preset = $presets[$preset_id];
    foreach ($preset['filters'] as $f_name => $f_settings) {
        switch ($f_name) {
            case 'task_status':
                $list->filters[] = new ListFilter_status_min(array('value' => $f_settings['min']));
                #$list->filters[]= new ListFilter_status_max(array(
                #    'value'=>$f_settings['max'],
                #));
                break;
            case 'last_logout':
                $list->filters[] = new ListFilter_last_logout(array('value' => $f_settings['value']));
                break;
            case 'last_week':
                $list->filters[] = new ListFilter_min_week(array('value' => $f_settings['value'], 'factor' => $f_settings['factor']));
                #$list->filters[]= new ListFilter_max_week(array(
                #   'value'=>$f_settings['value'],
                #));
                break;
            case 'last_two_weeks':
                $list->filters[] = new ListFilter_min_week(array('value' => $f_settings['value'], 'factor' => $f_settings['factor']));
                #$list->filters[]= new ListFilter_max_week(array(
                #   'value'=>$f_settings['value'],
                #));
                break;
            default:
                trigger_error("Unknown filter setting {$f_name}", E_USER_WARNING);
                break;
        }
    }
    $filter_empty_folders = isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'] ? true : NULL;
    $page->print_presets(array('target' => $preset_location, 'project_id' => '', 'preset_id' => $preset_id, 'presets' => $presets, 'person_id' => $person->id));
    $list->query_options['modified_by'] = $person->id;
    $list->print_automatic();
    echo '<input type="hidden" name="person" value="' . $person->id . '">';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemple #20
0
 function render_tr(&$file, $style = "")
 {
     global $PH;
     if (!isset($file) || !$file instanceof File) {
         return;
     }
     #$buffer = $PH->getLink('fileView',__("Details"), array('file'=>$file->id),'item file');
     $buffer = '';
     if ($file->mimetype == 'image/png' || $file->mimetype == 'image/x-png' || $file->mimetype == 'image/jpeg' || $file->mimetype == 'image/pjpeg' || $file->mimetype == 'image/jpg' || $file->mimetype == 'image/gif') {
         if ($author = Person::getVisibleById($file->created_by)) {
             $author_name = $author->nickname;
         } else {
             $author_name = "???";
         }
         $buffer .= "<span class=sub><a " . "title='" . sprintf(__("creatd on %s", "date a file was created"), renderDate($file->created)) . "' " . "target='blank' " . "href='" . $PH->getUrl('fileDownloadAsImage', array('file' => $file->id)) . "' " . "><img class='left' title='" . asHtml($file->name) . "' alt='" . asHtml($file->name) . "' " . "src='" . $file->getCachedUrl(100) . "'" . "><br>" . "" . asHtml($file->name) . "</a>" . "</span>" . "<br>" . "<span class=sub title='" . __('click to show details') . "'>" . $PH->getLink('fileView', '#' . $file->id, array('file' => $file->id)) . ' ' . sprintf(__('by %s', 'person who uploaded a file'), $author_name) . ', ' . renderFilesize($file->filesize) . "<br>" . "</span>";
     } else {
         $buffer .= "<b>" . $PH->getLink('fileDownload', $file->name, array('file' => $file->id)) . "</b>" . "<br>" . "<span class=sub>" . $file->filesize . " bytes" . " / " . sprintf(__("ID %s"), $file->id) . " / " . renderDateHtml($file->created) . "</span>" . "<br>" . "<span class=sub>" . $PH->getLink('fileView', __('Show Details'), array('file' => $file->id)) . "</span>";
     }
     print "<td class='attachment_summary'>{$buffer}</td>";
 }
 /**
  * get People working for company
  *
  * @@@ visibilities-validation is REALLY slow
  */
 function getPeople()
 {
     $prefix = confGet('DB_TABLE_PREFIX');
     require_once confGet('DIR_STREBER') . 'db/class_person.inc.php';
     require_once confGet('DIR_STREBER') . 'db/class_employment.inc.php';
     $dbh = new DB_Mysql();
     $sth = $dbh->prepare("SELECT p.* FROM {$prefix}person p,{$prefix}employment em, {$prefix}item i\r\n                        WHERE   i.type= " . ITEM_EMPLOYMENT . "\r\n                        AND     i.state=1\r\n                        AND     i.id= em.id\r\n                        AND     em.company = \"{$this->id}\"\r\n                        AND     em.person= p.id\r\n                        AND     p.state=1");
     $sth->execute("", 1);
     $tmp = $sth->fetchall_assoc();
     $es = array();
     foreach ($tmp as $t) {
         if ($person = Person::getVisibleById($t['id'])) {
             $es[] = $person;
         }
     }
     return $es;
 }
Exemple #22
0
 function render_tr(&$obj, $style = "nowrap")
 {
     if (!isset($obj) || !$obj instanceof Task) {
         return;
     }
     $value = "";
     if ($obj->created_by) {
         if ($person = Person::getVisibleById($obj->created_by)) {
             $value = $person->getLink();
         }
     }
     print "<td class=nowrap>{$value}</td>";
 }
 public function __toString()
 {
     global $PH;
     global $auth;
     #--- news -----------------------------------------------------------
     $comments = $this->item_with_comments->getComments(array('order_by' => 'created'));
     $block = new PageBlock(array('title' => sprintf(__("%s Comments"), count($comments) ? count($comments) : __("No", "As in... >No< Comments")), 'id' => 'news'));
     $block->render_blockStart();
     $count = 0;
     foreach ($comments as $c) {
         ### own comment
         $is_comment_editable = $auth->cur_user->user_rights & RIGHT_EDITALL || $c->created_by == $auth->cur_user->id;
         if (!($creator = Person::getVisibleById($c->created_by))) {
             continue;
         }
         echo "<div class='post_list_entry'>";
         echo "<h3>";
         if ($c->created_by == $auth->cur_user->id) {
             echo $creator->nickname;
         } else {
             echo $creator->getLink();
         }
         echo "<span class=separator>:</span>";
         echo asHtml($c->name);
         if ($new = $c->isChangedForUser()) {
             if ($new == 1) {
                 echo '<span class=new> (' . __('New') . ') </span>';
             } else {
                 echo '<span class=new>  (' . __('Updated') . ') </span>';
             }
         }
         echo "</h3>";
         echo "<p class= details>";
         echo renderTimeAgo($c->created);
         require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php";
         $versions = ItemVersion::getFromItem($c);
         if (count($versions) > 1) {
             echo " (" . $PH->getLink('itemViewDiff', sprintf(__("%s. update", "like in... Nth update"), count($versions)), array('item' => $c->id));
             echo " " . renderTimeAgo($c->modified);
             echo ") ";
         }
         if ($c->pub_level != PUB_LEVEL_OPEN) {
             echo ' - ' . sprintf(__("visible as %s"), renderPubLevelName($c->pub_level));
             ### publish ###
             if (($parent_task = Task::getEditableById($c->task)) && $c->pub_level < PUB_LEVEL_OPEN) {
                 echo " - " . $PH->getLink('itemsSetPubLevel', __('Publish'), array('item' => $c->id, 'item_pub_level' => PUB_LEVEL_OPEN));
             }
         }
         ### delete
         if ($is_comment_editable) {
             echo " - " . $PH->getLink('commentsDelete', __('Delete'), array('comment' => $c->id));
         }
         echo "</p>";
         if ($is_comment_editable) {
             echo wikifieldAsHtml($c, 'description');
         } else {
             echo wikifieldAsHtml($c, 'description', array('editable' => false));
         }
         echo "</div>";
         $c->nowViewedByUser();
     }
     $this->render_blockEnd();
     return '';
 }
 private function addRecentChanges()
 {
     ### list project changes ###
     require_once confGet('DIR_STREBER') . './lists/list_changes.inc.php';
     $updates_html = '';
     $updates_txt = '';
     foreach ($this->projects as $p) {
         if ($changes = ChangeLine::getChangeLinesForPerson($this->recipient, $p, $this->recipient->notification_last)) {
             $this->information_count++;
             $updates_html .= "<h4>";
             $updates_html .= $this->getItemLink($p->id, $p->name);
             $updates_html .= "</h4><ul>";
             $updates_txt .= "\n\r" . $p->name . "\n\r";
             foreach ($changes as $c) {
                 $updates_html .= "<li>";
                 $updates_txt .= "\n\r- ";
                 ### task
                 if ($c->item && $c->item->type == ITEM_TASK) {
                     $task = $c->item;
                     $updates_html .= $this->getItemLink($task->id, $task->name);
                     $updates_txt .= $task->name;
                 } else {
                     if ($c->item && $c->item->type == ITEM_FILE) {
                         $file = $c->item;
                         $updates_html .= $this->getItemLink($file->id, $file->name);
                         $updates_txt .= $file->name;
                     }
                 }
                 $updates_html .= '<br><span class="details">';
                 # invisible user
                 $updates_txt .= "\n\r";
                 # invisible user
                 ### what...
                 if ($c->html_what) {
                     $updates_html .= $c->html_what . ' ';
                     if ($c->txt_what) {
                         $updates_txt .= '  ' . $c->txt_what;
                     } else {
                         $updates_txt .= '  ' . strip_tags($c->html_what);
                     }
                 }
                 $updates_html .= ' ' . __("by") . ' ';
                 # invisible user
                 $updates_txt .= ' ' . __("by") . ' ';
                 # invisible user
                 ### who...
                 if ($c->person_by) {
                     if ($p_who = Person::getVisibleById($c->person_by)) {
                         $updates_html .= "<b>" . asHtml($p_who->nickname) . "</b>" . " ";
                         $updates_txt .= $p_who->nickname;
                     } else {
                         $updates_html .= '??? ';
                         # invisible user
                         $updates_txt .= '???: ';
                         # invisible user
                     }
                 }
                 ### when...
                 if ($c->timestamp) {
                     $updates_html .= ' - ' . renderTimestamp($c->timestamp);
                     $updates_txt .= ' - ' . renderTimestamp($c->timestamp);
                 }
                 ### to...
                 /**
                  * @@@ bug: this contains internal links that can be viewed from mail
                  **/
                 if ($c->html_assignment) {
                     $updates_html .= ' (' . $c->html_assignment . ') ';
                 }
                 $updates_html .= "</span>";
                 $updates_html .= "<div class='details'>" . $c->html_details . "</div>";
                 $updates_html .= "</li>";
                 $updates_txt .= "\n\r";
             }
             $updates_html .= "</ul>";
             $updates_txt .= "\n\r";
         }
     }
     if ($updates_html) {
         $this->body_html .= "<h3>" . __('Project Updates') . "</h3>" . $updates_html;
         $this->body_plaintext .= "\n\r" . __('Project Updates') . "\n\r" . str_repeat("=", strlen(__('Project Updates'))) . "\n\r" . $updates_txt;
     }
 }
Exemple #25
0
/**
* Create new comment 
* 
* New comments have to be attached to an option. So the major part of this code
* deals with finding out, to what the comment belongs to.
* 
* @ingroup pages
*
*
*  - requires comment, task or comments_* - param
*/
function commentNew()
{
    global $PH;
    global $COMMENTTYPE_VALUES;
    $project = NULL;
    $name = get('new_name') ? get('new_name') : __('New Comment', 'Default name of new comment');
    ### build new object ###
    $newComment = new Comment(array('id' => 0, 'name' => $name));
    ### try single project-id ###
    if ($id = getOnePassedId('prj', 'projects_*', false)) {
        #no not abort if not found
        if ($project = Project::getVisibleById($id)) {
            $newComment->project = $project->id;
        }
    }
    ### try single task-id ###
    $task = NULL;
    $comment = NULL;
    if ($id = getOnePassedId('tsk', 'tasks_*', false)) {
        #no not abort if not found
        if ($task = Task::getVisibleById($id)) {
            $newComment->task = $task->id;
            ### try to figure project-id from task ###
            if (!$newComment->project) {
                $newComment->project = $task->getProject()->id;
            }
        }
    }
    ### subtask? ###
    if (!$task) {
        if ($task_id = get('parent_task')) {
            if ($task = Task::getVisibleById($task_id)) {
                $newComment->task = $task->id;
                ### try to figure project-id from task ###
                if (!$newComment->project) {
                    $newComment->project = $task->getProject()->id;
                }
            }
        }
    }
    ### try single company-id ###
    if ($id = getOnePassedId('company', 'companies_*', false)) {
        #no not abort if not found
        if ($company = Company::getVisibleById($id)) {
            $newComment->company = $company->id;
        }
    }
    ### try single person-id ###
    if ($id = getOnePassedId('person', 'people_*', false)) {
        #no not abort if not found
        if ($person = Person::getVisibleById($id)) {
            $newComment->person = $person->id;
        }
    }
    ### try comment on comment ###
    if ($id = getOnePassedId('comment', 'comments_*', false)) {
        #no not abort if not found
        if ($comment = Comment::getById($id)) {
            $newComment->comment = $comment->id;
            switch (confGet('REPLY_ON_COMMENT_PREFIX')) {
                case 0:
                    $newComment->name = '';
                    break;
                case 1:
                    $newComment->name = __('Re: ') . $comment->name;
                    break;
                case 2:
                    $newComment->name = __('Reply to ', 'prefix for name of new comment on another comment') . $comment->name;
                    break;
                default:
                    $newComment->name = __('Re: ') . $comment->name;
                    break;
            }
            $newComment->occasion = $COMMENTTYPE_VALUES['Reply'];
        }
    }
    ### get current project ###
    if (!$project) {
        if ($task) {
            if (!($project = Project::getVisibleById($task->project))) {
                $PH->abortWarning('invalid project id', ERROR_FATAL);
            }
        } else {
            $PH->abortWarning('can´t access project', ERROR_BUG);
        }
    }
    if (!$task && !$comment) {
        $PH->abortWarning('need at least comment or task', ERROR_WARNING);
    }
    ### set a valid create-level ###
    $newComment->pub_level = $project->getCurrentLevelCreate();
    if ($newComment->pub_level < 1) {
        ### abort, if not enough rights ###
        $PH->abortWarning(__('insufficient rights'), ERROR_RIGHTS);
    }
    ### render form ###
    $PH->show('commentEdit', array('comment' => $newComment->id), $newComment);
}
 function render_tr(&$r, $style = "")
 {
     if ($r instanceof SearchResult) {
         if (isset($r->item)) {
             if ($r->item->modified_by) {
                 if ($person = Person::getVisibleById($r->item->modified_by)) {
                     print '<td><span class=date>' . renderDateHtml($r->item->modified) . '</span><br><span class="sub who">' . __('by') . ' ' . $person->getLink() . '</span></td>';
                     return;
                 }
             } else {
                 print '<td><span class=date>' . renderDateHtml($r->item->modified) . '</span></td>';
             }
         }
         print "<td></td>";
     } else {
         trigger_error('ListBlockCol_ChangesDate() requires instance of SearchResult', E_USER_WARNING);
         print "<td></td>";
     }
 }
/**
* writes a changeline as html
*
* 
*/
function printChangeLine($c)
{
    global $PH;
    global $auth;
    if ($c->person_by == $auth->cur_user->id) {
        $changed_by_current_user = true;
    } else {
        $changed_by_current_user = false;
    }
    if ($c->item->type == ITEM_TASK) {
        if ($changed_by_current_user) {
            echo '<li class=by_cur_user>';
        } else {
            echo '<li>';
        }
        echo $c->item->getLink(false);
    } elseif ($c->item->type == ITEM_FILE) {
        echo '<li>' . $PH->getLink('fileView', $c->item->name, array('file' => $c->item->id));
    } else {
        trigger_error('printChangeLine() for unknown item item', E_USER_WARNING);
        return;
    }
    /**
     * remarks on new, updated or item that require feedback
     */
    if ($c->item) {
        if ($c->item->isFeedbackRequestedForUser()) {
            echo '<span class=new> (' . __('Needs feedback') . ') </span>';
        } elseif ($new = $c->item->isChangedForUser()) {
            if ($new == 1) {
                echo '<span class=new> (' . __('New') . ') </span>';
            } else {
                echo '<span class=new>  (' . __('Updated') . ') </span>';
            }
        }
    }
    echo "<span class=sub>{$c->txt_what}";
    if ($person = Person::getVisibleById($c->person_by)) {
        echo ' ' . __('by') . ' <span class=person>' . asHtml($person->name) . "</span>";
    }
    echo ' ' . renderTimeAgo($c->timestamp);
    echo "</span>";
    echo '</li>';
    return;
}
 function render_tr(&$project, $style = "")
 {
     global $PH;
     print "<td>";
     if ($pps = $project->getProjectPeople()) {
         $str_delimiter = "";
         foreach ($pps as $pp) {
             ### ###
             if ($person = Person::getVisibleById($pp->person)) {
                 $link = $PH->getLink('personView', $person->getShort(), array('person' => $person->id));
                 print $str_delimiter . $link;
                 $str_delimiter = ", ";
             }
         }
     }
     print "</td>";
 }
/**
* Person View @ingroup pages
*/
function personView()
{
    global $PH;
    global $auth;
    ### get current person ###
    $id = getOnePassedId('person', 'people_*');
    if (!($person = Person::getVisibleById($id))) {
        $PH->abortWarning("invalid person-id");
        return;
    }
    ### create from handle ###
    $PH->defineFromHandle(array('person' => $person->id));
    ## is viewed by user ##
    $person->nowViewedByUser();
    $page = new Page();
    $page->cur_tab = 'people';
    if ($person->can_login) {
        $page->title = $person->nickname;
        $page->title_minor = $person->name;
    } else {
        $page->title = $person->name;
        if ($person->category) {
            global $g_pcategory_names;
            if (isset($g_pcategory_names[$person->category])) {
                $page->title_minor = $g_pcategory_names[$person->category];
            }
        }
    }
    $page->type = __("Person");
    $page->crumbs = build_person_crumbs($person);
    $page->options = build_person_options($person);
    ### skip edit functions ###
    if ($edit = Person::getEditableById($person->id)) {
        ### page functions ###
        $page->add_function(new PageFunction(array('target' => 'taskNoteOnPersonNew', 'params' => array('person' => $person->id), 'tooltip' => __('Add task for this people (optionally creating project and effort on the fly)', 'Tooltip for page function'), 'name' => __('Add note', 'Page function person'))));
        #$page->add_function(new PageFunction(array(
        #'target'    =>'personLinkCompanies',
        #'params'    =>array('person'=>$person->id),
        #'tooltip'   =>__('Add existing companies to this person'),
        #'name'      =>__('Companies'),
        #)));
        $page->add_function(new PageFunction(array('target' => 'personEdit', 'params' => array('person' => $person->id), 'icon' => 'edit', 'tooltip' => __('Edit this person', 'Tooltip for page function'), 'name' => __('Edit', 'Page function edit person'))));
        $page->add_function(new PageFunction(array('target' => 'personEditRights', 'params' => array('person' => $person->id), 'icon' => 'edit', 'tooltip' => __('Edit user rights', 'Tooltip for page function'), 'name' => __('Edit rights', 'Page function for edit user rights'))));
        if ($person->id != $auth->cur_user->id) {
            $page->add_function(new PageFunction(array('target' => 'personDelete', 'params' => array('person' => $person->id), 'name' => __('Delete'))));
        }
        $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $person->id));
        if (!$item || $item[0]->is_bookmark == 0) {
            #$page->add_function(new PageFunction(array(
            #    'target'    =>'itemsAsBookmark',
            #    'params'    =>array('person'=>$person->id),
            #    'tooltip'   =>__('Mark this person as bookmark'),
            #    'name'      =>__('Bookmark'),
            #)));
        } else {
            $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('person' => $person->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark'))));
        }
        if ($person->state == ITEM_STATE_OK && $person->can_login && ($person->personal_email || $person->office_email)) {
            $page->add_function(new PageFunction(array('target' => 'personSendActivation', 'params' => array('person' => $person->id))));
            $page->add_function(new PageFunction(array('target' => 'peopleFlushNotifications', 'params' => array('person' => $person->id))));
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen_Columns();
    ### write info block (but only for registed users)
    global $auth;
    if ($auth->cur_user->id != confGet('ANONYMOUS_USER')) {
        $block = new PageBlock(array('title' => __('Summary', 'Block title'), 'id' => 'summary'));
        $block->render_blockStart();
        echo "<div class=text>";
        if ($person->mobile_phone) {
            echo "<div class=labeled><label>" . __('Mobile', 'Label mobilephone of person') . '</label>' . asHtml($person->mobile_phone) . '</div>';
        }
        if ($person->office_phone) {
            echo "<div class=labeled><label>" . __('Office', 'label for person') . '</label>' . asHtml($person->office_phone) . '</div>';
        }
        if ($person->personal_phone) {
            echo "<div class=labeled><label>" . __('Private', 'label for person') . '</label>' . asHtml($person->personal_phone) . '</div>';
        }
        if ($person->office_fax) {
            echo "<div class=labeled><label>" . __('Fax (office)', 'label for person') . '</label>' . asHtml($person->office_fax) . '</div>';
        }
        if ($person->office_homepage) {
            echo "<div class=labeled><label>" . __('Website', 'label for person') . '</label>' . url2linkExtern($person->office_homepage) . '</div>';
        }
        if ($person->personal_homepage) {
            echo "<div class=labeled><label>" . __('Personal', 'label for person') . '</label>' . url2linkExtern($person->personal_homepage) . '</div>';
        }
        if ($person->office_email) {
            echo "<div class=labeled><label>" . __('E-Mail', 'label for person office email') . '</label>' . url2linkMail($person->office_email) . '</div>';
        }
        if ($person->personal_email) {
            echo "<div class=labeled><label>" . __('E-Mail', 'label for person personal email') . '</label>' . url2linkMail($person->personal_email) . '</div>';
        }
        if ($person->personal_street) {
            echo "<div class=labeled><label>" . __('Adress Personal', 'Label') . '</label>' . asHtml($person->personal_street) . '</div>';
        }
        if ($person->personal_zipcode) {
            echo '<div class=labeled><label></label>' . asHtml($person->personal_zipcode) . '</div>';
        }
        if ($person->office_street) {
            echo "<div class=labeled><label>" . __('Adress Office', 'Label') . '</label>' . asHtml($person->office_street) . '</div>';
        }
        if ($person->office_zipcode) {
            echo "<div class=labeled><label></label>" . asHtml($person->office_zipcode) . '</div>';
        }
        if ($person->birthdate && $person->birthdate != "0000-00-00") {
            echo "<div class=labeled><label>" . __('Birthdate', 'Label') . "</label>" . renderDateHtml($person->birthdate) . "</div>";
        }
        if ($person->last_login) {
            echo "<div class=labeled><label>" . __('Last login', 'Label') . '</label>' . renderDateHtml($person->last_login) . '</div>';
        }
        ### functions ####
        echo "</div>";
        $block->render_blockEnd();
    }
    require_once confGet('DIR_STREBER') . 'lists/list_companies.inc.php';
    $companies = $person->getCompanies();
    $list = new ListBlock_companies();
    $list->title = __('works for', 'List title');
    unset($list->columns['short']);
    unset($list->columns['homepage']);
    unset($list->columns['people']);
    unset($list->functions['companyDelete']);
    #unset($list->functions['companyNew']);
    /**
     * \todo We should provide a list-function to link more
     * people to this company. But therefore we would need to
     * pass the company's id, which is not possible right now...
     */
    $list->add_function(new ListFunction(array('target' => $PH->getPage('personLinkCompanies')->id, 'name' => __('Link Companies'), 'id' => 'personLinkCompanies', 'icon' => 'add')));
    $list->add_function(new ListFunction(array('target' => $PH->getPage('personCompaniesDelete')->id, 'name' => __('Remove companies from person'), 'id' => 'personCompaniesDelete', 'icon' => 'sub', 'context_menu' => 'submit')));
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT) {
        $list->no_items_html = $PH->getLink('personLinkCompanies', __('link existing Company'), array('person' => $person->id)) . " " . __("or") . " " . $PH->getLink('companyNew', __('create new'), array('person' => $person->id));
    } else {
        $list->no_items_html = __("no companies related");
    }
    #$list->no_items_html=__("no company");
    $list->render_list($companies);
    echo new PageContentNextCol();
    #--- description ----------------------------------------------------------------
    if ($person->description != "") {
        $block = new PageBlock(array('title' => __('Person details'), 'id' => 'persondetails'));
        $block->render_blockStart();
        echo "<div class=text>";
        echo wikifieldAsHtml($person, 'description');
        echo "</div>";
        $block->render_blockEnd();
    }
    /**
     *  \Note: passing colum to person->getProject is not simple...
     *  the sql-querry currently just querry project-people, which do not contain anything usefull
     *  Possible solutions:
     *   - rewrite the querry-string
     *   - rewrite all order-keys to something like company.name
     */
    $order_by = get('sort_' . $PH->cur_page->id . "_projects");
    require_once confGet('DIR_STREBER') . 'lists/list_projects.inc.php';
    $projects = $person->getProjects($order_by);
    if ($projects || $person->can_login) {
        $list = new ListBlock_projects();
        $list->title = __('works in Projects', 'list title for person projects');
        $list->id = "works_in_projects";
        unset($list->columns['date_closed']);
        unset($list->columns['date_start']);
        unset($list->columns['tasks']);
        unset($list->columns['efforts']);
        unset($list->functions['projDelete']);
        unset($list->functions['projNew']);
        if ($auth->cur_user->user_rights & RIGHT_PROJECT_CREATE) {
            $list->no_items_html = $PH->getLink('projNew', '', array());
        } else {
            $list->no_items_html = __("no active projects");
        }
        $list->render_list($projects);
    }
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    $list = new ListBlock_tasks(array('active_block_function' => 'list'));
    $list->query_options['assigned_to_person'] = $person->id;
    unset($list->columns['created_by']);
    unset($list->columns['planned_start']);
    unset($list->columns['assigned_to']);
    $list->title = __('Assigned tasks');
    $list->no_items_html = __('No open tasks assigned');
    if (isset($list->block_functions['tree'])) {
        unset($list->block_functions['tree']);
        $list->block_functions['grouped']->default = true;
    }
    $list->print_automatic();
    ### add company-id ###
    # note: some pageFunctions like personNew can use this for automatical linking
    #
    echo "<input type='hidden' name='person' value='{$person->id}'>";
    #echo "<a href=\"javascript:document.my_form.go.value='tasksMoveToFolder';document.my_form.submit();\">move to task-folder</a>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemple #30
0
/**
* View details of a file (versions, etc) @ingroup pages
*/
function fileView()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
    ### get object ####
    $file_id = getOnePassedId('file');
    if (!($file = File::getVisibleById($file_id))) {
        $PH->abortWarning("invalid file-id", ERROR_FATAL);
    }
    $file_org = $file->getOriginal();
    if ($file->is_latest) {
        $file_latest = $file;
    } else {
        $file_latest = $file->getLatest();
    }
    if (!($project = Project::getVisibleById($file->project))) {
        $PH->abortWarning("invalid project-id", ERROR_FATAL);
    }
    /**
     * parent item (not implemented yet)
     */
    $parent_task = NULL;
    if ($file->parent_item) {
        #trigger_error('@@@not implemented yet', E_USER_ERROR);
        if (!($parent_task = Task::getVisibleById(intval($file->parent_item)))) {
            $PH->messages[] = sprintf(__("Could not access parent task Id:%s"), $file->parent_item);
        }
    }
    ### create from handle ###
    $from_handle = $PH->defineFromHandle(array('file' => $file->id));
    ## is viewed by user ##
    $file->nowViewedByUser();
    $page = new Page();
    initPageForFile($page, $file, $project);
    #$page->title_minor=sprintf('#%d', $file_org->id);;
    if ($file->state == -1) {
        $page->title_minor = sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($file->deleted));
    }
    ### page functions ###
    $page->add_function(new PageFunction(array('target' => 'fileEdit', 'params' => array('file' => $file->id), 'icon' => 'edit', 'tooltip' => __('Edit this file'), 'name' => __('Edit'))));
    $page->add_function(new PageFunction(array('target' => 'filesMoveToFolder', 'params' => array("file" => $file->id), 'tooltip' => __('Move this file to another task'), 'name' => __('Move'))));
    if ($auth->cur_user->settings & USER_SETTING_ENABLE_BOOKMARKS) {
        $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $file->id));
        if (!$item || $item[0]->is_bookmark == 0) {
            $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('file' => $file->id), 'tooltip' => __('Mark this file as bookmark'), 'name' => __('Bookmark'))));
        } else {
            $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('file' => $file->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark'))));
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Upload new version', 'block title'), 'id' => 'summary'));
    $block->render_blockStart();
    echo "<div class=text>";
    echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . confGet('FILE_UPLOAD_SIZE_MAX') . '" />';
    echo '<input id="userfile" name="userfile" type="file" size="40" accept="*" />';
    echo '<input type="submit" value="' . __('Upload') . '" />';
    echo '</div>';
    $block->render_blockEnd();
    $block = new PageBlock(array('title' => sprintf(__('Version #%s (current): %s'), $file_latest->version, $file_latest->name), 'id' => 'description'));
    $block->render_blockStart();
    echo "<div class=text>";
    ### show thumbnail
    if ($file_latest->mimetype == "image/png" || $file_latest->mimetype == "image/x-png" || $file_latest->mimetype == "image/jpeg" || $file_latest->mimetype == "image/gif") {
        echo "<div class=image style='float:right;'><a href='index.php?go=fileDownloadAsImage&amp;file={$file_latest->id}'>";
        echo "<img src='index.php?go=fileDownloadAsImage&amp;file={$file_latest->id}&amp;max_size=128'>";
        echo "</a></div>";
    }
    if ($parent_task) {
        echo "<div class=labeled><label>" . __('For task') . "</label><span>" . $parent_task->getLink(false) . "</span></div>";
    }
    echo "<div class=labeled><label>" . __('Filesize') . "</label><span>{$file_latest->filesize} bytes</span></div>";
    echo "<div class=labeled><label>" . __('Type') . "</label><span>{$file_latest->mimetype}</span></div>";
    echo "<div class=labeled><label>" . __('Uploaded') . "</label><span>" . renderDateHtml($file_latest->created) . "</span></div>";
    if ($uploader = Person::getVisibleById($file->created_by)) {
        echo "<div class=labeled><label>" . __('Uploaded by') . "</label><span>" . $uploader->getLink() . "</span></div>";
    }
    if ($file_latest->created != $file_latest->modified) {
        echo "<div class=labeled><label>" . __('Modified') . "</label><span>" . renderDateHtml($file_latest->created) . "</span></div>";
    }
    echo "<div class=labeled><label>" . __('Download') . "</label><span>" . $PH->getLink('fileDownload', $file_latest->org_filename, array('file' => $file_latest->id)) . "</span></div>";
    $str = wikifieldAsHtml($file_latest, 'description');
    echo "<br>";
    echo "{$str}";
    echo "</div>";
    $block->render_blockEnd();
    /**
     * build list of old versions,
     * because org_file is zero for the original file, with have to append it
     */
    $old_files = File::getAll(array('latest_only' => false, 'org_file' => $file_org->id, 'order_by' => 'version DESC', 'project' => $project->id));
    if ($file_latest->id != $file_org->id) {
        $old_files[] = $file_org;
    }
    foreach ($old_files as $of) {
        if ($of->id != $file_latest->id) {
            $block = new PageBlock(array('title' => sprintf(__('Version #%s : %s'), $of->version, $of->name), 'id' => 'version_' . $of->id));
            $block->render_blockStart();
            echo "<div class=text>";
            ### show thumbnail
            if ($of->mimetype == "image/png" || $of->mimetype == "image/x-png" || $of->mimetype == "image/jpeg" || $of->mimetype == "image/gif") {
                echo "<div class=image style='float:right;'><a href='index.php?go=fileDownloadAsImage&file={$of->id}'>";
                echo "<img src='index.php?go=fileDownloadAsImage&file={$of->id}&max_size=128'>";
                echo "</a></div>";
            }
            $str = wikifieldAsHtml($of, 'description');
            echo "{$str}";
            echo "<div class=labeled><label>" . __('Filesize') . "</label><span>{$of->filesize} bytes</span></div>";
            echo "<div class=labeled><label>" . __('Type') . "</label><span>{$of->mimetype}</span></div>";
            echo "<div class=labeled><label>" . __('Uploaded') . "</label><span>" . renderDateHtml($of->created) . "</span></div>";
            #echo "<div class=labeled><label>" . __('Version') .  "</label><span>". intval($of->version) ."</span></div>";
            echo "<div class=labeled>" . $PH->getLink('fileDownload', '', array('file' => $of->id)) . "</div>";
            echo "</div>";
            $block->render_blockEnd();
        }
    }
    $PH->go_submit = 'fileUpdate';
    /**
     * list comments
     * NOTE: can files have comments?
     */
    /*
    {
        $comments= $file->getComments();
        $list=new ListBlock_comments();
        $list->no_items_html=$PH->getLink('commentNew','',array('parent_task'=>$task->id));
        $list->render_list($comments);
    }
    */
    echo '<input type="hidden" name="prj"  value="' . $file->project . '">';
    echo '<input type="hidden" name="org_file" value="' . $file->id . '">';
    /**
     * 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();
}