aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Models
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Application/Models')
-rwxr-xr-xh-source/Application/Models/UsersModel.php18
-rw-r--r--h-source/Application/Models/WikiModel.php41
2 files changed, 55 insertions, 4 deletions
diff --git a/h-source/Application/Models/UsersModel.php b/h-source/Application/Models/UsersModel.php
index a7c3845..fe72ce7 100755
--- a/h-source/Application/Models/UsersModel.php
+++ b/h-source/Application/Models/UsersModel.php
@@ -88,6 +88,24 @@ class UsersModel extends Model_Map
}
}
+ public function getLinkToUser($user)
+ {
+ if (strstr($user,'__'))
+ {
+ return str_replace('__',null,$user);
+ }
+ else
+ {
+ return "<a href='http://".DOMAIN_NAME."/meet/user/".Lang::$current."/$user'>$user</a>";
+ }
+ }
+
+ public function getLinkToUserFromId($id_user = 0)
+ {
+ $clean['id_user'] = (int)$id_user;
+ return $this->getLinkToUser($this->getUser($clean['id_user']));
+ }
+
//get the user id from the username
public function getUserId($username = '')
{
diff --git a/h-source/Application/Models/WikiModel.php b/h-source/Application/Models/WikiModel.php
index 1372a04..0a00bfb 100644
--- a/h-source/Application/Models/WikiModel.php
+++ b/h-source/Application/Models/WikiModel.php
@@ -50,13 +50,21 @@ class WikiModel extends Model_Map {
$this->fieldsWithBreaks = array(gtext('wiki page'));
$this->strongConditions['insert'] = array(
- "checkLength|99" => 'title',
- "+checkLength|5000" => 'page',
+ "checkLength|99" => 'title|'.gtext('title is too length'),
+ "+checkLength|9000" => 'page|'.gtext('the page text is too length'),
);
$this->strongConditions['update'] = array(
- "checkLength|99" => 'title',
- "+checkLength|5000" => 'page',
+ "checkLength|99" => 'title|'.gtext('title is too length'),
+ "+checkLength|9000" => 'page|'.gtext('the page text is too length'),
+ );
+
+ $this->databaseConditions['insert'] = array(
+ "checkUnique" => 'title|'.gtext('a page with the same title already exists'),
+ );
+
+ $this->databaseConditions['update'] = array(
+ "checkUniqueCompl" => 'title|'.gtext('a page with the same title already exists'),
);
parent::__construct();
@@ -95,6 +103,7 @@ class WikiModel extends Model_Map {
{
$clean['id'] = (int)$id;
+ $this->values['created_by'] = (int)$this->id_user;
$this->values['update_date'] = date('Y-m-d H:i:s');
$this->values['title_clean'] = encodeUrl($this->values['title']);
@@ -110,6 +119,13 @@ class WikiModel extends Model_Map {
$revisions->values = $oldValues;
if ($revisions->insert())
{
+
+ if ($this->isMain($clean['id']))
+ {
+ $this->values['title'] = 'Main Page';
+ $this->values['title_clean'] = 'Main-Page';
+ }
+
parent::update($clean['id']);
if ($this->queryResult)
{
@@ -155,6 +171,12 @@ class WikiModel extends Model_Map {
$this->values['created_by'] = (int)$this->id_user;
$this->values['update_date'] = date('Y-m-d H:i:s');
+ if ($this->isMain($clean['id_wiki']))
+ {
+ $this->values['title'] = 'Main Page';
+ $this->values['title_clean'] = 'Main-Page';
+ }
+
if ($revisions->insert())
{
if (parent::update($clean['id_wiki']))
@@ -221,6 +243,17 @@ class WikiModel extends Model_Map {
}
}
+ public function isMain($id)
+ {
+ $clean['id'] = (int)$id;
+ $res = $this->select('is_main')->where(array('id_wiki'=>$clean['id']))->send();
+ if ( count($res) > 0 )
+ {
+ return strcmp($res[0]['wiki']['is_main'],'no') === 0 ? false : true;
+ }
+ return false;
+ }
+
public function getDiffArray($oldArray, $newArray)
{
return getDiffArray($this->diffFields, $oldArray, $newArray);