/** * List all tags * */ function list_tags() { ajx_current("empty"); $order = array_var($_GET, 'order', 'count'); $ts = array(); $tags = Tags::getTagNames($order); $extra = array(); $extra['tags'] = $tags; ajx_extra_data($extra); }
function listTags($username, $password) { if ($this->loginUser($username, $password)) { $tags = Tags::getTagNames(); $this->initXml('tags'); if (is_array($tags)) { foreach ($tags as $tag) { $this->instance->startElement('tag'); $this->instance->text($tag['name']); $this->instance->endElement(); } } $result = $this->endXml(); } else $result = ''; return $result; }
private function get_ext_values($field, $manager = null) { $values = array(array('id' => '', 'name' => '-- ' . lang('select') . ' --')); if ($field == 'company_id' || $field == 'assigned_to_company_id') { $companies = Companies::getVisibleCompanies(logged_user()); foreach ($companies as $company) { $values[] = array('id' => $company->getId(), 'name' => $company->getName()); } } else { if ($field == 'user_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_user_id' || $field == 'completed_by_id') { $users = Users::getVisibleUsers(logged_user()); foreach ($users as $user) { $values[] = array('id' => $user->getId(), 'name' => $user->getDisplayName()); } } else { if ($field == 'milestone_id') { $milestones = ProjectMilestones::getActiveMilestonesByUser(logged_user()); foreach ($milestones as $milestone) { $values[] = array('id' => $milestone->getId(), 'name' => $milestone->getName()); } } else { if ($field == 'workspace') { $workspaces = logged_user()->getWorkspaces(false, 0); foreach ($workspaces as $ws) { $values[] = array('id' => $ws->getId(), 'name' => $ws->getName()); } } else { if ($field == 'tag') { $tags = Tags::getTagNames(); foreach ($tags as $tag) { $values[] = array('id' => $tag['name'], 'name' => $tag['name']); } } else { if ($field == 'object_subtype') { $object_types = ProjectCoTypes::findAll(array('conditions' => !is_null($manager) ? "`object_manager`='{$manager}'" : "")); foreach ($object_types as $object_type) { $values[] = array('id' => $object_type->getId(), 'name' => $object_type->getName()); } } } } } } } return $values; }
/** * Add file * * @access public * @param void * @return null */ function add_file() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $file_data = array_var($_POST, 'file'); $file = new ProjectFile(); tpl_assign('file', $file); tpl_assign('file_data', $file_data); tpl_assign('tags', Tags::getTagNames()); if (is_array(array_var($_POST, 'file'))) { $this->setLayout("html"); $upload_option = array_var($file_data, 'upload_option'); $skipSettings = false; try { DB::beginWork(); if ($upload_option && $upload_option != -1) { $skipSettings = true; $file = ProjectFiles::findById($upload_option); $old_subs = $file->getSubscribers(); // Mantain old subscribers foreach ($old_subs as $user) { $value = "user_" . $user->getId(); if (is_array($_POST['subscribers'])) { if (array_var($_POST['subscribers'], $value, null) != 'checked') { $_POST['subscribers'][$value] = 'checked'; } } } if ($file->isCheckedOut()) { if (!$file->canCheckin(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $file->setCheckedOutById(0); } else { // Check for edit permissions if (!$file->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } } } else { $type = array_var($file_data, 'type'); $file->setType($type); $file->setFilename(array_var($file_data, 'name')); $file->setFromAttributes($file_data); $file->setIsPrivate(false); if (!logged_user()->isMemberOfOwnerCompany()) { $file->setIsImportant(false); $file->setCommentsEnabled(true); $file->setAnonymousCommentsEnabled(false); } // if $file->setIsVisible(true); } $file->save(); if ($file->getType() == ProjectFiles::TYPE_DOCUMENT) { // handle uploaded file $upload_id = array_var($file_data, 'upload_id'); $uploaded_file = array_var($_SESSION, $upload_id, array()); $revision_comment = array_var($file_data, 'revision_comment'); $revision = $file->handleUploadedFile($uploaded_file, true, $revision_comment); // handle uploaded file @unlink($uploaded_file['tmp_name']); unset($_SESSION[$upload_id]); } else { if ($file->getType() == ProjectFiles::TYPE_WEBLINK) { $url = array_var($file_data, 'url', ''); if ($url && strpos($url, ':') === false) { $url = "http://" . $url; $file->setUrl($url); $file->save(); } $revision = new ProjectFileRevision(); $revision->setFileId($file->getId()); $revision->setRevisionNumber($file->getNextRevisionNumber()); $revision->setFileTypeId(FileTypes::getByExtension('webfile')->getId()); $revision->setTypeString($file->getUrl()); $revision->setRepositoryId('webfile'); $revision_comment = array_var($file_data, 'revision_comment', lang('initial versions')); $revision->setComment($revision_comment); $revision->save(); } } $object_controller = new ObjectController(); //Add properties if (!$skipSettings) { $file->setTagsFromCSV(array_var($file_data, 'tags')); $object_controller->add_to_workspaces($file); } //Add links $object_controller->link_to_new_object($file); $object_controller->add_subscribers($file); $object_controller->add_custom_properties($file); ApplicationLogs::createLog($file, $file->getWorkspaces(), ApplicationLogs::ACTION_ADD); DB::commit(); $ajx_file = array(); $ajx_file["file"][] = get_class($file->manager()) . ':' . $file->getId(); //flash_success(array_var($file_data, 'add_type')); flash_success(lang('success add file', $file->getFilename())); if (array_var($_POST, 'popup', false)) { ajx_current("reload"); } else { ajx_current("back"); } ajx_add("overview-panel", "reload"); ajx_extra_data($ajx_file); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); Logger::log($e->getMessage()); Logger::log("Error when uploading file:" . $e->getTraceAsString()); ajx_current("empty"); // If we uploaded the file remove it from repository if (isset($revision) && $revision instanceof ProjectFileRevision && FileRepository::isInRepository($revision->getRepositoryId())) { FileRepository::deleteFile($revision->getRepositoryId()); } // if } // try } // if }