예제 #1
0
 public function email_notifications()
 {
     if (\WebAPL\Modules::checkInstance('person')) {
         $events = \CalendarModel::join(CalendarLangModel::getTableName(), \CalendarModel::getField('id'), '=', CalendarLangModel::getField('calendar_item_id'))->join(\CalendarGroup::getTableName(), \CalendarGroup::getField('id'), '=', \CalendarModel::getField('calendar_group_id'))->join(\CalendarPostModel::getTableName(), \CalendarPostModel::getField('calendar_group_id'), '=', \CalendarGroup::getField('id'))->where(CalendarLangModel::getField('lang_id'), \WebAPL\Language::getId())->where(\CalendarModel::getField('enabled'), 1)->where(\CalendarModel::getField('person_id'), '<>', 0)->select(CalendarLangModel::getField("*"), \CalendarModel::getField('event_date'), \CalendarModel::getField('repeat_frequency'), \CalendarModel::getField('repeat_to_date'), \CalendarModel::getField('person_id'), \CalendarModel::getField('post_id'), \CalendarModel::getField('period'))->orderBy(\CalendarModel::getField('event_date'), 'asc')->where(function ($query) {
             $query->where(function ($query) {
                 $query->where(DB::raw("DATE(" . CalendarModel::getField('event_date') . ")"), '=', DB::raw('DATE(CURRENT_TIMESTAMP)'));
             })->orWhere(function ($query) {
                 $query->where(\CalendarModel::getField('event_date'), '<=', DB::raw('CURRENT_TIMESTAMP'))->where(\CalendarModel::getField('repeat_to_date'), '>=', DB::raw('CURRENT_TIMESTAMP'))->where(\CalendarModel::getField('repeat_frequency'), '<>', 'none');
             });
         })->get();
         $event_list = \CalendarModel::generateEvents($events, false);
         $today_events = [];
         foreach ($event_list as $event) {
             if (date("Y-m-d", strtotime($event['event_date'])) === date("Y-m-d") && strtotime($event['event_date']) >= time()) {
                 echo " sendone ";
                 $today_events[] = $event;
                 $this->loadClass(['PersonModel'], 'person');
                 $person = \PersonModel::getPerson($event['person_id']);
                 if (isset($person->email) && $person->email) {
                     Template::viewModule($this->module_name, function () use($person, $event) {
                         \EmailModel::sendToAddress($person->email, "Do you have an event today", 'views.calendarEmail', ['person' => $person, 'event' => $event]);
                     });
                 }
             }
         }
     }
 }
예제 #2
0
 public static function answers($id)
 {
     $answers = PollAnswerLangModel::join(PollAnswerModel::getTableName(), PollAnswerModel::getField('id'), '=', PollAnswerLangModel::getField('answer_id'))->select(PollAnswerLangModel::getField('*'))->where(PollAnswerLangModel::getField('lang_id'), \WebAPL\Language::getId())->where(PollAnswerModel::getField('poll_id'), $id)->orderBy(PollAnswerModel::getField('ord'), 'asc')->get();
     foreach ($answers as &$answer) {
         $answer['count'] = PollVotesModel::where(array('poll_id' => $id, 'answer_id' => $answer->answer_id))->count();
     }
     return $answers;
 }
예제 #3
0
 public function getlist()
 {
     \User::onlyHas('jobrequest-view');
     $jqgrid = new jQgrid(\JobRequestModel::getTableName());
     echo $jqgrid->populate(function ($start, $limit) {
         return \JobRequestModel::join(PostLang::getTableName(), \PostLang::getField('post_id'), '=', \JobRequestModel::getField('post_id'))->where(\PostLang::getField('lang_id'), \WebAPL\Language::getId())->select(\JobRequestModel::getField('id'), \PostLang::getField('title'), \JobRequestModel::getField('name'), \JobRequestModel::getField('cv_path'), \JobRequestModel::getField('date_created'))->skip($start)->take($limit)->orderBy(\JobRequestModel::getField('date_created'), 'desc')->get();
     });
 }
예제 #4
0
 public function display()
 {
     \User::onlyHas('chat-view');
     $data = array('person' => \PersonModel::where('user_id', \Auth::user()->id)->first());
     if ($data['person']) {
         $tokenGen = new FireBaseAuth(\SettingsModel::one('firechat_key'));
         $data['token'] = $tokenGen->createToken(array("uid" => "person-{$data['person']->id}"), array("admin" => True));
         $data['person_lang'] = $data['person']->langs()->where('lang_id', \WebAPL\Language::getId())->first();
         return Template::moduleView($this->module_name, 'views.chat-display', $data);
     } else {
         throw new Exception('Person not found');
     }
 }
