Пример #1
0
function buildEntryBlock($entry, $uniqueVoters, $alltags)
{
    $logguedAndValid = Person::logguedAndValid();
    $tagBlock = "";
    $cpBlock = "";
    $name = $entry["name"];
    $email = isset($entry["email"]) ? $entry["email"] : "";
    $cpList = isset($entry["cp"]) ? $entry["cp"] : "";
    if (!isset($_GET["cp"]) && $entry["type"] == Survey::TYPE_SURVEY) {
        if (isset($entry["cp"])) {
            if (is_array($entry["cp"])) {
                $cpList = "";
                foreach ($entry["cp"] as $cp) {
                    if (!in_array($cp, $cps)) {
                        $cpBlock .= ' <button class="filter " data-filter=".' . $cp . '">' . $cp . '</button>';
                        array_push($cps, $cp);
                    }
                    $cpList .= $cp . " ";
                }
            } else {
                if (!in_array($entry["cp"], $cps)) {
                    $cpBlock .= ' <button class="filter " data-filter=".' . $entry["cp"] . '">' . $entry["cp"] . '</button>';
                    array_push($cps, $entry["cp"]);
                }
            }
        }
    }
    $tags = "";
    if (isset($entry["tags"])) {
        foreach ($entry["tags"] as $t) {
            if (!empty($t) && !in_array($t, $alltags)) {
                array_push($alltags, $t);
                $tagBlock .= ' <button class="filter " data-filter=".' . $t . '">' . $t . '</button>';
            }
            $tags .= $t . ' ';
        }
    }
    $count = PHDB::count(Survey::COLLECTION, array("type" => Survey::TYPE_ENTRY, "survey" => (string) $entry["_id"]));
    $link = $name;
    /* **************************************
       //check if I wrote this law
       *************************************** */
    $meslois = $logguedAndValid && Yii::app()->session["userEmail"] && $entry['email'] == Yii::app()->session["userEmail"] ? "myentries" : "";
    //checks if the user is a follower of the entry
    $followingEntry = $logguedAndValid && Action::isUserFollowing($entry, Action::ACTION_FOLLOW) ? "myentries" : "";
    //title + Link
    if ($entry["type"] == Survey::TYPE_SURVEY) {
        $link = '<a class="titleMix ' . $meslois . '" href="' . Yii::app()->createUrl("/" . Yii::app()->controller->module->id . "/survey/entries/id/" . (string) $entry["_id"]) . '">' . $name . ' (' . $count . ')</a>';
    } else {
        if ($entry["type"] == "entry") {
            $link = '<a class="titleMix ' . $meslois . '" onclick="entryDetail(\'' . Yii::app()->createUrl("/" . Yii::app()->controller->module->id . "/survey/entry/id/" . (string) $entry["_id"]) . '\')" href="javascript:;">' . $name . '</a>';
        }
    }
    //$infoslink bring visual detail about the entry
    $infoslink = "";
    $infoslink .= !empty($followingEntry) ? "<a class='btn voteAbstain filter' data-filter='.myentries' ><i class='fa fa-rss infolink' ></i></a>" : "";
    $infoslink .= !empty($meslois) ? ' <a class="btn btn-xs filter" data-filter=".myentries" onclick="entryDetail(\'' . Yii::app()->createUrl("/" . Yii::app()->controller->module->id . "/survey/entry/id/" . (string) $entry["_id"]) . '\',\'edit\')" href="javascript:;"><i class="fa fa-user infolink"></i> Edit</a> ' : '';
    if (Yii::app()->session["userIsAdmin"]) {
        $linkStandalone = Yii::app()->createUrl("/" . Yii::app()->controller->module->id . "/survey/entry/id/" . (string) $entry["_id"]);
        $infoslink .= "<a target='_blank' class='btn voteAbstain' href='" . $linkStandalone . "' title='Open standalone page'><i class='fa fa-magic infolink'></i></a>";
    }
    /* **************************************
       Rendering Each block
       ****************************************/
    $voteLinksAndInfos = Action::voteLinksAndInfos($logguedAndValid, $entry);
    $avoter = $voteLinksAndInfos["avoter"];
    $hrefComment = "#commentsForm";
    $commentCount = 0;
    //$linkComment = ($logguedAndValid && $commentActive) ? "<a class='btn ".$entry["_id"].Action::ACTION_COMMENT."' role='button' data-toggle='modal' href=\"".$hrefComment."\" title='".$commentCount." Commentaire'><i class='fa fa-comments '></i></a>" : "";
    $totalVote = $voteLinksAndInfos["totalVote"];
    $info = $totalVote ? '<span class="info">' . $totalVote . ' sur <span class="info voterTotal">' . $uniqueVoters . '</span> voter(s)</span><br/>' : '<span class="info"></span><br/>';
    $content = $entry["type"] == Survey::TYPE_ENTRY ? "" . $entry["message"] : "";
    $leftLinks = $voteLinksAndInfos["links"];
    $graphLink = $totalVote ? ' <a class="btn voteAbstain" onclick="entryDetail(\'' . Yii::app()->createUrl("/" . Yii::app()->controller->module->id . "/survey/graph/id/" . (string) $entry["_id"]) . '\',\'graph\')" href="javascript:;"><i class="fa fa-th-large"></i> Result</a> ' : '';
    $moderatelink = @$where["type"] == Survey::TYPE_ENTRY && $isModerator && isset($entry["applications"][Yii::app()->controller->module->id]["cleared"]) && $entry["applications"][Yii::app()->controller->module->id]["cleared"] == false ? "<a class='btn golink' href='javascript:moderateEntry(\"" . $entry["_id"] . "\",1)'><i class='fa fa-plus ' ></i></a><a class='btn alertlink' href='javascript:moderateEntry(\"" . $entry["_id"] . "\",0)'><i class='fa fa-minus ' ></i></a>" : "";
    $rightLinks = @$entry["applications"][Yii::app()->controller->module->id]["cleared"] == false ? $moderatelink : $graphLink . $infoslink;
    $rightLinks = $entry["type"] == Survey::TYPE_ENTRY ? "<div class='rightlinks'>" . $rightLinks . "</div>" : "";
    $ordre = $voteLinksAndInfos["ordre"];
    $created = @$entry["created"] ? date("d/m/y h:i", $entry["created"]) : "";
    $views = @$entry["viewCount"] ? ", views : " . $entry["viewCount"] : "";
    $byInfo = "";
    if (isset($entry["parentType"]) && isset($entry["parentId"])) {
        if ($entry["parentType"] == Organization::COLLECTION) {
            $parentCtrler = Organization::CONTROLLER;
            $parentIcon = "group";
        } else {
            if ($entry["parentType"] == Person::COLLECTION) {
                $parentCtrler = Person::CONTROLLER;
                $parentIcon = "user";
            } else {
                if ($entry["parentType"] == City::COLLECTION) {
                    $parentCtrler = City::CONTROLLER;
                    $parentIcon = "university";
                }
            }
        }
        //$parentTitle = '<a href="'.Yii::app()->createUrl("/communecter/".$parentCtrler."/dashboard/id/".$id).'">'.$parent["name"]."</a>'s ";
        $byInfo = "by <a href='" . Yii::app()->createUrl(Yii::app()->controller->module->id . "/" . $parentCtrler . "/dashboard/id/" . $entry["parentId"]) . "'><i class='fa fa-" . $parentIcon . "'></i></a>";
    }
    $contextType = $entry["type"] == Survey::TYPE_ENTRY ? Survey::COLLECTION : Survey::PARENT_COLLECTION;
    $commentBtn = "<a class='btn btn-xs voteAbstain' href='" . Yii::app()->createUrl(Yii::app()->controller->module->id . "/comment/index/type/" . $contextType . "/id/" . $entry["_id"]) . "'>" . @$entry["commentCount"] . " <i class='fa fa-comment'></i> Comment</a>";
    $closeBtn = "";
    $isClosed = "";
    if (Yii::app()->session["userEmail"] == $entry["email"] && (!isset($entry["dateEnd"]) || $entry["dateEnd"] > time()) && $entry["type"] == Survey::TYPE_ENTRY) {
        $closeBtn = "<a class='btn btn-xs btn-danger' href='javascript:;' onclick='closeEntry(\"" . $entry["_id"] . "\")'><i class='fa fa-times'></i> CLOSE</a>";
    } else {
        $isClosed = " closed";
    }
    $cpList = @$where["type"] == Survey::TYPE_SURVEY ? $cpList : "";
    $createdInfo = !empty($created) ? " created : " . $created : "";
    $ends = !empty($entry["dateEnd"]) ? '<div class="space1"></div>' . " end : " . date("d/m/y", $entry["dateEnd"]) : "";
    $boxColor = $entry["type"] == Survey::TYPE_ENTRY ? "boxColor1" : "boxColor2";
    $block = ' <div class="mix ' . $boxColor . ' ' . $avoter . ' ' . $meslois . ' ' . $followingEntry . ' ' . $tags . ' ' . $cpList . $isClosed . '"' . 'data-vote="' . $ordre . '"  data-time="' . $created . '" style="display:inline-blocks"">' . $link . '<br/>' . $info . '<div class="space1"></div><div class="pull-right" >' . $leftLinks . '</div>' . '<div class="space1"></div>' . $createdInfo . $views . $ends . '<div class="space1"></div><div class="pull-left" >' . $graphLink . $infoslink . $commentBtn . $closeBtn . $byInfo . '</div>' . '</div>';
    return array("block" => $block, "alltags" => $alltags, "tagBlock" => $tagBlock, "cpBlock" => $cpBlock);
}
Пример #2
0
 public static function getPeopleBy($params)
 {
     $where = isset($params["where"]) ? $params["where"] : array();
     $fields = isset($params["fields"]) ? $params["fields"] : array();
     if (isset($params["groupid"])) {
         $group = PHDB::findOne(PHType::TYPE_GROUPS, array("_id" => new MongoId($params["groupid"])));
         $where = array(isset(CitoyenType::$types2Nodes[$group["type"]]) ? CitoyenType::$types2Nodes[$group["type"]] : "participants" => (string) $group['_id']);
     }
     if (isset($params["groupname"])) {
         $group = PHDB::findOne(PHType::TYPE_GROUPS, array("name" => $params["groupname"]));
         $where = array(isset(CitoyenType::$types2Nodes[$group["type"]]) ? CitoyenType::$types2Nodes[$group["type"]] : "participants" => (string) $group['_id']);
     }
     if (isset($params["cp"])) {
         $where = array("cp" => $params["cp"]);
     }
     if (isset($params["app"])) {
         $where = array("applications." . $params["app"] . ".usertype" => $params["app"]);
     }
     if (!isset($params["count"])) {
         $res = PHDB::find(self::COLLECTION, $where, $fields);
     } else {
         $res = array('count' => PHDB::count(self::COLLECTION, $where, $fields));
     }
     return $res;
 }
