function fill_db($path, $parent_id)
 {
     $dh = opendir($path) or error("Can't open {$path}");
     while (($file = readdir($dh)) !== false) {
         if ($file[0] == '.') {
             continue;
         }
         $rpath = $path . '/' . $file;
         $fl = new FileItem();
         $fl->parent_id = $parent_id;
         $fl->name = $file;
         if (is_dir($rpath)) {
             $fl->type = FileItem::Folder;
             $fl->save();
             Initiator::fill_db($rpath, $fl->id);
         } else {
             if ($file == 'all.php') {
                 continue;
             }
             if (substr($file, -4) != '.php') {
                 continue;
             }
             $fl->type = FileItem::File;
             $fl->save();
             $doc = new Documenter();
             $doc->parse($rpath);
             $doc->save($fl);
         }
     }
     closedir($dh);
 }
 public function delete($id)
 {
     $this->isDefaultUserIteractBlock($id);
     Auth::isAdminOrDie(App::$instance);
     $initiator = Initiator::findorFail($id);
     $initiator->delete();
     App::$instance->MQ->setMessage("Успешно удалено");
     App::$instance->log->logWrite(LOG_CONFIG_CHANGE, 'Инициатор удален' . $initiator->name);
     ST::redirectToRoute('Initiators/index');
 }
 public function on_init()
 {
     Initiator::check_init();
     /*
     $dc = new Documenter();
     $dc->parse(S_BASE.'data/json.php');
     dwrite_msg('', dump_str($dc->blocks));
     */
     $this->add_control('FileOutput', new FileOutput());
     $this->add_control('BlockOutput', new BlockOutput());
     $this->add_control('NoteOutput', new NoteOutput());
     $root = new FileItem();
     $root->find(array('parent_id=', 0));
     $this->vars['files'] = $root->childs;
 }
Beispiel #4
0
 function init()
 {
     parent::init();
     Initiator::getInstance()->addJs($this->app);
 }
 public function edit($id)
 {
     //can this user access it
     $vks = Vks::full()->findOrFail($id);
     $check = boolval(intval(Settings_controller::getOther("attendance_check_enable")));
     $strict = boolval(intval(Settings_controller::getOther("attendance_strict")));
     if (!Auth::isAdmin(App::$instance) && (!$this->isThisUserCanEdit($vks) || !VKSTimeAnalizator::isManipulatable($vks))) {
         $this->error('no_manipulable');
     }
     //get vksdata
     if ($vks->is_simple) {
         App::$instance->MQ->setMessage("Упрощенные ВКС редактировать запрещено, можно только аннулировать");
         ST::redirectToRoute("Vks/show/" . $vks->id);
     }
     if ($vks->other_tb_required) {
         App::$instance->MQ->setMessage("Вкс для которых создана транзитная ВКС на ресурсах ЦА, нельзя редактировать, только аннулировать");
         ST::redirectToRoute("Vks/show/" . $vks->id);
     }
     $vks = $this->humanize($vks);
     if (!Auth::isAdmin(App::$instance) && !$vks->humanized->isEditable) {
         App::$instance->MQ->setMessage("Данную ВКС редактировать запрещено");
         ST::redirectToRoute("Vks/show/" . $vks->id);
     }
     $departments = Department::orderBy('prefix')->get();
     $initiators = Initiator::all();
     $this->fillCookieParticipants('vks_participants_edit', $vks);
     //        vks_participants_edit
     if (Auth::isAdmin(App::$instance)) {
         $versSys = new VksVersion_controller();
         $this->render('vks/admin/edit', ['vks' => $vks, 'versions' => $versSys->getVersionsList($vks->id), 'departments' => $departments, 'initiators' => $initiators]);
     } else {
         $this->render('vks/edit-ws', compact('vks', 'departments', 'initiators', 'check', 'strict'));
     }
 }