public function __construct($data)
 {
     if (isset($data['session'])) {
         $guid = $data['guid'];
         $title = $data['blog_title'];
         $description = $data['description'];
         $access_id = $data['access_id'];
         $user = getUserFromSession($data['session']);
         if (!$guid) {
             $blog = new Blog();
             $blog->owner_guid = $user->guid;
             $blog->save();
         } else {
             $blog = getEntity($guid);
         }
         if ($blog->owner_guid == $user->guid) {
             $blog->title = $title;
             $blog->description = $description;
             $blog->access_id = $access_id;
             $blog->status = "draft";
             $guid = $blog->save();
             $blog = getEntity($guid);
             echo json_encode(array("guid" => $guid, "timeago" => display("output/friendly_time", array("timestamp" => $blog->last_updated))));
         }
     }
 }
function indexAction()
{
    $user = getUserFromSession();
    if (!$user) {
        include TPL_PATH . 'main.php';
        include TPL_RSB_PATH . 'indexRsb.php';
        include TPL_PATH . 'end.php';
    } else {
        header("Location: /?controller=user");
    }
}
 public function __construct($data)
 {
     $guid = $data['guid'];
     $notification = getEntity($guid);
     classGateKeeper($notification, "Notification");
     if (!$data['session']) {
         if ($notification->owner_guid == getLoggedInUserGuid()) {
             $notification->delete();
         }
     } else {
         $user = getUserFromSession($data['session']);
         if ($notification->owner_guid == $user->guid) {
             $notification->delete();
         }
     }
 }
 function __construct($data)
 {
     if (isset($data['session'])) {
         $user = getUserFromSession($data['session']);
         if ($user->isAdmin()) {
             $count = 0;
             $order = $data['order'];
             foreach ($order as $o) {
                 $guid = str_replace("guid_", "", $o);
                 $guid = intval($guid);
                 $page = getEntity($guid);
                 $page->weight = $count;
                 $page->save();
                 $count++;
             }
         }
     }
 }
 public function __construct($data)
 {
     $order = $data['order'];
     if (isset($data['session'])) {
         $user = getUserFromSession($data['session']);
         if ($user->isAdmin()) {
             $x = 0;
             Cache::clear();
             Cache::clear();
             foreach ($order as $string) {
                 $guid = str_replace("guid_", "", $string);
                 $plugin = getEntity($guid);
                 $plugin->plugin_order = $x;
                 $plugin->save();
                 $x = $x + 1;
             }
         }
     }
 }
 * NOTICE:  All information contained herein is, and remains the property of SocialApparatus 
 * and its suppliers, if any.  The intellectual  and technical concepts contained herein 
 * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign 
 * Patents, patents in process, and are protected by trade secret or copyright law. 
 * 
 * Dissemination of this information or reproduction of this material is strictly forbidden 
 * unless prior written permission is obtained from SocialApparatus.
 * 
 * Contact Shane Barron admin@socia.us for more information.
 */
namespace SocialApparatus;

denyDirect();
$params = Vars::get("params");
$count = Vars::get("count");
$count_shown = Vars::get("count_shown");
$wrapper_id = Vars::get("wrapper_id");
$session = getInput("session");
$user = getUserFromSession($session);
if ($user) {
    $params['logged_in_user_guid'] = $user->guid;
}
echo listEntities($params);
if ($count > $count_shown) {
    $params['offset'] = $params['offset'] + $params['limit'];
    $params = json_encode($params);
    $button = "<button class='show_more btn btn-danger btn-xs pull-right' data-count='{$count}' data-count_shown='{$count_shown}' data-params='{$params}' data-id='{$wrapper_id}'>More</button>";
} else {
    $button = NULL;
}
echo $button;
function deleteProjectAction()
{
    $errors = NULL;
    if (isset($_POST['deleting_project']) && isset($_COOKIE['form'])) {
        setcookie('form', 1, time() - 3600);
        $proj_id = intval($_POST['deleting_project']);
        if ($proj_id === 0) {
            $errors[] = 'Проект не выбран';
        }
        if ($proj_id === getProjectFromSession()['id']) {
            $errors[] = 'Зактойте проект перед удалением';
        }
        if (!$errors) {
            $user_id = getUserFromSession()['id'];
            if (!deleteProjectByIdAndUserId($proj_id, $user_id)) {
                $errors[] = 'Произошла ошибка доступа к базе данных';
            }
        }
    }
    indexAction($errors);
}