Beispiel #1
0
 public function deleteOrganisationById($orgId)
 {
     $wepModel = new Model_Wep();
     // Delete Activities
     $actCollModel = new Model_ActivityCollection();
     $activities = $actCollModel->getActivityIdsByAccount($orgId);
     $activityModel = new Model_Activity();
     foreach ($activities as $activity) {
         $activityModel->deleteActivityById($activity['id']);
     }
     // Delete Defaults
     $wepModel->deleteRow('default_field_groups', 'account_id', $orgId);
     $wepModel->deleteRow('default_field_values', 'account_id', $orgId);
     // Delete registry info
     $regModel = new Model_RegistryInfo();
     $regModel->deleteRegistryInfo($orgId);
     // Delete Users
     $userModel = new Model_User();
     $users = $userModel->getAllUsersByAccountId($orgId);
     foreach ($users as $user) {
         $this->deleteUserById($user['user_id']);
     }
     // Delete account
     $wepModel->deleteRow('iati_activities', 'account_id', $orgId);
     $wepModel->deleteRow('account', 'id', $orgId);
 }
Beispiel #2
0
 /**
  * This function is used to check if user has minimum number of files publised for stopping displaying various tooltips.
  * The minimum number is saved in application.ini
  */
 public static function checkHasPublished($accountId = null)
 {
     if (!$accountId) {
         $identity = Zend_Auth::getInstance()->getIdentity();
         $accountId = $identity->account_id;
     }
     $minPublishedForHelp = Zend_Registry::get('config')->min_published_for_help;
     $model = new Model_ActivityCollection();
     $publishedCount = $model->getActivitiesCountByStatusAndAccount(Iati_WEP_ActivityState::STATUS_PUBLISHED, $accountId);
     if ($publishedCount >= $minPublishedForHelp) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #3
0
 public function listOrganisationAction()
 {
     $model = new Model_Wep();
     $userModel = new Model_User();
     $activity_model = new Model_ActivityCollection();
     $orgs = $model->listOrganisation('account');
     $org_data = array();
     foreach ($orgs as $organisation) {
         $users = $userModel->getUserCountByAccountId($organisation['id']);
         $organisation['users_count'] = $users[0]['users_count'];
         $activities = $activity_model->getActivitiesCountByAccount($organisation['id']);
         $organisation['activity_count'] = $activities[0]['activity_count'];
         $user = $userModel->getUserByAccountId($organisation['id'], array('role_id' => 1));
         $organisation['user_id'] = $user['user_id'];
         $organisation['email'] = $user['email'];
         $org_data[] = $organisation;
     }
     $this->view->rowSet = $org_data;
 }
Beispiel #4
0
 public function init()
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $activityId = $this->_getParam('activity_id');
     // Check activity access
     if ($activityId) {
         $model = new Model_ActivityCollection();
         $access = $model->getActivityAccess($activityId, $identity->account_id);
         if (!$access) {
             $this->_helper->FlashMessenger->addMessage(array('error' => "Access denied."));
             $this->_redirect("/wep/dashboard");
         }
     }
     $this->_helper->layout()->setLayout('layout_wep');
     $this->view->blockManager()->enable('partial/dashboard.phtml');
     $this->view->blockManager()->enable('partial/primarymenu.phtml');
     $this->view->blockManager()->enable('partial/add-activity-menu.phtml');
     $this->view->blockManager()->enable('partial/published-list.phtml');
     $this->view->blockManager()->enable('partial/organisation-data.phtml');
     $this->view->blockManager()->enable('partial/download-my-data.phtml');
     // for role user check if the user has permission to add, publish ,if not disable menu.
     if ($identity->role == 'user') {
         $model = new Model_Wep();
         $userPermission = $model->getUserPermission($identity->user_id);
         $permission = $userPermission->hasPermission(Iati_WEP_PermissionConts::ADD_ACTIVITY);
         $publishPermission = $userPermission->hasPermission(Iati_WEP_PermissionConts::PUBLISH);
         if (!$permission) {
             $this->view->blockManager()->disable('partial/add-activity-menu.phtml');
         }
         if (!$publishPermission) {
             $this->view->blockManager()->disable('partial/published-list.phtml');
         }
     }
     $this->view->blockManager()->enable('partial/usermgmtmenu.phtml');
     if (!Simplified_Model_Simplified::isSimplified()) {
         $this->view->blockManager()->enable('partial/uploaded-docs.phtml');
     }
 }
