Example #1
0
 /**
  * tries to build a valid a href-link to an item.
  *
  * - uses $this->name
  * - sets -this-html
  * - does all the neccessary security checks, styles and conversions
  */
 static function renderLinkFromItemId($target_id, $name = "")
 {
     global $PH;
     $target_id = intval($target_id);
     $html = "";
     if (!($item = DbProjectItem::getVisibleById($target_id))) {
         $html = '<em>' . sprintf(__("Unkwown item %s"), $target_id) . '</em>';
     } else {
         switch ($item->type) {
             case ITEM_TASK:
                 if ($task = Task::getVisibleById($item->id)) {
                     $style_isdone = $task->status >= STATUS_COMPLETED ? 'isDone' : '';
                     if ($name) {
                         $html = $PH->getLink('taskView', $name, array('tsk' => $task->id), $style_isdone, true);
                     } else {
                         $html = $task->getLink(false);
                     }
                 }
                 break;
             case ITEM_FILE:
                 require_once confGet('DIR_STREBER') . "db/class_file.inc.php";
                 if ($file = File::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('fileDownloadAsImage', $name, array('file' => $file->id), NULL, true);
                     } else {
                         $html = $PH->getLink('fileDownloadAsImage', $file->name, array('file' => $file->id));
                     }
                 }
                 break;
             case ITEM_COMMENT:
                 require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
                 if ($comment = Comment::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('commentView', $name, array('comment' => $comment->id), NULL, true);
                     } else {
                         $html = $PH->getLink('commentView', $comment->name, array('comment' => $comment->id));
                     }
                 }
                 break;
             case ITEM_PERSON:
                 if ($person = Person::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('personView', $name, array('person' => $person->id), NULL, true);
                     } else {
                         $html = $PH->getLink('personView', $person->name, array('person' => $person->id));
                     }
                 }
                 break;
             case ITEM_PROJECT:
                 if ($project = Project::getVisibleById($item->id)) {
                     if ($name == "") {
                         $name = asHtml($project->name);
                     }
                     $html = $PH->getLink('projView', $name, array('prj' => $project->id), NULL, true);
                 }
                 break;
             default:
                 $html = '<em>' . sprintf(__('Cannot link to item #%s of type %s'), intval($target_id), $item->type) . '</em>';
                 break;
         }
     }
     return $html;
 }
