Inheritance: extends Block
Exemplo n.º 1
0
/**
* Shown, if unknown page-id requested
*
* @ingroup pages
*
* \TODO this should only trigger an error and relay to home
* \TODO removing this function would make renderBacktrace() obsolete, too
*/
function error()
{
    global $PH;
    require_once confGet('DIR_STREBER') . 'render/render_list.inc.php';
    $page = new Page();
    $page->tabs['error'] = array('target' => "index.php?go=error", 'title' => __('Error', 'top navigation tab'), 'bg' => "error");
    $page->cur_tab = 'error';
    $page->title = __("Unknown Page");
    $page->type = __("Error");
    $page->title_minor = get('go');
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Error'), 'id' => 'error'));
    $block->render_blockStart();
    echo "<div class=text>";
    echo "<p>Sorry but you found a function that has not yet been implemented.<br>";
    echo "If you feel this a bug, or a very important function is missing, please help us to fix this,\r\n    Please hit the back-button of your browser and use the 'Wiki + Help' option to follow to the online\r\n    documentation. Then edit 'issue' or 'request-part'.</p>";
    echo "</div>";
    ### Show traceback only for admins
    if ($auth->cur_user->user_rights & RIGHT_VIEWALL) {
        $block->render_blockEnd();
        $block = new PageBlock(array('title' => 'Details', 'id' => 'details'));
        $block->render_blockStart();
        echo "<div class=text>";
        echo "<pre>";
        echo renderBacktrace(debug_backtrace());
        echo "</pre>";
        echo "</div>";
        $block->render_blockEnd();
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 2
0
 protected function renderContent()
 {
     $model = new Page();
     //If it has guid, it means this is a translated version
     $guid = isset($_GET['guid']) ? strtolower(trim($_GET['guid'])) : '';
     //List of language that should exclude not to translate
     $lang_exclude = array();
     //List of translated versions
     $versions = array();
     // If the guid is not empty, it means we are creating a translated version of a content
     // We will exclude the translated language and include the name of the translated content to $versions
     if ($guid != '') {
         $page_object = Page::model()->findAll('guid=:gid', array(':gid' => $guid));
         if (count($page_object) > 0) {
             $langs = GxcHelpers::getAvailableLanguages();
             foreach ($page_object as $obj) {
                 $lang_exclude[] = $obj->lang;
                 $versions[] = $obj->name . ' - ' . $langs[$obj->lang]['name'];
             }
         }
         $model->guid = $guid;
     }
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'page-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     //Define Blocks in Regions
     $regions_blocks = array();
     // collect user input data
     if (isset($_POST['Page'])) {
         $regions_blocks = isset($_POST['Page']['regions']) ? $_POST['Page']['regions'] : array();
         $model->attributes = $_POST['Page'];
         if ($model->save()) {
             if (!empty($regions_blocks)) {
                 //Delete All Page Block Before
                 PageBlock::model()->deleteAll('page_id = :id', array(':id' => $model->page_id));
                 foreach ($regions_blocks as $key => $blocks) {
                     $order = 1;
                     for ($i = 0; $i < count($blocks['id']); $i++) {
                         $block = $blocks['id'][$i];
                         $temp_page_block = new PageBlock();
                         $temp_page_block->page_id = $model->page_id;
                         $temp_page_block->block_id = $block;
                         $temp_page_block->region = $key;
                         $temp_page_block->block_order = $order;
                         $temp_page_block->status = $blocks['status'][$i];
                         $temp_page_block->save();
                         $order++;
                     }
                 }
             }
             //Start to save the Page Block
             user()->setFlash('success', t('cms', 'Create new Page Successfully!'));
             $model = new Page();
             Yii::app()->controller->redirect(array('create'));
         }
     }
     $this->render('cmswidgets.views.page.page_form_widget', array('model' => $model, 'lang_exclude' => $lang_exclude, 'versions' => $versions, 'regions_blocks' => $regions_blocks));
 }
Exemplo n.º 3
0
/**
* render home view @ingroup pages
*/
function home()
{
    global $PH;
    global $auth;
    ### create from handle ###
    $PH->defineFromHandle(array());
    $page = new Page();
    $page->cur_tab = 'home';
    $page->options = build_home_options();
    $page->title = __("Today");
    # $auth->cur_user->name;
    $page->type = __("At Home");
    $page->title_minor = renderTitleDate(time());
    ### page functions ###
    $page->add_function(new PageFunction(array('target' => 'personEdit', 'params' => array('person' => $auth->cur_user->id), 'icon' => 'edit', 'name' => __('Edit your Profile'))));
    $page->add_function(new PageFunction(array('target' => 'personAllItemsViewed', 'params' => array('person' => $auth->cur_user->id), 'icon' => 'edit', 'name' => __('Mark all items as viewed'))));
    echo new PageHeader();
    echo new PageContentOpen_Columns();
    measure_stop('init2');
    require_once confGet('DIR_STREBER') . 'db/class_company.inc.php';
    $block = new PageBlock(array('title' => __('Active projects'), 'id' => 'projects'));
    $block->render_blockStart();
    echo "<div class=linklist>";
    /**
     * get companies
     */
    foreach (Company::getAll() as $c) {
        /**
         * get project for company
         *
         * @NOTE single sql requests are not the fastes solution here...
         */
        if ($projects = Project::getAll(array('order_by' => 'c.name', 'company' => $c->id))) {
            echo "<span class=sub>" . __("for", "short for client") . '</span> <b>' . $c->getLink() . "</b>:";
            echo '<ul>';
            foreach ($projects as $project) {
                echo '<li>' . $PH->getLink('projView', $project->name, array('prj' => $project->id)) . '</li>';
            }
            echo '</ul>';
        }
    }
    if ($projects = Project::getAll(array('order_by' => 'c.name', 'company' => 0))) {
        echo __("without client");
        echo '<ul>';
        foreach ($projects as $project) {
            echo '<li>' . $PH->getLink('projView', $project->name, array('prj' => $project->id)) . '</li>';
        }
        echo '</ul>';
    }
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentNextCol();
    if ($projects = Project::getAll(array('order_by' => 'modified DESC'))) {
        require_once confGet('DIR_STREBER') . 'lists/list_recentchanges.inc.php';
        printRecentChanges($projects);
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 4
0
 protected function renderContent()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     $model = GxcHelpers::loadDetailModel('Page', $id);
     //Guid of the Object
     $guid = $model->guid;
     //List of language that should exclude not to translate
     $lang_exclude = array();
     //List of translated versions
     $versions = array();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'page-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     //Define Blocks in Regions
     $regions_blocks = array();
     //Find all the Page Blocks of this current Page
     $page_blocks = PageBlock::model()->findAll(array('condition' => 'page_id = :pid', 'params' => array(':pid' => $model->page_id), 'order' => 'region ASC, block_order ASC'));
     foreach ($page_blocks as $pb) {
         $regions_blocks[$pb->region]['id'][] = $pb->block_id;
         $regions_blocks[$pb->region]['status'][] = $pb->status;
     }
     // collect user input data
     if (isset($_POST['Page'])) {
         $regions_blocks = isset($_POST['Page']['regions']) ? $_POST['Page']['regions'] : array();
         $model->attributes = $_POST['Page'];
         if ($model->save()) {
             if (!empty($regions_blocks)) {
                 //Delete All Page Block Before
                 PageBlock::model()->deleteAll('page_id = :id', array(':id' => $model->page_id));
                 foreach ($regions_blocks as $key => $blocks) {
                     $order = 1;
                     for ($i = 0; $i < count($blocks['id']); $i++) {
                         $block = $blocks['id'][$i];
                         $temp_page_block = new PageBlock();
                         $temp_page_block->page_id = $model->page_id;
                         $temp_page_block->block_id = $block;
                         $temp_page_block->region = $key;
                         $temp_page_block->block_order = $order;
                         $temp_page_block->status = $blocks['status'][$i];
                         $temp_page_block->save();
                         $order++;
                     }
                 }
             }
             //Start to save the Page Block
             user()->setFlash('success', t('Update Page Successfully!'));
         }
     }
     $this->render('cmswidgets.views.page.page_form_widget', array('model' => $model, 'lang_exclude' => $lang_exclude, 'versions' => $versions, 'regions_blocks' => $regions_blocks));
 }
function projViewFiles()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "render/render_wiki.inc.php";
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    $project = Project::getVisibleById($id);
    if (!$project || !$project->id) {
        $PH->abortWarning(__("invalid project-id"));
        return;
    }
    ### define from-handle ###
    $PH->defineFromHandle(array('prj' => $project->id));
    ## is viewed by user ##
    $project->nowViewedByUser();
    ## next milestone ##
    $next = $project->getNextMilestone();
    $page = new Page();
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->cur_tab = 'projects';
    $page->title = $project->name;
    $page->title_minor = __("Downloads");
    if ($project->status == STATUS_TEMPLATE) {
        $page->type = __("Project Template");
    } else {
        if ($project->status >= STATUS_COMPLETED) {
            $page->type = __("Inactive Project");
        } else {
            $page->type = __("Project", "Page Type");
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    measure_stop('init2');
    measure_start('info');
    $block = new PageBlock(array('id' => 'support'));
    $block->render_blockStart();
    echo "<div class=text>";
    if ($task = Task::getVisibleById(3645)) {
        echo wikifieldAsHtml($task, 'description');
    }
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 6
0
 function __construct($project)
 {
     parent::__construct(NULL);
     $this->project = $project;
     $this->title = __('Project News');
     $this->id = 'project_news';
 }
Exemplo n.º 7
0
 protected function renderContent()
 {
     if (isset($this->page)) {
         //get all blocks of current region, order by 'order'
         $blocks = PageBlock::model()->findAll(array('condition' => 'page_id=:paramId and region=:regionId and status=:status', 'params' => array(':paramId' => $this->page->page_id, ':regionId' => $this->region, ':status' => ConstantDefine::PAGE_BLOCK_ACTIVE), 'order' => 'block_order ASC'));
         if ($blocks) {
             foreach ($blocks as $page_block) {
                 $block = GxcHelpers::loadDetailModel('Block', $page_block->block_id);
                 if ($block) {
                     $block_ini = parse_ini_file(Yii::getPathOfAlias('common.front_blocks.' . $block->type) . DIRECTORY_SEPARATOR . 'info.ini');
                     //Include the class
                     Yii::import('common.front_blocks.' . $block->type . '.' . $block_ini['class']);
                     if ($this->data != null) {
                         $this->widget('common.front_blocks.' . $block->type . '.' . $block_ini['class'], array('block' => $block, 'page' => $this->page, 'layout_asset' => $this->layout_asset, 'data' => $this->data));
                     } else {
                         $this->widget('common.front_blocks.' . $block->type . '.' . $block_ini['class'], array('block' => $block, 'page' => $this->page, 'layout_asset' => $this->layout_asset));
                     }
                 } else {
                     echo '';
                 }
             }
         } else {
             echo '';
         }
     }
 }
 public function __construct($project)
 {
     parent::__construct(NULL);
     $this->project = $project;
     $this->current_milestone = $project->getNextMilestone();
     $this->title = __('');
 }
Exemplo n.º 9
0
 protected function renderContent()
 {
     if (isset($this->page)) {
         $blocks = Yii::app()->cache->get($this->page->page_id . '-' . $this->region);
         if ($blocks === false) {
             //var_dump($this->page->page_id.'-'.$this->region);
             //get all blocks of current region, order by 'order'
             $blocks = PageBlock::model()->findAll(array('condition' => 'page_id=:paramId and region=:regionId and status=:status', 'params' => array(':paramId' => $this->page->page_id, ':regionId' => $this->region, ':status' => ConstantDefine::PAGE_BLOCK_ACTIVE), 'order' => 'block_order ASC'));
             if ($blocks) {
                 Yii::app()->cache->set($this->page->page_id . '-' . $this->region, $blocks, 300);
                 $this->workWithBlocks($blocks);
             } else {
                 echo '';
             }
         } else {
             $this->workWithBlocks($blocks);
         }
     }
 }
 public function __toString()
 {
     global $PH;
     global $auth;
     #--- news -----------------------------------------------------------
     $comments = $this->item_with_comments->getComments(array('order_by' => 'created'));
     $block = new PageBlock(array('title' => sprintf(__("%s Comments"), count($comments) ? count($comments) : __("No", "As in... >No< Comments")), 'id' => 'news'));
     $block->render_blockStart();
     $count = 0;
     foreach ($comments as $c) {
         ### own comment
         $is_comment_editable = $auth->cur_user->user_rights & RIGHT_EDITALL || $c->created_by == $auth->cur_user->id;
         if (!($creator = Person::getVisibleById($c->created_by))) {
             continue;
         }
         echo "<div class='post_list_entry'>";
         echo "<h3>";
         if ($c->created_by == $auth->cur_user->id) {
             echo $creator->nickname;
         } else {
             echo $creator->getLink();
         }
         echo "<span class=separator>:</span>";
         echo asHtml($c->name);
         if ($new = $c->isChangedForUser()) {
             if ($new == 1) {
                 echo '<span class=new> (' . __('New') . ') </span>';
             } else {
                 echo '<span class=new>  (' . __('Updated') . ') </span>';
             }
         }
         echo "</h3>";
         echo "<p class= details>";
         echo renderTimeAgo($c->created);
         require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php";
         $versions = ItemVersion::getFromItem($c);
         if (count($versions) > 1) {
             echo " (" . $PH->getLink('itemViewDiff', sprintf(__("%s. update", "like in... Nth update"), count($versions)), array('item' => $c->id));
             echo " " . renderTimeAgo($c->modified);
             echo ") ";
         }
         if ($c->pub_level != PUB_LEVEL_OPEN) {
             echo ' - ' . sprintf(__("visible as %s"), renderPubLevelName($c->pub_level));
             ### publish ###
             if (($parent_task = Task::getEditableById($c->task)) && $c->pub_level < PUB_LEVEL_OPEN) {
                 echo " - " . $PH->getLink('itemsSetPubLevel', __('Publish'), array('item' => $c->id, 'item_pub_level' => PUB_LEVEL_OPEN));
             }
         }
         ### delete
         if ($is_comment_editable) {
             echo " - " . $PH->getLink('commentsDelete', __('Delete'), array('comment' => $c->id));
         }
         echo "</p>";
         if ($is_comment_editable) {
             echo wikifieldAsHtml($c, 'description');
         } else {
             echo wikifieldAsHtml($c, 'description', array('editable' => false));
         }
         echo "</div>";
         $c->nowViewedByUser();
     }
     $this->render_blockEnd();
     return '';
 }
Exemplo n.º 11
0
 public static function inheritParent()
 {
     $parent = isset($_POST['parent']) ? (int) $_POST['parent'] : 0;
     $region = isset($_POST['region']) ? (int) $_POST['region'] : null;
     $layout = isset($_POST['layout']) ? (int) $_POST['layout'] : '';
     $result = array();
     $result['blocks'] = array();
     if ($parent && $region !== null) {
         $page = Page::model()->findByPk($parent);
         if ($page) {
             //We now find all blocks of this parent
             $page_blocks = PageBlock::model()->with('block')->findAll(array('condition' => 'page_id = :pid and region = :rid', 'params' => array(':pid' => $parent, ':rid' => $region), 'order' => 'region ASC, block_order ASC'));
             foreach ($page_blocks as $pb) {
                 $temp['region'] = $pb->region;
                 $temp['id'] = $pb->block_id;
                 $temp['status'] = $pb->status;
                 $temp['title'] = $pb->block->name;
                 $result['blocks'][] = $temp;
             }
         }
     }
     echo json_encode($result);
 }
Exemplo n.º 12
0
/**
* show system information @ingroup pages
*/
function systemInfo()
{
    global $PH;
    require_once confGet('DIR_STREBER') . 'render/render_list.inc.php';
    $system_info = getSysInfo();
    $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 = __("System information");
    $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>";
    foreach ($system_info as $label => $value) {
        echo "<div class=labeled><label>{$label}:</label> <span>{$value}</span></div>";
    }
    echo "</div>";
    global $auth;
    echo "<br>";
    echo "<h2>Timezone detection</h2>";
    echo "<div class=text>";
    echo "<ul>";
    echo "<li> time-offset for user: "******"sec";
    echo "<li> renderDateHtml(): " . renderDateHtml($auth->cur_user->last_login) . "";
    echo "<li> original db-string (should be GMT): " . $auth->cur_user->last_login;
    echo "<li> strToClienttime(): " . strToClientTime($auth->cur_user->last_login);
    echo "<li> gmdate:(strToClientTime) " . gmdate("H:i:s", strToClientTime($auth->cur_user->last_login));
    echo "<li> strToTime(): " . strToTime($auth->cur_user->last_login);
    echo "<li> date(strToTime): " . date("H:i:s", strToTime($auth->cur_user->last_login));
    echo "</ul>";
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 13
0
 public function postAjaxPagesGetBlock()
 {
     if (!Request::ajax()) {
         App::abort(404);
     }
     $element = PageBlock::where('id', Input::get('id'))->with('metas')->orderBy('order')->first()->metasByLang();
     #return $block->toJson();
     $locales = $this->locales;
     #Helper::dd($this->templates(__DIR__, '/views/tpl_block'));
     $templates = [];
     #foreach ($this->templates(__DIR__, '/views/tpl_block') as $template)
     #    @$templates[$template] = $template;
     $block_templates = $this->block_tpls();
     #Helper::tad($block_template);
     return View::make($this->module['tpl'] . '_block_edit', compact('element', 'locales', 'templates', 'block_templates'));
 }
Exemplo n.º 14
0
/**
* Person View @ingroup pages
*/
function personView()
{
    global $PH;
    global $auth;
    ### get current person ###
    $id = getOnePassedId('person', 'people_*');
    if (!($person = Person::getVisibleById($id))) {
        $PH->abortWarning("invalid person-id");
        return;
    }
    ### create from handle ###
    $PH->defineFromHandle(array('person' => $person->id));
    ## is viewed by user ##
    $person->nowViewedByUser();
    $page = new Page();
    $page->cur_tab = 'people';
    if ($person->can_login) {
        $page->title = $person->nickname;
        $page->title_minor = $person->name;
    } else {
        $page->title = $person->name;
        if ($person->category) {
            global $g_pcategory_names;
            if (isset($g_pcategory_names[$person->category])) {
                $page->title_minor = $g_pcategory_names[$person->category];
            }
        }
    }
    $page->type = __("Person");
    $page->crumbs = build_person_crumbs($person);
    $page->options = build_person_options($person);
    ### skip edit functions ###
    if ($edit = Person::getEditableById($person->id)) {
        ### page functions ###
        $page->add_function(new PageFunction(array('target' => 'taskNoteOnPersonNew', 'params' => array('person' => $person->id), 'tooltip' => __('Add task for this people (optionally creating project and effort on the fly)', 'Tooltip for page function'), 'name' => __('Add note', 'Page function person'))));
        #$page->add_function(new PageFunction(array(
        #'target'    =>'personLinkCompanies',
        #'params'    =>array('person'=>$person->id),
        #'tooltip'   =>__('Add existing companies to this person'),
        #'name'      =>__('Companies'),
        #)));
        $page->add_function(new PageFunction(array('target' => 'personEdit', 'params' => array('person' => $person->id), 'icon' => 'edit', 'tooltip' => __('Edit this person', 'Tooltip for page function'), 'name' => __('Edit', 'Page function edit person'))));
        $page->add_function(new PageFunction(array('target' => 'personEditRights', 'params' => array('person' => $person->id), 'icon' => 'edit', 'tooltip' => __('Edit user rights', 'Tooltip for page function'), 'name' => __('Edit rights', 'Page function for edit user rights'))));
        if ($person->id != $auth->cur_user->id) {
            $page->add_function(new PageFunction(array('target' => 'personDelete', 'params' => array('person' => $person->id), 'name' => __('Delete'))));
        }
        $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $person->id));
        if (!$item || $item[0]->is_bookmark == 0) {
            #$page->add_function(new PageFunction(array(
            #    'target'    =>'itemsAsBookmark',
            #    'params'    =>array('person'=>$person->id),
            #    'tooltip'   =>__('Mark this person as bookmark'),
            #    'name'      =>__('Bookmark'),
            #)));
        } else {
            $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('person' => $person->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark'))));
        }
        if ($person->state == ITEM_STATE_OK && $person->can_login && ($person->personal_email || $person->office_email)) {
            $page->add_function(new PageFunction(array('target' => 'personSendActivation', 'params' => array('person' => $person->id))));
            $page->add_function(new PageFunction(array('target' => 'peopleFlushNotifications', 'params' => array('person' => $person->id))));
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen_Columns();
    ### write info block (but only for registed users)
    global $auth;
    if ($auth->cur_user->id != confGet('ANONYMOUS_USER')) {
        $block = new PageBlock(array('title' => __('Summary', 'Block title'), 'id' => 'summary'));
        $block->render_blockStart();
        echo "<div class=text>";
        if ($person->mobile_phone) {
            echo "<div class=labeled><label>" . __('Mobile', 'Label mobilephone of person') . '</label>' . asHtml($person->mobile_phone) . '</div>';
        }
        if ($person->office_phone) {
            echo "<div class=labeled><label>" . __('Office', 'label for person') . '</label>' . asHtml($person->office_phone) . '</div>';
        }
        if ($person->personal_phone) {
            echo "<div class=labeled><label>" . __('Private', 'label for person') . '</label>' . asHtml($person->personal_phone) . '</div>';
        }
        if ($person->office_fax) {
            echo "<div class=labeled><label>" . __('Fax (office)', 'label for person') . '</label>' . asHtml($person->office_fax) . '</div>';
        }
        if ($person->office_homepage) {
            echo "<div class=labeled><label>" . __('Website', 'label for person') . '</label>' . url2linkExtern($person->office_homepage) . '</div>';
        }
        if ($person->personal_homepage) {
            echo "<div class=labeled><label>" . __('Personal', 'label for person') . '</label>' . url2linkExtern($person->personal_homepage) . '</div>';
        }
        if ($person->office_email) {
            echo "<div class=labeled><label>" . __('E-Mail', 'label for person office email') . '</label>' . url2linkMail($person->office_email) . '</div>';
        }
        if ($person->personal_email) {
            echo "<div class=labeled><label>" . __('E-Mail', 'label for person personal email') . '</label>' . url2linkMail($person->personal_email) . '</div>';
        }
        if ($person->personal_street) {
            echo "<div class=labeled><label>" . __('Adress Personal', 'Label') . '</label>' . asHtml($person->personal_street) . '</div>';
        }
        if ($person->personal_zipcode) {
            echo '<div class=labeled><label></label>' . asHtml($person->personal_zipcode) . '</div>';
        }
        if ($person->office_street) {
            echo "<div class=labeled><label>" . __('Adress Office', 'Label') . '</label>' . asHtml($person->office_street) . '</div>';
        }
        if ($person->office_zipcode) {
            echo "<div class=labeled><label></label>" . asHtml($person->office_zipcode) . '</div>';
        }
        if ($person->birthdate && $person->birthdate != "0000-00-00") {
            echo "<div class=labeled><label>" . __('Birthdate', 'Label') . "</label>" . renderDateHtml($person->birthdate) . "</div>";
        }
        if ($person->last_login) {
            echo "<div class=labeled><label>" . __('Last login', 'Label') . '</label>' . renderDateHtml($person->last_login) . '</div>';
        }
        ### functions ####
        echo "</div>";
        $block->render_blockEnd();
    }
    require_once confGet('DIR_STREBER') . 'lists/list_companies.inc.php';
    $companies = $person->getCompanies();
    $list = new ListBlock_companies();
    $list->title = __('works for', 'List title');
    unset($list->columns['short']);
    unset($list->columns['homepage']);
    unset($list->columns['people']);
    unset($list->functions['companyDelete']);
    #unset($list->functions['companyNew']);
    /**
     * \todo We should provide a list-function to link more
     * people to this company. But therefore we would need to
     * pass the company's id, which is not possible right now...
     */
    $list->add_function(new ListFunction(array('target' => $PH->getPage('personLinkCompanies')->id, 'name' => __('Link Companies'), 'id' => 'personLinkCompanies', 'icon' => 'add')));
    $list->add_function(new ListFunction(array('target' => $PH->getPage('personCompaniesDelete')->id, 'name' => __('Remove companies from person'), 'id' => 'personCompaniesDelete', 'icon' => 'sub', 'context_menu' => 'submit')));
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT) {
        $list->no_items_html = $PH->getLink('personLinkCompanies', __('link existing Company'), array('person' => $person->id)) . " " . __("or") . " " . $PH->getLink('companyNew', __('create new'), array('person' => $person->id));
    } else {
        $list->no_items_html = __("no companies related");
    }
    #$list->no_items_html=__("no company");
    $list->render_list($companies);
    echo new PageContentNextCol();
    #--- description ----------------------------------------------------------------
    if ($person->description != "") {
        $block = new PageBlock(array('title' => __('Person details'), 'id' => 'persondetails'));
        $block->render_blockStart();
        echo "<div class=text>";
        echo wikifieldAsHtml($person, 'description');
        echo "</div>";
        $block->render_blockEnd();
    }
    /**
     *  \Note: passing colum to person->getProject is not simple...
     *  the sql-querry currently just querry project-people, which do not contain anything usefull
     *  Possible solutions:
     *   - rewrite the querry-string
     *   - rewrite all order-keys to something like company.name
     */
    $order_by = get('sort_' . $PH->cur_page->id . "_projects");
    require_once confGet('DIR_STREBER') . 'lists/list_projects.inc.php';
    $projects = $person->getProjects($order_by);
    if ($projects || $person->can_login) {
        $list = new ListBlock_projects();
        $list->title = __('works in Projects', 'list title for person projects');
        $list->id = "works_in_projects";
        unset($list->columns['date_closed']);
        unset($list->columns['date_start']);
        unset($list->columns['tasks']);
        unset($list->columns['efforts']);
        unset($list->functions['projDelete']);
        unset($list->functions['projNew']);
        if ($auth->cur_user->user_rights & RIGHT_PROJECT_CREATE) {
            $list->no_items_html = $PH->getLink('projNew', '', array());
        } else {
            $list->no_items_html = __("no active projects");
        }
        $list->render_list($projects);
    }
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    $list = new ListBlock_tasks(array('active_block_function' => 'list'));
    $list->query_options['assigned_to_person'] = $person->id;
    unset($list->columns['created_by']);
    unset($list->columns['planned_start']);
    unset($list->columns['assigned_to']);
    $list->title = __('Assigned tasks');
    $list->no_items_html = __('No open tasks assigned');
    if (isset($list->block_functions['tree'])) {
        unset($list->block_functions['tree']);
        $list->block_functions['grouped']->default = true;
    }
    $list->print_automatic();
    ### add company-id ###
    # note: some pageFunctions like personNew can use this for automatical linking
    #
    echo "<input type='hidden' name='person' value='{$person->id}'>";
    #echo "<a href=\"javascript:document.my_form.go.value='tasksMoveToFolder';document.my_form.submit();\">move to task-folder</a>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 15
0
/**
* 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();
}
Exemplo n.º 16
0
/**
* export selected efforts as a CSV ready for copy and paste into a spread-sheet  @ingroup pages
**
*/
function effortShowAsCSV()
{
    global $PH;
    global $g_effort_status_names;
    $effort_ids = getPassedIds('effort', 'efforts_*');
    if (!$effort_ids) {
        $PH->abortWarning(__("Select some efforts(s) to show"));
        exit;
    }
    $efforts = array();
    $different_fields = array();
    $edit_fields = array('status', 'pub_level', 'task');
    foreach ($effort_ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $efforts[] = $effort;
            ### check project for first task
            if (count($efforts) == 1) {
                ### make sure all are of same project ###
                if (!($project = Project::getVisibleById($effort->project))) {
                    $PH->abortWarning('could not get project');
                }
            } else {
                if ($effort->project != $efforts[0]->project) {
                    $PH->abortWarning(__("For editing all efforts must be of same project."));
                }
                foreach ($edit_fields as $field_name) {
                    if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
                        $different_fields[$field_name] = true;
                    }
                }
            }
        }
    }
    $page = new Page(array('use_jscalendar' => true));
    $page->cur_tab = 'projects';
    $page->options[] = new naviOption(array('target_id' => 'effortEdit'));
    $page->type = __("Edit multiple efforts", "Page title");
    $page->title = sprintf(__("%s efforts for copy and pasting into a spread-sheet", "Page title"), count($efforts));
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
    $block->render_blockStart();
    $format = "[Date][Weekday][Task][Comment][Duration]";
    preg_match_all("/\\[(.*?)\\]/", $format, $matches);
    $overallDuration = 0;
    echo "<textarea style='width:96%; height:300px;'>";
    echo join("\t", $matches[1]) . "\n";
    foreach ($efforts as $e) {
        preg_match_all("/\\[(.*?)\\]/", $format, $matches);
        $separator = "";
        foreach ($matches[1] as $matchedFormat) {
            echo $separator;
            switch ($matchedFormat) {
                case "Date":
                    echo gmstrftime("%Y-%m-%d", strToGMTime($e->time_start));
                    break;
                case "Weekday":
                    echo gmstrftime("%a", strToGMTime($e->time_start));
                    break;
                case "Task":
                    if ($t = Task::getVisibleById($e->task)) {
                        echo $t->name;
                    }
                    break;
                case "Comment":
                    echo $e->name;
                    break;
                case "Duration":
                    $durationInMinutes = round((strToGMTime($e->time_end) - strToGMTime($e->time_start)) / 60, 0);
                    $roundUpTo15 = ceil($durationInMinutes / 15) * 15 / 60;
                    $overallDuration += $roundUpTo15;
                    echo number_format($roundUpTo15, 2, $dec_point = ',', '');
                    break;
            }
            $separator = "\t";
        }
        echo "\n";
    }
    echo "</textarea>";
    echo "<br>";
    echo __("Overall Duration:") . $overallDuration . "h";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
    exit;
}
Exemplo n.º 17
0
/**
* Edit several efforts @ingroup pages
*/
function effortEditMultiple()
{
    global $PH;
    global $g_effort_status_names;
    $effort_ids = getPassedIds('effort', 'efforts_*');
    if (!$effort_ids) {
        $PH->abortWarning(__("Select some efforts(s) to edit"));
        exit;
    }
    $efforts = array();
    $different_fields = array();
    $edit_fields = array('status', 'pub_level', 'task');
    foreach ($effort_ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $efforts[] = $effort;
            ### check project for first task
            if (count($efforts) == 1) {
                ### make sure all are of same project ###
                if (!($project = Project::getVisibleById($effort->project))) {
                    $PH->abortWarning('could not get project');
                }
            } else {
                if ($effort->project != $efforts[0]->project) {
                    $PH->abortWarning(__("For editing all efforts must be of same project."));
                }
                foreach ($edit_fields as $field_name) {
                    if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
                        $different_fields[$field_name] = true;
                    }
                }
            }
        }
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'effort_name'));
    $page->cur_tab = 'projects';
    $page->options[] = new naviOption(array('target_id' => 'effortEdit'));
    $page->type = __("Edit multiple efforts", "Page title");
    $page->title = sprintf(__("Edit %s efforts", "Page title"), count($efforts));
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($efforts as $e) {
        echo "<li>" . $e->getLink(false) . "</li>";
    }
    echo "</ol>";
    $block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $st = array();
    foreach ($g_effort_status_names as $key => $value) {
        $st[$key] = $value;
    }
    if (isset($different_fields['status'])) {
        $st[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('effort_status', __("Status"), array_flip($st), -1));
    } else {
        $form->add(new Form_Dropdown('effort_status', __("Status"), array_flip($st), $efforts[0]->status));
    }
    ### get meta-tasks / folders ###
    $folders = Task::getAll(array('sort_hierarchical' => true, 'parent_task' => 0, 'show_folders' => true, 'folders_only' => false, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED, 'project' => $project->id));
    if ($folders) {
        $folder_list = array("undefined" => "0");
        if ($effort->task) {
            if ($task = Task::getVisibleById($effort->task)) {
                ### add, if normal task (folders will added below) ###
                if (!$task->category == TCATEGORY_FOLDER) {
                    $folder_list[$task->name] = $task->id;
                }
            }
        }
        foreach ($folders as $f) {
            $str = '';
            foreach ($f->getFolder() as $pf) {
                $str .= $pf->getShort() . " > ";
            }
            $str .= $f->name;
            $folder_list[$str] = $f->id;
        }
        if (isset($different_fields['task'])) {
            $folder_list['-- ' . __('keep different') . ' --'] = -1;
            $form->add(new Form_Dropdown('effort_task', __("For task"), $folder_list, -1));
        } else {
            $form->add(new Form_Dropdown('effort_task', __("For task"), $folder_list, $efforts[0]->task));
        }
    }
    if (($pub_levels = $effort->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        if (isset($different_fields['pub_level'])) {
            $pub_levels['-- ' . __('keep different') . ' --'] = -1;
            $form->add(new Form_Dropdown('effort_pub_level', __("Publish to"), $pub_levels, -1));
        } else {
            $form->add(new Form_Dropdown('effort_pub_level', __("Publish to"), $pub_levels, $efforts[0]->pub_level));
        }
    }
    $number = 0;
    foreach ($efforts as $e) {
        $form->add(new Form_HiddenField("effort_id_{$number}", '', $e->id));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'effortEditMultipleSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
    exit;
}
Exemplo n.º 18
0
/**
* edit several bookmarks @ingroup pages
*/
function itemBookmarkEditMultiple($thebookmarks = NULL)
{
    global $PH;
    global $auth;
    global $g_notitychange_period;
    $is_already_bookmark = array();
    $bookmarks = array();
    $items = array();
    $edit_fields = array('notify_if_unchanged', 'notify_on_change');
    $different_fields = array();
    # hash containing fieldnames which are different in bookmarks
    if (!$thebookmarks) {
        $item_ids = getPassedIds('bookmark', 'bookmarks_*');
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            }
        }
    } else {
        $item_ids = $thebookmarks;
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 0))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = false;
                }
            } elseif ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            } else {
                $date = getGMTString();
                $bookmark = new ItemPerson(array('id' => 0, 'item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1, 'notify_if_unchanged' => 0, 'notify_on_change' => 0, 'created' => $date));
                if ($item = DbProjectItem::getById($is)) {
                    $bookmarks[] = $bookmark;
                    $items[] = $item;
                    $is_already_bookmark[$bookmark->id] = false;
                }
            }
        }
    }
    if (!$items) {
        $PH->abortWarning(__("Please select some items"));
    }
    $page = new Page();
    $page->cur_tab = 'home';
    $page->options = array(new NaviOption(array('target_id' => 'itemBookmarkEdit', 'name' => __('Edit bookmarks'))));
    $page->type = __('Edit multiple bookmarks', 'page title');
    $page->title = sprintf(__('Edit %s bookmark(s)'), count($items));
    $page->title_minor = __('Edit');
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($items as $item) {
        ## get item name ##
        $str_link = '';
        if ($type = $item->type) {
            switch ($type) {
                case ITEM_TASK:
                    require_once "db/class_task.inc.php";
                    if ($task = Task::getVisibleById($item->id)) {
                        $str_link = $task->getLink(false);
                    }
                    break;
                case ITEM_COMMENT:
                    require_once "db/class_comment.inc.php";
                    if ($comment = Comment::getVisibleById($item->id)) {
                        $str_link = $comment->getLink(false);
                    }
                    break;
                case ITEM_PERSON:
                    require_once "db/class_person.inc.php";
                    if ($person = Person::getVisibleById($item->id)) {
                        $str_link = $person->getLink(false);
                    }
                    break;
                case ITEM_EFFORT:
                    require_once "db/class_effort.inc.php";
                    if ($e = Effort::getVisibleById($item->id)) {
                        $str_link = $e->getLink(false);
                    }
                    break;
                case ITEM_FILE:
                    require_once "db/class_file.inc.php";
                    if ($f = File::getVisibleById($item->id)) {
                        $str_link = $f->getLink(false);
                    }
                    break;
                case ITEM_PROJECT:
                    require_once "db/class_project.inc.php";
                    if ($prj = Project::getVisibleById($item->id)) {
                        $str_link = $prj->getLink(false);
                    }
                    break;
                case ITEM_COMPANY:
                    require_once "db/class_company.inc.php";
                    if ($c = Company::getVisibleById($item->id)) {
                        $str_link = $c->getLink(false);
                    }
                    break;
                case ITEM_VERSION:
                    require_once "db/class_task.inc.php";
                    if ($tsk = Task::getVisibleById($item->id)) {
                        $str_link = $tsk->getLink(false);
                    }
                    break;
                default:
                    break;
            }
        }
        echo "<li>" . $str_link . "</li>";
    }
    echo "</ol>";
    foreach ($bookmarks as $bookmark) {
        foreach ($edit_fields as $field_name) {
            if ($bookmark->{$field_name} != $bookmarks[0]->{$field_name}) {
                $different_fields[$field_name] = true;
            }
        }
    }
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $b = array();
    $b[0] = __('no');
    $b[1] = __('yes');
    if (isset($different_fields['notify_on_change'])) {
        $b[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), -1));
    } else {
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), $bookmarks[0]->notify_on_change));
    }
    $a = array();
    foreach ($g_notitychange_period as $key => $value) {
        $a[$key] = $value;
    }
    if (isset($different_fields['notify_if_unchanged'])) {
        $a[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), -1));
    } else {
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), $bookmarks[0]->notify_if_unchanged));
    }
    $number = 0;
    foreach ($bookmarks as $bm) {
        $form->add(new Form_HiddenField("bookmark_id_{$number}", '', $bm->id));
        $form->add(new Form_HiddenField("bookmark_item_{$number}", '', $bm->item));
        $form->add(new Form_HiddenField("is_already_bookmark_{$number}", '', $is_already_bookmark[$bm->id]));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'itemBookmarkEditMultipleSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 19
0
/**
* Edit a project @ingroup pages
*/
function projEdit($project = NULL)
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
    if (!$project) {
        $prj = getOnePassedId('prj', 'projects_*');
        ### get project ####
        if (!($project = Project::getEditableById($prj))) {
            $PH->abortWarning("could not get Project");
            return;
        }
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'project_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit Project");
    $page->title = $project->name;
    $page->title_minor = $project->short;
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'projEdit'));
    echo new PageHeader();
    echo new PageContentOpen();
    global $g_status_names;
    global $g_prio_names;
    require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
    ### form background ###
    $block = new PageBlock(array('id' => 'project_edit'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($project->fields['name']->getFormElement($project));
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab("project", __("Project")));
    $tab->add(new Form_Dropdown('project_status', "Status", array_flip($g_status_names), $project->status));
    ### build company-list ###
    $companies = Company::getAll();
    $cl_options = array('undefined' => 0);
    foreach ($companies as $c) {
        $cl_options[$c->name] = $c->id;
    }
    $tab->add(new Form_Dropdown('project_company', __('Company', 'form label'), $cl_options, $project->company));
    $tab->add(new Form_Dropdown('project_prio', "Prio", array_flip($g_prio_names), $project->prio));
    $tab->add($project->fields['projectpage']->getFormElement($project));
    $tab->add($project->fields['date_start']->getFormElement($project));
    $tab->add($project->fields['date_closed']->getFormElement($project));
    $tab_group->add($tab = new Page_Tab("description", __("Description")));
    $e = $project->fields['description']->getFormElement($project);
    $e->rows = 20;
    $tab->add($e);
    global $g_project_setting_names;
    $tab_group->add($tab = new Page_Tab("tab3", __("Display")));
    $tab->add($project->fields['short']->getFormElement($project));
    $tab->add($project->fields['status_summary']->getFormElement($project));
    $tab->add($project->fields['color']->getFormElement($project));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_TASKS', $g_project_setting_names[PROJECT_SETTING_ENABLE_TASKS], $project->settings & PROJECT_SETTING_ENABLE_TASKS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_FILES', $g_project_setting_names[PROJECT_SETTING_ENABLE_FILES], $project->settings & PROJECT_SETTING_ENABLE_FILES));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_BUGS', $g_project_setting_names[PROJECT_SETTING_ENABLE_BUGS], $project->settings & PROJECT_SETTING_ENABLE_BUGS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_EFFORTS', $g_project_setting_names[PROJECT_SETTING_ENABLE_EFFORTS], $project->settings & PROJECT_SETTING_ENABLE_EFFORTS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_MILESTONES', $g_project_setting_names[PROJECT_SETTING_ENABLE_MILESTONES], $project->settings & PROJECT_SETTING_ENABLE_MILESTONES));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_VERSIONS', $g_project_setting_names[PROJECT_SETTING_ENABLE_VERSIONS], $project->settings & PROJECT_SETTING_ENABLE_VERSIONS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_NEWS', $g_project_setting_names[PROJECT_SETTING_ENABLE_NEWS], $project->settings & PROJECT_SETTING_ENABLE_NEWS));
    ### create another one ###
    if ($auth->cur_user->user_rights & RIGHT_PROJECT_CREATE && $project->id == 0) {
        $checked = get('create_another') ? 'checked' : '';
        $form->form_options[] = "<span class=option><input name='create_another' class='checker' type=checkbox {$checked}>" . __("Create another project after submit") . "</span>";
    }
    #echo "<input type=hidden name='prj' value='$project->id'>";
    $form->add(new Form_Hiddenfield('prj', '', $project->id));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'projEditSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 20
