Commit ed9a54ca authored by Nicolas Nambinintsoa's avatar Nicolas Nambinintsoa
Browse files

Merge remote-tracking branch 'origin/master'

parents ca089788 657d399d
<?php
class DeleteAction extends CAction {
public function run($id) {
$controller=$this->getController();
$res = Cms::deleteCms($id);
return $res;
}
}
\ No newline at end of file
......@@ -5,25 +5,7 @@ class DeleteAction extends CAction {
public function run($type, $id) {
$controller=$this->getController();
$reason = @$_POST["reason"];
if($type == Cms::COLLECTION){
$cms = Element::getElementById($id,Cms::COLLECTION);
$parentId = null;
$parentType = null;
if( isset($cms["type"]) && $cms["type"] != "blockCms" ){
$parentId = array_keys($cms["parent"])[0];
$parentType = $cms["parent"][$parentId]["type"];
}
if(isset($cms["type"]) && $cms["type"]=="blockCms" && !Authorisation::isUserSuperAdmin(Yii::app()->session["userId"])){
return Rest::json(array("result"=> false, "error"=>"403", "msg" => "Forbidden : Only allowed for the super administrator"));
}else if(isset($cms["type"]) && $cms["type"]!="blockCms" && !Authorisation::canDeleteElement($parentId,$parentType,Yii::app()->session["userId"]))
return Rest::json(array("result"=> false, "error"=>"403", "msg" => "Forbidden : Only allowed for the administrator"));
PHDB::remove($type, array("_id"=>new MongoId($id)));
return Rest::json(array("result" => true, "msg" => "The element has been deleted succesfully"));
}
if ( ! Authorisation::canDeleteElement($id, $type, Yii::app()->session["userId"])) {
Rest::json( array( "result" => false, "msg" => "You are not allowed to delete this element !" ));
return;
......
......@@ -212,6 +212,24 @@ class Cms {
return $cms;
}
public static function deleteCms($id){
$cms = Element::getElementById($id,self::COLLECTION);
$parentId = null;
$parentType = null;
if( isset($cms["type"]) && $cms["type"] != "blockCms" ){
$parentId = array_keys($cms["parent"])[0];
$parentType = $cms["parent"][$parentId]["type"];
}
if(isset($cms["type"]) && $cms["type"]=="blockCms" && !Authorisation::isUserSuperAdmin(Yii::app()->session["userId"])){
return Rest::json(array("result"=> false, "error"=>"403", "msg" => "Forbidden : Only allowed for the super administrator"));
}else if(isset($cms["type"]) && $cms["type"]!="blockCms" && !Authorisation::canDeleteElement($parentId,$parentType,Yii::app()->session["userId"]))
return Rest::json(array("result"=> false, "error"=>"403", "msg" => "Forbidden : Only allowed for the administrator"));
PHDB::remove(self::COLLECTION, array("_id"=>new MongoId($id)));
return Rest::json(array("result" => true, "msg" => "The element has been deleted succesfully"));
}
public static function delete($id, $userId) {
if ( !@$userId) {
return array( "result" => false, "msg" => "You must be loggued to delete something" );
......@@ -244,6 +262,8 @@ class Cms {
}
}
public static function getDataBinding() {
return self::$dataBinding;
}
......
......@@ -1593,24 +1593,29 @@ class Mail {
if (empty($params["tplMail"]) && isset($costum["admin"]["email"])){
$params["tplMail"] = $costum["admin"]["email"];
}
if(!empty($params["tplMail"])) {
$fromMail=(isset($params["fromMail"]) && !empty($params["fromMail"])) ? $params["fromMail"] : null;
$res = array (
"type" => Cron::TYPE_MAIL,
"tpl"=>$params["tpl"],
"logo"=>$params["logo"],
"subject" => $params["tplObject"],
"from"=>Yii::app()->params['adminEmail'],
"to" => $params["tplMail"],
"tplParams" => self::initTplParams($params)
);
$res=self::getCustomMail($res, $fromMail);
if (@$params["logo"][0] == "banner") {
$res["tplParams"]["logo"] = $costum["banner"];
$res["tplParams"]["signature"] = $params["signature"];
foreach ($params["tplMail"] as $v){
$params["tplMail"] = $v;
$fromMail=(isset($params["fromMail"]) && !empty($params["fromMail"])) ? $params["fromMail"] : null;
$res = array (
"type" => Cron::TYPE_MAIL,
"tpl"=>$params["tpl"],
"logo"=>$params["logo"],
"subject" => $params["tplObject"],
"from"=>Yii::app()->params['adminEmail'],
"to" => $params["tplMail"],
"tplParams" => self::initTplParams($params)
);
$res=self::getCustomMail($res, $fromMail);
if (@$params["logo"] === "banner") {
$res["tplParams"]["logo"] = $costum["banner"];
$res["tplParams"]["sign"] = $params["sign"];
}
Mail::schedule($res);
}
Mail::schedule($res);
} else {
throw new CTKException(Yii::t("common","Missing email!"));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment