Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 232a73c

Browse files
author
Julien Jomier
committed
ENH: Worked on the migration script
ENH: Now checking that directories don't have the same names STYLE: Renamed plusOneView() to incrementViewCount()
1 parent 7c41569 commit 232a73c

14 files changed

+504
-86
lines changed

core/controllers/AdminController.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class AdminController extends AppController
77
{
88
public $_models=array('Errorlog','Assetstore');
99
public $_daos=array();
10-
public $_components=array('Upgrade','Utility');
10+
public $_components=array('Upgrade','Utility','MIDAS2Migration');
1111
public $_forms=array('Admin','Assetstore');
1212

1313
function init()
@@ -363,8 +363,15 @@ function serversidefilechooserAction()
363363
} // end function serversidefilechooserAction
364364

365365

366-
367-
366+
/**
367+
* \fn
368+
* \brief
369+
*/
370+
function migratemidas2Action()
371+
{
372+
$this->Component->MIDAS2Migration->migrate();
373+
exit();
374+
}
368375

369376
} // end class
370377

core/controllers/CommunityController.php

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function viewAction()
246246
$this->Group->addUser($member_group,$this->userSession->Dao);
247247
}
248248

249-
$this->Community->plusOneView($communityDao);
249+
$this->Community->incrementViewCount($communityDao);
250250
$this->view->communityDao=$communityDao;
251251
$this->view->information=array();
252252
$this->view->feeds=$this->Feed->getFeedsByCommunity($this->userSession->Dao,$communityDao);
@@ -312,61 +312,11 @@ function createAction()
312312
$form=$this->Form->Community->createCreateForm();
313313
if($this->_request->isPost()&&$form->isValid($this->getRequest()->getPost()))
314314
{
315-
if($this->Community->getByName($form->getValue('name'))!==false)
316-
{
317-
throw new Zend_Exception("Community already exists.");
318-
}
319-
$communityDao=new CommunityDao();
320-
$communityDao->setName(ucfirst($form->getValue('name')));
321-
$communityDao->setDescription($form->getValue('description'));
322-
$communityDao->setPrivacy($form->getValue('privacy'));
323-
$communityDao->setCreation(date('c'));
324-
$this->Community->save($communityDao);
325-
326-
$folderGlobal=$this->Folder->createFolder('community_'.$communityDao->getKey(),'Main folder of the community '.$communityDao->getKey(),MIDAS_FOLDER_COMMUNITYPARENT);
327-
$folderPublic=$this->Folder->createFolder('Public','Public folder of the community '.$communityDao->getKey(),$folderGlobal);
328-
$folderPrivate=$this->Folder->createFolder('Private','Private folder of the community '.$communityDao->getKey(),$folderGlobal);
329-
330-
$adminGroup=$this->Group->createGroup($communityDao,'Admin group of community '.$communityDao->getKey());
331-
$moderatorsGroup=$this->Group->createGroup($communityDao,'Moderators group of community '.$communityDao->getKey());
332-
$memberGroup=$this->Group->createGroup($communityDao,'Members group of community '.$communityDao->getKey());
333-
$anonymousGroup=$this->Group->load(MIDAS_GROUP_ANONYMOUS_KEY);
334-
335-
$communityDao->setFolderId($folderGlobal->getKey());
336-
$communityDao->setPublicfolderId($folderPublic->getKey());
337-
$communityDao->setPrivatefolderId($folderPrivate->getKey());
338-
$communityDao->setAdmingroupId($adminGroup->getKey());
339-
$communityDao->setModeratorgroupId($moderatorsGroup->getKey());
340-
$communityDao->setMembergroupId($memberGroup->getKey());
341-
$this->Community->save($communityDao);
342-
343-
$this->Group->addUser($adminGroup,$this->userSession->Dao);
344-
$this->Group->addUser($memberGroup,$this->userSession->Dao);
345-
346-
$feed=$this->Feed->createFeed($this->userSession->Dao,MIDAS_FEED_CREATE_COMMUNITY,$communityDao,$communityDao);
347-
$this->Feedpolicyuser->createPolicy($this->userSession->Dao,$feed,MIDAS_POLICY_ADMIN);
348-
349-
$this->Folderpolicygroup->createPolicy($adminGroup,$folderGlobal,MIDAS_POLICY_ADMIN);
350-
$this->Folderpolicygroup->createPolicy($adminGroup,$folderPublic,MIDAS_POLICY_ADMIN);
351-
$this->Folderpolicygroup->createPolicy($adminGroup,$folderPrivate,MIDAS_POLICY_ADMIN);
352-
$this->Feedpolicygroup->createPolicy($adminGroup,$feed,MIDAS_POLICY_ADMIN);
353-
354-
$this->Folderpolicygroup->createPolicy($moderatorsGroup,$folderGlobal,MIDAS_POLICY_READ);
355-
$this->Folderpolicygroup->createPolicy($moderatorsGroup,$folderPublic,MIDAS_POLICY_WRITE);
356-
$this->Folderpolicygroup->createPolicy($moderatorsGroup,$folderPrivate,MIDAS_POLICY_WRITE);
357-
$this->Feedpolicygroup->createPolicy($moderatorsGroup,$feed,MIDAS_POLICY_ADMIN);
358-
359-
$this->Folderpolicygroup->createPolicy($memberGroup,$folderGlobal,MIDAS_POLICY_READ);
360-
$this->Folderpolicygroup->createPolicy($memberGroup,$folderPublic,MIDAS_POLICY_WRITE);
361-
$this->Folderpolicygroup->createPolicy($memberGroup,$folderPrivate,MIDAS_POLICY_WRITE);
362-
$this->Feedpolicygroup->createPolicy($memberGroup,$feed,MIDAS_POLICY_READ);
363-
364-
if($communityDao->getPrivacy()!=MIDAS_COMMUNITY_PRIVATE)
365-
{
366-
$this->Folderpolicygroup->createPolicy($anonymousGroup,$folderPublic,MIDAS_POLICY_READ);
367-
$this->Feedpolicygroup->createPolicy($anonymousGroup,$feed,MIDAS_POLICY_READ);
368-
}
315+
$name = $form->getValue('name');
316+
$description = $form->getValue('description');
317+
$privacy = $form->getValue('privacy');
369318

319+
$communityDao = $this->Community->createCommunity($name,$description,$privacy,$this->userSession->Dao);
370320
$this->_redirect("/community/".$communityDao->getKey());
371321
}
372322
else
@@ -382,7 +332,7 @@ function createAction()
382332