Beispiel #5
0
 public function listOrganisationAction()
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $userId = $identity->user_id;
     $userModel = new Model_User();
     $groupModel = new User_Model_DbTable_Group();
     $userGroupModel = new User_Model_DbTable_UserGroup();
     $activityModel = new Model_ActivityCollection();
     $group = $userGroupModel->getRowByUserId($userId);
     $orgs = $groupModel->getAllOrganisationsByGroupId($group['group_id']);
     $org_data = array();
     foreach ($orgs as $organisation) {
         $users = $userModel->getUserCountByAccountId($organisation['account_id']);
         $organisation['users_count'] = $users[0]['users_count'];
         $activities = $activityModel->getActivitiesCountByAccount($organisation['account_id']);
         $organisation['activity_count'] = $activities[0]['activity_count'];
         $user = $userModel->getUserByAccountId($organisation['account_id'], array('role_id' => 1));
         $organisation['user_id'] = $user['user_id'];
         $org_data[] = $organisation;
     }
     $this->view->groupRow = $group;
     $this->view->rowSet = $org_data;
 }
Beispiel #6
0
 public function dashboardAction()
 {
     if (Simplified_Model_Simplified::isSimplified()) {
         $this->_redirect('simplified/default/dashboard');
     }
     $identity = Zend_Auth::getInstance()->getIdentity();
     $account_id = $identity->account_id;
     $model = new Model_Wep();
     $activityModel = new Model_Activity();
     $activities_id = $model->listAll('iati_activities', 'account_id', $account_id);
     if (empty($activities_id)) {
         $data['@version'] = '01';
         $data['@generated_datetime'] = date('Y-m-d H:i:s');
         $data['user_id'] = $identity->user_id;
         $data['account_id'] = $identity->account_id;
         $data['unqid'] = uniqid();
         $activities_id = $model->insertRowsToTable('iati_activities', $data);
     } else {
         $activities_id = $activities_id[0]['id'];
     }
     $activityCollModel = new Model_ActivityCollection();
     $activities = $activityCollModel->getActivitiesByAccount($account_id);
     $activitiesAttribs = $activityCollModel->getActivityAttribs($activities);
     $regInfoModel = new Model_RegistryInfo();
     $regInfo = $regInfoModel->getOrgRegistryInfo($account_id);
     $regPublishModel = new Model_RegistryPublishedData();
     $publishedFiles = $regPublishModel->getPublishedInfoByOrg($account_id);
     $this->view->published_data = $published_data;
     $this->view->activity_count = sizeof($activities);
     $this->view->state_count = $activityModel->getCountByState($activities);
     $this->view->last_updated_datetime = $activityModel->getLastUpdatedDatetime($activities);
     $this->view->published_activity_count = $regPublishModel->getActivityCount($publishedFiles);
     $this->view->activity_elements_info = $activitiesAttribs;
     $this->view->registry_url = "/publisher/" . $regInfo->publisher_id;
     $this->view->activities_id = $activities_id;
 }
Beispiel #7
0
 public function getPublishedActivityCollection($account_id)
 {
     $db = new Model_ActivityCollection();
     $activitiesId = $db->getActivitiesByStatusAndAccount(Iati_WEP_ActivityState::STATUS_PUBLISHED, $account_id);
     return $activitiesId;
 }
Beispiel #8
0
 /**
  * Ported from Admin Controller::listActivityStatesAction()
  * @param None
  * @return Array containing activity states and activity registry published count for all organisations.
  */
 public function allOrganisationsActivityStates()
 {
     $model = new Model_Wep();
     $activityCollModel = new Model_ActivityCollection();
     // $activityModel = new Model_Activity();
     $orgs = $model->listOrganisation('account');
     $orgData = array();
     foreach ($orgs as $organisation) {
         $activities = $activityCollModel->getActivitiesByAccount($organisation['id']);
         $states = $this->getCountByState($activities);
         $organisation['states'] = $states;
         $regPublishModel = new Model_RegistryPublishedData();
         $publishedFiles = $regPublishModel->getPublishedInfoByOrg($organisation['id']);
         $publishedActivityCount = $regPublishModel->getActivityCount($publishedFiles);
         $organisation['registry_published_count'] = $publishedActivityCount;
         $orgData[] = $organisation;
     }
     return $orgData;
 }
Beispiel #9
0
 /**
  * Fetch all activity ids from account id. User activitycollection model
  */
 public function getActivityIds($accountId)
 {
     $ids = array();
     $actModel = new Model_ActivityCollection();
     $activityIds = $actModel->getActivityIdsByAccount($accountId);
     if (!empty($activityIds)) {
         foreach ($activityIds as $id) {
             $ids[] = $id['id'];
         }
     }
     return $ids;
 }