0
 public function __construct($args = NULL)
 {
     $this->title = __("Topics");
     $this->id = 'parent_task';
     parent::__construct($args);
 }
Exemplo n.º 21
0
/**
* Edit a person  @ingroup pages
*/
function personEdit($person = NULL)
{
    global $PH;
    global $auth;
    ### new object not in database ###
    if (!$person) {
        $id = getOnePassedId('person', 'people_*');
        # WARNS if multiple; ABORTS if no id found
        if (!($person = Person::getEditableById($id))) {
            $PH->abortWarning("ERROR: could not get Person");
            return;
        }
    }
    ### validate rights ###
    if ($auth->cur_user->id == $person->id && $auth->cur_user->user_rights & RIGHT_PERSON_EDIT_SELF || $auth->cur_user->user_rights & RIGHT_PERSON_EDIT || $auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $person->id == 0) {
        $pass = true;
    } else {
        $PH->abortWarning(__("not allowed to edit"), ERROR_RIGHTS);
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'person_name'));
    $page->cur_tab = 'people';
    $page->type = __('Edit Person', 'Page type');
    $page->title = $person->name;
    $page->title_minor = '';
    $page->crumbs = build_person_crumbs($person);
    $page->options = array(new NaviOption(array('target_id' => 'personEdit')));
    echo new PageHeader();
    echo new PageContentOpen();
    ### form background ###
    $block = new PageBlock(array('id' => 'person_edit'));
    $block->render_blockStart();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    global $g_pcategory_names;
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($person->fields['name']->getFormElement($person));
    ### profile and login ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT_RIGHTS || $auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $auth->cur_user->user_rights & RIGHT_PROJECT_ASSIGN && $person->id == 0) {
        /**
         * if checkbox not rendered, submit might reset $person->can_login.
         * ...be sure the user_rights match
         */
        $form->add(new Form_checkbox("person_can_login", __('Person with account (can login)', 'form label'), $person->can_login));
    }
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab("account", __("Account")));
    $fnick = $person->fields['nickname']->getFormElement($person);
    if ($person->can_login) {
        $fnick->required = true;
    }
    $tab->add($fnick);
    $tab->add($person->fields['office_email']->getFormElement($person));
    ### show password-fields if can_login ###
    /**
     * since the password as stored as md5-hash, we can initiate current password,
     * but have have to make sure the it is not changed on submit
     */
    $fpw1 = new Form_password('person_password1', __('Password', 'form label'), "__dont_change__", $person->fields['password']->tooltip);
    if ($person->can_login) {
        $fpw1->required = true;
    }
    $tab->add($fpw1);
    $fpw2 = new Form_password('person_password2', __('confirm Password', 'form label'), "__dont_change__", $person->fields['password']->tooltip);
    if ($person->can_login) {
        $fpw2->required = true;
    }
    $tab->add($fpw2);
    ### authentication ###
    if (confGet('LDAP')) {
        $authentication = array('streber' => 0, 'ldap' => 1);
        $tab->add(new Form_Dropdown('person_auth', __("Authentication with", "form label"), $authentication, $person->ldap));
    }
    ### profile and login ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT_RIGHTS) {
        global $g_user_profile_names;
        global $g_user_profiles;
        ### display "undefined" profile if rights changed ###
        # will be skipped when submitting
        $profile_num = $person->profile;
        $reset = "";
        if (!($default_rights = $g_user_profiles[$profile_num]['default_user_rights'])) {
            trigger_error("undefined/invalid profile requested ({$profile_num})", E_USER_ERROR);
        }
        $list = $g_user_profile_names;
        if ($default_rights != $person->user_rights) {
            $profile_num = '-1';
            $list['-1'] = __('-- reset to...--');
        }
        $tab->add(new Form_Dropdown('person_profile', __("Profile", "form label"), array_flip($list), $profile_num));
    }
    $a = array(sprintf(__('ASAP'), -1) => -1, sprintf(__('daily'), 1) => 1, sprintf(__('each 3 days'), 3) => 3, sprintf(__('each 7 days'), 7) => 7, sprintf(__('each 14 days'), 14) => 14, sprintf(__('each 30 days'), 30) => 30, __('Never') => 0);
    $p = $person->notification_period;
    if (!$person->settings & USER_SETTING_NOTIFICATIONS) {
        $p = 0;
    }
    $tab->add(new Form_Dropdown('person_notification_period', __("Send notifications", "form label"), $a, $p));
    #$tab->add(new Form_checkbox("person_html_mail",__('Send mail as html','form label'),$person->settings & USER_SETTING_HTML_MAIL));
    if ($person->id == 0) {
        $prj_num = '-1';
        $prj_names = array();
        $prj_names['-1'] = __('- no -');
        ## get all projects ##
        if ($projects = Project::getAll()) {
            foreach ($projects as $p) {
                $prj_names[$p->id] = $p->name;
            }
            ## assigne new person to ptoject ##
            $tab->add(new Form_Dropdown('assigned_prj', __('Assigne to project', 'form label'), array_flip($prj_names), $prj_num));
        }
    }
    $tab_group->add($tab = new Page_Tab("details", __("Details")));
    ### category ###
    if ($p = get('perscat')) {
        $perscat = $p;
    } else {
        $perscat = $person->category;
    }
    $tab->add(new Form_Dropdown('pcategory', __('Category', 'form label'), array_flip($g_pcategory_names), $perscat));
    $tab->add($person->fields['mobile_phone']->getFormElement($person));
    $tab->add($person->fields['office_phone']->getFormElement($person));
    $tab->add($person->fields['office_fax']->getFormElement($person));
    $tab->add($person->fields['office_street']->getFormElement($person));
    $tab->add($person->fields['office_zipcode']->getFormElement($person));
    $tab->add($person->fields['office_homepage']->getFormElement($person));
    $tab->add($person->fields['personal_email']->getFormElement($person));
    $tab->add($person->fields['personal_phone']->getFormElement($person));
    $tab->add($person->fields['personal_fax']->getFormElement($person));
    $tab->add($person->fields['personal_street']->getFormElement($person));
    $tab->add($person->fields['personal_zipcode']->getFormElement($person));
    $tab->add($person->fields['personal_homepage']->getFormElement($person));
    $tab->add($person->fields['birthdate']->getFormElement($person));
    $tab_group->add($tab = new Page_Tab("description", __("Description")));
    $e = $person->fields['description']->getFormElement($person);
    $e->rows = 20;
    $tab->add($e);
    $tab_group->add($tab = new Page_Tab("options", __("Options")));
    $tab->add(new Form_checkbox("person_enable_efforts", __('Enable efforts'), $person->settings & USER_SETTING_ENABLE_EFFORTS));
    $tab->add(new Form_checkbox("person_enable_bookmarks", __('Enable bookmarks'), $person->settings & USER_SETTING_ENABLE_BOOKMARKS));
    global $g_theme_names;
    if (count($g_theme_names) > 1) {
        $tab->add(new Form_Dropdown('person_theme', __("Theme", "form label"), array_flip($g_theme_names), $person->theme));
    }
    global $g_languages;
    $tab->add(new Form_Dropdown('person_language', __("Language", "form label"), array_flip($g_languages), $person->language));
    global $g_time_zones;
    $tab->add(new Form_Dropdown('person_time_zone', __("Time zone", "form label"), $g_time_zones, $person->time_zone));
    ### effort-style ###
    $effort_styles = array(__("start times and end times") => 1, __("duration") => 2);
    $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
    $tab->add(new Form_Dropdown('person_effort_style', __("Log Efforts as"), $effort_styles, $effort_style));
    $tab->add(new Form_checkbox("person_filter_own_changes", __('Filter own changes from recent changes list'), $person->settings & USER_SETTING_FILTER_OWN_CHANGES));
    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($person->fields['salary_per_hour']->getFormElement($person));
    }
    ### temp uid for account activation ###
    if ($tuid = get('tuid')) {
        $form->add(new Form_Hiddenfield('tuid', '', $tuid));
    }
    ### create another person ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $person->id == 0) {
        #$form->add(new Form_checkbox("create_another","",));
        $checked = get('create_another') ? 'checked' : '';
        $form->form_options[] = "<span class=option><input id='create_another' name='create_another' class='checker' type=checkbox {$checked}><label for='create_another'>" . __("Create another person after submit") . "</label></span>";
    }
    #echo "<input type=hidden name='person' value='$person->id'>";
    $form->add(new Form_HiddenField('person', '', $person->id));
    echo $form;
    $PH->go_submit = 'personEditSubmit';
    ### pass company-id? ###
    if ($c = get('company')) {
        echo "<input type=hidden name='company' value='{$c}'>";
    }
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
 function __construct($item)
 {
     parent::__construct(NULL);
     $this->item_with_attachments = $item;
 }
