Commit 9ed811ce authored by Alan McNatty's avatar Alan McNatty
Browse files

Another big round of changes ticking off much of the Journal extras (is draft,...

Another big round of changes ticking off much of the Journal extras (is draft, allow comments) handling.
As a result quite a few UI changes to accommodate these fields.

Also fixes a few bug (but probably also introduces a few more. Much more robust getting closer to a final
test release candidate.
parent 7c53986b
......@@ -102,7 +102,7 @@
<!-- API Level 4 aka 1.6 required for multi-send support -->
<!-- API Level 5 aka 2.0 required for Account & Sync support -->
<!-- API Level 8 aka 2.2 required for (filtered) Account & Sync Intent support -->
<uses-sdk android:minSdkVersion="8" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
......
......@@ -61,6 +61,7 @@ if ($username == '') {
jsonreply( array('fail' => 'Username cannot be blank') );
}
// Starting the creation of our artefact (file) object
$data = new StdClass;
$USER = new User();
......@@ -106,37 +107,98 @@ catch (ParameterException $e) {
$data->parent = null;
}
// Set title
$title = '';
// Check for Journal ID to add a post to
$blog = ''; $blogpost = ''; $draft = 0; $allowcomments = 1;
try {
$blog = param_integer('blog');
}
catch (ParameterException $e) { }
try {
$draft = param_variable('draft');
}
catch (ParameterException $e) { }
try {
$allowcomments = param_variable('allowcomments');
}
catch (ParameterException $e) { }
// Check for artefact attributes title, description (or entry), tags, etc
$title = ''; $description = ''; $tags = '';
try {
$title = param_variable('title');
}
catch (ParameterException $e) { }
// Set description
$description = '';
try {
$description = param_variable('description');
}
catch (ParameterException $e) { }
// Set tags
$tags = '';
try {
$tags = explode(" ", param_variable('tags'));
}
catch (ParameterException $e) { }
$artefact_id = '';
// -- Start by creating a blog entry --
$postobj = ''; // our resulting blog post object on creation
$artefact_id = ''; // our resulting artefact id on creation
if ( $blog ) {
if ( ! ( $title && $description ) ) {
jsonreply( array('fail' => 'Journal posts must have a title and entry (description).') );
}
if (!get_record('artefact', 'id', $blog, 'owner', $USER->get('id'))) {
// Blog security is also checked closer to when blogs are added, this
// check ensures that malicious users do not even see the screen for
// adding a post to a blog that is not theirs
throw new AccessDeniedException(get_string('youarenottheownerofthisblog', 'artefact.blog'));
}
// Should we create a new post of attach the new file to an existing post
$postids = get_records_sql_array("
SELECT a.id
FROM {artefact} a
WHERE a.title = ? AND a.description = ?
AND a.owner = ? ",
array($title, $description, $USER->get('id')));
if ( $postids ) {
$blogpost = $postids[0]->id;
$postobj = new ArtefactTypeBlogPost($blogpost);
$postobj->check_permission();
if ($postobj->get('locked')) {
throw new AccessDeniedException(get_string('submittedforassessment', 'view'));
}
} else {
$postobj = new ArtefactTypeBlogPost($blogpost, null);
$postobj->set('title', $title);
$postobj->set('description', $description);
$postobj->set('tags', $tags);
$postobj->set('published', !$draft);
$postobj->set('allowcomments', (int) $allowcomments);
$postobj->set('parent', $blog);
$postobj->set('owner', $USER->id);
$postobj->commit();
}
}
// -- Now check for files to upload --
if ( $_FILES ) {
if ( ! $title ) {
basename($_FILES['userfile']['name']);
if ( $blog || ! $title ) { // set the filename to be the title of the artefact
$title = basename($_FILES['userfile']['name']);
}
try {
$data->title = ArtefactTypeFileBase::get_new_file_title($title, $data->parent, $data->owner);
$data->description = $description;
if ( ! $blog ) { // only set a description if it's an artefact upload
$data->description = $description;
}
$data->tags = $tags;
$artefact_id = ArtefactTypeFile::save_uploaded_file('userfile', $data);
if ( $artefact_id ) {
......@@ -151,51 +213,14 @@ if ( $_FILES ) {
}
}
// Check to see if we're creating a journal entry
// Check for Journal ID to add a post to
$blog = ''; $blogpost = ''; $draft = 0; $allowcomments = 1;
try {
$blog = param_integer('blog');
}
catch (ParameterException $e) { }
try {
$blogpost = param_integer('blogpost');
}
catch (ParameterException $e) { }
try {
$draft = param_variable('draft');
}
catch (ParameterException $e) { }
try {
$allowcomments = param_variable('allowcomments');
}
// -- Finally attach the file to the blog post once uploaded and --
catch (ParameterException $e) { }
// Check to see if we're creating a journal entry
if ( $blog && $title && $description ) {
if (!get_record('artefact', 'id', $blog, 'owner', $USER->get('id'))) {
// Blog security is also checked closer to when blogs are added, this
// check ensures that malicious users do not even see the screen for
// adding a post to a blog that is not theirs
throw new AccessDeniedException(get_string('youarenottheownerofthisblog', 'artefact.blog'));
}
$postobj = new ArtefactTypeBlogPost($blogpost, null);
$postobj->set('title', $title);
$postobj->set('description', $description);
$postobj->set('tags', $tags);
$postobj->set('published', !$draft);
$postobj->set('allowcomments', (int) $allowcomments);
$postobj->set('parent', $blog);
$postobj->set('owner', $USER->id);
$postobj->commit();
// If we created an artefact - attach it.
if ( $artefact_id ) {
$postobj->attach($artefact_id);
}
if ( $artefact_id && $postobj ) {
// If we created or matched a blog post and created an artefact
// attach the artefact to the blog.
$postobj->attach($artefact_id);
}
// Here we need to create a new hash - update our own store of it and return it to the handset
......
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/title"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="40dp"
android:singleLine="true"
android:gravity="left"
/>
\ No newline at end of file
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/artefact_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_gallery"
android:gravity="left"
android:layout_gravity="left"
android:paddingLeft="40dp"
/>
<TextView android:id="@+id/title"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:singleLine="true"
android:gravity="left"
/>
</LinearLayout>
\ No newline at end of file
......@@ -6,47 +6,49 @@
android:orientation="vertical"
style="@style/itemBackground"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactTitleLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactJournalLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView android:text="@string/upload_title_label"
android:layout_width="50dp"
<TextView android:text="@string/upload_journal_label"
android:layout_width="60dp"
android:singleLine="false"
android:layout_height="wrap_content"
android:textStyle="bold"
style="@android:style/TextAppearance.Small">
</TextView>
style="@android:style/TextAppearance.Small"
android:layout_gravity="left"
android:layout_weight="2"/>
<TextView
android:id="@+id/txtArtifactTitle"
android:id="@+id/txtArtefactJournal"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Small">
</TextView>
style="@android:style/TextAppearance.Small"
android:layout_gravity="left"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactDescriptionLayout"
android:id="@+id/ArtefactDescriptionLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView android:text="@string/upload_description_label"
android:layout_width="50dp"
android:layout_width="60dp"
android:singleLine="false"
android:layout_height="wrap_content"
android:textStyle="bold"
style="@android:style/TextAppearance.Small">
</TextView>
<TextView android:id="@+id/txtArtifactDescription"
<TextView android:id="@+id/txtArtefactDescription"
android:singleLine="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......@@ -61,19 +63,57 @@
android:orientation="horizontal">
<TextView android:text="@string/upload_tags_label"
android:layout_width="50dp"
android:layout_width="60dp"
android:singleLine="false"
android:layout_height="wrap_content"
android:textStyle="bold"
style="@android:style/TextAppearance.Small">
</TextView>
<TextView android:id="@+id/txtArtifactTags"
<TextView android:id="@+id/txtArtefactTags"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactJournalExtrasLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView android:text=""
android:layout_width="60dp"
android:singleLine="false"
android:layout_height="wrap_content"
android:textStyle="bold"
style="@android:style/TextAppearance.Small"
android:layout_gravity="left"
android:layout_weight="2"/>
<CheckBox
android:id="@+id/txtArtefactIsDraft"
android:checked="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:enabled="false"
style="@android:style/TextAppearance.Small"
android:text="Draft"/>
<CheckBox
android:id="@+id/txtArtefactAllowComments"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:enabled="false"
style="@android:style/TextAppearance.Small"
android:text="Allow Comments"/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
......@@ -83,14 +123,14 @@
android:orientation="horizontal">
<TextView android:text="@string/upload_time_label"
android:layout_width="50dp"
android:layout_width="60dp"
android:singleLine="false"
android:layout_height="wrap_content"
android:textStyle="bold"
style="@android:style/TextAppearance.Small">
</TextView>
<TextView android:id="@+id/txtArtifactTime"
<TextView android:id="@+id/txtArtefactTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Small">
......@@ -98,7 +138,7 @@
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactSettingsButtonLayout"
android:id="@+id/ArtefactSettingsButtonLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
......@@ -132,7 +172,7 @@
</LinearLayout>
<TextView android:id="@+id/txtArtifactFilename"
<TextView android:id="@+id/txtArtefactFilename"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......
......@@ -3,26 +3,10 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/top"
android:layout_gravity="left"
android:padding="10dp"
>
<ImageView
android:id="@+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/banner"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/gradient"
android:layout_below="@+id/top"
android:background="@drawable/gradient"
>
</RelativeLayout>
......@@ -102,8 +86,9 @@
android:visibility="gone"
android:headerDividersEnabled="true"
android:footerDividersEnabled="true"
android:groupIndicator="@drawable/expander_group"
/>
<!-- android:groupIndicator="@drawable/expander_group" -->
<TextView android:id="@+id/no_saved_artefacts"
android:text="@string/artefacts_no_saved_artefacts"
android:layout_margin="0dp"
......
......@@ -13,7 +13,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/JournalLayout"
android:id="@+id/ArtefactJournalLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
......@@ -32,41 +32,40 @@
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactConfirmLayout"
android:id="@+id/ArtefactConfirmLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox android:text="@string/upload_confirm_label"
<CheckBox
style="@android:style/TextAppearance.Small"
android:id="@+id/chkUpload"
android:layout_width="wrap_content"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
/>
<TextView android:text="@string/upload_confirm_text"
android:id="@+id/txtArtifactConfirm"
android:id="@+id/txtArtefactConfirm"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_margin="5dip"
android:paddingBottom="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
<!--
<ImageView android:id="@+id/UploadArtifact"
<ImageView android:id="@+id/UploadArtefact"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactTitleLayout"
android:id="@+id/ArtefactTitleLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
......@@ -82,7 +81,7 @@
</TextView>
<EditText android:text=""
android:id="@+id/txtArtifactTitle"
android:id="@+id/txtArtefactTitle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
......@@ -91,7 +90,7 @@
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactDescriptionLayout"
android:id="@+id/ArtefactDescriptionLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
......@@ -106,7 +105,7 @@
style="@android:style/TextAppearance.Small">
</TextView>
<EditText android:text=""
android:id="@+id/txtArtifactDescription"
android:id="@+id/txtArtefactDescription"
android:singleLine="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......@@ -130,7 +129,7 @@
</TextView>
<EditText android:text=""
android:id="@+id/txtArtifactTags"
android:id="@+id/txtArtefactTags"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
......@@ -157,10 +156,68 @@
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactJournalExtrasLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactIsDraftLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- android:text="@string/upload_is_draft_label"-->
<CheckBox
style="@android:style/TextAppearance.Small"
android:id="@+id/txtArtefactIsDraft"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:checked="false"
android:layout_width="60dip"
/>
<TextView android:text="@string/upload_is_draft_text"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactAllowCommentsLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- android:text="@string/upload_allow_comments_label" -->
<CheckBox
style="@android:style/TextAppearance.Small"
android:id="@+id/txtArtefactAllowComments"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:checked="true"
android:layout_width="60dip"
/>
<TextView android:text="@string/upload_allow_comments_text"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactSettingsButtonLayout"
android:id="@+id/ArtefactSettingsButtonLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
......@@ -181,7 +238,7 @@
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:enabled="true"
style="@style/MaharaButton"
>
</Button>
......@@ -196,7 +253,7 @@
</LinearLayout>
<EditText android:text=""
android:id="@+id/txtArtifactId"
android:id="@+id/txtArtefactId"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......
......@@ -53,21 +53,33 @@
<string name="prefcat_advanced">Advanced</string>
<string name="pref_upload_journal_default_key">upload.journal.default</string>
<string name="pref_upload_journal_default_title">Journal post by default</string>
<string name="pref_upload_journal_default_summary">Check to select a default journal to post to</string>
<string name="pref_upload_journal_key">upload.journal</string>
<string name="pref_upload_journal_title">Journal</string>
<string name="pref_upload_journal_summary">Select the default journal to post to</string>
<string name="pref_upload_journal_title">Default journal</string>
<string name="pref_upload_journal_summary">Select the default journal to post to.
Note: nothing will be shown until your first sync.</string>
<string name="pref_upload_folder_default_key">upload.folder.default</string>
<string name="pref_upload_folder_default_title">Upload to a default folder</string>
<string name="pref_upload_folder_default_summary">Check to select the default folder to upload your files into</string>
<string name="pref_upload_folder_key">upload.folder</string>
<string name="pref_upload_folder_title">Upload Folder</string>
<string name="pref_upload_folder_summary">Select the default folder to upload your files into</string>
<string name="pref_upload_folder_summary">Select the default folder to upload your files into.
Note: nothing will be shown until your first sync.</string>
<string name="pref_upload_tags_default_key">upload.tags.default</string>
<string name="pref_upload_tags_default_title">Set tags by default</string>
<string name="pref_upload_tags_default_summary">Check to select the default tag to add to all uploaded files/journals</string>
<string name="pref_upload_tags_key">upload.tags</string>