Example #2
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;
     }
 }
 function render_tr(&$item, $style = "")
 {
     global $PH;
     $str_url = "";
     $str_name = "";
     $str_addon = "";
     $isDone = "";
     $html_details = "";
     $link = "";
     if ($type = $item->type) {
         switch ($type) {
             case ITEM_TASK:
                 require_once "db/class_task.inc.php";
                 if ($task = Task::getVisibleById($item->id)) {
                     $str_name = asHtml($task->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $task->id));
                     if ($task->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($task->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                         if ($tmp = $task->getFolderLinks()) {
                             $html_details .= ' > ' . $tmp;
                         }
                     }
                 }
                 break;
             case ITEM_COMMENT:
                 require_once "db/class_comment.inc.php";
                 if ($comment = Comment::getVisibleById($item->id)) {
                     $str_name = asHtml($comment->name);
                     if ($comment->comment) {
                         $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                         $str_addon = __("(on comment)");
                     } else {
                         if ($comment->task) {
                             $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                             $str_addon = __("(on task)");
                         } else {
                             $str_url = $PH->getUrl('projView', array('prj' => $comment->project));
                             $str_addon = __("(on project)");
                         }
                     }
                 }
                 break;
             case ITEM_PERSON:
                 require_once "db/class_person.inc.php";
                 if ($person = Person::getVisibleById($item->id)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 break;
             case ITEM_EFFORT:
                 require_once "db/class_effort.inc.php";
                 if ($e = Effort::getVisibleById($item->id)) {
                     $str_name = asHtml($e->name);
                     $str_url = $PH->getUrl('effortEdit', array('effort' => $e->id));
                 }
                 if ($prj = Project::getVisibleById($e->project)) {
                     $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                     $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                 }
                 break;
             case ITEM_FILE:
                 require_once "db/class_file.inc.php";
                 if ($f = File::getVisibleById($item->id)) {
                     $str_name = asHtml($f->org_filename);
                     $str_url = $PH->getUrl('fileView', array('file' => $f->id));
                     if ($f->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($f->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                     }
                 }
                 break;
             case ITEM_PROJECT:
                 require_once "db/class_project.inc.php";
                 if ($prj = Project::getVisibleById($item->id)) {
                     $str_name = asHtml($prj->name);
                     $str_url = $PH->getUrl('projView', array('prj' => $prj->id));
                     if ($prj->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                 }
                 break;
             case ITEM_COMPANY:
                 require_once "db/class_company.inc.php";
                 if ($c = Company::getVisibleById($item->id)) {
                     $str_name = asHtml($c->name);
                     $str_url = $PH->getUrl('companyView', array('company' => $c->id));
                 }
                 break;
             case ITEM_VERSION:
                 require_once "db/class_task.inc.php";
                 if ($tsk = Task::getVisibleById($item->id)) {
                     $str_name = asHtml($tsk->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $tsk->id));
                     if ($tsk->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($task->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                     }
                 }
                 break;
             default:
                 break;
         }
         print "<td class='nowrap'><span {$isDone}><a href='{$str_url}'>{$str_name}</a> {$str_addon}</span>";
         if ($html_details) {
             print "<br><span class='sub who'>{$html_details}</span>";
         }
         print "</td>";
     } else {
         $PH->abortWarning("Could not get type of the element.", ERROR_BUG);
         print "<td>&nbsp;</td>";
     }
 }
Example #4
0
 /**
  * returns the original version of a file (could be itself)
  */
 public function getOriginal()
 {
     if ($this->org_file == 0) {
         return $this;
     }
     if ($org_file = File::getVisibleById($this->org_file)) {
         # NOTE: this is slow!
         return $org_file;
     } else {
         trigger_error("failed to get original file of {$file->id}", E_USER_WARNING);
         return NULL;
     }
 }
 static function getChangeLines($query_options)
 {
     global $PH;
     global $auth;
     fillMissingValues($query_options, array('alive_only' => false));
     $date_compare = isset($query_options['date_min']) ? $query_options['date_min'] : "0000-00-00";
     /**
      * get list of items touched by other people
      */
     $changed_items = DbProjectItem::getAll($query_options);
     /**
      * go through list
      */
     $changes = array();
     foreach ($changed_items as $i) {
         $change_type = NULL;
         if (!isset($query_options['project'])) {
             $project = Project::getVisibleById($i->project);
         } else {
             $project = NULL;
         }
         /**
          * get item-change-type depeding on dates
          */
         if ($i->deleted >= $i->modified) {
             $change_type = ITEM_DELETED;
         } else {
             if ($i->modified > $i->created) {
                 $change_type = ITEM_MODIFIED;
             } else {
                 $change_type = ITEM_NEW;
             }
         }
         /**
          * build up change-list
          */
         switch ($change_type) {
             case ITEM_NEW:
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     if ($task->prio != PRIO_NORMAL && $task->prio != PRIO_UNDEFINED) {
                         global $g_prio_names;
                         $html_details .= ' / ' . $g_prio_names[$task->prio];
                     }
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => '<span class=new>' . __('new') . ' ' . $task->getLabel() . '</span>', 'txt_what' => __('new') . ' ' . $task->getLabel(), 'type' => ChangeLine::NEW_TASK, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('New file'), 'txt_what' => __('New file'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_MODIFIED:
                 $timestamp_last_change = $date_compare;
                 # make sure we use the last occured change type
                 /**
                  * modified tasks
                  */
                 $type = ChangeLine::UPDATED;
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $txt_what = $html_what = __('modified');
                     $type = ChangeLine::UPDATED;
                     $html_comment = '';
                     if ($comments = Comment::getAll(array('person' => $i->modified_by, 'task' => $task->id, 'date_min' => $timestamp_last_change, 'order_by' => 'created ASC'))) {
                         $last_comment = $comments[count($comments) - 1];
                         $timestamp_last_change = $last_comment->created;
                         if ($last_comment->name && $last_comment->name != __('New Comment')) {
                             # ignore default title
                             $html_comment = strip_tags($last_comment->name) . ': ';
                         }
                         $html_comment .= strip_tags($last_comment->description);
                         $html_comment = asHtml($html_comment);
                     }
                     ### get changed fields ###
                     $changed_fields_hash = array();
                     $html_functions = false;
                     if ($changed_fields_list = ItemChange::getItemChanges(array('item' => $i->id, 'person' => $i->modified_by, 'date_min' => $date_compare))) {
                         foreach ($changed_fields_list as $cf) {
                             $changed_fields_hash[$cf->field] = $cf;
                         }
                         if (isset($changed_fields_hash['status'])) {
                             $status_old = $changed_fields_hash['status']->value_old;
                             if ($task->status == STATUS_COMPLETED && $task->status > $status_old) {
                                 $txt_what = $html_what = __('completed') . ' ' . $task->getLabel();
                                 $html_functions = $PH->getLink('tasksApproved', __('Approve Task'), array('tsk' => $task->id));
                                 unset($changed_fields_hash['status']);
                             } else {
                                 if ($task->status == STATUS_APPROVED && $task->status > $status_old) {
                                     $txt_what = $html_what = __('approved');
                                     unset($changed_fields_hash['status']);
                                 } else {
                                     if ($task->status == STATUS_CLOSED && $task->status > $status_old) {
                                         $txt_what = $html_what = __('closed');
                                         unset($changed_fields_hash['status']);
                                     } else {
                                         if ($task->status == STATUS_OPEN && $task->status < $status_old) {
                                             $txt_what = $html_what = __('reopened');
                                             unset($changed_fields_hash['status']);
                                         } else {
                                             if ($task->status == STATUS_OPEN) {
                                                 unset($changed_fields_hash['status']);
                                             } else {
                                                 if ($task->status == STATUS_BLOCKED) {
                                                     $txt_what = $html_what = __('is blocked');
                                                     unset($changed_fields_hash['status']);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (isset($changed_fields_hash['parent_task'])) {
                         $txt_what = $html_what = __('moved');
                         $type = ChangeLine::MOVED;
                         unset($changed_fields_hash['parent_task']);
                     } else {
                         if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['name'])) {
                             $txt_what = $html_what = __('renamed');
                             $type = ChangeLine::RENAMED;
                         } else {
                             if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['description'])) {
                                 $txt_what = $html_what = __('edit wiki');
                                 $type = ChangeLine::EDITED_WIKI;
                             } else {
                                 if (count($changed_fields_hash)) {
                                     # status does not count
                                     $html_details .= ' / ' . __('changed:') . ' ' . implode(', ', array_keys($changed_fields_hash));
                                 } else {
                                     if ($html_comment) {
                                         $txt_what = $html_what = __('commented');
                                         $type = ChangeLine::COMMENTED;
                                     }
                                 }
                             }
                         }
                     }
                     if ($html_comment) {
                         $html_details .= ' / ' . $html_comment;
                     }
                     /**
                      * any recents assignments ?
                      * - to avoid confusion only list assignmets if it was to last action,
                      *
                      */
                     require_once "db/class_taskperson.inc.php";
                     $count_assignments = 0;
                     if ($assignments = TaskPerson::getTaskPeople(array('task' => $task->id, 'project' => $task->project, 'date_min' => $task->modified))) {
                         $t_timestamp = '';
                         foreach ($assignments as $a) {
                             if ($a->person != $task->modified_by && $a->created_by == $task->modified_by && $a->assigntype != ASSIGNTYPE_INITIAL) {
                                 $t_timestamp = $a->created;
                                 $count_assignments++;
                             }
                         }
                         if ($count_assignments && $timestamp_last_change < $t_timestamp) {
                             $type = ChangeLine::ASSIGNED;
                             $txt_what = $html_what = __('assigned');
                             $timestamp_last_change = $t_timestamp;
                         }
                         if ($html_comment) {
                             $html_details .= ' / ' . $html_comment;
                         }
                     }
                     /**
                      * any recents attachments by last editor ?
                      */
                     require_once "db/class_file.inc.php";
                     if ($files = File::getAll(array('parent_item' => $task->id, 'project' => $task->project, 'date_min' => $date_compare, 'created_by' => $task->modified_by))) {
                         $count_attached_files = 0;
                         $html_attached = __("attached") . ": ";
                         $t_timestamp = '';
                         $separator = '';
                         foreach ($files as $f) {
                             if ($task->modified_by == $f->modified_by) {
                                 $t_timestamp = $f->created;
                                 $count_attached_files++;
                                 $html_attached .= $separator . $PH->getLink('fileView', $f->name, array('file' => $f->id));
                                 $separator = ', ';
                             }
                         }
                         if ($count_attached_files) {
                             $type = ChangeLine::ATTACHED_FILE;
                             $txt_what = $html_what = __('attached file to');
                             if ($timestamp_last_change < $t_timestamp) {
                                 $html_details .= ' / ' . $html_attached;
                                 $timestamp_last_change = $t_timestamp;
                             }
                         }
                     }
                     if (count($changed_fields_hash)) {
                         $html_details .= " / " . $PH->getLink('itemViewDiff', NULL, array('item' => $task->id, 'date1' => $date_compare, 'date2' => gmdate("Y-m-d H:i:s")));
                     }
                     if ($html_functions) {
                         $html_details .= " | " . $html_functions;
                     }
                     $change = new ChangeLine(array('person_by' => $i->modified_by, 'timestamp' => $i->modified, 'item_id' => $i->id, 'item' => $task, 'type' => $type, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('changed File'), 'txt_what' => __('changed File'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_DELETED:
                 /**
                  * deleted tasks
                  */
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $html_details .= '|' . $PH->getLink('itemsRestore', __('restore'), array('item' => $task->id));
                     $txt_what = $html_what = __('deleted');
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->deleted_by, 'timestamp' => $i->deleted, 'item_id' => $i->id, 'type' => ChangeLine::DELETED, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('deleted File'), 'txt_what' => ChangeLine::DELETED, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             default:
                 trigger_error("unknown change-type {$change_type}", E_USER_WARNING);
                 break;
         }
     }
     return $changes;
 }
Example #6
0
/**
* edit several bookmarks @ingroup pages
*/
function itemBookmarkEditMultiple($thebookmarks = NULL)
{
    global $PH;
    global $auth;
    global $g_notitychange_period;
    $is_already_bookmark = array();
    $bookmarks = array();
    $items = array();
    $edit_fields = array('notify_if_unchanged', 'notify_on_change');
    $different_fields = array();
    # hash containing fieldnames which are different in bookmarks
    if (!$thebookmarks) {
        $item_ids = getPassedIds('bookmark', 'bookmarks_*');
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            }
        }
    } else {
        $item_ids = $thebookmarks;
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 0))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = false;
                }
            } elseif ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            } else {
                $date = getGMTString();
                $bookmark = new ItemPerson(array('id' => 0, 'item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1, 'notify_if_unchanged' => 0, 'notify_on_change' => 0, 'created' => $date));
                if ($item = DbProjectItem::getById($is)) {
                    $bookmarks[] = $bookmark;
                    $items[] = $item;
                    $is_already_bookmark[$bookmark->id] = false;
                }
            }
        }
    }
    if (!$items) {
        $PH->abortWarning(__("Please select some items"));
    }
    $page = new Page();
    $page->cur_tab = 'home';
    $page->options = array(new NaviOption(array('target_id' => 'itemBookmarkEdit', 'name' => __('Edit bookmarks'))));
    $page->type = __('Edit multiple bookmarks', 'page title');
    $page->title = sprintf(__('Edit %s bookmark(s)'), count($items));
    $page->title_minor = __('Edit');
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($items as $item) {
        ## get item name ##
        $str_link = '';
        if ($type = $item->type) {
            switch ($type) {
                case ITEM_TASK:
                    require_once "db/class_task.inc.php";
                    if ($task = Task::getVisibleById($item->id)) {
                        $str_link = $task->getLink(false);
                    }
                    break;
                case ITEM_COMMENT:
                    require_once "db/class_comment.inc.php";
                    if ($comment = Comment::getVisibleById($item->id)) {
                        $str_link = $comment->getLink(false);
                    }
                    break;
                case ITEM_PERSON:
                    require_once "db/class_person.inc.php";
                    if ($person = Person::getVisibleById($item->id)) {
                        $str_link = $person->getLink(false);
                    }
                    break;
                case ITEM_EFFORT:
                    require_once "db/class_effort.inc.php";
                    if ($e = Effort::getVisibleById($item->id)) {
                        $str_link = $e->getLink(false);
                    }
                    break;
                case ITEM_FILE:
                    require_once "db/class_file.inc.php";
                    if ($f = File::getVisibleById($item->id)) {
                        $str_link = $f->getLink(false);
                    }
                    break;
                case ITEM_PROJECT:
                    require_once "db/class_project.inc.php";
                    if ($prj = Project::getVisibleById($item->id)) {
                        $str_link = $prj->getLink(false);
                    }
                    break;
                case ITEM_COMPANY:
                    require_once "db/class_company.inc.php";
                    if ($c = Company::getVisibleById($item->id)) {
                        $str_link = $c->getLink(false);
                    }
                    break;
                case ITEM_VERSION:
                    require_once "db/class_task.inc.php";
                    if ($tsk = Task::getVisibleById($item->id)) {
                        $str_link = $tsk->getLink(false);
                    }
                    break;
                default:
                    break;
            }
        }
        echo "<li>" . $str_link . "</li>";
    }
    echo "</ol>";
    foreach ($bookmarks as $bookmark) {
        foreach ($edit_fields as $field_name) {
            if ($bookmark->{$field_name} != $bookmarks[0]->{$field_name}) {
                $different_fields[$field_name] = true;
            }
        }
    }
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $b = array();
    $b[0] = __('no');
    $b[1] = __('yes');
    if (isset($different_fields['notify_on_change'])) {
        $b[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), -1));
    } else {
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), $bookmarks[0]->notify_on_change));
    }
    $a = array();
    foreach ($g_notitychange_period as $key => $value) {
        $a[$key] = $value;
    }
    if (isset($different_fields['notify_if_unchanged'])) {
        $a[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), -1));
    } else {
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), $bookmarks[0]->notify_if_unchanged));
    }
    $number = 0;
    foreach ($bookmarks as $bm) {
        $form->add(new Form_HiddenField("bookmark_id_{$number}", '', $bm->id));
        $form->add(new Form_HiddenField("bookmark_item_{$number}", '', $bm->item));
        $form->add(new Form_HiddenField("is_already_bookmark_{$number}", '', $is_already_bookmark[$bm->id]));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'itemBookmarkEditMultipleSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Example #7
0
/**
* move files to folder...
*
* NOTE: this works either...
* - directly by passing a target folder in 'folder' or 'folders_*'
* - in two steps, whereas
*   - the passed task-ids are keept as hidden fields,
*   - a list with folders is been rendered
*   - a flag 'from_selection' is set
*   - after submit, the kept tasks are moved to 'folders_*'
*
*/
function FilesMoveToFolder()
{
    global $PH;
    $file_ids = getPassedIds('file', 'files_*');
    if (!$file_ids) {
        $PH->abortWarning(__("Select some files to move"));
        exit;
    }
    /**
     * by default render list of folders...
     */
    $target_id = -1;
    /**
     * ...but, if folder was given, directly move files...
     */
    $folder_ids = getPassedIds('folder', 'folders_*');
    if (count($folder_ids) == 1) {
        if ($folder_task = Task::getVisibleById($folder_ids[0])) {
            $target_id = $folder_task->id;
        }
    } else {
        if (get('from_selection')) {
            $target_id = 0;
        }
    }
    if ($target_id != -1) {
        if ($target_id != 0) {
            if (!($target_task = Task::getEditableById($target_id))) {
                $PH->abortWarning(__("insufficient rights"));
            }
            ### get path of target to check for cycles ###
            $parent_tasks = $target_task->getFolder();
            $parent_tasks[] = $target_task;
        } else {
            $parent_tasks = array();
        }
        $count = 0;
        foreach ($file_ids as $id) {
            if ($file = File::getEditableById($id)) {
                $file->parent_item = $target_id;
                $file->update();
            } else {
                $PH->messages[] = sprintf(__("Can not edit file %s"), $file->name);
            }
        }
        ### return to from-page? ###
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    #else if($target_id != -1) {
    #    $PH->abortWarning(__("insufficient rights to edit any of the selected items"));
    #}
    /**
     * build page folder lists...
     */
    ### get project ####
    if (!($file = File::getVisibleById($file_ids[0]))) {
        $PH->abortWarning("could not get file", ERROR_BUG);
    }
    if (!($project = Project::getVisibleById($file->project))) {
        $PH->abortWarning("file without project?", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'company_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit files");
    $page->title = "{$project->name}";
    $page->title_minor = __("Select folder to move files into");
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'filesMoveToFolder'));
    echo new PageHeader();
    echo new PageContentOpen();
    ### write files as hidden entry ###
    foreach ($file_ids as $id) {
        if ($file = File::getEditableById($id)) {
            echo "<input type=hidden name='files_{$id}_chk' value='1'>";
        }
    }
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    $list = new ListBlock_tasks();
    $list->query_options['show_folders'] = true;
    #$list->query_options['folders_only']= true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    $list->no_items_html = __('No folders available');
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    unset($list->columns['project']);
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project, NULL);
    echo __("(or select nothing to move to project root)") . "<br> ";
    echo "<input type=hidden name='from_selection' value='1'>";
    # keep flag to ungroup files
    echo "<input type=hidden name='project' value='{$project->id}'>";
    $button_name = __("Move items");
    echo "<input class=button2 type=submit value='{$button_name}'>";
    $PH->go_submit = 'filesMoveToFolder';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Example #8
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     $str_url = "";
     $str_name = "";
     $str_addon = "";
     switch ($obj->type) {
         case ITEM_PROJECT:
             if ($project = Project::getVisibleById($obj->id)) {
                 $str_name = asHtml($project->name);
                 $str_url = $PH->getUrl('projView', array('prj' => $project->id));
             }
             break;
         case ITEM_TASK:
             if ($task = Task::getVisibleById($obj->id)) {
                 $str_name = asHtml($task->name);
                 $str_url = $PH->getUrl('taskView', array('tsk' => $task->id));
                 if ($project = Project::GetVisibleById($task->project)) {
                     $str_addon = "(" . $project->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_COMMENT:
             if ($comment = Comment::getVisibleById($obj->id)) {
                 if ($comment->name == '') {
                     $str_name = "-";
                 } else {
                     $str_name = asHtml($comment->name);
                 }
                 $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                 $str_addon .= "(";
                 if ($task = Task::getVisibleById($comment->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= $project->getLink(false) . " > ";
                     }
                     $str_addon .= $task->getLink(false);
                     if ($comment->comment) {
                         if ($comm = Comment::getVisibleById($comment->comment)) {
                             $str_addon .= " > " . $comm->name;
                         }
                     }
                 }
                 $str_addon .= ")";
             }
             break;
         case ITEM_COMPANY:
             if ($c = Company::getVisibleById($obj->id)) {
                 $str_name = asHtml($c->name);
                 $str_url = $PH->getUrl('companyView', array('company' => $c->id));
             }
             break;
         case ITEM_PERSON:
             if ($person = Person::getVisibleById($obj->id)) {
                 $str_name = asHtml($person->name);
                 $str_url = $PH->getUrl('personView', array('person' => $person->id));
             }
             break;
         case ITEM_PROJECTPERSON:
             if ($pp = ProjectPerson::getVisibleById($obj->id)) {
                 if (!($person = new Person($pp->person))) {
                     $PH->abortWarning("ProjectPerson has invalid person-pointer!", ERROR_BUG);
                 }
                 $str_name = asHtml($person->name);
                 $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 if ($project = Project::getVisibleById($pp->project)) {
                     $str_addon = "(" . $project->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_EMPLOYMENT:
             if ($emp = Employment::getById($obj->id)) {
                 if ($person = Person::getVisibleById($emp->person)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 if ($company = Company::getVisibleById($emp->company)) {
                     $str_addon = "(" . $company->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_EFFORT:
             if ($e = Effort::getVisibleById($obj->id)) {
                 $str_name = asHtml($e->name);
                 $str_url = $PH->getUrl('effortEdit', array('effort' => $e->id));
                 if ($task = Task::getVisibleById($e->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= "(" . $project->getLink(false);
                         $str_addon .= " > " . $task->getLink(false) . ")";
                     }
                 }
             }
             break;
         case ITEM_FILE:
             if ($f = File::getVisibleById($obj->id)) {
                 $str_name = asHtml($f->org_filename);
                 $str_url = $PH->getUrl('fileView', array('file' => $f->id));
                 $str_addon .= "(";
                 if ($p = Project::getVisibleById($f->project)) {
                     $str_addon .= $p->getLink(false);
                 }
                 if ($t = Task::getVisibleById($f->parent_item)) {
                     $str_addon .= " > " . $t->getLink(false);
                 }
                 $str_addon .= ")";
             }
             break;
         case ITEM_ISSUE:
             if ($i = Issue::getVisibleById($obj->id)) {
                 if ($t = Task::getVisibleById($i->task)) {
                     $str_name = asHtml($t->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $t->id));
                     if ($p = Project::getVisibleById($t->project)) {
                         $str_addon .= "(" . $p->getLink(false) . ")";
                     }
                 }
             }
             break;
         case ITEM_TASKPERSON:
             if ($tp = TaskPerson::getVisibleById($obj->id)) {
                 if ($person = Person::getVisibleById($tp->person)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 if ($task = Task::getVisibleById($tp->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= "(" . $project->getLink(false);
                         $str_addon .= " > " . $task->getLink(false) . ")";
                     }
                 }
             }
             break;
         default:
             break;
     }
     print "<td><a href='{$str_url}'>{$str_name}</a><span class='sub who'> {$str_addon}</span></td>";
 }