Exemplo n.º 23
0
/**
* Edit a comment 
*
* @ingroup pages
*/
function commentEdit($comment = NULL)
{
    global $PH;
    global $auth;
    ### edit existing object or get from database ? ###
    if (!$comment) {
        $id = getOnePassedId('comment', 'comments*');
        # WARNS if multiple; ABORTS if no id found
        $comment = Comment::getVisibleById($id);
        if (!$comment) {
            $PH->abortWarning("could not get Comment", ERROR_FATAL);
            return;
        }
    }
    ### check user-rights ###
    if (!($project = Project::getVisibleById($comment->project))) {
        $PH->abortWarning("comment without project?", ERROR_BUG);
    }
    $project->validateEditItem($comment);
    # aborts if not enough rights to edit
    $task = Task::getVisibleById($comment->task);
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'comment_name'));
    initPageForComment($page, $comment, $project);
    if ($comment->id) {
        $page->title = __("Edit Comment", "Page title");
    } else {
        $page->title = __("New Comment", "Page title");
    }
    echo new PageHeader();
    echo new PageContentOpen();
    global $COMMENTTYPE_VALUES;
    global $PUB_LEVEL_VALUES;
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $block = new PageBlock(array('id' => 'edit'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($comment->fields['name']->getFormElement($comment));
    $e = $comment->fields['description']->getFormElement($comment);
    $e->rows = 22;
    $form->add($e);
    $form->add(new Form_HiddenField('comment_project', '', $comment->project));
    $form->add(new Form_HiddenField('comment_task', '', $comment->task));
    $form->add(new Form_HiddenField('comment_comment', '', $comment->comment));
    ### public-level ###
    if (($pub_levels = $comment->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        $form->add(new Form_Dropdown('comment_pub_level', __('Publish to', 'form label'), $pub_levels, $comment->pub_level));
    }
    if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
        $form->addCaptcha();
    }
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'commentEditSubmit';
    echo "<input type=hidden name='comment' value='{$comment->id}'>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 24
0
/**
* Display forgot password page @ingroup pages
*/
function loginForgotPassword()
{
    global $PH;
    global $auth;
    global $g_valid_login_params;
    if (isset($auth->cur_user)) {
        $auth->cur_user = NULL;
    }
    $page = new Page(array('autofocus_field' => 'login_name'));
    global $g_tabs_login;
    $page->tabs = $g_tabs_login;
    $page->cur_tab = 'login';
    $page->type = "";
    $page->title = __('Password reminder', 'Page title');
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $block = new PageBlock(array('title' => __('Please enter your nickname'), 'id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $msg = __("We will then sent you an E-mail with a link to adjust your password.") . " ";
    if ($mail = confGet('EMAIL_ADMINISTRATOR')) {
        $msg .= sprintf(__("If you do not know your nickname, please contact your administrator: %s."), "<a href='mailto:{$mail}'>{$mail}</a>");
    }
    $form->add(new Form_Text($msg));
    $form->add(new Form_Input('login_name', __('Nickname', 'label in login form'), ''));
    #$form->form_options[]="<span class=option><input name='login_forgot_password' class='checker' type=checkbox>".__("I forgot my password")."</span>";
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'loginForgotPasswordSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 25
0
function printRecentChanges($projects, $print_project_headlines = true)
{
    global $PH;
    global $auth;
    /**
     * first get all changelines for projects to filter out projects without changes
     */
    $projects_with_changes = array();
    # array with projects
    $project_changes = array();
    # hash with project id and changelist
    foreach ($projects as $project) {
        /**
         * first query all unviewed changes
         */
        $options = array('project' => $project->id, 'unviewed_only' => false, 'limit_rowcount' => confGet('MAX_CHANGELINES') + 1, 'limit_offset' => 0, 'type' => array(ITEM_TASK, ITEM_FILE));
        if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
            $options['not_modified_by'] = $auth->cur_user->id;
        }
        if ($changes = ChangeLine::getChangeLines($options)) {
            $projects_with_changes[] = $project;
            $project_changes[$project->id] = $changes;
        }
    }
    if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
        $link_name = __("Also show yours", "E.i. also show your changes");
    } else {
        $link_name = __("Hide yours", "E.i. Filter out your changes");
    }
    $block = new PageBlock(array('title' => __('Recent changes'), 'id' => 'recentchanges', 'headline_links' => array($PH->getLink('personToggleFilterOwnChanges', $link_name, array('person' => $auth->cur_user->id)))));
    $block->render_blockStart();
    ### no changes
    if (0 == count($projects_with_changes)) {
        echo "<div class=text>" . __("No changes yet") . "</div>";
        ### more options ###
        echo "<p class=more>";
        echo $PH->getLink('personToggleFilterOwnChanges', $link_name, array('person' => $auth->cur_user->id));
        echo "</p>";
        $block->render_blockEnd();
    } else {
        $changelines_per_project = confGet('MAX_CHANGELINES_PER_PROJECT');
        if (count($projects_with_changes) < confGet('MAX_CHANGELINES') / confGet('MAX_CHANGELINES_PER_PROJECT')) {
            $changelines_per_project = confGet('MAX_CHANGELINES') / count($projects_with_changes) - 1;
        }
        /**
         * count printed changelines to keep size of list
         */
        $printed_changelines = 0;
        foreach ($projects_with_changes as $project) {
            echo "<div class=post_list_entry>";
            $changes = $project_changes[$project->id];
            if ($print_project_headlines) {
                echo '<h3>' . sprintf(__("%s project", "links to project in recent changes list"), $PH->getLink('projView', $project->name, array('prj' => $project->id))) . "</h3>";
            }
            echo "<ul id='changesOnProject_{$project->id}'>";
            $lines = 0;
            foreach ($changes as $c) {
                $lines++;
                printChangeLine($c);
                $printed_changelines++;
                if ($lines >= $changelines_per_project) {
                    break;
                }
            }
            echo "</ul>";
            ### more options ###
            echo "<p class=more>";
            if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
                $link_name = __("Also show your changes");
            } else {
                $link_name = __("Hide your changes");
            }
            if ($lines < count($changes)) {
                echo " | ";
                echo "<a href='javascript:getMoreChanges({$project->id}, " . ($lines - 1) . ", " . confGet('MORE_CHANGELINES') . ");' " . '>' . __('Show more') . '</a>';
            }
            echo "</p>";
            /**
             * limit number of projects
             */
            if ($printed_changelines >= confGet('MAX_CHANGELINES')) {
                break;
            }
            echo "</div>";
        }
        $block->render_blockEnd();
    }
}
Exemplo n.º 26
0
/**
* view details of a version @ingroup pages
*/
function versionView()
{
    global $PH;
    global $auth;
    require_once "render/render_wiki.inc.php";
    ### get task ####
    if (!($version = Version::getVisibleById(get('version')))) {
        $PH->abortWarning("invalid version-id", ERROR_FATAL);
    }
    if (!($project = Project::getVisibleById($version->project))) {
        $PH->abortWarning("invalid project-id", ERROR_FATAL);
    }
    ### create from handle ###
    $from_handle = $PH->defineFromHandle(array('version' => $version->id));
    ## is viewed by user ##
    $version->isViewedByUser($auth->cur_user);
    $page = new Page();
    $page->cur_tab = 'projects';
    $page->cur_crumb = 'projViewTasks';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $type = __('Version', 'page type');
    if ($task) {
        $folder = $task->getFolderLinks() . "<em>&gt;</em>" . $task->getLink();
        $page->type = $folder . " > " . $type;
    } else {
        $page->type = $type;
    }
    $page->title = $version->name;
    $page->title_minor = "";
    if ($version->state == -1) {
        $page->title_minor = sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($version->deleted));
    }
    ### page functions ###
    $page->add_function(new PageFunction(array('target' => 'versionEdit', 'params' => array('version' => $version->id), 'icon' => 'edit', 'tooltip' => __('Edit this version'), 'name' => __('Edit'))));
    $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $version->id));
    if (!$item || $item[0]->is_bookmark == 0) {
        $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Mark this version as bookmark'), 'name' => __('Bookmark'))));
    } else {
        $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark'))));
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Description'), 'id' => 'description', 'noshade' => true));
    $block->render_blockStart();
    $str = wikifieldAsHtml($version, 'description');
    echo "<div class=text>";
    echo "{$str}";
    echo "</div>";
    $block->render_blockEnd();
    echo '<input type="hidden" name="prj" value="' . $version->project . '">';
    /**
     * give parameter for create of new items (subtasks, efforts, etc)
     */
    #echo '<input type="hidden" name="parent_task" value="'.$task->id.'">';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 27
0
    function updateBlock(region,title,id,old_object){
        
        var old_id=$(old_object).attr('id');        
        var old_block_count=old_id.split('_');
        old_block_count=old_block_count[2];
        var span_html='<input type="checkbox" class="checkbox_region" id="checkbox_'+old_block_count+'_'+region+'_'+id+'"/><span class="span_block">'+title+'</span> - <span><select name="Page[regions]['+region+'][status][]" id="select_region_'+old_block_count+'_'+region+'_'+id+'"><option value="<?php 
echo ConstantDefine::PAGE_BLOCK_ACTIVE;
?>
"><?php 
echo PageBlock::convertPageBlockStatus(ConstantDefine::PAGE_BLOCK_ACTIVE);
?>
</option><option value="<?php 
echo ConstantDefine::PAGE_BLOCK_DISABLE;
?>
"><?php 
echo PageBlock::convertPageBlockStatus(ConstantDefine::PAGE_BLOCK_DISABLE);
?>
</option></select> </span> <br /><a onClick="changeAnotherBlock('+region+','+id+','+old_block_count+')" href="javascript:void(0);"><?php 
echo t('Change');
?>
</a>&nbsp;<a onClick="editBlock('+region+','+id+','+old_block_count+')" href="javascript:void(0);"><?php 
echo t('Edit');
?>
</a>&nbsp;<a onClick="deleteBlockFromRegion(this)" href="javascript:void(0);"><?php 
echo t('Delete');
?>
</a>';
        var input_id_html='<input type="hidden" value="'+id+'" name="Page[regions]['+region+'][id][]" />';
        var input_status_html='<input type="hidden" value="<?php 
echo ConstantDefine::PAGE_BLOCK_ACTIVE;
?>
Exemplo n.º 28
0
/**
* Edit a task
*
* @ingroup pages
*/
function taskEdit($task = NULL)
{
    global $PH;
    ### object or from database? ###
    if (!$task) {
        $ids = getPassedIds('tsk', 'tasks_*');
        if (!$ids) {
            $PH->abortWarning(__("Select some task(s) to edit"), ERROR_NOTE);
            return;
        } else {
            if (count($ids) > 1) {
                $PH->show('taskEditMultiple');
                exit;
            } else {
                if (!($task = Task::getEditableById($ids[0]))) {
                    $PH->abortWarning(__("You do not have enough rights to edit this task"), ERROR_RIGHTS);
                }
            }
        }
    }
    ### get parent project ####
    if (!($project = Project::getVisibleById($task->project))) {
        $PH->abortWarning("FATAL error! parent project not found");
    }
    ### abort, if not enough rights ###
    $project->validateEditItem($task);
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'task_name'));
    initPageForTask($page, $task, $project);
    if ($task->id) {
        $page->title = $task->name;
        $page->title_minor = $task->short;
    } else {
        if ($task->category == TCATEGORY_MILESTONE) {
            $page->title = __("New milestone");
        } else {
            if ($task->category == TCATEGORY_VERSION) {
                $page->title = __("New version");
            } else {
                if ($task->category == TCATEGORY_DOCU) {
                    $page->title = __("New topic");
                } else {
                    if ($task->category == TCATEGORY_FOLDER) {
                        $page->title = __("New folder");
                    } else {
                        $page->title = __("New task");
                        if ($task->parent_task && ($parent_task = Task::getVisibleById($task->parent_task))) {
                            $page->title_minor = sprintf(__('for %s', 'e.g. new task for something'), $parent_task->name);
                        } else {
                            $page->title_minor = sprintf(__('for %s', 'e.g. new task for something'), $project->name);
                        }
                    }
                }
            }
        }
    }
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    global $auth;
    global $REPRODUCIBILITY_VALUES;
    global $g_prio_names;
    global $g_status_names;
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($task->fields['name']->getFormElement($task));
    $list = array();
    if ($task->category == TCATEGORY_MILESTONE || $task->category == TCATEGORY_VERSION) {
        $list = array(TCATEGORY_MILESTONE, TCATEGORY_VERSION);
        ### make sure it's valid
        if ($task->category != TCATEGORY_MILESTONE || $task->category != TCATEGORY_VERSION) {
            if ($task->is_released > RELEASED_UPCOMMING) {
                $task->category = TCATEGORY_VERSION;
            } else {
                $task->category = TCATEGORY_MILESTONE;
            }
        }
    } else {
        $list = array();
        if ($project->settings & PROJECT_SETTING_ENABLE_TASKS) {
            $list[] = TCATEGORY_TASK;
        }
        if ($project->settings & PROJECT_SETTING_ENABLE_BUGS) {
            $list[] = TCATEGORY_BUG;
        }
        $list[] = TCATEGORY_DOCU;
        $list[] = TCATEGORY_FOLDER;
    }
    global $g_tcategory_names;
    $cats = array();
    foreach ($list as $c) {
        $cats[$c] = $g_tcategory_names[$c];
    }
    $form->add(new Form_Dropdown('task_category', __("Display as"), array_flip($cats), $task->category));
    ### warning if folder with subtasks ###
    if ($task->id && $task->category == TCATEGORY_FOLDER && ($num_subtasks = count($task->getSubtasks()))) {
        $form->add(new Form_CustomHtml('<p><label></label>' . sprintf(__("This folder has %s subtasks. Changing category will ungroup them."), $num_subtasks) . '</p>'));
    }
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab('task', __("Task")));
    ### normaltasks and folders ##
    if (!$task->isMilestoneOrVersion()) {
        if ($project->settings & PROJECT_SETTING_ENABLE_MILESTONES) {
            $tab->add(new Form_DropdownGrouped('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
        }
        ### prio ###
        if ($task->category != TCATEGORY_MILESTONE && $task->category != TCATEGORY_VERSION) {
            $tab->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio));
        }
    }
    ### for existing tasks, get already assigned
    if ($task->id) {
        $assigned_people = $task->getAssignedPeople();
        #$task_assignments = $task->getAssignments();
    } else {
        ### check new assigments ###
        $count = 0;
        while ($id_new = get('task_assign_to_' . $count)) {
            $count++;
            ### check if already assigned ###
            if ($p = Person::getVisibleById($id_new)) {
                $assigned_people[] = $p;
            }
        }
        if (!$count) {
            $parents = $task->getFolder();
            if ($parents) {
                $parents = array_reverse($parents);
                foreach ($parents as $p) {
                    if ($ap = $p->getAssignedPeople()) {
                        $assigned_people = $ap;
                        break;
                    }
                }
            }
        }
    }
    $team = array(__('- select person -') => 0);
    ### create team-list ###
    foreach ($project->getPeople() as $p) {
        $team[$p->name] = $p->id;
    }
    ### create drop-down-lists ###
    $count_new = 0;
    $count_all = 0;
    if (isset($assigned_people)) {
        foreach ($assigned_people as $ap) {
            if (!($p = Person::getVisibleById($ap->id))) {
                continue;
                # skip if invalid person
            }
            if ($task->id) {
                $tab->add(new Form_Dropdown('task_assigned_to_' . $ap->id, __("Assigned to"), $team, $ap->id));
            } else {
                $tab->add(new Form_Dropdown('task_assign_to_' . $count_new, __("Assign to"), $team, $ap->id));
                $count_new++;
            }
            $count_all++;
            unset($team[$ap->name]);
        }
    }
    ### add empty drop-downlist for new assignments ###
    $str_label = $count_all == 0 ? __("Assign to", "Form label") : __("Also assign to", "Form label");
    $tab->add(new Form_Dropdown("task_assign_to_{$count_new}", $str_label, $team, 0));
    ### completion ###
    if (!$task->is_released > RELEASED_UPCOMMING) {
        #$form->add($task->fields['estimated'    ]->getFormElement($task));
        $ar = array(__('undefined') => -1, '0%' => 0, '10%' => 10, '20%' => 20, '30%' => 30, '40%' => 40, '50%' => 50, '60%' => 60, '70%' => 70, '80%' => 80, '90%' => 90, '95%' => 95, '98%' => 98, '99%' => 99, '100%' => 100);
        $tab->add(new Form_Dropdown('task_completion', __("Completed"), $ar, $task->completion));
    }
    $st = array();
    foreach ($g_status_names as $s => $n) {
        if ($s >= STATUS_NEW) {
            $st[$s] = $n;
        }
    }
    if ($task->isMilestoneOrVersion()) {
        unset($st[STATUS_NEW]);
    }
    $field_status = new Form_Dropdown('task_status', "Status", array_flip($st), $task->status);
    if ($task->fields['status']->invalid) {
        $field_status->invalid = true;
    }
    $tab->add($field_status);
    if (!$task->isMilestoneOrVersion()) {
        if ($project->settings & PROJECT_SETTING_ENABLE_MILESTONES) {
            ### resolved version ###
            $tab->add(new Form_DropdownGrouped('task_resolved_version', __('Resolved in'), $project->buildResolvedInList(), $task->resolved_version));
        }
        ### resolved reason ###
        global $g_resolve_reason_names;
        $tab->add(new Form_Dropdown('task_resolve_reason', __('Resolve reason'), array_flip($g_resolve_reason_names), $task->resolve_reason));
    }
    $tab_group->add($tab = new Page_Tab("bug", __("Bug Report")));
    ### use issue-report ###
    global $g_severity_names;
    global $g_reproducibility_names;
    ### create new one ###
    if ($task->issue_report <= 0) {
        $issue = new Issue(array('id' => 0));
        ### get recent issue-reports ###
        if ($recent_ir = Issue::getCreatedRecently()) {
            $default_version = '';
            $default_plattform = '';
            $default_production_build = '';
            $default_os = '';
            foreach ($recent_ir as $ir) {
                if ($ir->project == $project->id) {
                    if (!$issue->version && $ir->version) {
                        $issue->version = $ir->version;
                    }
                    if (!$issue->plattform && $ir->plattform) {
                        $issue->plattform = $ir->plattform;
                    }
                    if (!$issue->os && $ir->os) {
                        $issue->os = $ir->os;
                    }
                    if (!$issue->production_build && $ir->production_build) {
                        $issue->production_build = $ir->production_build;
                    }
                }
            }
        }
    } else {
        /**
         * note: if task is visible ignore visibility of issue report
         */
        $issue = Issue::getById($task->issue_report);
    }
    if ($issue) {
        $tab->add(new Form_Dropdown('issue_severity', __("Severity", "Form label, attribute of issue-reports"), array_flip($g_severity_names), $issue->severity));
        $tab->add(new Form_Dropdown('issue_reproducibility', __("Reproducibility", "Form label, attribute of issue-reports"), array_flip($g_reproducibility_names), $issue->reproducibility));
        foreach ($issue->fields as $field) {
            $tab->add($field->getFormElement($issue));
        }
        $tab->add(new Form_HiddenField('task_issue_report', '', $task->issue_report));
    } else {
        trigger_error("could not get Issue with id ({$task->issue}-report)", E_USER_NOTICE);
    }
    $tab_group->add($tab = new Page_Tab("timing", __("Timing")));
    ### estimated ###
    if (!$task->isMilestoneOrVersion()) {
        #$tab->add($task->fields['estimated'    ]->getFormElement($task));
        $ar = array(__('undefined') => 0, __('30 min') => 30 * 60, __('1 h') => 60 * 60, __('2 h') => 2 * 60 * 60, __('4 h') => 4 * 60 * 60, __('1 Day') => 1 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Days') => 2 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Days') => 3 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('4 Days') => 4 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('1 Week') => 1 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Weeks') => 2 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Weeks') => 3 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60);
        $tab->add(new Form_Dropdown('task_estimated', __("Estimated time"), $ar, $task->estimated));
        $tab->add(new Form_Dropdown('task_estimated_max', __("Estimated worst case"), $ar, $task->estimated_max));
    }
    ### planned time ###
    if (!$task->isMilestoneOrVersion()) {
        $tab->add($task->fields['planned_start']->getFormElement($task));
    }
    $tab->add($task->fields['planned_end']->getFormElement($task));
    if ($task->isMilestoneOrVersion()) {
        global $g_released_names;
        $tab->add(new Form_Dropdown('task_is_released', __("Release as version", "Form label, attribute of issue-reports"), array_flip($g_released_names), $task->is_released));
        $tab->add($task->fields['time_released']->getFormElement($task));
    }
    $tab_group->add($tab = new Page_Tab('description', __("Description")));
    $e = $task->fields['description']->getFormElement($task);
    $e->rows = 20;
    $tab->add($e);
    $tab_group->add($tab = new Page_Tab('display', __("Display")));
    ### short ###
    $tab->add($task->fields['short']->getFormElement($task));
    ### order id ###
    $tab->add($task->fields['order_id']->getFormElement($task));
    ### Shows as news ###
    $tab->add($task->fields['is_news']->getFormElement($task));
    ### Shows Folder as documentation ###
    $tab->add($task->fields['show_folder_as_documentation']->getFormElement($task));
    ### public-level ###
    if (($pub_levels = $task->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        $tab->add(new Form_Dropdown('task_pub_level', __("Publish to"), $pub_levels, $task->pub_level));
    }
    ### label ###
    if (!$task->isOfCategory(TCATEGORY_VERSION, TCATEGORY_MILESTONE, TCATEGORY_FOLDER)) {
        $labels = array(__('undefined') => 0);
        $counter = 1;
        foreach (explode(",", $project->labels) as $l) {
            $labels[$l] = $counter++;
        }
        $tab->add(new Form_Dropdown('task_label', __("Label"), $labels, $task->label));
    }
    if (confGet('INTERNAL_COST_FEATURE') && $auth->cur_user->user_rights & RIGHT_VIEWALL && $auth->cur_user->user_rights & RIGHT_EDITALL) {
        $tab_group->add($tab = new Page_Tab("internal", __("Internal")));
        $tab->add($task->fields['calculation']->getFormElement($task));
    }
    /**
     * to reduce spam, enforce captcha test for guests
     */
    global $auth;
    if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
        $form->addCaptcha();
    }
    $form->add($task->fields['parent_task']->getFormElement($task));
    #echo "<input type=hidden name='tsk' value='$task->id'>";
    $form->add(new Form_HiddenField('tsk', '', $task->id));
    #echo "<input type=hidden name='task_project' value='$project->id'>";
    $form->add(new Form_HiddenField('task_project', '', $project->id));
    ### create another task ###
    if ($task->id == 0) {
        $checked = get('create_another') ? 'checked' : '';
        $form->form_options[] = "<input id='create_another' name='create_another' type=checkbox {$checked}><label for='create_another'>" . __("Create another task after submit") . "</label>";
    }
    echo $form;
    $PH->go_submit = 'taskEditSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    $block->render_blockEnd();
    #@@@ passing project-id is an security-issue, because it might allow to add tasks to unverified projects.
    # Double-checking project-rights in taskEditSubmit() required
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemplo n.º 29
0
 protected function afterDelete()
 {
     PageBlock::model()->deleteAll('block_id = :id', array(':id' => $this->block_id));
 }
Exemplo n.º 30
0
/**
* Edit description of a task
*
* @ingroup pages
*/
function taskEditDescription($task = NULL)
{
    global $PH;
    ### object or from database? ###
    if (!$task) {
        $id = getOnePassedId('tsk', 'tasks_*');
        if (!($task = Task::getEditableById($id))) {
            $PH->abortWarning(__("Select a task to edit description"), ERROR_NOTE);
            return;
        }
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'task_name'));
    initPageForTask($page, $task);
    $page->title_minor = __("Edit description");
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $block = new PageBlock(array('id' => 'edit'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add(new Form_HiddenField('task_id', '', $task->id));
    $form->add($task->fields['name']->getFormElement($task));
    $e = $task->fields['description']->getFormElement($task);
    $e->rows = 22;
    $form->add($e);
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'taskEditDescriptionSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}