Пример #3
0
									<?php 
        }
        ?>
								</a>
							</td>
							<td ><a href="<?php 
        echo $link;
        ?>
"><?php 
        if (isset($e["name"])) {
            echo $e["name"];
        }
        ?>
</a></td>
							<td><?php 
        echo PHDB::count(Survey::COLLECTION, array('survey' => (string) $e["_id"]));
        ?>
</td>
							<td></td>
							<td><?php 
        if (isset($e["created"])) {
            echo date("d/m/y", $e["created"]);
        }
        ?>
</td>
							<td><?php 
        if (isset($e["dateEnd"])) {
            echo $e["dateEnd"];
        }
        ?>
</td>
Пример #4
0
                 array_push($cps, $value["cp"]);
             }
         }
     }
 }
 $tags = "";
 if (isset($value["tags"])) {
     foreach ($value["tags"] as $t) {
         if (!empty($t) && !in_array($t, $alltags)) {
             array_push($alltags, $t);
             $tagBlock .= ' <button class="filter " data-filter=".' . $t . '">' . $t . '</button>';
         }
         $tags .= $t . ' ';
     }
 }
 $count = PHDB::count(Survey::COLLECTION, array("type" => Survey::TYPE_ENTRY, "survey" => (string) $value["_id"]));
 $link = $name;
 /* **************************************
    //check if I wrote this law
    *************************************** */
 $meslois = $logguedAndValid && Yii::app()->session["userEmail"] && $value['email'] == Yii::app()->session["userEmail"] ? "myentries" : "";
 //checks if the user is a follower of the entry
 $followingEntry = $logguedAndValid && isset($value[Action::ACTION_FOLLOW]) && is_array($value[Action::ACTION_FOLLOW]) && in_array(Yii::app()->session["userId"], $value[Action::ACTION_FOLLOW]) ? "myentries" : "";
 if ($value["type"] == Survey::TYPE_SURVEY) {
     $link = '<a class="titleMix ' . $meslois . '" href="' . Yii::app()->createUrl("/" . $this->module->id . "/survey/entries/id/" . (string) $value["_id"]) . '">' . $name . ' (' . $count . ')</a>';
 } else {
     if ($value["type"] == "entry") {
         $link = '<a class="titleMix ' . $meslois . '" onclick="entryDetail(\'' . Yii::app()->createUrl("/" . $this->module->id . "/survey/entry/id/" . (string) $value["_id"]) . '\')" href="javascript:;">' . $name . '</a>';
     }
 }
 //$infoslink bring visual detail about the entry