/**
  * Execute report
  *
  * @param User $user
  * @param TimeReport $report
  * @param Project $project
  * @return array
  */
 function executeReport($user, $report, $project = null)
 {
     $conditions = $report->prepareConditions($user, $project);
     if (empty($conditions)) {
         return null;
     }
     // if
     if ($report->getSumByUser()) {
         $rows = db_execute_all('SELECT SUM(float_field_1) AS total_time, integer_field_1 AS user_id FROM ' . TABLE_PREFIX . 'project_objects WHERE ' . $conditions . ' GROUP BY integer_field_1');
         if (is_foreachable($rows)) {
             $result = array();
             foreach ($rows as $row) {
                 $user = Users::findById($row['user_id']);
                 if (instance_of($user, 'User')) {
                     $result[] = array('user' => $user, 'total_time' => float_format($row['total_time'], 2));
                 }
                 // if
             }
             // foreach
             return $result;
         } else {
             return null;
         }
         // if
     } else {
         return TimeRecords::findBySQL('SELECT * FROM ' . TABLE_PREFIX . 'project_objects WHERE ' . $conditions . ' ORDER BY date_field_1');
     }
     // if
 }
Example #2
0
/**
 * Render project users combo.
 *
 * @param String $name
 * @param array $attributes
 * @return String All users I am sharing something with.
 */
function render_sharing_users($name, $attributes = null)
{
    //TODO:  This functions must be rebuilt
    $perms = ObjectUserPermissions::getAllPermissionsByUser(logged_user());
    $options = array(option_tag(lang('none'), 0));
    $my_id = logged_user()->getId();
    if (isset($perms)) {
        foreach ($perms as $perm) {
            $file_id = $perm->getFileId();
            if (trim($file_id) != '') {
                $users = ObjectUserPermissions::getAllPermissionsByObjectIdAndManager($file_id, 'ProjectFiles');
                foreach ($users as $user_perm) {
                    $user_id = $user_perm->getUserId();
                    if ($user_id != null && trim($user_id) != '' && $user_id != $my_id) {
                        $user = Users::findById($user_id);
                        if ($user != null) {
                            //foreach user
                            $options[] = option_tag($user->getUserName(), $user->getUserName());
                        }
                    }
                }
            }
        }
    }
    $options = array_unique($options);
    return select_box($name, $options, $attributes);
}
 /**
  * Return user object
  *
  * @param void
  * @return User
  */
 function getUser()
 {
     if (is_null($this->user)) {
         $this->user = Users::findById($this->getUserId());
     }
     return $this->user;
 }
 /**
  * Set user object from the system
  *
  * @param void
  * @return null
  */
 function setSystemUser()
 {
     if (is_null($this->system_user)) {
         $this->system_user = Users::findById($this->getUserId());
     }
     // if
 }
 /**
  * Return parent user
  *
  * @param void
  * @return User
  */
 function getResponsibleUser()
 {
     if (is_null($this->user)) {
         $this->user = Users::findById($this->getResponsibleUserId());
     }
     // if
     return $this->user;
 }
 function getUserName()
 {
     $user = Users::findById($this->getCreatedById());
     if ($user instanceof User) {
         return $user->getUsername();
     } else {
         return null;
     }
 }
 function initUser($id)
 {
     $this->user = Users::findById($id);
     if ($this->user != null) {
         CompanyWebsite::instance()->setLoggedUser($this->user);
     } else {
         ImportLogger::instance()->logError("User not found: id={$id}");
         die("User not found: id={$id}");
     }
 }
