public function indexAction()
 {
     $grpmodel = new Default_Model_Groups();
     $cmpmodel = new Default_Model_Campaigns();
     $grpadm = new Default_Model_GroupAdmins();
     // If you find a better way to do this, be my guest.
     $cmps = $cmpmodel->getRecent(15);
     $cmps_new = array();
     foreach ($cmps as $cmp) {
         $grp = $grpmodel->getGroupData($cmp['id_grp_cmp']);
         $cmp['group_name_grp'] = $grp['group_name_grp'];
         $cmps_new[] = $cmp;
     }
     // See previous comment.
     $grps = $grpmodel->getRecent(12);
     $grps_new = array();
     foreach ($grps as $grp) {
         $adm = $grpadm->getGroupAdmins($grp['id_grp']);
         $grp['id_admin'] = $adm[0]['id_usr'];
         $grp['login_name_admin'] = $adm[0]['login_name_usr'];
         $grps_new[] = $grp;
     }
     $this->view->campaigns = $cmps_new;
     $this->view->groups = $grps_new;
 }
示例#2
0
 /**
  *   isValid Checks if a campaign exists in db using Campaign model's
  *   campaignExists function.
  *
  *   @param  $value string group name
  *   @return boolean
  */
 public function isValid($value)
 {
     $value = (string) $value;
     $this->_setValue($value);
     $campaignModel = new Default_Model_Campaigns();
     if ($campaignModel->campaignExists($value)) {
         $this->_error(self::NOT_MATCH);
         return false;
         // if the group exists, the form is not valid
     } else {
         return true;
         // if the group doesn't exist, the form is valid
     }
 }
