/**
  * Add webpage
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add');
     if (!ProjectWebpage::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $webpage = new ProjectWebpage();
     $webpage_data = array_var($_POST, 'webpage');
     if (!is_array($webpage_data)) {
         $webpage_data = array('milestone_id' => array_var($_GET, 'milestone_id'));
         // array
     }
     // if
     if (is_array(array_var($_POST, 'webpage'))) {
         try {
             if (substr_utf($webpage_data['url'], 0, 7) != 'http://' && substr_utf($webpage_data['url'], 0, 7) != 'file://' && substr_utf($webpage_data['url'], 0, 8) != 'https://' && substr_utf($webpage_data['url'], 0, 6) != 'about:' && substr_utf($webpage_data['url'], 0, 6) != 'ftp://') {
                 $webpage_data['url'] = 'http://' . $webpage_data['url'];
             }
             $webpage->setFromAttributes($webpage_data);
             $webpage->setIsPrivate(false);
             // Options are reserved only for members of owner company
             if (!logged_user()->isMemberOfOwnerCompany()) {
                 $webpage->setIsPrivate(false);
             }
             // if
             DB::beginWork();
             $webpage->save();
             $webpage->setTagsFromCSV(array_var($webpage_data, 'tags'));
             $object_controller = new ObjectController();
             $object_controller->add_to_workspaces($webpage);
             $object_controller->link_to_new_object($webpage);
             $object_controller->add_subscribers($webpage);
             $object_controller->add_custom_properties($webpage);
             ApplicationLogs::createLog($webpage, $webpage->getWorkspaces(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             flash_success(lang('success add webpage', $webpage->getTitle()));
             ajx_current("back");
             // Error...
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
         // try
     }
     // if
     tpl_assign('webpage', $webpage);
     tpl_assign('webpage_data', $webpage_data);
 }
 /**
  * Show project objects tagged with specific tag
  *
  * @access public
  * @param void
  * @return null
  */
 function project_tag()
 {
     $tag = array_var($_GET, 'tag');
     if (trim($tag) == '') {
         flash_error(lang('tag dnx'));
         $this->redirectTo('project', 'tags');
     }
     // if
     $tagged_objects = active_or_personal_project()->getObjectsByTag($tag);
     $total_tagged_objects = Tags::countObjectsByTag($tag);
     if (is_array($tagged_objects)) {
         foreach ($tagged_objects as $type => $objects) {
             if (is_array($objects)) {
                 $total_tagged_objects += count($objects);
             }
         }
         // foreach
     }
     // if
     tpl_assign('tag', $tag);
     tpl_assign('tagged_objects', $tagged_objects);
     tpl_assign('total_tagged_objects', $total_tagged_objects);
 }
 function icalendar_import()
 {
     @set_time_limit(0);
     if (isset($_GET['from_menu']) && $_GET['from_menu'] == 1) {
         unset($_SESSION['history_back']);
     }
     if (isset($_SESSION['history_back'])) {
         if ($_SESSION['history_back'] > 0) {
             $_SESSION['history_back'] = $_SESSION['history_back'] - 1;
         }
         if ($_SESSION['history_back'] == 0) {
             unset($_SESSION['history_back']);
         }
         ajx_current("back");
     } else {
         $ok = false;
         $this->setTemplate('cal_import');
         $filedata = array_var($_FILES, 'cal_file');
         if (is_array($filedata)) {
             $filename = $filedata['tmp_name'] . 'vcal';
             copy($filedata['tmp_name'], $filename);
             $events_data = CalFormatUtilities::decode_ical_file($filename);
             if (count($events_data)) {
                 try {
                     DB::beginWork();
                     foreach ($events_data as $ev_data) {
                         $event = new ProjectEvent();
                         $project = active_or_personal_project();
                         if ($ev_data['subject'] == '') {
                             $ev_data['subject'] = lang('no subject');
                         }
                         $event->setFromAttributes($ev_data);
                         $event->save();
                         $event->addToWorkspace($project);
                         $object_controller = new ObjectController();
                         $object_controller->add_subscribers($event);
                         ApplicationLogs::createLog($event, null, ApplicationLogs::ACTION_ADD);
                         $this->registerInvitations($ev_data, $event);
                         if (isset($ev_data['confirmAttendance'])) {
                             if ($event->getCreatedBy() instanceof User) {
                                 $this->change_invitation_state($ev_data['confirmAttendance'], $event->getId(), $event->getCreatedBy()->getId());
                             }
                         }
                     }
                     DB::commit();
                     $ok = true;
                     flash_success(lang('success import events', count($events_data)));
                     $_SESSION['history_back'] = 1;
                 } catch (Exception $e) {
                     DB::rollback();
                     flash_error($e->getMessage());
                 }
             } else {
                 flash_error(lang('no events to import'));
             }
             unset($filename);
             if (!$ok) {
                 ajx_current("empty");
             }
         } else {
             if (array_var($_POST, 'atimportform', 0)) {
                 ajx_current("empty");
             }
         }
     }
 }
<?php

