Exemple #1
0
 public static function add($name, $description = "", $grantAdmin = true)
 {
     $sectionManager = new Section();
     if ($sectionManager->rowCount(array('label' => $name)) == 0) {
         $sectionManager->setLabel($name);
         $sectionManager->setDescription($description);
         $sectionManager->save();
         if ($grantAdmin) {
             $right = new Right();
             $right = $right->load(array('section' => $sectionManager->getLabel(), 'rank' => 1));
             $right = !$right ? new Right() : $right;
             $right->setSection($sectionManager->getId());
             $right->setCreate(1);
             $right->setRead(1);
             $right->setUpdate(1);
             $right->setDelete(1);
             $right->setRank(1);
             $right->save();
         }
     }
 }
Exemple #2
0
	camp_html_add_msg(getGS('You must fill in the $1 field.','"'.getGS('Name').'"'));
}
if ($cShortName == "")  {
	camp_html_add_msg(getGS('You must fill in the $1 field.','"'.getGS('URL Name').'"'));
}
$isValidShortName = camp_is_valid_url_name($cShortName);

if (!$isValidShortName) {
	camp_html_add_msg(getGS('The $1 field may only contain letters, digits and underscore (_) character.', '"' . getGS('URL Name') . '"'));
}

$editUrl = "/$ADMIN/sections/edit.php?Pub=$Pub&Issue=$Issue&Language=$Language&Section=$Section";
if (!camp_html_has_msgs()) {
	$modified = true;
	$modified &= $sectionObj->setName($cName);
	$modified &= $sectionObj->setDescription($cDescription);
	$modified &= $sectionObj->setSectionTemplateId($cSectionTplId);
	$modified &= $sectionObj->setArticleTemplateId($cArticleTplId);

	if ($cSubs == "a") {
	$numSubscriptionsAdded = Subscription::AddSectionToAllSubscriptions($Pub, $Section);
		if ($numSubscriptionsAdded < 0) {
			$errors[] = getGS('Error updating subscriptions.');
		}
	}
	if ($cSubs == "d") {
		$numSubscriptionsDeleted = Subscription::DeleteSubscriptionsInSection($Pub, $Section);
		if ($numSubscriptionsDeleted < 0) {
			$errors[] = getGS('Error updating subscriptions.');
		}
	}
Exemple #3
0
 function showEditSectionRes()
 {
     $displaySysAdmin = new DisplaySysAdmin();
     $survey = new Survey($_SESSION['SUID']);
     $seid = getFromSessionParams('seid');
     $content = "";
     if ($seid != '') {
         //edit
         $section = $survey->getSection($seid);
         $_SESSION['SEID'] = $seid;
         $content = $displaySysAdmin->displaySuccess(Language::messageSectionChanged(loadvar(SETTING_NAME)));
     } else {
         //add section!
         if (loadvar(SETTING_NAME) != "") {
             $section = new Section();
             $section->setSuid($_SESSION['SUID']);
             $content = $displaySysAdmin->displaySuccess(Language::messageSectionAdded(loadvar(SETTING_NAME)));
         }
     }
     $checker = new Checker($_SESSION['SUID']);
     if ($seid == '') {
         $checks = $checker->checkName(loadvar(SETTING_NAME));
         if (sizeof($checks) > 0) {
             $content = implode("<br/>", $checks);
             return $this->showAddSection($content);
         }
     }
     //ADD ALL SORTS OF CHECKS!!
     if ($seid != '' || loadvar(SETTING_NAME) != "") {
         $section->setName(trim(loadvar(SETTING_NAME)));
         $section->setDescription(loadvar(SETTING_DESCRIPTION));
         $section->setHidden(loadvar(SETTING_HIDDEN));
         $section->setHeader(loadvarAllowHTML(SETTING_SECTION_HEADER));
         $section->setFooter(loadvarAllowHTML(SETTING_SECTION_FOOTER));
         $section->save();
         $checks = $checker->checkSection($section);
         if (sizeof($checks) > 0) {
             $content .= $displaySysAdmin->displayError(implode("<br/>", $checks));
         }
     }
     /* compile */
     $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey));
     $mess = $compiler->generateSections(array($section));
     $mess = $compiler->generateGetFillsSections(array($section));
     $mess = $compiler->generateInlineFieldsSections(array($section));
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     if ($seid != '') {
         return $displaySysAdmin->showEditSection($_SESSION['SEID'], $content);
     } else {
         return $displaySysAdmin->showSurvey($content);
     }
 }