public function librarylistAction()
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $id = $this->_getParam('iLibCategoryId');
         $eventsList = new Model_Document();
         $this->view->list = $eventsList->getDocListByCat($id);
     }
 }
Exemplo n.º 2
0
 public function action_index()
 {
     $data["documents"] = Model_Document::find("all", ["where" => [["deleted_at", 0]], "order_by" => [["created_at", "desc"]]]);
     $data['pasts'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
     $data['user'] = $this->user;
     $view = View::forge("students/documents", $data);
     $this->template->content = $view;
 }
Exemplo n.º 3
0
 public function action_index()
 {
     // add
     if (!empty($_FILES["file"]) and is_uploaded_file($_FILES["file"]["tmp_name"])) {
         $ext = explode(".", $_FILES["file"]["name"]);
         if (strtolower($ext[1]) == "pdf" or strtolower($ext[1]) == "doc" or strtolower($ext[1]) == "docx") {
             $filename = str_replace("/", "", $_FILES["file"]["name"]);
             $filepath = DOCROOT . "/contents/" . $filename;
             if (move_uploaded_file($_FILES["file"]["tmp_name"], $filepath)) {
                 chmod($filepath, 0644);
                 // save
                 if (Input::post("doc_type") == 1) {
                     $documents = Model_Document::query()->where('type', 2)->where('deleted_at', 0)->limit(1)->get_one();
                     if (count($documents) < 1) {
                         $document = Model_Document::forge();
                         $document->path = $filename;
                         $document->type = Input::post("doc_type");
                         $document->save();
                     } else {
                         $query = Model_Document::find($documents->id);
                         $query->path = $filename;
                         $query->type = Input::post("doc_type");
                         $query->save();
                     }
                 } else {
                     $document = Model_Document::forge();
                     $document->path = $filename;
                     $document->type = Input::post("doc_type");
                     $document->save();
                 }
                 Response::redirect("/admin/documents/");
             } else {
                 Response::redirect("/admin/documents/?e=1");
             }
         } else {
             Response::redirect("/admin/documents/?e=3");
         }
     }
     $where = [["deleted_at", 0], ["type", 0]];
     $data["documents"] = Model_Document::find("all", ["where" => $where, "order_by" => [["created_at", "desc"]]]);
     $where_online = [["deleted_at", 0], ["type", 1]];
     $data["online"] = Model_Document::find("all", ["where" => $where_online, "order_by" => [["created_at", "desc"]]]);
     $config = array('pagination_url' => "", 'uri_segment' => "p", 'num_links' => 9, 'per_page' => 100, 'total_items' => count($data["documents"]));
     $data["pager"] = Pagination::forge('mypagination', $config);
     $data["documents"] = array_slice($data["documents"], $data["pager"]->offset, $data["pager"]->per_page);
     $view = View::forge("admin/documents/index", $data);
     $this->template->content = $view;
 }
Exemplo n.º 4
0
 public function action_index()
 {
     $course_id = Session::instance()->get('course_id');
     $course = ORM::factory('course', $course_id);
     $role = Auth::instance()->get_user()->role();
     $criteria = array('course' => $course, 'role' => $role, 'filter_title' => $this->request->param('filter_title'), 'filter_by' => $this->request->param('filter_by'));
     $documents = Model_Document::documents($criteria);
     //ORM::factory('document')->find_all();
     $url = 'document/index';
     $filter = array('text' => '', 'select' => '');
     if ($this->request->param('filter_title')) {
         $url .= '/filter_title/' . $this->request->param('filter_title');
         $filter = array('text' => $this->request->param('filter_title'), 'select' => 'filter_title');
     }
     if ($this->request->param('filter_by')) {
         $url .= '/filter_by/' . $this->request->param('filter_by');
         $filter = array('text' => $this->request->param('filter_by'), 'select' => 'filter_by');
     }
     $filter['url'] = URL::site('document/index');
     $view = View::factory('document/list')->set('page_title', 'Documents Manager')->bind('documents', $documents)->bind('filter', $filter);
     $this->content = $view;
     Breadcrumbs::add(array('Courses', Url::site('course')));
     Breadcrumbs::add(array('Documents', Url::site('document')));
 }
Exemplo n.º 5
0
 public function action_index()
 {
     $data["documents"] = Model_Document::find("all", ["where" => [["deleted_at", 0]], "order_by" => [["created_at", "desc"]]]);
     $view = View::forge("teachers/documents", $data);
     $this->template->content = $view;
 }
Exemplo n.º 6
0
 public function post_deldocument()
 {
     $code = 0;
     $message = "ok";
     if ($this->auth_status) {
         $document = Model_Document::find(Input::post("id", 0));
         if ($document != null) {
             $document->deleted_at = time();
             $document->save();
         } else {
             $code = 404;
             $message = "Document not found.";
         }
     } else {
         $code = 500;
         $message = "Auth error.";
     }
     $this->response(array('code' => $code, 'message' => $message));
 }
Exemplo n.º 7
0
 public function action_submit()
 {
     if (!Security::check_token()) {
         Response::redirect('_404_');
     }
     if (Session::get_flash('email')) {
         $email = Session::get_flash("email");
         Auth::create_user($email, Session::get_flash("password"), $email, 1);
         $user = Model_User::find("first", ["where" => [["email", $email]]]);
         if ($user != null) {
             $user->sex = Session::get_flash("sex");
             $user->firstname = Session::get_flash("firstname");
             $user->middlename = Session::get_flash("middlename");
             $user->lastname = Session::get_flash("lastname");
             $user->birthday = Session::get_flash("year") . "-" . Session::get_flash("month") . "-" . Session::get_flash("day");
             $user->google_account = Session::get_flash("google_account");
             $user->need_reservation_email = Session::get_flash("need_reservation_email");
             $user->need_news_email = Session::get_flash("need_news_email");
             $user->timezone = Session::get_flash("timezone");
             $user->place = Session::get_flash("grameen");
             $user->grameen_student = Session::get_flash("grameen_student");
             $user->nationality = Session::get_flash("nationality");
             $user->save();
             // send mail
             $body = View::forge("email/students/signup");
             $body->set("name", $user->firstname);
             $body->set("user", $user);
             $body->set("ymd", explode("-", $user->birthday));
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($user->email);
             $sendmail->subject("Welcome Aboard! / Game-BootCamp");
             $sendmail->html_body(htmlspecialchars_decode($body));
             $documents = Model_Document::query()->where('type', 1)->where('deleted_at', 0)->limit(1)->get_one();
             if (count($documents) > 0) {
                 $query = Model_Document::find($documents->id);
                 $sendmail->attach(DOCROOT . '/contents/' . $query->path);
             }
             $sendmail->send();
         } else {
             Response::redirect('_404_/?hehe');
         }
     } else {
         Response::redirect('_404_');
     }
     $this->template->content = View::forge('students/signup/finish');
 }
Exemplo n.º 8
0
<?php

$documents = Model_Document::query()->where('type', 1)->where('deleted_at', 0)->limit(1)->get_one();
$query1 = Model_Document::find($documents->id);
$documents = Model_Document::query()->where('type', 2)->where('deleted_at', 0)->limit(1)->get_one();
$query2 = Model_Document::find($documents->id);
$doc1 = "/contents/" . $query1->path;
$doc2 = "/contents/" . $query2->path;
$open = Input::get('open', NULL);
if (!Auth::check()) {
    if ($open != 0) {
        ?>
			<input type="text" value="<?php 
        if ($open == 1) {
            echo "1";
        } elseif ($open == 2) {
            echo "2";
        }
        ?>
" id="openDoc" hidden/>
	<?php 
    }
} else {
    if (isset($student)) {
        $place = $student->place;
        ?>
			<input type="text" value="<?php 
        if ($place == 0) {
            echo "1";
        } elseif ($place == 1) {
            echo "2";
Exemplo n.º 9
0
 public function action_reference()
 {
     $this->test('CREATE DOCUMENT WITH REFERENCED DOCUMENT');
     $doc = new Model_Document();
     $doc->id = 'foo';
     $doc->other = Mongo_Document::factory('other');
     $doc->other->bar = 'baz';
     $doc->other->save();
     $doc->save();
     $this->assert('referenced document reference exists', $doc->_other);
     $doc = new Model_Document('foo');
     $this->assert('nested document saved', $doc->other->bar == 'baz');
     $this->test('SEARCH DOCUMENTS BY PREDEFINED SEARCH');
     $docs = $doc->other->find_docs();
     $this->assert('1 docs found', $docs->count() == 1);
     $doc0 = $docs->getNext();
     $this->assert('doc id is expected', $doc0->id == 'foo');
     $this->test('LOAD MULTIPLE REFERENCED DOCUMENTS FROM ARRAY OF _ids');
     for ($i = 0; $i < 3; $i++) {
         $newdoc = Mongo_Document::factory('other')->load_values(array('id' => 'more' . $i, 'foo' => 'bar' . $i))->save();
         $doc->push('_lots', $newdoc->id);
     }
     $doc->save();
     $lots = $doc->lots;
     $this->assert('found 3 referenced docs', $lots->count() == 3);
 }