function add_Datastream($pid, $datastream, $dsLabel, $mimetype, $xml_url)
{
    module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
    module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
    global $user;
    if (!fedora_repository_access(OBJECTHELPER::$ADD_FEDORA_STREAMS, $pid, $user)) {
        drupal_set_message('You do not have permission to add datastreams to this object!');
        return false;
    }
    global $base_url;
    module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
    $controlGroup = "M";
    $params = array('pid' => $pid, 'dsID' => $datastream, 'altIDs' => "", 'dsLabel' => $dsLabel, 'versionable' => "true", 'MIMEType' => $mimetype, 'formatURI' => "URL", 'dsLocation' => $xml_url, 'controlGroup' => "{$controlGroup}", 'dsState' => "A", 'checksumType' => "DISABLED", 'checksum' => "none", 'logMessage' => "datastream added");
    try {
        $soapHelper = new ConnectionHelper();
        $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
        if ($client == null) {
            drupal_set_message(t('Error Getting Soap Client.'), 'error');
            return false;
        }
        $object = $client->__soapCall('addDatastream', array('parameters' => $params));
        return true;
    } catch (exception $e) {
        try {
            $params['force'] = 'true';
            $object = $client->__soapCall('ModifyDatastreamByReference', array($params));
            return true;
        } catch (exception $e1) {
            drupal_set_message(t($e1->getMessage()), 'error');
            return false;
        }
    }
}
Exemple #2
0
 function getEpistemetecData($pid)
 {
     global $base_url;
     $path = drupal_get_path('module', 'Fedora_Repository');
     module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
     $soapHelper = new ConnectionHelper();
     $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
     $dsId = 'MAG';
     $params = array('pid' => "{$pid}", 'dsID' => "{$dsId}", 'asOfDateTime' => "");
     try {
         $object = $client->__soapCAll('getDatastreamDissemination', array('parameters' => $params));
     } catch (Exception $e2) {
         try {
             //probably no QDC so we will try for the DC stream.
             $dsId = 'MAG';
             $params = array('pid' => "{$pid}", 'dsID' => "{$dsId}", 'asOfDateTime' => "");
             $object = $client->__soapCAll('getDatastreamDissemination', array('parameters' => $params));
         } catch (exception $e2) {
             drupal_set_message($e2->getMessage(), 'error');
             return;
         }
     }
     $xmlstr = $object->dissemination->stream;
     try {
         $proc = new XsltProcessor();
     } catch (Exception $e) {
         drupal_set_message($e->getMessage(), 'error');
         return;
     }
     $proc->setParameter('', 'baseUrl', $base_url);
     $proc->setParameter('', 'path', $base_url . '/' . $path);
     $input = null;
     $xsl = new DomDocument();
     try {
         $xsl->load($path . '/epistemetec/xsl/epistemetecData.xsl');
         $input = new DomDocument();
         $input->loadXML(trim($xmlstr));
     } catch (exception $e) {
         watchdog("Fedora_Repository", "Problem loading xsl file!");
     }
     $xsl = $proc->importStylesheet($xsl);
     $newdom = $proc->transformToDoc($input);
     $output = $newdom->saveXML();
     $baseUrl = base_path();
     $baseUrl = substr($baseUrl, 0, strpos($baseUrl, "/") - 1);
     //        if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) {
     //            $output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' . $dsId . '"><img src="' . $base_url . '/' . $path . '/images/edit.gif" alt="' . t('Edit Meta Data') . '" /></a>';
     //        }
     return $output;
 }
 function execute()
 {
     $model = new connectionUserModel();
     $user = ConnectionHelper::userLogin();
     $model->addFavorite((int) $user['id'], (int) Request::post('user'));
     return true;
 }
 function execute()
 {
     if (Request::post('step')) {
         return $this->stepPurse(Request::post('step'));
     }
     return array('user' => ConnectionHelper::userLogin());
 }
 public static function before()
 {
     if (Request::get('lang')) {
         $langList = array_map(function ($a) {
             return $a['iso'];
         }, Language::getList());
         $lang = strtolower(Request::get('lang'));
         if (in_array($lang, $langList)) {
             Request::cookie(self::$langKeyCookie, $lang);
         }
         Request::redirect(Request::url(array('lang' => '')));
     }
     if (Request::get('confirm_email')) {
         connectionUserModel::create()->confirmationEmailLink(Request::get('confirm_email'));
         Request::get('email_confirm', true);
     }
     if (ConnectionHelper::isLogin() && Request::get('status') && Request::get('status') == connectionUserModel::STATUS_MODERATE) {
         $userLogin = ConnectionHelper::userLogin();
         connectionUserModel::create()->changeStatus($userLogin['id'], connectionUserModel::STATUS_MODERATE, 'Пользователь отправил профиль на проверку.');
         Request::redirect('/profile/');
     }
     if (Request::get('auth') && !ConnectionHelper::isLogin()) {
         Request::redirect('/login/');
     }
     if (ConnectionHelper::isLogin()) {
         ConnectionHelper::updateUserActive();
     }
 }
 function execute()
 {
     $model = new connectionUserPhotoModel();
     $user = ConnectionHelper::userLogin();
     $photo = $model->getPhoto($user['id']);
     return array('photos' => $photo);
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $model = new connectionFeedbackModel();
     $list = $model->where(array('contact' => (int) $user['id']))->sort('date', -1)->fetchAll();
     return array('list' => $list);
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $model = new connectionUserModel();
     $model->updateInfo($_POST, (int) $user['id'], $_FILES);
     Request::redirect('/profile/');
     return 'success';
 }
 function execute()
 {
     $user_id = (int) Request::post('id');
     $login = ConnectionHelper::userLogin();
     connectionUserContactModel::create()->addUser($login['id'], $user_id);
     connectionUserEventModel::create()->add(array('type' => connectionUserEventModel::TYPE_INVITE_CHAT, 'user' => (int) $user_id, 'from' => (int) $login['id']));
     return 'success';
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $model = connectionUserModel::create();
     $favorite = array();
     foreach ($user['favorite'] as $userID) {
         $favorite[] = $model->getInfo($userID);
     }
     return array('favorite' => $favorite);
 }
 function execute()
 {
     $model = new connectionUserMessageModel();
     $user = ConnectionHelper::userLogin();
     $message = $model->getUserMessage($user['id'], Request::post('id'));
     if ($message) {
         $model->setState($message['id'], 'unread');
         return 'success';
     }
     return 'error';
 }
 function send($to, $text, $attachment = array())
 {
     $user = ConnectionHelper::userLogin();
     $model = new connectionMessageModel();
     $date = (int) strtotime('now');
     $data = array('from' => (int) $user['id'], 'to' => (int) $to, 'text' => Validator::clearValue($text), 'state' => 'unread', 'attachment' => $attachment, 'date' => $date);
     $message_id = (int) $model->insert($data);
     $this->insert(array('user_id' => (int) $user['id'], 'message_id' => $message_id, 'type' => 'sent', 'date' => $date));
     $this->insert(array('user_id' => (int) $to, 'message_id' => $message_id, 'type' => 'inbox', 'date' => $date));
     return $message_id;
 }
 function execute()
 {
     $model = new connectionUserModel();
     $login = ConnectionHelper::userLogin();
     $user = array_map(function ($a) use($model) {
         $data = $model->getInfo($a['id']);
         return array('id' => $data['id'], 'key' => $data['id'], 'name' => $data['first_name'], 'status' => $data['online'] ? 'online' : 'offline', 'avatar' => '/photo/thumb/' . $data['avatar']['id'], 'nickname' => $data['first_name'], 'camera' => isset($data['camera']) && $data['camera'] == 1 ? $data['stream'] : false);
     }, $model->getContact($login['id']));
     echo json_encode(array('contact' => $user));
     exit;
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $model = new connectionFeedbackAnswerModel();
     $data = Request::post('answer');
     $data['user'] = $user['id'];
     $result = $model->add($data);
     if (!Request::isAjax()) {
         Request::redirect('/profile/support/' . $data['ticket'] . '/');
     }
     return $result ? 'success' : 'error';
 }
