本文整理汇总了PHP中WikiPage::setProjectId方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::setProjectId方法的具体用法?PHP WikiPage::setProjectId怎么用?PHP WikiPage::setProjectId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiPage
的用法示例。
在下文中一共展示了WikiPage::setProjectId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Add a wiki page
*
* @return void
*/
function add()
{
if (!WikiPage::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectTo('wiki');
}
//if
if (false !== ($data = array_var($_POST, 'wiki', false))) {
//Make a new wiki page
$page = new WikiPage();
//Set the Id for this project
$page->setProjectId(active_project()->getId());
$page->setProjectIndex(logged_user()->isMemberOfOwnerCompany() ? $data['project_index'] : 0);
$page->setProjectSidebar(logged_user()->isMemberOfOwnerCompany() ? $data['project_sidebar'] : 0);
//Make a new revision of this page
$revision = $page->makeRevision();
//Set attributes from form
$revision->setFromAttributes($data);
//Set user ID and project ID
$revision->setCreatedbyId(logged_user()->getId());
try {
//Start the db transaction
DB::beginWork();
//Save the page
$page->save();
//Make a log entry
ApplicationLogs::createLog($page, active_project(), ApplicationLogs::ACTION_ADD);
if (plugin_active('tags')) {
//Add page tags
$page->setTagsFromCSV($data['tags']);
}
//Commit changed
DB::commit();
//Tell the user they made a page
flash_success(lang('success add wiki page'));
//Redirect
$this->redirectToUrl($page->getViewUrl());
} catch (Exception $e) {
DB::rollback();
tpl_assign('error', $e);
}
//try
}
// if
if (!isset($page) || !instance_of($page, 'WikiPage')) {
$page = new WikiPage();
$page->setProjectId(active_project()->getId());
}
// if
tpl_assign('page', $page);
tpl_assign('revision', new Revision());
$this->setTemplate('edit');
}
示例2: add
/**
* Add a wiki page
*
* @return void
*/
function add()
{
if (!WikiPage::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectTo('wiki');
}
//if
//Here we will edit a wiki page
$preview = false;
$data = array_var($_POST, 'wiki', false);
if (false !== $data) {
$preview = array_key_exists('preview', $data);
}
if (!$preview && $data) {
//Make a new wiki page
$page = new WikiPage();
//Set the Id for this project
$page->setProjectId(active_project()->getId());
$page->setProjectIndex(logged_user()->isMemberOfOwnerCompany() ? $data['project_index'] : 0);
$page->setPublish(logged_user()->isMemberOfOwnerCompany() ? $data['publish'] : 0);
$page->setParentId($data['parent_id']);
$page->setProjectSidebar(logged_user()->isMemberOfOwnerCompany() ? $data['project_sidebar'] : 0);
//Make a new revision of this page
$revision = $page->makeRevision();
// Check to see if we want to lock this page
if (isset($data['locked'])) {
if ($data['locked'] == 1 && $page->canLock(logged_user())) {
// If we want to lock this page and the user has permissions to lock it, and the page is not already locked
$page->setLocked(true);
$page->setLockedById(logged_user()->getId());
$page->setLockedOn(DateTimeValueLib::now());
}
// if
}
// if
//Set attributes from form
$revision->setFromAttributes($data);
//Set user ID and project ID
$revision->setCreatedbyId(logged_user()->getId());
try {
//Start the db transaction
DB::beginWork();
//Save the page
$page->save();
//Make a log entry
ApplicationLogs::createLog($page, active_project(), ApplicationLogs::ACTION_ADD);
if (plugin_active('tags')) {
//Add page tags
$page->setTagsFromCSV($data['tags']);
}
//Commit changed
DB::commit();
//Tell the user they made a page
flash_success(lang('success add wiki page'));
//Redirect
$this->redirectToUrl($page->getViewUrl());
} catch (Exception $e) {
DB::rollback();
tpl_assign('error', $e);
}
//try
}
// if
if (!isset($page) || !instance_of($page, 'WikiPage')) {
$page = new WikiPage();
$page->setProjectId(active_project()->getId());
}
// if
$revision = new Revision();
if (!$data) {
// there was no input POSTed
$data['content'] = $revision->getContent();
}
$data['preview_content'] = do_textile($data['content']);
//Assign revision object
tpl_assign('data', $data);
tpl_assign('page', $page);
tpl_assign('revision', $revision);
tpl_assign('tags', '');
$this->setTemplate('edit');
$this->setSidebar(get_template_path('textile_help_sidebar'));
}
示例3: copy
/**
* Copy project
*
* @param void
* @return null
*/
function copy()
{
trace(__FILE__, "copy():begin");
if (!Project::canAdd(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
$this->setTemplate('copy_project');
$this->setLayout('administration');
$project_data = array_var($_POST, 'project');
tpl_assign('project_data', $project_data);
// Submitted...
if (is_array($project_data)) {
$source = Projects::findById($project_data['source']);
if (!$source instanceof Project) {
flash_error(lang('project dnx'));
$this->redirectTo('administration', 'projects');
}
// if
try {
$shift_dates = isset($project_data['shift_dates']) ? $project_data['shift_dates'] == 'checked' : false;
$copy_details = isset($project_data['copy_details']) ? $project_data['copy_details'] == 'checked' : false;
$copy_tasks = isset($project_data['copy_tasks']) ? $project_data['copy_tasks'] == 'checked' : false;
$copy_milestones = isset($project_data['copy_milestones']) ? $project_data['copy_milestones'] == 'checked' : false;
$copy_messages = isset($project_data['copy_messages']) ? $project_data['copy_messages'] == 'checked' : false;
$copy_links = isset($project_data['copy_links']) ? $project_data['copy_links'] == 'checked' : false;
$copy_files = isset($project_data['copy_files']) ? $project_data['copy_files'] == 'checked' : false;
$copy_users = isset($project_data['copy_users']) ? $project_data['copy_users'] == 'checked' : false;
$copy_pages = isset($project_data['copy_pages']) ? $project_data['copy_pages'] == 'checked' : false;
DB::beginWork();
$project = new Project();
$new_name = lang('projects copy new name', $source->getName());
$new_name .= date(' z H:i:s');
$project->setName($new_name);
if ($copy_details) {
$project->setDescription($source->getDescription());
$project->setPriority($source->getPriority());
$project->setShowDescriptionInOverview($source->getShowDescriptionInOverview());
}
$project->save();
$project_id = $project->getId();
$add_seconds = 0;
if (isset($project_data['add_days'])) {
$add_days = 0 + trim($project_data['add_days']);
$add_seconds = $add_days * 24 * 60 * 60;
}
$source_created_on = $source->getCreatedOn();
//var_dump($source_created_on);
$milestone_map = array(0 => 0);
// project milestones
if ($copy_milestones) {
$source_milestones = $source->getAllMilestones();
if (is_array($source_milestones)) {
foreach ($source_milestones as $source_milestone) {
$milestone = new ProjectMilestone();
//$milestone->copy($source_milestone);
$milestone->setName($source_milestone->getName());
$milestone->setDescription($source_milestone->getDescription());
if ($shift_dates) {
trace(__FILE__, "copy():shift dates");
$milestone->setDueDate(DateTimeValueLib::now());
$seconds = $source_milestone->getDueDate()->difference($source_created_on);
$milestone->getDueDate()->advance($seconds);
} else {
$milestone->setDueDate($source_milestone->getDueDate());
}
$milestone->getDueDate()->advance($add_seconds);
$milestone->setIsPrivate($source_milestone->getIsPrivate());
$milestone->setAssignedToUserId($source_milestone->getAssignedToUserId());
$milestone->setAssignedToCompanyId($source_milestone->getAssignedToCompanyId());
$milestone->setProjectId($project_id);
$milestone->save();
$milestone_map[$source_milestone->getId()] = $milestone->getId();
}
// foreach
}
// if
}
// if
// project tasks
if ($copy_tasks) {
$source_task_lists = $source->getAllTaskLists();
if (is_array($source_task_lists)) {
foreach ($source_task_lists as $source_task_list) {
$task_list = new ProjectTaskList();
//$task_list->copy($source_milestone);
$task_list->setName($source_task_list->getName());
$task_list->setPriority($source_task_list->getPriority());
$task_list->setDescription($source_task_list->getDescription());
if ($copy_milestones) {
$task_list->setMilestoneId($milestone_map[$source_task_list->getMilestoneId()]);
}
$task_list->setDueDate($source_task_list->getDueDate());
//.........这里部分代码省略.........