if (!$company->isTrashed()) {
    if (User::canAdd(logged_user(), $company)) {
        add_page_action(lang('add user'), $company->getAddUserUrl(), 'ico-add');
    }
    // if
    if (Contact::canAdd(logged_user(), active_or_personal_project())) {
        add_page_action(lang('add contact'), $company->getAddContactUrl(), 'ico-add');
    }
    // if
    if ($company->canEdit(logged_user())) {
        add_page_action(lang('edit company'), $company->getEditUrl(), 'ico-edit', null, null, true);
        add_page_action(lang('edit company logo'), $company->getEditLogoUrl(), 'ico-picture', null, null, true);
        if (!$company->isOwner()) {
            add_page_action(lang('permissions'), $company->getUpdatePermissionsUrl(), 'ico-permissions', null, null, true);
        }
        // if
        if (!$company->isArchived()) {
            add_page_action(lang('archive'), "javascript:if(confirm(lang('confirm archive object'))) og.openLink('" . $company->getArchiveUrl() . "');", 'ico-archive-obj');
        } else {
            add_page_action(lang('unarchive'), "javascript:if(confirm(lang('confirm unarchive object'))) og.openLink('" . $company->getUnarchiveUrl() . "');", 'ico-unarchive-obj');
        }
    }
    // if
}
if ($company->canDelete(logged_user())) {
    if ($company->isTrashed()) {
        add_page_action(lang('restore from trash'), "javascript:if(confirm(lang('confirm restore objects'))) og.openLink('" . $company->getUntrashUrl() . "');", 'ico-restore', null, null, true);
        add_page_action(lang('delete permanently'), "javascript:if(confirm(lang('confirm delete permanently company'))) og.openLink('" . $company->getDeletePermanentlyUrl() . "');", 'ico-delete', null, null, true);
    } else {
Exemple #5
0
</legend>
 	    <div id="<?php 
echo $genid;
?>
attachments"></div>
 	<a href="#" onclick="og.attachFromWorkspace('<?php 
echo $genid;
?>
')">
 		<?php 
echo lang('attach from workspace');
?>
 	</a>
 	<br/>
 	<a href="#" onclick="og.attachFromFileSystem(<?php 
echo active_or_personal_project()->getId() . ',\'' . active_tag() . '\'';
?>
, '<?php 
echo $genid;
?>
')">
 		<?php 
echo lang('attach from file system');
?>
 	</a>
 	<script type="text/javascript">
 	// add attachments
 	var container = document.getElementById('<?php 
echo $genid;
?>
attachments');
 /**
  * Show permission update form
  *
  * @param void
  * @return null
  */
 function permissions()
 {
     $project = active_or_personal_project();
     if (!$project->canChangePermissions(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     tpl_assign('project_users', $project->getUsers(false));
     tpl_assign('project_companies', $project->getCompanies());
     tpl_assign('user_projects', logged_user()->getProjects());
     $permissions = ProjectUsers::getNameTextArray();
     tpl_assign('permissions', $permissions);
     $companies = array(owner_company());
     $clients = owner_company()->getClientCompanies();
     if (is_array($clients)) {
         $companies = array_merge($companies, $clients);
     }
     // if
     tpl_assign('companies', $companies);
     if (array_var($_POST, 'process') == 'process') {
         try {
             DB::beginWork();
             $project->clearCompanies();
             $project->clearUsers();
             $companies = array(owner_company());
             $client_companies = owner_company()->getClientCompanies();
             if (is_array($client_companies)) {
                 $companies = array_merge($companies, $client_companies);
             }
             // if
             foreach ($companies as $company) {
                 // Company is selected!
                 if (array_var($_POST, 'project_company_' . $company->getId()) == 'checked') {
                     // Owner company is automaticly included so it does not need to be in project_companies table
                     if (!$company->isOwner()) {
                         $project_company = new ProjectCompany();
                         $project_company->setProjectId($project->getId());
                         $project_company->setCompanyId($company->getId());
                         $project_company->save();
                     }
                     // if
                     $users = $company->getUsers();
                     if (is_array($users)) {
                         $counter = 0;
                         foreach ($users as $user) {
                             $user_id = $user->getId();
                             $counter++;
                             if (array_var($_POST, "project_user_{$user_id}") == 'checked') {
                                 $project_user = new ProjectUser();
                                 $project_user->setProjectId($project->getId());
                                 $project_user->setUserId($user_id);
                                 foreach ($permissions as $permission => $permission_text) {
                                     // Owner company members have all permissions
                                     $permission_value = $company->isOwner() ? true : array_var($_POST, 'project_user_' . $user_id . '_' . $permission) == 'checked';
                                     $setter = 'set' . Inflector::camelize($permission);
                                     $project_user->{$setter}($permission_value);
                                 }
                                 // if
                                 $project_user->save();
                             }
                             // if
                         }
                         // foreach
                     }
                     // if
                 }
                 // if
             }
             // foreach
             DB::commit();
             flash_success(lang('success update project permissions'));
             ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             flash_error(lang('error update project permissions'));
             ajx_current("empty");
         }
         // try
     }
     // if
 }
<?php

set_page_title($file->isNew() ? lang('new spreadsheet') : lang('edit spreadsheet') . ' - ' . $file->getFilename());
$url = ROOT_URL . "/" . PUBLIC_FOLDER . "/assets/javascript/gelSheet/index.php";
?>
<div style="width:100%;height:100%;border:0px;margin:0px;padding:0px;overflow:hidden">
	<iframe style="width:100%;height:100%;border:0px;margin:0px;padding:0px;overflow:hidden"
	<?php 
if ($file->isNew()) {
    ?>
		src="<?php 
    echo $url . "?wid=" . active_or_personal_project()->getId();
    ?>
">
	<?php 
} else {
    ?>
		src="<?php 
    echo $url . "?id=" . $file->getId() . "&book=" . $file->getFileContent() . "&wid=" . active_or_personal_project()->getId();
    ?>
">
	<?php 
}
?>
	</iframe>
</div>
?>

<form id="<?php 
echo $genid . 'add-User-Form';
?>
" class="internalForm" style="height: 100%;width: 100%; overflow: auto;" action="<?php 
echo get_url("object", "add_subscribers_from_object_view", array('object_id' => $object->getId(), 'object_manager' => $type));
?>
" method="post">
<div class="og-add-subscribers">
<?php 
if (!is_array($subscriberIds)) {
    $subscriberIds = array(logged_user()->getId());
}
if (!isset($workspaces)) {
    $workspaces = array(active_or_personal_project());
}
if (!isset($genid)) {
    $genid = gen_id();
}
// get users with permissions
$users = array();
foreach ($workspaces as $ws) {
    $someUsers = $ws->getUsers(false);
    foreach ($someUsers as $u) {
        if ($type == 'Contacts' && $u->getCanManageContacts()) {
            $canRead = true;
        } else {
            // see if user can read type of object in the workspace
            $canRead = can_read_type($u, $ws, $type);
        }
 /**
  * Create a new template
  *
  */
 function new_template()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $project = active_or_personal_project();
     if (!ProjectTask::canAdd(logged_user(), $project)) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $id = get_id();
     $task = ProjectTasks::findById($id);
     if (!$task instanceof ProjectTask) {
         $task_data = array('is_template' => true);
     } else {
         $task_data = array('milestone_id' => $task->getMilestoneId(), 'title' => $task->getTitle(), 'assigned_to' => $task->getAssignedToCompanyId() . ":" . $task->getAssignedToUserId(), 'parent_id' => $task->getParentId(), 'priority' => $task->getPriority(), 'tags' => implode(",", $task->getTagNames()), 'project_id' => $task->getProjectId(), 'time_estimate' => $task->getTimeEstimate(), 'text' => $task->getText(), 'is_template' => true, 'copyId' => $task->getId());
         // array
         if ($task->getStartDate() instanceof DateTimeValue) {
             $task_data['start_date'] = $task->getStartDate()->getTimestamp();
         }
         if ($task->getDueDate() instanceof DateTimeValue) {
             $task_data['due_date'] = $task->getDueDate()->getTimestamp();
         }
     }
     $task = new ProjectTask();
     tpl_assign('task_data', $task_data);
     tpl_assign('task', $task);
     $this->setTemplate("add_task");
 }
?>
</a>
	</div>
</div>
<div class="coInputMainBlock">
	<div id="<?php 
echo $genid;
?>
parameters_select_workspace_div" style="display:none">
	<fieldset>
	<legend><?php 
echo lang('workspace');
?>
</legend>
		<?php 
echo select_project2('project_id', active_or_personal_project()->getId(), $genid);
?>
	</fieldset>
	</div>

	<div id="<?php 
echo $genid;
?>
parameters_tags_div" style="display:none">
	<fieldset>
	<legend><?php 
echo lang('tags');
?>
</legend>
		<?php 
echo autocomplete_tags_field('tags', '', 'tags');
 /**
  * Add client
  *
  * @param void
  * @return null
  */
 function add_client()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add_company');
     if (!Company::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $company = new Company();
     $company_data = array_var($_POST, 'company');
     if (!is_array($company_data)) {
         $company_data = array('timezone' => logged_user()->getTimezone());
         // array
     }
     // if
     tpl_assign('company', $company);
     tpl_assign('company_data', $company_data);
     if (is_array(array_var($_POST, 'company'))) {
         $company->setFromAttributes($company_data);
         $company->setClientOfId(owner_company()->getId());
         try {
             DB::beginWork();
             $company->save();
             $company->setTagsFromCSV(array_var($company_data, 'tags'));
             $object_controller = new ObjectController();
             $object_controller->add_to_workspaces($company, !can_manage_contacts(logged_user()));
             $object_controller->link_to_new_object($company);
             $object_controller->add_subscribers($company);
             $object_controller->add_custom_properties($company);
             ApplicationLogs::createLog($company, $company->getWorkspaces(), ApplicationLogs::ACTION_ADD);
             //				ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_ADD);
             DB::commit();
             flash_success(lang('success add client', $company->getName()));
             evt_add("company added", array("id" => $company->getId(), "name" => $company->getName()));
             ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             ajx_current("empty");
             flash_error($e->getMessage());
         }
         // try
     }
     // if
 }
 /**
  * Add comment
  *
  * Through this controller only logged users can post (no anonymous comments here)
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_comment');
     $object_id = get_id('object_id');
     $object_manager = array_var($_GET, 'object_manager');
     if (!is_valid_function_name($object_manager)) {
         flash_error(lang('invalid request'));
         ajx_current("empty");
         return;
     }
     // if
     $object = get_object_by_manager_and_id($object_id, $object_manager);
     if (!$object instanceof ProjectDataObject || !$object->canComment(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $comment = new Comment();
     $comment_data = array_var($_POST, 'comment');
     tpl_assign('comment_form_object', $object);
     tpl_assign('comment', $comment);
     tpl_assign('comment_data', $comment_data);
     if (is_array($comment_data)) {
         try {
             try {
                 $attached_files = ProjectFiles::handleHelperUploads(active_or_personal_project());
             } catch (Exception $e) {
                 $attached_files = null;
             }
             // try
             $comment->setFromAttributes($comment_data);
             $comment->setRelObjectId($object_id);
             $comment->setRelObjectManager($object_manager);
             //				if(!logged_user()->isMemberOfOwnerCompany()) {
             $comment->setIsPrivate(false);
             //				} // if
             DB::beginWork();
             $comment->save();
             if (is_array($attached_files)) {
                 foreach ($attached_files as $attached_file) {
                     $comment->attachFile($attached_file);
                 }
                 // foreach
             }
             // if
             // Subscribe user to object
             if (!$object->isSubscriber(logged_user())) {
                 $object->subscribeUser(logged_user());
             }
             // if
             if (strlen($comment->getText()) < 100) {
                 $comment_head = $comment->getText();
             } else {
                 $lastpos = strpos($comment->getText(), " ", 100);
                 if ($lastpos === false) {
                     $comment_head = $comment->getText();
                 } else {
                     $comment_head = substr($comment->getText(), 0, $lastpos) . "...";
                 }
             }
             $comment_head = html_to_text($comment_head);
             ApplicationLogs::createLog($object, $object->getWorkspaces(), ApplicationLogs::ACTION_COMMENT, false, null, true, $comment_head);
             DB::commit();
             flash_success(lang('success add comment'));
             ajx_current("reload");
         } catch (Exception $e) {
             DB::rollback();
             ajx_current("empty");
             flash_error($e->getMessage());
         }
         // try
     }
     // if
 }
/**
 * Renders a list of users to add as subscribers, used to add subscribers from the objects view.
 * @param $object
 * @param $genid
 * @param $subscribers
 * @param $workspaces
 * @return html text
 */
function render_add_subscribers_select(ProjectDataObject $object, $genid = null, $subscribers = null, $workspaces = null)
{
    if (!isset($genid)) {
        $genid = gen_id();
    }
    $subscriberIds = array();
    if (is_array($subscribers)) {
        foreach ($subscribers as $u) {
            $subscriberIds[] = $u->getId();
        }
    } else {
        if ($object->isNew()) {
            $subscriberIds[] = logged_user()->getId();
        } else {
            foreach ($object->getSubscribers() as $u) {
                $subscriberIds[] = $u->getId();
            }
        }
    }
    if (!isset($workspaces)) {
        if ($object->isNew()) {
            $workspaces = array(active_or_personal_project());
        } else {
            $workspaces = $object->getWorkspaces();
        }
    }
    tpl_assign('type', get_class($object->manager()));
    tpl_assign('workspaces', $workspaces);
    tpl_assign('subscriberIds', $subscriberIds);
    tpl_assign('genid', $genid);
    return tpl_fetch(get_template_path('add_subscribers_list', 'object'));
}
Exemple #14
0
			<td style="padding-right: 10px; width:95%; margin-top: 0px;vertical-align:bottom">
				<?php 
echo label_tag(lang('description'));
?>
			</td>
			<td style="padding-left: 10px;text-align:right; vertical-align: middle;">
			</td>
		</tr><tr>
			<td style="padding-right: 10px; width:140px;">
				<?php 
echo pick_date_widget2('timeslot[date]', DateTimeValueLib::now(), $genid, 100, false);
?>
			</td>
			<td style="padding-right:10px; width:140px;">
				 <?php 
echo select_project2('timeslot[project_id]', active_or_personal_project()->getId(), $genid);
?>
			</td>
			<?php 
if (logged_user()->isAdministrator()) {
    ?>
<td style="padding-right: 10px; width:140px;">
				<?php 
    echo user_select_box("timeslot[user_id]", logged_user()->getId(), array('id' => $genid . 'tsUser', 'tabindex' => '150'));
    ?>
			</td><?php 
} else {
    ?>
<td style="padding-right: 10px">	
				<input type="hidden" id="<?php 
    echo $genid;
 function instantiate()
 {
     $id = get_id();
     $template = COTemplates::findById($id);
     if (!$template instanceof COTemplate) {
         flash_error(lang("template dnx"));
         ajx_current("empty");
         return;
     }
     $parameters = TemplateParameters::getParametersByTemplate($id);
     $parameterValues = array_var($_POST, 'parameterValues');
     if (count($parameters) > 0 && !isset($parameterValues)) {
         ajx_current("back");
         return;
     }
     $objects = $template->getObjects();
     foreach ($objects as $object) {
         if (!$object instanceof ProjectDataObject) {
             continue;
         }
         // copy object
         $copy = $object->copy();
         if ($copy->columnExists('is_template')) {
             $copy->setColumnValue('is_template', false);
         }
         if ($copy instanceof ProjectTask) {
             // don't copy parent task and milestone
             $copy->setMilestoneId(0);
             $copy->setParentId(0);
         }
         $copy->save();
         $wsId = array_var($_POST, 'project_id', active_or_personal_project()->getId());
         // if specified, set workspace
         $workspace = Projects::findById($wsId);
         if (!$workspace instanceof Project) {
             $workspace = active_or_personal_project();
         }
         $copy->addToWorkspace($workspace);
         // add object tags and specified tags
         $tags = implode(',', $object->getTagNames());
         $copy->setTagsFromCSV($tags . "," . array_var($_POST, 'tags'));
         // copy linked objects
         $copy->copyLinkedObjectsFrom($object);
         // copy subtasks if applicable
         if ($copy instanceof ProjectTask) {
             ProjectTasks::copySubTasks($object, $copy, false);
             $manager = new ProjectTask();
         } else {
             if ($copy instanceof ProjectMilestone) {
                 ProjectMilestones::copyTasks($object, $copy, false);
                 $manager = new ProjectMilestone();
             }
         }
         // copy custom properties
         $copy->copyCustomPropertiesFrom($object);
         // set property values as defined in template
         $objProp = TemplateObjectProperties::getPropertiesByTemplateObject($id, $object->getId());
         foreach ($objProp as $property) {
             $propName = $property->getProperty();
             $value = $property->getValue();
             if ($manager->getColumnType($propName) == DATA_TYPE_STRING) {
                 if (is_array($parameterValues)) {
                     foreach ($parameterValues as $param => $val) {
                         $value = str_replace('{' . $param . '}', $val, $value);
                     }
                 }
             } else {
                 if ($manager->getColumnType($propName) == DATA_TYPE_DATE || $manager->getColumnType($propName) == DATA_TYPE_DATETIME) {
                     $operator = '+';
                     if (strpos($value, '+') === false) {
                         $operator = '-';
                     }
                     $opPos = strpos($value, $operator);
                     if ($opPos !== false) {
                         $dateParam = substr($value, 1, strpos($value, '}') - 1);
                         $dateUnit = substr($value, strlen($value) - 1);
                         // d, w or m (for days, weeks or months)
                         if ($dateUnit == 'm') {
                             $dateUnit = 'M';
                             // make month unit uppercase to call DateTimeValue::add with correct parameter
                         }
                         $dateNum = (int) substr($value, strpos($value, $operator), strlen($value) - 2);
                         $date = $parameterValues[$dateParam];
                         $date = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $date);
                         $value = $date->add($dateUnit, $dateNum);
                     }
                 } else {
                     if ($manager->getColumnType($propName) == DATA_TYPE_INTEGER) {
                         if (is_array($parameterValues)) {
                             foreach ($parameterValues as $param => $val) {
                                 $value = str_replace('{' . $param . '}', $val, $value);
                             }
                         }
                     }
                 }
             }
             if ($value != '') {
                 $copy->setColumnValue($propName, $value);
                 $copy->save();
             }
         }
         //copy assigned to company if applicable
         if ($copy->getAssignedToUserId() != 0) {
             $copy->setAssignedToCompanyId($copy->getAssignedTo()->getCompanyId());
             $copy->save();
         }
         // copy reminders
         $reminders = ObjectReminders::getByObject($object);
         foreach ($reminders as $reminder) {
             $copy_reminder = new ObjectReminder();
             $copy_reminder->setContext($reminder->getContext());
             $reminder_date = $copy->getColumnValue($reminder->getContext());
             if ($reminder_date instanceof DateTimeValue) {
                 $reminder_date = new DateTimeValue($reminder_date->getTimestamp());
                 $reminder_date->add('m', -$reminder->getMinutesBefore());
             }
             $copy_reminder->setDate($reminder_date);
             $copy_reminder->setMinutesBefore($reminder->getMinutesBefore());
             $copy_reminder->setObject($copy);
             $copy_reminder->setType($reminder->getType());
             $copy_reminder->setUserId($reminder->getUserId());
             $copy_reminder->save();
         }
     }
     if (is_array($parameters) && count($parameters) > 0) {
         ajx_current("back");
     } else {
         ajx_current("reload");
     }
 }
 function getWorkspaceColorsCSV($wsIds = null)
 {
     if ($this->isNew()) {
         return active_or_personal_project()->getColor();
     } else {
         $ids = array();
         $wss = $this->getWorkspaces($wsIds);
         if ($wss) {
             foreach ($wss as $w) {
                 $ids[] = $w->getColor();
             }
         }
         return join(", ", $ids);
     }
 }
        if ($file->canEdit(logged_user())) {
            if ($file->isModifiable() && $file->getType() != ProjectFiles::TYPE_WEBLINK) {
                add_page_action(lang('edit this file'), $file->getModifyUrl(), 'ico-edit', null, null, true);
            }
            add_page_action(lang('update file'), $file->getEditUrl(), 'ico-properties', null, null, true);
        }
    }
    if ($file->canDelete(logged_user())) {
        if ($file->isTrashed()) {
            add_page_action(lang('restore from trash'), "javascript:if(confirm(lang('confirm restore objects'))) og.openLink('" . $file->getUntrashUrl() . "');", 'ico-restore', null, null, true);
            add_page_action(lang('delete permanently'), "javascript:if(confirm(lang('confirm delete permanently'))) og.openLink('" . $file->getDeletePermanentlyUrl() . "');", 'ico-delete', null, null, true);
        } else {
            add_page_action(lang('move to trash'), "javascript:if(confirm(lang('confirm move to trash'))) og.openLink('" . $file->getTrashUrl() . "');", 'ico-trash', null, null, true);
        }
    }
    if (can_add(logged_user(), active_or_personal_project(), 'ProjectFiles') && $file->getType() != ProjectFiles::TYPE_WEBLINK) {
        add_page_action(lang('copy file'), $file->getCopyUrl(), 'ico-copy');
    }
    ?>


<div style="padding:7px">
<div class="files">

<?php 
    $description = '';
    if ($last_revision instanceof ProjectFileRevision) {
        $description .= '<div id="fileLastRevision"><span class="propertyName">' . lang('last revision') . ':</span>';
        if ($last_revision->getCreatedBy() instanceof User) {
            $description .= lang('file revision info long', $last_revision->getRevisionNumber(), $last_revision->getCreatedBy()->getCardUrl(), clean($last_revision->getCreatedBy()->getDisplayName()), format_descriptive_date($last_revision->getCreatedOn()));
        } else {
 /**
  * Create a new milestone template
  *
  */
 function new_template()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $project = active_or_personal_project();
     if (!ProjectMilestone::canAdd(logged_user(), $project)) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $id = get_id();
     $milestone = ProjectMilestones::findById($id);
     if (!$milestone instanceof ProjectMilestone) {
         $milestone_data = array('is_template' => true);
     } else {
         $milestone_data = array('name' => $milestone->getName(), 'assigned_to' => $milestone->getAssignedToCompanyId() . ":" . $milestone->getAssignedToUserId(), 'tags' => implode(",", $milestone->getTagNames()), 'project_id' => $milestone->getProjectId(), 'description' => $milestone->getDescription(), 'copyId' => $milestone->getId(), 'is_template' => true);
         // array
         if ($milestone->getDueDate() instanceof DateTimeValue) {
             $milestone_data['due_date'] = $milestone->getDueDate()->getTimestamp();
         }
     }
     $milestone = new ProjectMilestone();
     tpl_assign('milestone_data', $milestone_data);
     tpl_assign('milestone', $milestone);
     $this->setTemplate("add_milestone");
 }
    echo yes_no_widget('milestone[is_private]', $genid . 'milestoneFormIsPrivate', array_var($milestone_data, 'is_private'), lang('yes'), lang('no'), 30);
    ?>
</div>
		</div>
	 -->
	<?php 
}
// if
?>
		<div class="objectOption">
		<div class="optionLabel"><?php 
echo label_tag(lang('assign to'), $genid . 'milestoneFormAssignedTo');
?>
</div>
		<div class="optionControl"><?php 
echo assign_to_select_box('milestone[assigned_to]', active_or_personal_project(), array_var($milestone_data, 'assigned_to'), array('id' => $genid . 'milestoneFormAssignedTo', 'tabindex' => '40'));
?>
</div>
		<div class="optionControl"><?php 
echo checkbox_field('milestone[send_notification]', array_var($milestone_data, 'send_notification', true), array('id' => $genid . 'milestoneFormSendNotification', 'tabindex' => '45'));
?>
 
		<label for="<?php 
echo $genid;
?>
milestoneFormSendNotification" class="checkbox"><?php 
echo lang('send milestone assigned to notification');
?>
</label></div>
		</div>
		<div class="objectOption">
 function zip_add()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     if (!zip_supported()) {
         flash_error(lang('zip not supported'));
         return;
     }
     $files = ProjectFiles::findByCSVIds(array_var($_GET, 'objects'), '`type` = 0');
     if (count($files) == 0) {
         flash_error(lang('no files to compress'));
         return;
     }
     $isnew = false;
     $file = null;
     if (array_var($_GET, 'filename')) {
         $filename = array_var($_GET, 'filename');
         $isnew = true;
     } else {
         if (array_var($_GET, 'id')) {
             $file = ProjectFiles::findById(array_var($_GET, 'id'));
             $filename = $file->getFilename();
         }
     }
     $tmp_zip_path = ROOT . '/tmp/' . rand() . '.zip';
     $handle = fopen($tmp_zip_path, 'wb');
     if (!$isnew) {
         $content = $file->getLastRevision()->getFileContent();
         fwrite($handle, $content, $file->getLastRevision()->getFilesize());
     }
     fclose($handle);
     $zip = new ZipArchive();
     if (!$isnew) {
         $zip->open($tmp_zip_path);
     } else {
         $zip->open($tmp_zip_path, ZipArchive::OVERWRITE);
     }
     $tmp_dir = ROOT . '/tmp/' . rand() . '/';
     mkdir($tmp_dir);
     foreach ($files as $file_to_add) {
         if (FileRepository::getBackend() instanceof FileRepository_Backend_FileSystem) {
             $file_to_add_path = FileRepository::getBackend()->getFilePath($file_to_add->getLastRevision()->getRepositoryId());
         } else {
             $file_to_add_path = $tmp_dir . $file_to_add->getFilename();
             $handle = fopen($file_to_add_path, 'wb');
             fwrite($handle, $file_to_add->getLastRevision()->getFileContent(), $file_to_add->getLastRevision()->getFilesize());
             fclose($handle);
         }
         $zip->addFile($file_to_add_path, utf8_safe($file_to_add->getFilename()));
     }
     $zip->close();
     delete_dir($tmp_dir);
     $workspaces = $file == null ? array(active_or_personal_project()) : $file->getWorkspaces();
     $this->upload_file($file, $filename, $tmp_zip_path, $workspaces);
     unlink($tmp_zip_path);
     flash_success(lang('success compressing files', count($files)));
     ajx_current("reload");
 }
 function add_subscribers_list()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $genid = array_var($_GET, 'genid');
     $obj_id = array_var($_GET, 'obj_id');
     $obj_manager = array_var($_GET, 'manager');
     $object = get_object_by_manager_and_id($obj_id, $obj_manager);
     if (!isset($genid)) {
         $genid = gen_id();
     }
     $subscriberIds = array();
     if ($object->isNew()) {
         $subscriberIds[] = logged_user()->getId();
     } else {
         foreach ($object->getSubscribers() as $u) {
             $subscriberIds[] = $u->getId();
         }
     }
     if (!isset($workspaces)) {
         if ($object->isNew()) {
             $workspaces = array(active_or_personal_project());
         } else {
             $workspaces = $object->getWorkspaces();
         }
     }
     tpl_assign('object', $object);
     tpl_assign('type', get_class($object->manager()));
     tpl_assign('workspaces', $workspaces);
     tpl_assign('subscriberIds', $subscriberIds);
     tpl_assign('genid', $genid);
     //echo tpl_fetch(get_template_path('add_subscribers_list', 'object'));
 }
 /**
  * Delete task
  *
  * @access public
  * @param void
  * @return null
  */
 function delete_task()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $project = active_or_personal_project();
     $task = ProjectTasks::findById(get_id());
     if (!$task instanceof ProjectTask) {
         flash_error(lang('task dnx'));
         return;
     }
     // if
     if (!$task->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         return;
     }
     // if
     try {
         DB::beginWork();
         $is_template = $task->getIsTemplate();
         $task->trash();
         ApplicationLogs::createLog($task, ApplicationLogs::ACTION_TRASH);
         DB::commit();
         if ($is_template) {
             flash_success(lang('success delete template', $task->getObjectName()));
         } else {
             flash_success(lang('success delete task list', $task->getObjectName()));
         }
         if (array_var($_GET, 'quick', false)) {
             ajx_current('empty');
         } else {
             if (array_var($_GET, 'taskview', false)) {
                 ajx_current('reload');
             } else {
                 ajx_current('back');
             }
         }
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete task list'));
     }
     // try
 }
} else {
    ?>
			<div id="<?php 
    echo $genid;
    ?>
add_contact_select_workspace_div" style="display:none">
	<?php 
}
?>
	<fieldset><legend><?php 
echo lang('workspace');
?>
</legend>
	<?php 
if ($object->isNew()) {
    echo select_workspaces('ws_ids', null, array(active_or_personal_project()), $genid . 'ws_ids');
} else {
    echo select_workspaces('ws_ids', null, $object->getWorkspaces(null, 'workspace'), $genid . 'ws_ids');
}
?>
	</fieldset>
	</div>
		
	<div style="display:block" id="<?php 
echo $genid;
?>
add_contact_work">
	<fieldset><legend><?php 
echo lang('work');
?>
</legend>
<?php

require_javascript('og/modules/addMessageForm.js');
$project = active_or_personal_project();
$genid = gen_id();
$object = $message;
$all = true;
if (active_project() != null) {
    $all = false;
}
?>
<form id="<?php 
echo $genid;
?>
submit-edit-form" style='height:100%;background-color:white' action="<?php 
echo $message->isNew() ? get_url('message', 'add') : $message->getEditUrl();
?>
" method="post" enctype="multipart/form-data">
<div class="message">
<div class="coInputHeader">
<div class="coInputHeaderUpperRow">
	<div class="coInputTitle">
		<table style="width:535px"><tr><td>
			<?php 
echo $message->isNew() ? lang('new message') : lang('edit message');
?>
		</td><td style="text-align:right">
			<?php 
echo submit_button($message->isNew() ? lang('add message') : lang('save changes'), 's', array('style' => 'margin-top:0px;margin-left:10px', 'tabindex' => '5'));
?>
		</td></tr></table>
 function import_from_vcard()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     @set_time_limit(0);
     ini_set('auto_detect_line_endings', '1');
     if (isset($_GET['from_menu']) && $_GET['from_menu'] == 1) {
         unset($_SESSION['go_back']);
     }
     if (isset($_SESSION['go_back'])) {
         unset($_SESSION['go_back']);
         ajx_current("start");
     }
     tpl_assign('import_type', 'contact');
     if (!Contact::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $this->setTemplate('vcard_import');
     $filedata = array_var($_FILES, 'vcard_file');
     if (is_array($filedata) && !array_var($_GET, 'step2')) {
         $filename = ROOT . '/tmp/' . logged_user()->getId() . 'temp.vcf';
         copy($filedata['tmp_name'], $filename);
         //ajx_current("empty");
     } else {
         if (array_var($_GET, 'step2')) {
             $filename = ROOT . '/tmp/' . logged_user()->getId() . 'temp.vcf';
             $result = $this->read_vcard_file($filename);
             unlink($filename);
             $import_result = array('import_ok' => array(), 'import_fail' => array());
             foreach ($result as $contact_data) {
                 try {
                     DB::beginWork();
                     if (isset($contact_data['photo_tmp_filename'])) {
                         $file_id = FileRepository::addFile($contact_data['photo_tmp_filename'], array('public' => true));
                         $contact_data['picture_file'] = $file_id;
                         unlink($contact_data['photo_tmp_filename']);
                         unset($contact_data['photo_tmp_filename']);
                     }
                     if (isset($contact_data['company_name'])) {
                         $company = Companies::findOne(array("conditions" => "`name` = '" . mysql_real_escape_string($contact_data['company_name']) . "'"));
                         if ($company == null) {
                             $company = new Company();
                             $company->setName($contact_data['company_name']);
                             $company->setClientOfId(logged_user()->getCompanyId());
                             $company->save();
                             ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_ADD);
                         }
                         $contact_data['company_id'] = $company->getId();
                         unset($contact_data['company_name']);
                     }
                     $contact_data['import_status'] = '(' . lang('updated') . ')';
                     $fname = mysql_real_escape_string(array_var($contact_data, "firstname"));
                     $lname = mysql_real_escape_string(array_var($contact_data, "lastname"));
                     $contact = Contacts::findOne(array("conditions" => "firstname = '" . $fname . "' AND lastname = '" . $lname . "' OR email <> '' AND email = '" . array_var($contact_data, "email") . "'"));
                     $log_action = ApplicationLogs::ACTION_EDIT;
                     if (!$contact) {
                         $contact = new Contact();
                         $contact_data['import_status'] = '(' . lang('new') . ')';
                         $log_action = ApplicationLogs::ACTION_ADD;
                         $can_import = active_project() != null ? $contact->canAdd(logged_user(), active_project()) : can_manage_contacts(logged_user());
                     } else {
                         $can_import = $contact->canEdit(logged_user());
                     }
                     if ($can_import) {
                         $contact->setFromAttributes($contact_data);
                         $contact->save();
                         ApplicationLogs::createLog($contact, null, $log_action);
                         $contact->setTagsFromCSV(array_var($_GET, 'tags'));
                         if (active_project() instanceof Project) {
                             $pc = ProjectContacts::findOne(array("conditions" => "contact_id = " . $contact->getId() . " AND project_id = " . active_project()->getId()));
                             if (!$pc) {
                                 $pc = new ProjectContact();
                                 $pc->setContactId($contact->getId());
                                 $pc->setProjectId(active_project()->getId());
                                 $pc->setRole(array_var($contact_data, 'role'));
                                 $pc->save();
                             }
                             $contact->addToWorkspace(active_project());
                         }
                         $import_result['import_ok'][] = array('firstname' => $fname, 'lastname' => $lname, 'email' => $contact_data['email'], 'import_status' => $contact_data['import_status']);
                     } else {
                         throw new Exception(lang('no access permissions'));
                     }
                     DB::commit();
                 } catch (Exception $e) {
                     DB::rollback();
                     $fail_msg = substr_utf($e->getMessage(), strpos_utf($e->getMessage(), "\r\n"));
                     $import_result['import_fail'][] = array('firstname' => $fname, 'lastname' => $lname, 'email' => $contact_data['email'], 'import_status' => $contact_data['import_status'], 'fail_message' => $fail_msg);
                 }
             }
             $_SESSION['go_back'] = true;
             tpl_assign('import_result', $import_result);
         }
     }
 }