예제 #5
0
 public function soclist()
 {
     \User::onlyHas('socialc-view');
     $pages = \Post::join(\PostLang::getTableName(), \PostLang::getField('post_id'), '=', \Post::getField('id'))->where(\PostLang::getField('lang_id'), \WebAPL\Language::getId())->where(\Post::getField('taxonomy_id'), 1)->orderBy(\PostLang::getField('title'), 'desc')->get();
     $page_list = array();
     $page_json = array();
     foreach ($pages as $page) {
         $page_list[] = "{$page->post_id}:{$page->title}";
         $page_json[$page->post_id] = $page->title;
     }
     $data['pagesString'] = implode(';', $page_list);
     $data['pagesJson'] = json_encode($page_json);
     $this->layout->content = Template::moduleView($this->module_name, 'views.list', $data);
     return $this->layout;
 }
예제 #6
0
 public static function getPostPersonGroups($post_id)
 {
     $groups = PersonGroup::join(PersonGroupPostModel::getTableName(), PersonGroupPostModel::getField("group_id"), '=', PersonGroup::getField("id"))->join(PersonGroupLang::getTableName(), PersonGroupLang::getField("group_id"), '=', PersonGroup::getField('id'))->where(PersonGroupLang::getField("lang_id"), \WebAPL\Language::getId())->where(PersonGroupPostModel::getField("post_id"), $post_id)->select(PersonGroupLang::getField('name'), PersonGroupLang::getField('description'), PersonGroup::getField("id"))->get();
     if ($groups) {
         foreach ($groups as &$group) {
             $persons = PersonModel::personPrepare()->where(PersonRelModel::getField("group_id"), $group->id)->get();
             foreach ($persons as &$person) {
                 if ($person->feed_id) {
                     $person['posts'] = \Post::postsFeed($person->feed_id);
                 } else {
                     $person['posts'] = array();
                 }
             }
             $group['persons'] = $persons;
         }
     }
     return $groups;
 }
예제 #7
0
 public function postCreate()
 {
     User::onlyHas('var-create');
     $parent_key = Input::get('parent_key');
     $var_langs = Input::get('text');
     $key = VarModel::uniqKey(Input::get('key'), Input::get('text.' . \WebAPL\Language::getId()));
     $var = new VarModel();
     $var->key = $key;
     $var->parent_key = $parent_key;
     $var->save();
     foreach ($var_langs as $lang_id => $value) {
         $var_lang = new VarLangModel();
         $var_lang->var_key = $key;
         $var_lang->lang_id = $lang_id;
         $var_lang->value = $value;
         $var_lang->save();
     }
     Log::info("Created new var '{$key}'");
     return Redirect::back();
 }
예제 #8
0
 public function topost($id)
 {
     $post = Post::find($id);
     if ($post) {
         switch ($post->taxonomy_id) {
             case 1:
                 $uri = Post::getFullURI($post->id, true);
                 return Redirect::to($uri);
             case 2:
                 $feed = FeedPost::where('post_id', $post->id)->first();
                 if ($feed) {
                     $page = Post::where('feed_id', $feed->feed_id)->first();
                     if ($page) {
                         $viewmods = WebAPL\Template::getViewMethodList('page');
                         $uri = Post::getFullURI($page->id, true);
                         if (isset($viewmods[$page->view_mod]['support_item']) && $viewmods[$page->view_mod]['support_item']) {
                             $plang = PostLang::where('post_id', $post->id)->where('lang_id', \WebAPL\Language::getId())->first();
                             if ($plang) {
                                 $url = $uri . "?item=" . $plang->uri;
                             } else {
                                 $url = $uri;
                             }
                         } else {
                             $url = $uri;
                         }
                         return Redirect::to($url);
                     } else {
                         throw new Exception("Not found page, post #{$id}");
                     }
                 } else {
                     throw new Exception("Not found feed, post #{$id}");
                 }
                 break;
             default:
                 throw new Exception("Not found taxonomy, post #{$id}");
                 break;
         }
     } else {
         throw new Exception("Post not found #{$id}");
     }
 }
예제 #9
0
    };
</script>


<form action="<?php 
echo url('person/savegroup');
?>
" method="post">
    <h3><?php 
echo varlang('create-new-group');
?>
</h3>
    <div class="col-lg-6">
        <?php 