Example #8
0
 public function setAction($id = null)
 {
     $this->view->title = "Set Password - ";
     $this->view->selectmenu = "password";
     if ($this->request->isPost()) {
         $user = Users::findById($id);
         $password = $this->request->getPost('password');
         $user->password = $this->security->hash($password);
         $response = $id;
         $user->save();
         return $this->dispatcher->forward(array('action' => 'index', 'params' => array($this->view->title, $this->view->selectmenu, $response)));
     }
 }
 /**
  * Return project leader
  *
  * @param void
  * @return User
  */
 function getLeader()
 {
     if ($this->leader === false) {
         if ($this->getLeaderId()) {
             $this->leader = Users::findById($this->getLeaderId());
         }
         // if
         if (!instance_of($this->leader, 'User')) {
             $this->leader = new AnonymousUser($this->getLeaderName(), $this->getLeaderEmail());
         }
     }
     // if
     return $this->leader;
 }
 /**
  * Delete specific user
  *
  * @access public
  * @param void
  * @return null
  */
 function delete()
 {
     $this->setTemplate('del_user');
     $user = Users::findById(get_id());
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         $this->redirectTo('administration');
     }
     // if
     if (!$user->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $delete_data = array_var($_POST, 'deleteUser');
     tpl_assign('user', $user);
     tpl_assign('delete_data', $delete_data);
     if (!is_array($delete_data)) {
         $delete_data = array('really' => 0, 'password' => '');
         // array
         tpl_assign('delete_data', $delete_data);
     } else {
         if ($delete_data['really'] == 1) {
             $password = $delete_data['password'];
             if (trim($password) == '') {
                 tpl_assign('error', new Error(lang('password value missing')));
                 return $this->render();
             }
             if (!logged_user()->isValidPassword($password)) {
                 tpl_assign('error', new Error(lang('invalid login data')));
                 return $this->render();
             }
             try {
                 DB::beginWork();
                 $user->delete();
                 ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_DELETE);
                 DB::commit();
                 flash_success(lang('success delete user', $user->getDisplayName()));
             } catch (Exception $e) {
                 DB::rollback();
                 flash_error(lang('error delete user'));
             }
             // try
             $this->redirectToUrl($user->getCompany()->getViewUrl());
         } else {
             flash_error(lang('error delete user'));
             $this->redirectToUrl($user->getCompany()->getViewUrl());
         }
     }
 }
  		function SetData($billing_chart_data){
  			$this->data = array();
			
	    	foreach ($billing_chart_data as $row){
	    		$value = 0;
	    		$user = Users::findById($row['user']);
	    		if ($user instanceof User){
		    		$this->data['values'][0]['labels'][] = $user->getDisplayName();
		    		$this->data['values'][0]['values'][] = $row['total_billing'];
	    		}
		    	$this->total += $row['total_billing'];
	    	} // foreach
	    	
	    	$this->data['values'][0]['name'] = lang('current');
  		}
 /**
  * Display user details
  */
 function user()
 {
     $user_id = $this->request->get('object_id');
     if ($user_id) {
         $current_user = Users::findById($user_id);
     }
     // if
     if (!instance_of($current_user, 'User')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     if (!in_array($current_user->getId(), $this->logged_user->visibleUserIds())) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $current_user_company = $current_user->getCompany();
     $this->smarty->assign(array("current_user" => $current_user, "current_user_company" => $current_user->getCompany(), "page_title" => $current_user->getName(), "page_back_url" => mobile_access_module_get_view_url($current_user_company)));
 }
 /**
  * Construct Profile Controller
  *
  * @param void
  * @return null
  */
 function __construct($request)
 {
     parent::__construct($request);
     $user_id = $this->request->get('user_id');
     if ($user_id) {
         $this->active_user = Users::findById($user_id);
     }
     // if
     if (instance_of($this->active_user, 'User')) {
         if (!in_array($this->active_user->getId(), $this->logged_user->visibleUserIds())) {
             $this->httpError(HTTP_ERR_NOT_FOUND);
         }
         // if
         $this->wireframe->addBreadCrumb($this->active_user->getName(), $this->active_user->getViewUrl());
         if ($this->active_user->getId() == $this->logged_user->getId()) {
             $this->wireframe->current_menu_item = 'profile';
         }
         // if
     } else {
         $this->active_user = new User();
     }
     // if
     $this->smarty->assign('active_user', $this->active_user);
 }
Example #14
0
	og.events_selected = 0;
	og.eventSelected(0);
</script>

<?php 
define('PX_HEIGHT', 42);
$year = isset($_GET['year']) ? $_GET['year'] : (isset($_SESSION['year']) ? $_SESSION['year'] : date('Y'));
$month = isset($_GET['month']) ? $_GET['month'] : (isset($_SESSION['month']) ? $_SESSION['month'] : date('n'));
$day = isset($_GET['day']) ? $_GET['day'] : (isset($_SESSION['day']) ? $_SESSION['day'] : date('j'));
$_SESSION['year'] = $year;
$_SESSION['month'] = $month;
$_SESSION['day'] = $day;
$tags = active_tag();
$user_filter = $userPreferences['user_filter'];
$status_filter = $userPreferences['status_filter'];
$user = Users::findById(array('id' => $user_filter));
if ($user == null) {
    $user = logged_user();
}
$use_24_hours = user_config_option('time_format_use_24');
$date_format = user_config_option('date_format');
if ($use_24_hours) {
    $timeformat = 'G:i';
} else {
    $timeformat = 'g:i A';
}
echo stylesheet_tag('event/day.css');
$today = DateTimeValueLib::now();
$today->add('h', logged_user()->getTimezone());
$currentday = $today->format("j");
$currentmonth = $today->format("n");
 /**
  * Delete avatar
  *
  * @param void
  * @return null
  */
 function delete_avatar()
 {
     $user = Users::findById(get_id());
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         $this->redirectTo('dashboard');
     }
     // if
     if (!$user->canUpdateProfile(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('dashboard');
     }
     // if
     $redirect_to = array_var($_GET, 'redirect_to');
     if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) {
         $redirect_to = $user->getUpdateAvatarUrl();
     }
     // if
     tpl_assign('redirect_to', $redirect_to);
     if (!$user->hasAvatar()) {
         flash_error(lang('avatar dnx'));
         $this->redirectToUrl($redirect_to);
     }
     // if
     try {
         DB::beginWork();
         $user->deleteAvatar();
         $user->save();
         ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_EDIT);
         DB::commit();
         flash_success(lang('success delete avatar'));
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete avatar'));
     }
     // try
     $this->redirectToUrl($redirect_to);
 }
 /**
  * Remove user from project
  *
  * @param void
  * @return null
  */
 function remove_user()
 {
     if (!active_project()->canChangePermissions(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $user = Users::findById(get_id('user_id'));
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if ($user->isAccountOwner()) {
         flash_error(lang('user cant be removed from project'));
         ajx_current("empty");
         return;
     }
     // if
     $project = Projects::findById(get_id('project_id'));
     if (!$project instanceof Project) {
         flash_error(lang('project dnx'));
         ajx_current("empty");
         return;
     }
     // if
     $project_user = ProjectUsers::findById(array('project_id' => $project->getId(), 'user_id' => $user->getId()));
     if (!$project_user instanceof ProjectUser) {
         flash_error(lang('user not on project'));
         ajx_current("empty");
         return;
     }
     // if
     try {
         $project_user->delete();
         flash_success(lang('success remove user from project'));
         ajx_current("reload");
     } catch (Exception $e) {
         flash_error(lang('error remove user from project'));
         ajx_current("empty");
     }
     // try
 }
 /**
  * Get the user object for the user which locked this page
  * 
  * Returns null if user DNX or page is not locked
  * 
  * @return
  */
 function getLockedByUser()
 {
     // Cache the user object
     static $user = null;
     return $this->getLocked() ? $user instanceof User ? $user : ($user = Users::findById($this->getLockedById())) : null;
 }
 function total_task_times($report_data = null, $task = null)
 {
     if (!$report_data) {
         $report_data = array_var($_POST, 'report');
         // save selections into session
         $_SESSION['total_task_times_report_data'] = $report_data;
     }
     $conditions = array();
     $all_conditions = array_var($report_data, 'conditions');
     if (!is_array($all_conditions)) {
         $all_conditions = array_var($_POST, 'conditions');
     }
     if ($all_conditions != null) {
         tpl_assign('has_conditions', true);
     }
     if (is_array($all_conditions)) {
         foreach ($all_conditions as $condition) {
             if ($condition['deleted'] != "1") {
                 $conditions[] = $condition;
             }
         }
     }
     $columns = array_var($report_data, 'columns');
     if (!is_array($columns)) {
         $columns = array_var($_POST, 'columns', array());
     }
     asort($columns);
     //sort the array by column order
     foreach ($columns as $column => $order) {
         if ($order > 0) {
             $newColumn = new ReportColumn();
             //$newColumn->setReportId($newReport->getId());
             if (is_numeric($column)) {
                 $newColumn->setCustomPropertyId($column);
             } else {
                 $newColumn->setFieldName($column);
             }
         }
     }
     tpl_assign('allow_export', false);
     $this->setTemplate('report_wrapper');
     $user = Users::findById(array_var($report_data, 'user'));
     $workspace = Projects::findById(array_var($report_data, 'project_id'));
     if ($workspace instanceof Project) {
         if (array_var($report_data, 'include_subworkspaces')) {
             $workspacesCSV = $workspace->getAllSubWorkspacesQuery(null, logged_user());
         } else {
             $workspacesCSV = $workspace->getId();
         }
     } else {
         $workspacesCSV = logged_user()->getWorkspacesQuery();
     }
     $st = DateTimeValueLib::now();
     $et = DateTimeValueLib::now();
     switch (array_var($report_data, 'date_type')) {
         case 1:
             //Today
             $now = DateTimeValueLib::now();
             $st = DateTimeValueLib::make(0, 0, 0, $now->getMonth(), $now->getDay(), $now->getYear());
             $et = DateTimeValueLib::make(23, 59, 59, $now->getMonth(), $now->getDay(), $now->getYear());
             break;
         case 2:
             //This week
             $now = DateTimeValueLib::now();
             $monday = $now->getMondayOfWeek();
             $nextMonday = $now->getMondayOfWeek()->add('w', 1)->add('d', -1);
             $st = DateTimeValueLib::make(0, 0, 0, $monday->getMonth(), $monday->getDay(), $monday->getYear());
             $et = DateTimeValueLib::make(23, 59, 59, $nextMonday->getMonth(), $nextMonday->getDay(), $nextMonday->getYear());
             break;
         case 3:
             //Last week
             $now = DateTimeValueLib::now();
             $monday = $now->getMondayOfWeek()->add('w', -1);
             $nextMonday = $now->getMondayOfWeek()->add('d', -1);
             $st = DateTimeValueLib::make(0, 0, 0, $monday->getMonth(), $monday->getDay(), $monday->getYear());
             $et = DateTimeValueLib::make(23, 59, 59, $nextMonday->getMonth(), $nextMonday->getDay(), $nextMonday->getYear());
             break;
         case 4:
             //This month
             $now = DateTimeValueLib::now();
             $st = DateTimeValueLib::make(0, 0, 0, $now->getMonth(), 1, $now->getYear());
             $et = DateTimeValueLib::make(23, 59, 59, $now->getMonth(), 1, $now->getYear())->add('M', 1)->add('d', -1);
             break;
         case 5:
             //Last month
             $now = DateTimeValueLib::now();
             $now->add('M', -1);
             $st = DateTimeValueLib::make(0, 0, 0, $now->getMonth(), 1, $now->getYear());
             $et = DateTimeValueLib::make(23, 59, 59, $now->getMonth(), 1, $now->getYear())->add('M', 1)->add('d', -1);
             break;
         case 6:
             //Date interval
             $st = getDateValue(array_var($report_data, 'start_value'));
             $st = $st->beginningOfDay();
             $et = getDateValue(array_var($report_data, 'end_value'));
             $et = $et->beginningOfDay()->add('d', 1);
             break;
     }
     $st = new DateTimeValue($st->getTimestamp() - logged_user()->getTimezone() * 3600);
     $et = new DateTimeValue($et->getTimestamp() - logged_user()->getTimezone() * 3600);
     $timeslotType = array_var($report_data, 'timeslot_type', 0);
     $group_by = array();
     for ($i = 1; $i <= 3; $i++) {
         if ($timeslotType == 0) {
             $gb = array_var($report_data, 'group_by_' . $i);
         } else {
             $gb = array_var($report_data, 'alt_group_by_' . $i);
         }
         if ($gb != '0') {
             $group_by[] = $gb;
         }
     }
     $object_subtype = array_var($report_data, 'object_subtype');
     $timeslotsArray = Timeslots::getTaskTimeslots($workspace, $user, $workspacesCSV, $st, $et, array_var($report_data, 'task_id', 0), $group_by, null, 0, 0, $timeslotType, $conditions, $object_subtype);
     $unworkedTasks = null;
     if (array_var($report_data, 'include_unworked') == 'checked') {
         $unworkedTasks = ProjectTasks::getPendingTasks(logged_user(), $workspace);
         tpl_assign('unworkedTasks', $unworkedTasks);
     }
     if (array_var($_POST, 'exportCSV')) {
         $skip_ws = $all_conditions != null ? true : false;
         self::total_task_times_csv($report_data, $columns, $timeslotsArray, $skip_ws);
     } else {
         if (array_var($_POST, 'exportPDF')) {
             //self::total_task_times_pdf($report_data, $columns, $timeslotsArray);
         } else {
             tpl_assign('columns', $columns);
             tpl_assign('conditions', $conditions);
             tpl_assign('timeslot_type', $timeslotType);
             tpl_assign('group_by', $group_by);
             tpl_assign('timeslotsArray', $timeslotsArray);
             tpl_assign('workspace', $workspace);
             tpl_assign('start_time', $st);
             tpl_assign('end_time', $et);
             tpl_assign('user', $user);
             $report_data['conditions'] = $conditions;
             $report_data['columns'] = $columns;
             tpl_assign('post', $report_data);
             tpl_assign('template_name', 'total_task_times');
             tpl_assign('title', lang('task time report'));
         }
     }
 }
 /**
  * List all time total for a user (both billed and unbilled)
  *
  * @access public
  * @param void
  * @return null
  */
 function byuser()
 {
     $this->setLayout('administration');
     if (!logged_user()->isAdministrator(owner_company())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('dashboard');
     }
     // if
     $user_id = (int) array_var($_GET, 'id', 0);
     if ($user_id < 0) {
         $user_id = 0;
     }
     $redirect_to = array_var($_GET, 'redirect_to');
     if ($redirect_to == '') {
         $redirect_to = get_url('time', 'byuser', array('id' => $user_id));
         $redirect_to = str_replace('&amp;', '&', trim($redirect_to));
     }
     // if
     $unbilled = ProjectTimes::getTimeByUserStatus(Users::findById($user_id));
     $billed = ProjectTimes::getTimeByUserStatus(Users::findById($user_id), 1);
     tpl_assign('unbilled', $unbilled);
     tpl_assign('billed', $billed);
     tpl_assign('user', Users::findById($user_id));
     tpl_assign('redirect_to', $redirect_to);
     $this->setSidebar(get_template_path('index_sidebar', 'time'));
 }
Example #20
0
    $startday = date("j") - date("N") + 1;
    // beginning of the week, monday
} else {
    $startday = date("j") - date("w");
    // beginning of the week, sunday
}
user_config_option('show_two_weeks_calendar', null, logged_user()->getId()) ? $my_weeks = 2 : ($my_weeks = 1);
$endday = $startday + 7 * $my_weeks;
$today = DateTimeValueLib::now()->add('h', logged_user()->getTimezone());
$currentday = $today->getDay();
$currentmonth = $today->getMonth();
$currentyear = $today->getYear();
$user_comp_filter = user_config_option('pending tasks widget assigned to filter');
$exploded = explode(":", $user_comp_filter);
$user_filter_id = array_var($exploded, 1);
$user_filter = $user_filter_id > 0 ? Users::findById($user_filter_id) : null;
$date_start = new DateTimeValue(mktime(0, 0, 0, $currentmonth, $startday, $currentyear));
$date_end = new DateTimeValue(mktime(0, 0, 0, $currentmonth, $endday, $currentyear));
//FIXME $milestones = ProjectMilestones::getRangeMilestones($date_start, $date_end);
$tmp_tasks = ProjectTasks::getRangeTasksByUser($date_start, $date_end, $user_filter);
//FIXME
$birthdays = array();
//Contacts::instance()->getRangeContactsByBirthday($date_start, $date_end);
$tasks = array();
if ($tmp_tasks) {
    foreach ($tmp_tasks as $task) {
        $tasks = array_merge($tasks, replicateRepetitiveTaskForCalendar($task, $date_start, $date_end));
    }
}
$use_24_hours = user_config_option('time_format_use_24');
if ($use_24_hours) {
 /**
  * This function will use session ID from session or cookie and if presend log user
  * with that ID. If not it will simply break.
  * 
  * When this function uses session ID from cookie the whole process will be treated
  * as new login and users last login time will be set to current time.
  *
  * @access public
  * @param void
  * @return boolean
  */
 private function initLoggedUser()
 {
     $user_id = Cookie::getValue('id' . TOKEN_COOKIE_NAME);
     $twisted_token = Cookie::getValue(TOKEN_COOKIE_NAME);
     $remember = (bool) Cookie::getValue('remember' . TOKEN_COOKIE_NAME, false);
     if (empty($user_id) || empty($twisted_token)) {
         return false;
         // we don't have a user
     }
     // if
     $user = Users::findById($user_id);
     if (!$user instanceof User) {
         return false;
         // failed to find user
     }
     // if
     if (!$user->isValidToken($twisted_token)) {
         return false;
         // failed to validate token
     }
     // if
     $session_expires = $user->getLastActivity()->advance(SESSION_LIFETIME, false);
     if (DateTimeValueLib::now()->getTimestamp() < $session_expires->getTimestamp()) {
         $this->setLoggedUser($user, $remember, true);
     } else {
         $this->logUserIn($user, $remember);
     }
     // if
 }
 /**
  * Return user who checked out this message
  *
  * @access public
  * @param void
  * @return User
  */
 function getCheckedOutBy()
 {
     if (is_null($this->checked_out_by)) {
         if ($this->columnExists('checked_out_by_id')) {
             $this->checked_out_by = Users::findById($this->getCheckedOutById());
         }
     }
     //
     return $this->checked_out_by;
 }
 function assign_users()
 {
     if (!logged_user()->isAdministrator()) {
         flash_error(lang("no access permissions"));
         ajx_current("empty");
         return;
     }
     $users_data = array_var($_POST, 'users');
     if (is_array($users_data)) {
         try {
             DB::beginWork();
             foreach ($users_data as $user_id => $user_billing) {
                 $user = Users::findById($user_id);
                 if ($user_billing != $user->getDefaultBillingId()) {
                     $user->setDefaultBillingId($user_billing);
                     $user->save();
                 }
             }
             DB::commit();
             flash_success(lang("success assign user billing categories"));
             ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
     }
     tpl_assign('users_by_company', Users::getGroupedByCompany());
     tpl_assign('billing_categories', BillingCategories::findAll());
 }
Example #24
0
<?php
	 
	$genid = gen_id();
	$assign_type = 0; //All
	if (isset($assigned_to_user_filter) && $assigned_to_user_filter > 0){
		$assigned_to = Users::findById($assigned_to_user_filter);
		$assigned_to_me = $assigned_to->getId() == logged_user()->getId();
		$assign_type = $assigned_to_me? 1 : 2;
	} else if (isset($assigned_to_company_filter) && $assigned_to_company_filter > 0){
		$assigned_to = Companies::findById($assigned_to_company_filter);
		$assign_type = 3;
	}
?>

<script>
	var cant_tips = 0;
	var tips_array = [];
	
	function addTip(div_id, title, bdy) {
		tips_array[cant_tips++] = new Ext.ToolTip({
			target: div_id,
	        html: bdy,
	        title: title,
	        hideDelay: 1500,
	        closable: true
		});
	}
</script>


<div id="<?php echo $genid ?>-db" style="padding:7px;">
Example #25
0
 /**
  * Return user who completed this project
  *
  * @access public
  * @param void
  * @return User
  */
 function getCompletedBy()
 {
     return Users::findById($this->getCompletedById());
 }
 /**
  * Return user who updated this object
  *
  * @access public
  * @param void
  * @return User
  */
 function getUpdatedBy()
 {
     if (is_null($this->updated_by)) {
         if ($this->columnExists('updated_by_id')) {
             if ($this->getUpdatedById() > 0) {
                 $this->updated_by = Users::findById($this->getUpdatedById());
             }
         }
     }
     //
     return $this->updated_by;
 }
 /**
  * Get value of created_by
  *
  * @param void
  * @return User
  */
 function getCreatedBy()
 {
     if ($this->created_by === false) {
         $created_by_id = $this->created_by_id;
         if ($created_by_id) {
             $this->created_by = Users::findById($created_by_id);
         } else {
             $this->created_by = new AnonymousUser($this->created_by_name, $this->created_by_email);
         }
         // if
     }
     // if
     return $this->created_by;
 }
 /**
  * Return user who trashed this object
  *
  * @access public
  * @param void
  * @return User
  */
 function getTrashedBy()
 {
     if (is_null($this->trashed_by)) {
         if ($this->columnExists('trashed_by_id')) {
             $this->trashed_by = Users::findById($this->getTrashedById());
         }
     }
     //
     return $this->trashed_by;
 }
 /**
  * Return User object of person who completed this milestone
  *
  * @param void
  * @return User
  */
 function getCompletedBy()
 {
     if (is_null($this->completed_by)) {
         $this->completed_by = Users::findById($this->getCompletedById());
     }
     return $this->completed_by;
 }
 /**
  * Conflict incoming mail
  * 
  * @param void
  * @return void
  */
 function conflict()
 {
     if ($this->active_mail->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     require_once INCOMING_MAIL_MODULE_PATH . '/models/IncomingMailImporter.class.php';
     $mail_data = $this->request->post('mail');
     if (!is_foreachable($mail_data)) {
         flash_error(incoming_mail_module_get_status_description($this->active_mail->getState()));
         $mail_data = array('subject' => $this->active_mail->getSubject(), 'body' => $this->active_mail->getBody(), 'created_by_id' => $this->active_mail->getCreatedById(), 'project_id' => $this->active_mail->getProjectId());
     }
     // if
     if ($this->request->isSubmitted()) {
         $this->active_mail->setSubject(array_var($mail_data, 'subject'));
         $this->active_mail->setBody(array_var($mail_data, 'body'));
         $creator_id = array_var($mail_data, 'created_by_id');
         if ($creator_id && $creator_id != 'original_author') {
             $creator = Users::findById($creator_id);
             if (instance_of($creator, 'User')) {
                 $this->active_mail->setCreatedBy($creator);
             }
             // if
         }
         // if
         $this->active_mail->setCreatedById(array_var($mail_data, 'created_by_id'));
         $this->active_mail->setObjectType(array_var($mail_data, 'object_type'));
         if (array_var($mail_data, 'object_type') == 'comment') {
             $this->active_mail->setParentId(array_var($mail_data, 'parent_id'));
         }
         // if
         // import email
         if (instance_of($importing_result = IncomingMailImporter::importPendingEmail($this->active_mail, $creator_id == 'original_author'), 'ProjectObject')) {
             // we have successfully imported email
             $this->active_mail->delete();
             if ($this->request->isAsyncCall()) {
                 $this->renderText(lang('<p>Conflict Solved Successfully!</p><p>View created <a href=":url">:object</a>.</p>', array('object' => $this->active_mail->getObjectType(), 'url' => $importing_result->getViewUrl())));
             } else {
                 flash_success('Conflict Solved Successfully!');
                 $this->redirectTo('incoming_mail');
             }
             // if
         } else {
             if ($this->request->isAsyncCall()) {
                 $this->httpError(HTTP_ERR_INVALID_PROPERTIES, null, false, 2);
             } else {
                 flash_error($importing_result->getMessage());
             }
             // if
         }
         // if
     }
     // if
     $user = $this->active_mail->getCreatedBy();
     if (instance_of($user, 'User')) {
         $this->smarty->assign('object_user', $user);
     } else {
         $this->smarty->assign('object_user', $this->logged_user);
     }
     // if
     $this->smarty->assign(array('async' => $this->request->isAsyncCall(), 'form_url' => $this->active_mail->getImportUrl() . ($this->request->isAsyncCall() ? '?skip_layout=1&async=1' : ''), 'status_message' => incoming_mail_module_get_status_description($this->active_mail->getState()), 'mail_data' => $mail_data, 'project' => $this->active_mail->getProject()));
     $flash =& Flash::instance();
     $flash->init();
     js_assign('additional_fields_url', assemble_url('incoming_mail_additional_form_fields'));
 }