当前位置: 首页>>代码示例>>PHP>>正文


PHP Person::getVisibleById方法代码示例

本文整理汇总了PHP中Person::getVisibleById方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::getVisibleById方法的具体用法?PHP Person::getVisibleById怎么用?PHP Person::getVisibleById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Person的用法示例。


在下文中一共展示了Person::getVisibleById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __toString

 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 '';
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:36,代码来源:project_news_block.inc.php

示例2: projectPersonEdit

/**
* 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}'>";
//.........这里部分代码省略.........
开发者ID:Bremaweb,项目名称:streber-1,代码行数:101,代码来源:projectperson.inc.php

示例3: personRevertChanges

/**
* 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();
}
开发者ID:Bremaweb,项目名称:streber-1,代码行数:79,代码来源:personRevertChanges.inc.php

示例4: renderLinkFromItemId

 /**
  * 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;
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:70,代码来源:render_wiki.inc.php

示例5: render_tr

 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>";
     }
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:25,代码来源:list_bookmarks.inc.php

示例6: render_tr

 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>";
     }
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:70,代码来源:list_effortsprojectcalculation.inc.php

示例7: updateRSS

 /**
  * 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);
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:88,代码来源:class_rss.inc.php

示例8: getObjectById

 /**
  * 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;
     }
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:59,代码来源:db_item.inc.php

示例9: itemViewDiff

/**
* 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);
//.........这里部分代码省略.........
开发者ID:Bremaweb,项目名称:streber-1,代码行数:101,代码来源:item.inc.php

示例10: projAddPersonSubmit

/**
* 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));
    }
}
开发者ID:Bremaweb,项目名称:streber-1,代码行数:62,代码来源:project_more.inc.php

示例11: storeUserCookie

 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;
         }
     }
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:20,代码来源:class_auth.inc.php

示例12: effortEditSubmit

/**
* 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) {
//.........这里部分代码省略.........
开发者ID:Bremaweb,项目名称:streber-1,代码行数:101,代码来源:effort.inc.php

示例13: renderListCsv

 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);
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:95,代码来源:render_list.inc.php

示例14: companyEditSubmit

/**
* 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());
    }
}
开发者ID:Bremaweb,项目名称:streber-1,代码行数:75,代码来源:company.inc.php

示例15: render_quickedit

 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')) {
//.........这里部分代码省略.........
开发者ID:Bremaweb,项目名称:streber-1,代码行数:101,代码来源:task_view.inc.php


注:本文中的Person::getVisibleById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。