/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $users = Users::get();
     $comments = Comments::get();
     $supports = Supports::get();
     $notes = Notes::get();
     $usersJson = array();
     $commentsJson = array();
     $supportsJson = array();
     $notesJson = array();
     // build users
     foreach ($users as $user) {
         array_push($usersJson, array('id' => $user->id, 'name' => $user->name));
     }
     // build comments
     foreach ($comments as $comment) {
         array_push($commentsJson, array('id' => $comment->id, 'article_id' => $comment->article_id, 'user_id' => $comment->user_id, 'comment' => $comment->comment, 'challenge' => $comment->challenge));
     }
     // build supports
     foreach ($supports as $support) {
         array_push($supportsJson, array('id' => $support->id, 'user_id' => $support->user_id, 'comment_id' => $support->comment_id));
     }
     // build notes
     foreach ($notes as $note) {
         array_push($notesJson, array('id' => $note->id, 'comment_id' => $note->comment_id, 'comment' => $note->comment));
     }
     // build json
     $json = array('users' => $usersJson, 'comments' => $commentsJson, 'supports' => $supportsJson, 'notes' => $notesJson);
     // display json
     echo json_encode($json);
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Supports::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function topicsmapAction()
 {
     if (Supports::isProductionInstance()) {
         $this->_helper->viewRenderer->setNoRender();
         header("Status: 404 Not Found");
         return;
     }
     $error = "";
     if (isset($_GET["xml"]) || $_SERVER['REQUEST_METHOD'] === 'POST') {
         //elixir.discipline_topics_to_xml
         $this->_helper->viewRenderer->setNoRender();
         if ($_SERVER['REQUEST_METHOD'] === 'POST') {
             if (!(isset($_POST["discipline_id"]) || is_numeric($_POST["discipline_id"]))) {
                 $error = "Invalid discipline id";
             } elseif (!(isset($_POST["topic_id"]) || is_numeric($_POST["topic_id"]))) {
                 $error = "Invalid topic id";
             } elseif (!(isset($_POST["topic_uri"]) || trim($_POST["topic_uri"]) === "")) {
                 $error = "Invalid topic uri";
             } elseif (!(isset($_POST["topic_label"]) || trim($_POST["topic_label"]) === "")) {
                 $error = "Invalid topic label";
             } elseif (!(isset($_POST["action"]) || trim($_POST["topic_label"]) !== "add" && trim($_POST["topic_label"]) !== "remove")) {
                 $error = "Invalid action";
             } else {
                 try {
                     if ($_POST["action"] == "add" && $this->mappingexists($_POST["topic_uri"], $_POST["discipline_id"]) === false) {
                         db()->query("INSERT INTO elixir.discipline_topics VALUES(?,?,?,?)", array($_POST["topic_id"], $_POST["topic_uri"], $_POST["topic_label"], $_POST["discipline_id"]))->fetchAll();
                     } else {
                         if ($_POST["action"] == "remove" && $this->mappingexists($_POST["topic_uri"], $_POST["discipline_id"]) === true) {
                             db()->query("delete from elixir.discipline_topics where topic_uri=? and discipline_id=?", array($_POST["topic_uri"], $_POST["discipline_id"]))->fetchAll();
                         }
                     }
                 } catch (Exception $ex) {
                     $error = $ex->getMessage();
                 }
             }
         }
         $rows = db()->query("SELECT elixir.discipline_topics_to_xml() AS f;")->fetchall();
         header('Content-type: text/xml');
         $res = "<mappings count='" . count($rows) . "'";
         if (trim($error) !== "") {
             $res .= " error='" . $error . "' ";
         }
         $res .= ">";
         foreach ($rows as $r) {
             $res .= $r["f"];
         }
         $res .= "</mappings>";
         echo $res;
         return;
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::except(array('_token'));
     $rule = array('user_id' => 'required|exists:users,id', 'comment_id' => 'required|exists:comments,id');
     $validator = Validator::make($data, $rule);
     if ($validator->fails()) {
         /*return Redirect::to('comments')
           ->withErrors($validator->messages());*/
         return 'false';
     } else {
         Update::saveFormData(array("time" => time()));
         Supports::saveFormData(Input::except(array('_token')));
         /*return Redirect::to('comments')
           ->withMessage('success');*/
         return 'true';
     }
 }
Beispiel #5
0
 public function run()
 {
     //News
     $criNew = new CDBCriteria();
     $criNew->addCondition("category_news_id = 5");
     $criNew->order = "id DESC";
     $criNew->limit = 5;
     $arrNews = News::model()->findAll($criNew);
     //Support
     $criSupport = new CDbCriteria();
     $criSupport->order = "id DESC";
     $arrSupport = Supports::model()->findAll($criSupport);
     /*Ads Right*/
     $criAds = new CDbCriteria();
     $criAds->addCondition("album_id = 1");
     $criAds->order = "id DESC";
     $arrAds = Images::model()->findAll($criAds);
     /*Pictures*/
     $criPic = new CDbCriteria();
     $criPic->addCondition("album_id = 2");
     $criPic->order = "id DESC";
     $arrPic = Images::model()->findAll($criPic);
     $this->render("widgetRight", array('dataSystem' => $this->dataSystem, 'arrNews' => $arrNews, 'arrSupport' => $arrSupport, 'arrAds' => $arrAds, 'arrPic' => $arrPic));
 }
Beispiel #6
0
 /**
  * 
  * @param Default_Model_Researcher|integer $sourceUser The user to check the edit access group permissions of another user.
  * @param Default_Model_Researcher|integer $targetUser The user whose access groups will be edited.
  * @param {requestid,groupid}[] $userquests An array with submitted $targetUser access group requests.
  * @return {id, name, canAdd, canRemove, canRequest, canAcceptReject, hasRequest}[] An array of the $sourceUser permissions to edit the access groups of $targetUser.
  */
 public static function getAccessGroupsPermissions($sourceUser, $targetUser, $userrequests = array())
 {
     /* Return array with the groups the target is able to have. Filled with the permissions of the source or target for these groups.
      * id: access group id
      * name: access group name
      * canAdd: source can add target to this access group
      * canRemove: source can remove target from this access group
      * canAcceptReject: accept or reject targets requests from $sourceUser to be included in this group
      * canRequest: target can request to be included in this access group
      * hasRequest: target user's access group request id if any.the user access group request id if any made by the target user. By default false. 
      */
     $result = array();
     if ($sourceUser === null || $targetUser === null) {
         return array();
     }
     $sourceUser = self::getUser($sourceUser);
     $targetUser = self::getUser($targetUser);
     $sameuser = false;
     if ($sourceUser->id === $targetUser->id) {
         $sameuser = true;
     }
     if (self::inAllAccessGroups($sourceUser, array("-1")) === true) {
         //Administator can do anything except requesting for access group(no reason to do so)
         //$sourceIsAdmin = self::inAllAccessGroups($sourceUser,array("-1"));
         $result = array(array("id" => "-1", "name" => "AppDB Administrator", "canAdd" => true, "canRemove" => $sameuser ? true : false, "canRequest" => false, "canAcceptReject" => true, "hasRequest" => false), array("id" => "-2", "name" => "Managers", "canAdd" => true, "canRemove" => true, "canRequest" => false, "canAcceptReject" => true, "hasRequest" => false), array("id" => "-3", "name" => "National Representatives", "canAdd" => true, "canRemove" => true, "canRequest" => false, "canAcceptReject" => true, "hasRequest" => false));
         if (Supports::datasets()) {
             $result[] = array("id" => "-19", "name" => "Dataset Managers", "canAdd" => true, "canRemove" => true, "canRequest" => false, "canAcceptReject" => true, "hasRequest" => false);
         }
     } else {
         if (self::inAllAccessGroups($sourceUser, array("-2")) === true) {
             //Manager can do anything except removing an other manager
             $result = array(array("id" => "-2", "name" => "Managers", "canAdd" => true, "canRemove" => $sameuser ? true : false, "canRequest" => false, "canAcceptReject" => true, "hasRequest" => false), array("id" => "-3", "name" => "National Representatives", "canAdd" => true, "canRemove" => true, "canRequest" => false, "canAcceptReject" => true, "hasRequest" => false));
             if (Supports::datasets()) {
                 //Managers can edit datasets by default
                 $result[] = array("id" => "-19", "name" => "Dataset Managers", "canAdd" => true, "canRemove" => true, "canRequest" => false, "canAcceptReject" => true, "hasRequest" => false);
             }
         } else {
             if (self::inAllAccessGroups($sourceUser, array("-3")) === true) {
                 //NILS can add other NILS, remove their self or request to become managers
                 $sourceCountry = $sourceUser->countryid;
                 $targetCountry = $targetUser->countryid;
                 $samecountry = trim($targetCountry) === trim($sourceCountry) ? true : false;
                 $result = array(array("id" => "-2", "name" => "Managers", "canAdd" => false, "canRemove" => false, "canRequest" => $sameuser ? true : false, "canAcceptReject" => false, "hasRequest" => false), array("id" => "-3", "name" => "National Representatives", "canAdd" => $samecountry ? true : false, "canRemove" => $sameuser ? true : false, "canRequest" => false, "canAcceptReject" => $samecountry ? true : false, "hasRequest" => false));
                 if (Supports::datasets()) {
                     //A NIL can request to be added to group of dataset managers
                     $result[] = array("id" => "-19", "name" => "Dataset Managers", "canAdd" => false, "canRemove" => false, "canRequest" => $sameuser ? true : false, "canAcceptReject" => false, "hasRequest" => false);
                 }
             } else {
                 //All other users can only request to become managers or NILs
                 $result = array(array("id" => "-2", "name" => "Managers", "canAdd" => false, "canRemove" => false, "canRequest" => $sameuser ? true : false, "canAcceptReject" => false, "hasRequest" => false), array("id" => "-3", "name" => "National Representatives", "canAdd" => false, "canRemove" => false, "canRequest" => $sameuser ? true : false, "canAcceptReject" => false, "hasRequest" => false));
                 if (Supports::datasets()) {
                     //Anyone can request to be added to group of dataset managers
                     $result[] = array("id" => "-19", "name" => "Dataset Managers", "canAdd" => false, "canRemove" => false, "canRequest" => $sameuser ? true : false, "canAcceptReject" => false, "hasRequest" => false);
                 }
             }
         }
     }
     //Check if user requests are given
     if (is_null($userrequests) || count($userrequests) === 0) {
         $userrequests = self::getAccessGroupRequests($targetUser);
     }
     //Fill results with user access groups requests
     foreach ($userrequests as $ur) {
         for ($i = 0; $i < count($result); $i += 1) {
             if ($result[$i]["id"] === trim($ur["groupid"])) {
                 $result[$i]["hasRequest"] = $ur["requestid"];
                 break;
             }
         }
     }
     return $result;
 }
Beispiel #7
0
		"vappliance.permissions.manageversions" : "main:guides:general:permissions_guide#manage_virtual_appliance_versions",
		"vappliance.permissions.fullcontrol": "main:guides:general:permissions_guide#full_control",
		"swappliance.permissions.editmetadata" : "main:guides:general:permissions_guide#edit_information_publications",
		"swappliance.permissions.accessversions" : "main:guides:general:permissions_guide#access_private_data",
		"swappliance.permissions.managecontextscripts" : "main:guides:general:permissions_guide#manage_context_scripts",
		"swappliance.permissions.fullcontrol": "main:guides:general:permissions_guide#full_control",
	},
	features:{
	"logistics": true,
	"groupvaprovidertemplates": true,
	"swappliance": <?php 
echo Supports::swappliance() ? "true" : "false";
?>
,
	"singleVMIPolicy": <?php 
echo Supports::singleVMIPolicy() ? "true" : "false";
?>
,
	"email": <?php 
echo ApplicationConfiguration::email('enable', false) ? "true" : "false";
?>
	}
};
if( <?php 
echo $hasRepository;
?>
 ){
	appdb.config.repository = { };
	appdb.config.repository.endpoint = {};
	appdb.config.repository.endpoint.base = "<?php 
echo ApplicationConfiguration::url('/repository/');
Beispiel #8
0
 public function run()
 {
     parent::run();
     $data['data'] = Supports::model()->findAll(array("condition" => "state = 1", "order" => "'order' desc"));
     $this->render('support', $data);
 }
Beispiel #9
0
 public function clearAction()
 {
     $supports = new Supports();
     $supports->clear();
 }
Beispiel #10
0
 public function parseVAppImage($xml, $parent = null)
 {
     $m = $this->getItem("vmi", $xml);
     if (count($xml->xpath('./virtualization:notes')) > 0) {
         $m->notes = $xml->xpath('./virtualization:notes');
         $m->notes = (string) $m->notes[0];
         $m->notes = strip_tags($m->notes);
         if ($this->validateNotes($m->notes, "vmi") === false) {
             return $this->_setErrorMessage("Invalid notes value for VMI.");
         }
     }
     if (count($xml->xpath('./virtualization:description')) > 0) {
         $m->description = $xml->xpath('./virtualization:description');
         $m->description = (string) $m->description[0];
         $m->description = strip_tags($m->description);
         if ($this->validateDescription($m->description) === false) {
             return $this->_setErrorMessage("Invalid description value for virtual appliance version.");
         }
     } else {
         $m->description = "";
     }
     if (count($xml->xpath('./virtualization:group')) > 0) {
         $m->groupname = $xml->xpath('./virtualization:group');
         $m->groupname = (string) $m->groupname[0];
         $m->groupname = strip_tags($m->groupname);
         if ($this->validateGroupname($m->groupname) === false) {
             return $this->_setErrorMessage("Invalid group value for VMI.");
         }
         if ($this->isexternalrequest === false) {
             $isunique = $this->isGroupNameUnique($m, $parent);
             if ($isunique === false) {
                 return $this->_setErrorMessage("VMI Group values are used by other VMI groups in this version.");
             }
         }
     }
     //In case of a new vmi instance check if the user has given an identifier
     if (!$m->guid) {
         if (count($xml->xpath('./virtualization:identifier')) > 0) {
             $guid = $xml->xpath('./virtualization:identifier');
             $guid = (string) $guid[0];
             $guid = trim($guid);
             if (strlen($guid) > 0) {
                 $m->guid = $guid;
             }
         }
         //check if user-defined identifier is in use from other entities(images, other application's vappliance versions etc
         if ($m->guid) {
             //check if user-defined identifier is in use from other entities(images, other application's vappliance versions etc
             $vaversions = new Default_Model_VAversions();
             $vaversions->filter->guid->equals($m->guid);
             if (count($vaversions) > 0) {
                 $vaversion = $vaversions->items[0];
                 $va = $vaversion->getVa();
                 if ($va) {
                     $app = $va->getApplication();
                     if ($app) {
                         return $this->_setErrorMessage("Image identifier " . $m->guid . " is already used by " . $app->name . " virtual appliance.");
                     }
                 }
                 return $this->_setErrorMessage("Image identifier " . $m->guid . " is already used by another virtual appliance version.");
             }
             $vmis = new Default_Model_Vmis();
             $vmis->filter->guid->equals($m->guid);
             if (count($vmis->items) > 0) {
                 return $this->_setErrorMessage("Image identifier " . $m->guid . " is already used by another virtual appliance image group.");
             }
             $vminstances = new Default_Model_VMIinstances();
             $vminstances->filter->guid->equals($m->guid);
             if (count($vminstances->items) > 0) {
                 return $this->_setErrorMessage("Image identifier " . $m->guid . " is already used by another virtual appliance image.");
             }
             //Check if identifier is used inside a VO wide image list
             $voexists = self::VOGuidExists($m->guid);
             if ($voexists === true) {
                 return $this->_setErrorMessage("Image identifier " . $m->guid . " is already used in a virtual organization image list.");
             } else {
                 if (is_string($voexists)) {
                     return $this->_setErrorMessage("Image identifier " . $m->guid . " is already used by " . $voexists . " virtual organization image list.");
                 }
             }
         }
     }
     if (count($xml->xpath('./virtualization:description')) > 0) {
         $m->description = $xml->xpath('./virtualization:description');
         $m->description = (string) $m->description[0];
         $m->description = strip_tags($m->description);
         if ($this->validateDescription($m->description) === false) {
             return $this->_setErrorMessage("Invalid description value for VMI.");
         }
     }
     $m->vappid = $parent->vappid;
     $m->name = $this->appname;
     $m->save();
     //Retrieve current VMI Instances ids.
     $oldvmiinstanceids = $m->getWMIInstanceIds();
     //Get VMIInstances of VMI
     $xinstances = $xml->xpath("./virtualization:instance");
     $vmiinstances = array();
     if (count($xinstances) > 0) {
         for ($i = 0; $i < count($xinstances); $i += 1) {
             $v = $this->parseVAppImageInstance($xinstances[$i], $m);
             if ($v === false) {
                 return false;
             }
             $vmiinstances[] = $v;
         }
     }
     if (Supports::singleVMIPolicy() && count($vmiinstances) > 1) {
         return $this->_setErrorMessage("Only one VMI image per version is allowed");
     }
     /* Delete old undefined vmi instances */
     for ($i = 0; $i < count($vmiinstances); $i += 1) {
         $item = $vmiinstances[$i];
         $index = -1;
         //find in old values
         for ($j = 0; $j < count($oldvmiinstanceids); $j += 1) {
             if ($item->id == $oldvmiinstanceids[$j]) {
                 $index = $j;
                 break;
             }
         }
         //Remove current vmi instance item from old values array
         if ($index > -1) {
             unset($oldvmiinstanceids[$index]);
             $oldvmiinstanceids = array_values($oldvmiinstanceids);
         }
     }
     /*Remove old vmi instances that are no longer defined in the request xml */
     $oldvmiinstances = new Default_Model_VMIinstances();
     $oldvmiinstances->filter->id->in($oldvmiinstanceids);
     if (count($oldvmiinstances->items) > 0) {
         for ($i = 0; $i < count($oldvmiinstances->items); $i += 1) {
             $item = $oldvmiinstances->items[$i];
             $this->deleteContextScriptRelation($item->id);
             $item->delete();
         }
     }
     //Check if remaining vmiinstances have duplicate urls
     for ($i = 0; $i < count($vmiinstances); $i += 1) {
         $vminst = $vmiinstances[$i];
         //do not check url in deleted vmi instances
         if (in_array($vminst->id, $oldvmiinstanceids)) {
             continue;
         }
         $urlexists = $this->VMIInstanceUrlExists($vminst, $m);
         if ($urlexists === true) {
             return $this->_setErrorMessage("Duplicate url values in the same VMI group");
         }
     }
     /*Associate VMIInstances with current VAVersion*/
     $this->setupVAppList($parent, $vmiinstances);
     return $m;
 }