Exemple #15
0
 function handleQDCForm($form_values)
 {
     $dom = new DomDocument("1.0", "UTF-8");
     $dom->formatOutput = true;
     $pid = $form_values['pid'];
     $rootElement = $dom->createElement("foxml:digitalObject");
     $rootElement->setAttribute('PID', "{$pid}");
     $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#");
     $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
     $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-0.xsd");
     $dom->appendChild($rootElement);
     //create standard fedora stuff
     $this->createStandardFedoraStuff($form_values, $dom, $rootElement);
     //create relationships
     $this->createRelationShips($form_values, $dom, $rootElement);
     //create dublin core
     $this->createQDCStream($form_values, $dom, $rootElement);
     $this->createFedoraDataStreams($form_values, $dom, $rootElement);
     $params = array('objectXML' => $dom->saveXML(), 'format' => "foxml1.0", 'logMessage' => "Fedora Object Ingested");
     try {
         $soapHelper = new ConnectionHelper();
         $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
         if ($client == null) {
             drupal_set_message(t('Error Getting Soap Client.'), 'error');
             return;
         }
         $object = $client->__soapCall('ingest', array($params));
         $deleteFiles = $form_values['delete_file'];
         //remove files from drupal file system
         if ($deleteFiles > 0) {
             foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {
                 unlink($createdFile);
             }
             unlink($form_values['fullpath']);
         }
     } catch (exception $e) {
         drupal_set_message(t('Error Ingesting Object! ' . $e->getMessage()), 'error');
         return;
     }
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $model = new connectionUserVideoModel();
     if (Request::post('id') && Request::post('title')) {
         $video = (int) Request::post('id');
         $title = Request::post('title');
         if (!empty($title)) {
             $model->where(array('id' => $video))->update(array('title' => htmlspecialchars(Request::post('title'))));
         }
     }
     return array('video' => $model->where(array('user' => (int) $user['id']))->sort('date', -1)->fetchAll());
 }
 function execute()
 {
     $model = new connectionUserMessageModel();
     $user = ConnectionHelper::userLogin();
     $message = $model->getUserMessage($user['id'], Request::get('message_id'));
     if (!$message) {
         $this->showNotFound();
         return;
     }
     if ($message['type'] == 'inbox') {
         $model->setState($message['id'], 'readed');
     }
     return array('message' => $message);
 }
 function execute()
 {
     $photo_id = (int) Request::post('photo');
     if ($photo_id == 0) {
         return false;
     }
     $model = new connectionUserPhotoModel();
     $photo = $model->getPhotoByID($photo_id);
     $user = ConnectionHelper::userLogin();
     if (!$photo || isset($photo['avatar']) && $photo['avatar'] || $photo['user_id'] != $user['id']) {
         return false;
     }
     return $model->deletePhoto($photo_id);
 }
 function execute()
 {
     $photo_id = Request::get('photo_id');
     $photo_type = Request::get('photo_type');
     $model = new connectionUserPhotoModel();
     if (!in_array($photo_type, array_keys($model->dir))) {
         $this->notFound();
     }
     $photo = $model->getPhotoByID($photo_id);
     if (!$photo) {
         $this->notFound();
     }
     return ConnectionHelper::getPhotoDir($photo['user_id']) . $model->dir[$photo_type] . '/' . $photo['file'];
 }
 function execute()
 {
     $videoID = (int) Request::post('id');
     $model = new connectionUserVideoModel();
     $video = $model->where(array('id' => $videoID))->fetchOne();
     if (!$video) {
         return array('status' => 'error');
     }
     $user = ConnectionHelper::userLogin();
     if ($video['user'] != $user['id']) {
         return array('status' => 'error');
     }
     $model->where(array('id' => $videoID))->delete();
     return array('status' => 'success');
 }
 function execute()
 {
     $id = Request::post('id');
     $model = new connectionUserAttachmentModel();
     $login = ConnectionHelper::userLogin();
     $result = array('code' => $id);
     $file = Request::files('attach');
     if (sizeof($file) > 0) {
         $id = $model->addFile($file[0], $login['id']);
         if ($id) {
             $result['id'] = $id;
             $result['url'] = '/attachment/size-50/' . $id;
         }
     }
     return $result;
 }
 function execute()
 {
     if (Request::get('delete_attach') && Request::get('file')) {
         $user = ConnectionHelper::userLogin();
         $key = 'field_' . (int) Request::get('delete_attach');
         if (isset($user[$key])) {
             foreach ($user[$key] as $index => $value) {
                 if ($value['file'] == Request::get('file')) {
                     unset($user[$key][$index]);
                 }
             }
             connectionUserModel::create()->where(array('id' => (int) $user['id']))->update(array($key => array_values($user[$key])));
         }
     }
     $model = new connectionFieldsModel();
     return array('fields' => $model->getGroupLocale('info', Language::getActiveLanguageISO()));
 }
 function execute()
 {
     if (ConnectionHelper::isLogin()) {
         Request::redirect('/profile/');
     }
     $this->setSeoPage('login');
     if (!Request::post('login')) {
         return;
     }
     $model = new connectionUserModel();
     $result = $model->login(array('login' => Request::post('login'), 'password' => Request::post('password')));
     if ($result) {
         Request::redirect('/profile/');
     } else {
         Request::get('error_login', true);
     }
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $id = Request::params('video_id');
     if (!$id) {
         return array('status' => 'error', 'message' => '[`Title error view video not found`]');
     }
     $video = connectionUserVideoModel::create()->where(array('id' => (int) $id))->fetchOne();
     if (!$video) {
         return array('status' => 'error', 'message' => '[`Title error view video not found`]');
     }
     if ($video['status'] != 'published' && $video['user'] != $user['id']) {
         return array('status' => 'error', 'message' => '[`Title error view video not permission`]');
     }
     $file = '/me-uploads/connection/user_video/user' . $video['user'] . '/' . $video['id'] . '/video.flv';
     return array('status' => 'success', 'file' => $file, 'title' => $video['title']);
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $response = array('result' => '[`Title profile change password success`]');
     if (!$user || !Request::post('old_password') || !Request::post('new_password') || !Request::post('repeat_password')) {
         return array('result' => '[`Title profile change password error`]');
     }
     if (md5(Request::post('old_password')) != $user['password'] || Request::post('new_password') != Request::post('repeat_password')) {
         return array('result' => '[`Title profile change password error`]');
     }
     $model = new connectionUserModel();
     $password = Request::post('new_password');
     if (!Validator::Field($password, $model->regFields['password'])) {
         return array('result' => '[`Title profile change password error`]');
     }
     $model->changePassword($user['id'], $password);
     return $response;
 }
 function execute()
 {
     $video = new ConnectionVideo();
     if (!Request::files('Filedata')) {
         return array('status' => 'error');
     }
     $result = $video->download('Filedata');
     if (!$result) {
         return array('status' => 'error');
     }
     $file = Request::files('Filedata');
     $model = new connectionUserVideoModel();
     $user = ConnectionHelper::userLogin();
     $userModel = new connectionUserModel();
     $videoID = $model->insert(array('file' => $result, 'status' => 'upload', 'user' => (int) $user['id'], 'date' => strtotime('now'), 'title' => htmlspecialchars($file[0]['name'])));
     $userModel->addHistory($user['id'], connectionUserModel::HISTORY_ADD_VIDEO, '', array('video' => (int) $videoID));
     Route::exec('php ' . MAIN_DIR . DS . 'cli.php connection ConvertVideo cli ' . $videoID);
     return array('status' => 'success');
 }
 function execute()
 {
     $files = Request::files('photo');
     if (!$files || sizeof($files) == 0) {
         return;
     }
     $user = ConnectionHelper::userLogin();
     $uploadDir = ConnectionHelper::getPhotoDir($user['id']);
     $model = new connectionUserPhotoModel();
     File::mkdir($uploadDir);
     foreach ($files as $file) {
         $file_info = pathinfo($file['name']);
         if (!in_array(strtolower($file_info['extension']), array('png', 'jpeg', 'jpg', 'gif'))) {
             continue;
         }
         $file_name = uniqid() . strtotime('now') . md5(rand()) . '.' . $file_info['extension'];
         File::upload($file, $uploadDir, $file_name);
         $model->addPhoto($user['id'], $file_name);
     }
 }
 function execute()
 {
     $search = Request::post('search');
     $searchUser = ConnectionSearchUser::create();
     $saveTemp = false;
     $user = ConnectionHelper::userLogin();
     if (ConnectionHelper::isLogin() && !$search) {
         $saveTemp = Temp::get('user_' . $user['id'] . '_advanced_filter');
         $saveTemp = $saveTemp ? unserialize($saveTemp) : false;
     }
     if (!$saveTemp) {
         $saveTemp = array('query' => $search, 'filter' => $searchUser->filterSearchField($search));
         if (ConnectionHelper::isLogin()) {
             Temp::set('user_' . $user['id'] . '_advanced_filter', serialize($saveTemp));
         }
     }
     $this->setSeoPage('advanced_search');
     if ($search || true) {
         print_r($saveTemp);
     }
 }
 function execute()
 {
     $user = ConnectionHelper::userLogin();
     $mail = Request::post('mail');
     if (!$mail || !isset($mail['to']) || !isset($mail['text']) || empty($mail['text'])) {
         return array('status' => 'error', 'message' => '[`Title error private message send`]');
     }
     $model = new connectionUserMessageModel();
     $count = connectionMessageModel::create()->getDialogMessageCount($user['id'], $mail['to']);
     if ($count > 0) {
         $result = connectionUserBalanceModel::create()->operation((int) $user['id'], -(double) Settings::getValue('price_message', 'connection'), connectionUserBalanceModel::OPERATION_REASON_PRIVATE_MESSAGE);
         if (!$result) {
             return array('status' => 'error', 'message' => '[`Title error private message send balance`]');
         }
     }
     $message = $model->send($mail['to'], $mail['text'], isset($mail['attachment']) && is_array($mail['attachment']) ? array_unique($mail['attachment']) : array());
     if ($count > 0) {
         connectionUserBalanceModel::create()->where(array('id' => (int) $result))->update(array('param' => array('message' => (int) $message)));
     }
     return array('status' => 'success', 'message' => '[`Title success private message send`]');
 }
 function execute()
 {
     if (ConnectionHelper::isLogin()) {
         Request::redirect('/profile/');
     }
     $this->setSeoPage('registration');
     if (!Request::post('registration')) {
         return;
     }
     $model = new connectionUserModel();
     $registration = $model->registration(array('first_name' => Request::post('first_name'), 'last_name' => Request::post('last_name'), 'email' => Request::post('email'), 'password' => Request::post('password'), 'sex' => Request::post('sex'), 'birth_day' => (int) Request::post('birth_day'), 'birth_month' => (int) Request::post('birth_month'), 'birth_year' => (int) Request::post('birth_year'), 'country' => (int) Request::post('country')));
     $status = 'error';
     $message = '[`Title success registration`]';
     if ($registration) {
         $status = 'success';
     } else {
         $message = '[`Title error in registration`]';
     }
     echo json_encode(array('status' => $status, 'message' => $message));
     $this->endAction();
 }