$num = 0;
foreach (\WebAPL\Language::getList() as $lang) {
    $num++;
    ?>
            <?php 
    echo varlang('name-in');
    echo $lang->name;
    ?>
:<br>
            <input type="text" class="form-control" name="lang[<?php 
    echo $lang->id;
    ?>
][name]" />
            <div class="c10"></div>
            <?php 
    if ($num % 2 == 0) {
        ?>
예제 #10
0
echo varlang('nume-2');
?>
</th>
                        <th><?php 
echo varlang('screen');
?>
</th>
                        <th></th>
                    </tr>
                    <?php 
foreach ($view_mods as $view_key => $view_mod) {
    ?>
                        <tr>
                            <td>
                                <a target="_blank" href="<?php 
    echo url('/../' . \WebAPL\Language::ext() . "/topage/" . $view_key);
    ?>
"><i class="glyphicon glyphicon-zoom-in"></i></a>
                                <b><?php 
    echo $view_mod['name'];
    ?>
</b>
                                <?php 
    if ($view_mod['info']) {
        ?>
                                    <br>
                                    <?php 
        echo $view_mod['info'];
        ?>
                                <?php 
    }
예제 #11
0
 public static function prepareQuery()
 {
     return VarModel::join(VarLangModel::getTableName(), VarLangModel::getField('var_key'), '=', VarModel::getField('key'))->select(VarLangModel::getField('*'), DB::raw(VarModel::getField('id') . " as vid"), VarModel::getField('parent_key'), VarModel::getField('key'))->where(VarLangModel::getField('lang_id'), \WebAPL\Language::getId());
 }
예제 #12
0
 public function subscribe()
 {
     $data = array('persons' => PersonModel::join(PersonLangModel::getTableName(), PersonLangModel::getField('person_id'), '=', PersonModel::getField('id'))->select(PersonModel::getField('id'), PersonLangModel::getField('first_name'), PersonLangModel::getField('last_name'))->orderBy(PersonLangModel::getField('first_name'))->where(PersonLangModel::getField('lang_id'), \WebAPL\Language::getId())->get());
     return View::make('person::block_subscribe', $data);
 }
예제 #13
0
            <td>
                <input type="text" name="general[ord]" class='form-control' value='<?php 
echo isset($answer->ord) ? $answer->ord : '';
?>
' />
            </td>
        </tr>
        <?php 
foreach ($answer_langs as $answer_lang) {
    ?>
        <tr>
            <th><?php 
    echo varlang('answer-in-');
    ?>
 <?php 
    echo \WebAPL\Language::getItem($answer_lang->lang_id)->name;
    ?>
</th>
            <td>
                <input type="text" name="answer[<?php 
    echo $answer_lang->id;
    ?>
]" class='form-control' value='<?php 
    echo isset($answer_lang->title) ? $answer_lang->title : '';
    ?>
' />
            </td>
        </tr>
        <?php 
}
?>
예제 #14
0
 public function getlist()
 {
     \User::onlyHas('calendar-view');
     $jqgrid = new jQgrid('apl_calendar_item');
     echo $jqgrid->populate(function ($start, $limit) {
         return CalendarModel::select(CalendarModel::$ftable . '.id', CalendarModel::$ftable . '.event_date', CalendarLangModel::$ftable . '.title', CalendarModel::$ftable . '.period', CalendarModel::$ftable . '.enabled')->leftJoin(CalendarLangModel::$ftable, CalendarLangModel::$ftable . '.calendar_item_id', '=', CalendarModel::$ftable . '.id')->where(CalendarLangModel::$ftable . '.lang_id', \WebAPL\Language::getId())->skip($start)->take($limit)->get();
     });
 }
예제 #15
0
 public function page_group_attachment($post)
 {
     if (in_array($post->view_mod, array('persons_list', 'city_councilors', 'persons_big', 'persons_secretar', 'persons_mayor', 'group_with_persons', 'persons_with_photo'))) {
         $wdata = array('post' => $post->toArray(), 'person_groups' => PersonGroup::join(PersonGroupLang::getTableName(), PersonGroupLang::getField("group_id"), '=', PersonGroup::getField('id'))->select(PersonGroup::getField("id"), PersonGroupLang::getField("name"))->where(PersonGroupLang::getField("lang_id"), \WebAPL\Language::getId())->orderBy(\PersonGroupLang::getField('name'), 'asc')->get()->toArray(), 'selected_groups' => array());
         $selected_groups = PersonGroupPostModel::where('post_id', $post->id)->get();
         foreach ($selected_groups as $item) {
             $wdata['selected_groups'][] = $item->group_id;
         }
         echo Template::moduleView($this->module_name, 'views.attachment-group-page', $wdata);
     }
 }
예제 #16
0
 public function sendmail()
 {
     $session_id = \Session::get('chat_session_id');
     $html = \Input::get('messages');
     if ($session_id) {
         $chat = \FireChatSession::find($session_id);
         if ($chat) {
             $data['html'] = $html;
             $person = \PersonLangModel::where('person_id', $chat->person_id)->where('lang_id', \WebAPL\Language::getId())->first();
             Template::viewModule($this->module_name, function () use($data, $chat, $person) {
                 \Mail::send('views.email-mess', $data, function ($message) use($chat, $person) {
                     $message->from("noreply@{$_SERVER['SERVER_NAME']}", 'WebLPA');
                     $message->subject("Discutie on-line cu " . $person->first_name . " " . $person->last_name . " din " . date("Y-m-d H:i"));
                     $message->to($chat->user_email);
                 });
             });
         }
     }
 }
예제 #17
0
 public function sendarticle()
 {
     $post_id = Input::get('id');
     $post = \PostLang::where('post_id', $post_id)->first();
     if ($post) {
         $data['post'] = $post;
         $data['post_url'] = url("/../" . \WebAPL\Language::ext() . "/topost/" . $post_id);
         Template::viewModule($this->module_name, function () use($data, $post) {
             $newsletterUsers = \NewsletterModel::where('enabled', 1)->get();
             foreach ($newsletterUsers as $user) {
                 if (filter_var($user->email, FILTER_VALIDATE_EMAIL)) {
                     $data['user'] = $user;
                     $data['unsubscribe_link'] = url("/../newsletter/unsubscribe/{$user->hash}");
                     Mail::send('views.emails.post', $data, function ($message) use($post, $user) {
                         $message->from("noreply@{$_SERVER['SERVER_NAME']}", 'WebLPA');
                         $message->subject($post->title . " :: NEWSLETTER");
                         $message->to($user->email);
                     });
                 }
             }
         });
     }
 }
예제 #18
0
 /**
  * Get Page title
  * @return string
  */
 public static function getPageTitle($page = null)
 {
     $title = isset($page['is_home_page']) && $page['is_home_page'] ? '' : static::$page_title . ' :: ';
     $title_g = \SettingsModel::one('sitename_' . Language::ext());
     return $title . $title_g;
 }
예제 #19
0
파일: poll.php 프로젝트: vcorobceanu/WebAPL
 /**
  * Edit / create poll
  * @param int $id
  * @return layout
  */
 public function form($id = 0)
 {
     User::onlyHas('poll-edit');
     if ($id === 0) {
         $poll = new PollModel();
         $poll->save();
         $id = $poll->id;
         foreach (\WebAPL\Language::getList() as $lang) {
             $pollLang = new PollQuestionModel();
             $pollLang->poll_id = $id;
             $pollLang->lang_id = $lang->id;
             $pollLang->save();
         }
         return \Illuminate\Support\Facades\Redirect::to('poll/form/' . $id);
     }
     $data = array('poll' => PollModel::find($id), 'poll_question' => array(), 'module' => $this->module_name);
     if ($data['poll']) {
         $pollLangs = PollModel::find($id)->langs()->get();
         foreach ($pollLangs as $pollLang) {
             $data['poll_question'][$pollLang->lang_id] = $pollLang;
         }
     }
     $this->layout->content = Template::moduleView($this->module_name, 'views.form', $data);
     return $this->layout;
 }
예제 #20
0
파일: rss.php 프로젝트: vcorobceanu/WebAPL
</title>
        <link><?php 
echo url();
?>
</link>
        <description></description>
        <?php 
foreach ($posts as $item) {
    ?>
            <item>
                <title><?php 
    echo htmlspecialchars($item->title);
    ?>
</title>
                <link><?php 
    echo \WebAPL\Language::url('topost/' . $item->id);
    ?>
</link>
                <description><?php 
    echo htmlspecialchars(htmlspecialchars_decode(Str::words(strip_tags($item->text), 200)));
    ?>
</description>
                <pubDate><?php 
    echo date("D, d M Y H:i:s O", strtotime($item->created_at));
    ?>
</pubDate>
            </item>
        <?php 
}
?>
    </channel>