Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 938

Přidáno uživatelem Michal Kliment před více než 13 roky(ů)

Implementace komentaru u prevodu a u praci. Zbyva doladit zobrazeni na vypise vsech clenu a praci.

Zobrazit rozdíly:

freenetis/branches/comments/application/i18n/cs_CZ/texts.php
'collateral' => 'Vedlejší',
'column headers' => 'Hlavičky sloupců',
'comment' => 'Komentář',
'comment has been successfully added' => 'Komentář byl úspěšně přidán',
'comment has been successfully deleted' => 'Komentář byl úspěšně smazán',
'comment has been successfully updated' => 'Komentář byl úspěšně aktualizován',
'comment of admin shown to user' => 'Komentář administrátora zobrazený uživateli',
'comments' => 'Komentáře',
'company' => 'Firemní',
freenetis/branches/comments/application/helpers/callback.php
*/
public static function balance_field($item, $name)
{
$title = (isset($item->a_comment)) ? $item->a_comment : '';
if ($item->balance > 0)
echo '<span style="color:green">'.number_format((float)$item->balance, 2, ',', ' ').'</span>';
echo '<span style="color:green" title="'.$title.'">'.number_format((float)$item->balance, 2, ',', ' ').'</span>';
elseif ($item->balance < 0)
echo '<span style="color:red">'.number_format((float)$item->balance, 2, ',', ' ').'</span>';
echo '<span style="color:red" title="'.$title.'">'.number_format((float)$item->balance, 2, ',', ' ').'</span>';
else
echo $item->balance;
}
......
echo html::anchor (url_lang::base().'ifaces/show/'.$item->iface_id, $item->iface_id, array('title' => url_lang::lang('texts.Show interface')));
}
/**
* Callback to print edit field
*
* @author
* @param <type> $item
* @param <type> $name
* @param array $args
*/
public function edit_field ($item, $name, $args = array())
{
if (Session::instance()->get('user_id') == $item->user_id)
echo html::anchor (url_lang::base().$args[0].'/edit/'.$item->id, url_lang::lang('texts.Edit'));
}
/**
* Callback to print delete field
*
*@author Michal Kliment
* @param <type> $item
* @param <type> $name
* @param array $args
*/
public function delete_field ($item, $name, $args = array())
{
if (Session::instance()->get('user_id') == $item->user_id)
freenetis/branches/comments/application/models/comment.php
class Comment_Model extends ORM
{
protected $belongs_to = array('comments_thread');
protected $belongs_to = array('comments_thread', 'user');
/**
* Returns all comments belongs to thread
freenetis/branches/comments/application/models/member.php
$where = implode(" AND ",$where);
$where = ($where!='') ? 'WHERE '.$where : '';
return $this->db->query("SELECT
/*return $this->db->query("SELECT
m.id, m.registration, m.name,
s.street, ap.street_number, t.town, t.quarter,
m.variable_symbol, a.id AS aid,
......
$where
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results"
);
);*/
return $this->db->query("
SELECT id, registration, name, street, street_number, town, quarter, variable_symbol, aid, balance, redirect, GROUP_CONCAT(a_comment SEPARATOR '\n\n') AS a_comment FROM
(
SELECT
m.id, m.registration, m.name,
s.street, ap.street_number, t.town, t.quarter,
m.variable_symbol, a.id AS aid,
a.balance,
m.redirect, CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text) AS a_comment
FROM members m
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN comments c ON ct.id = c.comments_thread_id
LEFT JOIN users u ON c.user_id = u.id
$where
ORDER BY c.datetime DESC
) AS q
GROUP BY q.id
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results
");
}
/**
freenetis/branches/comments/application/controllers/users.php
}
} // end of add function
/**
* Shows works of user
*
* @author Michal Kliment
* @param integer $work_id
*/
public function show_work ($work_id = NULL)
{
Works_Controller::show ($work_id);
}
/**
* Callback for type field
freenetis/branches/comments/application/controllers/transfers.php
// $transfers_grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/edit')->action(url_lang::lang('texts.Edit'));
$transfers_grid->datasource($transfers);
$comment_model = new Comment_Model();
$comments = $comment_model->get_all_comments_by_comments_thread($account->comments_thread_id);
if ($this->acl_check_view ('Members_Controller','comment',$account->member_id))
{
$comment_model = new Comment_Model();
$comments = $comment_model->get_all_comments_by_comments_thread($account->comments_thread_id);
$comments_grid = new Grid(url_lang::base().'members', null,array(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false,
));
$comments_grid = new Grid(url_lang::base().'members', null,array(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false,
));
$url = ($account->comments_thread_id) ? url_lang::base().'comments/add/'.$account->comments_thread_id : url_lang::base().'comments_threads/add/account/'.$account->id;
$comments_grid->add_new_button($url, url_lang::lang('texts.Add comment'));
$url = ($account->comments_thread_id) ? url_lang::base().'comments/add/'.$account->comments_thread_id : url_lang::base().'comments_threads/add/account/'.$account->id;
$comments_grid->add_new_button($url, url_lang::lang('texts.Add comment'));
//$comments_grid->field('id')->label('ID');
$comments_grid->field('text')->label(url_lang::lang('texts.Text'));
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.User'))->callback('callback::user_field');
$comments_grid->field('datetime')->label(url_lang::lang('texts.Time'));
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.Edit'))->callback('callback::edit_field','comments');
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.Delete'))->callback('callback::delete_field','comments');
$comments_grid->datasource($comments);
//$comments_grid->field('id')->label('ID');
$comments_grid->field('text')->label(url_lang::lang('texts.Text'));
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.User'))->callback('callback::user_field');
$comments_grid->field('datetime')->label(url_lang::lang('texts.Time'));
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.Edit'))->callback('callback::edit_field','comments');
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.Delete'))->callback('callback::delete_field','comments');
$comments_grid->datasource($comments);
}
$view = new View('main');
......
$view->content->outbound = $outbound;
$view->content->expiration_date = Members_Controller::get_expiration_date($account);
$view->content->transfers_grid = $transfers_grid;
$view->content->comments_grid = $comments_grid;
if ($this->acl_check_view ('Members_Controller','comment',$account->member_id))
$view->content->comments_grid = $comments_grid;
$view->content->message = $this->session->get_once('message');
$view->render(TRUE);
} // end of show_by_account function
freenetis/branches/comments/application/controllers/works.php
$view = new View('main');
$view->title = url_lang::lang('texts.Pending works');
$view->breadcrumbs = url_lang::lang('texts.Pending works');
$view->content = new View('works');
$view->content->grid = $grid;
$view->render(TRUE);
......
$view = new View('main');
$view->title = url_lang::lang('texts.Approved works');
$view->breadcrumbs = url_lang::lang('texts.Approved works');
$view->content = new View('works');
$view->content->grid = $grid;
$view->render(TRUE);
......
$view = new View('main');
$view->title = url_lang::lang('texts.Rejected works');
$view->breadcrumbs = url_lang::lang('texts.Rejected works');
$view->content = new View('works');
$view->content->grid = $grid;
$view->render(TRUE);
......
// access control
if ($this->acl_check_view('Users_Controller','work',$user->member_id))
$pending_works_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'works/show') ->action(url_lang::lang('texts.Show'))->class('center');
$pending_works_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'users/show_work') ->action(url_lang::lang('texts.Show'))->class('center');
$pending_works_grid->datasource($pending_works);
......
// access control
if ($this->acl_check_view('Users_Controller','work', $user->member_id))
$approved_works_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'works/show') ->action(url_lang::lang('texts.Show'))->class('center');
$approved_works_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'users/show_work') ->action(url_lang::lang('texts.Show'))->class('center');
$approved_works_grid->datasource($approved_works);
......
// access control
if ($this->acl_check_view('Users_Controller','work', $user->member_id))
$rejected_works_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'works/show') ->action(url_lang::lang('texts.Show'))->class('center');
$rejected_works_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'users/show_work') ->action(url_lang::lang('texts.Show'))->class('center');
$rejected_works_grid->datasource($rejected_works);
......
url::redirect(url::base().url::current(TRUE));
}
// breadcrumbs navigation
$breadcrumbs = array();
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members')) ? html::anchor (url_lang::base().'members/show_all', url_lang::lang('texts.Members')) : url_lang::lang('texts.Members');
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members', $user->member->id)) ? html::anchor(url_lang::base().'members/show/'.$user->member->id, "ID ".$user->member->id." - ".$user->member->name) : "ID ".$user->member->id." - ".$user->member->name;
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$user->member_id)) ? html::anchor (url_lang::base().'users/show_by_member/'.$user->member_id, url_lang::lang('texts.Users')) : url_lang::lang('texts.Users');
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$user->member_id)) ? html::anchor (url_lang::base().'users/show/'.$user->id, "$user->name $user->surname ($user->login)") : "$user->name $user->surname ($user->login)";
$breadcrumbs[] = url_lang::lang('texts.Works');
$view = new View('main');
$view->title = url_lang::lang('texts.List of works of user').' '.$user->name.' '.$user->surname;
$view->breadcrumbs = implode(' » ', $breadcrumbs);
$view->content = new View('works_show_by_user');
$view->content->headline = url_lang::lang('texts.List of works of user').' '.$user->name.' '.$user->surname;
$view->content->user = $user;
......
if (!$this->acl_check_view('Users_Controller','work',$work->user->member_id))
Controller::error(ACCESS);
// breadcrumbs navigation
$this->breadcrumbs = array();
if (url::slice(url_lang::uri(path::previous()),1,1) == 'show_by_user')
{
$this->breadcrumbs[] = ($this->acl_check_view('Members_Controller','members')) ? html::anchor (url_lang::base().'members/show_all', url_lang::lang('texts.Members')) : url_lang::lang('texts.Members');
$this->breadcrumbs[] = ($this->acl_check_view('Members_Controller','members', $work->user->member->id)) ? html::anchor(url_lang::base().'members/show/'.$work->user->member->id, "ID ".$work->user->member->id." - ".$work->user->member->name) : "ID ".$work->user->member->id." - ".$work->user->member->name;
$this->breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$work->user->member_id)) ? html::anchor (url_lang::base().'users/show_by_member/'.$work->user->member_id, url_lang::lang('texts.Users')) : url_lang::lang('texts.Users');
$this->breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$work->user->member_id)) ? html::anchor (url_lang::base().'users/show/'.$work->user->id, $work->user->name." ".$work->user->surname." (".$work->user->login.")") : $work->user->name." ".$work->user->surname." (".$work->user->login.")";
$this->breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$work->user->member_id)) ? html::anchor (url_lang::base().'works/show_by_user/'.$work->user->id, url_lang::lang('texts.Works')) : url_lang::lang('texts.Works');
}
else
{
switch ($work->state)
{
case 0:
case 1:
$this->breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/pending', url_lang::lang('texts.Pending works')) : url_lang::lang('texts.Pending works');
break;
case 2:
$this->breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/rejected', url_lang::lang('texts.Rejected works')) : url_lang::lang('texts.Rejected works');
break;
case 3:
$this->breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/approved', url_lang::lang('texts.Approved works')) : url_lang::lang('texts.Approved works');
break;
}
}
$this->breadcrumbs[] = url_lang::lang('texts.ID').' '.$work->id;
if ($work->state <= 1)
// work is opened
$this->show_opened ($work);
self::show_opened ($work);
else
// work is closed
$this->show_closed ($work);
self::show_closed ($work);
}
/**
......
if (!$work->job_report_id)
{
$links[] = html::anchor(url_lang::base().'works/pending', url_lang::lang('texts.of all pending works'));
$links[] = html::anchor(url_lang::base().'works/show_by_user/'.$work->user_id, url_lang::lang('texts.of all users works'));
//$links[] = html::anchor(url_lang::base().'works/pending', url_lang::lang('texts.of all pending works'));
//$links[] = html::anchor(url_lang::base().'works/show_by_user/'.$work->user_id, url_lang::lang('texts.of all users works'));
if ($this->acl_check_edit('Users_Controller','work',$work->user->member_id) && $work->state == 0)
$links[] = html::anchor(url_lang::base().'works/edit/'.$work->id,url_lang::lang('texts.Edit'));
if ($this->acl_check_delete('Users_Controller','work',$work->user->member_id) && $work->state == 0)
$links[] = html::anchor(url_lang::base().'works/delete/'.$work->id,url_lang::lang('texts.Delete'), array('class' => 'delete_link'));
$links = url_lang::lang('texts.Back to list').': '.implode(" | ", $links);
$links = implode(" | ", $links);
}
else
{
$links = html::anchor(url_lang::base().'work_reports/show/'.$work->job_report_id, url_lang::lang('texts.Back to the work report'));
}
if ($this->acl_check_view('Comments_Controller', 'works', $work->user->member_id))
{
$comment_model = new Comment_Model();
$comments = $comment_model->get_all_comments_by_comments_thread($work->comments_thread_id);
$comments_grid = new Grid(url_lang::base().'members', null,array(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false,
));
$url = ($work->comments_thread_id) ? url_lang::base().'comments/add/'.$work->comments_thread_id : url_lang::base().'comments_threads/add/job/'.$work->id;
$comments_grid->add_new_button($url, url_lang::lang('texts.Add comment'));
$comments_grid->field('text')->label(url_lang::lang('texts.Text'));
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.User'))->callback('callback::user_field');
$comments_grid->field('datetime')->label(url_lang::lang('texts.Time'));
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.Edit'))->callback('callback::edit_field','comments');
$comments_grid->callback_field('user_id')->label(url_lang::lang('texts.Delete'))->callback('callback::delete_field','comments');
$comments_grid->datasource($comments);
}
$view = new View('main');
$view->title = url_lang::lang('texts.Show work');
$view->breadcrumbs = implode(' » ', $this->breadcrumbs);
$view->content = new View('works_show');
$view->content->work = $work;
$view->content->links = $links;
......
$view->content->sums = $sums;
$view->content->state_text = $state_text;
$view->content->percents = $percents;
if ($this->acl_check_view('Comments_Controller', 'works', $work->user->member_id))
$view->content->comments_grid = $comments_grid;
$view->render(TRUE);
}
......
}
if (!$work->job_report_id)
$links[] = html::anchor(url_lang::base().'works/rejected', url_lang::lang('texts.of all rejected works'));
//$links[] = html::anchor(url_lang::base().'works/rejected', url_lang::lang('texts.of all rejected works'));
break;
case 3:
$state_text = '<span style="color: green">'.url_lang::lang('texts.Approved').'</span>';
if (!$work->job_report_id)
$links[] = html::anchor(url_lang::base().'works/approved', url_lang::lang('texts.of all approved works'));
//if (!$work->job_report_id)
//$links[] = html::anchor(url_lang::base().'works/approved', url_lang::lang('texts.of all approved works'));
break;
}
if (!$work->job_report_id)
{
$links[] = html::anchor(url_lang::base().'works/show_by_user/'.$work->user_id, url_lang::lang('texts.of all users works'));
//$links[] = html::anchor(url_lang::base().'works/show_by_user/'.$work->user_id, url_lang::lang('texts.of all users works'));
if ($this->acl_check_edit('Users_Controller','work',$work->user->member_id) && $work->state == 0)
$links[] = html::anchor(url_lang::base().'works/edit/'.$work->id,url_lang::lang('texts.Edit'));
$links = url_lang::lang('texts.Back to list').': '.implode(" | ", $links);
$links =implode(" | ", $links);
}
else
{
......
$view = new View('main');
$view->title = url_lang::lang('texts.Show work');
$view->breadcrumbs = implode(' » ', $this->breadcrumbs);
$view->content = new View('works_show');
$view->content->work = $work;
$view->content->transfer = $transfer;
......
*/
function add($user_id = null)
{
$breadcrumbs = array();
if(isset($user_id))
{
$user = new User_Model($user_id);
......
Controller::error(ACCESS);
$selected = $user->id;
$arr_users[$user->id] = $user->surname.' '.$user->name.' - '.$user->login;
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members')) ? html::anchor (url_lang::base().'members/show_all', url_lang::lang('texts.Members')) : url_lang::lang('texts.Members');
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members', $user->member->id)) ? html::anchor(url_lang::base().'members/show/'.$user->member->id, "ID ".$user->member->id." - ".$user->member->name) : "ID ".$user->member->id." - ".$user->member->name;
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$user->member_id)) ? html::anchor (url_lang::base().'users/show_by_member/'.$user->member_id, url_lang::lang('texts.Users')) : url_lang::lang('texts.Users');
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$user->member_id)) ? html::anchor (url_lang::base().'users/show/'.$user->id, "$user->name $user->surname ($user->login)") : "$user->name $user->surname ($user->login)";
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$user->member_id)) ? html::anchor (url_lang::base().'works/show_by_user/'.$user->id, url_lang::lang('texts.Works')) : url_lang::lang('texts.Works');
}
else
{
......
}
asort($arr_users, SORT_LOCALE_STRING);
$arr_users = arr::merge(array(NULL => '----- '.url_lang::lang('texts.select user').' -----'), $arr_users);
$breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/pending', url_lang::lang('texts.Pending works')) : url_lang::lang('texts.Pending works');
}
$breadcrumbs[] = url_lang::lang('texts.Add');
if ($this->acl_check_view('approval','templates'))
{
$approval_template_model = new Approval_template_Model();
......
$headline = url_lang::lang('texts.Add new work');
$view = new View('main');
$view->title = $headline;
$view->breadcrumbs = implode(' » ', $breadcrumbs);
$view->content = new View('form');
$view->content->headline = $headline;
$view->content->link_back = $anchor;
//$view->content->link_back = $anchor;
$view->content->link_back = '';
$view->content->form = $form->html();
$view->render(TRUE);
}
freenetis/branches/comments/application/controllers/comments.php
{
// thread belongs to account
case 'account':
// access control
if (!$this->acl_check_view ('Members_Controller','comment',$parent->member_id))
Controller::error (ACCESS);
$link_back_url = url_lang::base().'transfers/show_by_account/'.$parent->id;
$breadcrumbs[] = html::anchor (url_lang::base().'members/show_all', url_lang::lang('texts.Members'));
......
$breadcrumbs[] = html::anchor ($link_back_url, url_lang::lang('texts.Transfers'));
$breadcrumbs[] = url_lang::lang('texts.Add comment');
break;
case 'job':
// access control
if (!$this->acl_check_new (get_class($this),'works',$parent->user->member_id))
Controller::error (ACCESS);
if (url::slice(url_lang::uri(Path::instance()->previous()->current()),1,1) == 'show_work')
{
$link_back_url = url_lang::base().'users/show_work/'.$parent->id;
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members')) ? html::anchor (url_lang::base().'members/show_all', url_lang::lang('texts.Members')) : url_lang::lang('texts.Members');
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members', $parent->user->member->id)) ? html::anchor(url_lang::base().'members/show/'.$parent->user->member->id, "ID ".$parent->user->member->id." - ".$parent->user->member->name) : "ID ".$parent->user->member->id." - ".$parent->user->member->name;
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$parent->user->member_id)) ? html::anchor (url_lang::base().'users/show_by_member/'.$parent->user->member_id, url_lang::lang('texts.Users')) : url_lang::lang('texts.Users');
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$parent->user->member_id)) ? html::anchor (url_lang::base().'users/show/'.$parent->user->id, $parent->user->name." ".$parent->user->surname." (".$parent->user->login.")") : $parent->user->name." ".$parent->user->surname." (".$parent->user->login.")";
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$parent->user->member_id)) ? html::anchor (url_lang::base().'works/show_by_user/'.$parent->user->id, url_lang::lang('texts.Works')) : url_lang::lang('texts.Works');
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$parent->user->member_id)) ? html::anchor (url_lang::base().'users/show_work/'.$parent->id, url_lang::lang('texts.ID').' '.$parent->id) : url_lang::lang('texts.ID').' '.$parent->id;
}
else
{
$link_back_url = url_lang::base().'works/show/'.$parent->id;
switch ($parent->state)
{
case 0:
case 1:
$breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/pending', url_lang::lang('texts.Pending works')) : url_lang::lang('texts.Pending works');
break;
case 2:
$breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/rejected', url_lang::lang('texts.Rejected works')) : url_lang::lang('texts.Rejected works');
break;
case 3:
$breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/approved', url_lang::lang('texts.Approved works')) : url_lang::lang('texts.Approved works');
break;
}
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$parent->user->member_id)) ? html::anchor (url_lang::base().'works/show/'.$parent->id, url_lang::lang('texts.ID').' '.$parent->id) : url_lang::lang('texts.ID').' '.$parent->id;
}
$breadcrumbs[] = url_lang::lang('texts.Add comment');
break;
default:
Controller::error(RECORD);
break;
......
{
// thread belongs to account
case 'account':
// access control
if (!$this->acl_check_view ('Members_Controller','comment',$parent->member_id))
Controller::error (ACCESS);
$link_back_url = url_lang::base().'transfers/show_by_account/'.$parent->id;
$breadcrumbs[] = html::anchor (url_lang::base().'members/show_all', url_lang::lang('texts.Members'));
......
$breadcrumbs[] = html::anchor ($link_back_url, url_lang::lang('texts.Transfers'));
$breadcrumbs[] = url_lang::lang('texts.Edit comment');
break;
case 'job':
// access control
if (!$this->acl_check_edit (get_class($this),'works',$comment->user->member_id))
Controller::error (ACCESS);
if (url::slice(url_lang::uri(Path::instance()->previous()->current()),1,1) == 'show_work')
{
$link_back_url = url_lang::base().'users/show_work/'.$parent->id;
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members')) ? html::anchor (url_lang::base().'members/show_all', url_lang::lang('texts.Members')) : url_lang::lang('texts.Members');
$breadcrumbs[] = ($this->acl_check_view('Members_Controller','members', $parent->user->member->id)) ? html::anchor(url_lang::base().'members/show/'.$parent->user->member->id, "ID ".$parent->user->member->id." - ".$parent->user->member->name) : "ID ".$parent->user->member->id." - ".$parent->user->member->name;
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$parent->user->member_id)) ? html::anchor (url_lang::base().'users/show_by_member/'.$parent->user->member_id, url_lang::lang('texts.Users')) : url_lang::lang('texts.Users');
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'users',$parent->user->member_id)) ? html::anchor (url_lang::base().'users/show/'.$parent->user->id, $parent->user->name." ".$parent->user->surname." (".$parent->user->login.")") : $parent->user->name." ".$parent->user->surname." (".$parent->user->login.")";
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$parent->user->member_id)) ? html::anchor (url_lang::base().'works/show_by_user/'.$parent->user->id, url_lang::lang('texts.Works')) : url_lang::lang('texts.Works');
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$parent->user->member_id)) ? html::anchor (url_lang::base().'users/show_work/'.$parent->id, url_lang::lang('texts.ID').' '.$parent->id) : url_lang::lang('texts.ID').' '.$parent->id;
}
else
{
$link_back_url = url_lang::base().'works/show/'.$parent->id;
switch ($parent->state)
{
case 0:
case 1:
$breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/pending', url_lang::lang('texts.Pending works')) : url_lang::lang('texts.Pending works');
break;
case 2:
$breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/rejected', url_lang::lang('texts.Rejected works')) : url_lang::lang('texts.Rejected works');
break;
case 3:
$breadcrumbs[] = ($this->acl_check_view('Users_Controller','work')) ? html::anchor (url_lang::base().'works/approved', url_lang::lang('texts.Approved works')) : url_lang::lang('texts.Approved works');
break;
}
$breadcrumbs[] = ($this->acl_check_view('Users_Controller', 'work',$parent->user->member_id)) ? html::anchor (url_lang::base().'works/show/'.$parent->id, url_lang::lang('texts.ID').' '.$parent->id) : url_lang::lang('texts.ID').' '.$parent->id;
}
$breadcrumbs[] = url_lang::lang('texts.Edit comment');
break;
default:
Controller::error(RECORD);
break;
......
{
// thread belongs to account
case 'account':
// access control
if (!$this->acl_check_view ('Members_Controller','comment',$parent->member_id))
Controller::error (ACCESS);
$link_back_url = url_lang::base().'transfers/show_by_account/'.$parent->id;
break;
case 'job':
// access control
if (!$this->acl_check_delete(get_class($this),'works',$comment->user->member_id))
Controller::error (ACCESS);
if ($comment->delete())
$this->session->set_flash('message', url_lang::lang('texts.Comment has been successfully deleted').'.');
url::redirect ($link_back_url);
if (url::slice(url_lang::uri(Path::instance()->previous()->current()),1,1) == 'show_work')
$link_back_url = url_lang::base().'users/show_work/'.$parent->id;
else
$link_back_url = url_lang::base().'works/show/'.$parent->id;
break;
default:
Controller::error(RECORD);
break;
}
if ($comment->delete())
$this->session->set_flash('message', url_lang::lang('texts.Comment has been successfully deleted').'.');
url::redirect ($link_back_url);
}
}
freenetis/branches/comments/application/upgrade_sql/upgrade_sql.php
// array of sql queries that upgrade database
$upgrade_sql[get_SVN_rev()] = array(
"CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`comments_thread_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`text` text COLLATE utf8_czech_ci NOT NULL,
`datetime` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `comments_thread_id` (`comments_thread_id`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"INSERT INTO `acl` (`id`, `section_value`, `allow`, `enabled`, `return_value`, `note`, `updated_date`) VALUES ('76', 'user', '1', '1', NULL, 'Engineers can view all comments, they can add/edit/delete own comments.', '0');",
"CREATE TABLE IF NOT EXISTS `comments_threads` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(255) COLLATE utf8_czech_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"INSERT INTO `axo` (`id`, `section_value`, `value`, `order_value`, `name`, `hidden`) VALUES ('174', 'Comments_Controller', 'works', '0', '', '0');",
"ALTER TABLE `accounts` ADD `comments_thread_id` INT( 11 ) NULL DEFAULT NULL ,
ADD INDEX ( `comments_thread_id` )",
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES ('76', 'Comments_Controller', 'works');",
"ALTER TABLE `jobs` ADD `comments_thread_id` INT( 11 ) NULL DEFAULT NULL ,
ADD INDEX ( `comments_thread_id` )",
"INSERT INTO `aco_map` (`acl_id` ,`section_value` ,`value`) VALUES ('76', 'freenetis', 'view_all'), ('76', 'freenetis', 'new_all');",
"INSERT INTO `aco_map` (`acl_id` ,`section_value` ,`value`) VALUES ('76', 'freenetis', 'edit_own'), ('76', 'freenetis', 'delete_own');",
"INSERT INTO `aro_groups_map` (`acl_id`, `group_id`) VALUES ('76', '29');",
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES ('38', 'Comments_Controller', 'works');",
);
?>
freenetis/branches/comments/application/upgrade_sql/upgrade_sql_937.php
<?php
// array of sql queries that upgrade database
$upgrade_sql[937] = array(
"CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`comments_thread_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`text` text COLLATE utf8_czech_ci NOT NULL,
`datetime` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `comments_thread_id` (`comments_thread_id`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"CREATE TABLE IF NOT EXISTS `comments_threads` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(255) COLLATE utf8_czech_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"ALTER TABLE `accounts` ADD `comments_thread_id` INT( 11 ) NULL DEFAULT NULL ,
ADD INDEX ( `comments_thread_id` )",
"ALTER TABLE `jobs` ADD `comments_thread_id` INT( 11 ) NULL DEFAULT NULL ,
ADD INDEX ( `comments_thread_id` )",
);
?>
freenetis/branches/comments/application/libraries/Path.php
<?php defined('SYSPATH') or die('No direct script access.');
/**
* @author Michal Kliment
* @version 1.0
*
* This is library for path = history of urls
* It works as iterarator
*/
class Path
{
/**
* Actual path
* @var string
*/
private $path = NULL;
/**
* Id of current position in pathl
* @var integer
*/
private $id = NULL;
/**
* Array of all paths
* @var array
*/
private $paths = NULL;
/**
* For singleton instance
* @var Path object
*/
private static $instance = NULL;
/**
* Creates or return instance of object
*
* @author Michal Kliment
* @return Path object
*/
public static function instance()
{
// Create the instance if it does not exist
empty(self::$instance) and new Path;
return self::$instance;
}
/**
* Constructor, only clear object
*
* @author Michal Kliment
*/
public function __construct ()
{
if (self::$instance === NULL)
{
$this->clear();
self::$instance = $this;
}
}
/**
* Clear object - sets to default value
*
*@author Michal Kliment
* @return Path object
*/
public function clear()
{
$this->paths = Session::instance()->get('paths');
$this->set_path (Session::instance()->get('last_path_id'));
return $this;
}
/**
* Sets path to given id
*
* @author Michal Kliment
* @param integer $path_id
* @return boolean
*/
public function set_path ($path_id = NULL)
{
if (isset($this->paths[$path_id]))
{
$this->path = $this->paths[$path_id];
$this->last();
return true;
}
else
return false;
}
/**
* Returns URL of current position in object
*
* @author Michal Kliment
* @return string
*/
public function current()
{
return $this->path[$this->id];
}
/**
* Goes to previous position
*
* @author Michal Kliment
* @return Path object
*/
public function previous()
{
if ($this->id > 0)
$this->id--;
return $this;
}
/**
* Goes to next position
*
* @author Michal Kliment
* @return Path object
*/
public function next()
{
if ($this->id < (count($this->path)-1))
$this->id++;
return $this;
}
/**
* Goes to first position
*
* @author Michal Kliment
* @return Path object
*/
public function first()
{
$this->id = 0;
return $this;
}
/**
* Goes to last position
*
* @author Michal Kliment
* @return Path object
*/
public function last()
{
$this->id = count($this->path)-1;
return $this;
}
}
?>
freenetis/branches/comments/application/libraries/MY_Controller.php
/**
* Function to update paths
* @author MIchal Kliment
* @author Michal Kliment
*/
private function update_paths ()
{
......
{
$path = $paths[$this->session->get('last_path_id')];
if (url::base().url::previous() == $path[count($path)-1])
$paths[$this->session->get('last_path_id')][] = url::base().url::current();
else
if ($path[count($path)-1] != url::base().url::current())
{
foreach ($paths as $id => $path)
if (url::base().url::previous() != $path[count($path)-1])
{
if (url::base().url::previous() == $path[count($path)-1])
foreach ($paths as $id => $path)
{
$this->session->set('last_path_id', $id);
if (url::base().url::previous() == $path[count($path)-1])
{
$this->session->set('last_path_id', $id);
break;
}
}
}
$path = NULL;
foreach ($paths[$this->session->get('last_path_id')] as $i => $url)
{
if (url::base().url::current() == $url)
{
$path = array_slice($paths[$this->session->get('last_path_id')], 0, $i+1);
break;
}
}
$paths[$this->session->get('last_path_id')][] = url::base().url::current();
if (!$path)
$paths[$this->session->get('last_path_id')][] = url::base().url::current();
else
$paths[$this->session->get('last_path_id')] = $path;
}
}
else
freenetis/branches/comments/application/views/works_show_by_user.php
<h2><?php echo $headline ?></h2>
<?php echo ($message = $this->session->get('message')) ? '<div class="message">'.$message.'</div>' : '' ?>
<br />
<?php
if ($this->acl_check_view('Members_Controller','members',$user->member_id))
$links[] = html::anchor(url_lang::base().'members/show/'.$user->member_id, url_lang::lang('texts.Back to the member'));
if ($this->acl_check_view('Users_Controller','users',$user->member_id))
$links[] = html::anchor(url_lang::base().'users/show/'.$user->id, url_lang::lang('texts.Back to the user'));
echo implode(' | ', $links);
?>
<br />
<br />
<br />
<h3><?php echo url_lang::lang('texts.Pending works') ?></h3>
<?php echo $pending_works_grid ?>
freenetis/branches/comments/application/views/works_show.php
<h3><?php echo url_lang::lang('texts.Approval') ?> - <?php echo url_lang::lang('texts.'.$vote_groups[$i]) ?></h3>
<b><?php echo $percents[$i] ?>% (<?php echo $agrees[$i] ?>/<?php echo $total_votes[$i] ?>)</b><br /><br />
<?php echo $vote_grid ?><br /><br />
<?php endforeach ?>
<?php endforeach ?>
<?php if (isset($comments_grid)): ?>
<h3><?php echo url_lang::lang('texts.Comments') ?></h3>
<?php echo $comments_grid ?>
<?php endif ?>
freenetis/branches/comments/application/views/transfers/show_by_account.php
// $links[] = html::anchor (url_lang::base().'members/show/'.$account->member_id, url_lang::lang('texts.Back to the member'));
$links[] = html::anchor (url_lang::base().'transfers/show_by_account/'.$account->id.'#transfers', url_lang::lang('texts.Transfers'), array('id' => 'transfers_link'));
$links[] = html::anchor (url_lang::base().'transfers/show_by_account/'.$account->id.'#comments', url_lang::lang('texts.Comments'), array('id' => 'comments_link'));
if ($this->acl_check_view ('Members_Controller','comment',$account->member_id))
$links[] = html::anchor (url_lang::base().'transfers/show_by_account/'.$account->id.'#comments', url_lang::lang('texts.Comments'), array('id' => 'comments_link'));
echo implode(' | ', $links);
?>
<br />
<?php echo $message ? '<div class="message">'.$message.'</div>' : '' ?>
<br />
<table class="extended" style="float:left">
<tr>
......
<?php echo $transfers_grid; ?><br />
</div>
<?php if ($this->acl_check_view ('Members_Controller','comment',$account->member_id)): ?>
<div id="comments_grid">
<h3><a name="comments"><?php echo url_lang::lang('texts.Comments') ?></a></h3>
<?php echo $comments_grid; ?>
</div>
</div>
<?php endif ?>

Také k dispozici: Unified diff