383333

384334

385-
/** valid entries (ajax)*/
335+
/** valid entries (ajax)*/
386336
public function validentryAction()
387337
{
388338
if(!$this->getRequest()->isXmlHttpRequest())

core/controllers/FolderController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function viewAction()
7171
$header.="</ul>";
7272
}
7373

74-
$this->Folder->plusOneView($folder);
74+
$this->Folder->incrementViewCount($folder);
7575
$this->view->mainFolder=$folder;
7676
$this->view->folders=$folders;
7777
$this->view->items=$items;

core/controllers/ImportController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ private function _recursiveParseDirectory($path,$currentdir)
133133
$item->setName($fileInfo->getFilename());
134134
$this->Item->save($item);
135135

136-
137136
// Set the keyword for the item
138137
$keyword = new ItemKeywordDao();
139138
$keyword->setValue($fileInfo->getFilename());

core/controllers/ItemController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function viewAction()
7474
setcookie('recentItems'.$this->userSession->Dao->getKey(), serialize($recentItems), time()+60*60*24*30,'/'); //30 days
7575
}
7676
$itemRevision=$this->Item->getLastRevision($itemDao);
77-
$this->Item->plusOneView($itemDao);
77+
$this->Item->incrementViewCount($itemDao);
7878
$itemDao->lastrevision=$itemRevision;
7979
$itemDao->revisions=$itemDao->getRevisions();
8080
$itemDao->creation=$this->Component->Date->formatDate(strtotime($itemRevision->getDate()));

0 commit comments

Comments
 (0)