示例#3
0
 /**
  * viewAction - shows an individual group's page
  *
  * @author Mikko Aatola
  */
 function viewAction()
 {
     // Get authentication
     $auth = Zend_Auth::getInstance();
     // If user has identity
     if ($auth->hasIdentity()) {
         // Get data for this specific group.
         $grpId = $this->_request->getParam('groupid');
         $grpModel = new Default_Model_Groups();
         $usrHasGrpModel = new Default_Model_UserHasGroup();
         $grpAdminsModel = new Default_Model_GroupAdmins();
         $campaignModel = new Default_Model_Campaigns();
         $grpAdmins = $grpAdminsModel->getGroupAdmins($grpId);
         $user = $auth->getIdentity();
         // Add data to the view.
         $this->view->grpId = $grpId;
         $this->view->grpData = $grpModel->getGroupData($grpId);
         $this->view->grpUsers = $usrHasGrpModel->getAllUsersInGroup($grpId);
         $this->view->grpAdmins = $grpAdmins;
         $this->view->userHasGroup = $usrHasGrpModel;
         $this->view->campaigns = $campaignModel->getCampaignsByGroup($grpId);
         $this->view->userIsGroupAdmin = $this->checkIfArrayHasKeyWithValue($grpAdmins, 'id_usr', $user->user_id);
     } else {
         // Groups are only visible to registered users.
         $target = $this->_urlHelper->url(array('controller' => 'index', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->_redirector->gotoUrl($target);
     }
 }
示例#4
0
 function getrecentgroupsAction()
 {
     $offset = isset($this->params['offset']) ? $this->params['offset'] : 0;
     $grpmodel = new Default_Model_Groups();
     $grpadm = new Default_Model_GroupAdmins();
     $usrHasGrp = new Default_Model_UserHasGroup();
     $cmpmodel = new Default_Model_Campaigns();
     $grps = $grpmodel->getRecentFromOffset($offset, 10);
     $grps_new = array();
     foreach ($grps as $grp) {
         $adm = $grpadm->getGroupAdmins($grp['id_grp']);
         $grp['id_admin'] = $adm[0]['id_usr'];
         $grp['login_name_admin'] = $adm[0]['login_name_usr'];
         $grp['campaign_count'] = count($cmpmodel->getCampaignsByGroup($grp['id_grp']));
         $grp['member_count'] = count($usrHasGrp->getAllUsersInGroup($grp['id_grp']));
         $grps_new[] = $grp;
     }
     $this->view->recentgroups = $grps_new;
 }
示例#5
0
文件: RssReader.php 项目: jannev/site
 private function getCampaignTitle()
 {
     $cmpModel = new Default_Model_Campaigns();
     $cmp = $cmpModel->getCampaignById($this->id);
     return $cmp->name_cmp;
 }
示例#6
0
 function endAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $cmpId = $this->_request->getParam('id');
         if (!$cmpId) {
             $target = $this->_urlHelper->url(array('controller' => 'index', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
             $this->_redirector->gotoUrl($target);
         }
         // Get group id from campaign info.
         $cmpModel = new Default_Model_Campaigns();
         $cmp = $cmpModel->getCampaignById($cmpId)->toArray();
         $grpId = $cmp['id_grp_cmp'];
         // Only group admins can end campaign.
         $grpAdminsModel = new Default_Model_GroupAdmins();
         $grpAdmins = $grpAdminsModel->getGroupAdmins($grpId);
         $userIsGroupAdmin = $this->checkIfArrayHasKeyWithValue($grpAdmins, 'id_usr', $auth->getIdentity()->user_id);
         if (!$userIsGroupAdmin) {
             $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
             $this->_redirector->gotoUrl($redirectUrl);
         }
         // Check if campaign status is ended
         $status = $cmpModel->getStatus($cmpId);
         if ($status === "ended") {
             $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
             $this->_redirector->gotoUrl($redirectUrl);
         }
         // Chang end date to yesterday
         $cmpModel->endCampaign($cmpId, $cmp['start_time_cmp']);
         // Redirect back to the campaign page.
         $target = $this->_urlHelper->url(array('cmpid' => $cmpId, 'language' => $this->view->language), 'campaign_view', true);
         $this->_redirector->gotoUrl($target);
     } else {
         // Not logged in.
         $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->_redirector->gotoUrl($redirectUrl);
     }
 }
示例#7
0
文件: Content.php 项目: jannev/site
 /**
  *   editContent
  *
  *   Edit content.
  *
  *   @param array $data
  */
 public function editContent($data)
 {
     // Get the original content
     $content = $this->getContentRow($data['content_id']);
     // Get content type
     $contentTypes = new Default_Model_ContentTypes();
     $contentType = $contentTypes->getTypeById($content['id_cty_cnt']);
     // Unset fields that are not going to be updated
     unset($content['id_cnt']);
     unset($content['id_cty_cnt']);
     unset($content['views_cnt']);
     unset($content['created_cnt']);
     $content['title_cnt'] = htmlspecialchars($data['content_header']);
     $content['lead_cnt'] = htmlspecialchars($data['content_textlead']);
     $content['language_cnt'] = $data['content_language'];
     $content['body_cnt'] = htmlspecialchars($data['content_text']);
     if (!isset($data['content_research'])) {
         $data['content_research'] = "";
     }
     if (!isset($data['content_opportunity'])) {
         $data['content_opportunity'] = "";
     }
     if (!isset($data['content_threat'])) {
         $data['content_threat'] = "";
     }
     if (!isset($data['content_solution'])) {
         $data['content_solution'] = "";
     }
     $content['research_question_cnt'] = htmlspecialchars($data['content_research']);
     $content['opportunity_cnt'] = htmlspecialchars($data['content_opportunity']);
     $content['threat_cnt'] = htmlspecialchars($data['content_threat']);
     $content['solution_cnt'] = htmlspecialchars($data['content_solution']);
     $content['references_cnt'] = htmlspecialchars($data['content_references']);
     $content['modified_cnt'] = new Zend_Db_Expr('NOW()');
     if (isset($data['publish']) && $data['publish'] == 1) {
         $content['published_cnt'] = 1;
     }
     $where = $this->getAdapter()->quoteInto('`id_cnt` = ?', $data['content_id']);
     // MIK� VITTU T�SS� KUSEE?
     if (!$this->update($content, $where)) {
         $return = false;
     } else {
         $return = $data['content_id'];
     }
     // Check if user has given keywords
     if (!empty($data['content_keywords'])) {
         // Get existing keywords of the content
         $cntHasTag = new Default_Model_ContentHasTag();
         $existingTags = $cntHasTag->checkExistingTags($data['content_id'], $data['content_keywords']);
         //$existingTags = $cntHasTag->getContentTags($data['content_id']);
         $modelTags = new Default_Model_Tags();
         $modelTags->addTagsToContent($data['content_id'], $data['content_keywords'], $existingTags);
         /*
         $i = 0;
         // Go through all existing keywords
         // This belongs to contentHasTags model
         foreach($existingTags as $existingTag) {
         // If some of the existing keywords aren't found in sent keywords,
         // that keyword is deleted the from content and maybe even from the
         // database
         if(!in_array($existingTag['name_tag'], $data['content_keywords'])) {
         // Removing tag from content
         $cntHasTag->deleteTagFromContent($existingTag['id_tag'], $data['content_id']);
         
         // If other content(s) doesn't have this tag, the whole
         // tag is going to be removed from the database
         if(!$cntHasTag->checkIfOtherContentHasTag($existingTag['id_tag'], $data['content_id'])) {
         $modelTags->removeTag($existingTag['id_tag']);
         }
         
         // Remove tag from existingTags array
         unset($existingTags[$i]);
         }
         $i++;
         }
         */
         /*
         // Go through all sent keywords
         // This belongs to Tags model
         foreach($data['content_keywords'] as $tag) {
         $tag = strip_tags($tag);
         
         $foundTag = false;
         foreach($existingTags as $existingTag) {
         if($tag == $existingTag['name_tag']) {
         $foundTag = true;
         }
         }
         
         // If tag is not found in existing tags
         if(!$foundTag) {
         // Check if given keyword does not exists in database
         if($modelTags->tagExists($tag)) {
         // Create new keyword
         $tag = $modelTags->createTag($tag);
         } else {
         // Get keyword
         $tag = $modelTags->getTag($tag);
         } // end else
         
         // Add keywords to content
         $cntHasTag->addTagToContent($tag->id_tag, $data['content_id']);
         }
         } // end foreach
         */
     }
     // end if
     // Check if user has related companies
     if (!empty($data['content_related_companies'])) {
         // Get existing related companies of the content
         $cntHasRec = new Default_Model_ContentHasRelatedCompany();
         $existingCompanies = $cntHasRec->checkExistingCompanies($data['content_id'], $data['content_related_companies']);
         //$existingRecs = $cntHasRec->getContentRelComps($data['content_id']);
         $modelRecs = new Default_Model_RelatedCompanies();
         $modelRecs->addRelatedCompaniesToContent($data['content_id'], $data['content_related_companies'], $existingCompanies);
         /*
         $i = 0;
         // Go through all existing related companies
         // FIX: This belongs to ContentHasRelatedCompany model
         foreach($existingRecs as $existingRec) {
         // If some of the existing related companies aren't found in sent
         // related companies, that related company is deleted from the
         // content and maybe even from thedatabase
         // FIXED: Could have caused mismatches when adding,
         // since when related company is added strip_tags is used
         // but not when doing comparisons here.
         // This goes for campaigns as well.
         if(!in_array($existingRec['name_rec'], $data['content_related_companies'])) {
         // Removing rec from content
         $cntHasRec->deleteRelCompFromContent($existingRec['id_rec'], $data['content_id']);
         
         // If other content(s) doesn't have this related company, the whole
         // related company is going to be removed from the database
         if(!$cntHasRec->checkIfOtherContentHasRelComp($existingRec['id_rec'], $data['content_id'])) {
         $modelRecs->removeRelComp($existingRec['id_rec']);
         }
         
         // Remove related company from existingRecs array
         unset($existingRecs[$i]);
         }
         $i++;
         }
         */
         /*
         // Go through all sent related companies
         // FIX: This belongs to RelatedCompany model
         foreach($data['content_related_companies'] as $rec) {
         //$rec = strip_tags($rec);
         
         $foundRec = false;
         foreach($existingRecs as $existingRec) {
         if($rec == $existingRec['name_rec']) {
         $foundRec = true;
         }
         }
         
         // If related company is not found in existing related companies
         if(!$foundRec) {
         // Check if given related company does not exists in database
         if($modelRecs ->relCompExists($rec)) {
         // Create new related company
         $rec = $modelRecs ->createRelComp($rec);
         } else {
         // Get related company
         $rec = $modelRecs ->getRelComp($rec);
         } // end else
         
         // Add related company to content
         $cntHasRec->addRelCompToContent($rec->id_rec, $data['content_id']);
         }
         } // end foreach
         */
     }
     // end if
     /*
     if($_FILES['content_file_upload']['size'] != 0) {
     $files = new Default_Model_Files();
     $files->newFile($content->id_cnt, $auth->getIdentity()->user_id);
     }
     */
     // Check if user has given campaigns
     if (!empty($data['content_campaigns'])) {
         // Get existing campaigns of the content
         $cntHasCmp = new Default_Model_ContentHasCampaign();
         $existingCampaigns = $cntHasCmp->checkExistingCampaigns($data['content_id'], $data['content_campaigns']);
         //$existingCmps = $cntHasCmp->getContentCampaigns($data['content_id']);
         $modelCmps = new Default_Model_Campaigns();
         $modelCmps->addCampaignsToContent($data['content_id'], $data['content_campaigns'], $existingCampaigns);
         /*
         $i = 0;
         // Go through all existing campaigns
         // FIX: This belongs to ContentHasCampaign moodel
         foreach($existingCmps as $existingCmp) {
         // If some of the existing campaigns aren't found in sent campaigns,
         // that campaign is deleted the from content and maybe even from the
         // database
         if(!in_array($existingCmp['name_cmp'], $data['content_campaigns'])) {
         // Removing campaign from content
         $cntHasCmp->deleteCampaignFromContent($existingCmp['id_cmp'], $data['content_id']);
         
         // If other content(s) doesn't have this campaign, the whole
         // campaign is going to be removed from the database
         if(!$cntHasCmp->checkIfOtherContentHasCampaign($existingCmp['id_cmp'], $data['content_id'])) {
         $modelCmps->removeCampaign($existingCmp['id_cmp']);
         }
         
         // Remove campaign from existingCmps array
         unset($existingCmps[$i]);
         }
         $i++;
         }
         */
         /*
         // Go through all sent campaigns
         // FIX: This belongs to Campaigns model
         foreach($data['content_campaigns'] as $cmp) {
         //$cmp = strip_tags($cmp);
         
         $foundCmp = false;
         foreach($existingCmps as $existingCmp) {
         if($cmp == $existingCmp['name_cmp']) {
         $foundCmp = true;
         }
         }
         
         // If campaign is not found in existing tags
         if(!$foundCmp) {
         // Check if given campaign does not exists in database
         if($modelCmps->campaignExists($cmp)) {
         // Create new campaign
         $cmp = $modelCmps->createCampaign($cmp);
         } else {
         // Get campaign
         $cmp = $modelCmps->getCampaign($cmp);
         } // end else
         
         // Add campaigns to content
         $cntHasCmp->addCampaignToContent($cmp->id_cmp, $data['content_id']);
         }
         } // end foreach
         */
     }
     // end if
     /*// Update industry to content
     	 $contentHasIndustry = new Default_Model_ContentHasIndustries();
     	 $current_industry = $contentHasIndustry->getIndustryIdOfContent($data['content_id']);
     	 if($current_industry != $data['content_industry_id']) {
     	 if(!$contentHasIndustry->updateIndustryToContent($data['content_industry_id'], $data['content_id'])) {
     	 $return = false;
     	 }
     	 }*/
     if ($return) {
         $filesModel = new Default_Model_Files();
         $filesModel->newFiles($data['content_id'], "content", $data['files']);
         if (isset($data['uploadedFiles'])) {
             $filesModel->deleteCertainFiles($data['content_id'], "content", $data['uploadedFiles']);
         }
     }
     if ($contentType == "idea") {
         // Update innovation type to content
         $contentHasInnovationType = new Default_Model_ContentHasInnovationTypes();
         $current_innovation_type = $contentHasInnovationType->getInnovationTypeIdOfContent($data['content_id']);
         if ($current_innovation_type != $data['innovation_type']) {
             if (!$contentHasInnovationType->updateInnovationTypeToContent($data['innovation_type'], $data['content_id'])) {
                 $return = false;
             }
         }
     }
     return $return;
 }
示例#8
0
 /**
  *	Show mainpage and list newest and most viewed ideas and problems
  */
 function indexAction()
 {
     // Variable for number recent campaigns to be sent to view
     $recentCampaignsCount = 0;
     $this->view->title = "index-home";
     // Get cache from registry
     $cache = Zend_Registry::get('cache');
     // $contentTypesModel = new Default_Model_ContentTypes();
     // $userModel = new Default_Model_User();
     // Load recent posts from cache
     $cachePosts = 'IndexPosts_' . $this->view->language;
     if (!($result = $cache->load($cachePosts))) {
         $contentModel = new Default_Model_Content();
         $contentHasTagModel = new Default_Model_ContentHasTag();
         // get data
         //($cty = 'all', $page = 1, $count = -1, $order = 'created', $lang = 'en', $ind = 0)
         $recentposts_raw = $contentModel->listRecent('all', 12, -1, 'created', $this->view->language, -1);
         $recentposts = array();
         $i = 0;
         // gather data for recent posts
         foreach ($recentposts_raw as $post) {
             $recentposts[$i] = $post;
             $recentposts[$i]['tags'] = $contentHasTagModel->getContentTags($post['id_cnt']);
             $i++;
         }
         // Save recent posts data to cache
         $cache->save($recentposts, $cachePosts);
     } else {
         $recentposts = $result;
     }
     // Load most popular tags from cache
     if (!($result = $cache->load('IndexTags'))) {
         $tagsModel = new Default_Model_Tags();
         $tags = $tagsModel->getPopular(20);
         /*
         // resize tags
         foreach ($tags as $k => $tag) {
             $size = round(50 + ($tag['count'] * 30));
             if ($size > 300) {
                 $size = 300;
             }
             $tags[$k]['tag_size'] = $size;
         }
         */
         // Action helper for tags
         $tags = $this->_helper->tagsizes->popularTagCalc($tags);
         // Action helper for define is tag running number divisible by two
         $tags = $this->_helper->tagsizes->isTagDivisibleByTwo($tags);
         // Save most popular tags data to cache
         $cache->save($tags, 'IndexTags');
     } else {
         $tags = $result;
     }
     // Laod most active users from cache
     if (!($result = $cache->load('IndexUsers'))) {
         $contentHasUserModel = new Default_Model_ContentHasUser();
         $activeusers = $contentHasUserModel->getMostActive(5);
         // Save most active users data to cache
         $cache->save($activeusers, 'IndexUsers');
     } else {
         $activeusers = $result;
     }
     // inject data to view
     if (isset($recentposts)) {
         $this->view->recentposts = $recentposts;
     } else {
         $this->view->recentposts = '';
     }
     // Get recent campaigns
     $grpmodel = new Default_Model_Groups();
     $campaignModel = new Default_Model_Campaigns();
     $recentcampaigns = $campaignModel->getRecent(5);
     // If you find (time to think of) a better way to do this, be my guest.
     $cmps_new = array();
     foreach ($recentcampaigns as $cmp) {
         $grp = $grpmodel->getGroupData($cmp['id_grp_cmp']);
         $cmp['group_name_grp'] = $grp['group_name_grp'];
         $cmps_new[] = $cmp;
     }
     // Get recent groups
     $grps = $grpmodel->getRecent(5);
     $grps_new = array();
     $grpadm = new Default_Model_GroupAdmins();
     foreach ($grps as $grp) {
         $adm = $grpadm->getGroupAdmins($grp['id_grp']);
         $grp['id_admin'] = $adm[0]['id_usr'];
         $grp['login_name_admin'] = $adm[0]['login_name_usr'];
         $grps_new[] = $grp;
     }
     $this->view->campaigns = $cmps_new;
     $this->view->groups = $grps_new;
     $this->view->poptags = $tags;
     $this->view->activeusers = $activeusers;
     $this->view->isLoggedIn = Zend_Auth::getInstance()->hasIdentity();
     $this->view->recentCampaignsCount = $recentCampaignsCount;
 }
示例#9
0
 /**
  * linkedgroupsAction
  *
  * @author Mikko Korpinen
  */
 public function linkedgroupsAction()
 {
     // User identity, group header and group menu:
     // Group id
     $grpId = $this->_request->getParam('groupid');
     $grpModel = new Default_Model_Groups();
     // Check if group exists
     if (!isset($grpId) || !$grpModel->groupExistsById($grpId)) {
         $target = $this->_urlHelper->url(array('controller' => 'group', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->_redirector->gotoUrl($target);
     }
     // Group data
     $grpData = $this->getGroupData($grpId);
     // Menudata
     $menuData['id_grp'] = $grpId;
     $menuData['grp_action'] = 'linkedgroups';
     $menuData['group_name_grp'] = $grpData['group_name_grp'];
     $menuData['grp_admins'] = $grpData['grp_admins'];
     // Set $this->view->...
     $this->view->grpData = $grpData;
     $this->view->menuData = $menuData;
     // Group membersAction special stuff:
     // Get linked groups
     $grpHasGrpModel = new Default_Model_GroupHasGroup();
     $linkedgroups = $grpHasGrpModel->getGroupGroups($grpId);
     $linkedgroups = array_merge($linkedgroups['parents'], $linkedgroups['childs']);
     $usrHasGrpModel = new Default_Model_UserHasGroup();
     $cmpModel = new Default_Model_Campaigns();
     $linkedgroups_new = array();
     foreach ($linkedgroups as $grp) {
         $grp['campaign_count'] = count($cmpModel->getCampaignsByGroup($grp['id_grp']));
         $grp['member_count'] = count($usrHasGrpModel->getAllUsersInGroup($grp['id_grp']));
         $linkedgroups_new[] = $grp;
     }
     // Set $this->view->...
     $this->view->linkedgroups = $linkedgroups_new;
 }
示例#10
0
 /**
  * viewAction - shows an individual group's page
  *
  * @author Mikko Aatola
  */
 function viewAction()
 {
     // Get authentication
     $auth = Zend_Auth::getInstance();
     // If user has identity
     if ($auth->hasIdentity()) {
         $this->view->identity = true;
     } else {
         $this->view->identity = false;
     }
     // Get data for this specific group.
     $grpId = $this->_request->getParam('groupid');
     $grpModel = new Default_Model_Groups();
     $usrHasGrpModel = new Default_Model_UserHasGroup();
     $usrHasGrpWaitingModel = new Default_Model_UserHasGroupWaiting();
     $grpAdminsModel = new Default_Model_GroupAdmins();
     $campaignModel = new Default_Model_Campaigns();
     $grpAdmins = $grpAdminsModel->getGroupAdmins($grpId);
     $user = $auth->getIdentity();
     $grpData = $grpModel->getGroupData($grpId);
     $grpData['description_grp'] = str_replace("\n", '<br>', $grpData['description_grp']);
     $grpData['body_grp'] = str_replace("\n", '<br>', $grpData['body_grp']);
     // Group type
     $grpTypeId = $grpModel->getGroupTypeId($grpId);
     $grpTypeModel = new Default_Model_GroupTypes();
     $isClosed = $grpTypeModel->isClosed($grpTypeId);
     // Waiting list count
     $usrWaitingCount = $usrHasGrpWaitingModel->getUserCountByGroup($grpId);
     // Group weblinks
     $groupWeblinksModel = new Default_Model_GroupWeblinks();
     $grpData['groupWeblinks'] = $groupWeblinksModel->getGroupWeblinks($grpId);
     $i = 0;
     foreach ($grpData['groupWeblinks'] as $weblink) {
         if (strlen($weblink['name_gwl']) == 0 || strlen($weblink['url_gwl']) == 0) {
             unset($grpData['groupWeblinks'][$i]);
         }
         $i++;
     }
     // Get group groups
     $grpHasGrpModel = new Default_Model_GroupHasGroup();
     $linkedgroups = $grpHasGrpModel->getGroupGroups($grpId);
     $linkedgroups = array_merge($linkedgroups['parents'], $linkedgroups['childs']);
     $comments = new Oibs_Controller_Plugin_Comments("group", $grpId);
     if ($this->view->identity) {
         $comments->allowComments(true);
     }
     $this->view->jsmetabox->append('commentUrls', $comments->getUrls());
     $comments->loadComments();
     $this->view->comments = $comments;
     $this->view->hasFeeds = Oibs_Controller_Plugin_RssReader::hasFeeds($grpId, "group");
     // Add data to the view.
     $this->view->grpId = $grpId;
     $this->view->grpData = $grpData;
     $this->view->grpUsers = $usrHasGrpModel->getAllUsersInGroup($grpId);
     $this->view->grpAdmins = $grpAdmins;
     $this->view->userHasGroup = $usrHasGrpModel;
     $this->view->userHasGroupWaiting = $usrHasGrpWaitingModel;
     //$this->view->campaigns = $campaignModel->getCampaignsByGroup($grpId);
     $this->view->openCampaigns = $campaignModel->getOpenCampaignsByGroup($grpId);
     $this->view->notstartedCampaigns = $campaignModel->getNotstartedCampaignsByGroup($grpId);
     $this->view->endedCampaigns = $campaignModel->getEndedCampaignsByGroup($grpId);
     $this->view->userIsGroupAdmin = isset($user->user_id) ? $this->checkIfArrayHasKeyWithValue($grpAdmins, 'id_usr', $user->user_id) : false;
     $this->view->linkedgroups = $linkedgroups;
     $this->view->isClosed = $isClosed;
     $this->view->usrWaitingCount = $usrWaitingCount;
 }
示例#11
0
 /**
  * linkAction
  *
  * Link content to campaign.
  */
 public function linkAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $usrId = $auth->getIdentity()->user_id;
         $cmpId = $this->_request->getParam('cmpid');
         if (!isset($cmpId)) {
             $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
             $this->_redirector->gotoUrl($redirectUrl);
         }
         $this->view->cmpid = $cmpId;
         $cmpmodel = new Default_Model_Campaigns();
         $cmp = $cmpmodel->getCampaignById($cmpId);
         $usrmodel = new Default_Model_User();
         $usrcnt = $usrmodel->getUserContent($usrId);
         if (!empty($usrcnt)) {
             $cmpcnt = $cmpmodel->getAllContentsInCampaign($cmpId);
             $cnt = array();
             foreach ($usrcnt as $usercontent) {
                 if (!$this->checkIfArrayHasKeyWithValue($cmpcnt, 'id_cnt', $usercontent['id_cnt'])) {
                     $cnt[] = $usercontent;
                 }
             }
             $hasUserContents = true;
         } else {
             $hasUserContents = false;
         }
         $this->view->cmp = $cmp;
         $this->view->usrcnt = $cnt;
         $this->view->hasUserContents = $hasUserContents;
     } else {
         // If not logged, redirecting to system message page
         $message = 'campaign-link-not-logged';
         $url = $this->_urlHelper->url(array('controller' => 'msg', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->flash($message, $url);
     }
 }
示例#12
0
文件: Groups.php 项目: jannev/site
 /**
  *   removeGroup
  *   Removes the group from the database
  *
  *   @param int id_grp
  *   @author Mikko Aatola
  */
 public function removeGroup($id_grp = 0)
 {
     if (!$id_grp) {
         return false;
     }
     // Delete the group's campaigns.
     $data = $this->_db->select()->from('campaigns_cmp', 'id_cmp')->where('id_grp_cmp = ?', $id_grp);
     $campaigns = $this->_db->fetchAll($data);
     $cmpModel = new Default_Model_Campaigns();
     foreach ($campaigns as $cmp) {
         $cmpModel->removeCampaign($cmp['id_cmp']);
     }
     // Delete group weblinks
     $grpWeblinksModel = new Default_Model_GroupWeblinks();
     $grpWeblinksModel->removeGroupWeblinks($id_grp);
     // Delete group-admin links from grp_has_admin_usr.
     $grpAdm = new Default_Model_GroupAdmins();
     $grpAdm->removeAdminsFromGroup($id_grp);
     // Delete groups files
     $filesModel = new Default_Model_Files();
     $filesModel->removeFiles($id_grp, "group");
     // Delete group.
     $where = $this->getAdapter()->quoteInto('id_grp = ?', $id_grp);
     $this->delete($where);
 }
示例#13
0
 /**
  *
  *
  */
 public function checkExistingCampaigns($contentId = -1, array $campaigns = array())
 {
     $result = null;
     if ($contentId != -1 && !empty($campaigns)) {
         // Go through all existing campaigns
         $existingCmps = $this->getContentCampaigns($contentId);
         foreach ($existingCmps as $id => $campaign) {
             // If some of the existing campaigns aren't found in sent campaigns,
             // that campaign is deleted the from content and maybe even from the
             // database
             if (!in_array($campaign['name_cmp'], $campaigns)) {
                 // Removing campaign from content
                 $this->deleteCampaignFromContent($existingCmp['id_cmp'], $contentId);
                 // If other content(s) doesn't have this campaign, the whole
                 // campaign is going to be removed from the database
                 if (!$this->checkIfOtherContentHasCampaign($existingCmp['id_cmp'], $contentId)) {
                     $modelCmps = new Default_Model_Campaigns();
                     $modelCmps->removeCampaign($existingCmp['id_cmp']);
                 }
                 // Remove campaign from existingCmps array
                 unset($existingCmps[$id]);
             }
         }
         $result = $existingCmps;
     }
     return $result;
 }
示例#14
0
 /**
  * removecampaignlinkAction - Remove campaign link
  */
 public function removecampaignlinkAction()
 {
     // Get authentication
     $auth = Zend_Auth::getInstance();
     // If user has identity
     if ($auth->hasIdentity()) {
         $parentCmpId = $this->_request->getParam('parentcmpid');
         $this->view->parentcmpid = $parentCmpId;
         $childCmpId = $this->_request->getParam('childcmpid');
         $this->view->childcmpid = $childCmpId;
         if (!(isset($parentCmpId) && isset($childCmpId))) {
             $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
             $this->_redirector->gotoUrl($redirectUrl);
         }
         $cmpModel = new Default_Model_Campaigns();
         $cmp = $cmpModel->getCampaignById($parentCmpId);
         $grpId = $cmp['id_grp_cmp'];
         $usrId = $auth->getIdentity()->user_id;
         $grpadminmodel = new Default_Model_GroupAdmins();
         if (!$grpadminmodel->userIsAdmin($grpId, $usrId)) {
             $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
             $this->_redirector->gotoUrl($redirectUrl);
         }
         $cmphascmpmodel = new Default_Model_CampaignHasCampaign();
         $cmphascmpmodel->removeCampaignFromCampaign($parentCmpId, $childCmpId);
         $cmphascmpmodel->removeCampaignFromCampaign($childCmpId, $parentCmpId);
         // TODO:
         // Tell the user that the unlink was created.
         // Redirect back to the current campaign's page.
         $target = $this->_urlHelper->url(array('cmpid' => $parentCmpId, 'language' => $this->view->language), 'campaign_view', true);
         $this->_redirector->gotoUrl($target);
     } else {
         // If not logged, redirecting to system message page
         $message = 'content-link-not-logged';
         $url = $this->_urlHelper->url(array('controller' => 'msg', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->flash($message, $url);
     }
 }